Exemple #1
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtDecrypted.Text) && !string.IsNullOrEmpty(txtKeypass.Text))
            {
                if(txtKeypass.Text.Length < 12)
                {
                    MessageBox.Show("Độ dài keypass tối thiểu là 12 kí tự", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var keypass = chkDLL.Checked ? SecurityModel.Keypass : txtKeypass.Text;
                txtEncrypted.Text = CryptoProvider.SimpleEncryptWithPassword(txtDecrypted.Text, keypass);
            }
        }
Exemple #2
0
        public ActionResult Update(tblFtpAccount obj, int page = 1, string group = "", string key = "")
        {
            //
            ViewBag.PN         = page;
            ViewBag.groupValue = group;
            ViewBag.keyValue   = key;

            //Kiểm tra
            var oldObj = _tblFtpAccountService.GetById(obj.Id);

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

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

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

            oldObj.FtpHost = obj.FtpHost;
            oldObj.FtpPass = obj.FtpPass;
            oldObj.FtpUser = obj.FtpUser;
            oldObj.FtpPass = CryptoProvider.SimpleEncryptWithPassword(obj.FtpPass, SecurityModel.Session_Key);
            //oldObj.SortOrder = obj.SortOrder;

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id, obj.FtpHost, "tblFtpAccount", ConstField.ParkingCode, ActionConfigO.Update);

                return(RedirectToAction("Index", new { group = group, key = key, page = page, selectedId = obj.Id }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
Exemple #3
0
        public ActionResult Create(tblFtpAccount obj, bool SaveAndCountinue = false, string group = "", string key = "")
        {
            ViewBag.groupValue = group;
            ViewBag.keyValue   = key;

            //Kiểm tra
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }

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

            //Gán giá trị
            obj.Id      = Common.GenerateId();
            obj.FtpPass = CryptoProvider.SimpleEncryptWithPassword(obj.FtpPass, SecurityModel.Session_Key);

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id, obj.FtpHost, "tblFtpAccount", ConstField.ParkingCode, ActionConfigO.Create);

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

                return(RedirectToAction("Index", new { group = group, key = key, selectedId = obj.Id }));
            }
            else
            {
                return(View(obj));
            }
        }