private void AddMessage(Message message)
 {
     Block[] blocks = message.MessageBlocks;
     if (blocks != null && blocks.Length > 0)
     {
         Staff staff = this.dataService.GetStaff((long)((ulong)Jid.GetUid(message.FromJid)));
         if (staff != null)
         {
             if (!string.IsNullOrEmpty(message.Url) && !string.IsNullOrEmpty(message.Icon) && !string.IsNullOrEmpty(message.FileName) && staff.Uid == this.sessionService.Uid)
             {
                 System.IO.FileInfo file = new System.IO.FileInfo(message.FileName);
                 OpenFileControl openFile = new OpenFileControl(new FileItem(file)
                 {
                     FileName = message.Url + message.FileName,
                     IconBase64 = message.Icon
                 }, true);
                 if (openFile != null && !string.IsNullOrEmpty(staff.Name))
                 {
                     Paragraph p = new Paragraph();
                     FlowDocument doc = this.ViewMessageBoxViewer.Document;
                     TableRow tableRow = new TableRow();
                     TableCell tableCell = new TableCell();
                     tableRow.Cells.Add(tableCell);
                     tableCell.Blocks.Add(this.GetNameInfo(staff.Name, message.CreateTime, staff.Uid == this.sessionService.Uid));
                     p.Inlines.Add(openFile);
                     doc.Blocks.Add(p);
                     tableCell.Blocks.Add(doc.Blocks.LastBlock);
                     this.trgMessageTable.Rows.Add(tableRow);
                 }
             }
             else
             {
                 TableRow tableRow = this.CreateTableRow(message, blocks, staff);
                 this.trgMessageTable.Rows.Add(tableRow);
                 this.ScroolToEnd();
             }
         }
         else
         {
             TableRow tableRow = new TableRow();
             TableCell tableCell = new TableCell();
             tableRow.Cells.Add(tableCell);
             tableCell.Blocks.Add(this.GetNameInfo("此人已离职", message.CreateTime, (long)int.Parse(message.FromJid.Substring(0, message.FromJid.IndexOf("@"))) == this.sessionService.Uid));
             Block[] array = blocks;
             for (int i = 0; i < array.Length; i++)
             {
                 Paragraph block = (Paragraph)array[i];
                 this.SetParagraphStyle(block, message.Style);
                 tableCell.Blocks.Add(block);
             }
             this.trgMessageTable.Rows.Add(tableRow);
         }
     }
     this.DataSelect.Text = message.CreateTime.Substring(0, 10);
 }
 public void AddOpenFileControl(OpenFileControl openFile, string sendeName)
 {
     if (openFile != null && !string.IsNullOrEmpty(sendeName))
     {
         Paragraph p = new Paragraph();
         FlowDocument doc = this.viewMsgBox.Document;
         doc.Blocks.Add(this.GetNameInfo(sendeName, this.sessionService.CalculateSystemTime()));
         p.Inlines.Add(openFile);
         doc.Blocks.Add(p);
     }
 }
 public MsgRecordItem(Message message, Staff staf)
 {
     this.InitializeComponent();
     this.SelStaff = this.dataService.GetStaff(message.Gid);
     if (!string.IsNullOrEmpty(message.Url) && !string.IsNullOrEmpty(message.Icon) && !string.IsNullOrEmpty(message.FileName) && this.SelStaff.Uid == this.sessionService.Uid && this.SelStaff != null)
     {
         System.IO.FileInfo file = new System.IO.FileInfo(message.FileName);
         this.MessageContent.Document.Blocks.Add(this.GetNameInfo(this.sessionService.Name, message.CreateTime, true));
         this.imgHead.Source = this.sessionService.HeaderImage;
         OpenFileControl openFile = new OpenFileControl(new FileItem(file)
         {
             FileName = message.Url + message.FileName,
             IconBase64 = message.Icon
         }, true);
         if (openFile != null && !string.IsNullOrEmpty(this.SelStaff.Name))
         {
             Paragraph p = new Paragraph();
             FlowDocument doc = this.MessageContent.Document;
             p.Inlines.Add(openFile);
             doc.Blocks.Add(p);
         }
         this.staff = this.dataService.GetStaff(long.Parse(message.ToJid));
         this.message = message;
     }
     else
     {
         if (this.SelStaff != null)
         {
             if (message.Gid == this.sessionService.Uid)
             {
                 this.MessageContent.Document.Blocks.Add(this.GetNameInfo(this.sessionService.Name, message.CreateTime, true));
                 this.imgHead.Source = this.sessionService.HeaderImage;
             }
             else
             {
                 this.MessageContent.Document.Blocks.Add(this.GetNameInfo(this.SelStaff.Name, message.CreateTime, false));
                 this.imgHead.Source = this.SelStaff.HeaderImageOnline;
             }
             if (message.MessageBlocks.Length != 0)
             {
                 Block[] messageBlocks = message.MessageBlocks;
                 for (int i = 0; i < messageBlocks.Length; i++)
                 {
                     Paragraph block = (Paragraph)messageBlocks[i];
                     this.SetParagraphStyle(block, message.Style);
                     this.MessageContent.Document.Blocks.Add(block);
                 }
                 this.staff = this.dataService.GetStaff(long.Parse(message.ToJid));
                 this.message = message;
             }
             else
             {
                 this.staff = null;
                 this.message = null;
             }
         }
     }
     this.MouseEvent = true;
     this.InitUI();
 }
 //internal Image imgHead;
 //internal FlowDocumentScrollViewer MessageContent;
 //internal Image imgIsMarked;
 //private bool _contentLoaded;
 public MsgRecordItem(Message message, EntGroup gp)
 {
     this.InitializeComponent();
     Staff fromStaff = this.dataService.GetStaff((long)((ulong)Jid.GetUid(message.FromJid)));
     if (!string.IsNullOrEmpty(message.Url) && !string.IsNullOrEmpty(message.Icon) && !string.IsNullOrEmpty(message.FileName) && fromStaff != null && fromStaff.Uid == this.sessionService.Uid)
     {
         System.IO.FileInfo file = new System.IO.FileInfo(message.FileName);
         this.MessageContent.Document.Blocks.Add(this.GetNameInfo(this.sessionService.Name, message.CreateTime, true));
         this.imgHead.Source = this.sessionService.HeaderImage;
         OpenFileControl openFile = new OpenFileControl(new FileItem(file)
         {
             FileName = message.Url + message.FileName,
             IconBase64 = message.Icon
         }, true);
         if (openFile != null && !string.IsNullOrEmpty(this.sessionService.Name))
         {
             Paragraph p = new Paragraph();
             FlowDocument doc = this.MessageContent.Document;
             p.Inlines.Add(openFile);
             doc.Blocks.Add(p);
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(message.Url) && !string.IsNullOrEmpty(message.Icon) && !string.IsNullOrEmpty(message.FileName) && fromStaff == null)
         {
             System.IO.FileInfo file = new System.IO.FileInfo(message.FileName);
             this.MessageContent.Document.Blocks.Add(this.GetNameInfo("此人已离职", message.CreateTime, true));
             this.imgHead.Source = this.imageService.GetHeader(ImageTypeHeader.Gary48);
             OpenFileControl openFile = new OpenFileControl(new FileItem(file)
             {
                 FileName = message.Url + message.FileName,
                 IconBase64 = message.Icon
             }, true);
             if (openFile != null && !string.IsNullOrEmpty(this.sessionService.Name))
             {
                 Paragraph p = new Paragraph();
                 FlowDocument doc = this.MessageContent.Document;
                 p.Inlines.Add(openFile);
                 doc.Blocks.Add(p);
             }
         }
         else
         {
             if ((long)int.Parse(message.FromJid.Substring(0, message.FromJid.IndexOf("@"))) == this.sessionService.Uid)
             {
                 this.MessageContent.Document.Blocks.Add(this.GetNameInfo(this.sessionService.Name, message.CreateTime, true));
                 this.imgHead.Source = this.sessionService.HeaderImage;
             }
             else
             {
                 if (fromStaff != null)
                 {
                     this.MessageContent.Document.Blocks.Add(this.GetNameInfo(fromStaff.Name, message.CreateTime, false));
                     this.imgHead.Source = fromStaff.HeaderImageOnline;
                 }
                 else
                 {
                     this.MessageContent.Document.Blocks.Add(this.GetNameInfo("此人已离职", message.CreateTime, false));
                     this.imgHead.Source = this.imageService.GetHeader(ImageTypeHeader.Gary48);
                 }
             }
             Block[] messageBlocks = message.MessageBlocks;
             for (int i = 0; i < messageBlocks.Length; i++)
             {
                 Paragraph block = (Paragraph)messageBlocks[i];
                 this.SetParagraphStyle(block, message.Style);
                 this.MessageContent.Document.Blocks.Add(block);
             }
         }
     }
     this.message = message;
     this.group = gp;
     this.MouseEvent = true;
     this.InitUI();
 }
 private void EndEventHandle(string id, bool isStop)
 {
     try
     {
         if (!isStop)
         {
             if (this.staff != null)
             {
                 if (this.fileInfo != null)
                 {
                     string staffEndFileUpload = "文件" + this.fileName + "发送成功";
                     this.viewModel.SendOffLineFile(this.sessionService.Uid, this.staff.Uid, id, this.IconBase64, this.fileName, this.fileInfo.Length);
                     this.staffChatTab.ChatComponent.AddMessageNotice(staffEndFileUpload);
                 }
                 else
                 {
                     string staffEndFileDownload = "成功接收文件" + this.fileName;
                     this.staffChatTab.ChatComponent.AddMessageNotice(staffEndFileDownload);
                     if (this.SaveDirectory == null)
                     {
                         if (this.fileDir != null)
                         {
                             this.viewModel.SendStaffDownLoadNotice(this.sessionService.Jid, this.staff.Jid, this.fileName.Trim(), "", 2, this.IconBase64, this.fileName, this.fileDir);
                         }
                     }
                     else
                     {
                         this.viewModel.SendStaffDownLoadNotice(this.sessionService.Jid, this.staff.Jid, this.fileName.Trim(), "", 2, this.IconBase64, this.fileName, this.SaveDirectory);
                         this.SaveDirectory = null;
                     }
                     if (this.item != null)
                     {
                         OpenFileControl openFile = new OpenFileControl(this.item, true);
                         this.staffChatTab.ChatComponent.AddOpenFileControl(openFile, this.staff.Name);
                     }
                 }
             }
             if (this.coopStaff != null)
             {
                 if (this.fileInfo != null)
                 {
                     string staffEndFileUpload = "文件" + this.fileName + "发送成功";
                     this.viewModel.SendCooperationFileNoticeRequest(this.sessionService.Uid, this.coopStaff.Uid, this.coopStaff.Jid, this.coopStaff.UnitedProjectid, id, this.IconBase64, this.fileName, this.fileInfo.Length);
                     this.coopStaffChatTab.ChatComponent.AddMessageNotice(staffEndFileUpload);
                 }
                 else
                 {
                     string staffEndFileDownload = "成功接收文件" + this.fileName;
                     this.coopStaffChatTab.ChatComponent.AddMessageNotice(staffEndFileDownload);
                     if (this.SaveDirectory == null)
                     {
                         if (this.fileDir != null)
                         {
                             this.viewModel.SendCooperationStaffDownLoadNotice(this.sessionService.Jid, this.coopStaff.Jid, this.coopStaff.UnitedProjectid, this.fileName.Trim(), "", 2, this.IconBase64, this.fileName, this.fileDir);
                         }
                     }
                     else
                     {
                         this.viewModel.SendCooperationStaffDownLoadNotice(this.sessionService.Jid, this.coopStaff.Jid, this.coopStaff.UnitedProjectid, this.fileName.Trim(), "", 2, this.IconBase64, this.fileName, this.SaveDirectory);
                         this.SaveDirectory = null;
                     }
                     if (this.item != null)
                     {
                         OpenFileControl openFile = new OpenFileControl(this.item, true);
                         this.coopStaffChatTab.ChatComponent.AddOpenFileControl(openFile, this.coopStaff.Name);
                     }
                 }
             }
             if (this.group != null)
             {
                 if (this.fileInfo != null)
                 {
                     string groupEndFileUpload = "成功发送文件" + this.fileName + "至群";
                     this.viewModel.SendGroupFile(this.sessionService.Uid, this.group.Gid, id, this.IconBase64, this.fileName);
                     this.groupChatTab.ChatComponent.AddMessageNotice("成功发送文件" + this.fileName);
                     this.viewModel.SendGroupUpDownFile(this.sessionService.Jid, this.group.Gid, groupEndFileUpload, "", 6);
                 }
                 else
                 {
                     string groupEndFileDownload = "成功接收" + this.userName + "的文件" + this.fileName;
                     this.groupChatTab.ChatComponent.AddMessageNotice(groupEndFileDownload);
                     if (this.SaveDirectory == null)
                     {
                         this.viewModel.SendGroupDownLoadFile(this.sessionService.Jid, this.group.Gid, groupEndFileDownload, "", 2, this.fileName, this.IconBase64, this.fileDir);
                     }
                     else
                     {
                         this.viewModel.SendGroupDownLoadFile(this.sessionService.Jid, this.group.Gid, groupEndFileDownload, "", 2, this.fileName, this.IconBase64, this.SaveDirectory);
                         this.SaveDirectory = null;
                     }
                     if (this.item != null)
                     {
                         OpenFileControl openFile = new OpenFileControl(this.item, true);
                         this.groupChatTab.ChatComponent.AddOpenFileControl(openFile, this.userName);
                     }
                 }
             }
         }
         else
         {
             if (this.staff != null)
             {
                 if (this.fileInfo != null)
                 {
                     string staffStopFileUpload = "文件" + this.fileName + "发送失败";
                     this.staffChatTab.ChatComponent.AddMessageNotice(staffStopFileUpload);
                     this.viewModel.SendStaffUpDownNotice(this.sessionService.Jid, this.staff.Jid, staffStopFileUpload, "", 3);
                 }
                 else
                 {
                     string staffStopFileDownload = "文件" + this.fileName + "接收失败";
                     this.staffChatTab.ChatComponent.AddMessageNotice(staffStopFileDownload);
                     this.viewModel.SendStaffDownLoadNotice(this.sessionService.Jid, this.staff.Jid, this.fileName.Trim(), "", 4, null, null, null);
                 }
             }
             if (this.coopStaff != null)
             {
                 if (this.fileInfo != null)
                 {
                     string staffStopFileUpload = "文件" + this.fileName + "发送失败";
                     this.coopStaffChatTab.ChatComponent.AddMessageNotice(staffStopFileUpload);
                     this.viewModel.SendCooperationStaffUpDownNotice(this.sessionService.Jid, this.coopStaff.Jid, this.coopStaff.UnitedProjectid, staffStopFileUpload, "", 3);
                 }
                 else
                 {
                     string staffStopFileDownload = "文件" + this.fileName + "接收失败";
                     this.coopStaffChatTab.ChatComponent.AddMessageNotice(staffStopFileDownload);
                     this.viewModel.SendCooperationStaffDownLoadNotice(this.sessionService.Jid, this.coopStaff.Jid, this.coopStaff.UnitedProjectid, this.fileName.Trim(), "", 4, null, null, null);
                 }
             }
             if (this.group != null)
             {
                 if (this.fileInfo != null)
                 {
                     string groupStopFileUpload = "文件" + this.fileName + "发送失败";
                     this.groupChatTab.ChatComponent.AddMessageNotice(groupStopFileUpload);
                     this.viewModel.SendGroupUpDownFile(this.sessionService.Jid, this.group.Gid, groupStopFileUpload, "", 3);
                 }
                 else
                 {
                     string groupSotpFileDownload = string.Concat(new string[]
                     {
                         "接收",
                         this.userName,
                         "的文件",
                         this.fileName,
                         "失败"
                     });
                     this.groupChatTab.ChatComponent.AddMessageNotice(groupSotpFileDownload);
                     this.viewModel.SendGroupDownLoadFile(this.sessionService.Jid, this.group.Gid, groupSotpFileDownload, "", 4, null, null, null);
                 }
             }
         }
         this.CloseFileItem();
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine("ddd " + e.ToString());
     }
 }