protected override bool Execute(CodeActivityContext context)
        {
            object obj_id = ObjectID.Get(context);

            if (obj_id == null)
            {
                Error.Set(context, "Не опреден идентификатор объекта");
                return(false);
            }

            SummValues.Set(context, 0);
            Status.Set(context, (int)VALUES_FLAG_DB.DataNotFull);
            StatusStr.Set(context, TVALUES_DB.FLAG_to_String(VALUES_FLAG_DB.DataNotFull, ";"));

            var found = false;
            List <TVALUES_DB> vallist = null;

            try
            {
                var tidList   = new List <ID_Hierarchy_Channel>();
                var IH_Chanel = new ID_Hierarchy_Channel();
                IH_Chanel.ID            = obj_id.ToString();
                IH_Chanel.TypeHierarchy = (enumTypeHierarchy)ObjectType;
                IH_Chanel.Channel       = (byte)Channel;
                tidList.Add(IH_Chanel);

                //TODO часовой пояс
                var res = ARM_Service.DS_GetArchivesHierObjectLastHalfHours(
                    tidList,
                    IsCoeffEnabled,
                    StartDateTime.Get(context),
                    EndDateTime.Get(context),
                    DataSourceType,
                    DiscreteType, UnitDigit, false, null);


                if (res != null && res.Result_Values != null && res.Result_Values.Count > 0)
                {
                    var resultValues = new Dictionary <ID_Hierarchy_Channel, List <TVALUES_DB> >(res.Result_Values, new ID_Hierarchy_Channel_EqualityComparer());

                    if (resultValues.TryGetValue(IH_Chanel, out vallist) && vallist != null)
                    {
                        found = true;
                        var R = vallist.Accomulate();
                        SummValues.Set(context, R.F_VALUE);
                        Status.Set(context, (int)R.F_FLAG);
                        StatusStr.Set(context, TVALUES_DB.FLAG_to_String(R.F_FLAG, ";"));
                    }
                }
            }

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

            if (vallist == null)
            {
                vallist = new List <TVALUES_DB>();
            }
            ValueList.Set(context, vallist);

            return(string.IsNullOrEmpty(Error.Get(context)));
        }
Exemple #2
0
        protected override bool Execute(CodeActivityContext context)
        {
            var formulaUn = Formula_UN.Get(context);

            if (string.IsNullOrEmpty(formulaUn))
            {
                Error.Set(context, "Не определен идентификатор формулы");
                return(false);
            }

            var fId = new TFormulaParam
            {
                FormulaID     = formulaUn,
                FormulasTable = enumFormulasTable.Info_Formula_Description,
                IsFormulaHasCorrectDescription = true,
            };

            TFormulasResult result = null;

            try
            {
                var res = ARM_Service.FR_GetFormulasResults(new List <TFormulaParam> {
                    fId
                },
                                                            StartDateTime.Get(context),
                                                            EndDateTime.Get(context),
                                                            DiscreteType,
                                                            DataSourceType,
                                                            1,
                                                            IsCoeffEnabled,
                                                            false,
                                                            isPower,
                                                            false,
                                                            UnitDigit, null, false, false);


                if (res != null && res.Result_Values != null && res.Result_Values.Count > 0)
                {
                    var rv = res.Result_Values[0];
                    if (rv != null && rv.Result_Values != null && rv.Result_Values.Count > 0)
                    {
                        result = rv.Result_Values[0];
                        if (result.Val_List != null)
                        {
                            var r = result.Val_List.Accomulate();
                            SummValues.Set(context, r.F_VALUE);
                            Status.Set(context, (int)r.F_FLAG);
                            StatusStr.Set(context, TVALUES_DB.FLAG_to_String(r.F_FLAG, ";"));
                        }
                    }
                }

                if (res.Errors != null)
                {
                    Error.Set(context, res.Errors.ToString());
                }

                FormulaResult.Set(context, result);
            }
            catch (Exception ex)
            {
                Error.Set(context, ex.Message);
                if (!HideException.Get(context))
                {
                    throw ex;
                }
            }
            return(string.IsNullOrEmpty(Error.Get(context)));
        }