├── .gitignore ├── LICENSE ├── Printer ├── Printer.sln ├── Printer │ ├── API.cs │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Newtonsoft.Json.Net35.dll │ ├── Newtonsoft.Json.Net35.xml │ ├── Printer.csproj │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Resources │ │ ├── 20130822001448_QiwCM.thumb.600_0.jpeg │ │ ├── Thumbs.db │ │ ├── backphoto.jpg │ │ ├── default-printer.png │ │ ├── favicon.ico │ │ ├── git_message.png │ │ ├── logo.png │ │ ├── logo_500.png │ │ ├── printer-setting.png │ │ ├── refresh.png │ │ └── 未标题-1.png │ ├── ToJsonMy.cs │ ├── backgroundworker_refresh.cs │ ├── database.cs │ ├── datatype.cs │ ├── display.cs │ ├── download_class.cs │ ├── favicon.ico │ ├── location_settings.cs │ ├── login_class.cs │ ├── operation_all_class.cs │ ├── operation_class.cs │ ├── print_class.cs │ └── remember.cs └── output │ ├── Newtonsoft.Json.Net35.dll │ ├── Newtonsoft.Json.Net35.xml │ ├── Printer.exe │ ├── Spire.License.dll │ ├── Spire.License.xml │ ├── Spire.Pdf.dll │ └── Spire.Pdf.xml ├── README.md └── 技术文档.docx /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /Printer/Printer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Printer", "Printer\Printer.csproj", "{6809AF42-5941-492C-8924-24AEF0538932}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | output|Any CPU = output|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {6809AF42-5941-492C-8924-24AEF0538932}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 | {6809AF42-5941-492C-8924-24AEF0538932}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 | {6809AF42-5941-492C-8924-24AEF0538932}.output|Any CPU.ActiveCfg = output|Any CPU 16 | {6809AF42-5941-492C-8924-24AEF0538932}.output|Any CPU.Build.0 = output|Any CPU 17 | {6809AF42-5941-492C-8924-24AEF0538932}.Release|Any CPU.ActiveCfg = Release|Any CPU 18 | {6809AF42-5941-492C-8924-24AEF0538932}.Release|Any CPU.Build.0 = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(SolutionProperties) = preSolution 21 | HideSolutionNode = FALSE 22 | EndGlobalSection 23 | EndGlobal 24 | -------------------------------------------------------------------------------- /Printer/Printer/API.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Windows.Forms; 4 | using System.Net; 5 | using System.IO; 6 | namespace Printer 7 | { 8 | class API 9 | { 10 | public static string sid = ""; 11 | public static int myPage=1; 12 | private static string server_url = Program.serverUrl; 13 | public static string PutMethod(string metodUrl, string para, Encoding dataEncode) 14 | { 15 | string down = server_url + metodUrl; 16 | //string down = @"http://yunyin.org/api.php/Index/put"; 17 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(down); 18 | if (sid != "") 19 | { 20 | request.Headers.Add("Session-ID",sid ); 21 | } 22 | request.Method = "PUT"; 23 | string s = "1"; 24 | //HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 25 | 26 | request.Accept = "Accept: application/json"; 27 | try 28 | { 29 | //byte[] byteArray = dataEncode.GetBytes(para); //转化 30 | //request.ContentType = "application/x-www-form-urlencoded"; 31 | //request.Accept = "Accept: application/json"; 32 | //request.ContentLength = byteArray.Length; 33 | //Stream newStream = request.GetRequestStream(); 34 | //newStream.Write(byteArray, 0, byteArray.Length);//写入参数 35 | //newStream.Close(); 36 | 37 | //Console.WriteLine("\nThe HttpHeaders are \n\n\tName\t\tValue\n{0}", request.Headers); 38 | //HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 39 | //StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default); 40 | //s = sr.ReadToEnd(); 41 | //sr.Close(); 42 | //response.Close(); 43 | //newStream.Close(); 44 | using (StreamWriter writer = new StreamWriter(request.GetRequestStream())) 45 | { 46 | writer.Write(para); 47 | } 48 | HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 49 | using (StreamReader reader = new StreamReader(response.GetResponseStream())) 50 | { 51 | //while (reader.Peek() != -1) 52 | //{ 53 | // Console.WriteLine(reader.ReadLine()); 54 | //} 55 | s = reader.ReadToEnd(); 56 | reader.Close(); 57 | } 58 | } 59 | catch (Exception ex) 60 | { 61 | MessageBox.Show(ex.Message); 62 | } 63 | return s; 64 | 65 | } 66 | 67 | public static string DeleteMethod(string metodUrl) 68 | { 69 | string s = "1"; 70 | 71 | string url = server_url + metodUrl; 72 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 73 | request.Accept = "Accept: Application/json"; 74 | request.Method = "delete"; 75 | HttpWebResponse response = null; 76 | try 77 | { 78 | response = (HttpWebResponse)request.GetResponse(); 79 | } 80 | catch (WebException e) 81 | { 82 | response = (HttpWebResponse)e.Response; 83 | MessageBox.Show(e.Message + " - " + getRestErrorMessage(response)); 84 | return default(string); 85 | } 86 | return s; 87 | } 88 | 89 | //GetMEthod用来完成Accept: application/json 90 | /// 91 | /// GetMEthod用来完成Accept: application/json(string metodUrl) 92 | /// 93 | /// 94 | /// 95 | public static string GetMethod(string metodUrl) 96 | { 97 | string down = server_url + metodUrl; 98 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(down); 99 | if (sid!="") 100 | { 101 | request.Headers.Add("Session-ID", sid);//修改Headers,添加 102 | } 103 | request.Referer = "http://printer.yunyin.org"; 104 | request.Method = "get"; 105 | request.Accept = "Accept: application/json"; 106 | //request.ContentType = "application/json;charset=UTF-8"; 107 | HttpWebResponse response = null; 108 | try 109 | { 110 | response = (HttpWebResponse)request.GetResponse(); 111 | } 112 | catch (WebException e) 113 | { 114 | response = (HttpWebResponse)e.Response; 115 | MessageBox.Show(e.Message + " - " + getRestErrorMessage(response)); 116 | return default(string); 117 | } 118 | // 119 | //Console.WriteLine("\nThe HttpHeaders are \n\n\tName\t\tValue\n{0}", request.Headers); 120 | string json = getResponseString(response); 121 | return json; 122 | } 123 | 124 | // REST @GET 方法,根据泛型自动转换成实体,支持List 125 | /// 126 | /// REST @GET 方法,根据泛型自动转换成实体,支持List(string metodUrl) 127 | /// 128 | /// 129 | /// 130 | public static string doGetMethodToObj(string metodUrl) 131 | { 132 | string down = server_url + metodUrl; 133 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(down); 134 | request.Method = "get"; 135 | request.Accept = "Accept:application/json"; 136 | request.ContentType = "application/json;charset=UTF-8"; 137 | HttpWebResponse response = null; 138 | try 139 | { 140 | response = (HttpWebResponse)request.GetResponse(); 141 | } 142 | catch (WebException e) 143 | { 144 | response = (HttpWebResponse)e.Response; 145 | MessageBox.Show(e.Message + " - " + getRestErrorMessage(response)); 146 | return default(string); 147 | } 148 | 149 | string json = getResponseString(response); 150 | return json; 151 | } 152 | 153 | //post方法来从服务器访问数据 154 | /// 155 | /// post方法来从服务器访问数据 156 | /// 157 | /// 158 | /// 159 | /// 160 | /// 161 | public static string PostMethod(string postUrl, string paramData, Encoding dataEncode) 162 | { 163 | postUrl = server_url + postUrl; 164 | string ret = string.Empty; 165 | try 166 | { 167 | byte[] byteArray = dataEncode.GetBytes(paramData); //转化 168 | HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); 169 | webReq.Method = "POST"; 170 | webReq.ContentType = "application/x-www-form-urlencoded"; 171 | webReq.Accept = "Accept: application/json"; 172 | webReq.ContentLength = byteArray.Length; 173 | Stream newStream = webReq.GetRequestStream(); 174 | newStream.Write(byteArray, 0, byteArray.Length);//写入参数 175 | newStream.Close(); 176 | HttpWebResponse response = (HttpWebResponse)webReq.GetResponse(); 177 | StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8); 178 | ret = sr.ReadToEnd(); 179 | sr.Close(); 180 | response.Close(); 181 | newStream.Close(); 182 | } 183 | catch (Exception ex) 184 | { 185 | MessageBox.Show(ex.Message); 186 | } 187 | return ret; 188 | } 189 | 190 | public static string PostMethod_noparam(string postUrl,Encoding dataEncode) 191 | { 192 | postUrl = server_url + postUrl; 193 | string ret = string.Empty; 194 | 195 | try 196 | { 197 | //byte[] byteArray = dataEncode.GetBytes(paramData); //转化 198 | HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); 199 | webReq.Method = "POST"; 200 | webReq.ContentType = "application/x-www-form-urlencoded"; 201 | webReq.Accept = "Accept: application/json"; 202 | if (sid != "") 203 | { 204 | webReq.Headers.Add("Session-ID", sid);//修改Headers,添加 205 | } 206 | HttpWebResponse response = (HttpWebResponse)webReq.GetResponse(); 207 | using (StreamReader sr = new StreamReader(response.GetResponseStream())) 208 | { 209 | ret = sr.ReadLine(); 210 | sr.Close(); 211 | } 212 | 213 | response.Close(); 214 | 215 | } 216 | catch (Exception ex) 217 | { 218 | MessageBox.Show(ex.Message); 219 | } 220 | return ret; 221 | } 222 | 223 | private static string getResponseString(HttpWebResponse response) 224 | { 225 | string json = null; 226 | using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"))) 227 | { 228 | json = reader.ReadToEnd(); 229 | } 230 | return json; 231 | } 232 | // 获取异常信息 233 | /// 234 | /// 获取异常信息 235 | /// 236 | /// 237 | /// 238 | private static string getRestErrorMessage(HttpWebResponse errorResponse) 239 | { 240 | string errorhtml = getResponseString(errorResponse); 241 | string errorkey = "spi.UnhandledException:"; 242 | errorhtml = errorhtml.Substring(errorhtml.IndexOf(errorkey) + errorkey.Length); 243 | errorhtml = errorhtml.Substring(0, errorhtml.IndexOf("\n")); 244 | return errorhtml; 245 | } 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /Printer/Printer/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Threading; 10 | using System.Security.Cryptography; 11 | using Newtonsoft.Json.Linq; 12 | using System.IO; 13 | using System.Net; 14 | using Spire.Pdf; 15 | using Spire.Pdf.Annotations; 16 | using Spire.Pdf.Widget; 17 | using System.Drawing.Printing; 18 | using System.Runtime.InteropServices; 19 | 20 | namespace Printer 21 | { 22 | public partial class login_download : Form 23 | { 24 | /// 25 | /// 窗体构造函数 26 | /// 27 | public login_download() 28 | { 29 | 30 | InitializeComponent(); 31 | this.Size = new Size(300, 300); 32 | } 33 | /// 34 | /// 窗体生成后执行控件的显示 35 | /// 36 | /// 37 | /// 38 | private void login_download_Load(object sender, EventArgs e) 39 | { 40 | this.FormBorderStyle = FormBorderStyle.FixedSingle; 41 | this.MaximizeBox = false; 42 | login.Visible = true; //登录控件可见 43 | download.Visible = false; //下载控件隐藏 44 | login.Enabled = true; //登录控件使能 45 | checkbox.Checked = true; 46 | notifyIcon1.Visible = true; 47 | login_class.myLogin = remember.ReadTextFileToList(@"pwd.sjc"); 48 | if (login_class.myLogin.Count == 2) 49 | { 50 | password.Text = login_class.myLogin[0]; 51 | printerAcount.Text = login_class.myLogin[1]; 52 | } 53 | } 54 | //----------------------------------------------------------------------------------------- 55 | 56 | //关于登录panel的所有代码 57 | 58 | //----------------------------------------------------------------------------------------- 59 | 60 | 61 | 62 | //定义委托,执行控件的线程操作 63 | private delegate void boxDelegate(Control ctrl, string str, bool visuable, bool enable); 64 | boxDelegate my1; 65 | public string display_mode = "mode_all"; 66 | 67 | 68 | /// 69 | /// 用于控件的切换委托 70 | /// 71 | /// 72 | /// 73 | /// 74 | /// 75 | private void boxChange(Control ctrl, string str, bool visuable, bool enable) 76 | { 77 | ctrl.Text = str; ctrl.Visible = visuable; ctrl.Enabled = enable; 78 | } 79 | 80 | 81 | /// 82 | /// 执行登录线程 83 | /// 84 | /// 85 | /// 86 | private void loginbutton_Click_1(object sender, EventArgs e) 87 | { 88 | loginbutton.Enabled = false; //关闭登录按钮使能 89 | load(); 90 | } 91 | 92 | 93 | /// 94 | /// 执行登录函数 95 | /// 96 | private void load() 97 | { 98 | login_class.type = "2"; //打印店的type为2 99 | List myRem = new List(); //此处可以进行修改和简化 100 | if (printerAcount.Text.Length == 0 || password.Text.Length == 0) 101 | { 102 | if (error.InvokeRequired) 103 | { 104 | my1 = new boxDelegate(boxChange); 105 | error.Invoke(my1, new object[] { error, "请输入您的个人信息", true, true }); 106 | loginbutton.Invoke(my1, new object[] { loginbutton, "登录", true, true }); 107 | Thread.Sleep(100); 108 | } 109 | else 110 | { 111 | error.Text = "请输入您的个人信息"; 112 | error.Visible = true; 113 | loginbutton.Enabled = true; 114 | } 115 | } 116 | else 117 | { 118 | IAsyncResult result = login_class.login_del.BeginInvoke(printerAcount.Text, password.Text, null, null); 119 | string r = login_class.login_del.EndInvoke(result); 120 | login_to_show(r); 121 | } 122 | } 123 | 124 | public void login_to_show(string r) 125 | { 126 | List myRem = new List(); 127 | if (r.Contains("sid")) 128 | { 129 | JObject toke = JObject.Parse(r); 130 | location_settings.my.sid = (string)toke["info"]["sid"];//也能够得到token 131 | location_settings.my.name = (string)toke["info"]["printer"]["name"]; 132 | location_settings.my.id = (string)toke["info"]["printer"]["id"]; 133 | location_settings.my.sch_id = (string)toke["info"]["printer"]["sch_id"]; 134 | API.sid = location_settings.my.sid; 135 | //判断是否保存用户名 136 | if (checkbox.Checked) 137 | { 138 | myRem.Add(login_class.password_save); 139 | myRem.Add(printerAcount.Text); 140 | } 141 | File.WriteAllText(@"pwd.sjc", ""); 142 | remember.WriteListToTextFile(myRem, @"pwd.sjc"); 143 | if (remember.ReadTextFileToString(@"data_frompage.sjc") != "") 144 | { 145 | database.number_nouse_page = remember.ReadTextFileToString(@"data_frompage.sjc"); 146 | } 147 | showdownload(); //传递参数,显示下载控件 148 | timer_init(); 149 | } 150 | else 151 | { 152 | //登录失败 153 | 154 | if (error.InvokeRequired) 155 | { 156 | my1 = new boxDelegate(boxChange); 157 | error.Invoke(my1, new object[] { error, "登陆失败,请重新登录!", true, true }); 158 | loginbutton.Invoke(my1, new object[] { loginbutton, "登录", true, true }); 159 | Thread.Sleep(100); 160 | } 161 | else 162 | { 163 | error.Text = "登陆失败,请重新登录!"; 164 | error.Visible = true; 165 | loginbutton.Enabled = true; 166 | } 167 | } 168 | 169 | } 170 | 171 | 172 | /// 173 | /// 退出程序 174 | /// 175 | /// 176 | /// 177 | private void exitbutton_Click(object sender, EventArgs e) 178 | { 179 | this.Close(); 180 | Application.Exit(); 181 | } 182 | 183 | //----------------------------------------------------------------- 184 | 185 | //panel切换函数 186 | 187 | //----------------------------------------------------------------- 188 | 189 | 190 | private void showdownload() 191 | { 192 | 193 | login.Hide(); 194 | this.Size = new Size(1300, 400); 195 | this.Location = new Point(50, 200); 196 | this.FormBorderStyle = FormBorderStyle.Sizable; 197 | set_default_printer.Hide(); 198 | printers_setting_dialog.Hide(); 199 | exit_panel.Hide(); 200 | this.MaximizeBox = true; 201 | download.Show(); 202 | 203 | String Date = (DateTime.Now.ToLongDateString()); 204 | //location_settings.file_path = @"D:\云印南开\" + Date; 205 | location_settings.file_path = @"D:\云印南天\" ; 206 | location_settings.ibook_path = @"D:\云印南天\电子书\"; 207 | location_settings.creat_path(); 208 | 209 | backgroundworker_refresh br = new backgroundworker_refresh(this); 210 | br.refresh_first(); 211 | 212 | } 213 | 214 | 215 | 216 | 217 | //----------------------------------------------------------------- 218 | 219 | //关于下载panel的所有代码 220 | 221 | //----------------------------------------------------------------- 222 | 223 | 224 | private static System.Timers.Timer aTimer; 225 | 226 | /// 227 | /// 编辑改变状态按钮函数 228 | /// 229 | /// 230 | /// 231 | private void mydata_CellContentClick(object sender, DataGridViewCellEventArgs e) 232 | { 233 | if (e.RowIndex >= 0) 234 | { 235 | //if (e.ColumnIndex == mydata.Columns["operation"].Index) 236 | string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString(); 237 | ToJsonMy file = database.find_myjson(id); 238 | string buttonText = this.mydata.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); 239 | switch (buttonText) 240 | { 241 | case "确认支付": 242 | //DialogResult dr = MessageBox.Show("确认付款?", "", MessageBoxButtons.YesNo); 243 | //if (dr == DialogResult.Yes) 244 | //{ 245 | // file.ensure_payed(); 246 | // mydata.Rows.Remove(mydata.Rows[e.RowIndex]); 247 | //} 248 | operation_EnsurePayed_class operation6 = new operation_EnsurePayed_class(this, file, e.RowIndex); 249 | operation6.do_operation(); 250 | break; 251 | case "备注信息": 252 | operation_GetRequirements_class getrequirements_class = new operation_GetRequirements_class(this, file, e.RowIndex); 253 | getrequirements_class.do_operation(); 254 | break; 255 | case "确认打印完成": 256 | operation_TellPrinted_class tellprinted = new operation_TellPrinted_class(this, file, e.RowIndex); 257 | tellprinted.do_operation(); 258 | break; 259 | case "手动下载": 260 | //download_errfile_class download_class = new download_errfile_class(this, file, e.RowIndex); 261 | //download_class.download(); 262 | operation_ErrDownload_class operation1 = new operation_ErrDownload_class(this, file, e.RowIndex); 263 | operation1.do_operation(); 264 | break; 265 | case "取消订单": 266 | operation_cancel_class operation5 = new operation_cancel_class(this, file, e.RowIndex); 267 | operation5.do_operation(); 268 | break; 269 | case "打开源文件": 270 | operation_GetRowFile_class operation7 = new operation_GetRowFile_class(this, file, e.RowIndex); 271 | operation7.do_operation(); 272 | break; 273 | case "一键打印": 274 | operation_PrintDirect_class operation2 = new operation_PrintDirect_class(this, file, e.RowIndex); 275 | operation2.do_operation(); 276 | break; 277 | case "设置后打印": 278 | operation_PrintAfterSet_class operation3 = new operation_PrintAfterSet_class(this, file, e.RowIndex); 279 | operation3.do_operation(); 280 | break; 281 | case "重新下载": 282 | operation_ReDownload_class operation4 = new operation_ReDownload_class(this, file, e.RowIndex); 283 | operation4.do_operation(); 284 | break; 285 | } 286 | } 287 | } 288 | 289 | /// 290 | /// 手动刷新,同时进行手动下载 291 | /// 292 | /// 293 | /// 294 | private void refresh_Click(object sender, EventArgs e) 295 | { 296 | backgroundworker_refresh br = new backgroundworker_refresh(this); 297 | br.refresh_other(); 298 | } 299 | 300 | private void 版本信息ToolStripMenuItem_Click(object sender, EventArgs e) 301 | { 302 | MessageBox.Show("云印南开打印店客户端"); 303 | } 304 | 305 | /// 306 | /// 双击打开文件,若不存在,则自动下载,双击ID显示用户基本信息 307 | /// 308 | /// 309 | /// 310 | private void mydata_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) 311 | { 312 | if (e.RowIndex >= 0) 313 | { 314 | //if (e.ColumnIndex == mydata.Columns["operation"].Index) 315 | string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString(); 316 | ToJsonMy file = database.find_myjson(id); 317 | //string buttonText = this.mydata.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); 318 | //string buttonText1 = this.mydata.Rows[e.RowIndex].Cells[e.ColumnIndex].ToString(); 319 | 320 | switch (e.ColumnIndex) 321 | { 322 | case 5: 323 | operation_OpenFile_class openfile_class = new operation_OpenFile_class(this, file, e.RowIndex); 324 | openfile_class.do_operation(); 325 | break; 326 | case 6: 327 | operation_GetRequirements_class getrequirements_class = new operation_GetRequirements_class(this, file, e.RowIndex); 328 | getrequirements_class.do_operation(); 329 | break; 330 | case 7: 331 | operation_GetUserinfo_class GetUserInfo_class = new operation_GetUserinfo_class(this, file, e.RowIndex); 332 | GetUserInfo_class.do_operation(); 333 | break; 334 | default: 335 | break; 336 | } 337 | // if ((e.ColumnIndex >= 1) && (e.ColumnIndex < 2)) 338 | // { 339 | // string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString(); 340 | // ToJsonMy file = database.find_myjson(id); 341 | 342 | // userInfo user = new userInfo(); 343 | // user = usermessage(file.use_id); 344 | // MessageBox.Show("用户:" + user.name + " 学号:" + user.student_number + " 手机号:" + user.phone); 345 | 346 | // } 347 | 348 | // else if ((e.ColumnIndex >= 2) && (e.ColumnIndex < 3)) 349 | // { 350 | // string id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString(); 351 | // ToJsonMy file = database.find_myjson(id); 352 | // if (file != null) 353 | // { 354 | // if (!file.is_ibook) 355 | // { 356 | // string filename = ""; 357 | // filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; 358 | 359 | // string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); 360 | // if (doc_extension != ".pdf") 361 | // { 362 | // filename += ".pdf"; 363 | // } 364 | 365 | // if (File.Exists(@filename)) 366 | // { 367 | // System.Diagnostics.Process.Start(filename); 368 | 369 | // } 370 | // else 371 | // { 372 | // download_single_single_class file_download = new download_single_single_class(this, file); 373 | // file_download.download(); 374 | // } 375 | 376 | // } 377 | // else 378 | // { 379 | // string filename = ""; 380 | // filename = location_settings.ibook_path + file.name.Substring(0, file.name.Length - "【店内书】".Length); 381 | // if (File.Exists(@filename)) 382 | // { 383 | // System.Diagnostics.Process.Start(filename); 384 | 385 | // } 386 | // else 387 | // { 388 | // MessageBox.Show("本店电子书路径有误,请改正"); 389 | // } 390 | 391 | // } 392 | // } 393 | 394 | // } 395 | } 396 | } 397 | 398 | private void 一分钟ToolStripMenuItem_Click(object sender, EventArgs e) 399 | { 400 | aTimer.Interval = 60 * 1000; 401 | 一分钟ToolStripMenuItem.Checked = true; 402 | 十分钟ToolStripMenuItem.Checked = false; 403 | 三十分钟ToolStripMenuItem.Checked = false; 404 | } 405 | 406 | private void 十分钟ToolStripMenuItem_Click(object sender, EventArgs e) 407 | { 408 | aTimer.Interval = 60 * 1000 * 10; 409 | 一分钟ToolStripMenuItem.Checked = false; 410 | 十分钟ToolStripMenuItem.Checked = true; 411 | 三十分钟ToolStripMenuItem.Checked = false; 412 | } 413 | 414 | private void 三十分钟ToolStripMenuItem_Click(object sender, EventArgs e) 415 | { 416 | aTimer.Interval = 60 * 1000 * 30; 417 | 一分钟ToolStripMenuItem.Checked = false; 418 | 十分钟ToolStripMenuItem.Checked = false; 419 | 三十分钟ToolStripMenuItem.Checked = true; 420 | } 421 | 422 | /// 423 | /// 获得用户信息 424 | /// 425 | /// 426 | /// 427 | //public userInfo usermessage(string use_id) 428 | //{ 429 | // string jsonUrl = API.GetMethod("/printer/user/" + use_id); 430 | // JObject jo = JObject.Parse(jsonUrl); 431 | // userInfo user = new userInfo(); 432 | // user.name = jo["info"]["name"].ToString(); 433 | // user.sch_id = jo["info"]["sch_id"].ToString(); 434 | // user.student_number = jo["info"]["number"].ToString(); 435 | // jsonUrl = API.GetMethod("/printer/user/" + use_id + "/phone"); 436 | // jo = JObject.Parse(jsonUrl); 437 | // user.phone = jo["info"].ToString(); 438 | // return user; 439 | //} 440 | 441 | /// 442 | /// 增加最小化到托盘 443 | /// 444 | /// 445 | /// 446 | private void login_download_FormClosing(object sender, FormClosingEventArgs e) 447 | { 448 | //注意判断关闭事件Reason来源于窗体按钮,否则用菜单退出时无法退出! 449 | if (e.CloseReason == CloseReason.UserClosing) 450 | { 451 | ensure_notifyIcon.Checked = true; 452 | exit_panel.Show(); 453 | e.Cancel = true; 454 | //this.WindowState = FormWindowState.Minimized; //使关闭时窗口向右下角缩小的效果 455 | //notifyIcon1.Visible = true; 456 | //this.ShowInTaskbar = false; 457 | 458 | } 459 | } 460 | 461 | /// 462 | /// 双击托盘打开窗口 463 | /// 464 | /// 465 | /// 466 | private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) 467 | { 468 | if (this.WindowState == FormWindowState.Minimized) 469 | { 470 | this.WindowState = FormWindowState.Normal; 471 | 472 | this.Focus(); 473 | this.ShowInTaskbar = true; 474 | } 475 | } 476 | 477 | /// 478 | /// 托盘右键关闭退出程序 479 | /// 480 | /// 481 | /// 482 | private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e) 483 | { 484 | //database.write_data_frompage(); 485 | this.Close(); 486 | Application.Exit(); 487 | } 488 | 489 | /// 490 | /// 如果有备注信息则显示 491 | /// 492 | /// 493 | /// 494 | //private void requirements_Click(object sender, EventArgs e) 495 | //{ 496 | // string current_id = mydata.Rows[mydata.CurrentRow.Index].Cells["id"].Value.ToString(); 497 | // ToJsonMy file = database.find_myjson(current_id); 498 | // if (file != null) 499 | // { 500 | // if (file.requirements != null) 501 | // { 502 | // MessageBox.Show(file.requirements, "备注信息"); 503 | // } 504 | // } 505 | // //} 506 | 507 | //} 508 | 509 | ///// 510 | ///// 单击后判断该文件是否有备注信息 511 | ///// 512 | ///// 513 | ///// 514 | //private void mydata_CellClick(object sender, DataGridViewCellEventArgs e) 515 | //{ 516 | // if ((e.ColumnIndex > -1) && (e.RowIndex > -1)) 517 | // { 518 | // string current_id = mydata.Rows[e.RowIndex].Cells["id"].Value.ToString(); 519 | // ToJsonMy file = database.find_myjson(current_id); 520 | // if (file != null) 521 | // { 522 | // if (file.requirements == "") 523 | // { 524 | // requirements.Visible = false; 525 | // } 526 | // else 527 | // { 528 | // requirements.Visible = true; 529 | // } 530 | // } 531 | 532 | // } 533 | //} 534 | 535 | private void dicret_download_Click(object sender, EventArgs e) 536 | { 537 | //try 538 | //{ 539 | 540 | // string current_id = mydata.Rows[mydata.CurrentRow.Index].Cells["id"].Value.ToString(); 541 | // ToJsonMy file = database.find_myjson(current_id); 542 | // if (file != null) 543 | // { 544 | // if (!file.is_ibook) 545 | // { 546 | // string filename = ""; 547 | // filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; 548 | 549 | // string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); 550 | // if ((doc_extension == ".doc") || (doc_extension == ".docx")) 551 | // { 552 | // filename += ".pdf"; 553 | // } 554 | // if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) 555 | // { 556 | // filename += ".pdf"; 557 | // throw new Exception("ppt文件请设置文件后打印"); 558 | // } 559 | 560 | // if (File.Exists(@filename)) 561 | // { 562 | 563 | // print_class.direct_print_file(file,this); 564 | // } 565 | // else 566 | // { 567 | // download_single_single_class file_download = new download_single_single_class(this, file); 568 | // file_download.download(); 569 | // } 570 | 571 | // } 572 | // else 573 | // { 574 | // print_class.direct_print_ibook(file,this); 575 | // } 576 | // } 577 | 578 | //} 579 | //catch (Exception excep) 580 | //{ 581 | // MessageBox.Show(excep.Message, "无法打印"); 582 | //} 583 | 584 | 585 | 586 | 587 | 588 | } 589 | 590 | private void 设置默认打印机ToolStripMenuItem_Click(object sender, EventArgs e) 591 | { 592 | foreach (string printname in PrinterSettings.InstalledPrinters) 593 | { 594 | 595 | if (!printer_comboBox.Items.Contains(printname)) 596 | { 597 | printer_comboBox.Items.Add(printname); 598 | 599 | } 600 | } 601 | 602 | set_default_printer.Show(); 603 | } 604 | 605 | private void ensure_printer_Click(object sender, EventArgs e) 606 | { 607 | if (printer_comboBox.SelectedItem != null) 608 | { 609 | if (Externs.SetDefaultPrinter(printer_comboBox.SelectedItem.ToString())) 610 | { 611 | set_default_printer.Hide(); 612 | MessageBox.Show(printer_comboBox.SelectedItem.ToString() + "设置为默认打印机成功!"); 613 | 614 | } 615 | else 616 | { 617 | MessageBox.Show(printer_comboBox.SelectedItem.ToString() + "设置为默认打印机失败!"); 618 | } 619 | } 620 | } 621 | 622 | private void close_printer_Click(object sender, EventArgs e) 623 | { 624 | set_default_printer.Hide(); 625 | } 626 | 627 | class Externs 628 | { 629 | [DllImport("winspool.drv")] 630 | public static extern bool SetDefaultPrinter(String Name); 631 | } 632 | 633 | private void set_before_print_Click(object sender, EventArgs e) 634 | { 635 | //try 636 | //{ 637 | // string current_id = mydata.Rows[mydata.CurrentRow.Index].Cells["id"].Value.ToString(); 638 | // ToJsonMy file = database.find_myjson(current_id); 639 | // if (file != null) 640 | // { 641 | // if (!file.is_ibook) 642 | // { 643 | // string filename = ""; 644 | // filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; 645 | // string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); 646 | // if ((doc_extension == ".doc") || (doc_extension == ".docx")) 647 | // { 648 | // filename += ".pdf"; 649 | 650 | // } 651 | // if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) 652 | // { 653 | // filename += ".pdf"; 654 | // } 655 | // if (File.Exists(@filename)) 656 | // { 657 | // print_class.setbefore_print_file(file, this); 658 | // } 659 | // else 660 | // { 661 | // download_single_single_class file_download = new download_single_single_class(this, file); 662 | // file_download.download(); 663 | // } 664 | // } 665 | // else 666 | // { 667 | // print_class.setbefore_print_ibook(file, this); 668 | // } 669 | // } 670 | //} 671 | //catch (Exception excep) 672 | //{ 673 | // MessageBox.Show(excep.Message, "无法打印"); 674 | //} 675 | } 676 | 677 | public void timer_init() 678 | { 679 | aTimer = new System.Timers.Timer(); 680 | aTimer.Elapsed += new System.Timers.ElapsedEventHandler(theout); 681 | aTimer.Interval = 60000; 682 | aTimer.AutoReset = true; 683 | aTimer.Enabled = true; 684 | } 685 | 686 | public void theout(object source, System.Timers.ElapsedEventArgs e) 687 | { 688 | backgroundworker_refresh br = new backgroundworker_refresh(this); 689 | br.refresh_other(); 690 | } 691 | 692 | private void 打印机设置ToolStripMenuItem_Click(object sender, EventArgs e) 693 | { 694 | printer_setting_dialog_show(); 695 | } 696 | 697 | public void printer_setting_dialog_show() 698 | { 699 | /// 700 | /// 1:对4种情况分别添加计算机有的打印机: 701 | /// 2:如果之前设置过打印机,显示设为默认初值 702 | /// 703 | //List printer_use_list = new List(); 704 | location_settings.printer_setting_list = remember.ReadTextFileToList(@"printer_setting.sjc"); 705 | foreach (string printname in PrinterSettings.InstalledPrinters) 706 | { 707 | 708 | if (!noduplex_nocolor_combox.Items.Contains(printname)) 709 | { 710 | noduplex_nocolor_combox.Items.Add(printname); 711 | } 712 | } 713 | 714 | foreach (string printname in PrinterSettings.InstalledPrinters) 715 | { 716 | 717 | if (!duplex_nocolor_combox.Items.Contains(printname)) 718 | { 719 | duplex_nocolor_combox.Items.Add(printname); 720 | } 721 | } 722 | foreach (string printname in PrinterSettings.InstalledPrinters) 723 | { 724 | 725 | if (!noduplex_color_combox.Items.Contains(printname)) 726 | { 727 | noduplex_color_combox.Items.Add(printname); 728 | } 729 | } 730 | foreach (string printname in PrinterSettings.InstalledPrinters) 731 | { 732 | 733 | if (!duplex_color_combox.Items.Contains(printname)) 734 | { 735 | duplex_color_combox.Items.Add(printname); 736 | } 737 | } 738 | //若果已经存在了保存的打印机选择列表,显示在combox中 739 | int i = 0; 740 | if (location_settings.printer_setting_list.Count == 4) 741 | { 742 | /// 743 | /// 已经有打印店选择的信息后printer_setting.sjc,直接显示在combox中 744 | /// 745 | for (i = 0; i < noduplex_nocolor_combox.Items.Count; i++) 746 | { 747 | if (location_settings.printer_setting_list[0] == noduplex_nocolor_combox.Items[i].ToString()) 748 | { 749 | noduplex_nocolor_combox.SelectedIndex = i; 750 | break; 751 | } 752 | } 753 | for (i = 0; i < duplex_nocolor_combox.Items.Count; i++) 754 | { 755 | if (location_settings.printer_setting_list[1] == duplex_nocolor_combox.Items[i].ToString()) 756 | { 757 | duplex_nocolor_combox.SelectedIndex = i; 758 | break; 759 | } 760 | } 761 | for (i = 0; i < noduplex_color_combox.Items.Count; i++) 762 | { 763 | if (location_settings.printer_setting_list[2] == noduplex_color_combox.Items[i].ToString()) 764 | { 765 | noduplex_color_combox.SelectedIndex = i; 766 | break; 767 | } 768 | } 769 | for (i = 0; i < duplex_color_combox.Items.Count; i++) 770 | { 771 | if (location_settings.printer_setting_list[3] == duplex_color_combox.Items[i].ToString()) 772 | { 773 | duplex_color_combox.SelectedIndex = i; 774 | break; 775 | } 776 | } 777 | } 778 | printers_setting_dialog.Show(); 779 | } 780 | 781 | private void setting_printers_ensure_Click(object sender, EventArgs e) 782 | { 783 | 784 | if ((noduplex_nocolor_combox.SelectedItem != null) && (duplex_nocolor_combox.SelectedItem != null) && (noduplex_color_combox.SelectedItem != null) && (duplex_color_combox.SelectedItem != null)) 785 | { 786 | location_settings.set_printer_setting_list(noduplex_nocolor_combox.SelectedItem.ToString(), duplex_nocolor_combox.SelectedItem.ToString(), noduplex_color_combox.SelectedItem.ToString(), duplex_color_combox.SelectedItem.ToString()); 787 | printers_setting_dialog.Hide(); 788 | MessageBox.Show("打印机设置成功"); 789 | } 790 | else 791 | { 792 | MessageBox.Show("打印机设置失败,请确认已全部设置"); 793 | } 794 | } 795 | 796 | private void setting_printer_exit_Click(object sender, EventArgs e) 797 | { 798 | printers_setting_dialog.Hide(); 799 | } 800 | 801 | private void 自动刷新ToolStripMenuItem_Click(object sender, EventArgs e) 802 | { 803 | 手动刷新ToolStripMenuItem.Checked = false; 804 | 自动刷新ToolStripMenuItem.Checked = true; 805 | aTimer.Enabled = true; 806 | } 807 | 808 | private void 手动刷新ToolStripMenuItem_Click(object sender, EventArgs e) 809 | { 810 | 手动刷新ToolStripMenuItem.Checked = true; 811 | 自动刷新ToolStripMenuItem.Checked = false; 812 | aTimer.Enabled = false; 813 | 814 | } 815 | 816 | private void 所有文件ToolStripMenuItem_Click(object sender, EventArgs e) 817 | { 818 | display_mode = "mode_all"; 819 | 所有文件ToolStripMenuItem.Checked = true; 820 | 未下载文件ToolStripMenuItem.Checked = false; 821 | 已下载文件ToolStripMenuItem.Checked = false; 822 | 打印完成文件ToolStripMenuItem.Checked = false; 823 | 已打印文件ToolStripMenuItem.Checked = false; 824 | mydata.Rows.Clear(); 825 | display.display_list_norefresh(this, database.jsonlist); 826 | 827 | } 828 | 829 | private void 未下载文件ToolStripMenuItem_Click(object sender, EventArgs e) 830 | { 831 | display_mode = "mode_downloading"; 832 | 所有文件ToolStripMenuItem.Checked = false; 833 | 未下载文件ToolStripMenuItem.Checked = true; 834 | 已下载文件ToolStripMenuItem.Checked = false; 835 | 已打印文件ToolStripMenuItem.Checked = false; 836 | 打印完成文件ToolStripMenuItem.Checked = false; 837 | mydata.Rows.Clear(); 838 | display.display_list_norefresh(this, database.jsonlist_err); 839 | 840 | } 841 | 842 | private void 已下载文件ToolStripMenuItem_Click(object sender, EventArgs e) 843 | { 844 | display_mode = "mode_downloaded"; 845 | 所有文件ToolStripMenuItem.Checked = false; 846 | 未下载文件ToolStripMenuItem.Checked = false; 847 | 已下载文件ToolStripMenuItem.Checked = true; 848 | 已打印文件ToolStripMenuItem.Checked = false; 849 | 打印完成文件ToolStripMenuItem.Checked = false; 850 | mydata.Rows.Clear(); 851 | display.display_list_norefresh(this, database.jsonlist_downloaded); 852 | 853 | } 854 | 855 | private void 已打印文件ToolStripMenuItem_Click(object sender, EventArgs e) 856 | { 857 | display_mode = "mode_printing"; 858 | 所有文件ToolStripMenuItem.Checked = false; 859 | 未下载文件ToolStripMenuItem.Checked = false; 860 | 已下载文件ToolStripMenuItem.Checked = false; 861 | 打印完成文件ToolStripMenuItem.Checked = false; 862 | 已打印文件ToolStripMenuItem.Checked = true; 863 | mydata.Rows.Clear(); 864 | display.display_list_norefresh(this, database.jsonlist_printing); 865 | 866 | } 867 | 868 | private void 打印完成文件ToolStripMenuItem_Click(object sender, EventArgs e) 869 | { 870 | display_mode = "mode_printed"; 871 | 所有文件ToolStripMenuItem.Checked = false; 872 | 未下载文件ToolStripMenuItem.Checked = false; 873 | 已下载文件ToolStripMenuItem.Checked = false; 874 | 打印完成文件ToolStripMenuItem.Checked = true; 875 | 已打印文件ToolStripMenuItem.Checked = false; 876 | mydata.Rows.Clear(); 877 | display.display_list_norefresh(this, database.jsonlist_printed); 878 | 879 | } 880 | 881 | private void all_selected_Click(object sender, EventArgs e) 882 | { 883 | for (int i = 0; i < this.mydata.Rows.Count; i++) 884 | { 885 | //if (this.mydata.Rows[i].Cells["select_idex"].Value != (object)true) 886 | //{ 887 | this.mydata.Rows[i].Cells["select_idex"].Value = true; 888 | //} 889 | } 890 | } 891 | 892 | private void none_selected_Click(object sender, EventArgs e) 893 | { 894 | for (int i = 0; i < this.mydata.Rows.Count; i++) 895 | { 896 | this.mydata.Rows[i].Cells["select_idex"].Value = false; 897 | } 898 | } 899 | 900 | private void all_ensure_payed_Click(object sender, EventArgs e) 901 | { 902 | DialogResult dr = MessageBox.Show("全部确认付款?", "", MessageBoxButtons.YesNo); 903 | if (dr == DialogResult.Yes) 904 | { 905 | operation_all_EnsurePayed_class operation_class = new operation_all_EnsurePayed_class(this); 906 | operation_class.do_operation(); 907 | } 908 | 909 | } 910 | 911 | private void all_direct_print_Click(object sender, EventArgs e) 912 | { 913 | operation_all_DirectPrint_class operation_class = new operation_all_DirectPrint_class(this); 914 | operation_class.do_operation(); 915 | } 916 | 917 | private void all_TellPrinted_Click(object sender, EventArgs e) 918 | { 919 | operation_all_TellPrinted_class operation_class = new operation_all_TellPrinted_class(this); 920 | operation_class.do_operation(); 921 | } 922 | 923 | private void all_cancel_Click(object sender, EventArgs e) 924 | { 925 | operation_all_cancel_class operation_class = new operation_all_cancel_class(this); 926 | operation_class.do_operation(); 927 | } 928 | 929 | private void exit_ensure_Click(object sender, EventArgs e) 930 | { 931 | if ((ensure_exit.Checked == true)&&(ensure_notifyIcon.Checked==false)) 932 | { 933 | this.Close(); 934 | Application.Exit(); 935 | } 936 | else if ((ensure_exit.Checked == false) && (ensure_notifyIcon.Checked == true)) 937 | { 938 | //exit_panel.Show(); 939 | //e.Cancel = true; 940 | this.WindowState = FormWindowState.Minimized; //使关闭时窗口向右下角缩小的效果 941 | notifyIcon1.Visible = true; 942 | this.ShowInTaskbar = false; 943 | exit_panel.Hide(); 944 | } 945 | } 946 | 947 | private void exit_close_Click(object sender, EventArgs e) 948 | { 949 | exit_panel.Hide(); 950 | } 951 | 952 | //private void mydata_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) 953 | //{ 954 | 955 | //} 956 | 957 | 958 | 959 | } 960 | } -------------------------------------------------------------------------------- /Printer/Printer/Newtonsoft.Json.Net35.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Newtonsoft.Json.Net35.dll -------------------------------------------------------------------------------- /Printer/Printer/Printer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {6809AF42-5941-492C-8924-24AEF0538932} 8 | WinExe 9 | Properties 10 | Printer 11 | Printer 12 | v3.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | ..\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | true 35 | 36 | 37 | favicon.ico 38 | 39 | 40 | 41 | ..\output\ 42 | false 43 | 44 | 45 | 46 | False 47 | D:\云印\json.NET\Bin\Net35\Newtonsoft.Json.Net35.dll 48 | 49 | 50 | ..\..\..\..\..\..\..\C#\BIN\NET3.5\Spire.Pdf.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | Form 71 | 72 | 73 | Form1.cs 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Form1.cs 86 | 87 | 88 | ResXFileCodeGenerator 89 | Resources.Designer.cs 90 | Designer 91 | 92 | 93 | True 94 | Resources.resx 95 | True 96 | 97 | 98 | SettingsSingleFileGenerator 99 | Settings.Designer.cs 100 | 101 | 102 | True 103 | Settings.settings 104 | True 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /Printer/Printer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | using System.Runtime.InteropServices; 6 | using System.Diagnostics; 7 | using System.Reflection; 8 | 9 | namespace Printer 10 | { 11 | static class Program 12 | { 13 | static public string serverUrl = @"http://api.yunyin.org"; 14 | [DllImport("User32.dll")] 15 | private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); 16 | 17 | [DllImport("User32.dll")] 18 | private static extern bool SetForegroundWindow(IntPtr hWnd); 19 | private const int WS_SHOWNORMAL = 1; 20 | /// 21 | /// 应用程序的主入口点。 22 | /// 23 | [STAThread] 24 | static void Main() 25 | { 26 | Application.EnableVisualStyles(); 27 | Application.SetCompatibleTextRenderingDefault(false); 28 | Process instance = RunningInstance(); 29 | if (instance == null) 30 | { 31 | //Form1 frm = new Form1(); 32 | Application.Run(new login_download()); 33 | } 34 | else 35 | { 36 | HandleRunningInstance(instance); 37 | } 38 | //Application.Run(new login_download()); 39 | } 40 | 41 | public static Process RunningInstance() 42 | { 43 | Process current = Process.GetCurrentProcess(); 44 | Process[] processes = Process.GetProcessesByName(current.ProcessName); 45 | foreach (Process process in processes) 46 | { 47 | if (process.Id != current.Id) 48 | { 49 | if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName) 50 | { 51 | return process; 52 | } 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | public static void HandleRunningInstance(Process instance) 59 | { 60 | ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL); //显示,可以注释掉 61 | SetForegroundWindow(instance.MainWindowHandle); //放到前端 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Printer/Printer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("Printer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Printer")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("61f8f7a9-f47a-46e4-a61a-a556c2700bbe")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Printer/Printer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34014 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Printer.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Printer.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 65 | /// 66 | internal static System.Drawing.Bitmap backphoto { 67 | get { 68 | object obj = ResourceManager.GetObject("backphoto", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 75 | /// 76 | internal static System.Drawing.Bitmap default_printer { 77 | get { 78 | object obj = ResourceManager.GetObject("default_printer", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 85 | /// 86 | internal static System.Drawing.Bitmap git_message { 87 | get { 88 | object obj = ResourceManager.GetObject("git_message", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 95 | /// 96 | internal static System.Drawing.Bitmap printer_setting { 97 | get { 98 | object obj = ResourceManager.GetObject("printer_setting", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 105 | /// 106 | internal static System.Drawing.Bitmap refresh { 107 | get { 108 | object obj = ResourceManager.GetObject("refresh", resourceCulture); 109 | return ((System.Drawing.Bitmap)(obj)); 110 | } 111 | } 112 | 113 | /// 114 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。 115 | /// 116 | internal static System.Drawing.Bitmap 未标题_1 { 117 | get { 118 | object obj = ResourceManager.GetObject("未标题-1", resourceCulture); 119 | return ((System.Drawing.Bitmap)(obj)); 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Printer/Printer/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\未标题-1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Resources\backphoto.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\Resources\default-printer.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\Resources\git_message.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | 134 | ..\Resources\printer-setting.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 135 | 136 | 137 | ..\Resources\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 138 | 139 | -------------------------------------------------------------------------------- /Printer/Printer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Printer.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Printer/Printer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Printer/Printer/Resources/20130822001448_QiwCM.thumb.600_0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/20130822001448_QiwCM.thumb.600_0.jpeg -------------------------------------------------------------------------------- /Printer/Printer/Resources/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/Thumbs.db -------------------------------------------------------------------------------- /Printer/Printer/Resources/backphoto.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/backphoto.jpg -------------------------------------------------------------------------------- /Printer/Printer/Resources/default-printer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/default-printer.png -------------------------------------------------------------------------------- /Printer/Printer/Resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/favicon.ico -------------------------------------------------------------------------------- /Printer/Printer/Resources/git_message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/git_message.png -------------------------------------------------------------------------------- /Printer/Printer/Resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/logo.png -------------------------------------------------------------------------------- /Printer/Printer/Resources/logo_500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/logo_500.png -------------------------------------------------------------------------------- /Printer/Printer/Resources/printer-setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/printer-setting.png -------------------------------------------------------------------------------- /Printer/Printer/Resources/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/refresh.png -------------------------------------------------------------------------------- /Printer/Printer/Resources/未标题-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/Resources/未标题-1.png -------------------------------------------------------------------------------- /Printer/Printer/ToJsonMy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using Newtonsoft.Json.Linq; 7 | using System.Net; 8 | using System.IO; 9 | using System.ComponentModel; 10 | using System.Windows.Forms; 11 | 12 | namespace Printer 13 | { 14 | public class ToJsonMy 15 | { 16 | private string m_double_side; 17 | private string m_copies; 18 | private string m_status; 19 | 20 | 21 | //public string file_SavePath { get; set; } 22 | public string id { get; set; }//文件编号 23 | public string use_id { get; set; }// 24 | public string use_name { get; set; }// 25 | public string student_number { get; set; }// 26 | public string pri_id { get; set; } 27 | public string name { get; set; } 28 | public string url { get; set; } 29 | public string time { get; set; } 30 | public string lujing { get; set; } 31 | public bool is_ibook; 32 | public bool isfirst; 33 | public bool ispayed; 34 | 35 | public string file_SavePath 36 | { 37 | get 38 | { 39 | string file_selfpath = time.Split(' ')[0]; 40 | //String pathDoc = ""; 41 | file_selfpath = location_settings.file_path + file_selfpath + "\\"; 42 | return file_selfpath; 43 | } 44 | set { } 45 | } 46 | 47 | public string filename 48 | { 49 | get 50 | { 51 | string fileName = id + "_" + copies + "_" + double_side + "_" + student_number + "_" + name; 52 | string doc_extension = Path.GetExtension(fileName); 53 | //if (doc_extension != ".pdf") 54 | //{ 55 | // fileName = fileName + ".pdf"; 56 | //} 57 | switch (doc_extension) 58 | { 59 | case ".doc": 60 | case ".docx": 61 | case ".ppt": 62 | case ".pptx": 63 | fileName = fileName + ".pdf"; 64 | break; 65 | default: 66 | break; 67 | } 68 | return fileName; 69 | } 70 | } 71 | 72 | 73 | public string copies 74 | { 75 | get 76 | { 77 | if (m_copies == "0") 78 | { 79 | return "现场打印"; 80 | } 81 | else 82 | return m_copies + "份"; 83 | } 84 | set { m_copies = value; } 85 | 86 | } 87 | 88 | public string double_side 89 | { 90 | get 91 | { 92 | if (m_double_side == "0") 93 | { 94 | return "单面"; 95 | } 96 | else if (m_double_side == "1") 97 | { 98 | return "双面"; 99 | } 100 | else 101 | { 102 | return "-"; 103 | } 104 | } 105 | set { m_double_side = value; } 106 | } 107 | //根据属性的特点,将存储的和得到的status建立起映射关系; 108 | public string status 109 | { 110 | get 111 | { 112 | switch (m_status) 113 | { 114 | case"0": 115 | return "用户取消"; 116 | case "1": 117 | return "已上传"; 118 | case "2": 119 | return "已下载"; 120 | case "3": 121 | return "已打印"; 122 | case "4": 123 | return "打印完成"; 124 | case"-1": 125 | return "打印店取消"; 126 | 127 | //case "5": 128 | //case "payed": 129 | // return "已付款"; 130 | } 131 | return "0"; 132 | } 133 | set 134 | { 135 | m_status = value; 136 | } 137 | } 138 | public string color { get; set; } 139 | public string ppt_layout { get; set; } 140 | public string requirements { get; set; } 141 | public string strcolor 142 | { 143 | get 144 | { 145 | if (color == "0") 146 | { 147 | return "黑白"; 148 | } 149 | else if (color == "1") 150 | { 151 | return "彩印"; 152 | } 153 | else 154 | { 155 | return "-"; 156 | } 157 | } 158 | set 159 | { 160 | strcolor = value; 161 | } 162 | } 163 | public string ppt 164 | { 165 | get 166 | { 167 | switch (ppt_layout) 168 | { 169 | case "0": 170 | return "-"; 171 | case "1": 172 | 173 | return "1X1"; 174 | case "2": 175 | 176 | return "2X3"; 177 | case "3": 178 | 179 | return "2X4"; 180 | case "4": 181 | 182 | return "3X3"; 183 | } 184 | return "-"; 185 | } 186 | set 187 | { 188 | ppt = value; 189 | } 190 | } 191 | 192 | 193 | 194 | /// 195 | /// 调用状态改变函数 196 | /// 197 | /// 198 | /// 199 | public bool changeStatusById(string currentStatus) 200 | { 201 | //put到服务器状态;/api.php/File/1234?token=xxxxxxxxxxxx 202 | //将下载完成的文件id添加到下载完成myDown (ArrayList)中 203 | //参数: status=>文件状态'uploud','download','printing','printed','payed', 返回操作结果 204 | string putUrl = @"/printer/task/" + id; 205 | string putPara = "status=" + currentStatus; 206 | string resualt = API.PutMethod(putUrl, putPara, new UTF8Encoding()); 207 | if (JObject.Parse(resualt)["status"].ToString() != "1") 208 | { 209 | MessageBox.Show((string)JObject.Parse(resualt)["info"]); 210 | return false; 211 | } 212 | else 213 | { 214 | return true; 215 | } 216 | 217 | } 218 | 219 | public void ensure_payed() 220 | { 221 | string r = API.PostMethod_noparam("/printer/task/" + id + "/pay", new UTF8Encoding()); 222 | if (JObject.Parse(r)["status"].ToString() != "1") 223 | { 224 | throw new Exception ((string)JObject.Parse(r)["info"]); 225 | } 226 | else 227 | { 228 | this.ispayed = true; 229 | } 230 | } 231 | 232 | public bool cancel() 233 | { 234 | //string r = API.PostMethod_noparam("/printer/task/" + id + "/pay", new UTF8Encoding()); 235 | //if (JObject.Parse(r)["status"].ToString() != "1") 236 | //{ 237 | // MessageBox.Show((string)JObject.Parse(r)["info"]); 238 | //} 239 | bool result = this.changeStatusById("-1"); 240 | if (result) 241 | { 242 | if (database.jsonlist.Contains(this)) 243 | { 244 | database.jsonlist.Remove(this); 245 | } 246 | if (database.jsonlist_downloaded.Contains(this)) 247 | { 248 | database.jsonlist_downloaded.Remove(this); 249 | } 250 | if (database.jsonlist_err.Contains(this)) 251 | { 252 | database.jsonlist_err.Remove(this); 253 | } 254 | if (database.jsonlist_printed.Contains(this)) 255 | { 256 | database.jsonlist_printed.Remove(this); 257 | } 258 | if (database.jsonlist_printing.Contains(this)) 259 | { 260 | database.jsonlist_printing.Remove(this); 261 | } 262 | } 263 | return result; 264 | } 265 | 266 | public bool is_exsist_file 267 | { 268 | get 269 | { 270 | if (File.Exists(file_SavePath+filename)) 271 | { 272 | return true; 273 | } 274 | else 275 | { 276 | return false; 277 | } 278 | } 279 | } 280 | 281 | public bool is_exsist_rawfile 282 | { 283 | get 284 | { 285 | if (File.Exists(file_SavePath + name)) 286 | { 287 | return true; 288 | } 289 | else 290 | { 291 | return false; 292 | } 293 | } 294 | } 295 | 296 | public void create_FilePath() 297 | { 298 | if(!Directory.Exists(this.file_SavePath)) 299 | { 300 | Directory.CreateDirectory(this.file_SavePath); 301 | } 302 | } 303 | 304 | public void MoveFromListToList(List fromlist, List tolist) 305 | { 306 | if (fromlist.Contains(this)) 307 | { 308 | fromlist.Remove(this); 309 | if (!tolist.Contains(this)) 310 | { 311 | tolist.Add(this); 312 | } 313 | else 314 | { 315 | MessageBox.Show("列表中已包含该文件"); 316 | } 317 | } 318 | else 319 | { 320 | MessageBox.Show("列表中不存在该文件"); 321 | } 322 | } 323 | 324 | public bool OpenFile() 325 | { 326 | if (!this.is_exsist_file) 327 | { 328 | return false; 329 | } 330 | else 331 | { 332 | System.Diagnostics.Process.Start(file_SavePath + filename); 333 | return true; 334 | } 335 | } 336 | 337 | public bool OpenRawFile() 338 | { 339 | if (!this.is_exsist_rawfile) 340 | { 341 | return false; 342 | } 343 | else 344 | { 345 | System.Diagnostics.Process.Start(file_SavePath + name); 346 | return true; 347 | } 348 | } 349 | 350 | public userInfo UserMessage 351 | { 352 | get 353 | { 354 | string jsonUrl = API.GetMethod("/printer/user/" + use_id); 355 | JObject jo = JObject.Parse(jsonUrl); 356 | userInfo user = new userInfo(); 357 | user.name = jo["info"]["name"].ToString(); 358 | user.sch_id = jo["info"]["sch_id"].ToString(); 359 | user.student_number = jo["info"]["number"].ToString(); 360 | jsonUrl = API.GetMethod("/printer/user/" + use_id + "/phone"); 361 | jo = JObject.Parse(jsonUrl); 362 | user.phone = jo["info"].ToString(); 363 | return user; 364 | } 365 | } 366 | 367 | } 368 | } 369 | -------------------------------------------------------------------------------- /Printer/Printer/backgroundworker_refresh.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ComponentModel; 6 | 7 | namespace Printer 8 | { 9 | class backgroundworker_refresh 10 | { 11 | static BackgroundWorker bw = new BackgroundWorker(); 12 | login_download form; 13 | 14 | public backgroundworker_refresh(login_download form) 15 | { 16 | this.form = form; 17 | } 18 | 19 | private void refresh_fun(object sender, DoWorkEventArgs e) 20 | { 21 | form.StatusLabel.Text = "正在刷新,请稍后"; 22 | database.jsonlist_refresh(); //获取文件列表 23 | } 24 | 25 | void after_refresh_first(object sender, RunWorkerCompletedEventArgs e) 26 | { 27 | form.StatusLabel.Text = ""; 28 | display.display_list(form, database.jsonlist); 29 | download_list_class download_jsonlist = new download_list_class(form, database.jsonlist); 30 | download_jsonlist.download(); 31 | //这时后台线程已经完成,并返回了主线程,所以可以直接使用UI控件了 32 | //this.label4.Text = e.Result.ToString(); 33 | } 34 | 35 | private void after_refresh(object sender, RunWorkerCompletedEventArgs e) 36 | { 37 | form.StatusLabel.Text = ""; 38 | download_list_class download_list = new download_list_class(form, database.jsonlist); 39 | download_list.download(); 40 | } 41 | 42 | public void refresh_first() 43 | { 44 | if (!bw.IsBusy) 45 | { 46 | bw = new BackgroundWorker(); 47 | bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(after_refresh_first); 48 | bw.DoWork += new DoWorkEventHandler(refresh_fun); 49 | bw.RunWorkerAsync(); 50 | } 51 | } 52 | 53 | public void refresh_other() 54 | { 55 | if (!bw.IsBusy) 56 | { 57 | bw = new BackgroundWorker(); 58 | bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(after_refresh); 59 | bw.DoWork += new DoWorkEventHandler(refresh_fun); 60 | 61 | bw.RunWorkerAsync(); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Printer/Printer/database.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Newtonsoft.Json.Linq; 6 | using System.Windows.Forms; 7 | using System.IO; 8 | 9 | namespace Printer 10 | { 11 | 12 | 13 | class database 14 | { 15 | static public List jsonlist = new List(); 16 | //static public List jsonlist_downloading = new List(); 17 | static public List jsonlist_downloaded = new List(); 18 | static public List jsonlist_printed = new List(); 19 | static public string number_nouse_page = "1"; 20 | static public List jsonlist_err = new List(); 21 | static public List jsonlist_printing = new List(); 22 | 23 | 24 | static public bool jsonlist_add(JArray ja) 25 | { 26 | bool flag = true; 27 | bool flag_allpaid = true; 28 | //用于遍历的 29 | //向jsonList中添加数据,如果json的id已经存在,则flag置为false 30 | //即不添加,维护jsonList 31 | for (int i = 0; i < ja.Count; i++)//遍历ja数组 32 | { 33 | //bool flag2 = true; 34 | flag = true; 35 | foreach (var item in jsonlist) //此处应当存在一个问题,即循环中jsonlist列表会发生改变,能否使用foreach 36 | { 37 | //已存在的或是已支付的都可不予以考虑 38 | if (item.id == ja[i]["id"].ToString()) 39 | { 40 | flag = false; 41 | break; 42 | } 43 | } 44 | if ((ja[i]["payed"].ToString() == "1")&&(ja[i]["status"].ToString()=="4")) 45 | { 46 | flag = false; 47 | } 48 | if (flag == true) 49 | { 50 | ToJsonMy myJs = new ToJsonMy(); 51 | myJs.id = ja[i]["id"].ToString(); 52 | myJs.name = ja[i]["name"].ToString(); 53 | //myJs.use_id = ja[i]["use"].ToString(); 54 | //myJs.pri_id = ja[i]["pri_id"].ToString(); 55 | //myJs.url = ja[i]["url"].ToString(); 56 | myJs.time = ja[i]["time"].ToString(); 57 | //myJs.name = ja[i]["name"].ToString(); 58 | myJs.status = ja[i]["status"].ToString(); 59 | myJs.copies = ja[i]["copies"].ToString(); 60 | myJs.use_name = ja[i]["user"].ToString(); 61 | myJs.double_side = ja[i]["double"].ToString(); 62 | //myJs.student_number = ja[i]["student_number"].ToString(); 63 | myJs.color = ja[i]["color"].ToString(); 64 | myJs.ppt_layout = ja[i]["format"].ToString(); 65 | myJs.requirements = ja[i]["requirements"].ToString(); 66 | 67 | if (ja[i]["payed"].ToString() == "1") 68 | { 69 | myJs.ispayed = true; 70 | } 71 | else 72 | { 73 | myJs.ispayed = false; 74 | } 75 | if (ja[i].ToString().Contains("pro")) 76 | { 77 | myJs.isfirst = true; 78 | } 79 | else 80 | { 81 | myJs.isfirst = false; 82 | } 83 | string file_url = ""; 84 | string file_more = ""; 85 | file_more = API.GetMethod("/printer/task/" + myJs.id); 86 | file_url = JObject.Parse(file_more)["info"]["url"].ToString(); 87 | myJs.use_id = JObject.Parse(file_more)["info"]["use_id"].ToString(); 88 | if (!file_url.Contains("book")) 89 | { 90 | myJs.is_ibook = false; 91 | 92 | } 93 | else 94 | { 95 | myJs.is_ibook = true; 96 | 97 | } 98 | //file_url = ""; 99 | jsonlist.Add(myJs); 100 | if (myJs.status == "打印完成") 101 | { 102 | jsonlist_printed.Add(myJs); 103 | } 104 | //if (myJs.status == "未下载") 105 | //{ 106 | // jsonlist_downloading.Add(myJs); 107 | //} 108 | if (myJs.status == "已下载") 109 | { 110 | jsonlist_downloaded.Add(myJs); 111 | } 112 | if (myJs.status == "已打印") 113 | { 114 | jsonlist_printing.Add(myJs); 115 | } 116 | } 117 | if (ja[i]["payed"].ToString() != "1") 118 | { 119 | flag_allpaid = false; 120 | } 121 | } 122 | return flag_allpaid; 123 | } 124 | 125 | static public void jsonlist_refresh() 126 | { 127 | //API.myPage = Int32.Parse(number_nouse_page); 128 | API.myPage = 1; 129 | //API.token = location_settings.my.token; 130 | string myJsFile = API.GetMethod("/printer/task?page=" + API.myPage ); 131 | API.myPage += 1; 132 | #if DEBUG 133 | Console.WriteLine(myJsFile); //这是为了调试么 134 | #endif 135 | JObject jo = JObject.Parse(myJsFile); 136 | JArray ja = jo["info"] as JArray; 137 | //将JArray类型的ja转化为ToMyJohn对象数组 138 | if (ja != null) 139 | { 140 | if (jsonlist_add(ja) == true) 141 | { 142 | number_nouse_page = API.myPage.ToString(); 143 | } 144 | bool myAdd = (ja.Count == 10); //主要用于判断是否有下一页 145 | //这里的逻辑应当仔细考虑 146 | while (myAdd) 147 | { 148 | //API.token = location_settings.my.token; 149 | myJsFile = API.GetMethod("/printer/task?page=" + API.myPage); 150 | #if DEBUG 151 | Console.WriteLine(myJsFile); //这是为了调试么 152 | #endif 153 | API.myPage += 1; 154 | jo = JObject.Parse(myJsFile); 155 | ja = jo["info"] as JArray; 156 | if (ja == null) 157 | { 158 | break; 159 | } 160 | if (ja != null) 161 | { 162 | if (jsonlist_add(ja) == true) 163 | { 164 | number_nouse_page = API.myPage.ToString(); 165 | } 166 | } 167 | if (ja.Count < 10) 168 | myAdd = false; 169 | else 170 | myAdd = true; 171 | } 172 | } 173 | } 174 | 175 | static public ToJsonMy find_myjson(string id) 176 | { 177 | ToJsonMy result = null; 178 | foreach (var item in jsonlist) 179 | { 180 | if (item.id == id) 181 | { 182 | result = item; 183 | break; 184 | } 185 | } 186 | return result; 187 | } 188 | //static public void create_data_frompage() 189 | //{ 190 | // if (!File.Exists("data_frompage.sjc")) 191 | // { 192 | // File.Create("data_frompage.sjc"); 193 | // } 194 | //} 195 | //static public void write_data_frompage() 196 | //{ 197 | // create_data_frompage(); 198 | // File.WriteAllText(@"data_frompage.sjc", ""); 199 | // remember.WriteStringToTextFile(number_nouse_page, @"data_frompage.sjc"); 200 | //} 201 | 202 | 203 | 204 | 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /Printer/Printer/datatype.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | //using System.Threading.Tasks; 6 | 7 | namespace Printer 8 | { 9 | 10 | //定义获取api的token 11 | public struct ToMyToken 12 | { 13 | public string sid { get; set; } 14 | public string name { get; set; } 15 | public string id { get; set; } 16 | public string sch_id { get; set; } 17 | //public float version { get; set; } 18 | } 19 | 20 | 21 | //声明用户的隐私信息 22 | //{ 23 | // "id": "用户id", 24 | // "name": "姓名", 25 | // "student_number": "学号", 26 | // "gender": "性别", 27 | // "phone": "真实手机号", 28 | // "email": "真实邮箱", 29 | // "status": "用户状态标识码" 30 | // } 31 | public class userInfo 32 | { 33 | public string id { get; set; } 34 | public string name { get; set; } 35 | public string student_number { get; set; } 36 | public string gender { get; set; } 37 | public string phone { get; set; } 38 | public string email { get; set; } 39 | public string status { get; set; } 40 | public string sch_id { get; set; } 41 | 42 | 43 | } 44 | 45 | public struct mydata_form 46 | { 47 | public string mydata_id { get; set; } 48 | public string mydata_status { get; set; } 49 | public string mydata_name { get; set; } 50 | public string mydata_setting { get; set; } 51 | public string mydata_userName { get; set; } 52 | public string mydata_time { get; set; } 53 | public string mydata_buttontext { get; set; } 54 | public string mydata_pay_buttontext { get; set; } 55 | public string mydata_requirements { get; set; } 56 | 57 | 58 | //public string mydata_copies { get; set; } 59 | 60 | 61 | 62 | //public string mydata_doubleside { get; set; } 63 | //public string mydata_color { get; set; } 64 | //public string mydata_ppt { get; set; } 65 | 66 | } 67 | 68 | 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /Printer/Printer/display.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Printer 7 | { 8 | class display 9 | { 10 | public delegate void Delegate_display(login_download form, mydata_form mydata); 11 | static public Delegate_display delegate_display; 12 | 13 | static public void display_list(login_download form, List list) 14 | { 15 | foreach (var item in list) 16 | { 17 | if (item.status != "已上传") 18 | { 19 | display_single(form, item); 20 | } 21 | } 22 | } 23 | 24 | static public void display_list_norefresh(login_download form, List list) 25 | { 26 | foreach (var item in list) 27 | { 28 | display_single(form, item); 29 | } 30 | } 31 | 32 | static public void display_fun(login_download form, mydata_form data) 33 | { 34 | form.mydata.Rows.Add(false, data.mydata_id, data.mydata_status,data.mydata_pay_buttontext, data.mydata_requirements, data.mydata_name, data.mydata_setting, data.mydata_userName, data.mydata_time, "一键打印", "设置后打印",data.mydata_buttontext, "取消订单", "打开源文件" ); 35 | } 36 | static public void display_single(login_download form, ToJsonMy file) 37 | { 38 | 39 | //mydata_form data = new mydata_form(); 40 | //data.mydata_userName = file.student_number + file.use_name; 41 | //data.mydata_buttontext = ""; 42 | //data.mydata_name = file.name; 43 | //data.mydata_id = file.id; 44 | //data.mydata_time = file.time; 45 | ////data.mydata_copies = file.copies; 46 | 47 | //if (database.jsonlist_err.Contains(file)) 48 | //{ 49 | // data.mydata_status = "下载失败"; 50 | //} 51 | //else 52 | //{ 53 | // data.mydata_status = file.status; 54 | //} 55 | 56 | ////data.mydata_doubleside = file.double_side; 57 | ////data.mydata_color = file.strcolor; 58 | ////data.mydata_ppt = file.ppt; 59 | 60 | 61 | //if (file.requirements != "") 62 | //{ 63 | // data.mydata_name = "(注)" + file.name; 64 | 65 | //} 66 | //if (file.isfirst == true) 67 | //{ 68 | // data.mydata_name = "(首单!)" + file.name; 69 | //} 70 | 71 | //if (file.copies == "现场打印") 72 | //{ 73 | // data.mydata_buttontext = "通知打印完成"; 74 | 75 | // //data.mydata_doubleside = "-"; 76 | // //data.mydata_color = "-"; 77 | // //data.mydata_ppt = "-"; 78 | // data.mydata_setting = "现场打印"; 79 | // delegate_display = display_fun; 80 | // form.mydata.Invoke(delegate_display, new object[] { form, data }); 81 | //} 82 | //else 83 | //{ 84 | // switch (file.status) 85 | // { 86 | // case "已下载": 87 | // data.mydata_buttontext = "通知打印完成"; 88 | // break; 89 | // case "已打印": 90 | // data.mydata_buttontext = "通知打印完成"; 91 | // break; 92 | // case "打印完成": 93 | // data.mydata_buttontext = "通知打印完成"; 94 | // break; 95 | // case "已上传": 96 | // data.mydata_buttontext = "手动下载"; 97 | // break; 98 | // } 99 | // if (!file.is_exsist_file) 100 | // { 101 | // data.mydata_buttontext = "重新下载"; 102 | // } 103 | // data.mydata_setting = file.copies + file.double_side + file.strcolor + file.ppt; 104 | 105 | // delegate_display = display_fun; 106 | // form.mydata.Invoke(delegate_display, new object[] { form, data }); 107 | 108 | //} 109 | switch (form.display_mode) 110 | { 111 | case "mode_all": 112 | display.Display_Single(form, file); 113 | break; 114 | case "mode_downloading": 115 | if (file.status == "已上传") 116 | { 117 | display.Display_Single(form, file); 118 | } 119 | break; 120 | case "mode_downloaded": 121 | if (file.status == "已下载") 122 | { 123 | display.Display_Single(form, file); 124 | } 125 | break; 126 | case "mode_printing": 127 | if (file.status == "已打印") 128 | { 129 | display.Display_Single(form, file); 130 | } 131 | break; 132 | case "mode_printed": 133 | if (file.status == "打印完成") 134 | { 135 | display.Display_Single(form, file); 136 | } 137 | break; 138 | default: 139 | break; 140 | } 141 | 142 | } 143 | 144 | static public void Display_Single(login_download form, ToJsonMy file) 145 | { 146 | mydata_form data = new mydata_form(); 147 | data.mydata_userName = file.student_number + file.use_name; 148 | data.mydata_buttontext = ""; 149 | data.mydata_name = file.name; 150 | data.mydata_id = file.id; 151 | data.mydata_time = file.time; 152 | data.mydata_requirements = file.requirements; 153 | //data.mydata_copies = file.copies; 154 | 155 | if (database.jsonlist_err.Contains(file)) 156 | { 157 | data.mydata_status = "下载失败"; 158 | } 159 | else 160 | { 161 | data.mydata_status = file.status; 162 | } 163 | 164 | //data.mydata_doubleside = file.double_side; 165 | //data.mydata_color = file.strcolor; 166 | //data.mydata_ppt = file.ppt; 167 | 168 | 169 | if (file.requirements != "") 170 | { 171 | data.mydata_name = "(注)" + file.name; 172 | 173 | } 174 | if (file.isfirst == true) 175 | { 176 | data.mydata_name = "(首单!)" + file.name; 177 | } 178 | if (file.ispayed == true) 179 | { 180 | data.mydata_pay_buttontext = "已支付"; 181 | } 182 | else 183 | { 184 | data.mydata_pay_buttontext = "确认支付"; 185 | } 186 | 187 | if (file.copies == "现场打印") 188 | { 189 | data.mydata_buttontext = "确认打印完成"; 190 | 191 | //data.mydata_doubleside = "-"; 192 | //data.mydata_color = "-"; 193 | //data.mydata_ppt = "-"; 194 | data.mydata_setting = "现场打印"; 195 | delegate_display = display_fun; 196 | form.mydata.Invoke(delegate_display, new object[] { form, data }); 197 | } 198 | else 199 | { 200 | switch (file.status) 201 | { 202 | case "已下载": 203 | data.mydata_buttontext = "确认打印完成"; 204 | break; 205 | case "已打印": 206 | data.mydata_buttontext = "确认打印完成"; 207 | break; 208 | case "打印完成": 209 | data.mydata_buttontext = "确认打印完成"; 210 | break; 211 | case "已上传": 212 | data.mydata_buttontext = "手动下载"; 213 | break; 214 | } 215 | if (!file.is_exsist_file) 216 | { 217 | data.mydata_buttontext = "重新下载"; 218 | } 219 | data.mydata_setting = file.copies + file.double_side + file.strcolor + file.ppt; 220 | 221 | delegate_display = display_fun; 222 | form.mydata.Invoke(delegate_display, new object[] { form, data }); 223 | 224 | } 225 | } 226 | 227 | } 228 | 229 | 230 | 231 | } 232 | -------------------------------------------------------------------------------- /Printer/Printer/download_class.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using Newtonsoft.Json.Linq; 7 | using System.Net; 8 | using System.IO; 9 | using System.ComponentModel; 10 | using System.Windows.Forms; 11 | 12 | namespace Printer 13 | { 14 | abstract class download_class 15 | { 16 | public login_download form; 17 | public ToJsonMy file; 18 | 19 | public void download() 20 | { 21 | if (!database.jsonlist_err.Contains(file)) 22 | { 23 | file.create_FilePath(); 24 | Download(); 25 | } 26 | } 27 | abstract public void Download(); 28 | } 29 | class download_single_class : download_class 30 | { 31 | //public ToJsonMy file; 32 | public download_single_class(login_download form, ToJsonMy file) 33 | { 34 | this.form = form; 35 | this.file = file; 36 | 37 | } 38 | 39 | public override void Download() 40 | { 41 | //string filename = this.file.id + "_" + this.file.copies + "_" + this.file.double_side + "_" + this.file.student_number + "_" + this.file.name; 42 | //string file_selfpath = this.file.time.Split(' ')[0]; 43 | this.file.url = JObject.Parse(API.GetMethod("/printer/task/" + this.file.id))["info"]["url"].ToString(); 44 | Thread piThread1 = new Thread(delegate() 45 | { 46 | WebClient webClient = new WebClient(); 47 | //String pathDoc = ""; 48 | 49 | //string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); 50 | //if (doc_extension != ".pdf") 51 | //{ 52 | // pathDoc = location_settings.file_path + "/" + file_selfpath + "/" + filename + ".pdf"; 53 | //} 54 | //else 55 | //{ 56 | // pathDoc = location_settings.file_path + "/" + file_selfpath + "/" + filename; 57 | //} 58 | //添加下载完成后的事件 59 | webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted); 60 | webClient.DownloadFileAsync(new Uri(this.file.url), this.file.file_SavePath + this.file.filename, this.file.id); 61 | 62 | }); 63 | piThread1.Start(); 64 | } 65 | 66 | //webClient下载完成后相应的事件,下载完成后,调用改变状态函数 67 | void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 68 | { 69 | if (e.Error == null)//下载成功 70 | { 71 | //改变文件的状态 72 | //改变文件在jsonlist中的状态 73 | //将已经下载的文件添加到mydata中 74 | this.file.status = "2"; 75 | display.display_single(form, this.file); 76 | this.file.changeStatusById("2"); 77 | form.notifyIcon1.Visible = true; 78 | form.notifyIcon1.ShowBalloonTip(10000); 79 | if (database.jsonlist_err.Contains(file)) 80 | { 81 | database.jsonlist_err.Remove(file); 82 | } 83 | if (!database.jsonlist_downloaded.Contains(file)) 84 | { 85 | database.jsonlist_downloaded.Add(file); 86 | } 87 | 88 | } 89 | else 90 | { 91 | 92 | MessageBox.Show("id=" + file.id + " " + e.Error.Message + @"\n" + "请手动下载"); 93 | if (!database.jsonlist_err.Contains(file)) 94 | { 95 | database.jsonlist_err.Add(file); 96 | display.display_single(form, this.file); 97 | } 98 | 99 | } 100 | } 101 | 102 | } 103 | 104 | class download_single_single_class : download_class 105 | { 106 | //public ToJsonMy file; 107 | public int RowIndex; 108 | public download_single_single_class(login_download form, ToJsonMy file, int RowIndex) 109 | { 110 | this.form = form; 111 | this.file = file; 112 | this.RowIndex = RowIndex; 113 | } 114 | 115 | public override void Download() 116 | { 117 | string jsonUrl = API.GetMethod("/printer/task/" + file.id); 118 | JObject jo = JObject.Parse(jsonUrl); 119 | ToJsonMy thisOne = new ToJsonMy(); 120 | thisOne.url = (jo)["info"]["url"].ToString(); 121 | WebClient webClient = new WebClient(); 122 | //String pathDoc = filename; 123 | webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(OnDownloadFileCompleted); 124 | webClient.DownloadFileAsync(new Uri(thisOne.url), file.file_SavePath + file.filename, file.id); 125 | MessageBox.Show("正在下载该文件!\n请等待,稍后请再次点击打印按钮"); 126 | } 127 | 128 | private void OnDownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 129 | { 130 | 131 | if (e.Error == null)//下载成功 132 | { 133 | MessageBox.Show("已下载完成\n请再次点击打印按钮"); 134 | form.mydata.Rows[RowIndex].Cells["operation"].Value = "确认打印完成"; 135 | } 136 | else 137 | { 138 | MessageBox.Show("id=" + file.id + " " + e.Error.Message); 139 | form.mydata.Rows[RowIndex].Cells["operation"].Value = "重新下载"; 140 | } 141 | } 142 | } 143 | 144 | 145 | class download_list_class 146 | { 147 | public List list; 148 | public login_download form; 149 | public download_list_class(login_download form, List list) 150 | { 151 | this.form = form; 152 | this.list = list; 153 | } 154 | 155 | public void download() 156 | { 157 | foreach (var item in list) 158 | { 159 | if (item.status == "已上传") 160 | { 161 | string file_url = ""; 162 | string file_more = ""; 163 | file_more = API.GetMethod("/printer/task/" + item.id); 164 | file_url = JObject.Parse(file_more)["info"]["url"].ToString(); 165 | if (!file_url.Contains("book")) 166 | { 167 | item.is_ibook = false; 168 | download_single_class file_download = new download_single_class(form, item); 169 | file_download.download(); 170 | } 171 | else 172 | { 173 | item.is_ibook = true; 174 | item.status = "2"; 175 | item.changeStatusById("2"); 176 | this.form.notifyIcon1.Visible = true; 177 | this.form.notifyIcon1.ShowBalloonTip(10000); 178 | display.display_single(form, item); 179 | } 180 | } 181 | } 182 | } 183 | } 184 | 185 | class download_rawfile_class 186 | { 187 | public ToJsonMy file; 188 | public login_download form; 189 | public int RowIndex; 190 | 191 | public void download() 192 | { 193 | //string filename = this.file.id + "_" + this.file.copies + "_" + this.file.double_side + "_" + this.file.student_number + "_" + this.file.name; ; 194 | //string file_selfpath = this.file.time.Split(' ')[0]; 195 | file.create_FilePath(); 196 | this.file.url = JObject.Parse(API.GetMethod("/printer/task/" + this.file.id + "/file"))["info"].ToString(); 197 | Thread piThread1 = new Thread(delegate() 198 | { 199 | WebClient webClient = new WebClient(); 200 | //添加下载完成后的事件 201 | webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted); 202 | webClient.DownloadFileAsync(new Uri(this.file.url), this.file.file_SavePath + this.file.name, this.file.id); 203 | 204 | }); 205 | piThread1.Start(); 206 | } 207 | 208 | //webClient下载完成后相应的事件,下载完成后,调用改变状态函数 209 | virtual public void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 210 | { 211 | } 212 | } 213 | 214 | class download_rawfile_all_class : download_rawfile_class 215 | { 216 | public download_rawfile_all_class(login_download form, ToJsonMy file, int RowIndex) 217 | { 218 | this.form = form; 219 | this.file = file; 220 | this.RowIndex = RowIndex; 221 | } 222 | 223 | override public void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 224 | { 225 | if (e.Error == null)//下载成功 226 | { 227 | //改变文件的状态 228 | //改变文件在jsonlist中的状态 229 | //将已经下载的文件添加到mydata中 230 | if (file.status == "已上传") 231 | { 232 | this.file.status = "2"; 233 | this.file.changeStatusById("2"); 234 | form.mydata.Rows[RowIndex].Cells["status"].Value = "已下载"; 235 | file.MoveFromListToList(database.jsonlist_err, database.jsonlist_downloaded); 236 | } 237 | form.notifyIcon1.Visible = true; 238 | form.notifyIcon1.ShowBalloonTip(10000); 239 | if (File.Exists(this.file.file_SavePath + this.file.name)) 240 | { 241 | System.Diagnostics.Process.Start(this.file.file_SavePath + this.file.name); 242 | } 243 | else 244 | { 245 | MessageBox.Show("文件下载路径存在问题"); 246 | } 247 | } 248 | else 249 | { 250 | MessageBox.Show("id=" + file.id + " " + e.Error.Message); 251 | //database.err_list.Add(file.id); 252 | } 253 | } 254 | 255 | } 256 | 257 | class download_rawfile_downloading_class : download_rawfile_class 258 | { 259 | public download_rawfile_downloading_class(login_download form, ToJsonMy file, int RowIndex) 260 | { 261 | this.form = form; 262 | this.file = file; 263 | this.RowIndex = RowIndex; 264 | } 265 | 266 | override public void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 267 | { 268 | if (e.Error == null)//下载成功 269 | { 270 | //改变文件的状态 271 | //改变文件在jsonlist中的状态 272 | //将已经下载的文件添加到mydata中 273 | if (file.status == "已上传") 274 | { 275 | this.file.status = "2"; 276 | this.file.changeStatusById("2"); 277 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 278 | file.MoveFromListToList(database.jsonlist_err, database.jsonlist_downloaded); 279 | } 280 | form.notifyIcon1.Visible = true; 281 | form.notifyIcon1.ShowBalloonTip(10000); 282 | if (File.Exists(this.file.file_SavePath + this.file.name)) 283 | { 284 | System.Diagnostics.Process.Start(this.file.file_SavePath + this.file.name); 285 | } 286 | else 287 | { 288 | MessageBox.Show("文件下载路径存在问题"); 289 | } 290 | } 291 | else 292 | { 293 | MessageBox.Show("id=" + file.id + " " + e.Error.Message); 294 | //database.err_list.Add(file.id); 295 | } 296 | } 297 | 298 | } 299 | 300 | class download_rawfile_others_class : download_rawfile_class 301 | { 302 | public download_rawfile_others_class(login_download form, ToJsonMy file, int RowIndex) 303 | { 304 | this.form = form; 305 | this.file = file; 306 | this.RowIndex = RowIndex; 307 | } 308 | 309 | override public void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 310 | { 311 | if (e.Error == null)//下载成功 312 | { 313 | //改变文件的状态 314 | //改变文件在jsonlist中的状态 315 | //将已经下载的文件添加到mydata中 316 | form.notifyIcon1.Visible = true; 317 | form.notifyIcon1.ShowBalloonTip(10000); 318 | if (File.Exists(this.file.file_SavePath + this.file.name)) 319 | { 320 | System.Diagnostics.Process.Start(this.file.file_SavePath + this.file.name); 321 | } 322 | else 323 | { 324 | MessageBox.Show("文件下载路径存在问题"); 325 | } 326 | } 327 | else 328 | { 329 | MessageBox.Show("id=" + file.id + " " + e.Error.Message); 330 | //database.err_list.Add(file.id); 331 | } 332 | } 333 | 334 | } 335 | 336 | 337 | 338 | 339 | class download_errfile_class 340 | { 341 | public ToJsonMy file; 342 | public login_download form; 343 | public int RowIndex; 344 | 345 | public void download() 346 | { 347 | file.create_FilePath(); 348 | this.file.url = JObject.Parse(API.GetMethod("/printer/task/" + this.file.id))["info"]["url"].ToString(); 349 | Thread piThread1 = new Thread(delegate() 350 | { 351 | WebClient webClient = new WebClient(); 352 | //添加下载完成后的事件 353 | webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted); 354 | webClient.DownloadFileAsync(new Uri(this.file.url), this.file.file_SavePath + file.filename, this.file.id); 355 | 356 | }); 357 | piThread1.Start(); 358 | } 359 | 360 | //webClient下载完成后相应的事件,下载完成后,调用改变状态函数 361 | virtual public void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 362 | { 363 | } 364 | } 365 | 366 | 367 | class download_errfile_all_class : download_errfile_class 368 | { 369 | //public ToJsonMy file; 370 | //public login_download form; 371 | //public int RowIndex; 372 | 373 | public download_errfile_all_class(login_download form, ToJsonMy file, int RowIndex) 374 | { 375 | this.form = form; 376 | this.file = file; 377 | this.RowIndex = RowIndex; 378 | 379 | } 380 | 381 | //webClient下载完成后相应的事件,下载完成后,调用改变状态函数 382 | override public void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 383 | { 384 | if (e.Error == null)//下载成功 385 | { 386 | this.file.changeStatusById("2"); 387 | form.notifyIcon1.Visible = true; 388 | form.notifyIcon1.ShowBalloonTip(10000); 389 | form.mydata.Rows[RowIndex].Cells["status"].Value = "已下载"; 390 | form.mydata.Rows[RowIndex].Cells["operation"].Value = "确认打印完成"; 391 | 392 | if (database.jsonlist_err.Contains(file)) 393 | { 394 | database.jsonlist_err.Remove(file); 395 | } 396 | if (!database.jsonlist_downloaded.Contains(file)) 397 | { 398 | database.jsonlist_downloaded.Add(file); 399 | } 400 | } 401 | else 402 | { 403 | MessageBox.Show("id=" + file.id + " " + e.Error.Message); 404 | if (!database.jsonlist_err.Contains(file)) 405 | { 406 | database.jsonlist_err.Add(file); 407 | } 408 | 409 | } 410 | } 411 | } 412 | 413 | class download_errfile_downloading_class : download_errfile_class 414 | { 415 | //public ToJsonMy file; 416 | //public login_download form; 417 | //public int RowIndex; 418 | 419 | public download_errfile_downloading_class(login_download form, ToJsonMy file, int RowIndex) 420 | { 421 | this.form = form; 422 | this.file = file; 423 | this.RowIndex = RowIndex; 424 | 425 | } 426 | 427 | //webClient下载完成后相应的事件,下载完成后,调用改变状态函数 428 | override public void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 429 | { 430 | if (e.Error == null)//下载成功 431 | { 432 | this.file.changeStatusById("2"); 433 | form.notifyIcon1.Visible = true; 434 | form.notifyIcon1.ShowBalloonTip(10000); 435 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 436 | 437 | if (database.jsonlist_err.Contains(file)) 438 | { 439 | database.jsonlist_err.Remove(file); 440 | } 441 | if (!database.jsonlist_downloaded.Contains(file)) 442 | { 443 | database.jsonlist_downloaded.Add(file); 444 | } 445 | } 446 | else 447 | { 448 | MessageBox.Show("id=" + file.id + " " + e.Error.Message); 449 | if (!database.jsonlist_err.Contains(file)) 450 | { 451 | database.jsonlist_err.Add(file); 452 | } 453 | } 454 | } 455 | } 456 | } 457 | 458 | -------------------------------------------------------------------------------- /Printer/Printer/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/Printer/favicon.ico -------------------------------------------------------------------------------- /Printer/Printer/location_settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.Text.RegularExpressions; 7 | using Newtonsoft.Json.Linq; 8 | using System.Windows.Forms; 9 | 10 | namespace Printer 11 | { 12 | class location_settings 13 | { 14 | static public ToMyToken my; 15 | static public string file_path { get; set; } 16 | static public string ibook_path { get; set; } 17 | static public List printer_setting_list = new List(); 18 | 19 | static public void creat_path() 20 | { 21 | if (!Directory.Exists(ibook_path)) 22 | { 23 | Directory.CreateDirectory(ibook_path); 24 | } 25 | if (!Directory.Exists(file_path)) 26 | { 27 | Directory.CreateDirectory(file_path); 28 | } 29 | } 30 | 31 | static public void set_printer_setting_list(string noduplex_nocolor_printer, string duplex_nocolor_printer, string noduplex_color_printer, string duplex_color_printer) 32 | { 33 | printer_setting_list.Clear(); 34 | printer_setting_list.Add(noduplex_nocolor_printer); 35 | printer_setting_list.Add(duplex_nocolor_printer); 36 | printer_setting_list.Add(noduplex_color_printer); 37 | printer_setting_list.Add(duplex_color_printer); 38 | File.WriteAllText(@"printer_setting.sjc", ""); 39 | remember.WriteListToTextFile(printer_setting_list, @"printer_setting.sjc"); 40 | } 41 | 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Printer/Printer/login_class.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Security.Cryptography; 6 | using System.Threading; 7 | 8 | namespace Printer 9 | { 10 | class login_class 11 | { 12 | static public List myLogin = new List(); 13 | static public string password_save; 14 | static public string type; //打印店的type为2 15 | public delegate string login_delegate(string username, string password); 16 | //static public event login_delegate login_event; 17 | 18 | static public login_delegate login_del = new login_delegate(login); 19 | static public string login(string username, string password) 20 | { 21 | if (myLogin.Count == 2) 22 | { 23 | if (myLogin[0].Length != password.Length) 24 | { 25 | password = md5_encoding(password); 26 | } 27 | } 28 | else 29 | { 30 | password = md5_encoding(password); 31 | } 32 | password = password.ToLower(); 33 | password_save = password; 34 | string r = get_token(type, username, password); 35 | return r; 36 | 37 | } 38 | 39 | private static string md5_encoding(string strpassword) 40 | { 41 | byte[] pword = Encoding.Default.GetBytes(strpassword.Trim()); //进行MD5的加密工作 42 | System.Security.Cryptography.MD5 md5 = new MD5CryptoServiceProvider(); 43 | byte[] out1 = md5.ComputeHash(pword); 44 | strpassword = BitConverter.ToString(out1).Replace("-", ""); 45 | return strpassword; 46 | } 47 | 48 | private static string get_token(string type, string strusername, string strpassword) 49 | { 50 | //string js = "type=" + type + "&account=" + strusername + "&pwd=" + strpassword; 51 | string js = "account=" + strusername + "&password=" + strpassword; 52 | //POST得到要数据//登陆得到token 53 | string r = API.PostMethod("/printer/auth/", js, new UTF8Encoding()); 54 | return r; 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Printer/Printer/operation_all_class.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace Printer 8 | { 9 | abstract class operation_all_class 10 | { 11 | public login_download form; 12 | public List stringlist = new List(); 13 | public void do_operation() 14 | { 15 | foreach (DataGridViewRow dr in form.mydata.Rows) 16 | { 17 | if (Convert.ToBoolean(dr.Cells["select_idex"].Value) == true) 18 | { 19 | stringlist.Add(dr.Cells["id"].Value.ToString()); 20 | } 21 | } 22 | foreach (var item in stringlist) 23 | { 24 | string id = item; 25 | int index = -1; 26 | ToJsonMy file = database.find_myjson(id); 27 | foreach (DataGridViewRow dr in form.mydata.Rows) 28 | { 29 | if (dr.Cells["id"].Value.ToString() == id) 30 | { 31 | index = dr.Index; 32 | break; 33 | } 34 | } 35 | if (index > -1) 36 | { 37 | Do_operation(file, index); 38 | //operation_EnsurePayed_class operation = new operation_EnsurePayed_class(form, file, index); 39 | //operation.do_operation(); 40 | } 41 | } 42 | } 43 | 44 | abstract public void Do_operation(ToJsonMy file, int index); 45 | } 46 | 47 | class operation_all_EnsurePayed_class : operation_all_class 48 | { 49 | public operation_all_EnsurePayed_class(login_download form) 50 | { 51 | this.form = form; 52 | } 53 | public override void Do_operation(ToJsonMy file, int index) 54 | { 55 | operation_EnsurePayed_class operation = new operation_EnsurePayed_class(form, file, index); 56 | operation.do_operation(); 57 | 58 | } 59 | } 60 | 61 | class operation_all_DirectPrint_class : operation_all_class 62 | { 63 | public operation_all_DirectPrint_class(login_download form) 64 | { 65 | this.form = form; 66 | } 67 | public override void Do_operation(ToJsonMy file, int index) 68 | { 69 | operation_PrintDirect_class operation = new operation_PrintDirect_class(form, file, index); 70 | operation.do_operation(); 71 | 72 | } 73 | } 74 | 75 | class operation_all_TellPrinted_class : operation_all_class 76 | { 77 | public operation_all_TellPrinted_class(login_download form) 78 | { 79 | this.form = form; 80 | } 81 | public override void Do_operation(ToJsonMy file, int index) 82 | { 83 | operation_TellPrinted_class tellprinted = new operation_TellPrinted_class(form, file, index); 84 | tellprinted.do_operation(); 85 | 86 | } 87 | } 88 | 89 | class operation_all_cancel_class : operation_all_class 90 | { 91 | public operation_all_cancel_class(login_download form) 92 | { 93 | this.form = form; 94 | } 95 | public override void Do_operation(ToJsonMy file, int index) 96 | { 97 | operation_cancel_class operation = new operation_cancel_class(form, file, index); 98 | operation.do_operation(); 99 | 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Printer/Printer/operation_class.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | using System.IO; 7 | 8 | namespace Printer 9 | { 10 | class operation_class 11 | { 12 | public login_download form; 13 | public ToJsonMy file; 14 | public int RowIndex; 15 | virtual public void do_operation() { } 16 | } 17 | 18 | class operation_TellPrinted_class : operation_class 19 | { 20 | public operation_TellPrinted_class(login_download form, ToJsonMy file, int RowIndex) 21 | { 22 | this.form = form; 23 | this.file = file; 24 | this.RowIndex = RowIndex; 25 | } 26 | override public void do_operation() 27 | { 28 | 29 | switch (form.display_mode) 30 | { 31 | case "mode_downloaded": 32 | case "mode_printing": 33 | if (file.changeStatusById("4")) 34 | { 35 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 36 | file.status = "4"; 37 | if (file.ispayed == false) 38 | { 39 | if (database.jsonlist_downloaded.Contains(file)) 40 | { 41 | database.jsonlist_downloaded.Remove(file); 42 | } 43 | if (database.jsonlist_printing.Contains(file)) 44 | { 45 | database.jsonlist_printing.Remove(file); 46 | } 47 | if (!database.jsonlist_printed.Contains(file)) 48 | { 49 | database.jsonlist_printed.Add(file); 50 | } 51 | } 52 | else 53 | { 54 | if (database.jsonlist.Contains(file)) 55 | { 56 | database.jsonlist.Remove(file); 57 | } 58 | if (database.jsonlist_downloaded.Contains(file)) 59 | { 60 | database.jsonlist_downloaded.Remove(file); 61 | } 62 | if (database.jsonlist_err.Contains(file)) 63 | { 64 | database.jsonlist_err.Remove(file); 65 | } 66 | if (database.jsonlist_printed.Contains(file)) 67 | { 68 | database.jsonlist_printed.Remove(file); 69 | } 70 | if (database.jsonlist_printing.Contains(file)) 71 | { 72 | database.jsonlist_printing.Remove(file); 73 | } 74 | } 75 | } 76 | 77 | break; 78 | case "mode_all": 79 | if (file.changeStatusById("4")) 80 | { 81 | file.status = "4"; 82 | if (file.ispayed == false) 83 | { 84 | form.mydata.Rows[RowIndex].Cells["status"].Value = "打印完成"; 85 | if (database.jsonlist_downloaded.Contains(file)) 86 | { 87 | database.jsonlist_downloaded.Remove(file); 88 | } 89 | if (database.jsonlist_printing.Contains(file)) 90 | { 91 | database.jsonlist_printing.Remove(file); 92 | } 93 | if (!database.jsonlist_printed.Contains(file)) 94 | { 95 | database.jsonlist_printed.Add(file); 96 | } 97 | } 98 | else 99 | { 100 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 101 | if (database.jsonlist.Contains(file)) 102 | { 103 | database.jsonlist.Remove(file); 104 | } 105 | if (database.jsonlist_downloaded.Contains(file)) 106 | { 107 | database.jsonlist_downloaded.Remove(file); 108 | } 109 | if (database.jsonlist_err.Contains(file)) 110 | { 111 | database.jsonlist_err.Remove(file); 112 | } 113 | if (database.jsonlist_printed.Contains(file)) 114 | { 115 | database.jsonlist_printed.Remove(file); 116 | } 117 | if (database.jsonlist_printing.Contains(file)) 118 | { 119 | database.jsonlist_printing.Remove(file); 120 | } 121 | } 122 | 123 | } 124 | //form.mydata.Rows[RowIndex].Cells["operation"].Value = "确认付款"; 125 | break; 126 | case "mode_downloading": 127 | MessageBox.Show("请先下载文件,打印后通知用户"); 128 | break; 129 | case "mode_printed": 130 | //file.changeStatusById("4"); 131 | MessageBox.Show("已通知打印完成"); 132 | break; 133 | default: 134 | MessageBox.Show("err:此操作方式不存在"); 135 | break; 136 | } 137 | 138 | } 139 | } 140 | 141 | class operation_ErrDownload_class : operation_class 142 | { 143 | public operation_ErrDownload_class(login_download form, ToJsonMy file, int RowIndex) 144 | { 145 | this.form = form; 146 | this.file = file; 147 | this.RowIndex = RowIndex; 148 | } 149 | override public void do_operation() 150 | { 151 | switch (form.display_mode) 152 | { 153 | case "mode_downloading": 154 | download_errfile_downloading_class downloading_class = new download_errfile_downloading_class(form, file, RowIndex); 155 | downloading_class.download(); 156 | break; 157 | case "mode_all": 158 | download_errfile_all_class all_class = new download_errfile_all_class(form, file, RowIndex); 159 | all_class.download(); 160 | break; 161 | default: 162 | MessageBox.Show("err:此种操作方式不存在!"); 163 | break; 164 | } 165 | } 166 | } 167 | 168 | class operation_ReDownload_class : operation_class 169 | { 170 | public operation_ReDownload_class(login_download form, ToJsonMy file, int RowIndex) 171 | { 172 | this.form = form; 173 | this.file = file; 174 | this.RowIndex = RowIndex; 175 | } 176 | public override void do_operation() 177 | { 178 | download_single_single_class download_class = new download_single_single_class(form, file, RowIndex); 179 | download_class.download(); 180 | } 181 | } 182 | 183 | class operation_PrintDirect_class : operation_class 184 | { 185 | public operation_PrintDirect_class(login_download form, ToJsonMy file, int RowIndex) 186 | { 187 | this.form = form; 188 | this.file = file; 189 | this.RowIndex = RowIndex; 190 | } 191 | override public void do_operation() 192 | { 193 | try 194 | { 195 | //if (!file.is_ibook) 196 | //{ 197 | // string filename = ""; 198 | // filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; 199 | 200 | // string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); 201 | // //if ((doc_extension == ".doc") || (doc_extension == ".docx")) 202 | // //{ 203 | // // filename += ".pdf"; 204 | // //} 205 | // if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) 206 | // { 207 | // //filename += ".pdf"; 208 | // throw new Exception("ppt文件请设置文件后打印"); 209 | // } 210 | 211 | // if (file.is_exsist) 212 | // { 213 | // print_class.direct_print_file(file); 214 | // file.changeStatusById("3"); 215 | // if (!database.jsonlist_printing.Contains(file)) 216 | // { 217 | // database.jsonlist_printing.Add(file); 218 | // } 219 | // if (database.jsonlist_downloaded.Contains(file)) 220 | // { 221 | // database.jsonlist_downloaded.Remove(file); 222 | // } 223 | // } 224 | // else 225 | // { 226 | // //download_single_single_class file_download = new download_single_single_class(form, file); 227 | // //file_download.download(); 228 | // form.mydata.Rows[RowIndex].Cells["operation"].Value = "重新下载"; 229 | // MessageBox.Show("当前文件不存在,请重新下载"); 230 | // } 231 | //} 232 | //else 233 | //{ 234 | // print_class.direct_print_ibook(file); 235 | //} 236 | switch (form.display_mode) 237 | { 238 | case "mode_all": 239 | file_print_direct_all_class print_all_class = new file_print_direct_all_class(form, file, RowIndex); 240 | print_all_class.file_print(); 241 | break; 242 | case "mode_downloaded": 243 | file_print_direct_downloaded_class print_downloaded_class = new file_print_direct_downloaded_class(form, file, RowIndex); 244 | print_downloaded_class.file_print(); 245 | break; 246 | case "mode_downloading": 247 | MessageBox.Show("请先下载文件后打印"); 248 | break; 249 | case "mode_printed": 250 | case "mode_printing": 251 | file_print_direct_others_class print_others_class = new file_print_direct_others_class(form, file, RowIndex); 252 | print_others_class.file_print(); 253 | break; 254 | } 255 | } 256 | catch (Exception excep) 257 | { 258 | MessageBox.Show(excep.Message, "无法打印"); 259 | } 260 | } 261 | } 262 | 263 | class operation_PrintAfterSet_class : operation_class 264 | { 265 | public operation_PrintAfterSet_class(login_download form, ToJsonMy file, int RowIndex) 266 | { 267 | this.form = form; 268 | this.file = file; 269 | this.RowIndex = RowIndex; 270 | } 271 | public override void do_operation() 272 | { 273 | try 274 | { 275 | //if (!file.is_ibook) 276 | //{ 277 | // if (file.is_exsist) 278 | // { 279 | // print_class.setbefore_print_file(file); 280 | // file.changeStatusById("3"); 281 | // if (!database.jsonlist_printing.Contains(file)) 282 | // { 283 | // database.jsonlist_printing.Add(file); 284 | // } 285 | // if (database.jsonlist_downloaded.Contains(file)) 286 | // { 287 | // database.jsonlist_downloaded.Remove(file); 288 | // } 289 | // } 290 | // else 291 | // { 292 | // //download_single_single_class file_download = new download_single_single_class(form, file); 293 | // //file_download.download(); 294 | // form.mydata.Rows[RowIndex].Cells["operation"].Value = "重新下载"; 295 | // MessageBox.Show("当前文件不存在,请重新下载"); 296 | // } 297 | //} 298 | //else 299 | //{ 300 | // print_class.setbefore_print_ibook(file); 301 | //} 302 | switch (form.display_mode) 303 | { 304 | case "mode_all": 305 | file_print_AfterSet_all_class print_all_class = new file_print_AfterSet_all_class(form, file, RowIndex); 306 | print_all_class.file_print(); 307 | break; 308 | case "mode_downloaded": 309 | file_print_AfterSet_downloaded_class print_downloaded_class = new file_print_AfterSet_downloaded_class(form, file, RowIndex); 310 | print_downloaded_class.file_print(); 311 | break; 312 | case "mode_downloading": 313 | MessageBox.Show("请先下载文件后打印"); 314 | break; 315 | case "mode_printed": 316 | case "mode_printing": 317 | file_print_AfterSet_others_class print_others_class = new file_print_AfterSet_others_class(form, file, RowIndex); 318 | print_others_class.file_print(); 319 | break; 320 | } 321 | } 322 | catch (Exception excep) 323 | { 324 | MessageBox.Show(excep.Message, "无法打印"); 325 | } 326 | } 327 | } 328 | 329 | class operation_cancel_class : operation_class 330 | { 331 | public operation_cancel_class(login_download form, ToJsonMy file, int RowIndex) 332 | { 333 | this.form = form; 334 | this.file = file; 335 | this.RowIndex = RowIndex; 336 | } 337 | public override void do_operation() 338 | { 339 | if (file.cancel()) 340 | { 341 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 342 | } 343 | } 344 | } 345 | 346 | class operation_EnsurePayed_class : operation_class 347 | { 348 | public operation_EnsurePayed_class(login_download form, ToJsonMy file, int RowIndex) 349 | { 350 | this.form = form; 351 | this.file = file; 352 | this.RowIndex = RowIndex; 353 | } 354 | public override void do_operation() 355 | { 356 | //DialogResult dr = MessageBox.Show("确认付款?", "", MessageBoxButtons.YesNo); 357 | //if (dr == DialogResult.Yes) 358 | //{ 359 | //file.ensure_payed(); 360 | //form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 361 | //} 362 | try 363 | { 364 | switch (form.display_mode) 365 | { 366 | case "mode_all": 367 | file.ensure_payed(); 368 | if (file.status == "打印完成") 369 | { 370 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 371 | if (database.jsonlist.Contains(file)) 372 | { 373 | database.jsonlist.Remove(file); 374 | } 375 | if (database.jsonlist_downloaded.Contains(file)) 376 | { 377 | database.jsonlist_downloaded.Remove(file); 378 | } 379 | if (database.jsonlist_err.Contains(file)) 380 | { 381 | database.jsonlist_err.Remove(file); 382 | } 383 | if (database.jsonlist_printed.Contains(file)) 384 | { 385 | database.jsonlist_printed.Remove(file); 386 | } 387 | if (database.jsonlist_printing.Contains(file)) 388 | { 389 | database.jsonlist_printing.Remove(file); 390 | } 391 | } 392 | else 393 | { 394 | form.mydata.Rows[RowIndex].Cells["pay_ensure_idex"].Value = "已支付"; 395 | } 396 | break; 397 | case "mode_downloading": 398 | case "mode_downloaded": 399 | case "mode_printing": 400 | file.ensure_payed(); 401 | form.mydata.Rows[RowIndex].Cells["pay_ensure_idex"].Value = "已支付"; 402 | break; 403 | case "mode_printed": 404 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 405 | if (database.jsonlist.Contains(file)) 406 | { 407 | database.jsonlist.Remove(file); 408 | } 409 | if (database.jsonlist_downloaded.Contains(file)) 410 | { 411 | database.jsonlist_downloaded.Remove(file); 412 | } 413 | if (database.jsonlist_err.Contains(file)) 414 | { 415 | database.jsonlist_err.Remove(file); 416 | } 417 | if (database.jsonlist_printed.Contains(file)) 418 | { 419 | database.jsonlist_printed.Remove(file); 420 | } 421 | if (database.jsonlist_printing.Contains(file)) 422 | { 423 | database.jsonlist_printing.Remove(file); 424 | } 425 | file.ensure_payed(); 426 | break; 427 | } 428 | } 429 | catch (Exception excep) 430 | { 431 | MessageBox.Show(excep.Message, "无法确认支付"); 432 | } 433 | } 434 | } 435 | 436 | class operation_GetRowFile_class : operation_class 437 | { 438 | public operation_GetRowFile_class(login_download form, ToJsonMy file, int RowIndex) 439 | { 440 | this.form = form; 441 | this.file = file; 442 | this.RowIndex = RowIndex; 443 | } 444 | public override void do_operation() 445 | { 446 | try 447 | { 448 | switch (form.display_mode) 449 | { 450 | case "mode_all": 451 | download_rawfile_all_class download_all_class = new download_rawfile_all_class(form, file, RowIndex); 452 | download_all_class.download(); 453 | break; 454 | case "mode_downloading": 455 | download_rawfile_downloading_class download_downloading_class = new download_rawfile_downloading_class(form, file, RowIndex); 456 | download_downloading_class.download(); 457 | break; 458 | case "mode_downloaded": 459 | case "mode_printing": 460 | case "mode_printed": 461 | download_rawfile_others_class download_others_class = new download_rawfile_others_class(form, file, RowIndex); 462 | download_others_class.download(); 463 | break; 464 | } 465 | } 466 | catch (Exception excep) 467 | { 468 | MessageBox.Show(excep.Message, "无法获取源文件"); 469 | } 470 | 471 | } 472 | } 473 | 474 | class operation_OpenFile_class : operation_class 475 | { 476 | public operation_OpenFile_class(login_download form, ToJsonMy file, int RowIndex) 477 | { 478 | this.form = form; 479 | this.file = file; 480 | this.RowIndex = RowIndex; 481 | } 482 | public override void do_operation() 483 | { 484 | try 485 | { 486 | switch (form.display_mode) 487 | { 488 | case "mode_all": 489 | if (file.status == "已上传") 490 | { 491 | MessageBox.Show("请先下载文件,再打开"); 492 | } 493 | else 494 | { 495 | if (!file.OpenFile()) 496 | { 497 | //MessageBox.Show("该文件不存在,请重新下载!"); 498 | //form.mydata.Rows[RowIndex].Cells["operation"].Value = "重新下载"; 499 | download_single_single_class download_class = new download_single_single_class(form, file, RowIndex); 500 | download_class.download(); 501 | } 502 | } 503 | break; 504 | case "mode_downloading": 505 | MessageBox.Show("请先下载文件,再打开"); 506 | break; 507 | case "mode_downloaded": 508 | case "mode_printing": 509 | case "mode_printed": 510 | if (!file.OpenFile()) 511 | { 512 | //MessageBox.Show("该文件不存在,请重新下载!"); 513 | //form.mydata.Rows[RowIndex].Cells["operation"].Value = "重新下载"; 514 | //MessageBox.Show("该文件不存在,正在自动下载!"); 515 | download_single_single_class download_class = new download_single_single_class(form, file, RowIndex); 516 | download_class.download(); 517 | } 518 | break; 519 | } 520 | } 521 | catch (Exception excep) 522 | { 523 | MessageBox.Show(excep.Message, "无法打开文件"); 524 | } 525 | 526 | } 527 | } 528 | 529 | class operation_GetUserinfo_class : operation_class 530 | { 531 | public operation_GetUserinfo_class(login_download form, ToJsonMy file, int RowIndex) 532 | { 533 | this.form = form; 534 | this.file = file; 535 | this.RowIndex = RowIndex; 536 | } 537 | public override void do_operation() 538 | { 539 | try 540 | { 541 | userInfo user = new userInfo(); 542 | user = file.UserMessage; 543 | MessageBox.Show("用户:" + user.name + " 学号:" + user.student_number + " 手机号:" + user.phone); 544 | } 545 | catch (Exception excep) 546 | { 547 | MessageBox.Show(excep.Message, "无法显示用户信息"); 548 | } 549 | 550 | } 551 | } 552 | 553 | class operation_GetRequirements_class : operation_class 554 | { 555 | public operation_GetRequirements_class(login_download form, ToJsonMy file, int RowIndex) 556 | { 557 | this.form = form; 558 | this.file = file; 559 | this.RowIndex = RowIndex; 560 | } 561 | public override void do_operation() 562 | { 563 | try 564 | { 565 | if (file.requirements != null) 566 | { 567 | MessageBox.Show(file.requirements, "备注信息"); 568 | } 569 | else 570 | { 571 | MessageBox.Show("该文件无备注信息"); 572 | } 573 | } 574 | catch (Exception excep) 575 | { 576 | MessageBox.Show(excep.Message, "无法显示备注信息"); 577 | } 578 | 579 | } 580 | } 581 | } -------------------------------------------------------------------------------- /Printer/Printer/print_class.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Spire.Pdf; 6 | using Spire.Pdf.Annotations; 7 | using Spire.Pdf.Widget; 8 | using System.Windows.Forms; 9 | using System.Drawing.Printing; 10 | using System.IO; 11 | 12 | namespace Printer 13 | { 14 | //class print_class 15 | //{ 16 | // static public void direct_print_file(ToJsonMy file) 17 | // { 18 | // string filename = ""; 19 | // filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; 20 | 21 | // string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); 22 | // //if ((doc_extension == ".doc") || (doc_extension == ".docx")) 23 | // //{ 24 | // // filename += ".pdf"; 25 | // //} 26 | // if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) 27 | // { 28 | // //filename += ".pdf"; 29 | // throw new Exception("ppt文件请设置文件后打印"); 30 | // } 31 | 32 | 33 | // if (file.copies == "现场打印") 34 | // { 35 | // throw new Exception("请选择详细设置后打印"); 36 | // } 37 | 38 | // PdfDocument doc = new PdfDocument(); 39 | // doc.LoadFromFile(file.file_SavePath + file.filename); 40 | 41 | // PrintDialog dialogprint = new PrintDialog(); 42 | 43 | 44 | // List printerlist = new List(); 45 | 46 | // string defaultprinter = dialogprint.PrinterSettings.PrinterName; 47 | // List printer_use_list = new List(); 48 | // printer_use_list = remember.ReadTextFileToList(@"printer_setting.sjc"); 49 | // if (printer_use_list.Count != 4) 50 | // { 51 | // throw new Exception("请先设置需要使用的打印机"); 52 | // } 53 | 54 | // if ((file.color == "0") && (file.double_side == "单面")) 55 | // { 56 | // dialogprint.PrinterSettings.PrinterName = printer_use_list[0]; 57 | // dialogprint.PrinterSettings.Duplex = Duplex.Simplex; 58 | // dialogprint.PrinterSettings.DefaultPageSettings.Color = false; 59 | // } 60 | 61 | // else if ((file.color == "1") && (file.double_side == "单面")) 62 | // { 63 | // dialogprint.PrinterSettings.PrinterName = printer_use_list[2]; 64 | // dialogprint.PrinterSettings.Duplex = Duplex.Simplex; 65 | // dialogprint.PrinterSettings.DefaultPageSettings.Color = true; 66 | // } 67 | // else if ((file.color == "0") && (file.double_side == "双面")) 68 | // { 69 | // dialogprint.PrinterSettings.PrinterName = printer_use_list[1]; 70 | // dialogprint.PrinterSettings.Duplex = Duplex.Vertical; 71 | // dialogprint.PrinterSettings.DefaultPageSettings.Color = false; 72 | 73 | // } 74 | // else if ((file.color == "1") && (file.double_side == "双面")) 75 | // { 76 | 77 | // dialogprint.PrinterSettings.PrinterName = printer_use_list[3]; 78 | // dialogprint.PrinterSettings.Duplex = Duplex.Vertical; 79 | // dialogprint.PrinterSettings.DefaultPageSettings.Color = true; 80 | // } 81 | 82 | // dialogprint.UseEXDialog = true; 83 | // dialogprint.AllowPrintToFile = true; 84 | // dialogprint.AllowSomePages = true; 85 | // dialogprint.PrinterSettings.MinimumPage = 1; 86 | // dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; 87 | // dialogprint.PrinterSettings.FromPage = 1; 88 | // dialogprint.PrinterSettings.Collate = true; 89 | // dialogprint.PrinterSettings.ToPage = doc.Pages.Count; 90 | 91 | // string copy = file.copies.Substring(0, 1); 92 | // dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); 93 | 94 | 95 | // doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 96 | // doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 97 | // doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 98 | // PrintDocument printdoc = doc.PrintDocument; 99 | 100 | // dialogprint.Document = printdoc; 101 | // printdoc.Print(); 102 | // //file.changeStatusById("4"); 103 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; 104 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; 105 | 106 | 107 | // } 108 | 109 | // static public void setbefore_print_file(ToJsonMy file) 110 | // { 111 | // //string filename = ""; 112 | // //filename = location_settings.file_path + "\\" + file.id + "_" + file.copies + "_" + file.double_side + "_" + file.student_number + "_" + file.name; 113 | // //string doc_extension = Path.GetExtension(location_settings.file_path + "/" + filename); 114 | // //if ((doc_extension == ".doc") || (doc_extension == ".docx")) 115 | // //{ 116 | // // filename += ".pdf"; 117 | 118 | // //} 119 | // //if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) 120 | // //{ 121 | // // filename += ".pdf"; 122 | 123 | // //} 124 | 125 | // PdfDocument doc = new PdfDocument(); 126 | // doc.LoadFromFile(file.file_SavePath + file.filename); 127 | 128 | // PrintDialog dialogprint = new PrintDialog(); 129 | 130 | // dialogprint.UseEXDialog = true; 131 | // dialogprint.AllowPrintToFile = true; 132 | // dialogprint.AllowSomePages = true; 133 | // dialogprint.PrinterSettings.MinimumPage = 1; 134 | // dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; 135 | // dialogprint.PrinterSettings.FromPage = 1; 136 | // dialogprint.PrinterSettings.Collate = true; 137 | // dialogprint.PrinterSettings.ToPage = doc.Pages.Count; 138 | // if (file.copies != "现场打印") 139 | // { 140 | // string copy = file.copies.Substring(0, 1); 141 | // dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); 142 | 143 | 144 | // } 145 | // if (dialogprint.ShowDialog() == DialogResult.OK) 146 | // { 147 | // doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 148 | // doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 149 | // doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 150 | // PrintDocument printdoc = doc.PrintDocument; 151 | 152 | // dialogprint.Document = printdoc; 153 | // printdoc.Print(); 154 | // //file.changeStatusById("4"); 155 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; 156 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; 157 | // } 158 | // } 159 | 160 | // static public void direct_print_ibook(ToJsonMy file) 161 | // { 162 | // string filename = ""; 163 | // filename = location_settings.ibook_path + file.name.Substring(0, file.name.Length - "【店内书】".Length); 164 | // if (File.Exists(@filename)) 165 | // { 166 | 167 | // PdfDocument doc = new PdfDocument(); 168 | // doc.LoadFromFile(filename); 169 | 170 | 171 | 172 | // PrintDialog dialogprint = new PrintDialog(); 173 | 174 | 175 | // List printer_use_list = new List(); 176 | // printer_use_list = remember.ReadTextFileToList(@"printer_setting.sjc"); 177 | // if (printer_use_list.Count != 4) 178 | // { 179 | // throw new Exception("请先设置需要使用的打印机"); 180 | // } 181 | 182 | // dialogprint.PrinterSettings.PrinterName = printer_use_list[1]; 183 | 184 | // dialogprint.PrinterSettings.Duplex = Duplex.Vertical; 185 | // dialogprint.PrinterSettings.DefaultPageSettings.Color = false; 186 | 187 | // dialogprint.UseEXDialog = true; 188 | // dialogprint.AllowPrintToFile = true; 189 | // dialogprint.AllowSomePages = true; 190 | // dialogprint.PrinterSettings.MinimumPage = 1; 191 | // dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; 192 | // dialogprint.PrinterSettings.FromPage = 1; 193 | // dialogprint.PrinterSettings.Collate = true; 194 | // dialogprint.PrinterSettings.ToPage = doc.Pages.Count; 195 | 196 | // string copy = file.copies.Substring(0, 1); 197 | // dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); 198 | 199 | // doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 200 | // doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 201 | // doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 202 | // PrintDocument printdoc = doc.PrintDocument; 203 | 204 | // dialogprint.Document = printdoc; 205 | // printdoc.Print(); 206 | // //file.changeStatusById("4"); 207 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; 208 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; 209 | // } 210 | // else 211 | // { 212 | // MessageBox.Show("本店电子书路径有误,请改正"); 213 | // } 214 | // } 215 | 216 | // static public void setbefore_print_ibook(ToJsonMy file) 217 | // { 218 | // string filename = ""; 219 | 220 | // filename = location_settings.ibook_path + file.name.Substring(0, file.name.Length - "【店内书】".Length); 221 | // if (File.Exists(@filename)) 222 | // { 223 | 224 | // PdfDocument doc = new PdfDocument(); 225 | // doc.LoadFromFile(filename); 226 | // PrintDialog dialogprint = new PrintDialog(); 227 | // dialogprint.UseEXDialog = true; 228 | // dialogprint.AllowPrintToFile = true; 229 | // dialogprint.AllowSomePages = true; 230 | // dialogprint.PrinterSettings.MinimumPage = 1; 231 | // dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; 232 | // dialogprint.PrinterSettings.FromPage = 1; 233 | // dialogprint.PrinterSettings.Collate = true; 234 | // dialogprint.PrinterSettings.ToPage = doc.Pages.Count; 235 | 236 | // string copy = file.copies.Substring(0, 1); 237 | // dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); 238 | // if (dialogprint.ShowDialog() == DialogResult.OK) 239 | // { 240 | // doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 241 | // doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 242 | // doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 243 | // PrintDocument printdoc = doc.PrintDocument; 244 | 245 | // dialogprint.Document = printdoc; 246 | // printdoc.Print(); 247 | // //file.changeStatusById("4"); 248 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["status"].Value = "已打印"; 249 | // //form.mydata.Rows[form.mydata.CurrentRow.Index].Cells["operation"].Value = "确认付款"; 250 | // } 251 | 252 | // } 253 | // else 254 | // { 255 | // MessageBox.Show("本店电子书路径有误,请改正"); 256 | // } 257 | 258 | 259 | 260 | // } 261 | 262 | //} 263 | 264 | class file_print_class 265 | { 266 | public login_download form; 267 | public ToJsonMy file; 268 | public int RowIndex; 269 | 270 | public void file_print() 271 | { 272 | //string doc_extension = Path.GetExtension(file.file_SavePath + file.filename); 273 | //if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) 274 | //{ 275 | // throw new Exception("ppt文件请设置文件后打印"); 276 | //} 277 | //if (file.copies == "现场打印") 278 | //{ 279 | // throw new Exception("请选择详细设置后打印"); 280 | //} 281 | 282 | is_print(); 283 | 284 | PdfDocument doc = new PdfDocument(); 285 | doc.LoadFromFile(file.file_SavePath + file.filename); 286 | 287 | PrintDialog dialogprint = new PrintDialog(); 288 | 289 | 290 | List printerlist = new List(); 291 | 292 | string defaultprinter = dialogprint.PrinterSettings.PrinterName; 293 | List printer_use_list = new List(); 294 | printer_use_list = remember.ReadTextFileToList(@"printer_setting.sjc"); 295 | if (printer_use_list.Count != 4) 296 | { 297 | throw new Exception("请先设置需要使用的打印机"); 298 | } 299 | 300 | if ((file.color == "0") && (file.double_side == "单面")) 301 | { 302 | dialogprint.PrinterSettings.PrinterName = printer_use_list[0]; 303 | dialogprint.PrinterSettings.Duplex = Duplex.Simplex; 304 | dialogprint.PrinterSettings.DefaultPageSettings.Color = false; 305 | } 306 | 307 | else if ((file.color == "1") && (file.double_side == "单面")) 308 | { 309 | dialogprint.PrinterSettings.PrinterName = printer_use_list[2]; 310 | dialogprint.PrinterSettings.Duplex = Duplex.Simplex; 311 | dialogprint.PrinterSettings.DefaultPageSettings.Color = true; 312 | } 313 | else if ((file.color == "0") && (file.double_side == "双面")) 314 | { 315 | dialogprint.PrinterSettings.PrinterName = printer_use_list[1]; 316 | dialogprint.PrinterSettings.Duplex = Duplex.Vertical; 317 | dialogprint.PrinterSettings.DefaultPageSettings.Color = false; 318 | 319 | } 320 | else if ((file.color == "1") && (file.double_side == "双面")) 321 | { 322 | 323 | dialogprint.PrinterSettings.PrinterName = printer_use_list[3]; 324 | dialogprint.PrinterSettings.Duplex = Duplex.Vertical; 325 | dialogprint.PrinterSettings.DefaultPageSettings.Color = true; 326 | } 327 | 328 | dialogprint.UseEXDialog = true; 329 | dialogprint.AllowPrintToFile = true; 330 | dialogprint.AllowSomePages = true; 331 | dialogprint.PrinterSettings.MinimumPage = 1; 332 | dialogprint.PrinterSettings.MaximumPage = doc.Pages.Count; 333 | dialogprint.PrinterSettings.FromPage = 1; 334 | dialogprint.PrinterSettings.Collate = true; 335 | dialogprint.PrinterSettings.ToPage = doc.Pages.Count; 336 | 337 | string copy = file.copies.Substring(0, 1); 338 | dialogprint.PrinterSettings.Copies = (short)Int32.Parse(copy); 339 | 340 | 341 | //doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 342 | //doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 343 | //doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 344 | //PrintDocument printdoc = doc.PrintDocument; 345 | 346 | //dialogprint.Document = printdoc; 347 | //printdoc.Print(); 348 | 349 | ensure_print(dialogprint, doc); 350 | } 351 | 352 | virtual public void is_print() 353 | { 354 | 355 | } 356 | virtual public void ensure_print(PrintDialog dialogprint, PdfDocument doc) { } 357 | } 358 | 359 | class file_print_direct_class : file_print_class 360 | { 361 | public file_print_direct_class() { } 362 | public file_print_direct_class(login_download form, ToJsonMy file, int RowIndex) 363 | { 364 | this.form = form; 365 | this.file = file; 366 | this.RowIndex = RowIndex; 367 | } 368 | 369 | public override void is_print() 370 | { 371 | base.is_print(); 372 | string doc_extension = Path.GetExtension(file.file_SavePath + file.filename); 373 | if ((doc_extension == ".ppt") || (doc_extension == ".pptx")) 374 | { 375 | throw new Exception("ppt文件请设置文件后打印"); 376 | } 377 | if (file.copies == "现场打印") 378 | { 379 | throw new Exception("请选择详细设置后打印"); 380 | } 381 | if (!file.is_exsist_file) 382 | { 383 | //form.mydata.Rows[RowIndex].Cells["operation"].Value = "重新下载"; 384 | //throw new Exception("当前文件不存在,请重新下载"); 385 | //MessageBox.Show("该文件不存在,正在自动下载!"); 386 | download_single_single_class download_class = new download_single_single_class(form, file, RowIndex); 387 | download_class.download(); 388 | } 389 | } 390 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 391 | { 392 | base.ensure_print(dialogprint, doc); 393 | doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 394 | doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 395 | doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 396 | PrintDocument printdoc = doc.PrintDocument; 397 | 398 | dialogprint.Document = printdoc; 399 | printdoc.Print(); 400 | } 401 | } 402 | 403 | class file_print_direct_all_class : file_print_direct_class 404 | { 405 | public file_print_direct_all_class(login_download form, ToJsonMy file, int RowIndex) 406 | { 407 | this.form = form; 408 | this.file = file; 409 | this.RowIndex = RowIndex; 410 | 411 | } 412 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 413 | { 414 | base.ensure_print(dialogprint, doc); 415 | if (file.status == "已下载") 416 | { 417 | file.status = "3"; 418 | form.mydata.Rows[RowIndex].Cells["status"].Value = "已打印"; 419 | file.MoveFromListToList(database.jsonlist_downloaded, database.jsonlist_printing); 420 | file.changeStatusById("3"); 421 | } 422 | } 423 | public override void is_print() 424 | { 425 | base.is_print(); 426 | if (file.status == "已上传") 427 | { 428 | throw new Exception("请先下载文件后打印"); 429 | } 430 | } 431 | 432 | } 433 | 434 | class file_print_direct_downloaded_class : file_print_direct_class 435 | { 436 | public file_print_direct_downloaded_class(login_download form, ToJsonMy file, int RowIndex) 437 | { 438 | this.form = form; 439 | this.file = file; 440 | this.RowIndex = RowIndex; 441 | } 442 | 443 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 444 | { 445 | base.ensure_print(dialogprint, doc); 446 | file.status = "3"; 447 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 448 | file.MoveFromListToList(database.jsonlist_downloaded, database.jsonlist_printing); 449 | file.changeStatusById("3"); 450 | } 451 | } 452 | 453 | class file_print_direct_others_class : file_print_direct_class 454 | { 455 | public file_print_direct_others_class(login_download form, ToJsonMy file, int RowIndex) 456 | { 457 | this.form = form; 458 | this.file = file; 459 | this.RowIndex = RowIndex; 460 | } 461 | 462 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 463 | { 464 | base.ensure_print(dialogprint, doc); 465 | } 466 | } 467 | 468 | 469 | 470 | class file_print_AfterSet_class : file_print_class 471 | { 472 | public file_print_AfterSet_class() { } 473 | public file_print_AfterSet_class(login_download form, ToJsonMy file, int RowIndex) 474 | { 475 | this.form = form; 476 | this.file = file; 477 | this.RowIndex = RowIndex; 478 | } 479 | 480 | public override void is_print() 481 | { 482 | base.is_print(); 483 | if (!file.is_exsist_file) 484 | { 485 | //form.mydata.Rows[RowIndex].Cells["operation"].Value = "重新下载"; 486 | //throw new Exception("当前文件不存在,请重新下载"); 487 | //MessageBox.Show("该文件不存在,正在自动下载!"); 488 | download_single_single_class download_class = new download_single_single_class(form, file, RowIndex); 489 | download_class.download(); 490 | } 491 | } 492 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 493 | { 494 | base.ensure_print(dialogprint, doc); 495 | } 496 | } 497 | 498 | class file_print_AfterSet_all_class : file_print_AfterSet_class 499 | { 500 | public file_print_AfterSet_all_class(login_download form, ToJsonMy file, int RowIndex) 501 | { 502 | this.form = form; 503 | this.file = file; 504 | this.RowIndex = RowIndex; 505 | 506 | } 507 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 508 | { 509 | base.ensure_print(dialogprint, doc); 510 | if (dialogprint.ShowDialog() == DialogResult.OK) 511 | { 512 | doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 513 | doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 514 | doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 515 | PrintDocument printdoc = doc.PrintDocument; 516 | 517 | dialogprint.Document = printdoc; 518 | printdoc.Print(); 519 | if (file.status == "已下载") 520 | { 521 | file.status = "3"; 522 | form.mydata.Rows[RowIndex].Cells["status"].Value = "已打印"; 523 | file.MoveFromListToList(database.jsonlist_downloaded, database.jsonlist_printing); 524 | file.changeStatusById("3"); 525 | } 526 | } 527 | } 528 | public override void is_print() 529 | { 530 | base.is_print(); 531 | if (file.status == "已上传") 532 | { 533 | throw new Exception("请先下载文件后打印"); 534 | } 535 | } 536 | } 537 | 538 | class file_print_AfterSet_downloaded_class : file_print_AfterSet_class 539 | { 540 | public file_print_AfterSet_downloaded_class(login_download form, ToJsonMy file, int RowIndex) 541 | { 542 | this.form = form; 543 | this.file = file; 544 | this.RowIndex = RowIndex; 545 | } 546 | 547 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 548 | { 549 | base.ensure_print(dialogprint, doc); 550 | if (dialogprint.ShowDialog() == DialogResult.OK) 551 | { 552 | doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 553 | doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 554 | doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 555 | PrintDocument printdoc = doc.PrintDocument; 556 | 557 | dialogprint.Document = printdoc; 558 | printdoc.Print(); 559 | file.status = "3"; 560 | form.mydata.Rows.Remove(form.mydata.Rows[RowIndex]); 561 | file.MoveFromListToList(database.jsonlist_downloaded, database.jsonlist_printing); 562 | file.changeStatusById("3"); 563 | } 564 | } 565 | } 566 | 567 | class file_print_AfterSet_others_class : file_print_AfterSet_class 568 | { 569 | public file_print_AfterSet_others_class(login_download form, ToJsonMy file, int RowIndex) 570 | { 571 | this.form = form; 572 | this.file = file; 573 | this.RowIndex = RowIndex; 574 | } 575 | 576 | public override void ensure_print(PrintDialog dialogprint, PdfDocument doc) 577 | { 578 | base.ensure_print(dialogprint, doc); 579 | if (dialogprint.ShowDialog() == DialogResult.OK) 580 | { 581 | doc.PrintFromPage = dialogprint.PrinterSettings.FromPage; 582 | doc.PrintToPage = dialogprint.PrinterSettings.ToPage; 583 | doc.PrintDocument.PrinterSettings = dialogprint.PrinterSettings; 584 | PrintDocument printdoc = doc.PrintDocument; 585 | 586 | dialogprint.Document = printdoc; 587 | printdoc.Print(); 588 | } 589 | } 590 | } 591 | } 592 | -------------------------------------------------------------------------------- /Printer/Printer/remember.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Management; 6 | using System.IO; 7 | using Newtonsoft.Json; 8 | namespace Printer 9 | { 10 | class remember 11 | { 12 | //将List转换为TXT文件 13 | /// 14 | /// List转换成TXT 15 | /// 16 | /// 17 | /// 18 | public static void WriteListToTextFile(List list, string txtFile) 19 | { 20 | /*if (!File.Exists(txtFile)) 21 | { 22 | File.Create(txtFile); 23 | }*/ 24 | //创建一个文件流,用以写入或者创建一个StreamWriter 25 | FileStream fs = new FileStream(txtFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); 26 | StreamWriter sw = new StreamWriter(fs); 27 | sw.Flush(); 28 | // 使用StreamWriter来往文件中写入内容 29 | sw.BaseStream.Seek(0, SeekOrigin.Begin); 30 | for (int i = 0; i < list.Count; i++) sw.WriteLine(list[i]); 31 | //关闭此文件t 32 | sw.Flush(); 33 | sw.Close(); 34 | fs.Close(); 35 | } 36 | /// 37 | /// 写入String转成Text 38 | /// 39 | /// 40 | /// 41 | public static void WriteStringToTextFile(string list, string txtFile) 42 | { 43 | /*if (!File.Exists(txtFile)) 44 | { 45 | File.Create(txtFile); 46 | }*/ 47 | //创建一个文件流,用以写入或者创建一个StreamWriter 48 | FileStream fs = new FileStream(txtFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); 49 | StreamWriter sw = new StreamWriter(fs); 50 | sw.Flush(); 51 | // 使用StreamWriter来往文件中写入内容 52 | sw.BaseStream.Seek(0, SeekOrigin.Begin); 53 | sw.WriteLine(list); 54 | //关闭此文件t 55 | sw.Flush(); 56 | sw.Close(); 57 | fs.Close(); 58 | } 59 | public static void WriteJsonToTextFile(List list, string txtFile) 60 | { 61 | /*if (!File.Exists(txtFile)) 62 | { 63 | File.Create(txtFile); 64 | }*/ 65 | //创建一个文件流,用以写入或者创建一个StreamWriter 66 | FileStream fs = new FileStream(txtFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); 67 | StreamWriter sw = new StreamWriter(fs); 68 | sw.Flush(); 69 | //string output = JsonConvert.SerializeObject(product);//类转换成Json字符串 70 | // 使用StreamWriter来往文件中写入内容 71 | sw.BaseStream.Seek(0, SeekOrigin.Begin); 72 | for (int i = 0; i < list.Count; i++) 73 | { 74 | string output = JsonConvert.SerializeObject(list[i]);//类转换成Json字符串 75 | //sw.Write(list[i].id); sw.Write(list[i].name); 76 | sw.WriteLine(output); 77 | } 78 | //关闭此文件t 79 | sw.Flush(); 80 | sw.Close(); 81 | fs.Close(); 82 | } 83 | //读取文本文件转换为List 84 | /// 85 | /// 读取文本文件转换为List 86 | /// 87 | /// 88 | /// 89 | public static List ReadTextFileToList(string fileName) 90 | { 91 | FileStream fs; 92 | if (!File.Exists(fileName)) 93 | { 94 | fs = File.Create(fileName); 95 | 96 | } 97 | else 98 | { 99 | fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); 100 | } 101 | List list = new List(); 102 | StreamReader sr = new StreamReader(fs); 103 | //使用StreamReader类来读取文件 104 | sr.BaseStream.Seek(0, SeekOrigin.Begin); 105 | // 从数据流中读取每一行,直到文件的最后一行 106 | string tmp = sr.ReadLine(); 107 | while (tmp != null) 108 | { 109 | list.Add(tmp); 110 | tmp = sr.ReadLine(); 111 | } 112 | //关闭此StreamReader对象 113 | sr.Close(); 114 | fs.Close(); 115 | return list; 116 | } 117 | //读取文本文件转换为List 118 | /// 119 | /// 读取文本文件转换为List 120 | /// 121 | /// 122 | /// 123 | public static List ReadJsonFileToList(string fileName) 124 | { 125 | if (!File.Exists(fileName)) 126 | { 127 | File.Create(fileName); 128 | } 129 | FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); 130 | List list = new List(); 131 | ToJsonMy my = new ToJsonMy(); 132 | StreamReader sr = new StreamReader(fs); 133 | //使用StreamReader类来读取文件 134 | sr.BaseStream.Seek(0, SeekOrigin.Begin); 135 | // 从数据流中读取每一行,直到文件的最后一行 136 | string tmp = sr.ReadLine(); 137 | while (tmp != null) 138 | { 139 | my = JsonConvert.DeserializeObject(tmp); 140 | //if(my.status!="5") 141 | //{ 142 | list.Add(my); 143 | //} 144 | tmp = sr.ReadLine(); 145 | } 146 | //关闭此StreamReader对象 147 | sr.Close(); 148 | fs.Close(); 149 | return list; 150 | } 151 | 152 | public static string ReadTextFileToString(string fileName) 153 | { 154 | FileStream fs; 155 | if (!File.Exists(fileName)) 156 | { 157 | fs = File.Create(fileName); 158 | 159 | } 160 | else 161 | { 162 | fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); 163 | } 164 | StreamReader sr = new StreamReader(fs); 165 | //使用StreamReader类来读取文件 166 | sr.BaseStream.Seek(0, SeekOrigin.Begin); 167 | // 从数据流中读取每一行,直到文件的最后一行 168 | string tmp = sr.ReadToEnd(); 169 | //关闭此StreamReader对象 170 | sr.Close(); 171 | fs.Close(); 172 | return tmp; 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /Printer/output/Newtonsoft.Json.Net35.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/output/Newtonsoft.Json.Net35.dll -------------------------------------------------------------------------------- /Printer/output/Printer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/output/Printer.exe -------------------------------------------------------------------------------- /Printer/output/Spire.License.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/output/Spire.License.dll -------------------------------------------------------------------------------- /Printer/output/Spire.License.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spire.License 5 | 6 | 7 | 8 | 9 | Indicates whether the lincese puchase date is during one year. 10 | 11 | 12 | 13 | 14 | If current license object is converted from a previouse version license object, 15 | this field will be set to the version of the original license object. 16 | Otherwise it's null. 17 | 18 | 19 | 20 | 21 | Provides a license by a license file path, which will be used for loading license. 22 | 23 | License file full path. 24 | 25 | 26 | 27 | Sets the license file name, which will be used for loading license. 28 | 29 | License file name. 30 | 31 | 32 | 33 | 34 | Provides a license by a license file object, which will be used for loading license. 35 | 36 | License file object. 37 | 38 | 39 | 40 | Provides a license by a license stream, which will be used for loading license. 41 | 42 | License data stream. 43 | 44 | 45 | 46 | Provides a license by a license key, which will be used for loading license. 47 | 48 | The value of the Key attribute of the element License of you license xml file. 49 | 50 | 51 | 52 | Provides a license by a license key, which will be used for loading license. 53 | 54 | The value of the Key attribute of the element License of you license xml file. 55 | The serialization to verify license key. 56 | 57 | 58 | 59 | Clear all cached license. 60 | 61 | 62 | 63 | 64 | Load the license provided by current setting to the license cache. 65 | 66 | 67 | 68 | 69 | Load the license provided by current setting to the license cache. 70 | 71 | Runtime product type 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Indicates whether the lincese puchase date is during one year. 83 | 84 | 85 | 86 | 87 | Indicates whether the lincese puchase date is during one year. 88 | 89 | 90 | 91 | 92 | Indicates whether the lincese puchase date is during one year. 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /Printer/output/Spire.Pdf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/Printer/output/Spire.Pdf.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Printer 2 | 云印新版打印店客户端 3 | 4 | ## 问题 5 | 6 | * 密码md5之后保存 7 | * 下拉滚动条 8 | 9 | -------------------------------------------------------------------------------- /技术文档.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YunYinORG/printer/c7efda5231d1f52acc39033a40b532721e87c3a8/技术文档.docx --------------------------------------------------------------------------------