Example #1
0
        protected override bool Execute(CodeActivityContext context)
        {
            DateTime dt = new DateTime(Year.Get(context), Month.Get(context), 1);

            try
            {
                TI_ChanelType ti = new TI_ChanelType
                {
                    ChannelType    = ChannelType.Get(context),
                    TI_ID          = TiId.Get(context),
                    DataSourceType = null
                };

                SectionIntegralComplexResults result =
                    ARM_Service.GroupTP_GetActConsumptionPowerTi(ti, ExcelAdapterType, dt, 2, ".", IsReadCalculatedValues.Get(context), isExportAllIncludetTi.Get(context), false, null, WcfTimeOut.Get(context));
                if (!string.IsNullOrEmpty(result.Errors.ToString()))
                {
                    Error.Set(context, result.Errors.ToString());
                }
                else
                {
                    SendEmail(context, CompressUtility.DecompressGZip(result.Document));
                }
            }
            catch (Exception ex)
            {
                Error.Set(context, ex.Message);
                if (!HideException.Get(context))
                {
                    throw ex;
                }
            }

            return(string.IsNullOrEmpty(Error.Get(context)));
        }
Example #2
0
        protected override bool Execute(CodeActivityContext context)
        {
            Error.Set(context, null);

            if (Parameters == null)
            {
                Error.Set(context, "Не определены параметры управления");
                return(false);
            }

            if (string.IsNullOrEmpty(LoginInfo.UserName) || string.IsNullOrEmpty(LoginInfo.Password))
            {
                Error.Set(context, "Не определены параметры авторизации");
                return(false);
            }

            int         ti_id = TiId.Get(context);
            CommandInfo paramscommand;

            try
            {
                try
                {
                    paramscommand = Parameters.DeserializeFromString <CommandInfo>();
                }
                catch (Exception ex)
                {
                    Error.Set(context, "Ошибка преобразования параметров команды" + ex.Message);
                    return(false);
                }

//command.SerializeToString<CommandInfo>()   - в строку
//command.DeserializeFromString<CommandInfo>()   - из строки

                List <KeyValuePair <int, FailReason> > Res = ARM_Service.DM_Set_Device_Methods(LoginInfo.UserName, LoginInfo.Password, paramscommand.Request,
                                                                                               new List <Tuple <int, List <KeyValuePair <long, DeviceMethodDescription> > > >()
                {
                    new Tuple <int, List <KeyValuePair <long, DeviceMethodDescription> > >(paramscommand.DeviceToClass_ID, paramscommand.Methods)
                }, new List <int>()
                {
                    ti_id
                });
                if (Res.Count == 1)
                {
                    Error.Set(context, GlobalEnumsDictionary.ConvertFailReasonToString(Res[0].Value));
                }
            }
            catch (Exception ex)
            {
                Error.Set(context, ex.Message);
                if (!HideException.Get(context))
                {
                    throw ex;
                }
            }
            return(string.IsNullOrEmpty(Error.Get(context)));
        }
        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)));
        }
        protected override bool Execute(CodeActivityContext context)
        {
            int ti_id = TiId.Get(context);

            Value.Set(context, 0);
            Status.Set(context, (int)VALUES_FLAG_DB.DataNotFull);
            StatusStr.Set(context, TVALUES_DB.FLAG_to_String(VALUES_FLAG_DB.DataNotFull, ";"));
            ValueDateTime.Set(context, DateTime.MinValue);

            List <TINTEGRALVALUES_DB> _valueList = new List <TINTEGRALVALUES_DB>();

            ValueList.Set(context, _valueList);

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

            try
            {
                List <TI_ChanelType> tiList = new List <TI_ChanelType>()
                {
                    new TI_ChanelType()
                    {
                        TI_ID          = ti_id,
                        ChannelType    = Channel.Get(context),
                        DataSourceType = DataSourceType,
                    }
                };

                if (RequestType == enumEnrgyQualityRequestType.Archive)
                {
                    //TODO часовой пояс
                    var values = ARM_Service.DS_GetIntegralsValues_List(tiList,
                                                                        StartDateTime.Get(context),
                                                                        EndDateTime.Get(context),
                                                                        IsCoeffEnabled, false, false, true, false, false, enumTimeDiscreteType.DBHalfHours, EnumUnitDigit.None, null, false,
                                                                        false);


                    if (values != null && values.IntegralsValue30orHour != null && values.IntegralsValue30orHour.Count > 0)
                    {
                        var    integralTiValue = values.IntegralsValue30orHour[0];
                        double diff            = 0;
                        var    flag            = VALUES_FLAG_DB.None;
                        if (integralTiValue.Val_List != null)
                        {
                            foreach (var iVal in integralTiValue.Val_List)
                            {
                                diff += iVal.F_VALUE_DIFF;
                                flag  = flag.CompareAndReturnMostBadStatus(iVal.F_FLAG);
                                _valueList.Add(iVal);
                            }
                        }

                        Value.Set(context, diff);
                        var stat = flag;
                        Status.Set(context, (int)stat);
                        StatusStr.Set(context, TVALUES_DB.FLAG_to_String(stat, ";"));

                        if (integralTiValue.Val_List != null && integralTiValue.Val_List.Count > 0)
                        {
                            ValueDateTime.Set(context, integralTiValue.Val_List.Last().EventDateTime);
                        }
                    }
                }
                else
                {
                    var Val = ARM_Service.DS_ReadLastIntegralArchives(tiList);
                    if (Val != null && Val.Count > 0)
                    {
                        var ValDict = Val.ToDictionary(k => k.Key, v => v.Value, new TI_ChanelComparer());
                        foreach (var r in tiList)
                        {
                            TINTEGRALVALUES_DB i_val;

                            if (ValDict.TryGetValue(r, out i_val) && i_val != null)
                            {
                                Value.Set(context, i_val.F_VALUE);
                                Status.Set(context, (int)i_val.F_FLAG);
                                StatusStr.Set(context, TVALUES_DB.FLAG_to_String(i_val.F_FLAG, ";"));
                                ValueDateTime.Set(context, i_val.EventDateTime);
                                _valueList.Add(i_val);
                                break;
                            }
                        }
                    }
                }
            }

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

            ValueList.Set(context, _valueList);

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