Ejemplo n.º 1
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)));
        }