Exemplo n.º 1
0
        private async Task DeleteNode()
        {
            var    list   = new List <KeyValuePair <string, string> >();
            string res    = string.Empty;
            var    poster = new HttpDataPostSender();

            switch (_tmpActiveDataGrid.Name)
            {
            case "dgSensorRules":

                list.Add(new KeyValuePair <string, string>("id", dgSensorRules.SelectedRows[0].Cells["colPrID"].Value.ToString()));
                res = await poster.SendHttpPost(HttpApiRes.DeleteProblem, list, HttpApiRes.Host, HttpApiRes.Port);

                break;

            case "dgReason":
                list.Add(new KeyValuePair <string, string>("id", dgReason.SelectedRows[0].Cells["colReasID"].Value.ToString()));
                res = await poster.SendHttpPost(HttpApiRes.DeleteReason, list, HttpApiRes.Host, HttpApiRes.Port);

                break;

            case "dgSolution":
                list.Add(new KeyValuePair <string, string>("id", dgSolution.SelectedRows[0].Cells["colSolID"].Value.ToString()));
                res = await poster.SendHttpPost(HttpApiRes.DeleteSolution, list, HttpApiRes.Host, HttpApiRes.Port);

                break;
            }

            if (res == "200")
            {
                MessageBox.Show("Удалено");
            }
            else
            {
                MessageBox.Show($"Государь! Сервер пал... {res}");
            }
        }
Exemplo n.º 2
0
        private async Task SaveData(DialogueEventArgs args)
        {
            var    list   = new List <KeyValuePair <string, string> >();
            string res    = string.Empty;
            var    poster = new HttpDataPostSender();

            switch (_tmpActiveDataGrid.Name)
            {
            case "dgSensorRules":
                if (_selectedId > 0)
                {
                    list.Add(new KeyValuePair <string, string>("pr_id", _selectedId.ToString()));
                }
                list.Add(new KeyValuePair <string, string>("pr_cond", args.GetValue("tbCondition")));
                list.Add(new KeyValuePair <string, string>("pr_value", args.GetValue("tbValue")));
                list.Add(new KeyValuePair <string, string>("sens_id", args.GetValue("tbSensId")));
                list.Add(new KeyValuePair <string, string>("pr_text", args.GetValue("tbProblem")));
                list.Add(new KeyValuePair <string, string>("pr_bound_value", args.GetValue("tbBoundValue")));
                list.Add(new KeyValuePair <string, string>("pr_color", "r"));
                list.Add(new KeyValuePair <string, string>("pr_nn", args.GetValue("tbNumber")));
                list.Add(new KeyValuePair <string, string>("ap_id", ((ApparatusModel)treeObjects.SelectedNode.Tag).ap_id.ToString()));
                res = await poster.SendHttpPost(HttpApiRes.RulesPost, list, HttpApiRes.Host, HttpApiRes.Port);

                break;

            case "dgReason":
                if (_selectedId > 0)
                {
                    list.Add(new KeyValuePair <string, string>("rs_id", _selectedId.ToString()));
                }
                list.Add(new KeyValuePair <string, string>("pr_id", dgSensorRules.SelectedRows[0].Cells["colPrID"].Value.ToString()));
                list.Add(new KeyValuePair <string, string>("rs_text", args.GetValue("tbReason")));
                list.Add(new KeyValuePair <string, string>("rs_cond", args.GetValue("tbReasRule")));
                list.Add(new KeyValuePair <string, string>("rs_value", args.GetValue("tbReasValue")));
                list.Add(new KeyValuePair <string, string>("sens_id", args.GetValue("tbSensor")));
                list.Add(new KeyValuePair <string, string>("nn_rs", args.GetValue("tbReasNumber")));
                list.Add(new KeyValuePair <string, string>("rs_probability", args.GetValue("tbProb")));
                res = await poster.SendHttpPost(HttpApiRes.ReasonPost, list, HttpApiRes.Host, HttpApiRes.Port);

                break;

            case "dgSolution":
                if (_selectedId > 0)
                {
                    list.Add(new KeyValuePair <string, string>("sol_id", _selectedId.ToString()));
                }
                list.Add(new KeyValuePair <string, string>("rs_id", dgReason.SelectedRows[0].Cells["colReasID"].Value.ToString()));
                list.Add(new KeyValuePair <string, string>("sol_text", args.GetValue("tbSolution")));
                list.Add(new KeyValuePair <string, string>("sol_par", args.GetValue("tbParam")));
                list.Add(new KeyValuePair <string, string>("sens_id", args.GetValue("tbSolSensID")));
                list.Add(new KeyValuePair <string, string>("sol_nn", args.GetValue("tbSolNumber")));
                res = await poster.SendHttpPost(HttpApiRes.SolutionPost, list, HttpApiRes.Host, HttpApiRes.Port);

                break;
            }

            if (res == "200")
            {
                MessageBox.Show("Успешно");
            }
            else
            {
                MessageBox.Show($"Государь! Сервер пал... {res}");
            }
        }