/// <summary> /// تاریخ آخرین زمان محاسبات پرسنلی که محاسبه برای وی انجام شده است را بروزرسانی می نماید /// </summary> /// <param name="InvalidCalcResult"></param> private void UpdateExecutablePersonCalculation(decimal ExecutablePrsCalcId, decimal PersonId, DateTime ToDate) { ExecutablePersonCalculation ExecPrsCalc = ExecutablePersonCalculation.GetExecutablePersonCalcRepositoy(false).GetById(ExecutablePrsCalcId, false); if (ExecPrsCalc != null) { ExecPrsCalc.FromDate = ToDate; ExecPrsCalc.CalculationIsValid = true; ExecPrsCalc.MidNightCalculate = true; ExecutablePersonCalculation.GetExecutablePersonCalcRepositoy(false).WithoutTransactUpdate(ExecPrsCalc); } else { gtsRuleLogger.Error(PersonId.ToString(), "This is a test log", new Exception()); gtsRuleLogger.Flush(); } }
public static void GetLog(GTSEngineLogger gtsRuleLogger, string personCode, Exception ex) { if (ex is BaseException) { if (!((BaseException)ex).InsertedLog) { ((BaseException)ex).InsertedLog = true; gtsRuleLogger.Error(personCode, ex.Message, ex); gtsRuleLogger.Flush(); } } else { gtsRuleLogger.Error(personCode, ex.Message, ex); gtsRuleLogger.Flush(); } }
/// <summary> /// این تابع وظیفه اجرای قوانین برای تماممی اشخاصی که محاسباتشان نامعتبر است را برعهده دارد /// </summary> /// <param name="toDate"></param> public void Execute(string CallerIdentity, DateTime toDate) { try { IList <ExecutablePersonCalculation> MustExecuted = ExecutablePersonCalculation.GetExecutablePersonCalcRepositoy(false).GetAll(toDate); ThreadHelper.CleanupThreads(); IList <ExecutablePersonCalculation> Threads = ThreadHelper.AddThreads(CallerIdentity, MustExecuted, this.FinishedCallback); logger.Logger.Info( string.Format("Execute all start at '{0}', Total Thread Count: '{1}', Executable Thread Count: '{2}', Runing Thread Count: '{3}'", DateTime.Now.ToShortDateString() , ThreadHelper.TotalThreadCount , ThreadHelper.TotalThreadCount - ThreadHelper.TotalExecutingThreadCount , ThreadHelper.TotalExecutingThreadCount)); logger.Flush(); IList <Action> actions = new List <Action>(); foreach (ExecutablePersonCalculation item in Threads /*.Where(x => x.CalculationIsValid == false)*/) { item.ToDate = toDate; ExecutableThread.ThreadParam param = ThreadHelper.PrepareToExecute(CallerIdentity, item); if (param != null) { //ThreadPool.QueueUserWorkItem(new WaitCallback(this.Execute), param); actions.Add(() => this.Execute(param)); } } Task.Factory.StartNew(() => Parallel.Invoke( new ParallelOptions() { MaxDegreeOfParallelism = MaxThread }, actions.ToArray())); } catch (Exception ex) { logger.Error("Execute(string CallerIdentity, DateTime toDate)->", "" + ex.Message, ex); logger.Flush(); throw ex; } }