/// <summary>
        /// Getting MTD status for a metric
        /// </summary>
        /// <param name="target">Target whose status needs to be find out</param>
        /// <param name="year">Year for which status is required</param>
        /// <param name="month">Month for which status is required</param>
        /// <returns>Drill down status of metric</returns>
        public ActualStatus GetMetricMTDStatus(Target
                                               target, int year, int month)
        {
            ActualStatus status = ActualStatus.NotEntered;
            var          primaryMetricTargetId = target?.Id;

            if (primaryMetricTargetId.HasValue)
            {
                int trackingMethod           = target.TrackingMethodId;
                int?mtdPerformanceTrackingId = target.MTDPerformanceTrackingMethodId;
                if (trackingMethod == Constants.TrackingMethodDaily && mtdPerformanceTrackingId.HasValue)
                {
                    status = GetMonthToDatePerformance(target, year, month).Status;
                }
                else if (trackingMethod == Constants.TrackingMethodMonthly)
                {
                    var monthlyActual = monthlyActualRepository.GetAll()
                                        .FirstOrDefault(x => x.TargetId == primaryMetricTargetId.Value && x.Month == month &&
                                                        (x.Status == ActualStatus.Achieved || x.Status == ActualStatus.NotAchieved));
                    if (monthlyActual != null)
                    {
                        status = monthlyActual.Status;
                    }
                }
            }
            return(status);
        }
Exemple #2
0
        /// <summary>
        /// method to return status by comparing goal and actual value based on goal type
        /// </summary>
        /// <param name="goalValue"></param>
        /// <param name="actualValue"></param>
        /// <param name="goalTypeId"></param>
        /// <returns></returns>
        public static ActualStatus GetActualStatus(decimal?goalValue,
                                                   decimal?actualValue, int goalTypeId)
        {
            ActualStatus status = new ActualStatus();

            if (goalValue.HasValue)
            {
                switch (goalTypeId)
                {
                case Constants.GoalTypeEqualTo:
                    status = (actualValue == goalValue) ? ActualStatus.Achieved
                                : ActualStatus.NotAchieved;
                    break;

                case Constants.GoalTypeGreaterThanOrEqualTo:
                    status = (actualValue >= goalValue) ? ActualStatus.Achieved
                           : ActualStatus.NotAchieved;
                    break;

                case Constants.GoalTypeLessThanOrEqualTo:
                    status = (actualValue <= goalValue) ? ActualStatus.Achieved
                           : ActualStatus.NotAchieved;
                    break;
                }
            }
            else
            {
                status = ActualStatus.NotEntered;
            }
            return(status);
        }
Exemple #3
0
 /// <summary>
 /// Получение элемента из XML
 /// </summary>
 /// <param name="st"></param>
 /// <returns></returns>
 public static DbActualStatus Get(ActualStatus st)
 {
     return(new DbActualStatus()
     {
         ActstatId = st.ActstatId,
         Name = st.Name
     });
 }
        public static AObject CreateNew(int depth = 0)
        {
            rt.fias.model.fias.AObject entity = new rt.fias.model.fias.AObject();

            // You may need to maually enter this key if there is a constraint violation.
            entity.Id = System.Guid.NewGuid();

            entity.Aoguid     = System.Guid.NewGuid();
            entity.Formalname = "Test Test ";
            entity.Regioncode = "T";
            entity.Autocode   = "T";
            entity.Areacode   = "Te";
            entity.Citycode   = "Te";
            entity.Ctarcode   = "T";
            entity.Placecode  = "T";
            entity.Streetcode = "Tes";
            entity.Extrcode   = "Test Test ";
            entity.Sextcode   = "T";
            entity.Offname    = "Test Test ";
            entity.Postalcode = "Test";
            entity.Ifnsfl     = "Tes";
            entity.Terrifnsfl = "Tes";
            entity.Ifnsul     = "Tes";
            entity.Terrifnsul = "T";
            entity.Okato      = "Test Test";
            entity.Oktmo      = "Test Te";
            entity.Updatedate = System.DateTime.Now;
            entity.Shortname  = "T";
            entity.Aolevel    = 28;
            entity.Parentguid = System.Guid.NewGuid();
            entity.Code       = "123";
            entity.Plaincode  = "Test Test T";
            entity.Startdate  = System.DateTime.Now;
            entity.Enddate    = System.DateTime.Now;
            entity.Normdoc    = System.Guid.NewGuid();
            entity.Livestatus = "T";

            using (rt.fias.business.manager.IActualStatusManager actualStatusManager = ObjectFactory.GetInstance <IActualStatusManager>())
            {
                var          all       = actualStatusManager.GetAll(1);
                ActualStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

                if (entityRef == null && depth < 3)
                {
                    depth++;
                    entityRef = ActualStatusTests.CreateNew(depth);
                    ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef);
                }

                entity.ACTSTATUS = entityRef;
            }

            using (rt.fias.business.manager.ICenterStatusManager centerStatusManager = ObjectFactory.GetInstance <ICenterStatusManager>())
            {
                var          all       = centerStatusManager.GetAll(1);
                CenterStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

                if (entityRef == null && depth < 3)
                {
                    depth++;
                    entityRef = CenterStatusTests.CreateNew(depth);
                    ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef);
                }

                entity.CENTSTATUS = entityRef;
            }

            using (rt.fias.business.manager.ICurrentStatusManager currentStatusManager = ObjectFactory.GetInstance <ICurrentStatusManager>())
            {
                var           all       = currentStatusManager.GetAll(1);
                CurrentStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

                if (entityRef == null && depth < 3)
                {
                    depth++;
                    entityRef = CurrentStatusTests.CreateNew(depth);
                    ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef);
                }

                entity.CURRSTATUS = entityRef;
            }

            using (rt.fias.business.manager.IAObjectManager aObjectMember1Manager = ObjectFactory.GetInstance <IAObjectManager>())
            {
                entity.NEXT = null;
            }

            using (rt.fias.business.manager.IAObjectManager aObjectMember2Manager = ObjectFactory.GetInstance <IAObjectManager>())
            {
                entity.PREV = null;
            }

            using (rt.fias.business.manager.IOperationStatusManager operationStatusManager = ObjectFactory.GetInstance <IOperationStatusManager>())
            {
                var             all       = operationStatusManager.GetAll(1);
                OperationStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

                if (entityRef == null && depth < 3)
                {
                    depth++;
                    entityRef = OperationStatusTests.CreateNew(depth);
                    ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef);
                }

                entity.OPERSTATUS = entityRef;
            }

            return(entity);
        }