/// <summary> /// 退出讨论组 /// </summary> public static bool ExitGroup(string groupId, string groupName, List <AntSdkGroupMember> Members) { ExitGroupInput input = new ExitGroupInput(); input.groupId = groupId; input.token = AntSdkService.AntSdkLoginOutput.token; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.version = GlobalVariable.Version; BaseOutput output = new BaseOutput(); var errCode = 0; string errMsg = string.Empty; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var isResult = AntSdkService.GroupExitor(AntSdkService.AntSdkLoginOutput.userId, groupId, ref errCode, ref errMsg); if (isResult) { string[] ThreadParams = new string[3]; ThreadParams[0] = groupId; ThreadParams[1] = ImageHandle.GetGroupPicture(Members.Where(c => c.userId != AntSdkService.AntSdkLoginOutput.userId).Select(c => c.picture).ToList()); ThreadParams[2] = string.IsNullOrEmpty(groupName) ? "" : groupName; Thread UpdateGroupPictureThread = new Thread(UpdateGroupPicture); UpdateGroupPictureThread.Start(ThreadParams); //OnDropOutGroupEvent(this); } else { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } return(isResult); }
/// <summary> /// 发送用户通知回执 /// </summary> /// /// <param name="chatMsg"></param> public static void SendSysUserMsgReceipt(string chatIndex, string sessionId, AntSdkMsgType msgType) { if (string.IsNullOrEmpty(chatIndex) || string.IsNullOrEmpty(sessionId)) { return; } //SysUserMsgReceipt msgReceipt = new SysUserMsgReceipt(); //msgReceipt.mtp = (int)GlobalVariable.MsgType.SysUserMsg; //msgReceipt.ctt = new SysUserMsgReceipt_Ctt(); //msgReceipt.ctt.sendUserId = AntSdkService.AntSdkLoginOutput.userId; //msgReceipt.ctt.companyCode = GlobalVariable.CompanyCode; //msgReceipt.ctt.chatIndex = chatIndex; //msgReceipt.ctt.sessionId = sessionId; //msgReceipt.ctt.os = (int)GlobalVariable.OSType.PC; string errMsg = string.Empty; //TODO:AntSdk_Modify //DONE:AntSdk_Modify AntSdkReceiptMsg receiptMsg = new AntSdkReceiptMsg(); receiptMsg.chatIndex = chatIndex; receiptMsg.sessionId = sessionId; receiptMsg.userId = AntSdkService.AntSdkLoginOutput.userId; receiptMsg.MsgType = msgType; AntSdkService.SdkPublishReceiptMsg(receiptMsg, AntSdkReceiptType.ReadReceipt, ref errMsg); //MqttService.Instance.Publish<SysUserMsgReceipt>(GlobalVariable.TopicClass.MessageRead, msgReceipt, ref errMsg); }
private void LoadData(AttendanceRecord attendanceRecord) { var errCode = 0; var errMsg = string.Empty; todayAttendanceRecords = attendanceRecord; if (todayAttendanceRecords == null) { return; } checkInDataTime = todayAttendanceRecords.PuncherDateTime; AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg); DateTime serverDateTime = DateTime.Now; if (serverResult != null) { serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime); } var diffMinute = serverDateTime - checkInDataTime; if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString()) { return; } if (diffMinute.Hours > 6) { return; } if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20 || !todayAttendanceRecords.IsbtnVerify) { return; } //设置定时器 timer?.Stop(); timer = null; timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 1); //时间间隔为一秒 timer.Tick += new EventHandler(timer_Tick); var minuteChangeSecond = 0d; if (diffMinute.TotalMinutes < 0) { minuteChangeSecond = (20 - 0.01) * 60; } else { minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60; } //处理倒计时的类 processCount = new ProcessCount((int)minuteChangeSecond); //Application.Current.Dispatcher.Invoke((Action)(() => //{ todayAttendanceRecords.ChcekInTimer = "(" + processCount.GetMinute() + "分" + processCount.GetSecond() + "秒" + ")"; //})); CountDown += new CountDownHandler(processCount.ProcessCountDown); //开启定时器 timer.Start(); }
/// <summary> /// 查询附件信息 /// </summary> /// <param name="id"></param> private void UpdateAttachment(string id) { AttachControlViewModelList.Clear(); //inFindDetailsNotice inData = new inFindDetailsNotice(); //inData.userId = AntSdkService.AntSdkCurrentUserInfo.userId; //inData.version = "1.0"; //inData.notificationId = id; //inData.token = AntSdkService.AntSdkLoginOutput.token; //ReturnNoticeAddDto rData = null; var errorCode = 0; string errorMsg = ""; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var result = AntSdkService.GetNotificationsById(id, ref errorCode, ref errorMsg); // bool result = false;//new HttpService().SearchNoticeDetailsByNoticeId(inData, ref rData, ref errorMsg, GlobalVariable.RequestMethod.GET); if (result != null) { if (result.attach != null) { List <data> datas = JsonConvert.DeserializeObject <List <data> >(result.attach); foreach (var list in datas) { if (list == null) { continue; } AttachControlViewModel vm = new AttachControlViewModel(list); AttachControlViewModelList.Add(vm); } } } }
/// <summary> /// 更改状态 /// </summary> /// <param name="noticeId"></param> public void IsReadStutes(string noticeId, string targetId) { delateNoticeDto inData = new delateNoticeDto(); inData.userId = AntSdkService.AntSdkCurrentUserInfo.userId; inData.version = "1.0"; inData.token = AntSdkService.AntSdkLoginOutput.token; inData.notificationId = noticeId; inData.targetId = targetId; baseNotice bn = null; var errorCode = 0; string errorMsg = ""; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var isResult = AntSdkService.UpdateNotificationsState(AntSdkService.AntSdkCurrentUserInfo.userId, targetId, noticeId, ref errorCode, ref errorMsg); bool b = false;// new HttpService().ReadNotice(inData, ref bn, ref errorMsg, GlobalVariable.RequestMethod.PATCH); if (isResult) { //if (bn.result == 1) //{ //} } }
/// <summary> /// 用户A收到B已读阅后即焚的通知需要发送回执 /// </summary> public static void SendBurnAfterReadReceipt(BurnAfterReadReceiptCtt msg, string messageID) { //BurnAfterReadReceipt receipt = new BurnAfterReadReceipt(); //receipt.ctt = new BurnAfterReadReceiptCtt(); //receipt.ctt.sendUserId = AntSdkService.AntSdkCurrentUserInfo.userId; //receipt.ctt.companyCode = GlobalVariable.CompanyCode; //receipt.ctt.chatIndex = msg.chatIndex; //receipt.ctt.os = ((int)GlobalVariable.OSType.PC).ToString(); //receipt.ctt.sessionId = msg.sessionId; //receipt.ctt.targetId = null; //receipt.ctt.content = null; string errMsg = string.Empty; //TODO:AntSdk_Modify //DNOE:AntSdk_Modify var burnRead = new AntSdkSendMsg.PointBurnReaded { targetId = msg.targetId, chatIndex = msg.chatIndex, sessionId = msg.sessionId, sendUserId = AntSdkService.AntSdkCurrentUserInfo.userId, messageId = PublicTalkMothed.timeStampAndRandom(), chatType = (int)AntSdkchatType.Point, os = (int)GlobalVariable.OSType.PC, content = new AntSdkSendMsg.PointBurnReaded_content { readIndex = int.Parse(msg.chatIndex), //TODO://收到的那条阅后即焚消息的messageId messageId = messageID } }; AntSdkService.SdkPublishPointBurnReadReceiptMsg(burnRead, ref errMsg); //MqttService.Instance.Publish<BurnAfterReadReceipt>(GlobalVariable.TopicClass.MessageRead, receipt, ref errMsg, NullValueHandling.Ignore); }
protected virtual void OnLoginSuccess() { //NotifyIconControl.Instance.notifyIcon.ContextMenu.MenuItems["ExitApp"].Click -= ItemExitClick; //NotifyIconControl.Instance.notifyIcon.MouseClick -= OnNotifyIconMouseClick; //NotifyIconControl.Instance.notifyIcon.Visible = false; //this.LoginSuccessEvent?.Invoke(); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); System.Windows.Application.Current.Dispatcher.Invoke(() => { MainWindowViewModel model = new MainWindowViewModel(); var result = model.GetGroupList(); if (!result) { loginCount++; //如果尝试3获取数据失败,返回登录页面 if (loginCount >= 3) { MessageBoxWindow.Show("尝试多次获取群数据失败,请联系管理员。", GlobalVariable.WarnOrSuccess.Warn); if (IsLoginSuccess) { var errorCode = 0; var errorMsg = string.Empty; //发送状态 AntSdkService.AntSdkUpdateCurrentUserState((int)GlobalVariable.OnLineStatus.OffLine, ref errorCode, ref errorMsg); //停止SDK SDK.AntSdk.AntSdkService.StopAntSdk(ref errorCode, ref errorMsg); AudioChat.ExitClearApi(); } System.Windows.Application.Current.Shutdown(); CommonMethods.StartApplication(System.Windows.Forms.Application.StartupPath + "/AntennaChat.exe"); return; } OnLoginSuccess(); return; } //model.DownloadUserHeadImage(); MainWindowView mainWindow = new MainWindowView { DataContext = model }; //model.InitMainVM(); if (this.LoginWindow != null) { var loginWindow = LoginWindow as LoginWindowView; loginWindow?.taskbarIcon.Dispose(); } loginCount = 0; mainWindow.Show(); GlobalVariable.LastLoginDatetime = DateTime.Now; this.LoginWindow?.Close(); }); stopWatch.Stop(); Antenna.Framework.LogHelper.WriteDebug($"[Model_LoginSuccessEvent({stopWatch.Elapsed.TotalMilliseconds}毫秒)]"); }
/// <summary> /// 初始化用户信息 /// </summary> /// <param name="id"></param> private async void InitUserInfo(string id) { var temperrorCode = 0; var temperrorMsg = string.Empty; await Task.Run(() => { CurrentProfile = AntSdkService.AntSdkGetUserInfo(id, ref temperrorCode, ref temperrorMsg); }); SetUserInfo(); }
/// <summary> /// 设置验证码图片 /// </summary> private void SetVerifyCodeImage() { //AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher, // () => // { App.Current.Dispatcher.Invoke((Action)(() => { var errMessage = string.Empty; var errCode = 0; HttpWebRequest request = null; HttpWebResponse ress = null; Stream sstreamRes = null; try { request = (HttpWebRequest)WebRequest.Create(AntSdkService.GetVerifyCodeImage(string.IsNullOrEmpty(this.LoginID) ? _selectedData : this.LoginID, ref errCode, ref errMessage)); request.Method = "GET"; ress = (HttpWebResponse)request.GetResponse(); sstreamRes = ress.GetResponseStream(); var bmp = new BitmapImage(); bmp.BeginInit(); //bmp.CacheOption = BitmapCacheOption.OnLoad; bmp.StreamSource = sstreamRes; bmp.EndInit(); Thread.Sleep(50); IdentifyingCodeBitmap = bmp; //if (sstreamRes != null) // return sstreamRes; } catch (System.Net.WebException x) { } finally { request.Abort(); ress?.Close(); sstreamRes?.Close(); } })); //return null; //}, //(ex, datas) => //{ // if (datas == null) return; //var bmp = new BitmapImage(); //bmp.BeginInit(); ////bmp.CacheOption = BitmapCacheOption.OnLoad; //bmp.StreamSource = sstreamRes; //bmp.EndInit(); //IdentifyingCodeBitmap = bmp; //}); //IdentifyingCodeBitmap = AntSdkService.GetVerifyCodeImage(string.IsNullOrEmpty(this.LoginID) ? _selectedData : this.LoginID, ref errCode, ref errMessage); }
public static List <AntSdkGroupMember> GetMembers(string groupId) { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); GetGroupMembersInput input = new GetGroupMembersInput(); input.token = AntSdkService.AntSdkLoginOutput.token; input.version = GlobalVariable.Version; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupId = groupId; GetGroupMembersOutput output = new GetGroupMembersOutput(); var errCode = 0; string errMsg = string.Empty; //TODO:AntSdk_Modify //if ((new HttpService()).GetGroupMembers(input, ref output, ref errMsg)) //{ // Members = output.users; // this.GroupName = string.Format("{0}", GroupInfo.groupName); // GroupMemberCount = string.Format("({0}人)", Members == null ? 0 : Members.Count()); // GetGroupMembers_User tempUser = Members.Find(c => c.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin); // if (tempUser != null && AntSdkService.AntSdkLoginOutput.userId == tempUser.userId) // { // DeleteGroupVisibility = Visibility.Visible; // GroupClassifyName = "我管理的"; // GroupClassify = 1; // } // else // { // GroupClassifyName = "我加入的"; // GroupClassify = 2; // } //} //DONE:AntSdk_Modify var groupMembers = AntSdkService.GetGroupMembers(AntSdkService.AntSdkLoginOutput.userId, groupId, ref errCode, ref errMsg); if (groupMembers != null && groupMembers.Length > 0) { return(groupMembers.ToList()); } //Log输出 if (!string.IsNullOrEmpty(errMsg)) { } stopWatch.Stop(); LogHelper.WriteDebug(string.Format("[GroupInfoViewModel_GetMembers({0}毫秒)]", stopWatch.Elapsed.TotalMilliseconds)); return(new List <AntSdkGroupMember>()); }
public CreateVoteViewModel(string groupId) { _groupId = groupId; var errCode = 0; var errMsg = string.Empty; AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg); DateTime serverDateTime = DateTime.Now; if (serverResult != null) { serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime); } _displayDateEnd = serverDateTime.AddMonths(1); InitData(); }
/// <summary> /// 获取当前用户的所有群组,并请求群组离线消息 /// </summary> public void GetGroupList() { var temperrorCode = 0; var temperrorMsg = string.Empty; var groups = AntSdkService.GetGroupList(AntSdkService.AntSdkLoginOutput.userId, ref temperrorCode, ref temperrorMsg); if (!string.IsNullOrEmpty(temperrorMsg)) { Application.Current.Dispatcher.Invoke(new Action(() => MessageBoxWindow.Show(temperrorMsg, GlobalVariable.WarnOrSuccess.Warn))); } if (groups == null || groups.Length == 0) { return; } GroupInfos = new List <AntSdkGroupInfo>(groups); }
/// <summary> /// 查询用户信息 /// </summary> /// <param name="id"></param> public static AntSdkUserInfo QueryUserInfo(string id) { var isExist = AntSdkService.AntSdkListContactsEntity.users.FirstOrDefault(v => v.userId == id); if (isExist == null) { return(null); } var errCode = 0; var errMsg = string.Empty; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var user = AntSdkService.AntSdkGetUserInfo(id, ref errCode, ref errMsg); return(user ?? null); }
/// <summary> /// 从本地查询消息 /// </summary> /// <param name="sessionId">会话ID</param> /// <param name="chatType">聊天类型</param> /// <param name="first">第一次查询,传true;其他传false</param> /// <param name="msgCount">查询数量,范围在[1,20],超出的话,会报错</param> /// <param name="index">起始chatIndex,如果第一次查询的话,可以传0;如果不是第一次查询,那么查询出来的消息的index都是小于这个chatIndex的</param> /// <returns></returns> public static List <AntSdkChatMsg.ChatBase> QueryMessageFromLocal(string sessionId, AntSdkchatType chatType, bool first, int msgCount, int index) { var input = new AntSdkSynchronusMsgInput { sessionId = sessionId, chatType = (int)chatType, flag = 0, userId = AntSdkService.AntSdkLoginOutput.userId, isFirst = first, count = msgCount, chatIndex = index, }; var listChatdata = new List <AntSdkChatMsg.ChatBase>(); var result = AntSdkService.GetLocalMsgData(input, ref listChatdata, false); return(result ? listChatdata : null); }
/// <summary> /// 加载公告详情数据 /// </summary> /// <param name="lists"></param> public void LoadNoticeData(List <Notice_content> lists) { this.noticeList = lists; if (noticeList == null || noticeList.Count == 0) { return; } var errorCode = 0; string errorMsg = string.Empty; var result = AntSdkService.GetNotificationsById(noticeList[0].notificationId, ref errorCode, ref errorMsg); if (result != null) { txtContent = result.content; } txtTitles = noticeList[0].title; NoticeDetailWinHeight = 300; AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == lists[0].createId); if (user != null) { createBy = user.userName; } //createBy = lists[0].createBy; IsReadStutes(noticeList[0].notificationId, noticeList[0].targetId); if (lists[0].hasAttach == 1) { SetGridStatus(true); UpdateAttachment(noticeList[0].notificationId); //isShowAttch = Visibility.Visible; } else { SetGridStatus(false); //isShowAttch = Visibility.Collapsed; } btnRemarkText = createBy + " 编辑于 " + DataConverter.FormatTimeByTimeStamp(noticeList[0].createTime); if (noticeList.Count() == 1) { noticeCount = "我知道了"; } else { noticeCount = "下一条(" + Convert.ToInt32(noticeList.Count() - 1) + ")"; } }
/// <summary> /// Timer触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Tick(object sender, EventArgs e) { if (OnCountDown()) { //Application.Current.Dispatcher.Invoke((Action)(() => //{ if (todayAttendanceRecords != null) { todayAttendanceRecords.ChcekInTimer = "(" + processCount.GetMinute() + "分" + processCount.GetSecond() + "秒" + ")"; } ThreadPool.QueueUserWorkItem(m => { if (processCount.timerTotalSecond >= 20) { var errCode = 0; var errMsg = string.Empty; AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg); DateTime serverDateTime = DateTime.Now; if (serverResult != null) { serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime); } var diffMinute = serverDateTime - checkInDataTime; if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString()) { return; } if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20) { return; } var minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60; processCount.ResetTotalSecond((int)minuteChangeSecond); } }); //})); } else { todayAttendanceRecords.IsbtnVerify = false; todayAttendanceRecords.VerifyDescribe = "验证过期"; todayAttendanceRecords.VerifyState = 1; timer.Stop(); } }
/// <summary> /// Timer触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Tick(object sender, EventArgs e) { if (OnCountDown()) { //HourArea.Text = processCount.GetHour(); //MinuteArea.Text = processCount.GetMinute(); //SecondArea.Text = processCount.GetSecond(); ChcekInTimer = processCount.GetMinute() + "分" + processCount.GetSecond() + "秒"; ThreadPool.QueueUserWorkItem(m => { if (processCount.timerTotalSecond >= 20) { var errCode = 0; var errMsg = string.Empty; AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg); DateTime serverDateTime = DateTime.Now; if (serverResult != null) { serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime); } var diffMinute = serverDateTime - checkInDataTime; if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString()) { return; } if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20) { return; } var minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60; processCount.ResetTotalSecond((int)minuteChangeSecond); } }); } else { if (VerifyView != null) { VerifyView.Close(); //MainWindowViewModel.CloseExitVerify(); } VerifyResultShow(true, CheckInVerifyResultState.TimeError); timer.Stop(); } }
public static void UpdateGroupPicture(object localPicture) { string[] ThreadParams = localPicture as string[]; string pictureAddress = ImageHandle.UploadPicture(ThreadParams[1]); AntSdkUpdateGroupInput updateInput = new AntSdkUpdateGroupInput(); updateInput.userId = AntSdkService.AntSdkLoginOutput.userId; updateInput.groupId = ThreadParams[0]; updateInput.groupName = ""; updateInput.groupPicture = pictureAddress; var errCode = 0; string errMsg = string.Empty; //TODO:AntSdk_Modify //DONE:AntSdk_Modify AntSdkService.UpdateGroup(updateInput, ref errCode, ref errMsg); //(new HttpService()).UpdateGroup(updateInput, ref updateOut, ref errMsg); }
public VoteDetailViewModel(VoteViewType type, int voteId, int groupMemberCount) { _voteId = voteId; var errCode = 0; var errMsg = string.Empty; var output = AntSdkService.GetVoteInfo(voteId, AntSdkService.AntSdkCurrentUserInfo.userId, ref errCode, ref errMsg); AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg); DateTime serverDateTime = DateTime.Now; if (serverResult != null) { serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime); } if (output != null) { SetVoteData(output, type, groupMemberCount, serverDateTime); } }
/// <summary> /// 设置消息提醒方式 /// </summary> public void SetMsgRemind(GlobalVariable.MsgRemind?remind = null) { AntSdkUpdateGroupConfigInput input = new AntSdkUpdateGroupConfigInput(); input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupId = this.GroupInfo.groupId; BaseOutput output = new BaseOutput(); var errCode = 0; string errMsg = string.Empty; if (remind == null) { input.state = MessageNoticeIsChecked ? ((int)GlobalVariable.MsgRemind.Remind).ToString() : ((int)GlobalVariable.MsgRemind.NoRemind).ToString(); } else { input.state = ((int)remind.Value).ToString(); } var isResult = AntSdkService.UpdateGroupConfig(input, ref errCode, ref errMsg); if (isResult) { GroupInfo.state = int.Parse(input.state); if (GroupInfo.state == (int)GlobalVariable.MsgRemind.NoRemind) { MessageNoticeIsChecked = false; MessageHideIsChecked = true; ImageNoRemindVisibility = Visibility.Visible; } else { MessageNoticeIsChecked = true; MessageHideIsChecked = false; ImageNoRemindVisibility = Visibility.Collapsed; } } else { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } }
/// <summary> /// 解散讨论组 /// </summary> public static void DismissGroup(string groupId) { ExitGroupInput input = new ExitGroupInput(); input.groupId = groupId; input.token = AntSdkService.AntSdkLoginOutput.token; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.version = GlobalVariable.Version; BaseOutput output = new BaseOutput(); var errCode = 0; var errMsg = string.Empty; var isResult = AntSdkService.DissolveGroup(AntSdkService.AntSdkLoginOutput.userId, groupId, ref errCode, ref errMsg); if (isResult) { //OnDropOutGroupEvent(this); } else { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } }
/// <summary> /// 上传讨论组头像 /// </summary> /// <param name="strFilePath"></param> /// <returns></returns> public static string UploadPicture(string strFilePath) { SendCutImageDto scid = new SendCutImageDto(); scid.cmpcd = GlobalVariable.CompanyCode; scid.seId = ""; scid.fileFileName = ""; scid.file = strFilePath; //TODO:AntSdk_Modify //DONE:AntSdk_Modify AntSdkSendFileInput fileInput = new AntSdkSendFileInput(); fileInput.cmpcd = GlobalVariable.CompanyCode; fileInput.seId = fileInput.file = strFilePath; AntSdkFailOrSucessMessageDto failMessage = new AntSdkFailOrSucessMessageDto(); failMessage.mtp = (int)AntSdkMsgType.ChatMsgPicture; failMessage.content = ""; //failMessage.sessionid = s_ctt.sessionId; DateTime dt = DateTime.Now; failMessage.lastDatetime = dt.ToString(); fileInput.FailOrSucess = failMessage; var errCode = 0; string errMsg = string.Empty; var fileOutput = AntSdkService.FileUpload(fileInput, ref errCode, ref errMsg); //ReturnCutImageDto dto = (new HttpService()).FileUpload<ReturnCutImageDto>(scid); if (fileOutput == null) { return(string.Empty); } else { return(fileOutput.dowmnloadUrl); } }
/// <summary> /// 管理员转让 /// </summary> /// <param name="errMsg"></param> /// <returns></returns> public bool ChangeAdmin(ref string errMsg) { bool changeResult = false; try { //ChangeGroupAdminIn input = new ChangeGroupAdminIn() //{ // groupId = GroupId, // newManagerId = Member.userId, // token = AntSdkService.AntSdkLoginOutput.token, // userId = AntSdkService.AntSdkLoginOutput.userId, // version = GlobalVariable.Version //}; //ChangeGroupAdminOut output = new ChangeGroupAdminOut(); //TODO:AntSdk_Modify //DONE:AntSdk_Modify AntSdkGroupOwnerChangeInput groupManageChangeInput = new AntSdkGroupOwnerChangeInput(); groupManageChangeInput.groupId = GroupId; groupManageChangeInput.newOwnerId = Member.userId; groupManageChangeInput.userId = AntSdkService.AntSdkLoginOutput.userId; var errorCode = 0; changeResult = AntSdkService.GroupOwnerChange(groupManageChangeInput, ref errorCode, ref errMsg); //changeResult=(new HttpService()).ChangeGroupAdmin(input, ref output, ref errMsg); //转让管理员成功显示阅后即焚图标 if (changeResult == true) { switchImage(); } } catch (Exception ex) { changeResult = false; errMsg = $"变更管理员时发生异常:{ex.Message}"; } return(changeResult); }
/// <summary> /// 从网络查询消息 /// </summary> /// <param name="sessionId">会话ID</param> /// <param name="chatType">聊天类型</param> /// <param name="first">第一次查询,传true;其他传false</param> /// <param name="msgCount">查询数量,范围在[1,20],超出的话,会报错</param> /// <param name="index">起始chatIndex,如果第一次查询的话,可以传0;如果不是第一次查询,那么查询出来的消息的index都是小于这个chatIndex的</param> /// <returns></returns> public static List <AntSdkChatMsg.ChatBase> QueryMessageFromServer(string sessionId, AntSdkchatType chatType, bool first, int msgCount, int index) { var input = new AntSdkSynchronusMsgInput { sessionId = sessionId, chatType = (int)chatType, flag = 0, userId = AntSdkService.AntSdkLoginOutput.userId, isFirst = first, count = msgCount, chatIndex = index, }; var chatMsgList = new List <AntSdkChatMsg.ChatBase>(); int errorCode = 0; string errorMsg = string.Empty; AntSdkService.SynchronusMsgs(input, ref chatMsgList, ref errorCode, ref errorMsg); if (chatMsgList == null || chatMsgList.Count == 0) { return(null); } else { var tempChatMsg = chatMsgList[chatMsgList.Count - 1]; var localMsgSession = t_sessionBll.GetModelByKey(tempChatMsg.sessionId); var chatIndex = 0; int.TryParse(tempChatMsg.chatIndex, out chatIndex); if (localMsgSession != null) { var localChatIndex = 0; var burnChatIndex = 0; if (!string.IsNullOrEmpty(localMsgSession.LastChatIndex)) { int.TryParse(localMsgSession.LastChatIndex, out localChatIndex); } if (!string.IsNullOrEmpty(localMsgSession.BurnLastChatIndex)) { int.TryParse(localMsgSession.BurnLastChatIndex, out burnChatIndex); } if (localChatIndex < burnChatIndex) { localChatIndex = burnChatIndex; } if (chatIndex > localChatIndex) { var antSdkContactUser = AntSdkService.AntSdkListContactsEntity.users.FirstOrDefault(c => c.userId == tempChatMsg.sendUserId); localMsgSession.LastChatIndex = tempChatMsg.chatIndex; localMsgSession.LastMsg = antSdkContactUser != null? FormatLastMessageContent(tempChatMsg.MsgType, tempChatMsg, chatType == AntSdkchatType.Group, antSdkContactUser.userNum != null?antSdkContactUser.userNum + antSdkContactUser.userName : antSdkContactUser.userName) : PublicMessageFunction.FormatLastMessageContent(tempChatMsg.MsgType, tempChatMsg, chatType == AntSdkchatType.Group); localMsgSession.LastMsgTimeStamp = tempChatMsg.sendTime; t_sessionBll.Update(localMsgSession); tempChatMsg.chatType = (int)chatType; SessionMonitor.AddSessionItemOnlineMsg(tempChatMsg.MsgType, tempChatMsg, false); } } return(chatMsgList); } }
/// <summary> /// 打开公告详情 /// </summary> private void GoNoticeDetail(NoticeModel currentSNoticeAddDto) { try { #region 旧代码 //if (NoticeDetailsWindowViewModelVisibility == Visibility.Collapsed || NoticeDetailsWindowViewModelVisibility == Visibility.Hidden) //{ // delateNoticeDto inData = new delateNoticeDto(); // inData.userId = AntSdkService.AntSdkCurrentUserInfo.userId; // inData.version = "1.0"; // inData.token = AntSdkService.AntSdkLoginOutput.token; // inData.notificationId = currentSNoticeAddDto.NotificationId; // baseNotice bn = null; // string errorMsg = ""; // NoticeAddDto preData = _noticeList.SingleOrDefault(m => m.NotificationId == currentSNoticeAddDto.NotificationId); // if (preData.readStatusforeground == "1") // { // NoticeDetailsWindowViewModel = new NoticeDetailsWindowViewModel(this, currentSNoticeAddDto); // } // else // { // bool b = new HttpService().ReadNotice(inData, ref bn, ref errorMsg, GlobalVariable.RequestMethod.PATCH); // if (b == true) // { // if (bn.result == 1) // { // NoticeDetailsWindowViewModel = new NoticeDetailsWindowViewModel(this, currentSNoticeAddDto); // preData.isbtnShowVisibility = "1"; // preData.readStatusforeground = "1"; // } // } // } //} //if (NoticeDetailsWindowViewModelVisibility == Visibility.Hidden) //{ // NoticeDetailsWindowViewModelVisibility = Visibility.Collapsed; //} //NoticeDetailsWindowViewModelVisibility = NoticeDetailsWindowViewModelVisibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Hidden; #endregion //inFindDetailsNotice inData = new inFindDetailsNotice(); //inData.userId = AntSdkService.AntSdkCurrentUserInfo.userId; //inData.version = "1.0"; //inData.notificationId = currentSNoticeAddDto.NotificationId; //inData.token = AntSdkService.AntSdkLoginOutput.token; //ReturnNoticeAddDto rData = null; var errorCode = 0; string errorMsg = ""; //TODO:AntSdk_Modify //DONE:AntSdk_Modify //bool result = false;// new HttpService().SearchNoticeDetailsByNoticeId(inData, ref rData, ref errorMsg, GlobalVariable.RequestMethod.GET); var result = AntSdkService.GetNotificationsById(currentSNoticeAddDto.NotificationId, ref errorCode, ref errorMsg); if (result != null) { NoticeReadViewModel readModel = new NoticeReadViewModel(result); NoticeRead read = new NoticeRead(); read.DataContext = readModel; read.Owner = Antenna.Framework.Win32.GetTopWindow(); read.ShowDialog(); } } catch (Exception ex) { LogHelper.WriteError("[NoticeWindowListsViewModel_ListBox_SelectionChanged:" + ex.Message + ex.StackTrace + ex.Source); } }
/// <summary> /// 发送消息 /// </summary> /// <param name="o"></param> private void SendMassMsg(object o) { if (ContactUsers == null || ContactUsers.Count == 0) { MessageBoxWindow.Show("请先选择消息接收人!", GlobalVariable.WarnOrSuccess.Warn); return; } else if (string.IsNullOrWhiteSpace(MsgContent)) { MessageBoxWindow.Show("消息内容不能为空!", GlobalVariable.WarnOrSuccess.Warn); return; } else if (MsgContent.Length > 500) { MessageBoxWindow.Show("消息内容不能超过500个字符!", GlobalVariable.WarnOrSuccess.Warn); return; } MassMsg msg = new MassMsg(); msg.mtp = (int)GlobalVariable.MsgType.MassMsg; //TODO:AntSdk_Modify AntSdkMassMsgCtt ctt = new AntSdkMassMsgCtt(); //ctt.messageId = PublicTalkMothed.timeStampAndRandom(); ctt.sendUserId = AntSdkService.AntSdkCurrentUserInfo.userId; if (ContactUsers != null && ContactUsers.Count > 0) { ctt.targetId = string.Join(",", ContactUsers.Where(m => m.userId != AntSdkService.AntSdkCurrentUserInfo.userId).Select(c => c.userId).ToArray()); } ctt.companyCode = GlobalVariable.CompanyCode; ctt.content = MsgContent; ctt.os = (int)GlobalVariable.OSType.PC; ctt.sessionId = DataConverter.GetSessionID(AntSdkService.AntSdkCurrentUserInfo.userId, GlobalVariable.MassAssistantId); ctt.chatIndex = null; ctt.sendTime = null; string errMsg = ""; //DONE:AntSdk_Modify AntSdkChatMsg.MultiSend massMsg = new AntSdkChatMsg.MultiSend(); massMsg.sendUserId = AntSdkService.AntSdkCurrentUserInfo.userId; if (ContactUsers != null && ContactUsers.Count > 0) { massMsg.targetId = string.Join(",", ContactUsers.Where(m => m.userId != AntSdkService.AntSdkCurrentUserInfo.userId).Select(c => c.userId).ToArray()); } massMsg.content = MsgContent; massMsg.chatType = (int)AntSdkchatType.Point; massMsg.messageId = PublicTalkMothed.timeStampAndRandom(); massMsg.sessionId = DataConverter.GetSessionID(AntSdkService.AntSdkCurrentUserInfo.userId, GlobalVariable.MassAssistantId); var isResult = AntSdkService.SdkPublishChatMsg(massMsg, ref errMsg); // AntSdkMassMsgCtt if (isResult) { ctt.messageId = massMsg.messageId; LogHelper.WriteWarn("---------------------------消息助手群发消息已发送---------------------"); SendMassMsgEvent?.Invoke(ctt); (o as System.Windows.Window)?.Close(); } else { MessageBoxWindow.Show("消息发送失败!" + errMsg, GlobalVariable.WarnOrSuccess.Warn); } }
/// <summary> /// 登录 /// </summary> /// <param name="id"></param> /// <param name="pwd"></param> /// <param name="errMsg"></param> /// <returns></returns> private bool Login(string id, string pwd, ref string errMsg) { var errCode = 0; AccountInfo info = ListAccountInfo.FirstOrDefault(c => c.ID == this.LoginID); if (info != null) { TimeSpan span = DateTime.Now - info.LastLoginTime; if (span.TotalSeconds < 10) { var loginWindow = LoginWindow as LoginWindowView; loginWindow?.LoginFault(); return(false); } else { // info.IsLogin = true; info.LastLoginTime = DateTime.Now; DataConverter.EntityToXml( System.Environment.CurrentDirectory + "/AccountCache.xml", ListAccountInfo, ref errMsg); } } Stopwatch stopWatch = new Stopwatch(); if (!AntSdkService.AntSdkLogin(id, pwd, UserSelectedState.OnlineState, IdentifyingCode, ref errCode, ref errMsg)) { if (info != null) { info.LastLoginTime = DateTime.Now.AddMinutes(-1); } //TimeSpan time = DateTime.Now - LoginPwdErrorDateTime; if (errCode == 10022) { if (info != null && !info.IsIdentifyingCode) { info.IsIdentifyingCode = true; } LoginPwd = string.Empty; if (!IsIdentifyingCode) { IsIdentifyingCode = true; } IdentifyingCode = string.Empty; SetVerifyCodeImage(); if (!loginIDList.ContainsKey(id)) { loginIDList.Add(id, DateTime.Now.AddMinutes(-1)); } } else if (errCode == 10014 && IsIdentifyingCode) { IdentifyingCode = string.Empty; SetVerifyCodeImage(); } else if (errCode == 10023) { IdentifyingCode = string.Empty; if (!IsIdentifyingCode) { if (!loginIDList.ContainsKey(id)) { loginIDList.Add(id, DateTime.Now.AddMinutes(-1)); } IsIdentifyingCode = true; } SetVerifyCodeImage(); //this.TipsLabelText = errMsg; } DataConverter.EntityToXml( System.Environment.CurrentDirectory + "/AccountCache.xml", ListAccountInfo, ref errMsg); return(false); } else { if (info != null && info.IsIdentifyingCode) { info.IsIdentifyingCode = false; DataConverter.EntityToXml( System.Environment.CurrentDirectory + "/AccountCache.xml", ListAccountInfo, ref errMsg); } loginIDList.Remove(id); checkCode = string.Empty; IdentifyingCode = string.Empty; LoginPwdErrorCount = 0; //LoginPwdErrorDateTime = DateTime.Now.AddMinutes(-1); } SaveAccountInfo(); stopWatch.Stop(); LogHelper.WriteDebug($"[LoadAction_Login({stopWatch.Elapsed.TotalMilliseconds}毫秒)]"); return(true); }
public NoticeDetailsWindowViewModel(NoticeWindowListsViewModel notice, NoticeAddDto dtos) { this.notice = notice; this.dtos = dtos; //inFindDetailsNotice inData = new inFindDetailsNotice(); //inData.userId = AntSdkService.AntSdkCurrentUserInfo.userId; //inData.version = "1.0"; //inData.notificationId = dtos.notificationId; //inData.token = AntSdkService.AntSdkLoginOutput.token; //ReturnNoticeAddDto rData = null; var errorCode = 0; string errorMsg = ""; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var result = AntSdkService.GetNotificationsById(dtos.notificationId, ref errorCode, ref errorMsg); //bool result = false;//new HttpService().SearchNoticeDetailsByNoticeId(inData, ref rData, ref errorMsg, GlobalVariable.RequestMethod.GET); if (result != null) { noticeTitle = result.title; noticeContent = result.content; explain = result.createBy + " 编辑于 " + DataConverter.FormatTimeByTimeStamp(result.createTime); if (result.attach != null) { gridHeight = 90; List <data> datas = JsonConvert.DeserializeObject <List <data> >(result.attach); foreach (var list in datas) { if (list == null) { continue; } AddAttachmentDto add = new AddAttachmentDto(); add.fileGuid = Guid.NewGuid().ToString().Replace("-", ""); add.fileName = list.fileName; if (Convert.ToInt32(list.fileSize) < 1024) { add.fileLength = list.fileSize + "B"; } if (Convert.ToInt32(list.fileSize) > 1024) { add.fileLength = Math.Round((double)Convert.ToInt32(list.fileSize) / 1024, 2) + "KB"; } if (Convert.ToInt32(list.fileSize) > 1024 * 1024) { add.fileLength = Math.Round((double)Convert.ToInt32(list.fileSize) / 1024 / 1024, 2) + "MB"; } add.localPath = list.downloadURL; add.fileimageShow = fileShowImage.showImageHtmlPath(list.fileType, ""); add.btnStatus = "downLoad"; add.btnforeground = "0"; _attachment.Add(add); } } else { gridHeight = 0; } } }
//public string NewGroupPicture; /// <summary> /// 更新讨论组 /// </summary> private void UpdateGroup() { if (GroupInfo == null) { return; } AntSdkUpdateGroupInput input = new AntSdkUpdateGroupInput(); input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupId = this.GroupInfo.groupId; NewGroupMemberList = new List <AntSdkContact_User>(); foreach (ContactInfoViewModel vm in GroupMemberList) { if (!OriginalMemberIds.Contains(vm.User.userId)) { if (input.userIds == null) { input.userIds = new List <string>(); } input.userIds.Add(vm.User.userId); if (input.userNames == null) { input.userNames = new List <string>(); } input.userNames.Add(vm.User.userName); NewGroupMemberList.Add(vm.User); } } if (NewGroupMemberList.Count != 0) { BaseOutput output = new BaseOutput(); var errCode = 0; string errMsg = string.Empty; //TODO:AntSdk_Modify //DONE:AntSdk_Modify var isResult = AntSdkService.UpdateGroup(input, ref errCode, ref errMsg); if (!isResult) { NewGroupMemberList = null; MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); return; } //if (!(new HttpService()).UpdateGroup(input, ref output, ref errMsg)) //{ // NewGroupMemberList = null; // if (output.errorCode != "1004") // { // MessageBoxWindow.Show(errMsg,GlobalVariable.WarnOrSuccess.Warn); // } // return; // //OnUpdateGroupEvent(input.groupId, input.userIds); //} string[] ThreadParams = new string[3]; ThreadParams[0] = this.GroupInfo.groupId; ThreadParams[1] = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); ThreadParams[2] = string.IsNullOrEmpty(this.GroupInfo.groupName) ? "" : this.GroupInfo.groupName; Thread UpdateGroupPictureThread = new Thread(GroupPublicFunction.UpdateGroupPicture); UpdateGroupPictureThread.Start(ThreadParams); //this.NewGroupPicture = input.groupPicture; } App.Current.Dispatcher.BeginInvoke((Action)(() => { this.close.Invoke(); })); }
private void CreateGroup() { // 讨论组名不能为空 //if (string.IsNullOrWhiteSpace(GroupName)) //{ // GroupNameBorderBrush = new SolidColorBrush(Colors.Red); // //GroupNameBorderThickness = new Thickness(1, 1, 1, 1); // return; //} //else //{ // GroupNameBorderBrush = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#e0e0e0")); // //GroupNameBorderThickness = new Thickness(0); //} // 讨论组成员不能少于3 if (GroupMemberList == null || GroupMemberList.Count < 3) { MessageBoxWindow.Show("讨论组至少需要包括三个成员", GlobalVariable.WarnOrSuccess.Warn); return; } if (string.IsNullOrWhiteSpace(GroupName.Trim(' ')))//自定义群名为空 取默认值 { GroupName = GetNewGroupName(); } GroupName = GroupName.TrimStart(' '); #region 旧代码 CreateGroupInput input = new CreateGroupInput(); input.token = AntSdkService.AntSdkLoginOutput.token; input.version = GlobalVariable.Version; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupName = GroupName; //获取讨论组成员头像 //List<string> picList = new List<string>(); //foreach (ContactInfoViewModel m in GroupMemberList) //{ // picList.Add(m.Photo); //} //input.groupPicture = ImageHandle.GetGroupPicture(picList); //input.groupPicture =; input.userIds = string.Join(",", GroupMemberList.Select(c => c.User.userId).ToArray()); //CreateGroupOutput output = new CreateGroupOutput(); var errCode = 0; var errMsg = string.Empty; //if (!(new HttpService()).CreateGroup(input, ref output, ref errMsg)) //{ // if (output.errorCode != "1004") // { // MessageBoxWindow.Show(errMsg,GlobalVariable.WarnOrSuccess.Warn); // } // return; //} //output.group.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //ThreadPool.QueueUserWorkItem(m => //{ //}); #endregion AntSdkCreateGroupInput newGroupInput = new AntSdkCreateGroupInput(); newGroupInput.userId = AntSdkService.AntSdkLoginOutput.userId; newGroupInput.groupName = GroupName; newGroupInput.userIds = GroupMemberList.Select(c => c.User.userId).ToArray(); //newGroupInput.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //TODO:AntSdk_Modify //DONE:AntSdk_Modify AntSdkCreateGroupOutput createGroupOutput = AntSdkService.CreateGroup(newGroupInput, ref errCode, ref errMsg); if (createGroupOutput == null) { if (!AntSdkService.AntSdkIsConnected) { errMsg = "网络已断开,请检查网络"; } if (!string.IsNullOrEmpty(errMsg)) { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } return; } createGroupOutput.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //异步更新讨论组头像,这里需要用前台线程,因此不能用线程池 string[] ThreadParams = new string[3]; ThreadParams[0] = createGroupOutput.groupId; ThreadParams[1] = createGroupOutput.groupPicture; ThreadParams[2] = string.IsNullOrEmpty(createGroupOutput.groupName) ? "" : createGroupOutput.groupName; Thread UpdateGroupPictureThread = new Thread(GroupPublicFunction.UpdateGroupPicture); UpdateGroupPictureThread.Start(ThreadParams); this.CreateGroupOutput = createGroupOutput; App.Current.Dispatcher.BeginInvoke((Action)(() => { this.close.Invoke(); })); }