Beispiel #1
0
        /// <summary>
        /// 记住密码 自动填充效果 加载头像
        /// </summary>
        private void initialData()
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new LoadDele(initialData));
            }
            else
            {
                this.pictureBoxOfHeadIcon.BackgroundImage = WorkLogForm.Properties.Resources.AutoIconBigWhite;

                if (IniReadAndWrite.IniReadValue("temp", "rem").Equals(CommonStaticParameter.YES))
                {
                    string un   = Securit.DeDES(IniReadAndWrite.IniReadValue("temp", "un"));
                    string pwd  = Securit.DeDES(IniReadAndWrite.IniReadValue("temp", "pw"));
                    string myid = IniReadAndWrite.IniReadValue("temp", "myid");
                    this.pictureBoxOfRememberPwd.BackgroundImage = WorkLogForm.Properties.Resources.Checked;
                    #region 加载自己的头像
                    string address = CommonStaticParameter.ICONS + @"\" + myid + ".png";
                    if (File.Exists(address))
                    {
                        //string filename = address;//如果不是png类型,须转换
                        //System.Drawing.Bitmap ybitmap = new System.Drawing.Bitmap(filename);

                        this.pictureBoxOfHeadIcon.BackgroundImage = CommonClass.ReadPictureFromStream.GetFile(address);//ybitmap;
                    }

                    #endregion
                    //rem_checkBox.Checked = true;
                    textBox1.Text = un != null && un != "" ? un : "请输入用户名";
                    if (pwd != null && pwd != "")
                    {
                        this.textBox2.UseSystemPasswordChar = true;
                        this.textBox2.Font = new Font(new FontFamily("微软雅黑"), 12);
                        this.textBox2.Font = new Font(new FontFamily("宋体"), 12);
                        this.textBox2.Text = pwd;
                    }
                    else
                    {
                        this.textBox2.IsPasswordChar = false;
                        this.textBox2.Font           = new Font(new FontFamily("微软雅黑"), 12);
                        this.textBox2.Font           = new Font(new FontFamily("宋体"), 12);
                        this.textBox2.Text           = "请输入密码";
                    }
                }
                if (IniReadAndWrite.IniReadValue("temp", "auto").Equals(CommonStaticParameter.YES))
                {
                    pictureBoxofAutoLogin.BackgroundImage = WorkLogForm.Properties.Resources.Checked;
                    button1_Click(pictureBox1, new EventArgs());
                }
            }
            //
        }
Beispiel #2
0
 public static Configuration getConfiguration()
 {
     if (cfg == null)
     {
         cfg = new Configuration();
         string ip  = IniReadAndWrite.IniReadValue("connect", "ip");
         string id  = IniReadAndWrite.IniReadValue("connect", "id");
         string pwd = IniReadAndWrite.IniReadValue("connect", "pwd");
         string db  = IniReadAndWrite.IniReadValue("connect", "db");
         cfg.SetProperty("connection.connection_string", "UID=" + Securit.DeDES(id) + ";PWD=" + Securit.DeDES(pwd) + ";Database=" + Securit.DeDES(db) + ";server=" + Securit.DeDES(ip));
         cfg.AddAssembly("ClassLibrary");
     }
     return(cfg);
 }
        private void SaveAndUploadHeadPic()
        {
            if (this.pb_photo_cut.BackgroundImage != null)
            {
                Bitmap savpic        = new Bitmap(this.pb_photo_cut.BackgroundImage);
                string addressonlyid = CommonStaticParameter.ICONS + @"\" + this.user.Id.ToString() + ".png";
                string address       = CommonStaticParameter.ICONS + @"\" + this.user.Id.ToString() + "__" + DateTime.Now.Ticks.ToString() + ".png";

                if (!Directory.Exists(CommonStaticParameter.ICONS))
                {
                    Directory.CreateDirectory(CommonStaticParameter.ICONS);
                }

                if (File.Exists(addressonlyid))
                {
                    FileInfo oldfi = new FileInfo(addressonlyid);
                    oldfi.Delete();
                }

                savpic.Save(addressonlyid); //保存临时文件

                //ToRoundPic(address).Save(address);
                if (fileop == null)
                {
                    string _ip  = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "ip"));
                    string _id  = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "id"));
                    string _pwd = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "pwd"));
                    fileop = new FileUpDown(_ip, _id, _pwd);
                }
                try
                {
                    fileop.IsConnectSucceed(this.user.Id.ToString() + ".png", "Iconpics");
                    bool isxe = fileop.DirectoryExist(this.user.Id.ToString() + ".png", "Iconpics");
                    if (isxe)
                    {
                        fileop.DeleteFileName(this.user.Id.ToString() + ".png", "Iconpics");
                    }
                    fileop.Upload(addressonlyid, "Iconpics");
                    fileop.Rename(addressonlyid, this.user.Id.ToString() + ".png", "Iconpics");
                    themain.RefreshHeaderPic();
                    MessageBox.Show("上传成功!");
                }
                catch (Exception exp)
                {
                    MessageBox.Show("上传失败" + exp.ToString());
                    return;
                }
            }
        }
        private void onlineUpDate()
        {
            #region 在线更新
            string thePreUpdateDate = "";
            try
            {
                string     _ip        = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "ip"));
                string     _id        = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "id"));
                string     _pwd       = Securit.DeDES(FileReadAndWrite.IniReadValue("ftpfile", "pwd"));
                FileUpDown fileUpDown = new FileUpDown(_ip, _id, _pwd);

                string theLastsUpdateVersionNumber = GetTheUpdateVersionNum(System.Windows.Forms.Application.StartupPath);//上次的版本号


                fileUpDown.Download(CommonStaticParameter.TEMP, "UpdateConfig.xml", "WorkLog");

                thePreUpdateDate = GetTheUpdateVersionNum(CommonStaticParameter.TEMP);//这次的版本号
                if (thePreUpdateDate != "")
                {
                    //如果客户端将升级的应用程序的更新版本号与服务器上的不一致则进行更新
                    if (thePreUpdateDate != theLastsUpdateVersionNumber)
                    {
                        MessageBox.Show("有可更新的版本,程序将关闭…", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        {
                            this.Close();
                            themain.DialogResult = DialogResult.OK;
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("当前版本为最新版" + thePreUpdateDate + ",无需更新");
                        return;
                    }
                }
                else
                {
                    onlineUpDate();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("程序出错 原因:" + ex.Message.ToString());
            }
            #endregion
        }
Beispiel #5
0
 public static SqlConnection getSqlConnection()
 {
     if (connection == null || connection.State == ConnectionState.Closed)
     {
         string ip  = IniReadAndWrite.IniReadValue("connect", "ip");
         string id  = IniReadAndWrite.IniReadValue("connect", "id");
         string pwd = IniReadAndWrite.IniReadValue("connect", "pwd");
         string db  = IniReadAndWrite.IniReadValue("connect", "db");
         connection = new SqlConnection("UID=" + Securit.DeDES(id) + ";PWD=" + Securit.DeDES(pwd) + ";Database=" + Securit.DeDES(db) + ";server=" + Securit.DeDES(ip));
     }
     if (connection.State != ConnectionState.Open)
     {
         try
         {
             connection.Open();
         }
         catch
         {
             throw;
         }
     }
     return(connection);
 }
Beispiel #6
0
        /// <summary>
        /// 登录函数 其中包括查库操作
        /// </summary>
        private string loginMethod()
        {
            try
            {
                #region 将用户信息存入临时文件
                if (pictureBoxOfRememberPwd.BackgroundImage != null)
                {
                    IniReadAndWrite.IniWriteValue("temp", "rem", CommonStaticParameter.YES);
                }
                else
                {
                    IniReadAndWrite.IniWriteValue("temp", "rem", CommonStaticParameter.NO);
                }
                if (pictureBoxofAutoLogin.BackgroundImage != null)
                {
                    IniReadAndWrite.IniWriteValue("temp", "auto", CommonStaticParameter.YES);
                }
                else
                {
                    IniReadAndWrite.IniWriteValue("temp", "auto", CommonStaticParameter.NO);
                }
                IniReadAndWrite.IniWriteValue("temp", "un", Securit.DES(textBox1.Text.Trim()));
                IniReadAndWrite.IniWriteValue("temp", "pw", Securit.DES(textBox2.Text.Trim()));
                #endregion

                //判断是否加密成功
                IList pwd = baseService.ExecuteSQL("select right(sys.fn_VarBinToHexStr(hashbytes('MD5', '" + textBox2.Text.Trim() + "')),32)");     // 数据库属性,跟具体表无关
                if (pwd == null || pwd.Count <= 0)
                {
                    return("登录异常!");
                }
                object[] pwdArray = (object[])pwd[0];
                //因为是共用表 选择是工作小秘书相关的角色
                IList userList = baseService.loadEntityList("select u from WkTUser u right join u.UserRole role where role.KrDESC='工作小秘书角色' and u.KuLid='" + textBox1.Text.Trim() + "' and u.KuPassWD='" + pwdArray[0] + "'");
                if (userList == null || userList.Count <= 0)
                {
                    return("用户名或密码错误!");
                }
                else if (userList.Count > 1)
                {
                    return("用户异常,请联系管理员!");
                }
                else
                {
                    WkTUser u = (WkTUser)userList[0];
                    foreach (WkTRole r in u.UserRole)
                    {
                        if (r.KrDESC.Trim().Equals("工作小秘书角色"))    //是本系统的用户角色
                        {
                            role = r;
                        }
                    }
                    this.User = (WkTUser)userList[0];
                    IniReadAndWrite.IniWriteValue("temp", "myid", User.Id.ToString());

                    return("登录成功!");
                }

                // }
            }
            catch
            {
                return("未能与服务器建立连接……");
            }
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            #region   图片并生成新html
            Regex           r  = new Regex("<IMG[\\s\\S]*?>");
            MatchCollection mc = r.Matches(htmlEditor1.BodyInnerHTML);
            ///string[] mc = CommonClass.HtmlUtility.GetElementsByTagName(htmlEditor1.BodyInnerHTML, "IMG");

            String html     = htmlEditor1.BodyInnerHTML;
            Uri    endpoint = new Uri(Securit.DeDES(IniReadAndWrite.IniReadValue("fileManage", "filePath")));
            for (int i = 0; i < mc.Count; i++)
            {
                if (mc[i].Value.Contains("src=\"http://"))
                {
                    continue;
                }
                using (WebClient myWebClient = new WebClient())
                {
                    myWebClient.UploadFileCompleted += new UploadFileCompletedEventHandler(uploadCompleted);
                    String imgHtml = mc[i].Value;

                    string inPath = HtmlUtility.GetTitleContent(imgHtml, "img", "src");  //imgHtml.Substring(startIndex, imgHtml.LastIndexOf("\"") - startIndex);

                    try
                    {
                        String newName  = user.Id + "_" + DateTime.Now.Ticks + inPath.Substring(inPath.LastIndexOf("."));
                        String tempPath = Application.StartupPath.ToString() + "\\temp\\" + newName;
                        File.Copy(inPath, tempPath, true);

                        myWebClient.UploadFileAsync(endpoint, tempPath);

                        String newString2 = imgHtml.Remove(imgHtml.IndexOf("src"), inPath.Length + 6);//.Remove(imgHtml.LastIndexOf('>'))+" src=\"" + Securit.DeDES(IniReadAndWrite.IniReadValue("fileManage", "savePath")) + newName + "\">";
                        string newString1 = newString2.Remove(newString2.LastIndexOf('>'));
                        string newString  = newString1 + " src=\"" + Securit.DeDES(IniReadAndWrite.IniReadValue("fileManage", "savePath")) + @"LogPic\" + newName + "\">";
                        //html

                        html = html.Replace(mc[i].Value, newString);
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show(exp.ToString());
                        return;
                    }
                }
            }
            #endregion
            StaffLog staffLog = null;
            if (htmlEditor1.Tag == null)
            {
                staffLog = new StaffLog();
            }
            else if (htmlEditor1.Tag != null)
            {
                staffLog = (StaffLog)htmlEditor1.Tag;
            }
            staffLog.Content      = html;
            staffLog.State        = (int)IEntity.stateEnum.Normal;
            staffLog.WriteTime    = DateTime.Now.Ticks;
            staffLog.TimeStamp    = DateTime.Now.Ticks;
            staffLog.Staff        = user;
            staffLog.SharedStaffs = sharedUser;

            try
            {
                if (staffLog.Id == 0)
                {
                    object be = baseService.saveEntity(staffLog);
                    staffLog.Id = int.Parse(be.ToString());
                }
                else if (staffLog.Id != 0)
                {
                    baseService.SaveOrUpdateEntity(staffLog);
                }

                #region 向服务中发送数据

                try
                {
                    KjqbService.Service1Client ser = new KjqbService.Service1Client();
                    if (sharedUser != null && sharedUser.Count > 0)
                    {
                        foreach (WkTUser u in sharedUser)
                        {
                            KjqbService.LogInService ll = new KjqbService.LogInService();
                            ll.LogId       = staffLog.Id;
                            ll.WriteUserId = this.user.Id;
                            ll.ShareUserId = u.Id;
                            ll.TimeStamp   = DateTime.Now.Ticks;
                            ser.SaveInLogListInService(ll);
                        }
                    }
                }
                catch
                {
                }
                #endregion
            }
            catch
            {
                MessageBox.Show("保存失败!");
                return;
            }
            MessageBox.Show("保存成功!");

            this.DialogResult = DialogResult.OK;
            this.Close();
        }