Exemplo n.º 1
0
        public ActionResult Save(int?id)
        {
            var obj = new DeviceAuthorize()
            {
                Source = 1, EffectiveDT = System.DateTime.Now.ToString("yyyy-MM-dd")
            };
            var devices = new List <SelectListItem>();

            if (id.HasValue)
            {
                obj = DeviceAuthorService.GetOne(id.Value);
                devices.Add(new SelectListItem()
                {
                    Value = obj.DeviceId, Text = obj.DeviceName
                });
                var dev = DevicesService.GetOneByuid(obj.DeviceId);
                if (dev != null)
                {
                    ViewBag.Category = dev.CategoryId;
                    ViewBag.Brand    = dev.Brand;
                    ViewBag.Spec     = dev.Spec;
                }
            }
            var list = DevicesService.GetList();

            ViewBag.list    = list.ToJson();
            ViewBag.devices = devices;
            ViewBag.users   = ListToSelect(UserService.GetList(false).Select(o => new SelectListItem()
            {
                Text = o.FullName, Value = o.UserId
            }), emptyTitle: "请选择");
            return(View(obj.IsNullThrow()));
        }
Exemplo n.º 2
0
        private void btn_Device_Authrize_Edit_Click(object sender, EventArgs e)
        {
            if (this.DeviceInfoGrid.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择设备!");
                return;
            }

            if (this.DeviceInfoGrid.SelectedRows[0].Cells[2].Value.ToString() != "门禁控制板")
            {
                MessageBox.Show("该设备类型无法配置权限!");
                return;
            }



            string positiontype = (new DAL.DAL_Position()).GetPositionType(this.DeviceInfoGrid.SelectedRows[0].Cells["DevicePosition"].Value.ToString());

            if (positiontype == "1")
            {
                DeviceAuthorize deviceauthorizeform = new DeviceAuthorize(this.DeviceInfoGrid.SelectedRows[0].Cells[0].Value.ToString());

                if (deviceauthorizeform.ShowDialog() == DialogResult.OK)
                {
                }
            }

            if (positiontype == "2")
            {
                DeviceVehicleAuthorize deviceauthorizeform = new DeviceVehicleAuthorize(this.DeviceInfoGrid.SelectedRows[0].Cells[0].Value.ToString());
                if (deviceauthorizeform.ShowDialog() == DialogResult.OK)
                {
                }
            }
        }
Exemplo n.º 3
0
        public OpResult SaveOrUpdate(DeviceAuthorize obj, string category, string brand, string spec)
        {
            //if (!TraderRepository.GetQuery(o => o.CID == obj.CID).Any())
            //return OpResult.Fail("商户不存在!");
            if (category.IsNullOrEmpty() || brand.IsNullOrEmpty() || spec.IsNullOrEmpty())
            {
                return(OpResult.Fail("设备分类等信息选择不完整!"));
            }
            var cate   = short.Parse(category);
            var device = DevicesRepository.Find(o => o.CategoryId == cate && o.Brand == brand && o.Spec == spec);

            if (device == null)
            {
                return(OpResult.Fail("设备分类不存在,请重新选择!"));
            }
            obj.DeviceId = device.DeviceId;
            if (DeviceAuthorRepository.GetQuery(o => o.DeviceId == obj.DeviceId && o.DeviceNo == obj.DeviceNo && o.Status != 2 && o.Id != obj.Id).Any())
            {
                return(OpResult.Fail("同设备和编码下不允许重复添加!"));
            }
            if (obj.Id == 0)
            {
                obj.CreateDT     = DateTime.Now;
                obj.CreateUID    = CurrentUser.UID;
                obj.ExpirationDT = DateTime.Parse(obj.EffectiveDT).AddMonths(obj.ValidityNum.GetValueOrDefault()).ToString("yyyy-MM-dd");
                DeviceAuthorRepository.Add(obj);
            }
            else
            {
                var res = DeviceAuthorRepository.Get(obj.Id);
                obj.ToCopyProperty(res, new List <string>()
                {
                    "CreateDT", "CreateUID", "CID", "MachineSN", "SerialNo"
                });
                res.ExpirationDT = DateTime.Parse(obj.EffectiveDT).AddMonths(obj.ValidityNum.GetValueOrDefault()).ToString("yyyy-MM-dd");
                DeviceAuthorRepository.SaveChanges();
            }
            return(OpResult.Success());
        }
Exemplo n.º 4
0
        public ActionResult Save(DeviceAuthorize obj)
        {
            var op = DeviceAuthorService.SaveOrUpdate(obj, Request["Category"], Request["Brand"], Request["Spec"]);

            return(new OpActionResult(op));
        }