Esempio n. 1
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();
        }
        private void NewMessageWindow_Load(object sender, EventArgs e)
        {
            if (this.formLocation != null)
            {
                this.Location = formLocation;
            }

            if (loglist != null && loglist.Count > 0)
            {
                loglist.Reverse();
                foreach (KjqbService.LogInService ll in Loglist)
                {
                    StaffLog ss = new StaffLog();
                    ss = (StaffLog)baseService.loadEntity(ss, ll.LogId);

                    LinkLabel l1 = new LinkLabel();
                    l1.Text = ss.Staff.KuName + "分享给您的日志";
                    l1.Width = this.flowLayoutPanel1.Width - 10;
                    l1.Height = 30;
                    l1.Top = 10;
                    l1.Tag = ll;
                    l1.Click += l1_Click;
                    l1.Parent = flowLayoutPanel1;
                    l1.DoubleClick +=l1_DoubleClick;
                }
            }

            if (schedulelist != null && schedulelist.Count > 0)
            {
                schedulelist.Reverse();
                foreach (KjqbService.ScheduleInService ll in schedulelist)
                {
                    StaffSchedule ss = new StaffSchedule();
                    //string sql = "select u from StaffLog u where u.Id = " + ll.LogId;
                    ss = (StaffSchedule)baseService.loadEntity(ss, ll.ScheduleId);

                    LinkLabel l1 = new LinkLabel();
                    l1.Width = this.flowLayoutPanel1.Width - 10;
                    l1.Height = 30;
                    l1.Top = 10;
                    l1.Tag = ll;
                    l1.Click += l1_Click;
                    l1.Parent = flowLayoutPanel1;
                    l1.DoubleClick+=l1_DoubleClick;
                    if(ss.Staff.Id  == ss.ArrangeMan.Id)
                    {
                        l1.Text = ss.Staff.KuName + "分享给您的日程";

                    }
                    else if (ss.Staff.Id != ss.ArrangeMan.Id)
                    {
                        l1.Text = ss.ArrangeMan.KuName + "给您安排的日程";
                    }

                }
            }

            if (commentList != null && commentList.Count > 0)
            {
                commentList.Reverse();
                foreach (KjqbService.CommentInService ll in commentList)
                {
                    StaffLog ss = new StaffLog();
                    //string sql = "select u from StaffLog u where u.Id = " + ll.LogId;
                    ss = (StaffLog)baseService.loadEntity(ss, ll.LogId);

                    LinkLabel l1 = new LinkLabel();
                    l1.Text = ll.CommentUserName + "评论了您的日志";
                    l1.Width = this.flowLayoutPanel1.Width - 10;
                    l1.Height = 30;
                    l1.Top = 10;
                    l1.Tag = ll;
                    l1.Click += l1_Click;
                    l1.DoubleClick+=l1_DoubleClick;
                    l1.Parent = flowLayoutPanel1;
                }
            }

            if(tfmlist != null && tfmlist.Count >0)
            {
                tfmlist.Reverse();
                foreach(KjqbService.TimeArrangeForManagerInService tfm in tfmlist)
                {
                    TimeArrangeForManager tt = new TimeArrangeForManager();
                    tt = (TimeArrangeForManager)baseService.loadEntity(tt,tfm.TimeArrangeForManagerId);

                    LinkLabel l1 = new LinkLabel();
                    l1.Width = this.flowLayoutPanel1.Width - 10;
                    l1.Height = 30;
                    l1.Top = 10;
                    l1.Tag = tfm;
                    l1.Click += l1_Click;
                    l1.DoubleClick += l1_DoubleClick;
                    l1.Parent = flowLayoutPanel1;
                    DateTime dt = new DateTime(tt.TimeMonth);
                    if (tfm.ExamineOrExamineresult == 0)
                    {
                        l1.Text = dt.ToString("yyyy年MM月")+" "+"排班待您审核";
                    }
                    if (tfm.ExamineOrExamineresult == 1)
                    {
                        l1.Text = dt.ToString("yyyy年MM月") + " " + "排班审核通过";
                    }
                    if (tfm.ExamineOrExamineresult == 2)
                    {
                        l1.Text = dt.ToString("yyyy年MM月") + " " + "排班审核未通过";
                    }
                    if (tfm.ExamineOrExamineresult == 3)
                    {
                        l1.Text = "请您安排"+dt.ToString("yyyy年MM月")+"的值班";
                    }

                }

            }

            if (levlist != null && levlist.Count > 0)
            {
                levlist.Reverse();
                foreach (KjqbService.LeaveInService tfm in levlist)
                {
                    LeaveManage tt = new LeaveManage();
                    tt = (LeaveManage)baseService.loadEntity(tt, tfm.LeaveId);

                    LinkLabel l1 = new LinkLabel();
                    l1.Width = this.flowLayoutPanel1.Width - 10;
                    l1.Height = 30;
                    l1.Top = 10;
                    l1.Tag = tfm;
                    l1.Click += l1_Click;
                    l1.DoubleClick +=l1_DoubleClick;
                    l1.Parent = flowLayoutPanel1;

                    if (tfm.ExamineOrExamineresult == 0)
                    {
                        l1.Text = tt.Ku_Id.KuName + "请假申请待您审核";
                    }
                    DateTime dt1 = new DateTime(tt.StartTime);
                    DateTime dt2 = new DateTime(tt.EndTime);

                    if (tfm.ExamineOrExamineresult == 1)
                    {
                        l1.Text = "您提交的"+tt.LeaveType+"申请审核通过";
                    }
                    if (tfm.ExamineOrExamineresult == 2)
                    {
                        l1.Text = "您提交的" + tt.LeaveType + "申请审核未通过";
                    }

                }
            }
            if (buslist != null && buslist.Count > 0)
            {
                buslist.Reverse();
                foreach (KjqbService.BusinessService tfm in buslist)
                {
                    // tt = new LeaveManage();
                    //tt = (LeaveManage)baseService.loadEntity(tt, tfm.LeaveId);

                    LinkLabel l1 = new LinkLabel();
                    l1.Width = this.flowLayoutPanel1.Width - 10;
                    l1.Height = 30;
                    l1.Top = 10;
                    l1.Tag = tfm;
                    l1.Click += l1_Click;
                    l1.DoubleClick += l1_DoubleClick;
                    l1.Parent = flowLayoutPanel1;

                    if (tfm.Type == 0)
                    {
                        l1.Text = "您有一条出差信息待审批";
                    }
                    else if(tfm.Type == 1)
                    {
                          l1.Text = "您的出差申请被退回";

                    }
                    else if(tfm.Type == 2)
                    {
                        l1.Text = "您的出差申请被撤销";
                    }
                    else if(tfm.Type == 3)
                    {
                        l1.Text = "您的出差申请审核通过";
                    }

                }
            }
        }
        void l1_Click(object sender, EventArgs e)
        {
            LinkLabel l1 = (LinkLabel)sender;

            if (l1.Tag.GetType() == typeof(KjqbService.LogInService))
            {
                KjqbService.LogInService ll = (KjqbService.LogInService)l1.Tag;
                StaffLog ss = new StaffLog();
                ss = (StaffLog)baseService.loadEntity(ss, ll.LogId);
                if (ss.State == 0)
                {
                    writeLog wl = new writeLog();
                    wl.User = ss.Staff;
                    wl.LogDate = new DateTime(ss.WriteTime);
                    wl.IsComment = true;
                    wl.CommentPersonName = this.User.KuName;
                    wl.ShowDialog();
                }
                else
                {
                    MessageBox.Show("该篇日志作者已经删除");
                }

            }
            else if (l1.Tag.GetType() == typeof(KjqbService.CommentInService))
            {
                KjqbService.CommentInService ll = (KjqbService.CommentInService)l1.Tag;
                StaffLog ss = new StaffLog();
                ss = (StaffLog)baseService.loadEntity(ss, ll.LogId);
                if (ss.State == 0)
                {
                    writeLog wl = new writeLog();
                    wl.User = ss.Staff;
                    wl.LogDate = new DateTime(ss.WriteTime);
                    wl.IsComment = true;
                    wl.CommentPersonName = this.User.KuName;
                    wl.ShowDialog();
                }
                else
                {
                    MessageBox.Show("该篇日志作者已经删除");
                }
            }
            else if (l1.Tag.GetType() == typeof(KjqbService.ScheduleInService))
            {
                KjqbService.ScheduleInService ll = (KjqbService.ScheduleInService)l1.Tag;
                StaffSchedule ss = new StaffSchedule();
                ss = (StaffSchedule)baseService.loadEntity(ss, ll.ScheduleId);
                DateTime dt = new DateTime(ss.ScheduleTime);
                MessageBox.Show(dt.ToString("yyyy-MM-dd HH:mm:ss") + " :" + ss.Content);
            }
            else if (l1.Tag.GetType() == typeof(KjqbService.LeaveInService))
            {
                //KjqbService.LeaveInService ll = (KjqbService.LeaveInService)l1.Tag;
                //LeaveManage tt = new LeaveManage();
                //tt = (LeaveManage)baseService.loadEntity(tt, ll.LeaveId);

                if (leaveWindow == null || leaveWindow.IsDisposed)
                {
                    leaveWindow = new Leave();
                    leaveWindow.Leaveman = this.user;
                    leaveWindow.Role = role;
                }
                if (!leaveWindow.Created)
                {
                    leaveWindow.Show();
                }
                else
                {
                    leaveWindow.WindowState = FormWindowState.Normal;
                    leaveWindow.Focus();
                }
            }
            else if (l1.Tag.GetType() == typeof(KjqbService.BusinessService))
            {
                if (businessManagement == null || businessManagement.IsDisposed)
                {
                    businessManagement = new BusinessManagement();
                }
                if (!businessManagement.Created)
                {
                    businessManagement.User = this.User;
                    businessManagement.Role = this.Role;
                    businessManagement.Show();
                }
                else
                {
                    businessManagement.WindowState = FormWindowState.Normal;
                    businessManagement.Focus();
                }
            }
        }
 bool IsInLoglist(StaffLog ss)
 {
     foreach (KjqbService.LogInService l in loglist)
     {
         if (l.LogId == ss.Id)
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 5
0
        void item_ContentClicked(object sender, EventArgs e)
        {
            Label p = (Label)sender;
            long logid = long.Parse(p.Parent.Tag.ToString());
            p.Parent.Cursor = Cursors.WaitCursor;
            StaffLog sl = new StaffLog();
            baseService.loadEntity(sl, logid);
            writeLog log = new writeLog();
            log.IsComment = true;
            log.User = sl.Staff;
            log.CommentPersonName = User.KuName;
            log.LogDate = new DateTime(sl.WriteTime);
            log.ShowDialog();
            panelOfLogCommentMessageItem item = (panelOfLogCommentMessageItem)p.Parent;
            this.panelOfLogCommentMessage1.RemoveCommentItem(item);

            p.Parent.Cursor = Cursors.Hand;
        }
        private void share_dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 5)
            {
                StaffLog thelog = new StaffLog();
                object[] sf = (object[])share_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag;
                thelog = (StaffLog)baseService.loadEntity(thelog, Convert.ToInt64(sf[0].ToString()));

                writeLog wl = new writeLog();
                wl.User = thelog.Staff;
                wl.LogDate = new DateTime(thelog.WriteTime);
                wl.IsComment = true;
                wl.CommentPersonName = this.user.KuName;
                wl.ShowDialog();
            }
        }