public ActionResult XuLyLuu(Models.HostModel.Input.Them input)
        {
            // TempData["returnUrl"] = Url.Action("Index", "ThoiTietNongVu", new { Areas = "LVKhuyenNong" });
            // var kiemTra = Helpers.XuLyPhanQuyen.KiemTraQuyenTruyCap(ChucNang.Ma.QuanLyThongBaoKhan, QuyenHan.Ma.Them);
            // ViewBag.KetQua = kiemTra.KetQua;
            //if (kiemTra.KetQua < 0) return PartialView("_ThemCapNhatPartial", new CommonBieuMauInAn.BieuMauInAnOutput.ThongTin());
            //if (Session["UserInfo"] == null) return Redirect(ChucNang.DuongDan.DangNhap);
            var model = new CommonModel.CommonOutput();

            var input2 = new ThongBaoKhan.Models.ThongBaoKhanModel.Input.ThongTin2();

            try
            {
                //input2.Id = input.Id;
                //input2.Ten = input.Ten;
                //input2.TenVietTat = input.TenVietTat;


                //input2.Ma = string.IsNullOrEmpty(input.Ma) ? "" : input.Ma.Replace(" ", "");

                //input2.ThuTu = input.ThuTu;

                //input2.GhiChu = input.GhiChu;
                //var input = new ThoiTietNongVuInput2();
                //input2.HinhDaiDien = input.HinhDaiDien;
                //input2.DuongDanThanThien = input.DuongDanThanThien;
                //input2.TieuDe = input.TieuDe;
                //input2.NoiDungTomTat = input.NoiDungTomTat;
                //input2.NoiDung = input.NoiDung;
                //input2.TrangThai = 0;
                //if (input.TrangThai) input2.TrangThai = 1;
                //input2.DoUuTien = 0;
                //if (input.DoUuTien) input2.DoUuTien = 1;
                dynamic param = new ExpandoObject();
                param.host           = input.host;
                param.inventory_mode = 0;
                param.interfaces     = new List <ExpandoObject>();
                foreach (var item in input.interfaces)
                {
                    dynamic inf = new ExpandoObject();
                    inf.type  = Convert.ToInt32(item.type);
                    inf.main  = 1;
                    inf.useip = item.useip;
                    inf.ip    = string.IsNullOrEmpty(item.ip) ? "" : item.ip;
                    inf.dns   = string.IsNullOrEmpty(item.dns) ? "" : item.dns;
                    inf.port  = item.port;
                    param.interfaces.Add(inf);
                }
                param.groups = new List <ExpandoObject>();
                foreach (var item in input.groups)
                {
                    dynamic inf = new ExpandoObject();
                    inf.groupid = item.groupid;

                    param.groups.Add(inf);
                }
                //param.output = "extend";
                //// param.filter = new ExpandoObject();
                ////param.filter.name = new string[] { "Zabbix server" };
                //var p = new
                //{
                //    output = "extend",
                //    filter = new
                //    {
                //        name = new string[] { "Zabbix server" }
                //    }
                //};
                //param.filter.name.Add("Zabbix servers");
                //param.templateids = "extend";
                //input.macros = new List<Models.HostModel.Input.Macro>();
                //input.inventory = new Models.HostModel.Input.Inventory();
                //input.tags = new List<Models.HostModel.Input.Tag>();
                //input.templates = new List<Models.HostModel.Input.Template>();
                //input.inventory_mode = 1;
                input.interfaces.FirstOrDefault().dns = "";
                //param.host = "abcd";
                var output = XuLyAPI.ApiJsonZabbix(APIUrl.Zabbix.Host.Them, param) as Response;
                ViewBag.KetQua = 0;
                model.KetQua   = 1;
                model.ThongBao = ConstantValues.Message.ThanhCong;
            }
            catch (Exception ex)
            {
                ViewBag.KetQua = 0;
                model.KetQua   = 0;
                model.ThongBao = ConstantValues.Message.ThatBai;
                model.DuLieu   = ex.Message;
            }
            return(Json(model));
        }
        public ActionResult XuLyLuu(Models.ThongBaoKhanModel.Input.ThongTin input)
        {
            TempData["returnUrl"] = Url.Action("Index", "ThoiTietNongVu", new { Areas = "LVKhuyenNong" });
            var kiemTra = Helpers.XuLyPhanQuyen.KiemTraQuyenTruyCap(ChucNang.Ma.QuanLyThongBaoKhan, QuyenHan.Ma.Them);

            ViewBag.KetQua = kiemTra.KetQua;
            //if (kiemTra.KetQua < 0) return PartialView("_ThemCapNhatPartial", new CommonBieuMauInAn.BieuMauInAnOutput.ThongTin());
            //if (Session["UserInfo"] == null) return Redirect(ChucNang.DuongDan.DangNhap);
            var model  = new CommonOutput();
            var input2 = new ThongBaoKhan.Models.ThongBaoKhanModel.Input.ThongTin2();

            try
            {
                input2.Id = input.Id;
                //input2.Ten = input.Ten;
                //input2.TenVietTat = input.TenVietTat;


                //input2.Ma = string.IsNullOrEmpty(input.Ma) ? "" : input.Ma.Replace(" ", "");

                //input2.ThuTu = input.ThuTu;

                //input2.GhiChu = input.GhiChu;
                //var input = new ThoiTietNongVuInput2();
                input2.HinhDaiDien       = input.HinhDaiDien;
                input2.DuongDanThanThien = input.DuongDanThanThien;
                input2.TieuDe            = input.TieuDe;
                input2.NoiDungTomTat     = input.NoiDungTomTat;
                input2.NoiDung           = input.NoiDung;
                input2.TrangThai         = 0;
                if (input.TrangThai)
                {
                    input2.TrangThai = 1;
                }
                input2.DoUuTien = 0;
                if (input.DoUuTien)
                {
                    input2.DoUuTien = 1;
                }
                var url    = !string.IsNullOrEmpty(input.Id) ? APIUrl.ThongBaoKhan.Sua : APIUrl.ThongBaoKhan.Them;
                var output = XuLyAPI.ApiJsonPost(url, input2) as CommonOutput;
                if (output == null)
                {
                    throw new Exception(ConstantValues.Message.LoiServer);
                }
                if (output.KetQua == 1)
                {
                    if (input.DoUuTien)
                    {
                        GuiThongBao(input2, output);
                    }
                    model.KetQua   = 1;
                    model.ThongBao = ConstantValues.Message.ThanhCong;
                    ViewBag.KetQua = 1;
                    return(PartialView("_ThemCapNhatPartial", new Models.ThongBaoKhanModel.Input.ThongTin()));
                }
                else
                {
                    ViewBag.KetQua = 0;
                    return(PartialView("_ThemCapNhatPartial", input));
                }
            }
            catch (Exception ex)
            {
                ViewBag.KetQua = 0;
                model.KetQua   = 0;
                model.ThongBao = ConstantValues.Message.ThatBai;
                return(PartialView("_ThemCapNhatPartial", input));
            }
        }