/// <summary> /// «اعتبارسنجی /// «مقدار دهی ابتدا و انتها /// «ابتدا بزرگتر از انتها نباشد /// «ابتدا و انتها برابر نباشد /// «اشتراک نداشته باشد /// /// </summary> /// <param name="shift"></param> private void InsertValidateShiftPair(decimal shiftId, ShiftPair pair) { UIValidationExceptions exception = new UIValidationExceptions(); if (pair != null) { if (pair.To == 0) { exception.Add(ExceptionResourceKeys.ShiftPairFromToEmpty, "جفت شیفت نمیتواند تهی باشد", ExceptionSrc); } if (!pair.NextDayContinual && pair.From > pair.To) { exception.Add(ExceptionResourceKeys.ShiftFromGreaterThanTo, "مقدار ابتدا از انتها بزرگتر است", ExceptionSrc); } if (!pair.NextDayContinual && pair.From == pair.To) { exception.Add(ExceptionResourceKeys.ShiftFromAndToAreEquals, "مقدار ابتدا و انتها برابر است", ExceptionSrc); } Shift shift = GetByID(shiftId); if (Operation.Intersect((IPair)pair, shift.Pairs.ToList().ConvertAll(x => (IPair)x)).Value > 0) { exception.Add(ExceptionResourceKeys.ShiftPairHasIntersect, "این جفت با جفتهای موجود در شیفت همپوشانی دارد", ExceptionSrc); } } else { exception.Add(ExceptionResourceKeys.ShiftPairNull, "جفت شیفت نمیتواند تهی باشد", ExceptionSrc); } if (exception.Count > 0) { throw exception; } }
private VirtualMidNight GetMidNightOFShift(AssignedWGDShift shift, MidNightTimeSt midNight) { try { VirtualMidNight result = new VirtualMidNight(); ShiftPair firstPair = shift.Pairs.OrderBy(x => x.From).First(); ShiftPair lastPair = shift.Pairs.OrderBy(x => x.From).Last(); int time = 0; DateTime date = new DateTime(); //فرض شده است که شیفت بهم چسبیده نداریم //برای شیفتی که انتهای آن فردا است if (lastPair.To > DayMinutes && lastPair.To > midNight.Start && !EndOfDayIsForce) { date = shift.Date; time = lastPair.To;//+ (int)lAfterTelorance1; result = new VirtualMidNight(date, time, firstPair.BeforeTolerance, lastPair.AfterTolerance); } result = new VirtualMidNight(shift.Date, midNight.Start, midNight.BeforeTelorance, midNight.AfterTelorance); return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// اعمال مجوز تاخیر مجاز بعد از ماموریت ساعت 23 /// </summary> /// <param name="MyRule"></param> public void R4503(AssignedRule MyRule) { //3021 تاخیر مجاز //تاخیر ساعتي 3029 //201 کد پیشکارت درخواست تاخیر مجاز ماموریت /*if (this.DoConcept(3029).Value > 0) * { * PairableScndCnpValue late = ((PairableScndCnpValue)this.DoConcept(3029)); * Permit permit = this.Person.GetPermitByDate(this.RuleCalculateDate, EngEnvironment.GetPrecard(201)); * if (permit != null && (permit.Value > 0 || permit.PairCount > 0)) * { * IPair pair = new ShiftPair(); * pair.From = this.Person.GetShiftByDate(this.RuleCalculateDate).Pairs.OrderBy(x => x.From).First().From; * pair.To = pair.From + MyRule["First", this.RuleCalculateDate].ToInt(); * this.DoConcept(3021).Value = Operation.Intersect(pair, late).Value; * ((PairableScndCnpValue)this.DoConcept(3029)).AddPairs(Operation.Differance(late, pair)); * this.ReCalculate(13, 3020, 3028); * } * }*/ Permit permit = this.Person.GetPermitByDate(this.RuleCalculateDate, EngEnvironment.GetPrecard(201)); if (permit != null && (permit.Value > 0 || permit.PairCount > 0)) { GetLog(MyRule, DebugRuleState.Before, 4002); IPair pair = permit.Pairs.First(); IPair mojaz = new ShiftPair(1, 6 * 60); PairableScndCnpValue overtime = Operation.Intersect(pair, mojaz); ((PairableScndCnpValue)this.DoConcept(4002)).AppendPairs(overtime); GetLog(MyRule, DebugRuleState.After, 4002); } }
/// <summary> /// /// </summary> /// <param name="shiftPair"></param> /// <param name="action"></param> private void GetReadyBeforeSaveShiftPair(ShiftPair shiftPair, UIActionType action) { if (shiftPair.NextDayContinual) { shiftPair.To += 1440; } }
/// <summary> /// عملیات درج و بروزرسانی انجام میشود /// // new ShiftPair() { ID = 5, ShiftId = 10 }; /// </summary> /// <param name="pair"></param> public decimal SaveChangesShiftPair(ShiftPair pair, UIActionType action) { try { this.CheckInterfaceRuleGroup(pair); GetReadyBeforeSaveShiftPair(pair, action); if (action == UIActionType.EDIT) { UpdateValidateShiftPair(pair.ShiftId, pair); UpdateShiftPair(pair); } else if (action == UIActionType.ADD) { InsertValidateShiftPair(pair.ShiftId, pair); InsertShiftPair(pair); } else if (action == UIActionType.DELETE) { DeleteShiftPair(pair.ID); } this.UpdateCFP(pair, action); return(pair.ID); } catch (Exception ex) { LogException(ex, "Shift", "SaveChangesShiftPair"); throw ex; } }
public void CheckInterfaceRuleGroup(ShiftPair pair) { BWorkGroupCalendar busWorkGroup = new BWorkGroupCalendar(); WorkGroupRepository workRep = new WorkGroupRepository(false); IList <WorkGroup> list = workRep.GetAllWorkGroupByShift(pair.ShiftId); foreach (WorkGroup workGroup in list) { busWorkGroup.CheckInterfaceRuleGroup(workGroup.ID); } }
private void UpdateShiftPair(ShiftPair shiftPair) { try { pairRep.Merge(shiftPair); } catch (Exception ex) { LogException(ex, "Shift", "UpdateShiftPair"); throw ex; } }
/// <summary> /// /// </summary> /// <param name="shiftPair"></param> /// <param name="action"></param> private void GetReadyBeforeSaveShiftPair(ShiftPair shiftPair, UIActionType action) { if (shiftPair.NextDayContinual && !shiftPair.BeginEndInNextDay) { shiftPair.To += 1440; } //DNN Note if (shiftPair.BeginEndInNextDay) { shiftPair.To += 1440; shiftPair.From += 1440; } }
private void InsertShiftPair(ShiftPair shiftPair) { try { //if (shiftPair.NextDayContinual) //{ // shiftPair.To += dayMinutes; //} pairRep.Save(shiftPair); } catch (Exception ex) { LogException(ex, "Shift", "InsertShiftPair"); throw ex; } }
public void ValidateInsertUpdateShiftPair_FromToAreAqualsTest() { try { shift_testObject = businessShift.GetByID(ADOShift.ID); shiftpair_testObject = shift_testObject.Pairs[0]; shiftpair_testObject.From = shiftpair_testObject.To; shiftpair_testObject.ShiftId = shift_testObject.ID; businessShift.SaveChangesShiftPair(shiftpair_testObject, UIActionType.EDIT); Assert.Fail("مقدار ابتدا با انتها برابر است"); } catch (UIValidationExceptions ex) { Assert.AreEqual(ex.ExceptionList.First().ResourceKey, ExceptionResourceKeys.ShiftFromAndToAreEquals); } }
/// <summary> /// «اعتبارسنجی /// «مقدار دهی ابتدا و انتها /// «ابتدا بزرگتر از انتها نباشد /// «ابتدا و انتها برابر نباشد /// «اشتراک نداشته باشد /// /// </summary> /// <param name="shift"></param> private void UpdateValidateShiftPair(decimal shiftId, ShiftPair pair) { UIValidationExceptions exception = new UIValidationExceptions(); if (pair != null) { if (pair.To == 0) { exception.Add(ExceptionResourceKeys.ShiftPairFromToEmpty, "جفت شیفت نمیتواند تهی باشد", ExceptionSrc); } if (!pair.NextDayContinual && pair.From > pair.To) { exception.Add(ExceptionResourceKeys.ShiftFromGreaterThanTo, "مقدار ابتدا از انتها بزرگتر است", ExceptionSrc); } if (!pair.NextDayContinual && pair.From == pair.To) { exception.Add(ExceptionResourceKeys.ShiftFromAndToAreEquals, "مقدار ابتدا و انتها برابر است", ExceptionSrc); } if (pair.ShiftPairType == null || pair.ShiftPairType.ID == 0) { exception.Add(ExceptionResourceKeys.ShiftPairTypeIsEmpty, "نوع بازه شیفت نباید خالی باشد", ExceptionSrc); } if (pair.ShiftPairType != null && pair.ShiftPairType.ID != 0) { Shift shift = GetByID(shiftId); if (shift.Pairs != null && shift.Pairs.Count > 1) { ShiftPair orignalPair = shift.Pairs.Where(x => x.ID == pair.ID).First(); shift.Pairs.Remove(orignalPair); if (Operation.Intersect((IPair)pair, shift.Pairs.Where(p => p.ShiftPairType != null && p.ShiftPairType.ID == pair.ShiftPairType.ID).ToList().ConvertAll(x => (IPair)x)).Value > 0) { exception.Add(ExceptionResourceKeys.ShiftPairHasIntersect, "این جفت با جفتهای موجود در شیفت همپوشانی دارد", ExceptionSrc); } } } } else { exception.Add(ExceptionResourceKeys.ShiftPairNull, "جفت شیفت نمیتواند تهی باشد", ExceptionSrc); } if (exception.Count > 0) { throw exception; } }
public void ValidateInsertUpdateShiftPair_FromGreaterThanToTest() { try { shift_testObject = businessShift.GetByID(ADOShift.ID); shiftpair_testObject = shift_testObject.Pairs[0]; shiftpair_testObject.FromTime = "10:02"; shiftpair_testObject.ToTime = "10:01"; shiftpair_testObject.ShiftId = shift_testObject.ID; businessShift.SaveChangesShiftPair(shiftpair_testObject, UIActionType.EDIT); Assert.Fail("مقدار ابتدا از انتها بزرگتر است"); } catch (UIValidationExceptions ex) { Assert.AreEqual(ex.ExceptionList.First().ResourceKey, ExceptionResourceKeys.ShiftFromGreaterThanTo); } }
protected void UpdateCFP(ShiftPair obj, UIActionType action) { //return; if (action == UIActionType.ADD || action == UIActionType.EDIT || action == UIActionType.DELETE) { BWorkGroupCalendar busWorkGroup = new BWorkGroupCalendar(); WorkGroupRepository workRep = new WorkGroupRepository(false); IList <WorkGroup> list = workRep.GetAllWorkGroupByShift(obj.ShiftId); foreach (WorkGroup workGroup in list) { DateTime?firstUse = shiftRepository.GetFirstShiftUsedInWorkGroup(obj.ShiftId, workGroup.ID); if (firstUse != null && firstUse > Utility.GTSMinStandardDateTime) { busWorkGroup.UpdateCFPByWorkGroupId(workGroup.ID, (DateTime)firstUse); } } } }
public void TestSetup() { shift_testObject = new Shift(); shiftpair_testObject = new ShiftPair(); businessShift = new BShift(); nobatTA.Insert("NobatKari", "", "0-00"); DatabaseGateway.TA_NobatKariDataTable table = new DatabaseGateway.TA_NobatKariDataTable(); nobatTA.FillByCustomCode(table, "0-00"); ADONobatKari.ID = Convert.ToInt32(table.Rows[0]["nobat_ID"]); ADONobatKari.Name = Convert.ToString(table.Rows[0]["nobat_Name"]); ADONobatKari.CustomCode = Convert.ToString(table.Rows[0]["nobat_CustomCode"]); ADONobatKari.Description = Convert.ToString(table.Rows[0]["nobat_Description"]); shiftTA.Insert("ShiftTest", 1, 11, ADONobatKari.ID, 100, false, false, false, "2", "0-00"); ADOShift = new Shift(); DatabaseGateway.TA_ShiftDataTable shiftTable = new DatabaseGateway.TA_ShiftDataTable(); shiftTA.FillByName(shiftTable, "ShiftTest"); ADOShift.ID = Convert.ToInt32(shiftTable.Rows[0]["shift_ID"]); ADOShift.Name = Convert.ToString(shiftTable.Rows[0]["shift_Name"]); ADOShift.Color = Convert.ToString(shiftTable.Rows[0]["shift_Color"]); ADOShift.NobatKariID = Convert.ToInt32(shiftTable.Rows[0]["shift_Nobatkari"]); ADOShift.CustomCode = Convert.ToString(shiftTable.Rows[0]["shift_CustomCode"]); shiftPairTA.Insert(ADOShift.ID, 100, 200, 0, 0); shiftPairTA.Insert(ADOShift.ID, 300, 500, 0, 0); DatabaseGateway.TA_ShiftPairDataTable shiftpairTable = new DatabaseGateway.TA_ShiftPairDataTable(); shiftPairTA.FillByShiftId(shiftpairTable, ADOShift.ID); ShiftPair pair = new ShiftPair(); pair.ID = Convert.ToInt32(shiftpairTable.Rows[0]["shiftpair_ID"]); pair.From = Convert.ToInt32(shiftpairTable.Rows[0]["shiftpair_From"]); pair.To = Convert.ToInt32(shiftpairTable.Rows[0]["shiftpair_To"]); ADOShift.Pairs.Add(pair); pair = new ShiftPair(); pair.ID = Convert.ToInt32(shiftpairTable.Rows[1]["shiftpair_ID"]); pair.From = Convert.ToInt32(shiftpairTable.Rows[1]["shiftpair_From"]); pair.To = Convert.ToInt32(shiftpairTable.Rows[1]["shiftpair_To"]); ADOShift.Pairs.Add(pair); }
/// <summary> /// حذف یک آیتم /// </summary> /// <param name="shiftId"></param> /// <returns></returns> public bool DeleteShiftPair(decimal shiftPairId) { ShiftPair shiftPair = new ShiftPair() { ID = shiftPairId }; try { pairRep.Delete(shiftPair); return(true); } catch (Exception ex) { LogException(ex, "Shift", "DeleteShiftPair"); throw ex; } finally { } }
public void Update_ShiftPair_Test() { shift_testObject.Name = "TestShift"; shift_testObject.CustomCode = "0-02"; shift_testObject.Color = "2134154"; shift_testObject.NobatKari = ADONobatKari; shift_testObject.ShiftType = ShiftTypesEnum.WORK; businessShift.SaveChanges(shift_testObject, UIActionType.ADD); shiftpair_testObject.FromTime = "10:00"; shiftpair_testObject.ToTime = "20:00"; shiftpair_testObject.ShiftId = shift_testObject.ID; shiftpair_testObject.NextDayContinual = true; businessShift.SaveChangesShiftPair(shiftpair_testObject, UIActionType.ADD); ClearSession(); Shift shift = businessShift.GetByID(shift_testObject.ID); shiftpair_testObject = new ShiftPair(); shiftpair_testObject.ID = shift.Pairs[0].ID; shiftpair_testObject.FromTime = "04:00"; shiftpair_testObject.ToTime = "03:00"; shiftpair_testObject.AfterToleranceTime = "05:00"; shiftpair_testObject.BeforeToleranceTime = "00:00"; shiftpair_testObject.ShiftId = shift.ID; //shiftpair_testObject.TimePlusFlag = true; shiftpair_testObject.NextDayContinual = true; businessShift.SaveChangesShiftPair(shiftpair_testObject, UIActionType.EDIT); ClearSession(); shift = businessShift.GetByID(shift_testObject.ID); Assert.AreEqual(1, shift.PairCount); Assert.AreEqual(300, shift.Pairs[0].AfterTolerance); Assert.IsTrue(shift.Pairs[0].To > 1440); }
/// <summary> /// اعمال مجوز تاخیر مجاز بعد از ماموریت ساعت 23 /// </summary> /// <param name="MyRule"></param> public void R287(AssignedRule MyRule) { //3021 تاخیر مجاز //تاخیر ساعتي 3029 //201 کد پیشکارت درخواست تاخیر مجاز ماموریت GetLog(MyRule, " Before Execute State:", 3020, 3021, 3029); if (this.DoConcept(3029).Value > 0) { PairableScndCnpValue late = ((PairableScndCnpValue)this.DoConcept(3029)); Permit permit = this.Person.GetPermitByDate(this.RuleCalculateDate, EngEnvironment.GetPrecard(201)); if (permit != null && (permit.Value > 0 || permit.PairCount > 0)) { IPair pair = new ShiftPair(); pair.From = this.Person.GetShiftByDate(this.RuleCalculateDate).Pairs.OrderBy(x => x.From).First().From; pair.To = pair.From + MyRule["First", this.RuleCalculateDate].ToInt(); this.DoConcept(3021).Value = Operation.Intersect(pair, late).Value; ((PairableScndCnpValue)this.DoConcept(3029)).AddPairs(Operation.Differance(late, pair)); this.ReCalculate(13, 3020, 3028); } } GetLog(MyRule, " After Execute State:", 3020, 3021, 3029); }
public void TestSetup() { #region precards DatasetGatewayWorkFlow.TA_PrecardGroupsDataTable precardTable = new DatasetGatewayWorkFlow.TA_PrecardGroupsDataTable(); precardGroupTA.FillByName(precardTable, PrecardGroupsName.overwork.ToString()); ADOPrecardGroup1.ID = Convert.ToInt32(precardTable.Rows[0][0]); ADOPrecardGroup1.Name = "OwerWork"; precardTA.Insert("TestPrecard1", true, ADOPrecardGroup1.ID, true, false, true, "99999999", false); DatasetGatewayWorkFlow.TA_PrecardDataTable pTable = new DatasetGatewayWorkFlow.TA_PrecardDataTable(); pTable = precardTA.GetDataByName("TestPrecard1"); ADOPrecardOverTime1.ID = Convert.ToInt32(pTable.Rows[0][0]); ADOPrecardOverTime1.Name = "TestPrecard1"; pTable = precardTA.GetDataByCode(126.ToString()); ADOPrecardDasturyOverTime.ID = Convert.ToInt32(pTable.Rows[0][0]); #endregion requestTA.Insert(ADOPrecardOverTime1.ID, ADOPerson1.ID, new DateTime(2010, 5, 1), new DateTime(2010, 5, 1), 420, 600, "", DateTime.Now, ADOUser1.ID); DatasetGatewayWorkFlow.TA_RequestDataTable requestTable = new DatasetGatewayWorkFlow.TA_RequestDataTable(); requestTable = requestTA.GetDataByPersonId(ADOPerson1.ID); ADORequestOvertime1.ID = Convert.ToInt32(requestTable.Rows[0][0]); #region Manager Flow managerTA.Insert(ADOPerson1.ID, null); DatasetGatewayWorkFlow.TA_ManagerDataTable managetTable = new DatasetGatewayWorkFlow.TA_ManagerDataTable(); managerTA.FillByPersonID(managetTable, ADOPerson1.ID); ADOManager1.ID = Convert.ToInt32(managetTable.Rows[0]["MasterMng_ID"]); ADOManager1.Person = ADOPerson1; accessGroupTA.Insert("AccessGroup1_2"); DatasetGatewayWorkFlow.TA_PrecardAccessGroupDataTable accessTable = accessGroupTA.GetDataBy1("AccessGroup1_2"); ADOAccessGroup1.ID = Convert.ToInt32(accessTable.Rows[0][0]); ADOAccessGroup1.Name = "AccessGroup1_2"; flowTA.Insert(ADOAccessGroup1.ID, false, false, "FlowTest"); DatasetGatewayWorkFlow.TA_FlowDataTable mangTAble = flowTA.GetDataByName("FlowTest"); ADOFlow1.ID = Convert.ToInt32(mangTAble.Rows[0][0]); ADOFlow1.FlowName = "FlowTest"; ADOFlow1.ActiveFlow = false; ADOFlow1.WorkFlow = false; mangFlowTA.Insert(ADOManager1.ID, 1, ADOFlow1.ID, true); DatasetGatewayWorkFlow.TA_ManagerFlowDataTable nbgFlowTable = mangFlowTA.GetDataByFlowID(ADOFlow1.ID); ADOManagerFlow1.ID = Convert.ToInt32(nbgFlowTable.Rows[0]["mngrFlow_ID"]); ADOManagerFlow1.Level = Convert.ToInt32(nbgFlowTable.Rows[0]["mngrFlow_LEVEL"]); #endregion requestStatusTA.Insert(ADOManagerFlow1.ID, ADORequestOvertime1.ID, true, false, "", DateTime.Now, false); request_testObject = new Request(); busOverTime = new BRequest(ADOPerson1.ID); #region insert workgroup,shift BWorkgroup bworkGroup = new BWorkgroup(); ADOWorkGroup.CustomCode = "55-55"; ADOWorkGroup.Name = "ClanderWorkGroupTest"; bworkGroup.SaveChanges(ADOWorkGroup, UIActionType.ADD); assingWorkGrouTA.Insert(ADOWorkGroup.ID, ADOPerson1.ID, new DateTime(2000, 1, 1)); BShift bshift = new BShift(); ADOShift1.Name = "ClanderShiftTest1"; ADOShift1.Person = ADOPerson1; ADOShift1.Color = "0xff6512"; ADOShift1.ShiftType = ShiftTypesEnum.WORK; ADOShift1.CustomCode = "55-54"; bshift.SaveChanges(ADOShift1, UIActionType.ADD); ShiftPair pair1 = new ShiftPair(100, 200) { ShiftId = ADOShift1.ID }; ShiftPair pair2 = new ShiftPair(200, 400) { ShiftId = ADOShift1.ID }; bshift.SaveChangesShiftPair(pair1, UIActionType.ADD); bshift.SaveChangesShiftPair(pair2, UIActionType.ADD); ADOShift2.Name = "ClanderShiftTest2"; ADOShift2.Color = "0xbbccaa"; ADOShift2.Person = ADOPerson1; ADOShift2.ShiftType = ShiftTypesEnum.WORK; ADOShift2.CustomCode = "55-55"; bshift.SaveChanges(ADOShift2, UIActionType.ADD); #endregion #region date inti date1 = Utility.ToMildiDate("1390/5/1"); date2 = Utility.ToMildiDate("1390/5/2"); date3 = Utility.ToMildiDate("1390/5/3"); date4 = Utility.ToMildiDate("1390/5/5"); date5 = Utility.ToMildiDate("1390/5/6"); date6 = Utility.ToMildiDate("1390/5/7"); date7 = Utility.ToMildiDate("1390/5/9"); #endregion #region WorkGroup Detail wgdTA.Insert(ADOWorkGroup.ID, ADOShift1.ID, date1); wgdTA.Insert(ADOWorkGroup.ID, ADOShift1.ID, date2); wgdTA.Insert(ADOWorkGroup.ID, ADOShift1.ID, date3); wgdTA.Insert(ADOWorkGroup.ID, ADOShift1.ID, date4); wgdTA.Insert(ADOWorkGroup.ID, ADOShift1.ID, date5); wgdTA.Insert(ADOWorkGroup.ID, ADOShift2.ID, date6); wgdTA.Insert(ADOWorkGroup.ID, ADOShift2.ID, date7); #endregion ClearSession(); }
public string[] UpdateShiftPair_ShiftPage(string state, string SelectedShiftID, string SelectedShiftPairID, string From, string To, string FromTolerance, string ToTolerance, string ContinueInNextDay) { this.InitializeCulture(); string[] retMessage = new string[4]; try { decimal ShiftPairID = 0; decimal selectedShiftID = decimal.Parse(this.StringBuilder.CreateString(SelectedShiftID)); decimal selectedShiftPairID = decimal.Parse(this.StringBuilder.CreateString(SelectedShiftPairID)); From = this.StringBuilder.CreateString(From); To = this.StringBuilder.CreateString(To); FromTolerance = this.StringBuilder.CreateString(FromTolerance); ToTolerance = this.StringBuilder.CreateString(ToTolerance); bool continueInNextDay = bool.Parse(this.StringBuilder.CreateString(ContinueInNextDay)); UIActionType uam = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper()); ShiftPair shiftPair = new ShiftPair(); shiftPair.ShiftId = selectedShiftID; shiftPair.ID = selectedShiftPairID; if (uam != Business.UIActionType.DELETE) { shiftPair.FromTime = From; shiftPair.ToTime = To; shiftPair.BeforeToleranceTime = FromTolerance; shiftPair.AfterToleranceTime = ToTolerance; shiftPair.NextDayContinual = continueInNextDay; } switch (uam) { case UIActionType.ADD: ShiftPairID = this.ShiftBusiness.InsertShiftPair(shiftPair, uam); break; case UIActionType.EDIT: if (selectedShiftPairID == 0) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoShiftPairSelectedforEdit").ToString()), retMessage); return(retMessage); } ShiftPairID = this.ShiftBusiness.UpdateShiftPair(shiftPair, uam); break; case UIActionType.DELETE: if (selectedShiftPairID == 0) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoShiftPairSelectedforDelete").ToString()), retMessage); return(retMessage); } ShiftPairID = this.ShiftBusiness.DeleteShiftPair(shiftPair, uam); break; } retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString(); string SuccessMessageBody = string.Empty; switch (uam) { case Business.UIActionType.ADD: SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString(); break; case Business.UIActionType.EDIT: SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString(); break; case Business.UIActionType.DELETE: SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString(); break; default: break; } retMessage[1] = SuccessMessageBody; retMessage[2] = "success"; retMessage[3] = ShiftPairID.ToString(); return(retMessage); } catch (UIValidationExceptions ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); return(retMessage); } catch (UIBaseException ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); return(retMessage); } catch (Exception ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); return(retMessage); } }
public decimal DeleteShiftPair(ShiftPair shiftPair, UIActionType UAT) { return(this.SaveChangesShiftPair(shiftPair, UAT)); }
/// <summary> /// دو شیفت را دریافت کرده و بررسی مسکند که آیا این دو بهم چسبیده اند یا خیر /// </summary> /// <param name="telorance">مقدار تلورانسی که اگر این دو شیفت با هم فاصله داشته باشند /// هم بهم چسبیده بحساب می آیند</param> private bool AreShiftsConnected(AssignedWGDShift shift1, AssignedWGDShift shift2, int telorance) { try { ShiftPair fSpwd1 = shift1.Pairs.OrderBy(x => x.From).FirstOrDefault(); decimal fBeforeTelorance1 = fSpwd1.BeforeTolerance; decimal fAfterTelorance1 = fSpwd1.AfterTolerance; ShiftPair lSpwd1 = shift1.Pairs.OrderBy(x => x.From).LastOrDefault(); decimal lBeforeTelorance1 = lSpwd1.BeforeTolerance; decimal lAfterTelorance1 = lSpwd1.AfterTolerance; ShiftPair fSpwd2 = shift2.Pairs.OrderBy(x => x.From).FirstOrDefault(); decimal fBeforeTelorance2 = fSpwd2.BeforeTolerance; decimal fAfterTelorance2 = fSpwd2.AfterTolerance; ShiftPair lSpwd2 = shift2.Pairs.OrderBy(x => x.From).LastOrDefault(); decimal lBeforeTelorance2 = lSpwd2.BeforeTolerance; decimal lAfterTelorance2 = lSpwd2.AfterTolerance; if (shift1.Date == shift2.Date) { if (lSpwd1.To + lAfterTelorance1 + telorance >= fSpwd2.From - fAfterTelorance2) { return(true); } else { return(false); } } //اگر تاریخ ها باهم تفاوت داشت باید بررسی کنیم که آیا //شیفت در فردا ادامه دارد و اگر دارد تا شیفت بعدی ادامه دارد یا خیر else if (shift2.Date > shift1.Date && lSpwd1.To + lAfterTelorance1 > DayMinutes) { int days = Convert.ToInt32((lSpwd1.To + lAfterTelorance1) / DayMinutes); DateTime endDate = shift1.Date.AddDays(days); int remainTime = lSpwd1.To + (int)lAfterTelorance1 - days * DayMinutes; if (endDate >= shift2.Date && remainTime + telorance >= fSpwd2.From - fBeforeTelorance2) { return(true); } } else if (shift1.Date > shift2.Date && lSpwd2.To + lAfterTelorance2 > DayMinutes) { int days = Convert.ToInt32((lSpwd2.To + lAfterTelorance2) / DayMinutes); DateTime endDate = shift2.Date.AddDays(days); int remainTime = lSpwd2.To + (int)lAfterTelorance2 - days * DayMinutes; if (endDate >= shift1.Date && remainTime + telorance >= fSpwd1.From - fBeforeTelorance1) { return(true); } } return(false); } catch (Exception ex) { throw ex; } }