Encrypt() public static method

public static Encrypt ( string ToEncrypt, bool useHasing ) : string
ToEncrypt string
useHasing bool
return string
コード例 #1
0
        public JsonResult CheckLogin(LoginModel model)
        {
            var unitofwork = new UnitOfWork(new ELearningDBContext());
            var account    = unitofwork.Account.ValidBEAccount(model.Username, model.Password);

            if (account != null)
            {
                //đăng nhập thành công
                string     cookieclient       = account.Username;
                string     decodecookieclient = CryptorEngine.Encrypt(cookieclient, true);
                HttpCookie usercookie         = new HttpCookie("name_client")
                {
                    Value   = decodecookieclient,
                    Expires = DateTime.Now.AddDays(30)
                };
                HttpContext.Response.Cookies.Add(usercookie);
                return(Json(new { status = true, mess = "Đăng nhập thành công" }));
            }
            else
            {
                return(Json(new { status = false, mess = "Tên và mật khẩu không chính xác" }));
            }
        }
コード例 #2
0
        public User ValidFEAccount(string username, string password)
        {
            var db = ELearningDBContext;

            string passwordFactory = password + VariableExtensions.KeyCryptor;
            string passwordCryptor = CryptorEngine.Encrypt(passwordFactory, true);

            var account =
                db.Users.FirstOrDefault(
                    x => x.Username.ToLower() == username.ToLower() &&
                    x.Password == passwordCryptor &&
                    x.Status &&
                    x.RoleId == RoleKey.Student);

            if (account != null)
            {
                return(account);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        public int UpdateUser(UserUpdateModelRequest objUserUpdateModelRequest, Int64 UserId)
        {
            objUserUpdateModelRequest.Password = CryptorEngine.Encrypt(objUserUpdateModelRequest.Password, true);

            int rowEffected;

            if (objUserUpdateModelRequest.AutoSMSSignUp == null)
            {
                rowEffected = _objFriendFitDBEntity.Database.ExecuteSqlCommand("UpdateUser @UserId=@UserId,@FirstName=@FirstName,@LastName=@LastName,@Email=@Email,@Password=@Password,@MobileNumber=@MobileNumber,@CountryId=@CountryId,@AutoSMSSignUp=@AutoSMSSignUp,@FullWorkoutStatus=@FullWorkoutStatus,@WorkoutStatus=@WorkoutStatus",
                                                                               new SqlParameter("UserId", UserId),
                                                                               new SqlParameter("FirstName", objUserUpdateModelRequest.FirstName),
                                                                               new SqlParameter("LastName", objUserUpdateModelRequest.LastName),
                                                                               new SqlParameter("Email", objUserUpdateModelRequest.Email),
                                                                               new SqlParameter("Password", (Object)objUserUpdateModelRequest.Password ?? DBNull.Value),
                                                                               new SqlParameter("MobileNumber", objUserUpdateModelRequest.MobileNumber),
                                                                               new SqlParameter("CountryId", objUserUpdateModelRequest.CountryId),
                                                                               new SqlParameter("AutoSMSSignUp", false),
                                                                               new SqlParameter("FullWorkoutStatus", objUserUpdateModelRequest.FullWorkoutStatus),
                                                                               new SqlParameter("WorkoutStatus", objUserUpdateModelRequest.WorkoutStatus));
            }
            else
            {
                rowEffected = _objFriendFitDBEntity.Database.ExecuteSqlCommand("UpdateUser @UserId=@UserId,@FirstName=@FirstName,@LastName=@LastName,@Email=@Email,@Password=@Password,@MobileNumber=@MobileNumber,@CountryId=@CountryId,@AutoSMSSignUp=@AutoSMSSignUp,@FullWorkoutStatus=@FullWorkoutStatus,@WorkoutStatus=@WorkoutStatus",
                                                                               new SqlParameter("UserId", UserId),
                                                                               new SqlParameter("FirstName", objUserUpdateModelRequest.FirstName),
                                                                               new SqlParameter("LastName", objUserUpdateModelRequest.LastName),
                                                                               new SqlParameter("Email", objUserUpdateModelRequest.Email),
                                                                               new SqlParameter("Password", (Object)objUserUpdateModelRequest.Password ?? DBNull.Value),
                                                                               new SqlParameter("MobileNumber", objUserUpdateModelRequest.MobileNumber),
                                                                               new SqlParameter("CountryId", objUserUpdateModelRequest.CountryId),
                                                                               new SqlParameter("AutoSMSSignUp", objUserUpdateModelRequest.AutoSMSSignUp),
                                                                               new SqlParameter("FullWorkoutStatus", objUserUpdateModelRequest.FullWorkoutStatus),
                                                                               new SqlParameter("WorkoutStatus", objUserUpdateModelRequest.WorkoutStatus));
            }
            return(rowEffected);
        }
コード例 #4
0
 public virtual void WriteLine(string format, Object arg0, Object arg1, Object arg2)
 {
     try
     {
         if (doCryptor)
         {
             _originalStreamWriter.WriteLine(format,
                                             CryptorEngine.Encrypt(arg0, true, KeyGen.Generator(currentGui)),
                                             CryptorEngine.Encrypt(arg1, true, KeyGen.Generator(currentGui)),
                                             CryptorEngine.Encrypt(arg2, true, KeyGen.Generator(currentGui)));
         }
         else
         {
             _originalStreamWriter.WriteLine(format,
                                             arg0,
                                             arg1,
                                             arg2);
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #5
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        //String pass = CryptorEngine.Encrypt(TextBox3.Text, true);
        SqlConnection con = new SqlConnection(str);

        con.Open();
        SqlCommand cmd = new SqlCommand("select * from login where username=@1", con);

        cmd.Parameters.AddWithValue("@1", ss);
        SqlDataReader sdr = cmd.ExecuteReader();

        if (sdr.Read())
        {
            if (sdr.GetString(1).Equals(CryptorEngine.Encrypt(TextBox3.Text, true)) || sdr.GetString(1) == CryptorEngine.Encrypt(TextBox3.Text, true))
            {
                MultiView1.ActiveViewIndex = 0;
            }
            else
            {
                Response.Write("<script type='text/javascript'>alert('Password Not Matched');</script> ");
            }
        }
        con.Close();
    }
コード例 #6
0
        public ActionResult SaveJobs(ManageJobs objjobsdetails)
        {
            try
            {
                SaveJobInDatabase(objjobsdetails);
                if (objjobsdetails.jobiddecypt == 0)
                {
                    TempData["Message"] = "Job Created";
                }
                else
                {
                    TempData["Message"] = "Job Updated";
                }
            }
            catch (Exception ex)
            {
                TempData["Message"] = "Some error occured";
                cm.ErrorExceptionLogingByService(ex.ToString(), "WhiteBoards" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "WhiteBoardDetails", "NA", "NA", "NA", "WEB");
            }

            return(RedirectToAction("WhiteBoardDetails", new { @wbid = @cm.Code_Encrypt(CryptorEngine.Encrypt(objjobsdetails.WhiteboardID.ToString())) }));
            //   return RedirectToAction("Index");
        }
コード例 #7
0
 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     txtEncryp.Text = CryptorEngine.Encrypt(txtEncryp.Text);
 }
コード例 #8
0
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            ClientSideScript = MessageBoxText != string.Empty ? string.Format("messageBox('{0}','{1}','alert','{2}');", MessageBoxText, messageBoxTitle, messageBoxType) : string.Empty;
            ClientSideScript = closeModalResultValue != string.Empty ? string.Format("closeModal('{0}');", closeModalResultValue) : string.Empty;

            if (IsModal && !IsPostBack)
            {
                ClientSideScript = "parent.modalLoadCompleted(window);";
            }

            ClientSideScript = "if(parent.loadPageComplete) parent.loadPageComplete();";

            CryptorEngine encryptor = new CryptorEngine();

            if (Page.Request.Url.OriginalString.Contains("PageLoaderLight"))
            {
                ClientSideScript = string.Format("authenticationString = '{0}';validationString = '{1}';", encryptor.Encrypt(Helper.GetUrlWithoutPortNumber(Page.Request.UrlReferrer.OriginalString)), Helper.Encrypt(encryptor.GetObjectData() + "$" + Helper.GetUrlWithoutPortNumber(Page.Request.UrlReferrer.OriginalString), Session));
            }
            else
            {
                ClientSideScript = string.Format("authenticationString = '{0}';validationString = '{1}';", encryptor.Encrypt(Helper.GetUrlWithoutPortNumber(Page.Request.Url.OriginalString)), Helper.Encrypt(encryptor.GetObjectData() + "$" + Helper.GetUrlWithoutPortNumber(Page.Request.Url.OriginalString), Session));
            }

            if (ClientSideScript != string.Empty)
            {
                writer.WriteLine("<script type=\"text/javascript\">var authenticationString;var validationString;$(document).ready(function(){" + ClientSideScript + "});</script>");
            }
        }
コード例 #9
0
        public ActionResult Index(LoginModel model)
        {
            Random random;

            if (TempData["Count"] != null && int.Parse(TempData["Count"].ToString()) >= 5)
            {
                TempData.Keep("Count");
                if (string.IsNullOrEmpty(model.Captcha))
                {
                    ViewBag.ShowCaptcha = true;
                    ModelState.AddModelError("Captcha", "Vui lòng nhập captcha");
                }
                else
                {
                    if (model.Captcha != Session["Captcha"].ToString())
                    {
                        ViewBag.ShowCaptcha = true;
                        ModelState.AddModelError("Captcha", "Mã captcha không đúng");
                    }
                }
            }
            if (string.IsNullOrEmpty(model.LanguageID))
            {
                ModelState.AddModelError("LanguageID", "Vui lòng chọn ngôn ngữ");
            }
            if (ModelState.IsValid)
            {
                int checklogin = CheckLogin.CheckUserLogin(model.UserName, model.Password, model.LanguageID);
                switch (checklogin)
                {
                case 1:

                    //Đăng nhập thành công
                    string     cookieClient       = model.UserName + "||";
                    string     decodeCookieClient = CryptorEngine.Encrypt(cookieClient, true);
                    HttpCookie userCookie         = new HttpCookie("name_client");
                    userCookie.Value   = decodeCookieClient;
                    userCookie.Expires = DateTime.Now.AddDays(30);
                    HttpContext.Response.Cookies.Add(userCookie);

                    HttpCookie langCookie = new HttpCookie("lang_client");
                    langCookie.Value   = model.LanguageID;
                    langCookie.Expires = DateTime.Now.AddDays(30);
                    HttpContext.Response.Cookies.Add(langCookie);

                    TempData["Count"]    = 0;
                    TempData["Messages"] = "Đăng nhập thành công";
                    return(RedirectToAction("Index", "ControlPanel"));

                case 2:
                    TempData["Messages"] = "Tài khoản đã bị khóa";
                    return(RedirectToAction("Index"));

                case 3:
                    if (TempData["Count"] == null)
                    {
                        TempData["Count"] = 1;
                        TempData.Keep("Count");
                    }
                    else
                    {
                        TempData["Count"] = int.Parse(TempData["Count"].ToString()) + 1;
                        TempData.Keep("Count");
                    }
                    if (int.Parse(TempData["Count"].ToString()) >= 5)
                    {
                        random = new Random();
                        int iNumber = random.Next(10000, 99999);
                        Session["Captcha"] = iNumber.ToString();

                        ViewBag.ShowCaptcha = true;
                        ViewBag.Message     = CommentController.Messages(TempData["Message"]);
                        return(View());
                    }
                    ViewBag.ListLanguage = CommentController.ListLanguage().Select(a => new SelectListItem
                    {
                        Value = a.ID,
                        Text  = a.Name
                    }).ToList();
                    ViewBag.Messages = "Tên đăng nhập và mật khẩu không đúng";
                    return(View(model));
                }
            }
            return(View());
        }
コード例 #10
0
        public ActionResult Create(tblCustomer obj, HttpPostedFileBase FileUpload, bool SaveAndCountinue = false, string key = "", string customergroup = "", string customerstatus = "", string RePassword = "")
        {
            var DictionaryAction = FunctionHelper.GetLocalizeDictionary("Home", "notification");

            ViewBag.keyValue            = key;
            ViewBag.CustomerGroupValue  = customergroup;
            ViewBag.customerstatusValue = customerstatus;

            ViewBag.CustomerGroups = GetMenuList();
            var systemconfig = _tblSystemConfigService.GetDefault();

            ViewBag.IsCompartment = systemconfig != null ? systemconfig.isCompartment : true;
            //Kiểm tra
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }

            if (string.IsNullOrWhiteSpace(obj.CustomerName))
            {
                ModelState.AddModelError("CustomerName", DictionaryAction["enter_customer_name"]);
                return(View(obj));
            }

            if (string.IsNullOrWhiteSpace(obj.CustomerCode))
            {
                ModelState.AddModelError("CustomerCode", DictionaryAction["enter_customer_code"]);
                return(View(obj));
            }

            var existed = _tblCustomerService.GetByCode(obj.CustomerCode);

            if (existed != null)
            {
                ModelState.AddModelError("CustomerCode", DictionaryAction["Customer_code_already_exists"]);
                return(View(obj));
            }

            if (!string.IsNullOrWhiteSpace(obj.Password))
            {
                if (obj.Password != RePassword)
                {
                    ModelState.AddModelError("Password", DictionaryAction["correct_password"]);
                    return(View(obj));
                }

                obj.Password = CryptorEngine.Encrypt(obj.Password, true);
            }

            //Gán giá trị
            obj.CustomerID       = Guid.NewGuid();
            obj.AccessLevelID    = "";
            obj.Finger1          = "";
            obj.Finger2          = "";
            obj.DevPass          = "";
            obj.AccessExpireDate = Convert.ToDateTime("2099/12/31");
            obj.CompartmentId    = !string.IsNullOrEmpty(obj.CompartmentId) ? obj.CompartmentId.Trim() : "";
            if (FileUpload != null)
            {
                var extension = Path.GetExtension(FileUpload.FileName) ?? "";
                var fileName  = Path.GetFileName(string.Format("{0}{1}", StringUtil.RemoveSpecialCharactersVn(FileUpload.FileName.Replace(extension, "")).GetNormalizeString(), extension));

                var url = ConfigurationManager.AppSettings["FileUploadAvatar"];
                obj.Avatar = string.Format("{0}{1}", url, fileName);
            }

            if (!string.IsNullOrEmpty(obj.Address))
            {
                obj.AddressUnsign = StringUtil.RemoveSpecialCharactersVn(obj.Address.ToLower()).Replace("-", " ");
            }

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.ParkingCode, ActionConfigO.Create);

                UploadFile(FileUpload);

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

                return(RedirectToAction("Index", new { key = key, customergroup = customergroup, customerstatus = customerstatus, selectedId = obj.CustomerID }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(obj));
            }
        }
コード例 #11
0
        public JsonResult CreateOrEdit(Account input, bool isEdit, string oldPassword, string rePassword)
        {
            try
            {
                if (isEdit) //update
                {
                    using (var workScope = new UnitOfWork(new PatientManagementDbContext()))
                    {
                        var elm = workScope.Accounts.Get(input.Id);

                        if (elm != null) //update
                        {
                            //xu ly password
                            if (!string.IsNullOrEmpty(input.Password) || oldPassword != "")
                            {
                                if (oldPassword == "" || input.Password == "" || rePassword == "")
                                {
                                    return(Json(new { status = false, mess = "Không được để trống" }));
                                }
                                if (!CookiesManage.Logined())
                                {
                                    return(Json(new { status = false, mess = "Chưa đăng nhập" }));
                                }
                                if (input.Password != rePassword)
                                {
                                    return(Json(new { status = false, mess = "Mật khẩu không khớp" }));
                                }

                                var passwordFactory = input.Password + VariableExtensions.KeyCrypto;
                                var passwordCryptor = CryptorEngine.Encrypt(passwordFactory, true);
                                input.Password = passwordCryptor;
                            }
                            else
                            {
                                input.Password = elm.Password;
                            }

                            input.UserName = elm.UserName;

                            if (input.Role == RoleKey.Admin)
                            {
                                input.PatientId = null;
                                input.DoctorId  = null;
                            }
                            else if (input.Role == RoleKey.Doctor)
                            {
                                input.PatientId = null;
                            }
                            else if (input.Role == RoleKey.Patient)
                            {
                                input.DoctorId = null;
                            }
                            elm = input;

                            workScope.Accounts.Put(elm, elm.Id);
                            workScope.Complete();

                            if (input.UserName != GetCurrentUser().UserName)
                            {
                                return(Json(new { status = true, mess = "Cập nhập thành công " }));
                            }
                            //Đăng xuất
                            var nameCookie = Request.Cookies[CookiesKey.Client];
                            if (nameCookie != null)
                            {
                                var myCookie = new HttpCookie(CookiesKey.Client)
                                {
                                    Expires = DateTime.Now.AddDays(-1d)
                                };
                                Response.Cookies.Add(myCookie);
                            }

                            //Login luon
                            if (HttpContext.Request.Url != null)
                            {
                                var host = HttpContext.Request.Url.Authority;

                                var cookieClient       = elm.UserName + "|" + host.ToLower() + "|" + elm.Id;
                                var decodeCookieClient = CryptorEngine.Encrypt(cookieClient, true);
                                var userCookie         = new HttpCookie(CookiesKey.Client)
                                {
                                    Value   = decodeCookieClient,
                                    Expires = DateTime.Now.AddDays(30)
                                };
                                HttpContext.Response.Cookies.Add(userCookie);
                            }
                            else
                            {
                                return(Json(new { status = false, mess = "Lỗi" }));
                            }
                            return(Json(new { status = true, mess = "Cập nhập thành công " }));
                        }
                        else
                        {
                            return(Json(new { status = false, mess = "Không tồn tại " + KeyElement }));
                        }
                    }
                }
                else //Thêm mới
                {
                    using (var workScope = new UnitOfWork(new PatientManagementDbContext()))
                    {
                        if (input.Password != rePassword)
                        {
                            return(Json(new { status = false, mess = "Mật khẩu không khớp" }));
                        }

                        var elm = workScope.Accounts.Query(x => x.UserName.ToLower() == input.UserName.ToLower()).Any();
                        if (elm)
                        {
                            return(Json(new { status = false, mess = "Tên đăng nhập đã tồn tại" }));
                        }

                        var passwordFactory = input.Password + VariableExtensions.KeyCrypto;
                        var passwordCrypto  = CryptorEngine.Encrypt(passwordFactory, true);

                        input.Password = passwordCrypto;
                        input.Id       = Guid.NewGuid();

                        if (input.Role == RoleKey.Admin)
                        {
                            input.PatientId = null;
                            input.DoctorId  = null;
                        }
                        else if (input.Role == RoleKey.Doctor)
                        {
                            input.PatientId = null;
                        }
                        else if (input.Role == RoleKey.Patient)
                        {
                            input.DoctorId = null;
                        }
                        workScope.Accounts.Add(input);
                        workScope.Complete();
                    }
                    return(Json(new { status = true, mess = "Thêm thành công " + KeyElement }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    status = false,
                    mess = "Có lỗi xảy ra: " + ex.Message
                }));
            }
        }
コード例 #12
0
        public JsonResult Update(Account us, HttpPostedFileBase avataUpload)
        {
            if (!CookiesManage.Logined())
            {
                return(Json(new { status = false, mess = "Chưa đăng nhập" }));
            }
            var user = CookiesManage.GetUser();

            using (var workScope = new UnitOfWork(new PatientManagementDbContext()))
            {
                var account = workScope.Accounts.FirstOrDefault(x => x.UserName.ToLower() == user.UserName.ToLower());
                if (account != null)
                {
                    try
                    {
                        if (avataUpload?.FileName != null)
                        {
                            if (avataUpload.ContentLength >= FileKey.MaxLength)
                            {
                                return(Json(new { status = false, mess = L.T("FileMaxLength") }));
                            }
                            var splitFilename = avataUpload.FileName.Split('.');
                            if (splitFilename.Length > 1)
                            {
                                var fileExt = splitFilename[splitFilename.Length - 1];

                                //Check ext

                                if (FileKey.FileExtensionApprove().Any(x => x == fileExt))
                                {
                                    var slugName = StringHelper.ConvertToAlias(account.FullName);
                                    var fileName = slugName + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + fileExt;
                                    var path     = Path.Combine(Server.MapPath("~/FileUploads/images/avatas/"), fileName);
                                    avataUpload.SaveAs(path);
                                    us.LinkAvatar = "/FileUploads/images/avatas/" + fileName;
                                }
                                else
                                {
                                    return(Json(new { status = false, mess = L.T("FileExtensionReject") }));
                                }
                            }
                            else
                            {
                                return(Json(new { status = false, mess = L.T("FileExtensionReject") }));
                            }
                        }

                        us.Password = account.Password;
                        us.UserName = account.UserName;
                        us.Role     = RoleKey.Patient;
                        us.Id       = account.Id;

                        if (string.IsNullOrEmpty(us.LinkAvatar))
                        {
                            us.LinkAvatar = us.Gender ? "/Content/images/team/2.png" : "/Content/images/team/3.png";
                        }
                        account = us;
                        workScope.Accounts.Put(account, account.Id);
                        workScope.Complete();

                        //Đăng xuất
                        var nameCookie = Request.Cookies[CookiesKey.Client];
                        if (nameCookie != null)
                        {
                            var myCookie = new HttpCookie(CookiesKey.Client)
                            {
                                Expires = DateTime.Now.AddDays(-1d)
                            };
                            Response.Cookies.Add(myCookie);
                        }

                        //Login luon
                        if (HttpContext.Request.Url != null)
                        {
                            var host = HttpContext.Request.Url.Authority;

                            var cookieClient       = account.UserName + "|" + host.ToLower() + "|" + account.Id;
                            var decodeCookieClient = CryptorEngine.Encrypt(cookieClient, true);
                            var userCookie         = new HttpCookie(CookiesKey.Client)
                            {
                                Value   = decodeCookieClient,
                                Expires = DateTime.Now.AddDays(30)
                            };
                            HttpContext.Response.Cookies.Add(userCookie);
                            //RedirectToAction("Account", "Edit");
                            return(Json(new { status = true, mess = "Cập nhật thành công" }));
                        }
                        else
                        {
                            return(Json(new { status = false, mess = "Cập nhật K thành công" }));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { status = false, mess = "Cập nhật không thành công", ex }));
                    }
                }
                else
                {
                    return(Json(new { status = false, mess = "Tài khoản không khả dụng" }));
                }
            }
        }
コード例 #13
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));
            }
        }
コード例 #14
0
        public ActionResult Index(string Compid)

        {
            int  n;
            bool isNumeric = int.TryParse(Compid, out n);

            if (isNumeric == true)
            {
                Compid = cm.Code_Encrypt(CryptorEngine.Encrypt(Compid));
            }

            if (string.IsNullOrEmpty(Compid))
            {
                return(RedirectToAction("ProspectListsAdmin", "Index"));
            }
            CompContact objcomp = new CompContact();

            try
            {
                int CompidIddecrypt = Convert.ToInt32(CryptorEngine.Decrypt(cm.Code_Decrypt(Convert.ToString(Compid))));
                var data            = context.SPgetCompdetailsbycompid(CompidIddecrypt).FirstOrDefault();

                if (data != null)
                {
                    objcomp.name    = data.name;
                    objcomp.biztype = data.biztype;
                    objcomp.addr2   = data.addr2;
                    objcomp.addr1   = data.addr1;
                    objcomp.weburl  = data.weburl;
                    if (data.weburl != "" && data.weburl != null)
                    {
                        if (!data.weburl.Contains("http://") || !data.weburl.Contains("https://"))
                        {
                            objcomp.weburl = "http://" + data.weburl;
                        }
                    }
                    objcomp.city  = data.city;
                    objcomp.state = data.state;
                    objcomp.zip   = data.zip;
                    if (data.target == null)
                    {
                        objcomp.target = false;
                    }
                    else
                    {
                        objcomp.target = Convert.ToBoolean(data.target);
                    }
                    if (data.priority == null)
                    {
                        objcomp.priority = false;
                    }
                    else
                    {
                        objcomp.priority = Convert.ToBoolean(data.priority);
                    }
                    objcomp.phone      = data.phone;
                    objcomp.citycircle = data.citycircle;
                    objcomp.listid     = data.listid;
                    objcomp.companyid  = CompidIddecrypt;
                    var CompContacts = context.SpGetContactlistbyCompid(CompidIddecrypt, objcomp.listid).ToList();
                    if (CompContacts != null)
                    {
                        foreach (var i in CompContacts)
                        {
                            ContactDetails objcondetails = new ContactDetails();
                            objcondetails.contactid          = i.contactid;
                            objcondetails.companyid          = i.companyid;
                            objcondetails.contactfullname    = i.contactfullname;
                            objcondetails.titlestandard      = i.titlestandard;
                            objcondetails.contactphone       = i.contactphone;
                            objcondetails.contactcellphone   = i.contactcellphone;
                            objcondetails.contactemail       = i.contactemail;
                            objcondetails.listid             = i.listid;
                            objcondetails.linkedinprofileurl = i.linkedinprofileurl;
                            objcondetails.combinednotes      = i.combinednotes;
                            objcondetails.contactemail       = i.contactemail;
                            objcomp.objcontacts.Add(objcondetails);
                        }
                    }
                }

                var Complst = context.SPgetCompanies(objcomp.listid).ToList().Select(xx => new SelectListItem {
                    Value = xx.companyid.ToString(), Text = xx.name + " - Business Type : " + xx.biztype
                }).ToList();
                ViewData["Complst"] = Complst;
                if (TempData["ConEmail"] != null)
                {
                    ViewBag.ConEmail = TempData["ConEmail"];
                }
            }
            catch (Exception ex)
            {
                cm.ErrorExceptionLogingByService(ex.ToString(), "ProspectViewCompany" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "Index", "NA", "NA", "NA", "WEB");
            }
            return(View(objcomp));
        }
コード例 #15
0
        public JsonResult UpdatePass(string OldPassword, string NewPassword, string RePassword)
        {
            if (OldPassword == "" || NewPassword == "" || RePassword == "")
            {
                return(Json(new { status = false, mess = "Không được để trống" }));
            }
            if (!CookiesManage.Logined())
            {
                return(Json(new { status = false, mess = "Chưa đăng nhập" }));
            }
            if (NewPassword != RePassword)
            {
                return(Json(new { status = false, mess = "Mật khẩu không khớp" }));
            }
            var user = CookiesManage.GetUser();

            using (var unitofwork = new UnitOfWork(new ELearningDBContext()))
            {
                var account = unitofwork.Account.FirstOrDefault(x => x.Username.ToLower() == user.Username.ToLower());
                if (account != null)
                {
                    try
                    {
                        string passwordFactory = OldPassword + VariableExtensions.KeyCryptor;
                        string passwordCryptor = CryptorEngine.Encrypt(passwordFactory, true);

                        if (passwordCryptor == account.Password)
                        {
                            passwordFactory = "";
                            passwordCryptor = "";

                            passwordFactory = NewPassword + VariableExtensions.KeyCryptor;
                            passwordCryptor = CryptorEngine.Encrypt(passwordFactory, true);

                            account.Password = passwordCryptor;
                            unitofwork.Account.Put(account, account.Username);
                            unitofwork.Complete();

                            //Đăng xuất
                            var nameCookie = Request.Cookies["name_student"];
                            if (nameCookie != null)
                            {
                                var myCookie = new HttpCookie("name_student")
                                {
                                    Expires = DateTime.Now.AddDays(-1d)
                                };
                                Response.Cookies.Add(myCookie);
                            }

                            //Login luon
                            var cookieClient       = account.Username;
                            var decodeCookieClient = CryptorEngine.Encrypt(cookieClient, true);

                            var userCookie = new HttpCookie("name_student")
                            {
                                Value   = decodeCookieClient,
                                Expires = DateTime.Now.AddDays(30)
                            };
                            HttpContext.Response.Cookies.Add(userCookie);

                            return(Json(new { status = true, mess = "Cập nhật thành công" }));
                        }
                        else
                        {
                            return(Json(new { status = false, mess = "mật khẩu cũ không đúng" }));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { status = false, mess = "Cập nhật không thành công", ex }));
                    }
                }
                else
                {
                    return(Json(new { status = false, mess = "Tài khoản không khả dụng" }));
                }
            }
        }
コード例 #16
0
        public JsonResult Update(User us, HttpPostedFileBase avatarUpload)
        {
            if (!CookiesManage.Logined())
            {
                return(Json(new { status = false, mess = "Chưa đăng nhập" }));
            }
            var user = CookiesManage.GetUser();

            using (var unitofwork = new UnitOfWork(new ELearningDBContext()))
            {
                var account = unitofwork.Account.FirstOrDefault(x => x.Username.ToLower() == user.Username.ToLower());
                if (account != null)
                {
                    try
                    {
                        if (avatarUpload != null && avatarUpload.FileName != null)
                        {
                            if (avatarUpload.ContentLength >= FileKey.MaxLength)
                            {
                                return(Json(new { status = false, mess = L.T("FileMaxLength") }));
                            }
                            var splitFilename = avatarUpload.FileName.Split('.');
                            if (splitFilename.Length > 1)
                            {
                                var fileExt = splitFilename[splitFilename.Length - 1];

                                //Check ext

                                if (FileKey.FileExtensionApprove().Any(x => x == fileExt))
                                {
                                    string slugName = StringHelper.ConvertToAlias(account.FullName);
                                    string fileName = slugName + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + fileExt;
                                    var    path     = Path.Combine(Server.MapPath("~/FileUploads/images/avatas/"), fileName);
                                    avatarUpload.SaveAs(path);
                                    us.LinkAvata = "/FileUploads/images/avatas/" + fileName;
                                }
                                else
                                {
                                    return(Json(new { status = false, mess = L.T("FileExtensionReject") }));
                                }
                            }
                            else
                            {
                                return(Json(new { status = false, mess = L.T("FileExtensionReject") }));
                            }
                        }

                        us.RoleId   = RoleKey.Student;
                        us.Status   = true;
                        us.Password = account.Password;
                        us.Username = account.Username;
                        if (string.IsNullOrEmpty(us.LinkAvata))
                        {
                            us.LinkAvata = us.Gender == GenderKey.Male ? "/Content/images/team/2.png" : "/Content/images/team/3.png";
                        }
                        unitofwork.Account.Put(us, us.Username);
                        unitofwork.Complete();

                        //Đăng xuất
                        var nameCookie = Request.Cookies["name_student"];
                        if (nameCookie != null)
                        {
                            var myCookie = new HttpCookie("name_student")
                            {
                                Expires = DateTime.Now.AddDays(-1d)
                            };
                            Response.Cookies.Add(myCookie);
                        }

                        //Login luon
                        var cookieClient       = us.Username;
                        var decodeCookieClient = CryptorEngine.Encrypt(cookieClient, true);

                        var userCookie = new HttpCookie("name_student")
                        {
                            Value   = decodeCookieClient,
                            Expires = DateTime.Now.AddDays(30)
                        };
                        HttpContext.Response.Cookies.Add(userCookie);

                        return(Json(new { status = true, mess = "Cập nhật thành công" }));
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { status = false, mess = "Cập nhật không thành công", ex }));
                    }
                }
                else
                {
                    return(Json(new { status = false, mess = "Tài khoản không khả dụng" }));
                }
            }
        }
コード例 #17
0
        public ActionResult Update(tblCustomer obj, HttpPostedFileBase FileUpload, string key = "", string customergroup = "", string customerstatus = "", string RePassword = "", int page = 1)
        {
            var dictonary = FunctionHelper.GetLocalizeDictionary("Home", "notification");

            ViewBag.keyValue            = key;
            ViewBag.customergroupValue  = customergroup;
            ViewBag.customerstatusValue = customerstatus;
            ViewBag.PN = page;

            ViewBag.CustomerGroups = GetMenuList();
            var systemconfig = _tblSystemConfigService.GetDefault();

            ViewBag.IsCompartment = systemconfig != null ? systemconfig.isCompartment : true;
            //Kiểm tra
            var oldObj = _tblCustomerService.GetById(obj.CustomerID);

            if (oldObj == null)
            {
                ViewBag.Error = "Bản ghi không tồn tại";
                return(View(obj));
            }

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

            if (string.IsNullOrWhiteSpace(obj.CustomerName))
            {
                ModelState.AddModelError("CustomerName", dictonary["enter_customer_name"]);
                return(View(oldObj));
            }

            if (string.IsNullOrWhiteSpace(obj.CustomerCode))
            {
                ModelState.AddModelError("CustomerCode", dictonary["enter_customer_code"]);
                return(View(oldObj));
            }

            var existed = _tblCustomerService.GetByCode_Id(obj.CustomerCode, obj.CustomerID.ToString());

            if (existed != null)
            {
                ModelState.AddModelError("CustomerCode", dictonary["Customer_code_already_exists"]);
                return(View(oldObj));
            }

            if (!string.IsNullOrWhiteSpace(obj.Password))
            {
                if (obj.Password != RePassword)
                {
                    ModelState.AddModelError("Password", dictonary["correct_password"]);
                    return(View(oldObj));
                }

                oldObj.Password = CryptorEngine.Encrypt(obj.Password, true);
            }

            //Gán giá trị
            oldObj.Account         = obj.Account;
            oldObj.Address         = obj.Address;
            oldObj.CustomerCode    = obj.CustomerCode;
            oldObj.CompartmentId   = !string.IsNullOrEmpty(obj.CompartmentId) ? obj.CompartmentId.Trim() : "";
            oldObj.CustomerGroupID = obj.CustomerGroupID;
            oldObj.CustomerName    = obj.CustomerName;
            oldObj.Description     = obj.Description;
            oldObj.EnableAccount   = obj.EnableAccount;
            oldObj.IDNumber        = obj.IDNumber;
            oldObj.Inactive        = obj.Inactive;
            oldObj.Mobile          = obj.Mobile;
            oldObj.SortOrder       = obj.SortOrder;

            if (!string.IsNullOrEmpty(oldObj.Address))
            {
                oldObj.AddressUnsign = StringUtil.RemoveSpecialCharactersVn(oldObj.Address.ToLower()).Replace("-", " ");
            }
            else
            {
                oldObj.AddressUnsign = "";
            }

            if (FileUpload != null)
            {
                var extension = Path.GetExtension(FileUpload.FileName) ?? "";
                var fileName  = Path.GetFileName(string.Format("{0}{1}", StringUtil.RemoveSpecialCharactersVn(FileUpload.FileName.Replace(extension, "")).GetNormalizeString(), extension));

                var url = ConfigurationManager.AppSettings["FileUploadAvatar"];
                oldObj.Avatar = string.Format("{0}{1}", url, fileName);
            }

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.ParkingCode, ActionConfigO.Update);

                WriteLog.WriteLogFile(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.ParkingCode, ActionConfigO.Update);

                UploadFile(FileUpload);

                return(RedirectToAction("Index", new { page = page, key = key, customergroup = customergroup, customerstatus = customerstatus, selectedId = oldObj.CustomerID }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
コード例 #18
0
        public ActionResult DeleteJob(string jobid, string wbid)
        {
            try
            {
                int wbiddecrypt  = Convert.ToInt32(CryptorEngine.Decrypt(cm.Code_Decrypt(Convert.ToString(wbid))));
                int jobiddecrypt = Convert.ToInt32(CryptorEngine.Decrypt(cm.Code_Decrypt(Convert.ToString(jobid))));
                context.spdeletejob(jobiddecrypt);
                context.SaveChanges();
                TempData["Message"] = "Record Deleted";
                return(RedirectToAction("WhiteBoardDetails", new { @wbid = @cm.Code_Encrypt(CryptorEngine.Encrypt(wbiddecrypt.ToString())) }));
            }
            catch (Exception ex)
            {
                TempData["Message"] = "Some error occured";
                cm.ErrorExceptionLogingByService(ex.ToString(), "WhiteBoards" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "DeleteJob", "NA", "NA", "NA", "WEB");
            }


            return(View());
        }
コード例 #19
0
        public JsonResult Register(AccountRegiter usreg, string rePassword)
        {
            if (usreg.Password != rePassword)
            {
                return(Json(new { status = false, mess = "Mật khẩu không khớp" }));
            }
            using (var workScope = new UnitOfWork(new PatientManagementDbContext()))
            {
                var account = workScope.Accounts.FirstOrDefault(x => x.UserName.ToLower() == usreg.UserName.ToLower());
                if (account == null)
                {
                    try
                    {
                        var doctors = workScope.Doctors.GetAll().ToList();
                        BELibrary.Entity.Doctor doctor = doctors[0];
                        //add record
                        Record record   = new Record();
                        var    recordid = Guid.NewGuid();
                        record.Id           = recordid;
                        record.CreatedDate  = DateTime.Today;
                        record.CreatedBy    = "Quản trị";
                        record.ModifiedBy   = "Quản trị";
                        record.ModifiedDate = DateTime.Today;
                        record.StatusRecord = 1;
                        record.DoctorId     = doctor.Id;
                        workScope.Records.Add(record);
                        workScope.Complete();

                        //add patient
                        Patient pati  = new Patient();
                        var     paiid = Guid.NewGuid();
                        pati.Id       = paiid;
                        pati.FullName = usreg.FullName;
                        pati.Gender   = usreg.Gender;
                        pati.IndentificationCardDate = usreg.IndentificationCardDate;
                        pati.IndentificationCardId   = usreg.IndentificationCardId;
                        pati.Phone       = usreg.Phone;
                        pati.Email       = usreg.Email;
                        pati.Address     = usreg.Address;
                        pati.DateOfBirth = usreg.DateOfBirth;
                        int code;
                        // Create patient code

                        var patient = workScope.Patients.GetAll().OrderByDescending(x => x.PatientCode.Length).
                                      ThenByDescending(x => x.PatientCode).FirstOrDefault();
                        if (patient != null)
                        {
                            code = Int32.Parse(patient.PatientCode) + 1;
                        }
                        else
                        {
                            code = 1;
                        }

                        pati.PatientCode = code.ToString();

                        pati.JoinDate = DateTime.Now;
                        pati.Status   = true;

                        pati.RecordId = recordid;

                        workScope.Patients.Add(pati);

                        workScope.Complete();

                        var passwordFactory = usreg.Password + VariableExtensions.KeyCrypto;
                        var passwordCrypto  = CryptorEngine.Encrypt(passwordFactory, true);

                        Account ac = new Account();
                        ac.FullName   = pati.FullName;
                        ac.Gender     = pati.Gender;
                        ac.Phone      = pati.Phone;
                        ac.UserName   = usreg.UserName;
                        ac.Password   = passwordCrypto;
                        ac.Role       = RoleKey.Patient;
                        ac.LinkAvatar = "/Content/images/team/2.png";
                        ac.Id         = Guid.NewGuid();
                        ac.PatientId  = paiid;

                        workScope.Accounts.Add(ac);
                        workScope.Complete();

                        //Login luon
                        if (HttpContext.Request.Url != null)
                        {
                            var host = HttpContext.Request.Url.Authority;

                            var cookieClient       = usreg.UserName + "|" + host.ToLower() + "|" + ac.Id;
                            var decodeCookieClient = CryptorEngine.Encrypt(cookieClient, true);
                            var userCookie         = new HttpCookie(CookiesKey.Client)
                            {
                                Value   = decodeCookieClient,
                                Expires = DateTime.Now.AddDays(30)
                            };
                            HttpContext.Response.Cookies.Add(userCookie);
                            return(Json(new { status = true, mess = "Đăng ký thành công" }));
                        }
                        else
                        {
                            return(Json(new { status = false, mess = "Thêm không thành công" }));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { status = false, mess = "Thêm không thành công" }));
                    }
                }
                else
                {
                    return(Json(new { status = false, mess = "Username không khả dụng" }));
                }
            }
        }
コード例 #20
0
        public JsonResult MoveContact(int contactid, int companyid, int companyidold)
        {
            string msg = "";

            try
            {
                context.SpMoveContact(companyid, contactid, companyidold);
                context.SaveChanges();
                msg = Url.Action("Index", "ProspectViewCompanyClient", new { @Compid = @cm.Code_Encrypt(CryptorEngine.Encrypt(companyid.ToString())) });
            }
            catch (Exception ex)
            {
                cm.ErrorExceptionLogingByService(ex.ToString(), "ProspectViewCompanyClient" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "MoveContact", "NA", "NA", "NA", "WEB");
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
コード例 #21
0
        public JsonResult UpdatePass(string oldPassword, string newPassword, string rePassword)
        {
            if (oldPassword == "" || newPassword == "" || rePassword == "")
            {
                return(Json(new { status = false, mess = "Không được để trống" }));
            }
            if (!CookiesManage.Logined())
            {
                return(Json(new { status = false, mess = "Chưa đăng nhập" }));
            }
            if (newPassword != rePassword)
            {
                return(Json(new { status = false, mess = "Mật khẩu không khớp" }));
            }
            var user = CookiesManage.GetUser();

            using (var workScope = new UnitOfWork(new PatientManagementDbContext()))
            {
                var account = workScope.Accounts.FirstOrDefault(x => x.UserName.ToLower() == user.UserName.ToLower());
                if (account != null)
                {
                    try
                    {
                        var passwordFactory = oldPassword + VariableExtensions.KeyCryptorClient;
                        var passwordCryptor = CryptorEngine.Encrypt(passwordFactory, true);

                        if (passwordCryptor == account.Password)
                        {
                            passwordFactory = newPassword + VariableExtensions.KeyCryptorClient;
                            passwordCryptor = CryptorEngine.Encrypt(passwordFactory, true);

                            account.Password = passwordCryptor;
                            workScope.Accounts.Put(account, account.Id);
                            workScope.Complete();

                            //Đăng xuất
                            var nameCookie = Request.Cookies[CookiesKey.Client];
                            if (nameCookie != null)
                            {
                                var myCookie = new HttpCookie(CookiesKey.Client)
                                {
                                    Expires = DateTime.Now.AddDays(-1d)
                                };
                                Response.Cookies.Add(myCookie);
                            }

                            //Login luon
                            if (HttpContext.Request.Url != null)
                            {
                                var host = HttpContext.Request.Url.Authority;

                                var cookieClient       = account.UserName + "|" + host.ToLower() + "|" + account.Id;
                                var decodeCookieClient = CryptorEngine.Encrypt(cookieClient, true);
                                var userCookie         = new HttpCookie(CookiesKey.Client)
                                {
                                    Value   = decodeCookieClient,
                                    Expires = DateTime.Now.AddDays(30)
                                };
                                HttpContext.Response.Cookies.Add(userCookie);
                                return(Json(new { status = true, mess = "Cập nhật thành công" }));
                            }
                            else
                            {
                                return(Json(new { status = false, mess = "Cập nhật K thành công" }));
                            }
                        }
                        else
                        {
                            return(Json(new { status = false, mess = "mật khẩu cũ không đúng" }));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { status = false, mess = "Cập nhật không thành công", ex }));
                    }
                }
                else
                {
                    return(Json(new { status = false, mess = "Tài khoản không khả dụng" }));
                }
            }
        }
コード例 #22
0
        public ActionResult Update(tblCustomer obj, HttpPostedFileBase FileUpload, string key = "", string customergroup = "", string customerstatus = "", string RePassword = "", string hidFinger1 = "", string hidFinger2 = "", int page = 1)
        {
            ViewBag.keyValue            = key;
            ViewBag.customergroupValue  = customergroup;
            ViewBag.customerstatusValue = customerstatus;
            ViewBag.PN = page;

            ViewBag.CustomerGroups = GetMenuList();
            ViewBag.ControllerList = _tblAccessControllerService.GetAllActive();
            ViewBag.LevelList      = _tblAccessLevelService.GetAllActive();

            //Kiểm tra
            var oldObj = _tblCustomerService.GetById(obj.CustomerID);

            if (oldObj == null)
            {
                ViewBag.Error = "Bản ghi không tồn tại";
                return(View(obj));
            }

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

            var existed = _tblCustomerService.GetByCode_Id(obj.CustomerCode, obj.CustomerID.ToString());

            if (existed != null)
            {
                ModelState.AddModelError("CustomerCode", "Mã khách hàng đã tồn tại");
                return(View(oldObj));
            }

            if (!string.IsNullOrWhiteSpace(obj.Password))
            {
                if (obj.Password != RePassword)
                {
                    ModelState.AddModelError("Password", "Vui lòng nhập lại đúng mật khẩu");
                    return(View(oldObj));
                }

                oldObj.Password = CryptorEngine.Encrypt(obj.Password, true);
            }

            if (!string.IsNullOrWhiteSpace(obj.DevPass))
            {
                var devpass = _tblCustomerService.GetByDevPass(obj.DevPass);
                if (devpass != null && devpass.CustomerID != oldObj.CustomerID)
                {
                    ModelState.AddModelError("DevPass", "Mật khẩu đã tồn tại");
                    return(View(oldObj));
                }
            }

            //Gán giá trị
            oldObj.Account         = obj.Account;
            oldObj.Address         = obj.Address;
            oldObj.CustomerCode    = obj.CustomerCode;
            oldObj.CompartmentId   = obj.CompartmentId;
            oldObj.CustomerGroupID = obj.CustomerGroupID;
            oldObj.CustomerName    = obj.CustomerName;
            oldObj.Description     = obj.Description;
            oldObj.EnableAccount   = obj.EnableAccount;
            oldObj.IDNumber        = obj.IDNumber;
            oldObj.Inactive        = obj.Inactive;
            oldObj.Mobile          = obj.Mobile;
            oldObj.SortOrder       = obj.SortOrder;

            oldObj.AccessLevelID  = obj.AccessLevelID;
            oldObj.Finger1        = !string.IsNullOrWhiteSpace(hidFinger1) ? hidFinger1 : "";
            oldObj.Finger2        = !string.IsNullOrWhiteSpace(hidFinger2) ? hidFinger2 : "";
            oldObj.UserIDofFinger = obj.UserIDofFinger;
            oldObj.DevPass        = !string.IsNullOrEmpty(obj.DevPass) ? obj.DevPass : "";

            if (FileUpload != null)
            {
                var extension = Path.GetExtension(FileUpload.FileName) ?? "";
                var fileName  = Path.GetFileName(string.Format("{0}{1}", StringUtil.RemoveSpecialCharactersVn(FileUpload.FileName.Replace(extension, "")).GetNormalizeString(), extension));

                var url = ConfigurationManager.AppSettings["FileUploadAvatar"];
                oldObj.Avatar = string.Format("{0}{1}", url, fileName);
            }

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.AccessControlCode, ActionConfigO.Update);

                UploadFile(FileUpload);

                return(RedirectToAction("Index", new { page = page, key = key, customergroup = customergroup, customerstatus = customerstatus, selectedId = oldObj.CustomerID }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
コード例 #23
0
        public ActionResult Create(tblCustomer obj, HttpPostedFileBase FileUpload, bool SaveAndCountinue = false, string key = "", string customergroup = "", string customerstatus = "", string RePassword = "", string hidFinger1 = "", string hidFinger2 = "")
        {
            ViewBag.keyValue            = key;
            ViewBag.CustomerGroupValue  = customergroup;
            ViewBag.customerstatusValue = customerstatus;

            ViewBag.CustomerGroups = GetMenuList();
            ViewBag.ControllerList = _tblAccessControllerService.GetAllActive();
            ViewBag.LevelList      = _tblAccessLevelService.GetAllActive();

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

            var existed = _tblCustomerService.GetByCode(obj.CustomerCode);

            if (existed != null)
            {
                ModelState.AddModelError("CustomerCode", "Mã khách hàng đã tồn tại");
                return(View(obj));
            }

            if (!string.IsNullOrWhiteSpace(obj.Password))
            {
                if (obj.Password != RePassword)
                {
                    ModelState.AddModelError("Password", "Vui lòng nhập lại đúng mật khẩu");
                    return(View(obj));
                }

                obj.Password = CryptorEngine.Encrypt(obj.Password, true);
            }

            if (!string.IsNullOrWhiteSpace(obj.DevPass))
            {
                var devpass = _tblCustomerService.GetByDevPass(obj.DevPass);
                if (devpass != null)
                {
                    ModelState.AddModelError("DevPass", "Mật khẩu đã tồn tại");
                    return(View(obj));
                }
            }

            //Gán giá trị
            obj.CustomerID       = Guid.NewGuid();
            obj.AccessExpireDate = Convert.ToDateTime("2099/12/31");
            obj.Finger1          = !string.IsNullOrWhiteSpace(hidFinger1) ? hidFinger1 : "";
            obj.Finger2          = !string.IsNullOrWhiteSpace(hidFinger2) ? hidFinger2 : "";
            obj.DevPass          = !string.IsNullOrEmpty(obj.DevPass) ? obj.DevPass : "";

            if (FileUpload != null)
            {
                var extension = Path.GetExtension(FileUpload.FileName) ?? "";
                var fileName  = Path.GetFileName(string.Format("{0}{1}", StringUtil.RemoveSpecialCharactersVn(FileUpload.FileName.Replace(extension, "")).GetNormalizeString(), extension));

                var url = ConfigurationManager.AppSettings["FileUploadAvatar"];
                obj.Avatar = string.Format("{0}{1}", url, fileName);
            }

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

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.AccessControlCode, ActionConfigO.Create);

                UploadFile(FileUpload);

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

                return(RedirectToAction("Index", new { key = key, customergroup = customergroup, customerstatus = customerstatus, selectedId = obj.CustomerID }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(obj));
            }
        }
コード例 #24
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));
            }
        }
コード例 #25
0
        protected override void Seed(PatientManagementDbContext context)
        {
            //Role role = new Role
            //{
            //    Id = Guid.NewGuid(),
            //    RoleEnum = RoleKey.Admin,
            //    Name = RoleKey.GetRole(RoleKey.Admin)
            //};
            //context.Roles.AddOrUpdate(c => c.RoleEnum, role);

            //context.SaveChanges();
            var passwordFactory = VariableExtensions.DefautlPassword + VariableExtensions.KeyCrypto;
            var passwordCrypto  = CryptorEngine.Encrypt(passwordFactory, true);

            context.Accounts.AddOrUpdate(c => c.UserName, new Account()
            {
                Id         = Guid.NewGuid(),
                FullName   = "Quản Trị",
                Phone      = "0973 642 032",
                UserName   = "******",
                Password   = passwordCrypto,
                Role       = 1,
                Gender     = true,
                LinkAvatar = ""
            });

            #region Faculty

            var faculties = new List <Faculty>
            {
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Tim mạch Can thiệp"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Tim mạch tổng quát"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Nhịp tim học"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Hồi sức Tim mạch"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Phẫu thuật Tim - Lồng ngực mạch máu"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Nội Tiêu hóa"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Nội Thần kinh tổng quát"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Ngoại Thần kinh"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Nội tiết"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Bệnh lý mạch máu não"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Bệnh Nhiệt đới"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Cơ xương khớp"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Hô hấp"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Ngoại Niệu - Ghép thận"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Nội Thận - Miễn dịch ghép"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Cấp cứu Tổng hợp"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Hồi sức tích cực - Chống độc"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Gây mê - Hồi sức Ngoại"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Ngoại tổng quát"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Ngoại Chấn thương chỉnh hình"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Tai mũi họng"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Răng Hàm Mặt - Mắt"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Y học cổ truyền - Phục hồi chức năng "
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Y học cổ truyền - Phục hồi chức năng"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Y học thể thao"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Khám bệnh"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Khám và Điều trị theo yêu cầu "
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Khám và Điều trị theo yêu cầu"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Xét nghiệm"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Chẩn đoán hình ảnh"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Giải phẫu bệnh"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Đơn vị Nội soi"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Dinh dưỡng"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Kiểm soát nhiễm khuẩn"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Dược"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Khoa Ung bướu và Y học hạt nhân"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Tổ chức Cán bộ"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Kế hoạch Tổng hợp"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Điều dưỡng"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Chỉ đạo tuyến "
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Chỉ đạo tuyến"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Tài chính Kế toán"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Hành chính Quản trị "
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Vật tư - Thiết bị y tế"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Công nghệ thông tin"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Quản lý chất lượng "
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Phòng Công tác xã hội"
                },
                new Faculty {
                    Id = Guid.NewGuid(), Name = "Nhà Thuốc"
                }
            };
            //foreach (var faculty in faculties)
            //{
            //    context.Faculties.AddOrUpdate(c => c.Name, faculty);
            //}

            #endregion Faculty

            #region Medical

            var medicines = new List <Medicine>
            {
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Natri chloride 0,45%", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Natri chloride 10%", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Aminosteril N-Hepa 8%", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Abobotulinum Toxin A", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Abobotulinum Toxin A", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acarbose", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acenocoumarol", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acetazolamide", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acetyl-Dl-Leucine", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acetylcysteine", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Amoxicillin/ Clavulanic Acid (tiêm)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Zoledronic Acid", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acid Thioctic", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acid Ursodeoxycholic", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acid Folic", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acyclovir (Tra mắt)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Acyclovir (Uống)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Adalimumab", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Adapalene/ Clindamycin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Adapalene", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Adenosine", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Adrenaline", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Afatinib", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Albendazole", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Albumin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alendronate", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alendronate", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alfuzosin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alimemazine", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Allopurinol", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alpha Chymotrypsine (Uống)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alpha Chymotrypsine (Tiêm)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alprostadil", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alteplase", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alverine", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alverine/ Simethicone", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Alvesin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Ambroxol", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Amikacin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Aminophyllin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Amiodarone", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Amlodipine", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Amphotericin B lipid complex", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Anastrozole", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Atorvastatin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Atosiban", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Azithromycin (Uống)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Magnesi Lactate/ Vitamin B6", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Bambuterol", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Levodopa/Benserazide", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Bernevit", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Betahistin", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Bevacizumab", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Bisoprolol", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Mometasone (bôi)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Broncho Vacxom", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Budesonide (Khí dung)", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Hyoscin-N-Butylbromide", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Mytomycin C", Description = ""
                },
                new Medicine {
                    Id = Guid.NewGuid(), Name = "Capecitabine", Description = ""
                }
            };

            //foreach (var medicine in medicines)
            //{
            //    context.Medicines.AddOrUpdate(c => c.Name, medicine);
            //}

            #endregion Medical
        }
コード例 #26
0
        public ActionResult PasswordReset(User user, FormCollection collection)
        {
            Site Site       = GetSite(user.SiteID);
            bool ReturnCode = false;

            if (user.ID > 0)
            {
                User objUser = _repository.FindByID(user.ID);
                objUser.PasswordSalt    = WBHelper.CreateSalt();
                objUser.PasswordHash    = WBHelper.CreatePasswordHash(collection["txtPassword"], objUser.PasswordSalt);
                objUser.ConfirmPassword = objUser.PasswordHash;
                _repository.Update(objUser);
                _unitOfWork.Commit();
                ReturnCode = true;
            }
            string url = (USESSL ? "https" : "http") + "://" + (string.IsNullOrEmpty(Site.Alias) ? Site.CName : Site.Alias) + "/staticpage/passwordresetresult?authcode=" + HttpUtility.UrlEncode(CryptorEngine.Encrypt(ReturnCode.ToString() + SettingConstants.Seprate + user.ID, true));

            return(Redirect301(url, (string.IsNullOrEmpty(Site.Alias) ? Site.CName : Site.Alias)));
        }
コード例 #27
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (CheckBox1.Checked)
            {
                HttpCookie cookie = new HttpCookie("users");
                cookie.Value = "Ritesh Agarwal";

                cookie.Expires = DateTime.Now.AddDays(7);
                Response.Cookies.Add(cookie);
            }
            SqlConnection con = new SqlConnection(str);
            con.Open();
            SqlCommand cmd = new SqlCommand("Select * from login where username=@1 and password=@2", con);
            cmd.Parameters.AddWithValue("@1", TextBox1.Text);
            cmd.Parameters.AddWithValue("@2", CryptorEngine.Encrypt(TextBox2.Text, true));
            SqlDataReader sdr = cmd.ExecuteReader();

            if (sdr.Read())
            {
                Session["user_id"] = sdr.GetString(4);
                Response.Write(Session["user_id"].ToString());

                if (sdr.GetString(2) == "Y" && sdr.GetString(3) == "user")                   //checking that login is first time or not
                {
                    //Console.WriteLine("Logged in is first time user");

                    update_login();
                    Session["user_name"] = TextBox1.Text;
                    Response.Redirect("ChangePassword.aspx");
                }

                if (sdr.GetString(2) == "N")
                {
                    if (sdr.GetString(3) == "user")
                    {
                        Session["user_name"] = TextBox1.Text;
                        Response.Redirect("Home.aspx");
                    }

                    if (sdr.GetString(3) == "admin")
                    {
                        Session["user_name"] = TextBox1.Text;
                        Response.Redirect("AdminHome.aspx");
                    }
                }

                else
                {
                    Response.Write("<script type='javascript'>alert('Not a recognised format');</script>");
                }
            }
            else
            {
                Response.Write("<script type='javascript'>alert('Record does not exists');</script>");
            }

            con.Close();
        }
        catch (Exception exp)
        {
            Response.Write(exp.Message);
        }
    }
コード例 #28
0
 public String Encr(String cypher)
 {
     return(crypto.Encrypt(cypher, true));
 }
コード例 #29
0
        private void frm_master_Load(object sender, EventArgs e)
        {
            noti();
            //RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Depple",true);
            //string nnmm = key.GetValue("name").ToString();
            //if (key.GetValue("name").ToString() == "CMS")
            //{
            //    if (key.GetValue("days" ).ToString() == "1")
            //    {
            //        key.SetValue("regdate", System.DateTime.Now.ToString("dd/MM/yyyy"));
            //        key.SetValue("hardiskno", CryptorEngine.Encrypt(DeppleSoftwareLib.ValidationForm.Validation.getUniqueID("C"), true));
            //        key.SetValue("days", CryptorEngine.Encrypt("2", true));
            //    }
            //    else
            //    {
            //        string hdNo = CryptorEngine.Decrypt(key.GetValue("hardiskno").ToString(), true);
            //        if (hdNo == DeppleSoftwareLib.ValidationForm.Validation.getUniqueID("C"))
            //        {
            //            string d1 = CryptorEngine.Decrypt(key.GetValue("days").ToString(), true);
            //            if (Convert.ToInt32(d1) > 40)
            //            {
            //                MessageBox.Show("Cylinder Software Licence is Expire.  Please Contact Priyank Patel(9409544924).");
            //                Application.Exit();
            //            }
            //            else
            //            {
            //                int d2 = Convert.ToInt32(d1) + 1;
            //                key.SetValue("days", CryptorEngine.Encrypt(d2.ToString(), true));
            //            }
            //        }
            //        else
            //        {
            //            MessageBox.Show("This is Not Your Software. Please Contact Priyank Patel(9409544924).");
            //            Application.Exit();
            //        }
            //    }
            //}
            //else
            //{
            //    MessageBox.Show("This is Not Your Software. Please Contact Priyank Patel(9409544924).");
            //    Application.Exit();
            //}

            ModifyRegistry mr = new ModifyRegistry();
            string         nm = mr.Read("name");

            if (nm == "CMS")
            {
                if (mr.Read("days") == "1")
                {
                    mr.Write("regdate", System.DateTime.Now.ToString("dd/MM/yyyy"));
                    mr.Write("hardiskno", CryptorEngine.Encrypt(DeppleSoftwareLib.ValidationForm.Validation.getUniqueID("C"), true));
                    mr.Write("days", CryptorEngine.Encrypt("2", true));
                }
                else
                {
                    string hdNo = CryptorEngine.Decrypt(mr.Read("hardiskno"), true);
                    if (hdNo == DeppleSoftwareLib.ValidationForm.Validation.getUniqueID("C"))
                    {
                        string d1 = CryptorEngine.Decrypt(mr.Read("days"), true);

                        if (Convert.ToInt32(d1) > 500)
                        {
                            MessageBox.Show("Cylinder Software Licence is Expire.  Please Contact Priyank Patel(9409544924).");
                            Application.Exit();
                        }
                        else
                        {
                            int d2 = Convert.ToInt32(d1) + 1;
                            mr.Write("days", CryptorEngine.Encrypt(d2.ToString(), true));
                        }
                    }
                    else
                    {
                        MessageBox.Show("This is Not Your Software. Please Contact Priyank Patel(9409544924).");
                        Application.Exit();
                    }
                }
                //mr.Read("ACTIVE");
            }
            else
            {
                MessageBox.Show("This is Not Your Software. Please Contact Priyank Patel(9409544924).");
                Application.Exit();
            }
        }
コード例 #30
0
 public string Encrypt(string plainText, string passPhrase)
 {
     return(CryptorEngine.Encrypt(plainText, passPhrase));
 }