Esempio n. 1
0
        public JsonResult Delete(string id)
        {
            var obj = new tblCamera();

            //var listLand = _PK_LaneService.GetAllByCamera(id);
            //if (listLand.Any())
            //{
            //    var message = new Result();

            //    message.Success = false;
            //    message.Message = "Đang sử dụng trong làn vào ra. Không thể xóa";
            //    message.ErrorCode = 500;

            //    return Json(message, JsonRequestBehavior.AllowGet);
            //}

            var result = _tblCameraService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CameraID.ToString(), obj.CameraName, "tblCamera", ConstField.ParkingCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public MessageReport DeleteById(string id, ref tblCamera obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(Guid.Parse(id));
                if (obj != null)
                {
                    _tblCameraRepository.Delete(n => n.CameraID.ToString() == id);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
        public MessageReport Create(tblCamera obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                _tblCameraRepository.Add(obj);

                Save();

                re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["addSuccess"];
                re.isSuccess = true;
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
Esempio n. 4
0
        public ActionResult Create(tblCamera obj, string key, string pc, string group = "", bool SaveAndCountinue = false)
        {
            //
            ViewBag.PCs = GetPCList();

            //
            ViewBag.CameraType = FunctionHelper.CameraTypes1();
            ViewBag.StreamType = FunctionHelper.StreamTypes1();
            ViewBag.SDK        = FunctionHelper.SDKs1();

            //
            ViewBag.keyValue   = key;
            ViewBag.pcValue    = pc;
            ViewBag.groupValue = group;

            //
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }

            //
            if (string.IsNullOrWhiteSpace(obj.CameraName))
            {
                ModelState.AddModelError("CameraName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Camera_Name"]);
                return(View(obj));
            }

            //
            var existed = _tblCameraService.GetByName(obj.CameraName);

            if (existed != null)
            {
                ModelState.AddModelError("CameraName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Camera_already_exists"]);
                return(View(obj));
            }

            //
            obj.CameraID  = Guid.NewGuid();
            obj.Cgi       = FunctionHelper.GetCgiByCameraType(obj.CameraType, Convert.ToString(obj.FrameRate), obj.Resolution, obj.SDK, obj.UserName, obj.Password);
            obj.Password  = !string.IsNullOrWhiteSpace(obj.Password) ? CryptorEngine.Encrypt(obj.Password, true) : CryptorEngine.Encrypt("", true);
            obj.SortOrder = 0;

            //Thực hiện thêm mới
            var result = _tblCameraService.Create(obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CameraID.ToString(), obj.CameraName, "tblCamera", ConstField.ParkingCode, ActionConfigO.Create);

                if (SaveAndCountinue)
                {
                    TempData["Success"] = result.Message;
                    return(RedirectToAction("Create", new { group = group, key = key, pc = pc, selectedId = obj.CameraID }));
                }

                return(RedirectToAction("Index", new { group = group, key = key, pc = pc, selectedId = obj.CameraID }));
            }
            else
            {
                return(View(obj));
            }
        }
Esempio n. 5
0
        public ActionResult Update(tblCamera obj, int page = 1, string key = "", string pc = "", string group = "")
        {
            ViewBag.PCs = GetPCList();

            ViewBag.CameraType = FunctionHelper.CameraTypes1();
            ViewBag.StreamType = FunctionHelper.StreamTypes1();
            ViewBag.SDK        = FunctionHelper.SDKs1();

            ViewBag.keyValue   = key;
            ViewBag.pcValue    = pc;
            ViewBag.PN         = page;
            ViewBag.groupValue = group;

            //Kiểm tra
            var oldObj = _tblCameraService.GetById(obj.CameraID);

            if (oldObj == null)
            {
                ViewBag.Error = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                return(View(obj));
            }

            //
            if (string.IsNullOrWhiteSpace(obj.CameraName))
            {
                ModelState.AddModelError("CameraName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Camera_Name"]);
                return(View(oldObj));
            }

            //
            var existed = _tblCameraService.GetByName_Id(obj.CameraName, obj.CameraID);

            if (existed != null)
            {
                ModelState.AddModelError("CameraName", FunctionHelper.GetLocalizeDictionary("Home", "notification")["Camera_already_exists"]);
                return(View(oldObj));
            }

            if (!ModelState.IsValid)
            {
                return(View(oldObj));
            }

            oldObj.CameraCode      = obj.CameraCode;
            oldObj.CameraName      = obj.CameraName;
            oldObj.CameraType      = obj.CameraType;
            oldObj.Channel         = obj.Channel;
            oldObj.EnableRecording = obj.EnableRecording;
            oldObj.FrameRate       = obj.FrameRate;
            oldObj.HttpPort        = obj.HttpPort;
            oldObj.HttpURL         = obj.HttpURL;
            oldObj.Inactive        = obj.Inactive;
            oldObj.Password        = "";
            oldObj.PCID            = obj.PCID;
            oldObj.PositionIndex   = obj.PositionIndex;
            oldObj.Resolution      = obj.Resolution;
            oldObj.RtspPort        = obj.RtspPort;
            oldObj.SDK             = obj.SDK;
            //oldObj.SortOrder = obj.SortOrder;
            oldObj.StreamType = obj.StreamType;
            oldObj.UserName   = obj.UserName;

            oldObj.Cgi      = FunctionHelper.GetCgiByCameraType(obj.CameraType, Convert.ToString(obj.FrameRate), obj.Resolution, obj.SDK, obj.UserName, obj.Password);
            oldObj.Password = !string.IsNullOrWhiteSpace(obj.Password) ? CryptorEngine.Encrypt(obj.Password, true) : CryptorEngine.Encrypt("", true);

            //Thực hiện cập nhật
            var result = _tblCameraService.Update(oldObj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CameraID.ToString(), obj.CameraName, "tblCamera", ConstField.ParkingCode, ActionConfigO.Update);

                return(RedirectToAction("Index", new { group = group, page = page, key = key, pc = pc, selectedId = obj.CameraID }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }