protected override void InitializeCulture() { BLanguage LangProv = new BLanguage(); this.SetCurrentCultureResObjs(LangProv.GetCurrentLanguage()); base.InitializeCulture(); }
/// <summary> /// /// </summary> /// <param name="operatorPersonID"></param> /// <param name="TTM"></param> /// <param name="machineID"></param> /// <param name="fromDate"></param> /// <param name="toDate"></param> /// <param name="fromTime"></param> /// <param name="toTime"></param> /// <param name="fromRecord"></param> /// <param name="toRecord"></param> /// <param name="fromIdentifier"></param> /// <param name="toIdentifier"></param> /// <param name="transferDay"></param> /// <param name="transferTime"></param> /// <param name="TTT"></param> /// <param name="IsIntegralConditions"></param> public void TransferTraffics(decimal operatorPersonID, TrafficTransferMode TTM, decimal machineID, string fromDate, string toDate, string fromTime, string toTime, int fromRecord, int toRecord, decimal fromIdentifier, decimal toIdentifier, string transferDay, string transferTime, TrafficTransferType TTT, bool IsIntegralConditions) { try { GTS.Clock.Infrastructure.Repository.BasicTrafficRepository basicTrafficRepository = new Infrastructure.Repository.BasicTrafficRepository(); BLanguage LanguageBusiness = new BLanguage(); DateTime FromDate = DateTime.Now; DateTime ToDate = DateTime.Now; switch (LanguageBusiness.GetCurrentSysLanguage()) { case "fa-IR": FromDate = Utility.ToMildiDate(fromDate); ToDate = Utility.ToMildiDate(toDate); break; case "en-US": FromDate = Utility.ToMildiDateTime(fromDate); ToDate = Utility.ToMildiDateTime(toDate); break; } if (DateTime.Compare(FromDate, ToDate) > 0) { FromDate = ToDate; } int FromTime = Utility.RealTimeToIntTime(fromTime); int ToTime = Utility.RealTimeToIntTime(toTime); int TransferTime = Utility.RealTimeToIntTime(transferTime); int TransferDay = 0; if (transferDay != null && transferDay != string.Empty) { TransferDay = int.Parse(transferDay); } int TargetTime = 0; switch (TTM) { case TrafficTransferMode.RecordBase: int BasicTrafficsRowCount = basicTrafficRepository.GetBasicTrfficsRowCount(); toRecord = toRecord > 0 ? toRecord <= BasicTrafficsRowCount ? toRecord : BasicTrafficsRowCount : 1; fromRecord = fromRecord > 0 ? fromRecord <= toRecord ? fromRecord : 1 : 1; break; case TrafficTransferMode.IdentifierBase: decimal BasicTrafficsLastRowIdentifier = basicTrafficRepository.GetBaseTrafficsLastRowIdentifier(); toIdentifier = toIdentifier > 0 ? toIdentifier <= BasicTrafficsLastRowIdentifier ? toIdentifier : BasicTrafficsLastRowIdentifier : 0; fromIdentifier = fromIdentifier >= 0 ? fromIdentifier <= toIdentifier ? fromIdentifier : 0 : 0; break; } IList <BasicTraffic> BasicTrafficsList = basicTrafficRepository.GetAllBaiscTrafficsByConditions(TTM, machineID, FromDate, ToDate, FromTime, ToTime, fromRecord, toRecord, fromIdentifier, toIdentifier, IsIntegralConditions); trafficCount = BasicTrafficsList.Count; foreach (BasicTraffic BasicTrafficsListItem in BasicTrafficsList) { string errorDate = string.Empty; string errorDescription = string.Empty; switch (LanguageBusiness.GetCurrentLanguage()) { case "fa-IR": errorDescription = "اشکال در انتقال تردد " + BasicTrafficsListItem.Person.Name + " به شماره پرسنلی " + BasicTrafficsListItem.Person.BarCode + " در تاریخ " + BasicTrafficsListItem.Date + " و ساعت " + Utility.IntTimeToRealTime(BasicTrafficsListItem.Time) + ""; break; case "en-US": errorDescription = "Problem In Traffic Transfer " + BasicTrafficsListItem.Person.Name + " with Personnel Code " + BasicTrafficsListItem.Person.BarCode + " in Date " + BasicTrafficsListItem.Date + " and Time " + Utility.IntTimeToRealTime(BasicTrafficsListItem.Time) + ""; break; } switch (LanguageBusiness.GetCurrentSysLanguage()) { case "fa-IR": errorDate = Utility.ToPersianDate(BasicTrafficsListItem.Date); break; case "en-US": errorDate = Utility.ToString(BasicTrafficsListItem.Date); break; } switch (TTT) { case TrafficTransferType.Backward: BasicTrafficsList = BasicTrafficsList.OrderBy(x => x.DateTime).ToList <BasicTraffic>(); TargetTime = BasicTrafficsListItem.Time - TransferTime; using (this.NHSession.BeginTransaction()) { try { if (TargetTime >= 0) { BasicTrafficsListItem.Time = TargetTime; BasicTrafficsListItem.Date = BasicTrafficsListItem.Date.AddDays(-TransferDay); BasicTrafficsListItem.Transferred = true; objectRep.WithoutTransactUpdate(BasicTrafficsListItem); UpdateCFP(BasicTrafficsListItem, UIActionType.EDIT); } else { this.DeleteTraffic(operatorPersonID, BasicTrafficsListItem.ID); this.InsertTraffic(operatorPersonID, BasicTrafficsListItem.Person.ID, BasicTrafficsListItem.Precard.ID, BasicTrafficsListItem.Date.AddDays(-(TransferDay + 1)), BasicTrafficsListItem.Time + (24 * 60 - TransferTime), "TrraficTimeTransfer"); } NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { LogException(new Exception(errorDescription + " " + ex.Message), "BTraffic", "TransferDayTrafficsByConditions"); NHibernateSessionManager.Instance.RollbackTransactionOn(); SessionHelper.SaveSessionValue(SessionHelper.TrafficsTransferErrorOccuredCountSessionName, trafficErrorOccuredCounter++); } } break; case TrafficTransferType.Forward: BasicTrafficsList = BasicTrafficsList.OrderByDescending(x => x.DateTime).ToList <BasicTraffic>(); TargetTime = BasicTrafficsListItem.Time + TransferTime; using (this.NHSession.BeginTransaction()) { try { if (TargetTime < 24 * 60) { BasicTrafficsListItem.Time = TargetTime; BasicTrafficsListItem.Date = BasicTrafficsListItem.Date.AddDays(TransferDay); BasicTrafficsListItem.Transferred = true; objectRep.WithoutTransactUpdate(BasicTrafficsListItem); UpdateCFP(BasicTrafficsListItem, UIActionType.EDIT); } else { this.DeleteTraffic(operatorPersonID, BasicTrafficsListItem.ID); this.InsertTraffic(operatorPersonID, BasicTrafficsListItem.Person.ID, BasicTrafficsListItem.Precard.ID, BasicTrafficsListItem.Date.AddDays(TransferDay + 1), (BasicTrafficsListItem.Time + TransferTime) - 24 * 60, "TrraficTimeTransfer"); } NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { LogException(new Exception(errorDescription + " " + ex.Message), "BTraffic", "TransferDayTrafficsByConditions"); NHibernateSessionManager.Instance.RollbackTransactionOn(); SessionHelper.SaveSessionValue(SessionHelper.TrafficsTransferErrorOccuredCountSessionName, trafficErrorOccuredCounter++); } } break; } SessionHelper.SaveSessionValue(SessionHelper.TrafficsTransferCompletedCountSessionName, trafficCounter++); } } catch (Exception ex) { LogException(ex, "BTraffic", "TransferDayTrafficsByConditions"); throw ex; } }