Beispiel #1
0
        ProtocolResponse IProcessMessageStrategy.Process(ProtocolRequest request)
        {
            ProtocolResponse response = new ProtocolResponse(request.Action);

            if (Connection == null || !Connection.IsConnected)
            {
                Logger.Log("Connection to Redis Closed - Attempting to reopen...");
                try
                {
                    Connection = ConnectionMultiplexer.Connect(Config.RedisDBConnect);
                }
                catch (Exception ex)
                {
                    Logger.Log("Error connecting to Redis - lost connection (" + ex.Message + ")");
                    response.Error = "Error connecting to Redis - lost connection (" + ex.Message + ")";
                    return(response);
                }
            }

            if (!Config.RedisActionKeys.ContainsKey(request.Action))
            {
                Logger.Log("Error - Invalid Redis Action '" + request.Action + "' received from client");
                response.Error = "Error executing query against Redis - Action: '" + request.Action + "' not found in server configuration - please check action message or server configuration.";
                return(response);
            }

            RedisAction ra = Config.RedisActionKeys[request.Action];

            // parse out all lua nulls and convert to real nulls
            request.Data = Utility.ParseLuaNullsFromString(request.Data);

            try
            {
                IDatabase db = Connection.GetDatabase();
                RedisUtility.PerformOperation(ra.Action, request.IsBulkQuery, ref db, ref Logger, Config.RedisEnvironmentKey, ra.Key, request.Data);
                response.Result = true;
                response.Data   = new List <List <object> >();
            }
            catch (Exception ex)
            {
                CatchException(ref ex, ref request, ref response);
            }

            return(response);
        }
Beispiel #2
0
        private void ok_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.triggerCtl.RuleName))
                {
                    MyMessageBox.ShowMessage("警告", "名称不能为空.");
                    return;
                }
                if (string.IsNullOrEmpty(this.triggerCtl.KPI))
                {
                    MyMessageBox.ShowMessage("警告", "指标不能为空.");
                    return;
                }
                if (15 >= this.triggerCtl.Interval)
                {
                    MyMessageBox.ShowMessage("警告", "轮询间隔不能为小于15秒。");
                    return;
                }
                var trigger = this.triggerCtl.GetTrigger();
                var id      = trigger.SaveIt();
                var actions = trigger.Children <RedisAction>(null);
                if (null == actions || 0 == actions.Count)
                {
                    var action = new RedisAction();
                    action["name"]    = trigger.Name + "-" + "redis";
                    action["command"] = "SET";
                    action["arg0"]    = trigger["trigger"] + ":" + trigger["parent_id"];
                    action.CreateIt();
                }


                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MyMessageBox.ShowMessage("错误", "保存任务失败!", ex.ToString());
            }
        }