protected override bool Execute(CodeActivityContext context)
        {
            if (TIList.Get(context) == null)
            {
                Error.Set(context, "Не определен список идентификаторов ТИ");
                return(false);
            }

            List <int> InList = TIList.Get(context);

            if (InList.Count == 0)
            {
                Error.Set(context, "Список идентификаторов ТИ не должен быть пустым");
                return(false);
            }

            if (TechParamTypes == null || TechParamTypes.Count == 0)
            {
                Error.Set(context, "Список параметров мгновенных значений не должен быть пустым");
                return(false);
            }

            if (RequestType == enumEnrgyQualityRequestType.Archive)
            {
                if (ServerFromLook.Get(context) == null || ServerToLook.Get(context) == null)
                {
                    Error.Set(context, "Для архивных значений начальная и конечная дата должна быть определена");
                    return(false);
                }
            }

            try
            {
                var dt  = ServerFromLook.Get(context);
                var tis = InList.ToDictionary(k => k, v => dt);

                var res = ARM_Service.DS_GetArchTech_Quality_LastValues(tis, ServerToLook.Get(context), TechParamTypes, false);
                if (res != null)
                {
                    if (res.Errors != null)
                    {
                        Error.Set(context, res.Errors);
                    }

                    Values.Set(context, res.LastValues);
                }
            }
            catch (Exception ex)
            {
                Error.Set(context, ex.Message);
                if (!HideException.Get(context))
                {
                    throw ex;
                }
            }

            return(string.IsNullOrEmpty(Error.Get(context)));
        }
Ejemplo n.º 2
0
        protected override bool Execute(CodeActivityContext context)
        {
            int ti_id = TiId.Get(context);
            Dictionary <int, DateTime?> List_ti_id = new Dictionary <int, DateTime?>();

            List_ti_id[ti_id] = ServerFromLook.Get(context);

            if (TechParamTypes == null || TechParamTypes.Count == 0)
            {
                Error.Set(context, "Список параметров мгновенных значений не должен быть пустым");
                return(false);
            }

            if (RequestType == enumEnrgyQualityRequestType.Archive)
            {
                if (ServerFromLook.Get(context) == null || ServerToLook.Get(context) == null)
                {
                    Error.Set(context, "Для архивных значений начальная и конечная дата должна быть определена");
                    return(false);
                }
            }

            try
            {
                var res = ARM_Service.DS_GetArchTech_Quality_LastValues(List_ti_id, ServerToLook.Get(context), TechParamTypes, false);
                if (res != null)
                {
                    if (res.Errors != null)
                    {
                        Error.Set(context, res.Errors);
                    }

                    List <TArchTechQualityValue> result;
                    if (res.LastValues != null && res.LastValues.TryGetValue(ti_id, out result))
                    {
                        Values.Set(context, result);
                    }
                }
            }
            catch (Exception ex)
            {
                Error.Set(context, ex.Message);
                if (!HideException.Get(context))
                {
                    throw ex;
                }
            }

            return(string.IsNullOrEmpty(Error.Get(context)));
        }