public string CreateAccount(string username, string password, bool requiresConfirmation) { var hash = _encryptor.Encrypt(password); var token = requiresConfirmation ? TokenFactory.Create() : string.Empty; _factory.Create(username, GetHashSalt(hash), GetHashPassword(hash), token); return(token); }
private void ResumeCookie() { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LoginUserID"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("FirstName"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LastName"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("CompanyID"), 30); }
public void ProcessRequest(HttpContext context) { //UtilFactory.Helpers.CookieHelper.ResumeCookie(); //旧方法有时间问题 IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("ExpireTime"), DateTime.Now.ToUniversalTime().AddMinutes(30).ToString(), DateTime.Now.AddMinutes(30)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UtcTimeStamp"), (DateTime.UtcNow.AddMinutes(30) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds.ToString(), DateTime.Now.AddMinutes(30)); context.Response.Write("true"); }
public B_WORKER Login(string loginName, string passWord) { IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; HashEncrypt he = new HashEncrypt(); //解密前台DES加密的密码 //loginName = he.DESDecrypt(loginName, "", ""); //passWord = he.DESDecrypt(passWord, "", ""); B_WORKER entity = DAL.Organize.Worker.Login(loginName); if (entity == null) { return(null); } //根据后台配置加密密码 string temp = encrypt.Encrypt(entity.ID, passWord); if (entity.PassWord == temp) { return(entity); } else { return(null); } }
public bool SendForgotPasswordEmail(string username) { try { this.ClearBrokenRuleMessages(); UsersEntity user = this.GetUserByUserName(username); if (user == null) { return(false); } user.AccountStatus = UsersEntity.ForgotPasswordFlag; this.UpdateUser(user); IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string enkey = encrypt.Encrypt(string.Format("{0}_{1}", user.ID.ToString(), DateTime.Now.ToString())); string url = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host + "/ResetPassword.aspx?link=", enkey); string body = UtilFactory.Helpers.FileHelper.GetTemplateFileContent("SendEmailToUserForFindPassword.txt"); body = body.Replace("{FirstName}", user.FirstName); body = body.Replace("{LastName}", user.LastName); body = body.Replace("{Date}", DateTime.Now.ToString("MM/dd/yyyy")).Replace("{URL}", url); if (emailSender.SendMail(username, Config.DefaultSendEmail, "Password Assistance", body)) { return(true); } this.AddBrokenRuleMessage("Error", "Sorry,mail server is unavailable."); return(false); } catch (Exception ex) { WebLogAgent.Write(ex); return(false); } }
public async Task <IActionResult> On(OnModel model, bool remember, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } //var sessionImageCode = _distributedCache.GetString(ImageCodeHelper.SESSION_IMAGE_CODE); var sessionImageCode = HttpContext.Session.GetString(ImageCodeHelper.SESSION_IMAGE_CODE); model.ImageCode = ImageCodeHelper.CheckResult(model.ImageCode, sessionImageCode); if (model.ImageCode.ImageCodeError != ImageCodeError.NoError) { return(View(model)); } var existUser = await _logService.GetUser(model.UserName); if (existUser != null && existUser.Password == _encrypt.Encrypt(model.Password)) { await _logService.On(model, remember); return(ReturnUrlHelper.ReturnUrl(returnUrl)); } TempData["ModelState"] = "* 用户名或密码错误"; return(View(model)); }
protected void Page_Load(object sender, EventArgs e) { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); UtilFactory.Helpers.CookieHelper.Remove(encrypt.Encrypt("LoginUserID")); Response.Redirect("/Login.aspx"); }
public static void Save(string name, List <TERRAIN> terrains) { string __temp = JsonWriter.Serialize(terrains); byte[] bytes = Encoding.UTF8.GetBytes(__temp); encrypt.Encrypt(ref bytes); _IO.WriteByte(DIR + Path.ChangeExtension(name, FILE), bytes); }
protected BaseController() { ViewBag.LoginUserName = LoginUserName; IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string userId = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("LoginUserID"))); if (string.IsNullOrEmpty(userId)) { IsOut = true; } ResumeCookie(); }
public async Task <HttpResponseMessage> Handle(UploadModel message) { await _fileSaver.SaveFile(message.File, message.Username); var unzipped = await _unzipper.Unzip(message.File); var encrypted = _encryptor.Encrypt(unzipped); var response = await _webRequester.Send(new EncryptedContent(encrypted, message.File.FileName), message.Username, message.Password); return(response); }
public void LoginSystem(string userName, int userID, int companyID, string password, bool remember) { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string loginUseridEncrypt = encrypt.Encrypt("LoginUserID"); string userIdEncrypt = encrypt.Encrypt(userName); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LoginUserID"), encrypt.Encrypt(userID.ToString()), DateTime.Now.AddMinutes(30)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_UserName_"), encrypt.Encrypt(userName), DateTime.Now.AddDays(7)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("CompanyID"), encrypt.Encrypt(companyID + ""), DateTime.Now.AddMinutes(30)); if (remember) { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), encrypt.Encrypt(password), DateTime.Now.AddDays(7)); } else { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), string.Empty, DateTime.Now.AddSeconds(1)); } IdentityContext.UserID = userID; IdentityContext.CompanyID = companyID; }
public override APIResponse Insert(ICardDetails CardDetailsObj) { try { AESObj.GenerateKey(); CardDetailsObj.SetIV(AESObj.GetIV()); CardDetailsObj.SetDecryptionKey(AESObj.GetKey()); CardDetailsObj.SetName(AESObj.Encrypt(CardDetailsObj.GetName())); CardDetailsObj.SetCardNumber(AESObj.Encrypt(CardDetailsObj.GetCardNumber())); CardDetailsObj.SetExpiryMonth(AESObj.Encrypt(CardDetailsObj.GetExpiryMonth())); CardDetailsObj.SetExpiryYear(AESObj.Encrypt(CardDetailsObj.GetExpiryYear())); CardDetailsObj.SetCvv(AESObj.Encrypt(CardDetailsObj.GetCvv())); bool Response = new Security(UserProfileObj).AuthenticateUser(); if (Response == true) { if (0 == CardDetailsDataLayerObj.Insert(CardDetailsObj)) { return(APIResponse.NOT_OK); } else { return(APIResponse.OK); } } else { return(APIResponse.NOT_AUTHENTICATED); } } catch (NullReferenceException nex) { Logger.Instance().Log(Warn.Instance(), new LogInfo("Received null reference while adding card (Routine : AuthenticateUser), might be token manipulation. Check token : " + UserProfileObj.GetToken())); throw nex; } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }
public void ResumeCookie() { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LoginUserID"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("FirstName"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LastName"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("CompanyID"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("UserType"), 30); UtilFactory.Helpers.CookieHelper.ResumeExpire(encrypt.Encrypt("ExpireTime"), 30); UtilFactory.Helpers.CookieHelper.ResumeExpire(encrypt.Encrypt("UtcTimeStamp"), 30); }
public async Task <IActionResult> Put(OnModel model) { if (!ModelState.IsValid) { return(Json(ModelState.ValidationState)); } var sessionImageCode = HttpContext.Session.GetString(ImageCodeHelper.SESSION_IMAGE_CODE); model.ImageCode = ImageCodeHelper.CheckResult(model.ImageCode, sessionImageCode); if (model.ImageCode.ImageCodeError != ImageCodeError.NoError) { return(Json(new RequestResult { State = RequestState.Failed, Msg = "ÑéÖ¤Âë´íÎó!" })); } var existUser = await _logService.GetUser(model.UserName); if ((existUser != null) && (existUser.Password == _encrypt.Encrypt(model.Password))) { var requestAt = DateTime.Now; var expiresIn = requestAt + TokenAuthOption.ExpiresSpan; var token = GenerateToken(existUser, expiresIn); return(Json(new RequestResult { State = RequestState.Success, Data = new { requertAt = requestAt, expiresIn = TokenAuthOption.ExpiresSpan.TotalSeconds, tokeyType = TokenAuthOption.TokenType, accessToken = token } })); } else { return(Json(new RequestResult { State = RequestState.Failed, Msg = "Óû§Ãû»òÃÜÂë´íÎó!" })); } }
private void Encrypt_Click(object sender, RoutedEventArgs e) { if (!CheckInputFields()) { return; } var binaryFormatter = new BinaryFormatter(); var memoryStream = new MemoryStream(); binaryFormatter.Serialize(memoryStream, Entries); var decryptedBytes = memoryStream.ToArray(); var encryptedBytes = _encrypter.Encrypt(decryptedBytes, Password); using (var stream = File.Open(FileLocation, FileMode.Create)) stream.Write(encryptedBytes, 0, encryptedBytes.Length); }
private void ResumeCookie() { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string userType = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("UserType"))); if (userType != "SUNNET") { UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LoginUserID"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("FirstName"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("LastName"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("CompanyID"), 30); UtilFactory.Helpers.CookieHelper.Resume(encrypt.Encrypt("UserType"), 30); UtilFactory.Helpers.CookieHelper.ResumeExpire(encrypt.Encrypt("ExpireTime"), 30); } }
async Task <UserIdentity> ValidateUser(LoginModel account) { UserIdentity user = await GetUser(account); if (user == null) { return(null); } var hashPassword = _encryptor.Encrypt(account.Password, user.Salt); if (user.Password == hashPassword) { return(user); } return(null); }
protected void Page_Load(object sender, EventArgs e) { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); UtilFactory.Helpers.CookieHelper.Remove(encrypt.Encrypt("LoginUserID")); UtilFactory.Helpers.CookieHelper.RemoveAll(); string url = "/Login.aspx"; string returnUrl = Server.UrlDecode(Request.QueryString["returnurl"]); if (!string.IsNullOrEmpty(returnUrl) && returnUrl.IndexOf(".aspx") > 0) { bool exist = File.Exists(Server.MapPath(returnUrl.Substring(0, returnUrl.IndexOf(".aspx") + 5))); if (exist) { url += "?returnurl=" + Server.UrlEncode(returnUrl); } } Response.Redirect(url); }
private void InitCompanyInfo() { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); CompanyApplication comApp = new CompanyApplication(); CompanysEntity company = comApp.GetCompany(UserInfo.CompanyID); if (UserInfo.CompanyID == 1) //Sunnet 公司 { ltLogo.Text = string.Format("<a href=\"http://www.sunnet.us\" target=\"_blank\">{0}</a>" , BuilderLogo(company.Logo)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LtLogo"), encrypt.Encrypt(ltLogo.Text), DateTime.Now.AddMinutes(30)); } else { CompanysEntity sunntCompanyEntity = comApp.GetCompany(1); //获取Sunnet公司 if (company.Logo.IndexOf("logomain.jpg") >= 0) //没有上传Logo ,则显示 Sunnet 公司Logo { ltLogo.Text = string.Format("<a href=\"http://www.sunnet.us\" target=\"_blank\">{0}</a>" , BuilderLogo(sunntCompanyEntity.Logo)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LtLogo"), encrypt.Encrypt(ltLogo.Text), DateTime.Now.AddMinutes(30)); } else { ltLogo.Text = BuilderLogo(company.Logo); ltSunnetLogo.Text = string.Format("<a href=\"http://www.sunnet.us\" target=\"_blank\">{0}</a>" , BuilderLogo(sunntCompanyEntity.Logo)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LtLogo"), encrypt.Encrypt(ltLogo.Text), DateTime.Now.AddMinutes(30)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LtSunnetLogo"), encrypt.Encrypt(ltSunnetLogo.Text), DateTime.Now.AddMinutes(30)); } } }
private void btnEncrypt_Click(object sender, EventArgs e) { try { EncryptInfo encrypt = new EncryptInfo(this.txtSource.Text, Encoding.GetEncoding(this.cbxEncode.SelectedValue.ToString())); encrypt.Iv = this.txtIV.Text; encrypt.Key = this.txtKey.Text; IEncrypt obj = (IEncrypt)CreateInstance("EncryptBLL.Encrypt" + this.cbxType.SelectedValue); string checkeMsg = obj.Check(encrypt); if (string.Empty != checkeMsg) { MessageBox.Show(checkeMsg); return; } this.txtPassword.Text = obj.Encrypt(encrypt); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 调度台或者回访程序登录 /// </summary> /// <param name="loginName">TPerson编码</param> /// <param name="passWord"></param> /// <returns></returns> public B_WORKER DeskLogin(string loginName, string passWord) { IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; B_WORKER entity = DAL.Organize.Worker.DeskLogin(loginName); if (entity == null) { return(null); } string temp = encrypt.Encrypt(entity.ID, passWord); if (entity.PassWord == temp) { return(entity); } else { return(null); } }
public void Save(string filename) { string filePath = GetFilePath(filename); _ = Directory.CreateDirectory(GetFolderPath()); Dictionary <string, byte[]> gameData = new Dictionary <string, byte[]>(); foreach (KeyValuePair <string, IGameData> gd in _gameData) { gameData.Add(gd.Key, gd.Value.SaveData()); } string jsonData = _dataHandler.ConvertToString(gameData); if (_encrypt) { jsonData = _encryptor.Encrypt(jsonData); } using (StreamWriter writer = new StreamWriter(filePath)) writer.Write(jsonData); }
public static bool UpdatePassword(int workerId, string newPassword) { using (MainDataContext dbContext = new MainDataContext()) { using (MainDataContext dsContext = new MainDataContext(AppConfig.ConnectionStringDispatch)) { IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; B_WORKER worker = dbContext.B_WORKER.FirstOrDefault(v => v.ID == workerId); if (worker != null) { worker.PassWord = encrypt.Encrypt(workerId, newPassword); List <B_WORKER_ROLE> listWR = dbContext.B_WORKER_ROLE.Where(t => t.WorkerID == workerId).ToList(); foreach (B_WORKER_ROLE wr in listWR) { if (!string.IsNullOrEmpty(wr.EmpNo)) { TPerson tp = dsContext.TPerson.SingleOrDefault(t => t.工号 == wr.EmpNo); if (tp != null) { tp.口令 = new HashEncrypt().Encrypt(workerId, newPassword);; } } } } dbContext.SubmitChanges(); dsContext.SubmitChanges(); return(true); } } }
protected void Page_Load(object sender, EventArgs e) { userApp = new UserApplication(); if (!IsPostBack) { try { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string username = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("Login_UserName_"))); string password = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("Login_Password_"))); string preFailedUserName = QS("uname"); if (!string.IsNullOrEmpty(preFailedUserName))//如果前一次登陆成功过,那么就保存cookie, 否则就重新赋值为上一次失败的用户名。 { txtUserName.Text = preFailedUserName; txtPassword.Focus(); } else { txtUserName.Text = username; txtPassword.Text = password; } chkRemember.Checked = true; } catch { txtUserName.Text = "*****@*****.**"; txtPassword.Text = "jacK1234"; chkRemember.Checked = false; } } }
public string Encrypt(string raw) { var text = _inner.Encrypt(raw); return(Sha256(text)); }
public static string Encrypt(string value) { return(_instance.Encrypt(value)); }
/// <summary> /// Шифрование. Алфавит Англ. /// </summary> /// <param name="source">Входные данные</param> /// <param name="key">Ключ</param> public IEnumerable <string> Encrypt(IEnumerable <string> source, string key) { var newSource = new List <string>(source); return(encryptObj.Encrypt(newSource, key)); }
/// <summary> /// Login and set cookie /// </summary> /// <param name="user">Login user</param> /// <param name="password"></param> /// <param name="remember"></param> /// <param name="url">null mean default,a url to redirect</param> public void LoginSystem(UsersEntity user, string password, bool remember) { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string loginUseridEncrypt = encrypt.Encrypt("LoginUserID"); string userIdEncrypt = encrypt.Encrypt(user.ID.ToString()); if (user.UserType == "SUNNET") { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LoginUserID"), encrypt.Encrypt(user.ID.ToString()), true); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_UserName_"), encrypt.Encrypt(user.UserName), true); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("FirstName"), encrypt.Encrypt(user.FirstName), true); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LastName"), encrypt.Encrypt(user.LastName), true); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("CompanyID"), encrypt.Encrypt(user.CompanyID + ""), true); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UserType"), encrypt.Encrypt(user.UserType), true); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("ExpireTime"), "", true); if (remember) { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), encrypt.Encrypt(password), DateTime.Now.AddDays(7)); } else { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), string.Empty, DateTime.Now.AddSeconds(1)); } } else { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LoginUserID"), encrypt.Encrypt(user.ID.ToString()), DateTime.Now.AddMinutes(60)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_UserName_"), encrypt.Encrypt(user.UserName), DateTime.Now.AddDays(7)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("FirstName"), encrypt.Encrypt(user.FirstName), DateTime.Now.AddMinutes(60)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("LastName"), encrypt.Encrypt(user.LastName), DateTime.Now.AddMinutes(60)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("CompanyID"), encrypt.Encrypt(user.CompanyID + ""), DateTime.Now.AddMinutes(60)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UserType"), encrypt.Encrypt(user.UserType), DateTime.Now.AddMinutes(60)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("ExpireTime"), DateTime.Now.ToUniversalTime().AddMinutes(30).ToString(), DateTime.Now.AddMinutes(30)); UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("UtcTimeStamp"), (DateTime.UtcNow.AddMinutes(30) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds.ToString(), DateTime.Now.AddMinutes(30)); if (remember) { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), encrypt.Encrypt(password), DateTime.Now.AddDays(7)); } else { UtilFactory.Helpers.CookieHelper.Add(encrypt.Encrypt("Login_Password_"), string.Empty, DateTime.Now.AddSeconds(1)); } } IdentityContext.UserID = user.ID; IdentityContext.CompanyID = user.CompanyID; }
//public static List<C_ORGANIZE_TREE> GetWorkerTree(int id) //{ // using (MainDataContext dbContext = new MainDataContext()) // { // List<C_ORGANIZE_TREE> listTree = new List<C_ORGANIZE_TREE>(); // var list = from ra in dbContext.B_WORKER_ORGANIZATION // join r in dbContext.B_WORKER on ra.WorkerID equals r.ID // where ra.OrgID == id // select new // { // OrgID = ra.OrgID, // WorkerID = ra.WorkerID, // WorkerName = r.Name, // }; // foreach (var td in list) // { // C_ORGANIZE_TREE lw = new C_ORGANIZE_TREE(); // lw.id = td.WorkerID.ToString(); // lw.text = td.WorkerName; // lw.ParentID = td.OrgID.ToString(); // listTree.Add(lw); // } // return listTree; // } //} public static int Save(B_WORKER entity) { using (MainDataContext dbContext = new MainDataContext()) { using (MainDataContext dsContext = new MainDataContext(AppConfig.ConnectionStringDispatch)) { StringBuilder sb = new StringBuilder(); List <SqlParameter> paramArray = new List <SqlParameter>(); try { //人员 if (dbContext.B_WORKER.Count(t => t.ID == entity.ID) == 0) { //var list = from a in dbContext.B_WORKER select a.ID; //long total = list.LongCount(); //if (total == 0) //{ // entity.ID = 1; //} //else //{ // entity.ID = dbContext.B_WORKER.Max(a => a.ID) + 1; //} IApplicationContext ctx = ContextRegistry.GetContext(); IEncrypt encrypt = ctx["Encrypt"] as IEncrypt; entity.PassWord = encrypt.Encrypt(entity.ID, entity.PassWord); dbContext.B_WORKER.InsertOnSubmit(entity); } else { B_WORKER worker = dbContext.B_WORKER.Single(t => t.ID == entity.ID); worker.LoginName = entity.LoginName; worker.Name = entity.Name; worker.Sex = entity.Sex; worker.EntryDate = entity.EntryDate; worker.TitleTechnicalID = entity.TitleTechnicalID; worker.IsActive = entity.IsActive; worker.IsQuota = entity.IsQuota; worker.Mobile = entity.Mobile; worker.Tel = entity.Tel; worker.IsAllowInternetAccess = entity.IsAllowInternetAccess; worker.JobLevel = entity.JobLevel; } //调度台TPerson List <B_WORKER_ROLE> listWorkerRole = dbContext.B_WORKER_ROLE.Where(t => t.WorkerID == entity.ID && t.EmpNo != null && t.EmpNo != "").ToList(); foreach (B_WORKER_ROLE workerRole in listWorkerRole) { TPerson person = dsContext.TPerson.FirstOrDefault(t => t.工号 == workerRole.EmpNo); person.通话号码 = entity.Tel ?? string.Empty; person.短信号码 = entity.Mobile ?? string.Empty; person.是否有效 = entity.IsActive == "Y" ? true : false; person.姓名 = entity.Name; } dbContext.SubmitChanges(); dsContext.SubmitChanges(); return(entity.ID); } catch (Exception ex) { Log4Net.LogError("Save Worker", ex.Message); return(-1); } } } }
public void ProcessRequest(HttpContext context) { int eventID; if (int.TryParse(context.Request.Form["id"], out eventID)) { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string strUserID = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("LoginUserID"))); if (string.IsNullOrEmpty(strUserID)) { context.Response.Write("0"); } int userID = int.Parse(strUserID); EventEntity entity = new EventsApplication().GetEventInfo(eventID); if (entity == null || entity.CreatedBy != userID) { context.Response.Write("0"); } if (new EventsApplication().Delete(eventID, entity.FromDay.Date)) { context.Response.Write("1"); } else { context.Response.Write("0"); } } else { context.Response.Write("0"); } }