/// <summary> /// 添加上传任务方法 /// </summary> /// <param name="file"></param> public void dtMissionAdd(FileClass file, ItemUploadFile item, string fromUser, string toUser) { lock (this.dtMission) { DataRow dr = dtMission.NewRow(); dr["fileId"] = item.File.FileId; dr["FileSize"] = item.File.FileSize; dr["item"] = item; dr["Operation"] = (int)file.Operation; dtMission.Rows.Add(dr); if (file.Operation == OperationType.Download && !file.IsContinue) { sqlHelper.AddMission(item.File.FileId, item.File.SaveFileName, item.File.ReceivePath, item.File.FileSize.ToString(), 0, (int)file.Operation, fromUser, toUser); } } }
public void addHistory_SysTalk(ChromiumWebBrowser browser, bool isSelf, string contentStr, string sendName, string sendTime) { string MessageStr = string.Empty; SysInfoType st = SysInfoType.OK; string typeStr = contentStr.Substring(0, contentStr.IndexOf("]") + 1); switch (typeStr) { case SysParams.Sys_VibrationMessage: MessageStr = Common.VibrationMessage(isSelf, sendName); break; case SysParams.Sys_File_Success: //系统成功的消息 MessageStr = Common.VibrationMessage(isSelf, sendName); break; case SysParams.Sys_File_Warming: //系统失败的消息 MessageStr = Common.VibrationMessage(isSelf, sendName); break; case SysParams.Sys_File_Cancel: string fileContent = contentStr.Substring(contentStr.IndexOf("]") + 1); FileClass file = JsonConvert.DeserializeObject <FileClass>(fileContent); st = SysInfoType.Fail; MessageStr = Common.File_Message(isSelf, file.SaveFileName, file.FileSize, file.IsSender); break; case SysParams.Sys_OffLine_Success: fileContent = contentStr.Substring(contentStr.IndexOf("]") + 1); file = JsonConvert.DeserializeObject <FileClass>(fileContent); MessageStr = Common.File_OffLine_Message(isSelf, file.SaveFileName, file.FileSize, file.IsSender); break; } //string html = MessageStr; if (!string.IsNullOrEmpty(MessageStr)) { comm.sendMessage_Sys(browser, MessageStr, st); } }
public void retOffLineMission(string fromUser, string toUser) { DataTable dt = sqlHelper.retMission(fromUser, toUser); if (dt != null && dt.Rows.Count >= 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; FileClass file = new FileClass(); file.IsSender = false; file.Operation = OperationType.Download; file.SendFileType = SendFileType.OffLine; file.FileId = dr["fileid"].ToString(); file.IsContinue = true; file.FileName = file.SaveFileName = dr["filename"].ToString(); file.ReceivePath = dr["filePath"].ToString(); file.ReceiveSaveFileName = file.ReceivePath.Substring(file.ReceivePath.LastIndexOf('\\') + 1); file.ReceiveDir = file.ReceivePath.Substring(0, file.ReceivePath.LastIndexOf('\\')); file.FileSize = Convert.ToInt64(dr["fileSize"]); this.AddProcessCotrol.Invoke(file, false); } } }
/// <summary> /// 消息处理展示 /// </summary> /// <param name="messType"></param> /// <param name="isSysMessage"></param> /// <param name="userID"></param> /// <param name="originTime"></param> /// <param name="content"></param> /// <param name="color"></param> /// <param name="followingWords"></param> public void AppendChatBoxContentAll(ChromiumWebBrowser browser, string messType, string userID, DateTime originTime, ChatBoxContent content, string MineID, string FriendID, System.Drawing.Color color, bool followingWords, bool isOnload = false) { if (browser.IsBrowserInitialized) { string fontName = content.Font == null?"宋体": content.Font.FontFamily.Name; string fontSize = content.Font == null ? "12":content.Font.Size.ToString(); switch (messType) { case SysParams.Sys_AddFriendMessage: //添加好友消息 //AddUserForm(string JID, string messageStr) break; case SysParams.Sys_Normal: //标注聊天消息 int subLength = SysParams.Sys_Normal.Length; if (!string.IsNullOrEmpty(content.Text)) { content.Text = content.Text.Substring(subLength); } this.AppendChatBoxContent(browser, userID, originTime, content.Text, content.ForeignImageDictionary, followingWords, MineID, FriendID , color, fontName, fontSize, originTime != null); break; case SysParams.Sys_VibrationMessage: //震动提示 this.AppendSysContent(browser, userID, originTime, content.Text, MineID, FriendID, color, followingWords, originTime != null); if (FormObj is ChatFormForWeb) { Common.Vibration(FormObj); } break; case SysParams.Sys_VoiceMessage: //语音 string fileName = content.Text.Replace(SysParams.Sys_VoiceMessage, ""); if (!string.IsNullOrEmpty(fileName)) { AppendVoiceContent(browser, userID, fileName, originTime, MineID, FriendID, fontName, fontSize); } break; case SysParams.Sys_SendFileMessage: //文件发送-处理发送方消息 string sendContent = string.Empty; if (!string.IsNullOrEmpty(content.Text)) { subLength = SysParams.Sys_SendFileMessage.Length; sendContent = content.Text.Substring(subLength); FileClass file = JsonConvert.DeserializeObject <FileClass>(sendContent); if (FormObj is ChatFormForWeb && file != null) { file.IsSender = false; //添加控件 ((ChatFormForWeb)FormObj).AddProcess_Receive(file, isOnload); } } break; case SysParams.Sys_ReceiveFileMessage: //文件发送-处理接收方 发送的同意请求消息 if (!string.IsNullOrEmpty(content.Text)) { sendContent = content.Text.Substring(SysParams.Sys_ReceiveFileMessage.Length); FileClass file = JsonConvert.DeserializeObject <FileClass>(sendContent); if (FormObj is ChatFormForWeb && file != null) { file.IsSender = false; ((ChatFormForWeb)FormObj).setFileReceivePath(file); //添加控件 ((ChatFormForWeb)FormObj).OPENFIRE_SendFile(file); } } break; case SysParams.Sys_File_Warming: this.AppendSysContent(browser, userID, originTime, content.Text, MineID, FriendID, color, followingWords, originTime != null); break; case SysParams.Sys_File_Cancel: //文件取消 if (!string.IsNullOrEmpty(content.Text)) { //subLength = SysParams.Sys_SendFileMessage.Length; sendContent = content.Text.Substring(SysParams.Sys_File_Cancel.Length); FileClass file = JsonConvert.DeserializeObject <FileClass>(sendContent); if (FormObj is ChatFormForWeb && file != null) { file.IsSender = false; //添加控件 ((ChatFormForWeb)FormObj).RemoveProgressBar(file, isOnload); } } this.AppendSysContent(browser, userID, originTime, content.Text, MineID, FriendID, color, followingWords, originTime != null); break; case SysParams.Sys_File_Success: if (!string.IsNullOrEmpty(content.Text)) { //subLength = SysParams.Sys_SendFileMessage.Length; sendContent = content.Text.Substring(SysParams.Sys_File_Success.Length); FileClass file = JsonConvert.DeserializeObject <FileClass>(sendContent); string sendName = userID; bool isSelf = false; if (file != null) { if (FormObj is ChatFormForWeb) { sendName = MineID; isSelf = true; } else if (FormObj is HistoryForm) { sendName = userID; if (userID != MineID) { sendName = MineID; isSelf = true; } else { return; } } } if (!string.IsNullOrEmpty(sendName) && sendName.Contains("@")) { sendName = sendName.Substring(0, sendName.IndexOf('@')); } if (file.IsSender) { this.addHistory_File(browser, isSelf, "完成", sendName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), file.IcoUrl, file.FileName, file.FileSize, SysParams.File_Send_Result, fontName, fontSize); } else { this.addHistory_File(browser, isSelf, "完成", sendName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), file.IcoUrl, file.ReceivePath, file.FileSize, string.Format(SysParams.File_Receive_Result, file.ReceivePath), fontName, fontSize); } } //this.AppendSysContent(browser, userID, originTime, content.Text,MineID,FriendID, color, followingWords, originTime != null); break; case SysParams.Sys_OffLine_SendFileMessage: //离线消息 sendContent = string.Empty; if (!string.IsNullOrEmpty(content.Text)) { subLength = SysParams.Sys_OffLine_SendFileMessage.Length; sendContent = content.Text.Substring(subLength); FileClass file = JsonConvert.DeserializeObject <FileClass>(sendContent); if (FormObj is ChatFormForWeb && file != null) { file.IsSender = false; //添加控件 ((ChatFormForWeb)FormObj).AddProcess_Receive(file, isOnload); } } break; case SysParams.Sys_OffLine_Success: sendContent = string.Empty; if (!string.IsNullOrEmpty(content.Text)) { subLength = SysParams.Sys_OffLine_Success.Length; sendContent = content.Text.Substring(subLength); FileClass file = JsonConvert.DeserializeObject <FileClass>(sendContent); this.AppendSysContent(browser, userID, originTime, content.Text, MineID, FriendID, color, followingWords, originTime != null); } break; } } }