コード例 #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());
                }
            }
            //
        }
コード例 #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);
 }
コード例 #3
0
        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;
                }
            }
        }
コード例 #4
0
        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
        }
コード例 #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);
 }
コード例 #6
0
ファイル: writeLog.cs プロジェクト: zimengyu1992/WorkLogForm
        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();
        }