public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo)
        {
            IPlugInAPI.strMultiReturn result = default;
            result.DataOut     = actionInfo.DataIn;
            result.TrigActInfo = actionInfo;
            result.sResult     = string.Empty;
            if (postData != null && postData.Count > 0)
            {
                RefreshDeviceAction action = (actionInfo.DataIn != null) ?
                                             (RefreshDeviceAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) :
                                             new RefreshDeviceAction();

                foreach (var pair in postData)
                {
                    string text = Convert.ToString(pair, CultureInfo.InvariantCulture);
                    if (!string.IsNullOrWhiteSpace(text) && text.StartsWith(RefreshActionUIDropDownName, StringComparison.Ordinal))
                    {
                        action.DeviceRefId = Convert.ToInt32(postData[text], CultureInfo.InvariantCulture);
                    }
                }

                result.DataOut = ObjectSerialize.SerializeToBytes(action);
            }

            return(result);
        }
示例#2
0
        public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo)
        {
            IPlugInAPI.strMultiReturn result = default;
            result.DataOut     = actionInfo.DataIn;
            result.TrigActInfo = actionInfo;
            result.sResult     = string.Empty;
            if (postData != null && postData.Count > 0)
            {
                var action = (actionInfo.DataIn != null) ?
                             (TakeSnapshotAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) :
                             new TakeSnapshotAction();

                foreach (var pair in postData)
                {
                    string text = Convert.ToString(pair, CultureInfo.InvariantCulture);
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        if (text.StartsWith(nameof(TakeSnapshotAction.Id), StringComparison.Ordinal))
                        {
                            action.Id = postData[text];
                        }
                        else if (text.StartsWith(NameToIdWithPrefix(nameof(TakeSnapshotAction.TimeSpan)), StringComparison.Ordinal))
                        {
                            try
                            {
                                action.TimeSpan = TimeSpan.Parse(postData[text], CultureInfo.InvariantCulture);
                            }
                            catch (Exception)
                            {
                                result.sResult += "<BR>Time span is not valid";
                            }
                        }
                        else if (text.StartsWith(NameToIdWithPrefix(nameof(TakeSnapshotAction.Interval)), StringComparison.Ordinal))
                        {
                            try
                            {
                                action.Interval = TimeSpan.Parse(postData[text], CultureInfo.InvariantCulture);
                            }
                            catch (Exception)
                            {
                                result.sResult += "<BR>Interval is not valid";
                            }
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(action.Id))
                {
                    result.sResult += "<BR>Camera is not valid";
                }
                result.DataOut = ObjectSerialize.SerializeToBytes(action);
            }

            return(result);
        }
示例#3
0
        public override IPlugInAPI.strMultiReturn TriggerProcessPostUI(NameValueCollection postData, IPlugInAPI.strTrigActInfo trigInfo)
        {
            if (trigInfo.TANumber != 1)
            {
                throw new Exception("Unknown trigger number " + trigInfo.TANumber);
            }

            IPlugInAPI.strMultiReturn ret = new IPlugInAPI.strMultiReturn();
            ret.TrigActInfo = trigInfo;
            ret.DataOut     = trigInfo.DataIn;

            foreach (string key in postData.AllKeys)
            {
                string[] parts = key.Split('_');
                if (parts.Length > 1)
                {
                    postData.Add(parts[0], postData.Get(key));
                    Program.WriteLog(LogType.Console, parts[0] + " set to " + postData.Get(key));
                }
            }

            TriggerData trig = TriggerData.Unserialize(trigInfo.DataIn);

            int    tempInt;
            string tempStr;

            if ((tempStr = postData.Get("TrigType")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.Type = (TriggerType)tempInt;
            }

            if ((tempStr = postData.Get("DeviceLeft")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.DevRefLeft = tempInt;
            }

            if ((tempStr = postData.Get("DeviceRight")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.DevRefRight = tempInt;
            }

            if ((tempStr = postData.Get("CompOperator")) != null && int.TryParse(tempStr, out tempInt))
            {
                trig.Comparison = (TriggerComp)tempInt;
            }

            Program.WriteLog(LogType.Console, "Returning " + trig);
            ret.DataOut = trig.Serialize();
            return(ret);
        }
示例#4
0
        public IPlugInAPI.strMultiReturn GetRefreshActionPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo)
        {
            IPlugInAPI.strMultiReturn result = default;
            result.DataOut     = actionInfo.DataIn;
            result.TrigActInfo = actionInfo;
            result.sResult     = string.Empty;
            if (postData != null && postData.Count > 0)
            {
                var action = (actionInfo.DataIn != null) ?
                             (ChromecastCastAction)ObjectSerialize.DeSerializeFromBytes(actionInfo.DataIn) :
                             new ChromecastCastAction();

                foreach (var pair in postData)
                {
                    string text = Convert.ToString(pair);
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        if (text.StartsWith(nameof(ChromecastCastAction.ChromecastDeviceId)))
                        {
                            action.ChromecastDeviceId = postData[text];
                        }
                        else if (text.StartsWith(nameof(ChromecastCastAction.Url)))
                        {
                            action.Url = postData[text];
                        }
                        else if (text.StartsWith(nameof(ChromecastCastAction.ContentType)))
                        {
                            action.ContentType = postData[text];
                        }
                        else if (text.StartsWith(nameof(ChromecastCastAction.Live)))
                        {
                            action.Live = postData[text] == "checked";
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(action.Url))
                {
                    result.sResult += "<BR>Url is not valid";
                }

                if (string.IsNullOrWhiteSpace(action.ChromecastDeviceId))
                {
                    result.sResult += "<BR>Chromecast device is not valid";
                }
                result.DataOut = ObjectSerialize.SerializeToBytes(action);
            }

            return(result);
        }
        public IPlugInAPI.strMultiReturn TriggerProcessPostUi(NameValueCollection postData,
                                                              IPlugInAPI.strTrigActInfo trigActInfo)
        {
            var returnData = new IPlugInAPI.strMultiReturn();

            returnData.DataOut     = trigActInfo.DataIn;
            returnData.TrigActInfo = trigActInfo;
            returnData.sResult     = string.Empty;

            if (postData == null || postData.Count < 1)
            {
                return(returnData);
            }

            object action          = new Classes.action();
            var    formattedAction = _collectionFactory.GetActionsIfPossible(trigActInfo);

            formattedAction = _reformatCopiedAction.Run(formattedAction, trigActInfo.UID, trigActInfo.evRef);

            postData.Add(Constants.TriggerTypeKey,
                         this.ToString());        //this.GetType().Name);// typeof(this).Name;//this.ToString());

            postData.Add(Constants.IsConditionKey, _isCondition.ToString());

            //postData.Add(Constants.Uid, trigActInfo.UID.ToString());
            //postData.Add(Constants.EvRef, trigActInfo.evRef.ToString());

            foreach (string dataKey in postData)
            {
                if (string.IsNullOrEmpty(dataKey))
                {
                    continue;
                }

                var strippedKey = StripKeyOfUidStuff(dataKey);

                formattedAction.AddObject(strippedKey, (object)postData[dataKey]);
            }

            object objAction = (object)formattedAction;

            Utility.SerializeObject(ref objAction, ref returnData.DataOut);
            returnData.sResult = string.Empty;

            return(returnData);
        }
示例#6
0
        public IPlugInAPI.strMultiReturn ProcessPostUI([AllowNull] NameValueCollection postData,
                                                       IPlugInAPI.strTrigActInfo actionInfo)
        {
            var value = new IPlugInAPI.strMultiReturn
            {
                TrigActInfo = actionInfo
            };

            var config = new SendMessageActionConfig();

            if (postData != null && postData.HasKeys())
            {
                config.ToNumber = postData[0];
                config.Message  = postData[1];
                value.DataOut   = SendMessageActionConfig.SerializeActionConfig(config);
            }
            return(value);
        }
示例#7
0
        public override IPlugInAPI.strMultiReturn ActionProcessPostUI([AllowNull] NameValueCollection postData, IPlugInAPI.strTrigActInfo actionInfo)
        {
            LogDebug("Handling ActionProcessPostUI");
            var value = new IPlugInAPI.strMultiReturn();

            value.TrigActInfo = actionInfo;

            var config = new SendMessageActionConfig();

            if (postData != null && postData.HasKeys())
            {
                foreach (var key in postData.Keys)
                {
                    LogDebug(key + " has a value of " + postData[key.ToString()]);
                }

                LogDebug("Setting number to " + postData[0]);
                LogDebug("Setting message to " + postData[1]);
                config.ToNumber = postData[0];
                config.Message  = postData[1];
                value.DataOut   = SendMessageActionConfig.SerializeActionConfig(config);
            }
            return(value);
        }
示例#8
0
        public IPlugInAPI.strMultiReturn ProcessPostUI([AllowNull] NameValueCollection postData,
                                                       IPlugInAPI.strTrigActInfo actionInfo)
        {
            IPlugInAPI.strMultiReturn result = new IPlugInAPI.strMultiReturn();
            result.DataOut     = actionInfo.DataIn;
            result.TrigActInfo = actionInfo;
            result.sResult     = string.Empty;

            this.logger.LogDebug(string.Join("; ", postData.AllKeys));
            ReceiveMessageTriggerConfig config = new ReceiveMessageTriggerConfig();

            foreach (string key in postData.AllKeys)
            {
                if (key.StartsWith("AnyNumber", StringComparison.InvariantCulture))
                {
                    config.FromAnyNumber = postData[key] == "checked";
                }
                if (key.StartsWith("FromNumber", StringComparison.InvariantCulture))
                {
                    config.FromNumber = postData[key];
                }
                if (key.StartsWith("Message", StringComparison.InvariantCulture))
                {
                    config.Message = postData[key];
                }
            }

            if (config.FromAnyNumber)
            {
                config.FromNumber = string.Empty;
            }

            result.DataOut = ReceiveMessageTriggerConfig.SerializeTriggerConfig(config);

            return(result);
        }
示例#9
0
 public HomeSeerAPI.IPlugInAPI.strMultiReturn ActionProcessPostUI(System.Collections.Specialized.NameValueCollection PostData, HomeSeerAPI.IPlugInAPI.strTrigActInfo TrigInfoIN)
 {
     HomeSeerAPI.IPlugInAPI.strMultiReturn r = new IPlugInAPI.strMultiReturn();
     r.sResult = "NOT IMPLEMENTED";
     return(r);
 }
示例#10
0
 public HomeSeerAPI.IPlugInAPI.strMultiReturn TriggerProcessPostUI(System.Collections.Specialized.NameValueCollection PostData, HomeSeerAPI.IPlugInAPI.strTrigActInfo TrigInfoIN)
 {
     HomeSeerAPI.IPlugInAPI.strMultiReturn r = new IPlugInAPI.strMultiReturn();
     return(r);
 }