Patrick Germain 8 mēneši atpakaļ
vecāks
revīzija
f4b29a5e62
4 mainītis faili ar 69 papildinājumiem un 44 dzēšanām
  1. 1 1
      Fuel_ASO/Fuel_ASO.csproj
  2. 28 16
      Fuel_ASO/f_about.Designer.cs
  3. 24 12
      Fuel_ASO/f_about.cs
  4. 16 15
      Fuel_ASO/f_presta.cs

+ 1 - 1
Fuel_ASO/Fuel_ASO.csproj

@@ -428,7 +428,7 @@
   </PropertyGroup>
   <ProjectExtensions>
     <VisualStudio>
-      <UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_StartDate="2018/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_UseUniversalClock="True" BuildVersion_BuildVersioningStyle="None.None.YearDayOfYearStamp.Increment" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_IncrementBeforeBuild="False" BuildVersion_DetectChanges="False" />
+      <UserProperties BuildVersion_DetectChanges="False" BuildVersion_IncrementBeforeBuild="False" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.YearDayOfYearStamp.Increment" BuildVersion_UseUniversalClock="True" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2018/1/1" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 28 - 16
Fuel_ASO/f_about.Designer.cs

@@ -280,7 +280,7 @@
             this.bt_send.TabIndex = 31;
             this.bt_send.Text = "Envoi Serveur";
             this.bt_send.UseVisualStyleBackColor = true;
-            this.bt_send.Click += new System.EventHandler(bt_send_Click);
+            this.bt_send.Click += new System.EventHandler(this.bt_send_Click);
             // 
             // bt_maj
             // 
@@ -396,7 +396,7 @@
             this.checkBoxAPI.AutoSize = true;
             this.checkBoxAPI.Checked = true;
             this.checkBoxAPI.CheckState = System.Windows.Forms.CheckState.Indeterminate;
-            this.checkBoxAPI.Location = new System.Drawing.Point(543, 258);
+            this.checkBoxAPI.Location = new System.Drawing.Point(543, 94);
             this.checkBoxAPI.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxAPI.Name = "checkBoxAPI";
             this.checkBoxAPI.Size = new System.Drawing.Size(80, 24);
@@ -406,7 +406,7 @@
             // 
             // bt_chekAPI
             // 
-            this.bt_chekAPI.Location = new System.Drawing.Point(384, 251);
+            this.bt_chekAPI.Location = new System.Drawing.Point(384, 87);
             this.bt_chekAPI.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_chekAPI.Name = "bt_chekAPI";
             this.bt_chekAPI.Size = new System.Drawing.Size(134, 35);
@@ -418,7 +418,7 @@
             // label6
             // 
             this.label6.AutoSize = true;
-            this.label6.Location = new System.Drawing.Point(4, 265);
+            this.label6.Location = new System.Drawing.Point(4, 101);
             this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(241, 20);
@@ -427,7 +427,7 @@
             // 
             // textCopieAPI
             // 
-            this.textCopieAPI.Location = new System.Drawing.Point(52, 288);
+            this.textCopieAPI.Location = new System.Drawing.Point(52, 124);
             this.textCopieAPI.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textCopieAPI.Name = "textCopieAPI";
             this.textCopieAPI.Size = new System.Drawing.Size(571, 26);
@@ -442,6 +442,7 @@
             this.bt_fold.TabIndex = 56;
             this.bt_fold.Text = "...";
             this.bt_fold.UseVisualStyleBackColor = true;
+            this.bt_fold.Visible = false;
             this.bt_fold.Click += new System.EventHandler(this.bt_fold_Click);
             // 
             // label5
@@ -453,6 +454,7 @@
             this.label5.Size = new System.Drawing.Size(322, 20);
             this.label5.TabIndex = 54;
             this.label5.Text = "Chemin pour copie locale vers le serveur ISS";
+            this.label5.Visible = false;
             // 
             // textCopieLocal
             // 
@@ -463,10 +465,11 @@
             this.textCopieLocal.Name = "textCopieLocal";
             this.textCopieLocal.Size = new System.Drawing.Size(571, 26);
             this.textCopieLocal.TabIndex = 53;
+            this.textCopieLocal.Visible = false;
             // 
             // bt_sav
             // 
-            this.bt_sav.Location = new System.Drawing.Point(477, 475);
+            this.bt_sav.Location = new System.Drawing.Point(477, 166);
             this.bt_sav.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_sav.Name = "bt_sav";
             this.bt_sav.Size = new System.Drawing.Size(148, 35);
@@ -478,7 +481,7 @@
             // checkAll
             // 
             this.checkAll.AutoSize = true;
-            this.checkAll.Location = new System.Drawing.Point(70, 482);
+            this.checkAll.Location = new System.Drawing.Point(22, 163);
             this.checkAll.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkAll.Name = "checkAll";
             this.checkAll.Size = new System.Drawing.Size(389, 24);
@@ -491,26 +494,28 @@
             this.checkBoxSignalR.AutoSize = true;
             this.checkBoxSignalR.Checked = true;
             this.checkBoxSignalR.CheckState = System.Windows.Forms.CheckState.Indeterminate;
-            this.checkBoxSignalR.Location = new System.Drawing.Point(543, 188);
+            this.checkBoxSignalR.Location = new System.Drawing.Point(543, 401);
             this.checkBoxSignalR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxSignalR.Name = "checkBoxSignalR";
             this.checkBoxSignalR.Size = new System.Drawing.Size(80, 24);
             this.checkBoxSignalR.TabIndex = 50;
             this.checkBoxSignalR.Text = "Vérifié";
             this.checkBoxSignalR.UseVisualStyleBackColor = true;
+            this.checkBoxSignalR.Visible = false;
             // 
             // checkBoxBin
             // 
             this.checkBoxBin.AutoSize = true;
             this.checkBoxBin.Checked = true;
             this.checkBoxBin.CheckState = System.Windows.Forms.CheckState.Indeterminate;
-            this.checkBoxBin.Location = new System.Drawing.Point(543, 106);
+            this.checkBoxBin.Location = new System.Drawing.Point(543, 259);
             this.checkBoxBin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.checkBoxBin.Name = "checkBoxBin";
             this.checkBoxBin.Size = new System.Drawing.Size(80, 24);
             this.checkBoxBin.TabIndex = 49;
             this.checkBoxBin.Text = "Vérifié";
             this.checkBoxBin.UseVisualStyleBackColor = true;
+            this.checkBoxBin.Visible = false;
             // 
             // checkBoxDatas
             // 
@@ -539,59 +544,65 @@
             // label4
             // 
             this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(4, 194);
+            this.label4.Location = new System.Drawing.Point(4, 407);
             this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(206, 20);
             this.label4.TabIndex = 46;
             this.label4.Text = "Adresse du serveur SignalR";
+            this.label4.Visible = false;
             // 
             // textSignalR
             // 
-            this.textSignalR.Location = new System.Drawing.Point(58, 217);
+            this.textSignalR.Location = new System.Drawing.Point(58, 430);
             this.textSignalR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textSignalR.Name = "textSignalR";
             this.textSignalR.Size = new System.Drawing.Size(571, 26);
             this.textSignalR.TabIndex = 44;
+            this.textSignalR.Visible = false;
             // 
             // bt_checkR
             // 
-            this.bt_checkR.Location = new System.Drawing.Point(384, 180);
+            this.bt_checkR.Location = new System.Drawing.Point(384, 393);
             this.bt_checkR.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_checkR.Name = "bt_checkR";
             this.bt_checkR.Size = new System.Drawing.Size(134, 35);
             this.bt_checkR.TabIndex = 45;
             this.bt_checkR.Text = "Vérifier serveur";
             this.bt_checkR.UseVisualStyleBackColor = true;
+            this.bt_checkR.Visible = false;
             this.bt_checkR.Click += new System.EventHandler(this.bt_check_Click);
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(4, 112);
+            this.label3.Location = new System.Drawing.Point(4, 265);
             this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(351, 20);
             this.label3.TabIndex = 43;
             this.label3.Text = "Adresse du serveur pour la mise à jour du logiciel";
+            this.label3.Visible = false;
             // 
             // textSrvBin
             // 
-            this.textSrvBin.Location = new System.Drawing.Point(58, 135);
+            this.textSrvBin.Location = new System.Drawing.Point(58, 288);
             this.textSrvBin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.textSrvBin.Name = "textSrvBin";
             this.textSrvBin.Size = new System.Drawing.Size(571, 26);
             this.textSrvBin.TabIndex = 41;
+            this.textSrvBin.Visible = false;
             // 
             // bt_checkBin
             // 
-            this.bt_checkBin.Location = new System.Drawing.Point(384, 98);
+            this.bt_checkBin.Location = new System.Drawing.Point(384, 251);
             this.bt_checkBin.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.bt_checkBin.Name = "bt_checkBin";
             this.bt_checkBin.Size = new System.Drawing.Size(134, 35);
             this.bt_checkBin.TabIndex = 42;
             this.bt_checkBin.Text = "Vérifier serveur";
             this.bt_checkBin.UseVisualStyleBackColor = true;
+            this.bt_checkBin.Visible = false;
             this.bt_checkBin.Click += new System.EventHandler(this.bt_check_Click);
             // 
             // label2
@@ -635,6 +646,7 @@
             this.checkBoxLocale.TabIndex = 55;
             this.checkBoxLocale.Text = "Utiliser la copie locale";
             this.checkBoxLocale.UseVisualStyleBackColor = true;
+            this.checkBoxLocale.Visible = false;
             // 
             // f_about
             // 
@@ -648,7 +660,7 @@
             this.MaximizeBox = false;
             this.MinimizeBox = false;
             this.Name = "f_about";
-            this.Padding = new System.Windows.Forms.Padding(14, 14, 14, 14);
+            this.Padding = new System.Windows.Forms.Padding(14);
             this.ShowIcon = false;
             this.ShowInTaskbar = false;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;

+ 24 - 12
Fuel_ASO/f_about.cs

@@ -187,7 +187,7 @@ namespace Fuel01
             label1.Visible = true;
             this.Cursor = Cursors.WaitCursor;
             System.Windows.Forms.Application.DoEvents();
-
+            int i = 1;
             Properties.Settings.Default.chemin_copie_locale = textCopieLocal.Text;
             if (Properties.Settings.Default.use_locale)
             {
@@ -196,20 +196,28 @@ namespace Fuel01
                 File.Copy(Program.subfolder + @"\vehicule.json", Properties.Settings.Default.chemin_copie_locale + @"\vehicule.json", true);
                 File.Copy(Program.folder + @"\param\produit.json", Properties.Settings.Default.chemin_copie_locale + @"\produit.json", true);
                 SendFile(Program.subfolder + @"\station.json").Wait();
-                SendFile(Program.subfolder + @"\presta.json").Wait(); 
+                UploadProgressChanged(i++, 4);
+                SendFile(Program.subfolder + @"\presta.json").Wait();
+                UploadProgressChanged(i++, 4);
                 SendFile(Program.subfolder + @"\vehicule.json").Wait() ;
+                UploadProgressChanged(i++, 4);
                 SendFile(Program.folder + @"\param\produit.json").Wait();
+                UploadProgressChanged(i, 4);
             }
             else
             {
 
                 SendFile(Program.subfolder + @"\station.json").Wait();
+                UploadProgressChanged(i++, 4);
                 SendFile(Program.subfolder + @"\presta.json").Wait();
+                UploadProgressChanged(i++, 4);
                 SendFile(Program.subfolder + @"\vehicule.json").Wait();
+                UploadProgressChanged(i++, 4);
                 SendFile(Program.folder + @"\param\produit.json").Wait();
+                UploadProgressChanged(i, 4);
 
             }
-            Thread.Sleep(5000);
+            Thread.Sleep(500);
             label1.Visible = false;
             this.Cursor = Cursors.Default;
             System.Windows.Forms.Application.DoEvents();
@@ -229,26 +237,30 @@ namespace Fuel01
                 var request = new HttpRequestMessage(HttpMethod.Post, $"{Properties.Settings.Default.adresse_copie_api}GetFile");
                 var content = new StringContent(JsonConvert.SerializeObject(file), null, "application/json");
                 request.Content = content;
-                var response = await client.SendAsync(request);
+                var response = client.SendAsync(request).Result;
                 response.EnsureSuccessStatusCode();
+
+                client = new HttpClient();
+                request = new HttpRequestMessage(HttpMethod.Post, $"https://tdf.axpower.eu/api/FileUpload/GetFile");
+                content = new StringContent(JsonConvert.SerializeObject(file), null, "application/json");
+                request.Content = content;
+                var responseWeb = client.SendAsync(request).Result;
+                responseWeb.EnsureSuccessStatusCode();
+
                 Console.WriteLine(await response.Content.ReadAsStringAsync());
             }
             catch (Exception ex)
             {
-                Console.WriteLine("ERRRRRRRRRRRRRRRREUUUUUUUUUURRRRRRRRRRR        POST        :" + ex.ToString());
+                Console.WriteLine($"ERRRRRRRRRRRRRRRREUUUUUUUUUURRRRRRRRRRR {ex.Message}");
             }
 
         }
 
-        private void Client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
+        private void UploadProgressChanged(int value,int maxValue)
         {
-            double bytesIn = double.Parse(e.BytesSent.ToString());
-            double totalBytes = double.Parse(e.TotalBytesToSend.ToString());
-            double percentage = bytesIn / totalBytes * 100;
-
+            double percentage = value / maxValue * 100;
             progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
-
-
+            System.Windows.Forms.Application.DoEvents();
         }
 
 

+ 16 - 15
Fuel_ASO/f_presta.cs

@@ -231,15 +231,17 @@ namespace Fuel01
         private void SavePresta()
         {
             List<PrestaSta> prestaStas = new List<PrestaSta>();
+            tb_presta.AcceptChanges();
             string filter = tbprestaBindingSource.Filter;
             tbprestaBindingSource.Filter = "";
             tbprestaBindingSource.Sort = "sta_pr,kind_pr,prod_pr";
+            bool isEmpty = tb_presta.Count == 0;
 
-            var result0 = JsonConvert.SerializeObject(tb_presta);
-            var result1 = JsonConvert.DeserializeObject<List<Presta>>(result0);
+            var result0 = isEmpty ? "[]" : JsonConvert.SerializeObject(tb_presta);
+            var result1 = isEmpty ? new List<Presta>() : JsonConvert.DeserializeObject<List<Presta>>(result0);
             var oldPr = "*";
             Prod prod;
-            PrestaSta newPresta = new PrestaSta();
+            PrestaSta newPresta=new PrestaSta() ;
             foreach (var presta in result1)
             {
                 var l_pr = lproduit.FirstOrDefault(x => x.key_prod == presta.prod_pr);
@@ -252,11 +254,9 @@ namespace Fuel01
                 var kind = presta.kind_pr;
                 if (idSta != oldPr)
                 {
-                    if (newPresta != null && !string.IsNullOrEmpty(newPresta.sta_pr))
-                    {
-                        prestaStas.Add(newPresta);
-                    }
                     newPresta = new PrestaSta();
+                    newPresta.sta_pr = presta.sta_pr ;                    
+                    prestaStas.Add(newPresta);
                     oldPr = idSta;
                 }
 
@@ -270,15 +270,16 @@ namespace Fuel01
                     ttc_pr = presta.ttc_pr.ToString("0.000")
                 };
 
-               
-                newPresta.sta_pr = idSta;
-                if (kind == "Carburant")
-                {
-                    newPresta.carburants.Add(prod);
-                }
-                else
+                if (newPresta != null)
                 {
-                    newPresta.autres.Add(prod);
+                    if (kind == "Carburant")
+                    {
+                        newPresta.carburants.Add(prod);
+                    }
+                    else
+                    {
+                        newPresta.autres.Add(prod);
+                    }
                 }
             }
             tbprestaBindingSource.Filter = filter;