Browse Source

UAS_PRINT提交

caosy 2 years ago
parent
commit
de9d78660b

+ 4 - 1
UAS_PRINT/Form2.cs

@@ -24,8 +24,10 @@ namespace UAS_PRINT
         }
         private static HttpListener httpPostRequest = new HttpListener();
         private Thread ThrednHttpPostRequest;
+
         private void Form2_Load(object sender, EventArgs e)
         {
+
             string path = Application.ExecutablePath;
             RegistryKey rk = Registry.LocalMachine;
             RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
@@ -33,7 +35,8 @@ namespace UAS_PRINT
             rk2.Close();
             rk.Close();
             httpPostRequest.Prefixes.Add("http://localhost:9100/");
-           httpPostRequest.Start();
+           // httpPostRequest.Prefixes.Add("https://localhost:9100/");
+            httpPostRequest.Start();
 
             ThrednHttpPostRequest = new Thread(new ThreadStart(httpPostRequestHandle));
             ThrednHttpPostRequest.Start();

+ 28 - 17
UAS_PRINT/PrintHandler.cs

@@ -18,8 +18,10 @@ namespace UAS_PRINT
         //打印图片集合
         static List<Bitmap> bitmaps = new List<Bitmap>();
         static DataTable dt = new DataTable();
-     
 
+        static int code = 0;
+        static string first = "";
+        static string last = "";
         public static void zplprint(string str, string PrinterName)
         {
             Dictionary<string, object> data = PrintHelper.ToDictionary(str);
@@ -185,6 +187,9 @@ namespace UAS_PRINT
                         }
                     }               
             }
+            code = 0;
+            first = "";
+            last = "";
             foreach (var item in barcode)
             {
                 int number = Settings.Default.Printnum;
@@ -226,32 +231,38 @@ namespace UAS_PRINT
                         else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
                         {
                             dr[itemc.Key] = itemc.Value.ToString().Replace("\"", "");
+                            if (code == 0)
+                             first = itemc.Value.ToString().Replace("\"", "");
+                            if(code == barcode.Count -1)
+                             last  = itemc.Value.ToString().Replace("\"", "");
                         }
                     }
                     dt.Rows.Add(dr);
                 }
+                code++;
             }
             try
             {
                 string logout_confirm = MessageBox.Show("打印" + dt.Rows.Count + "张条码,是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
+                //string logout_confirm = MessageBox.Show("打印" + dt.Rows.Count + "张条码,"+first+"到"+last+",是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
                 if (logout_confirm == "Yes")
                 {
-                    Report.PrintSettings.ShowDialog = false;
-                    byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(chooseprintername);
-                    chooseprintername = Encoding.UTF8.GetString(buffer);
-                    Report.PrintSettings.Printer = chooseprintername.Replace("\\\\", "\\");
-                    foreach (DataRow dr in dt.Rows)
-                    {
-                        DataTable dta = dt.Clone();
-                        dta.Rows.Add(dr.ItemArray);
-                        Report.RegisterData(dta, label_type);
-                        Report.GetDataSource(label_type).Enabled = true;
-                        Report.Print();
-                    }
-                    //Report.RegisterData(dt, label_type);
-                    //Report.GetDataSource(label_type).Enabled = true;
-                    //Report.Print();
-                }
+               Report.PrintSettings.ShowDialog = false;
+               byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(chooseprintername);
+               chooseprintername = Encoding.UTF8.GetString(buffer);
+               Report.PrintSettings.Printer = chooseprintername.Replace("\\\\", "\\");
+                    //foreach (DataRow dr in dt.Rows)
+                    //{
+                    //    DataTable dta = dt.Clone();
+                    //    dta.Rows.Add(dr.ItemArray);
+                    //    Report.RegisterData(dta, label_type);
+                    //    Report.GetDataSource(label_type).Enabled = true;
+                    //    Report.Print();
+                    //}
+                Report.RegisterData(dt, label_type);
+                Report.GetDataSource(label_type).Enabled = true;
+                Report.Print();
+            }
                
             }
             catch(Exception ex)

+ 2 - 2
UAS_PRINT/Properties/Settings.Designer.cs

@@ -25,7 +25,7 @@ namespace UAS_PRINT.Properties {
         
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("ftp://192.168.1.105")]
+        [global::System.Configuration.DefaultSettingValueAttribute("ftp://81.71.42.91")]
         public string ftpaddress {
             get {
                 return ((string)(this["ftpaddress"]));
@@ -49,7 +49,7 @@ namespace UAS_PRINT.Properties {
         
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("vsftpd")]
+        [global::System.Configuration.DefaultSettingValueAttribute("uas321vsftpd2021")]
         public string ftppassword {
             get {
                 return ((string)(this["ftppassword"]));

+ 2 - 2
UAS_PRINT/Properties/Settings.settings

@@ -3,13 +3,13 @@
   <Profiles />
   <Settings>
     <Setting Name="ftpaddress" Type="System.String" Scope="User">
-      <Value Profile="(Default)">ftp://192.168.1.105</Value>
+      <Value Profile="(Default)">ftp://81.71.42.91</Value>
     </Setting>
     <Setting Name="ftpuser" Type="System.String" Scope="User">
       <Value Profile="(Default)">vsftpd</Value>
     </Setting>
     <Setting Name="ftppassword" Type="System.String" Scope="User">
-      <Value Profile="(Default)">vsftpd</Value>
+      <Value Profile="(Default)">uas321vsftpd2021</Value>
     </Setting>
     <Setting Name="ifuseftp" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">False</Value>

+ 6 - 1
UAS_PRINT/UAS_PRINT.csproj

@@ -4,7 +4,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{B8BBF7C9-BCCA-49B0-BC22-6519B594AB19}</ProjectGuid>
+    <ProjectGuid>{B2428D57-87E0-4EFD-AF54-C52C4A964D1F}</ProjectGuid>
     <OutputType>WinExe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>UAS_PRINT</RootNamespace>
@@ -47,6 +47,11 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>.\FastReport.Editor.dll</HintPath>
     </Reference>
+    <Reference Include="Interop.BarTender, Version=10.1.4.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+      <HintPath>..\UAS_MES_LT\Tool\Interop.BarTender.dll</HintPath>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
       <Private>True</Private>

+ 2 - 2
UAS_PRINT/app.config

@@ -8,13 +8,13 @@
     <userSettings>
         <UAS_PRINT.Properties.Settings>
             <setting name="ftpaddress" serializeAs="String">
-                <value>ftp://192.168.1.105</value>
+                <value>ftp://81.71.42.91</value>
             </setting>
             <setting name="ftpuser" serializeAs="String">
                 <value>vsftpd</value>
             </setting>
             <setting name="ftppassword" serializeAs="String">
-                <value>vsftpd</value>
+                <value>uas321vsftpd2021</value>
             </setting>
             <setting name="ifuseftp" serializeAs="String">
                 <value>False</value>

+ 1 - 0
UAS_PRINT/ftpOperater.cs

@@ -159,6 +159,7 @@ namespace UAS_PRINT
                 reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + fileName));
                 reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
                 reqFTP.UseBinary = true;
+                reqFTP.UsePassive = false;
                 reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
                 FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                 Stream ftpStream = response.GetResponseStream();