예제 #1
0
        public bool ExecutePositions()
        {
            foreach (var position in Plan.PositionLogs)
            {
                //try
                //{
                //    CacheScheme(position);
                //}
                //catch (Exception)
                //{
                //    _log.LogError(Plan.Id, string.Format("There is no scheme for HCType {0} Company {1}", position.HCType.Code, position.Company.Code));
                //}
                //var scheme = _schemeCache[Tuple.Create(position.HCType.Code, position.Company.Code)];
                var scheme = _dataService.GetScheme(Plan.Id, Plan.FiscalYearId, Plan.From, Plan.To, position.PositionLogId, position.EmployeeLogId, position.HCType.Code, position.Company.Code);

                if (scheme != null)
                {
                    try
                    {
                        scheme.StartOver();
                        while (scheme.HasConceptsToRun())
                        {
                            var concept = scheme.GetCurrentConcept();
                            if (concept != null)
                            {
                                _dataService.UpdateConceptWithCurrentFunctionValues(Plan.Id, Plan.FiscalYearId, position.PositionLogId, position.EmployeeLogId,
                                                                                    concept);
                                _dataService.UpdateConceptFilterParametersWithCurrentFunctionValues(Plan.Id, Plan.FiscalYearId, position.PositionLogId, position.EmployeeLogId,
                                                                                                    concept);
                                _dataService.SaveInputParameters(Plan.Id, concept);
                                scheme.RunConcept();
                                _dataService.CreateResults(Plan.Id, position.PositionLogId, new List <IConcept> {
                                    concept
                                });
                            }
                            scheme.MoveNext();
                        }
                        _log.LogInfo(Plan.Id, string.Format("PositionLogId {0} executed", position.PositionLogId));
                    }
                    catch (Exception e)
                    {
                        _log.LogError(Plan.Id, e.Message);
                        _log.LogInfo(Plan.Id, string.Format("PositionLogId {0} NOT executed", position.PositionLogId));
                        continue;
                    }
                }
                else
                {
                    _log.LogError(Plan.Id, string.Format("There is no scheme for HCType {0} Company {1}", position.HCType.Code, position.Company.Code));
                }
            }
            //Thread.Sleep(100000);
            return(true);
        }