From 4eb54d20d578ac4c7fcd138f4f7544689aa8ad37 Mon Sep 17 00:00:00 2001 From: "MLG\\iproga.rodionov" Date: Thu, 5 Oct 2023 13:13:22 +0300 Subject: [PATCH 1/4] add comment to tblShifts --- .../BL/OrderHelper.cs | 72 ++++++++++++++++++- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/MygigIntegration.DomainModel/BL/OrderHelper.cs b/MygigIntegration.DomainModel/BL/OrderHelper.cs index 9bd9c7d..0c3f790 100644 --- a/MygigIntegration.DomainModel/BL/OrderHelper.cs +++ b/MygigIntegration.DomainModel/BL/OrderHelper.cs @@ -107,9 +107,12 @@ namespace MygigIntegration.DomainModel.BL } } - public static decimal? GetSalary(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, + public static RateInfo GetSalary(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, bool? RateMK, Guid? IDDepartment, Guid customer, DateTime orderdate) { + + var rateInfo = new RateInfo(); + using (SqlConnection cnn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand()) { @@ -136,8 +139,20 @@ namespace MygigIntegration.DomainModel.BL { //return new Tuple(decimal.Parse(rd[0].ToString()), rd[1].ToString()); ////em.ShiftRate = decimal.Parse(rd[0].ToString()); - if (rd != null && rd[0] != DBNull.Value) - return decimal.Parse(rd[0].ToString()); + if (rd != null) + { + if(rd[0] != DBNull.Value) + rateInfo.Salary = decimal.Parse(rd[0].ToString()); + + if (rd.FieldCount > 1 && rd[1] != DBNull.Value) + rateInfo.Description = rd[1].ToString(); + + if (rd.FieldCount > 2 && rd[2] != DBNull.Value) + rateInfo.IsUpRate = Convert.ToByte(rd[2]); + + return rateInfo; + + } else return null; } @@ -153,6 +168,34 @@ namespace MygigIntegration.DomainModel.BL } } + /// + /// Добавить комментарий к смене. + /// + /// + /// + public static void AddCommentToShifts(string connectionString, Guid? IDOrder) + { + try + { + using (SqlConnection cnn = new SqlConnection(connectionString)) + { + using (SqlCommand cmd = new SqlCommand()) + { + cmd.CommandText = $"nsp_add_CommentShifts '{IDOrder}'"; + cmd.Connection = cnn; + cnn.Open(); + int number = cmd.ExecuteNonQuery(); + + } + } + + } + catch (Exception ex) + { + _log.Info(ex.Message); + } + } + public static decimal? GetRate(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, bool? RateMK, Guid? IDDepartment, Guid customer, DateTime orderdate) { @@ -294,4 +337,27 @@ namespace MygigIntegration.DomainModel.BL } } } + + /// + /// Ставка смены. + /// + public class RateInfo + { + /// + /// Зарплата + /// + public decimal? Salary { get; set; } + + /// + /// Описание + /// + public string Description { get; set; } + + /// + /// Повышение ставки + /// + public byte? IsUpRate { get; set; } + + } + } -- GitLab From 49074baf25dd91ea84cba826c4ecbb861884f200 Mon Sep 17 00:00:00 2001 From: "MLG\\iproga.rodionov" Date: Thu, 5 Oct 2023 13:20:31 +0300 Subject: [PATCH 2/4] Revert "add comment to tblShifts" This reverts commit 4eb54d20d578ac4c7fcd138f4f7544689aa8ad37. --- .../BL/OrderHelper.cs | 72 +------------------ 1 file changed, 3 insertions(+), 69 deletions(-) diff --git a/MygigIntegration.DomainModel/BL/OrderHelper.cs b/MygigIntegration.DomainModel/BL/OrderHelper.cs index 0c3f790..9bd9c7d 100644 --- a/MygigIntegration.DomainModel/BL/OrderHelper.cs +++ b/MygigIntegration.DomainModel/BL/OrderHelper.cs @@ -107,12 +107,9 @@ namespace MygigIntegration.DomainModel.BL } } - public static RateInfo GetSalary(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, + public static decimal? GetSalary(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, bool? RateMK, Guid? IDDepartment, Guid customer, DateTime orderdate) { - - var rateInfo = new RateInfo(); - using (SqlConnection cnn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand()) { @@ -139,20 +136,8 @@ namespace MygigIntegration.DomainModel.BL { //return new Tuple(decimal.Parse(rd[0].ToString()), rd[1].ToString()); ////em.ShiftRate = decimal.Parse(rd[0].ToString()); - if (rd != null) - { - if(rd[0] != DBNull.Value) - rateInfo.Salary = decimal.Parse(rd[0].ToString()); - - if (rd.FieldCount > 1 && rd[1] != DBNull.Value) - rateInfo.Description = rd[1].ToString(); - - if (rd.FieldCount > 2 && rd[2] != DBNull.Value) - rateInfo.IsUpRate = Convert.ToByte(rd[2]); - - return rateInfo; - - } + if (rd != null && rd[0] != DBNull.Value) + return decimal.Parse(rd[0].ToString()); else return null; } @@ -168,34 +153,6 @@ namespace MygigIntegration.DomainModel.BL } } - /// - /// Добавить комментарий к смене. - /// - /// - /// - public static void AddCommentToShifts(string connectionString, Guid? IDOrder) - { - try - { - using (SqlConnection cnn = new SqlConnection(connectionString)) - { - using (SqlCommand cmd = new SqlCommand()) - { - cmd.CommandText = $"nsp_add_CommentShifts '{IDOrder}'"; - cmd.Connection = cnn; - cnn.Open(); - int number = cmd.ExecuteNonQuery(); - - } - } - - } - catch (Exception ex) - { - _log.Info(ex.Message); - } - } - public static decimal? GetRate(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, bool? RateMK, Guid? IDDepartment, Guid customer, DateTime orderdate) { @@ -337,27 +294,4 @@ namespace MygigIntegration.DomainModel.BL } } } - - /// - /// Ставка смены. - /// - public class RateInfo - { - /// - /// Зарплата - /// - public decimal? Salary { get; set; } - - /// - /// Описание - /// - public string Description { get; set; } - - /// - /// Повышение ставки - /// - public byte? IsUpRate { get; set; } - - } - } -- GitLab From 27cd733ef07a40a4c0b89b61e5335031dcac6e5d Mon Sep 17 00:00:00 2001 From: "MLG\\iproga.rodionov" Date: Thu, 5 Oct 2023 13:51:21 +0300 Subject: [PATCH 3/4] add comment to Shifts --- ConsoleApp1/Services/OrderService.cs | 20 +++-- .../BL/OrderHelper.cs | 74 +++++++++++++++++-- 2 files changed, 80 insertions(+), 14 deletions(-) diff --git a/ConsoleApp1/Services/OrderService.cs b/ConsoleApp1/Services/OrderService.cs index a2fad70..1e12d75 100644 --- a/ConsoleApp1/Services/OrderService.cs +++ b/ConsoleApp1/Services/OrderService.cs @@ -158,19 +158,20 @@ namespace MygigIntegration.Service.Services _log.Info($"Не синхронизирована торговая точка для заказа {order.IDDemand}; id точки: {order.IDDirection};"); return null; } - decimal? salary = OrderHelper.GetSalary(_connectionstring, order.DateBeginMS ?? DateTime.Today, order.DateEndMS ?? DateTime.Today, + RateInfo rateInfo = OrderHelper.GetSalary(_connectionstring, order.DateBeginMS ?? DateTime.Today, order.DateEndMS ?? DateTime.Today, order.IDJobPosition ?? Guid.Empty, order.MedBook, order.IDDepartment, order.IDDirection ?? Guid.Empty, order.DateOrder); - if (salary == null) + if (rateInfo == null) { _log.Info($"Невозможно рассчитать ставку по заявке {order.IDDemand}."); return null; } - if (salary == 0) + if (rateInfo.Salary == 0) { _log.Info($"Cтавка по заявке {order.IDDemand} должна быть больше нуля."); return null; } + decimal? rate = OrderHelper.GetRate(_connectionstring, order.DateBeginMS ?? DateTime.Today, order.DateEndMS ?? DateTime.Today, order.IDJobPosition ?? Guid.Empty, order.MedBook, order.IDDepartment, order.IDDirection ?? Guid.Empty, order.DateOrder); @@ -189,7 +190,7 @@ namespace MygigIntegration.Service.Services description: $"{order.Comment ?? "открытая позиция"}", documents: documents, paymentPerJob: rate ?? 0, - salary, rate ?? 0, salary, null, + rateInfo.Salary, rate ?? 0, rateInfo.Salary, null, order.MygigDirectionID, order.MygigClientID, null/*order.Breaktime*/);; @@ -204,19 +205,22 @@ namespace MygigIntegration.Service.Services _log.Info($"Не синхронизирована торговая точка для заказа {order.IDDemand}; id точки: {order.IDDirection};"); return null; } - decimal? salary = OrderHelper.GetSalary(_connectionstring, order.DateBeginMS ?? DateTime.Today, order.DateEndMS ?? DateTime.Today, + RateInfo rateInfo = OrderHelper.GetSalary(_connectionstring, order.DateBeginMS ?? DateTime.Today, order.DateEndMS ?? DateTime.Today, order.IDJobPosition ?? Guid.Empty, order.MedBook, order.IDDepartment, order.IDDirection ?? Guid.Empty, order.DateOrder); - if (salary == null) + if (rateInfo == null) { _log.Info($"Невозможно рассчитать ставку по заявке {order.IDDemand}."); return null; } - if (salary == 0) + if (rateInfo.Salary == 0) { _log.Info($"Cтавка по заявке {order.IDDemand} должна быть больше нуля."); return null; } + + OrderHelper.AddCommentToShifts(_connectionstring, order.IDOrder); + decimal? rate = OrderHelper.GetRate(_connectionstring, order.DateBeginMS ?? DateTime.Today, order.DateEndMS ?? DateTime.Today, order.IDJobPosition ?? Guid.Empty, order.MedBook, order.IDDepartment, order.IDDirection ?? Guid.Empty, order.DateOrder); @@ -234,7 +238,7 @@ namespace MygigIntegration.Service.Services order.MygigJobPosName, $"{order.Comment ?? "открытая позиция"}", documents, - salary, salary, rate??0, + rateInfo.Salary, rateInfo.Salary, rate??0, /*Убрал подстановку времени сдвига по часовому поясу*/ //DateTime.Parse(order.DateBeginMS.ToString()+ $"+{order.Timezone}:00"), //DateTime.Parse(order.DateEndMS.ToString() + $"+{order.Timezone}:00"), diff --git a/MygigIntegration.DomainModel/BL/OrderHelper.cs b/MygigIntegration.DomainModel/BL/OrderHelper.cs index 9bd9c7d..2dc94a1 100644 --- a/MygigIntegration.DomainModel/BL/OrderHelper.cs +++ b/MygigIntegration.DomainModel/BL/OrderHelper.cs @@ -9,8 +9,7 @@ using System.Text; using System.Threading.Tasks; namespace MygigIntegration.DomainModel.BL -{ - +{ public static class OrderHelper { public static bool ExistEmployeeByiddemand(string connectionString, string mygigorder,string worker) @@ -107,9 +106,11 @@ namespace MygigIntegration.DomainModel.BL } } - public static decimal? GetSalary(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, + public static RateInfo GetSalary(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, bool? RateMK, Guid? IDDepartment, Guid customer, DateTime orderdate) { + var rateInfo = new RateInfo(); + using (SqlConnection cnn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand()) { @@ -127,7 +128,7 @@ namespace MygigIntegration.DomainModel.BL orderdate.ToString("yyyy-MM-dd"), "0", "0", Guid.Empty, - (RateMK ?? false) ? 1 : 0, IDDepartment,0, 1); + (RateMK ?? false) ? 1 : 0, IDDepartment, 0, 1); try { using (SqlDataReader rd = cmd.ExecuteReader()) @@ -136,8 +137,20 @@ namespace MygigIntegration.DomainModel.BL { //return new Tuple(decimal.Parse(rd[0].ToString()), rd[1].ToString()); ////em.ShiftRate = decimal.Parse(rd[0].ToString()); - if (rd != null && rd[0] != DBNull.Value) - return decimal.Parse(rd[0].ToString()); + if (rd != null) + { + if (rd[0] != DBNull.Value) + rateInfo.Salary = decimal.Parse(rd[0].ToString()); + + if (rd.FieldCount > 1 && rd[1] != DBNull.Value) + rateInfo.Description = rd[1].ToString(); + + if (rd.FieldCount > 2 && rd[2] != DBNull.Value) + rateInfo.IsUpRate = Convert.ToByte(rd[2]); + + return rateInfo; + + } else return null; } @@ -153,6 +166,33 @@ namespace MygigIntegration.DomainModel.BL } } + /// + /// Добавить комментарий к смене. + /// + /// + /// + public static void AddCommentToShifts(string connectionString, Guid? IDOrder) + { + try + { + using (SqlConnection cnn = new SqlConnection(connectionString)) + { + using (SqlCommand cmd = new SqlCommand()) + { + cmd.CommandText = $"nsp_add_CommentShifts '{IDOrder}'"; + cmd.Connection = cnn; + cnn.Open(); + int number = cmd.ExecuteNonQuery(); + } + } + + } + catch (Exception ex) + { + _log.Info(ex.Message); + } + } + public static decimal? GetRate(string connectionString, DateTime shiftbegin, DateTime shiftend, Guid jobposition, bool? RateMK, Guid? IDDepartment, Guid customer, DateTime orderdate) { @@ -294,4 +334,26 @@ namespace MygigIntegration.DomainModel.BL } } } + + /// + /// Ставка смены. + /// + public class RateInfo + { + /// + /// Зарплата + /// + public decimal? Salary { get; set; } + + /// + /// Описание + /// + public string Description { get; set; } + + /// + /// Повышение ставки + /// + public byte? IsUpRate { get; set; } + + } } -- GitLab From e28b97ff8a050e5cf11b18128c594dfeb2a06e26 Mon Sep 17 00:00:00 2001 From: "MLG\\iproga.rodionov" Date: Tue, 24 Oct 2023 17:54:13 +0300 Subject: [PATCH 4/4] Added check by employee ID --- ConsoleApp1/Services/OrderService.cs | 28 ++++++++++++++++++- .../BL/OrderHelper.cs | 16 +++++------ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ConsoleApp1/Services/OrderService.cs b/ConsoleApp1/Services/OrderService.cs index 1e12d75..861756d 100644 --- a/ConsoleApp1/Services/OrderService.cs +++ b/ConsoleApp1/Services/OrderService.cs @@ -219,7 +219,33 @@ namespace MygigIntegration.Service.Services return null; } - OrderHelper.AddCommentToShifts(_connectionstring, order.IDOrder); + if (rateInfo.IsUpRate.HasValue && rateInfo.IsUpRate == 1) + { + JobsApi instance = new JobsApi(_url); + if (instance.Configuration.DefaultHeader.ContainsKey("Authorization")) + instance.Configuration.DefaultHeader.Remove("Authorization"); + if (!instance.Configuration.DefaultHeader.ContainsKey("Authorization")) + instance.Configuration.DefaultHeader.Add("Authorization", "Bearer " + _token); + + var jobs = instance.JobsGet(order.MygigOrderID); + if (jobs != null) + { + var jobResponse = jobs.FirstOrDefault(q => q.Source.ToUpper() == order.IDDemand.ToString().ToUpper()); + + if (jobResponse != null) + { + OrderHelper.AddCommentToShifts(_connectionstring, order.IDOrder, jobResponse.Worker); + } + else + { + _log.Error($"Не найден работник IDDemand {order.IDDemand}"); + } + } + else + { + _log.Error($"Не найден job {order.MygigOrderID}"); + } + } decimal? rate = OrderHelper.GetRate(_connectionstring, order.DateBeginMS ?? DateTime.Today, order.DateEndMS ?? DateTime.Today, order.IDJobPosition ?? Guid.Empty, order.MedBook, order.IDDepartment, diff --git a/MygigIntegration.DomainModel/BL/OrderHelper.cs b/MygigIntegration.DomainModel/BL/OrderHelper.cs index 2dc94a1..649e217 100644 --- a/MygigIntegration.DomainModel/BL/OrderHelper.cs +++ b/MygigIntegration.DomainModel/BL/OrderHelper.cs @@ -170,26 +170,26 @@ namespace MygigIntegration.DomainModel.BL /// Добавить комментарий к смене. /// /// - /// - public static void AddCommentToShifts(string connectionString, Guid? IDOrder) + /// ID заказа + /// ID гигера + public static void AddCommentToShifts(string connectionString, Guid? IDOrder, string worker) { try { - using (SqlConnection cnn = new SqlConnection(connectionString)) + using (var cnn = new SqlConnection(connectionString)) { - using (SqlCommand cmd = new SqlCommand()) + using (var cmd = new SqlCommand()) { - cmd.CommandText = $"nsp_add_CommentShifts '{IDOrder}'"; + cmd.CommandText = $"nsp_add_CommentShifts '{IDOrder}', '{worker}'"; cmd.Connection = cnn; cnn.Open(); - int number = cmd.ExecuteNonQuery(); + var number = cmd.ExecuteNonQuery(); } } - } catch (Exception ex) { - _log.Info(ex.Message); + _log.Error(ex); } } -- GitLab