/// <summary> /// 把邮件UserInfo转换为数据库实体 /// </summary> /// <param name="user"></param> /// <returns></returns> public static HMail.MailEntity.UserInfo ConvertToMailEntity(HXMail.Model.UserInfo user) { if (user == null) { throw new ArgumentNullException("user"); } if (user.IsEmpty()) { return(null); } try { HMail.MailEntity.UserInfo userInfo = new HMail.MailEntity.UserInfo(); userInfo.EmailAddress = user.EmailAddress; userInfo.Password = EncryptHelper.HXMailDecrypt(user.Password); userInfo.PopAddress = user.PopAddress; userInfo.SmtpAddress = user.SmtpAddress; userInfo.PopPort = user.PopPort; userInfo.SmtpPort = user.SmtpPort; userInfo.UserName = user.EmailAddress.Split('@')[0]; return(userInfo); } catch (Exception e) { throw e; } }
private void button1_Click(object sender, EventArgs e) { if (currUser == null) currUser = allUser[0]; DownLoadMails f = new DownLoadMails(); f.FormClosed += new FormClosedEventHandler((object o, FormClosedEventArgs exc) => { this.Enabled = true; }); this.Enabled = false; f.Show(); f.Activate(); }
public int CreateUser(UserInfo User) { int ret = 0; try { User.Password = HXMail.Common.EncryptHelper.HXMailEncrypt(User.Password); if (userService.GetByUserAndPass(User.EmailAddress, User.Password) != null) return 2; ret = userService.Insert(User); Common.FileExcute.FolderCreate(Common.PathInfo.GetUserAttachmentDir(User.EmailAddress)); Common.FileExcute.FolderCreate(Common.PathInfo.GetUserErrorLogDir(User.EmailAddress)); Common.FileExcute.FolderCreate(Common.PathInfo.GetUserTempDir(User.EmailAddress)); if (ret == 1) OnCreatedUserEvent(); } catch (Exception e) { OnCreateUserErrorEvent(e); } return ret; }
private void button1_Create_Click(object sender, EventArgs e) { if (!ValiInput()) return; UserInfo userInfo = new UserInfo(); userInfo.EmailAddress = textBox1.Text; userInfo.UserName = textBox5.Text; userInfo.Password = textBox2.Text; userInfo.PopAddress = textBox4.Text; userInfo.SmtpAddress = textBox3.Text; userInfo.PopPort = int.Parse(textBox7.Text); userInfo.SmtpPort = int.Parse(textBox6.Text); userInfo.CreateDate = DateTime.Now; UserManage userMng = new UserManage(); userMng.OnCreateUserErrorEvent += new UserManage.CreateUserErrorHandler((Exception ex) => { Common.AppLog.SysLog(ex.ToString()); MessageBox.Show(LanguageSelect.getResc("CreateUserError")); }); userMng.OnCreatedUserEvent += new UserManage.CreatedUserHandler(() => { Common.AppLog.SysLog(string.Format(LanguageSelect.getResc("SysUserCreate"),userInfo.EmailAddress)); }); switch (userMng.CreateUser(userInfo)) { case 1: MessageBox.Show(LanguageSelect.getResc("CreateUserSuccess")); AppMain.currUser = userInfo; DownLoadMails f = new DownLoadMails(); f.Show(); f.Activate(); this.Close(); break; case 2: MessageBox.Show(LanguageSelect.getResc("RepeatUser")); break; } }
private void Form1_Load(object sender, EventArgs e) { base._SetLanguage(this); HXMail.App_Code.HotKey.RegisterHotKey(this.Handle, 100100, App_Code.HotKey.KeyModifiers.Ctrl, Keys.X); this.listBox1.ItemHeight = 30; this.listBox1.Font = new Font(new FontFamily("宋体"), 10); IContentManage contentMng = new ContentManage(); StringBuilder sb = new StringBuilder(); this.listBox1.Click += new EventHandler((object obj, EventArgs ev) => { IList<ContentInfo> all = contentMng.GetByMailId((int)allMail[this.listBox1.SelectedIndex].Id); foreach (ContentInfo v in all) { sb.Append(v.Content); } try { webBrowser1.Document.InvokeScript("removeEditor"); webBrowser1.Document.Body.Style = string.Format("height:{1};width:{0}", webBrowser1.Width, webBrowser1.Height); webBrowser1.Document.GetElementById("content").Style = string.Format("height:{1};width:{0}", webBrowser1.Width, webBrowser1.Height); webBrowser1.Document.GetElementById("content").SetAttribute("value", sb.ToString()); webBrowser1.Document.InvokeScript("showEditor"); } catch (Exception ex) { throw ex; } sb.Clear(); }); this.listView1.DoubleClick += new EventHandler((object obj, EventArgs ex) => { currUser = allUser[((ListView)obj).SelectedItems[0].Index]; this.listBox1.Items.Clear(); thread1 = new System.Threading.Thread(new System.Threading.ThreadStart(() => { LoadMail(); })); thread1.Start(); }); LoadUser(); }
private SQLiteParameter[] Parameter(UserInfo User) { return new SQLiteParameter[] { new SQLiteParameter("@Id",User.Id), new SQLiteParameter("@UserName",User.UserName), new SQLiteParameter("@Password",User.Password), new SQLiteParameter("@EmailAddress",User.EmailAddress), new SQLiteParameter("@PopAddress",User.PopAddress), new SQLiteParameter("@SmtpAddress",User.SmtpAddress), new SQLiteParameter("@PopPort",User.PopPort), new SQLiteParameter("@SmtpPort",User.SmtpPort), new SQLiteParameter("@CreateDate",User.CreateDate), new SQLiteParameter("@Del",User.Del) }; }
public int UpDate(UserInfo User) { try { return SqliteHelper.ExecuteNoQuery(System.Data.CommandType.Text, "update hm_user set UserName = @UserName,Password = @Password,EmailAddress = @EmailAddress,PopAddress = @PopAddress,SmtpAddress = @SmtpAddress,PopPort = @PopPort,SmtpPort = @SmtpPort,CreateDate = @CreateDate,Del = @Del where Id = @Id", Parameter(User)); } catch { return -1; } }
public int Insert(UserInfo User) { try { return SqliteHelper.ExecuteNoQuery(System.Data.CommandType.Text, "insert into hm_user (UserName,Password,EmailAddress,PopAddress,SmtpAddress,PopPort,SmtpPort,CreateDate,Del)values(@UserName,@Password,@EmailAddress,@PopAddress,@SmtpAddress,@PopPort,@SmtpPort,@CreateDate,@Del)", Parameter(User)); } catch { return -1; } }