Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 验证结果
        /// </summary>
        /// <param name="isShowWin"></param>
        /// <param name="state"></param>
        private void VerifyResultShow(bool isShowWin, CheckInVerifyResultState?state)
        {
            if (isShowWin)
            {
                CheckInVerifyResultView resultView = new CheckInVerifyResultView();
                resultView.DataContext = new CheckInVerifyViewModel(_attendanceContent, state, false, false);
                resultView.Topmost     = true;
                resultView.Show();
                return;
            }
            switch (state)
            {
            case CheckInVerifyResultState.TimeError:
                VerifyResultIcon = GlobalVariable.AttendanceImage.AttendValidationFailsIcon;
                VerifyResult     = "打卡验证失败";
                var checkInDataTime = PublicTalkMothed.ConvertStringToDateTime(_attendanceContent.attendTime);
                VerifyDescription = "由于未按时在PC端上完成验证,您在" + checkInDataTime.ToString("HH:mm") + "的打卡失效";
                break;

            case CheckInVerifyResultState.IPVerifyError:
                VerifyResultIcon  = GlobalVariable.AttendanceImage.AttendVerificationFailedIcon;
                VerifyResult      = "打卡验证未通过";
                VerifyDescription = "请使用公司的网络登录七讯PC版以完成验证";
                break;
            }
        }
Ejemplo n.º 4
0
 private void _dispatcherTimer_Tick(object sender, EventArgs e)
 {
     _dispatcherTimer.Stop();
     //隐藏发送状态
     PublicTalkMothed.HiddenMsgDiv(Arg.WebBrowser, Arg.SendIngId);
     //显示重发按钮
     PublicTalkMothed.VisibleMsgDiv(Arg.WebBrowser, Arg.RepeatId);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 更改界面消息显示状态
        /// </summary>
        /// <param name="state">状态</param>
        /// <param name="cef">cef</param>
        /// <param name="messageId">消息Id</param>
        public static void UpdateUiState(AntSdkburnMsg.isSendSucessOrFail state, ChromiumWebBrowser cef, string messageId)
        {
            switch (state)
            {
            case AntSdkburnMsg.isSendSucessOrFail.fail:
                PublicTalkMothed.HiddenMsgDiv(cef, messageId);
                break;

            case AntSdkburnMsg.isSendSucessOrFail.sucess:
                PublicTalkMothed.HiddenMsgDiv(cef, messageId);
                break;
            }
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
 public CheckInVerifyViewModel(AntSdkReceivedOtherMsg.AttendanceRecord_content content, CheckInVerifyResultState?state, bool IsPassword = true, bool isVerify = true)
 {
     _attendanceContent = content;
     attendId           = _attendanceContent.attendId;
     if (isVerify)
     {
         IsDisplayPassword = IsPassword;
         CheckInAddress    = content.address;
         checkInDataTime   = PublicTalkMothed.ConvertStringToDateTime(content.attendTime);
         LoadData();
     }
     else
     {
         VerifyResultShow(false, state);
     }
 }
Ejemplo n.º 8
0
 /// <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();
     }
 }
Ejemplo n.º 9
0
 /// <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();
     }
 }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 下载图片
        /// </summary>
        /// <param name="picUrl">图片Http地址</param>
        /// <param name="savePath">保存路径</param>
        /// <param name="timeOut">Request最大请求时间,如果为-1则无限制</param>
        ///<param name="actualFilePath">压缩之后保存路径(不压缩就不用传参)</param>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public static string DownloadPicture(string picUrl, string savePath, int timeOut = -1, string actualFilePath = "", string userId = "")
        {
            var         value    = "";
            WebResponse response = null;
            Stream      stream   = null;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(picUrl);
                if (timeOut != -1)
                {
                    request.Timeout = timeOut;
                }
                response = request.GetResponse();
                stream   = response.GetResponseStream();
                if (!response.ContentType.ToLower().StartsWith("Text/"))
                {
                    var isResult = SaveBinaryFile(response, savePath);
                    if (isResult)
                    {
                        if (!string.IsNullOrEmpty(actualFilePath))
                        {
                            value = GetPicThumbnail(savePath, actualFilePath, 50, 50, 96, userId);
                            if (File.Exists(savePath) && !PublicTalkMothed.IsFileInUsing(savePath))
                            {
                                File.Delete(savePath);
                            }
                        }
                    }
                }
            }
            catch
            {
                return(value);
            }
            finally
            {
                stream?.Close();
                response?.Close();
            }
            return(value);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取服务器考勤记录
        /// </summary>
        public void GetServicePunchClocksData(bool isNewRecord = false)
        {
            if (isNewRecord)
            {
                _isLast = false;
            }
            if (_isLast)
            {
                return;
            }
            AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher,
                                        () =>
            {
                if (isNewRecord)
                {
                    timer?.Stop();
                    timer = null;
                    _page = 0;
                    todayAttendanceRecords = null;
                }
                _page++;
                var errorCode         = 0;
                var errorMsg          = string.Empty;
                var punchClocksOutput = AntSdkService.GetPunchClocks(AntSdkService.AntSdkLoginOutput.userId, _page, _size, ref errorCode, ref errorMsg);
                return(punchClocksOutput);
            },
                                        (ex, datas) =>
            {
                if (isNewRecord)
                {
                    AttendanceRecords.Clear();
                }
                if (datas != null && datas.list.Count > 0)
                {
                    var serverDateTime        = PublicTalkMothed.ConvertStringToDateTime(datas.systemTime);
                    var punchClocksOutputList = datas.list.OrderByDescending(m => m.attendId);
                    foreach (var punchClocks in datas.list)
                    {
                        var exitAttendanceRecord = AttendanceRecords.FirstOrDefault(m => m.AttendId == punchClocks.attendId);
                        if (exitAttendanceRecord != null)
                        {
                            continue;
                        }
                        var attendanceRecord              = new AttendanceRecord();
                        attendanceRecord.AttendId         = punchClocks.attendId;
                        attendanceRecord.VerifyState      = punchClocks.status;
                        attendanceRecord.PuncherTimeStamp = punchClocks.attendTime;

                        if (attendanceRecord.VerifyState == 0)
                        {
                            attendanceRecord.IsbtnVerify    = true;
                            attendanceRecord.VerifyDescribe = "待验证";
                        }
                        else if (attendanceRecord.VerifyState == 1)
                        {
                            attendanceRecord.VerifyDescribe = "验证过期";
                        }
                        else if (attendanceRecord.VerifyState == 2)
                        {
                            attendanceRecord.VerifyDescribe = "打卡成功";
                        }
                        var diffMinute = serverDateTime - PublicTalkMothed.ConvertStringToDateTime(punchClocks.attendTime);
                        if ((diffMinute.Days > 0 || diffMinute.TotalMinutes > 20) && attendanceRecord.VerifyState == 0)
                        {
                            attendanceRecord.IsbtnVerify    = false;
                            attendanceRecord.VerifyDescribe = "验证过期";
                            attendanceRecord.VerifyState    = 1;
                        }
                        if (!string.IsNullOrEmpty(punchClocks.attendTime))
                        {
                            attendanceRecord.PuncherDateTime = PublicTalkMothed.ConvertStringToDateTime(punchClocks.attendTime);
                        }
                        else
                        {
                            attendanceRecord.PuncherDateTime = DateTime.Now;
                        }
                        attendanceRecord.PuncherAddress = punchClocks.address;
                        if (attendanceRecord.PuncherDateTime.Year - DateTime.Now.Year > 0)
                        {
                            attendanceRecord.PuncherDate = attendanceRecord.PuncherDateTime.ToString("yyyy年MM月dd日");
                        }
                        else
                        {
                            attendanceRecord.PuncherDate = attendanceRecord.PuncherDateTime.ToString("MM月dd日");
                        }
                        attendanceRecord.PuncherTime = attendanceRecord.PuncherDateTime.ToString("HH:mm");
                        AttendanceRecords.Insert(0, attendanceRecord);
                    }

                    _isFirst = datas.isFirstPage;
                    _isLast  = datas.isLastPage;
                    var tempAttendanceRecord = AttendanceRecords.FirstOrDefault(m => m.IsbtnVerify);
                    if (tempAttendanceRecord != null)
                    {
                        LoadData(tempAttendanceRecord);
                    }
                }
                else
                {
                }
            });
        }
Ejemplo n.º 13
0
        /// <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);
            }
        }
Ejemplo n.º 14
0
        /// 无损压缩图片
        /// <param name="sFile">原图片</param>
        /// <param name="dFile">压缩后保存位置</param>
        /// <param name="dHeight">高度</param>
        /// <param name="dWidth"></param>
        /// <param name="flag">压缩质量(数字越小压缩率越高) 1-100</param>
        /// <returns></returns>
        public static string GetPicThumbnail(string sFile, string dFile, int dHeight, int dWidth, int flag, string userID = "")
        {
            System.Drawing.Image iSource = System.Drawing.Image.FromFile(sFile);
            ImageFormat          tFormat = iSource.RawFormat;
            int sW = 0, sH = 0;

            if (iSource.Width > 50 || iSource.Height > 50)
            {
                //按比例缩放
                System.Drawing.Size tem_size = new System.Drawing.Size(iSource.Width, iSource.Height);

                if (tem_size.Width > dHeight || tem_size.Width > dWidth)
                {
                    if ((tem_size.Width * dHeight) > (tem_size.Width * dWidth))
                    {
                        sW = dWidth;
                        sH = (dWidth * tem_size.Height) / tem_size.Width;
                    }
                    else
                    {
                        sH = dHeight;
                        sW = (tem_size.Width * dHeight) / tem_size.Height;
                    }
                }
                else
                {
                    sW = tem_size.Width;
                    sH = tem_size.Height;
                }

                Bitmap   ob = new Bitmap(dWidth, dHeight);
                Graphics g  = Graphics.FromImage(ob);

                g.Clear(Color.WhiteSmoke);
                g.CompositingQuality = CompositingQuality.HighQuality;
                g.SmoothingMode      = SmoothingMode.HighQuality;
                g.InterpolationMode  = InterpolationMode.HighQualityBicubic;

                g.DrawImage(iSource, new Rectangle((dWidth - sW) / 2, (dHeight - sH) / 2, sW, sH), 0, 0, iSource.Width,
                            iSource.Height, GraphicsUnit.Pixel);

                g.Dispose();
                //以下代码为保存图片时,设置压缩质量
                EncoderParameters ep = new EncoderParameters();
                long[]            qy = new long[1];
                qy[0] = flag; //设置压缩的比例1-100
                EncoderParameter eParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qy);
                ep.Param[0] = eParam;
                try
                {
                    ImageCodecInfo[] arrayICI    = ImageCodecInfo.GetImageEncoders();
                    ImageCodecInfo   jpegICIinfo = null;
                    for (int x = 0; x < arrayICI.Length; x++)
                    {
                        if (arrayICI[x].FormatDescription.Equals("JPEG"))
                        {
                            jpegICIinfo = arrayICI[x];
                            break;
                        }
                    }
                    FileInfo fileInfo = new FileInfo(sFile);
                    var      saveFile = dFile + fileInfo.Name;
                    if (File.Exists(saveFile))
                    {
                        return(saveFile);
                    }
                    if (jpegICIinfo != null)
                    {
                        ob.Save(saveFile, jpegICIinfo, ep); //dFile是压缩后的新路径
                    }
                    else
                    {
                        ob.Save(dFile, tFormat);
                    }
                    //var tempUserImage = GlobalVariable.UserImages.FirstOrDefault(m => m.UserID == userId);
                    //if (tempUserImage == null)
                    //    GlobalVariable.UserImages.Add(new GlobalVariable.ContactUserImage
                    //    {
                    //        Url = saveFile,
                    //        UserID = userId
                    //    });
                    return(saveFile);
                }
                catch
                {
                    return(string.Empty);
                }
                finally
                {
                    iSource.Dispose();
                    ob.Dispose();
                }
            }
            else
            {
                FileInfo fileInfo  = new FileInfo(sFile);
                var      extension = Path.GetExtension(sFile);
                var      saveFile  = dFile + fileInfo.Name;
                if (!File.Exists(sFile) && !PublicTalkMothed.IsFileInUsing(saveFile))
                {
                    File.Move(sFile, saveFile);
                }
                //var tempUserImage = UserImages.FirstOrDefault(m => m.UserID == userId);
                //if (tempUserImage == null)
                //    UserImages.Add(new GlobalVariable.ContactUserImage
                //    {
                //        Url = saveFile,
                //        UserID = userId
                //    });
                return(saveFile);
            }
        }
Ejemplo n.º 15
0
        //private bool CmdPing(string strIp)
        ////通过CMD中的ping命令去得电脑上网IP
        //{
        //    bool returnvalue = false;
        //    Process p = new Process(); p.StartInfo.FileName = "cmd.exe";//设定程序名
        //    p.StartInfo.UseShellExecute = false; //关闭Shell的使用
        //    p.StartInfo.RedirectStandardInput = true;//重定向标准输入
        //    p.StartInfo.RedirectStandardOutput = true;//重定向标准输出
        //    p.StartInfo.RedirectStandardError = true;//重定向错误输出
        //    p.StartInfo.CreateNoWindow = true;//设置不显示窗口
        //    p.Start(); p.StandardInput.WriteLine("ping -n 2 -w 1 -S " + strIp + " " + "GuangWang");
        //    p.StandardInput.WriteLine("exit");
        //    string strRst = p.StandardOutput.ReadToEnd();
        //    if (strRst.IndexOf("(100% 丢失)") != -1 || strRst.IndexOf("(100% loss)") != -1)
        //    {
        //        returnvalue = false;
        //    }
        //    else
        //    {
        //        returnvalue = true;
        //    }
        //    p.Close();
        //    return returnvalue;
        //}


        /// <summary>
        /// 加载初始化数据
        /// </summary>
        private void LoadData()
        {
            string _ComputName = System.Net.Dns.GetHostName();

            listIp = NetworkHelper.GetPhysicsNetworkCardIP();
            if (listIp.Count > 0)
            {
                hostIp = listIp[0];
            }
            //System.Net.IPAddress[] _IPList = System.Net.Dns.GetHostAddresses(_ComputName);
            //for (int i = 0; i != _IPList.Length; i++)
            //{
            //    if (_IPList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            //    {

            //            hostIp = _IPList[i].ToString();
            //            MessageBoxWindow.Show(hostIp, GlobalVariable.WarnOrSuccess.Success);
            //            break;

            //    }
            //}
            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;
            }
            //设置定时器
            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);
            ChcekInTimer = processCount.GetMinute() + "分" + processCount.GetSecond() + "秒";
            CountDown   += new CountDownHandler(processCount.ProcessCountDown);

            //开启定时器
            timer.Start();
        }
Ejemplo n.º 16
0
        public VoteListViewModel(string groupId)
        {
            _groupId      = groupId;
            _voteInfoList = new ObservableCollection <VoteInfoModel>();
            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 voteList = AntSdkService.GetGroupVotes(groupId, ref errCode, ref errMsg, _page, _size, AntSdkService.AntSdkCurrentUserInfo.userId);

            if (voteList?.content != null && voteList.content.Count > 0)
            {
                foreach (var voteInfo in voteList.content)
                {
                    var tempInfoModel = new VoteInfoModel();
                    tempInfoModel.IsHaveVoted = voteInfo.voted;
                    if (voteInfo.createdBy == AntSdkService.AntSdkCurrentUserInfo.userId)
                    {
                        tempInfoModel.IsbtnDeleteVisibility = true;
                    }
                    tempInfoModel.VoteId    = voteInfo.id;
                    tempInfoModel.VoteSate  = DateTime.Compare(Convert.ToDateTime(voteInfo.expiryTime), serverDateTime) < 0;
                    tempInfoModel.VoteTitle = voteInfo.title + (voteInfo.secret ? "(匿名)" : "");
                    tempInfoModel.UserID    = voteInfo.createdBy;
                    AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == voteInfo.createdBy);
                    if (user != null)
                    {
                        tempInfoModel.Explain = user.userNum + user.userName + "  编辑于  " +
                                                DataConverter.FormatTimeByCreateTime(voteInfo.createdDate);
                        if (!string.IsNullOrWhiteSpace(user.picture) && publicMethod.IsUrlRegex(user.picture))
                        {
                            var    index         = user.picture.LastIndexOf("/", StringComparison.Ordinal) + 1;
                            var    fileNameIndex = user.picture.LastIndexOf(".", StringComparison.Ordinal);
                            var    fileName      = user.picture.Substring(index, fileNameIndex - index);
                            string strUrl        = user.picture.Replace(fileName, fileName + "_35x35");
                            var    userImage     =
                                GlobalVariable.ContactHeadImage.UserHeadImages.FirstOrDefault(
                                    m => m.UserID == user.userId);
                            tempInfoModel.UserHeadUrl = string.IsNullOrEmpty(userImage?.Url) ? strUrl : userImage.Url;
                        }
                        else
                        {
                            tempInfoModel.UserHeadUrl = GlobalVariable.DefaultImage.UserHeadDefaultImage;
                        }
                    }
                    //tempInfoModel.UserHeadUrl=
                    _voteInfoList.Add(tempInfoModel);
                }
                _isFirst = voteList.first;
                _isLast  = voteList.last;
                IsPaging = !_isLast;
            }
            else
            {
                IsVoteData = true;
                IsPaging   = false;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 分页查询投票数据
        /// </summary>
        private void LoadVotesData()
        {
            DateTime serverDateTime = DateTime.Now;

            AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher,
                                        () =>
            {
                var errCode = 0;
                var errMsg  = string.Empty;
                AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
                if (serverResult != null)
                {
                    serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
                }
                var voteList = AntSdkService.GetGroupVotes(_groupId, ref errCode, ref errMsg, _page, _size,
                                                           AntSdkService.AntSdkCurrentUserInfo.userId);
                return(voteList);
            },
                                        (ex, datas) =>
            {
                VoteInfoList.Clear();
                if (datas?.content != null && datas.content.Count > 0)
                {
                    foreach (var voteInfo in datas.content)
                    {
                        var tempInfoModel         = new VoteInfoModel();
                        tempInfoModel.IsHaveVoted = voteInfo.voted;
                        if (voteInfo.createdBy == AntSdkService.AntSdkCurrentUserInfo.userId)
                        {
                            tempInfoModel.IsbtnDeleteVisibility = true;
                        }
                        tempInfoModel.VoteId   = voteInfo.id;
                        tempInfoModel.VoteSate =
                            DateTime.Compare(Convert.ToDateTime(voteInfo.expiryTime), serverDateTime) < 0;
                        tempInfoModel.VoteTitle = voteInfo.title + (voteInfo.secret ? "(匿名)" : "");
                        tempInfoModel.UserID    = voteInfo.createdBy;
                        AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == voteInfo.createdBy);
                        if (user != null)
                        {
                            tempInfoModel.Explain = user.userNum + user.userName + "  编辑于  " +
                                                    DataConverter.FormatTimeByCreateTime(voteInfo.createdDate);
                            if (!string.IsNullOrWhiteSpace(user.picture) && publicMethod.IsUrlRegex(user.picture))
                            {
                                var userImage =
                                    GlobalVariable.ContactHeadImage.UserHeadImages.FirstOrDefault(
                                        m => m.UserID == user.userId);
                                tempInfoModel.UserHeadUrl = string.IsNullOrEmpty(userImage?.Url) ? user.picture : userImage.Url;
                            }
                            else
                            {
                                tempInfoModel.UserHeadUrl = GlobalVariable.DefaultImage.UserHeadDefaultImage;
                            }
                        }
                        //tempInfoModel.UserHeadUrl=
                        _voteInfoList.Add(tempInfoModel);
                    }
                }
                if (datas != null)
                {
                    _isFirst = datas.first;
                    _isLast  = datas.last;
                }
            });
        }
Ejemplo n.º 18
0
        public static void LeftShowPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, AntSdkContact_User user, List <string> imgId)
        {
            //显示内容解析
            List <MixMessage_content> receive = JsonConvert.DeserializeObject <List <MixMessage_content> >(msg.sourceContent);
            string        pathImage           = user.copyPicture;
            StringBuilder sbLeft = new StringBuilder();

            sbLeft.AppendLine("function myFunction()");

            sbLeft.AppendLine("{ var nodeFirst=document.createElement('div');");
            sbLeft.AppendLine("nodeFirst.className='leftd';");
            sbLeft.AppendLine("nodeFirst.id='" + msg.messageId + "';");

            //头像显示层
            sbLeft.AppendLine("var second=document.createElement('div');");
            sbLeft.AppendLine("second.className='leftimg';");
            sbLeft.AppendLine("var img = document.createElement('img');");
            sbLeft.AppendLine("img.src='" + pathImage + "';");
            sbLeft.AppendLine("img.className='divcss5Left';");
            sbLeft.AppendLine("img.id='" + user.userId + "';");
            sbLeft.AppendLine("img.addEventListener('click',clickImgCallUserId);");
            sbLeft.AppendLine("second.appendChild(img);");
            sbLeft.AppendLine("nodeFirst.appendChild(second);");

            //时间显示
            sbLeft.AppendLine("var timeshow = document.createElement('div');");
            sbLeft.AppendLine("timeshow.className='leftTimeText';");
            sbLeft.AppendLine("timeshow.innerHTML ='" + user.userNum + user.userName + "  " + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(timeshow);");

            //图文混合展示层
            //sbLeft.AppendLine("var node = document.createElement('div');");
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");

            sbLeft.AppendLine(PublicTalkMothed.divLeftCopyContent(divid));
            sbLeft.AppendLine("node.id='" + divid + "';");
            sbLeft.AppendLine("node.className='speech left';");
            int i = 0;
            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();

            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    break;

                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content?.ToString());
                    if (msg.IsSetImgLoadComplete)
                    {
                        sbInside.Append("<img id=\"" + imgId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgLeftProportion\" onload=\"scrollToend(event)\" ondblclick=\"myFunctions(event)\"/>");
                    }
                    else
                    {
                        sbInside.Append("<img id=\"" + imgId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgLeftProportion\"  ondblclick=\"myFunctions(event)\"/>");
                    }
                    i++;
                    break;

                case "0000":
                    sbInside.Append("<br/>");
                    break;
                }
            }
            sbLeft.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(node);");
            sbLeft.AppendLine("document.body.appendChild(nodeFirst);");
            sbLeft.AppendLine("}");
            sbLeft.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbLeft.ToString());
        }
Ejemplo n.º 19
0
        public ActivityDetailsViewModel(int activityId, string groupId)
        {
            _activityId = activityId;
            _groupId    = groupId;
            var      errCode        = 0;
            var      errMsg         = string.Empty;
            DateTime serverDateTime = DateTime.Now;

            AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher,
                                        () =>
            {
                AntSdkGetGroupActivityDetailsInput input = new AntSdkGetGroupActivityDetailsInput
                {
                    userId     = AntSdkService.AntSdkCurrentUserInfo.userId,
                    activityId = activityId,
                    groupId    = groupId
                };
                AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode,
                                                                                                ref errMsg);

                if (serverResult != null)
                {
                    serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
                }
                var output = AntSdkService.GetActivityInfo(input, ref errCode, ref errMsg);
                return(output);
            },
                                        (ex, datas) =>
            {
                if (datas != null)
                {
                    ActivityTitle = datas.theme;
                    if (!string.IsNullOrEmpty(datas.picture))
                    {
                        try
                        {
                            BitmapImage image = new BitmapImage();

                            image.BeginInit();

                            image.UriSource = new System.Uri(datas.picture);

                            image.DecodePixelWidth = 800;

                            image.EndInit();

                            ActivityThemePic = image;
                        }
                        catch (Exception e)
                        {
                            LogHelper.WriteError("[ActivityDetailsViewModel_ImageOnLoad]:" + e.Message + e.StackTrace + e.Source);
                        }
                    }
                    ActivityAddress   = datas.address;
                    ActivityIntroduce = datas.description;
                    latitude          = datas.latitude;
                    longitude         = datas.longitude;
                    Console.Out.WriteLine("");
                    var startTime = DateTime.Now;
                    var endTime   = DateTime.Now.AddMinutes(30);
                    if (!string.IsNullOrEmpty(datas.startTime) && !string.IsNullOrEmpty(datas.endTime))
                    {
                        startTime         = Convert.ToDateTime(datas.startTime);
                        endTime           = Convert.ToDateTime(datas.endTime);
                        TimeSpan timeSpan = endTime - startTime;
                        if (endTime.Year - startTime.Year == 0 && endTime.Day - startTime.Day == 0)
                        {
                            ActivityDateTime = startTime.ToString("yyyy-MM-dd HH:mm") + "-" +
                                               endTime.ToString("HH:mm");
                        }
                        else
                        {
                            ActivityDateTime = startTime.ToString("yyyy-MM-dd HH:mm") + "   " +
                                               endTime.ToString("yyyy-MM-dd HH:mm");
                        }
                    }
                    else
                    {
                        ActivityDateTime = startTime.ToString("yyyy-MM-dd HH:mm") + "-" +
                                           endTime.ToString("HH:mm");
                    }
                    ParticipatorsCount = datas.voteCount ?? 0;
                    if (datas.activityStatus == 1)
                    {
                        if (!datas.voteFlag)
                        {
                            if (DateTime.Compare(startTime, serverDateTime) <= 0)
                            {
                                ActivityStateContent   = "已开始";
                                IsParticipatedActivity = false;
                            }
                            else
                            {
                                ActivityStateContent   = "报名参加";
                                IsParticipatedActivity = true;
                            }
                        }
                        else
                        {
                            ActivityStateContent   = "已报名";
                            IsParticipatedActivity = false;
                        }
                    }
                    else
                    {
                        ActivityStateContent   = "已结束";
                        IsParticipatedActivity = false;
                    }
                    LoadActivityParticipators();
                }
            });
        }
Ejemplo n.º 20
0
        public static void RightSendPicAndTextMix(ChromiumWebBrowser cef, string messageId, List <MixMessageObjDto> obj, MessageStateArg arg, MixMsg mixMsgClass)
        {
            #region 图文混合Right
            StringBuilder sbRight = new StringBuilder();
            sbRight.AppendLine("function myFunction()");

            sbRight.AppendLine("{ var first=document.createElement('div');");
            sbRight.AppendLine("first.className='rightd';");
            sbRight.AppendLine("first.id='" + messageId + "';");

            //时间显示层
            sbRight.AppendLine("var timeDiv=document.createElement('div');");
            sbRight.AppendLine("timeDiv.className='rightTimeStyle';");
            sbRight.AppendLine("timeDiv.innerHTML='" + DateTime.Now.ToString("HH:mm:ss") + "';");
            sbRight.AppendLine("first.appendChild(timeDiv);");

            //头像显示层
            sbRight.AppendLine("var second=document.createElement('div');");
            sbRight.AppendLine("second.className='rightimg';");
            sbRight.AppendLine("var img = document.createElement('img');");
            sbRight.AppendLine("img.src='" + PictureAndTextMixMethod.HeadImgUrl() + "';");
            sbRight.AppendLine("img.className='divcss5';");
            sbRight.AppendLine("second.appendChild(img);");
            sbRight.AppendLine("first.appendChild(second);");

            //图文混合展示层
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");
            sbRight.AppendLine(PublicTalkMothed.divRightCopyContent(divid, messageId));
            sbRight.AppendLine("node.id='" + divid + "';");
            //sbRight.AppendLine("var node = document.createElement('div')");
            sbRight.AppendLine("node.className='speech right';");

            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();
            int           i        = 0;
            foreach (var list in obj)
            {
                //var type = list as MixMessageBase;
                switch (list.type)
                {
                //文本
                case "1001":
                    //var text = list as MixMessageDto;
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    break;

                //图片
                case "1002":
                    //var images = list as MixMessageDto;
                    var contentImg = JsonConvert.DeserializeObject <PictureDto>(list.content.ToString());
                    sbInside.Append("<img id=\"" + mixMsgClass.TagDto[i].PreGuid + "\" src=\"" + contentImg.picUrl + "\" class=\"imgRightProportion\" onload=\"scrollToend(event)\" ondblclick=\"myFunctions(event)\"/>");
                    i++;
                    break;

                //换行
                case "0000":
                    sbInside.Append("<br/>");
                    break;
                }
            }
            sbRight.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbRight.AppendLine("first.appendChild(node);");

            //重发div
            //sbRight.AppendLine(OnceSendMsgDiv("sendText", arg.MessageId, sendStr, imageTipId, imageSendingId, msgStr, ""));
            sbRight.AppendLine(PictureAndTextMixMethod.OnceSendMixPicDiv("sendMixPic", arg.MessageId, "", arg.RepeatId, arg.SendIngId, "", ""));
            sbRight.AppendLine("document.body.appendChild(first);");
            sbRight.AppendLine("}");

            sbRight.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbRight.ToString());
            #endregion
        }
Ejemplo n.º 21
0
        public static void RightScrollPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, List <string> imageId)
        {
            #region 右边展示
            StringBuilder sbRight = new StringBuilder();
            sbRight.AppendLine("function myFunction()");
            //显示内容解析
            List <MixMessageObjDto> receive = JsonConvert.DeserializeObject <List <MixMessageObjDto> >(msg.sourceContent);
            sbRight.AppendLine("{ var first=document.createElement('div');");
            sbRight.AppendLine("first.className='rightd';");
            sbRight.AppendLine("first.id='" + msg.messageId + "';");

            //时间显示层
            sbRight.AppendLine("var timeDiv=document.createElement('div');");
            sbRight.AppendLine("timeDiv.className='rightTimeStyle';");
            sbRight.AppendLine("timeDiv.innerHTML='" + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbRight.AppendLine("first.appendChild(timeDiv);");

            //头像显示层
            sbRight.AppendLine("var second=document.createElement('div');");
            sbRight.AppendLine("second.className='rightimg';");
            sbRight.AppendLine("var img = document.createElement('img');");
            sbRight.AppendLine("img.src='" + PictureAndTextMixMethod.HeadImgUrl() + "';");
            sbRight.AppendLine("img.className='divcss5';");
            sbRight.AppendLine("second.appendChild(img);");
            sbRight.AppendLine("first.appendChild(second);");
            int i = 0;
            //图文混合展示层
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");
            sbRight.AppendLine(PublicTalkMothed.divRightCopyContent(divid, msg.messageId));
            sbRight.AppendLine("node.id='" + divid + "';");
            //sbRight.AppendLine("var node = document.createElement('div')");
            sbRight.AppendLine("node.className='speech right';");

            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();
            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    break;

                //图片
                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content?.ToString());
                    sbInside.Append("<img id=\"" + imageId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgRightProportion\"  ondblclick=\"myFunctions(event)\"/>");
                    i++;
                    break;

                //换行
                case "0000":
                    sbInside.Append("<br/>");
                    break;
                }
            }
            sbRight.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbRight.AppendLine("first.appendChild(node);");
            //发送失败判断
            if (msg.sendsucessorfail == 0)
            {
                string guid = Guid.NewGuid().ToString().Replace("-", "");

                sbRight.AppendLine(PictureAndTextMixMethod.OnceSendHistoryPicDiv("sendMixPic", msg.messageId, "", guid, "sending" + guid, "", ""));
            }
            //获取body层
            sbRight.AppendLine("var listbody = document.getElementById('bodydiv');");
            sbRight.AppendLine("listbody.insertBefore(first,listbody.childNodes[0]);}");
            //sbRight.AppendLine("document.body.appendChild(first);");

            sbRight.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbRight.ToString());
            #endregion
        }
Ejemplo n.º 22
0
        //多文件上传方法
        public async void MultiFileHttpClientUpLoad(AntSdkMsgType antSdkMsgType, CurrentChatDto currentChat, MessageStateArg arg, MixMsg mixMsg, List <MixMessageObjDto> obj)
        {
            try
            {
                var        url    = AntSdkService.AntSdkConfigInfo.AntSdkMultiFileUpload;
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("user-agent", "User-Agent    Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; MALNJS; rv:11.0) like Gecko");
                HttpResponseMessage      response;
                MultipartFormDataContent mulContent = new MultipartFormDataContent();
                foreach (var list in mixMsg.TagDto)
                {
                    FileStream  fs          = new FileStream(@list.Path, FileMode.Open, FileAccess.Read, FileShare.Read);
                    HttpContent fileContent = new StreamContent(fs);
                    fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
                    int pos = list.Path.LastIndexOf("/");
                    if (pos == -1)
                    {
                        pos = list.Path.LastIndexOf("\\");
                    }
                    string fileName = list.Path.Substring(pos + 1);

                    mulContent.Add(fileContent, list.PreGuid, fileName);
                }
                string result = "";
                if (mixMsg.TagDto.Count() > 0)
                {
                    response = await client.PostAsync(new Uri(url), mulContent);

                    //var code = response.EnsureSuccessStatusCode();

                    result = await response.Content.ReadAsStringAsync();
                }
                else
                {
                    result = JsonConvert.SerializeObject(new BaseMultiDto()
                    {
                        errorCode = "0", errorMsg = "", data = null
                    });
                }
                if (!string.IsNullOrEmpty(result))
                {
                    BaseMultiDto baseMultiDto = JsonConvert.DeserializeObject <BaseMultiDto>(result);
                    if (baseMultiDto.errorCode == "0")
                    {
                        string JsonContent = "";
                        string mixError    = "";
                        bool   isResult    = false;
                        int    i           = 0;
                        if (mixMsg.TagDto.Count() > 0)
                        {
                            foreach (var list in obj)
                            {
                                //var type = list as MixMessageBase;
                                switch (list.type)
                                {
                                case "1002":
                                    //var picDto = list as MixMessageDto;
                                    PictureDto pic = JsonConvert.DeserializeObject <PictureDto>(list.content?.ToString());
                                    list.content = JsonConvert.SerializeObject(new PictureDto()
                                    {
                                        width = "50", height = "50", picUrl = baseMultiDto.data[i].dowmnloadUrl
                                    });
                                    i++;
                                    break;
                                }
                            }
                        }

                        #region New
                        List <MixMessage_content> ListMixMsg   = new List <MixMessage_content>();
                        AntSdkChatMsg.MixMessage  mixImageText = new AntSdkChatMsg.MixMessage();

                        foreach (var list in obj)
                        {
                            MixMessage_content message_Content = new MixMessage_content();
                            //var type = list as MixMessageBase;
                            switch (list.type)
                            {
                            case "1001":
                                //var text = list as MixMessageDto;
                                message_Content.type    = list.type;
                                message_Content.content = list.content;
                                break;

                            case "1002":
                                //var picDto = list as MixMessageDto;
                                message_Content.type    = list.type;
                                message_Content.content = list.content;
                                break;

                            case "1008":
                                //var at = list as MixMessageObjDto;
                                if (currentChat.isOnceSend)
                                {
                                    message_Content.type    = list.type;
                                    message_Content.content = list.content;
                                }
                                else
                                {
                                    List <object> listObj = new List <object>();
                                    message_Content.type = list.type;
                                    listObj.Add(list.content);
                                    message_Content.content = listObj;
                                }
                                break;

                            //换行
                            case "0000":
                                message_Content.type    = list.type;
                                message_Content.content = "";
                                break;
                            }
                            ListMixMsg.Add(message_Content);
                        }
                        mixImageText.content    = ListMixMsg;;
                        mixImageText.MsgType    = AntSdkMsgType.ChatMsgMixMessage;
                        mixImageText.messageId  = currentChat.messageId;
                        mixImageText.flag       = 0;
                        mixImageText.sendUserId = currentChat.sendUserId;
                        mixImageText.sessionId  = currentChat.sessionId;
                        mixImageText.targetId   = currentChat.targetId;
                        mixImageText.chatType   = (int)currentChat.type;
                        mixImageText.os         = (int)GlobalVariable.OSType.PC;
                        if (currentChat.type == AntSdkchatType.Point)
                        {
                            //消息监控
                            var IsHave = SendMsgListPointMonitor.MessageStateMonitorList.SingleOrDefault(m => m.dispatcherTimer.arg.MessageId == arg.MessageId);
                            if (IsHave != null)
                            {
                                SendMsgListPointMonitor.MessageStateMonitorList.Remove(IsHave);
                            }
                            if (SendMsgListPointMonitor.MsgIdAndImgSendingId.ContainsKey(arg.MessageId))
                            {
                                SendMsgListPointMonitor.MsgIdAndImgSendingId[arg.MessageId] = arg.SendIngId;
                            }
                            else
                            {
                                SendMsgListPointMonitor.MsgIdAndImgSendingId.Add(arg.MessageId, arg.SendIngId);
                            }
                            SendMsgListPointMonitor.MessageStateMonitorList.Add(new SendMsgStateMonitor(arg));
                        }
                        else
                        {
                            //消息监控
                            var IsHave = SendMsgListMonitor.MessageStateMonitorList.SingleOrDefault(m => m.dispatcherTimer.arg.MessageId == arg.MessageId);
                            if (IsHave != null)
                            {
                                SendMsgListMonitor.MessageStateMonitorList.Remove(IsHave);
                            }
                            if (SendMsgListMonitor.MsgIdAndImgSendingId.ContainsKey(arg.MessageId))
                            {
                                SendMsgListMonitor.MsgIdAndImgSendingId[arg.MessageId] = arg.SendIngId;
                            }
                            else
                            {
                                SendMsgListMonitor.MsgIdAndImgSendingId.Add(arg.MessageId, arg.SendIngId);
                            }
                            SendMsgListMonitor.MessageStateMonitorList.Add(new SendMsgStateMonitor(arg));
                        }
                        //发送
                        if (currentChat.isOnceSend)
                        {
                            isResult = AntSdkService.SdkRePublishChatMsg(mixImageText, ref mixError);
                        }
                        else
                        {
                            isResult = AntSdkService.SdkPublishChatMsg(mixImageText, ref mixError);
                            //if (mixMsg.TagDto.Count() == 0)
                            //{
                            //    #region 滚动条置底
                            //    arg.WebBrowser.GetMainFrame().ExecuteJavaScriptAsync("setscross();");
                            //    #endregion
                            //}
                        }

                        #endregion

                        #region old
                        //if (antSdkMsgType == AntSdkMsgType.ChatMsgMixImageText)
                        //{
                        //AntSdkChatMsg.MixImageText mixImageText = new AntSdkChatMsg.MixImageText();
                        //List<AntSdkChatMsg.MixImageText_content> imageText_Content = new List<AntSdkChatMsg.MixImageText_content>();
                        //mixImageText.messageId = currentChat.messageId;
                        //foreach (var lists in picAndTxtMix)
                        //{
                        //    if (lists.type == PictureAndTextMixEnum.Image)
                        //    {
                        //        imageText_Content.Add(new AntSdkChatMsg.MixImageText_content()
                        //        {
                        //            type = (Convert.ToInt32(lists.type).ToString()) == "0" ? "0000" : Convert.ToInt32(lists.type).ToString(),
                        //            content = JsonConvert.SerializeObject(new
                        //            PictureAndTextMixContentDto
                        //            { picUrl = lists.content })
                        //        });
                        //    }
                        //    else
                        //    {
                        //        imageText_Content.Add(new AntSdkChatMsg.MixImageText_content()
                        //        {
                        //            type = (Convert.ToInt32(lists.type).ToString()) == "0" ? "0000" : Convert.ToInt32(lists.type).ToString(),
                        //            content = lists.content
                        //        });
                        //    }
                        //}
                        //JsonContent = JsonConvert.SerializeObject(imageText_Content);
                        //mixImageText.content = imageText_Content;
                        //mixImageText.MsgType = AntSdkMsgType.ChatMsgMixImageText;
                        //mixImageText.flag = 0;
                        //mixImageText.sendUserId = currentChat.sendUserId;
                        //mixImageText.sessionId = currentChat.sessionId;
                        //mixImageText.targetId = currentChat.targetId;
                        //mixImageText.chatType = (int)currentChat.type;
                        //mixImageText.os = (int)GlobalVariable.OSType.PC;
                        //    if (currentChat.type == AntSdkchatType.Point)
                        //    {
                        //        //消息监控
                        //        var IsHave = SendMsgListPointMonitor.MessageStateMonitorList.SingleOrDefault(m => m.dispatcherTimer.arg.MessageId == arg.MessageId);
                        //        if (IsHave != null)
                        //        {
                        //            SendMsgListPointMonitor.MessageStateMonitorList.Remove(IsHave);
                        //        }
                        //        if (SendMsgListPointMonitor.MsgIdAndImgSendingId.ContainsKey(arg.MessageId))
                        //        {
                        //            SendMsgListPointMonitor.MsgIdAndImgSendingId[arg.MessageId] = arg.SendIngId;
                        //        }
                        //        else
                        //        {
                        //            SendMsgListPointMonitor.MsgIdAndImgSendingId.Add(arg.MessageId, arg.SendIngId);
                        //        }
                        //        SendMsgListPointMonitor.MessageStateMonitorList.Add(new SendMsgStateMonitor(arg));
                        //    }
                        //    else
                        //    {
                        //        //消息监控
                        //        var IsHave = SendMsgListMonitor.MessageStateMonitorList.SingleOrDefault(m => m.dispatcherTimer.arg.MessageId == arg.MessageId);
                        //        if (IsHave != null)
                        //        {
                        //            SendMsgListMonitor.MessageStateMonitorList.Remove(IsHave);
                        //        }
                        //        if (SendMsgListMonitor.MsgIdAndImgSendingId.ContainsKey(arg.MessageId))
                        //        {
                        //            SendMsgListMonitor.MsgIdAndImgSendingId[arg.MessageId] = arg.SendIngId;
                        //        }
                        //        else
                        //        {
                        //            SendMsgListMonitor.MsgIdAndImgSendingId.Add(arg.MessageId, arg.SendIngId);
                        //        }
                        //        SendMsgListMonitor.MessageStateMonitorList.Add(new SendMsgStateMonitor(arg));
                        //    }
                        //    //发送
                        //    if (currentChat.isOnceSend)
                        //    {
                        //        isResult = AntSdkService.SdkRePublishChatMsg(mixImageText, ref mixError);
                        //    }
                        //    else
                        //    {
                        //        isResult = AntSdkService.SdkPublishChatMsg(mixImageText, ref mixError);
                        //        #region 滚动条置底
                        //        StringBuilder sbEnd = new StringBuilder();
                        //        sbEnd.AppendLine("setscross();");
                        //        arg.WebBrowser.ExecuteScriptAsync(sbEnd.ToString());
                        //        #endregion
                        //    }
                        //}
                        //else
                        //{
                        //    At at = new At();
                        //    List<At_content> atContent = new List<At_content>();
                        //    at.messageId = currentChat.messageId;
                        //    foreach (var lists in picAndTxtMix)
                        //    {
                        //        switch (lists.type)
                        //        {
                        //            case PictureAndTextMixEnum.Text:
                        //                atContent.Add(new At_content()
                        //                {
                        //                    type = Convert.ToInt32(lists.type).ToString(),
                        //                    content = lists.content
                        //                });
                        //                break;
                        //            case PictureAndTextMixEnum.Image:
                        //                atContent.Add(new At_content()
                        //                {
                        //                    type = Convert.ToInt32(lists.type).ToString(),
                        //                    content = JsonConvert.SerializeObject(new
                        //                PictureAndTextMixContentDto
                        //                    { picUrl = lists.content })
                        //                });
                        //                break;
                        //            case PictureAndTextMixEnum.LineBreak:
                        //                atContent.Add(new At_content()
                        //                {
                        //                    type = Convert.ToInt32(lists.type).ToString() + "000",
                        //                    content = lists.content
                        //                });
                        //                break;
                        //            case PictureAndTextMixEnum.AtAll:
                        //                atContent.Add(new At_content()
                        //                {
                        //                    type = Convert.ToInt32(lists.type).ToString(),
                        //                });
                        //                break;
                        //            case PictureAndTextMixEnum.AtPerson:
                        //                var person = lists.obj as AntSdkChatMsg.contentAtOrdinary;
                        //                if (person == null)
                        //                {
                        //                    atContent.Add(new At_content()
                        //                    {
                        //                        type = Convert.ToInt32(lists.type).ToString(),
                        //                        ids = lists.ids,
                        //                        names = lists.names
                        //                    });
                        //                }
                        //                else
                        //                {
                        //                    atContent.Add(new At_content()
                        //                    {
                        //                        type = Convert.ToInt32(lists.type).ToString(),
                        //                        ids = person.ids,
                        //                        names = person.names
                        //                    });
                        //                }
                        //                break;
                        //        }
                        //    }
                        //    JsonContent = JsonConvert.SerializeObject(atContent);
                        //    at.sourceContent = JsonContent;
                        //    at.MsgType = AntSdkMsgType.ChatMsgAt;
                        //    at.flag = 0;
                        //    at.sendUserId = currentChat.sendUserId;
                        //    at.sessionId = currentChat.sessionId;
                        //    at.targetId = currentChat.targetId;
                        //    at.chatType = (int)currentChat.type;
                        //    at.os = (int)GlobalVariable.OSType.PC;
                        //    //消息监控
                        //    var IsHave = SendMsgListMonitor.MessageStateMonitorList.SingleOrDefault(m => m.dispatcherTimer.arg.MessageId == arg.MessageId);
                        //    if (IsHave != null)
                        //    {
                        //        SendMsgListMonitor.MessageStateMonitorList.Remove(IsHave);
                        //    }
                        //    if (SendMsgListMonitor.MsgIdAndImgSendingId.ContainsKey(arg.MessageId))
                        //    {
                        //        SendMsgListMonitor.MsgIdAndImgSendingId[arg.MessageId] = arg.SendIngId;
                        //    }
                        //    else
                        //    {
                        //        SendMsgListMonitor.MsgIdAndImgSendingId.Add(arg.MessageId, arg.SendIngId);
                        //    }
                        //    SendMsgListMonitor.MessageStateMonitorList.Add(new SendMsgStateMonitor(arg));
                        //    //发送
                        //    if (currentChat.isOnceSend)
                        //    {
                        //        isResult = AntSdkService.SdkRePublishChatMsg(at, ref mixError);
                        //    }
                        //    else
                        //    {
                        //        isResult = AntSdkService.SdkPublishChatMsg(at, ref mixError);
                        //        #region 滚动条置底
                        //        StringBuilder sbEnd = new StringBuilder();
                        //        sbEnd.AppendLine("setscross();");
                        //        arg.WebBrowser.ExecuteScriptAsync(sbEnd.ToString());
                        //        #endregion
                        //    }
                        //}
                        #endregion
                        if (isResult == true)
                        {
                            //更新数据库
                            if (currentChat.type == AntSdkchatType.Point)
                            {
                                //单聊
                                T_Chat_MessageDAL t_chat = new T_Chat_MessageDAL();
                                t_chat.UpdateContent(currentChat.messageId, AntSdkService.AntSdkConfigInfo.AntSdkCompanyCode, AntSdkService.AntSdkCurrentUserInfo.userId, JsonConvert.SerializeObject(ListMixMsg));
                            }
                            else
                            {
                                //群聊
                                T_Chat_Message_GroupDAL t_chatGroup = new T_Chat_Message_GroupDAL();
                                t_chatGroup.UpdateContent(currentChat.messageId, AntSdkService.AntSdkConfigInfo.AntSdkCompanyCode, AntSdkService.AntSdkCurrentUserInfo.userId, JsonConvert.SerializeObject(ListMixMsg));
                            }
                        }
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                //隐藏发送状态
                PublicTalkMothed.HiddenMsgDiv(arg.WebBrowser, arg.SendIngId);
                //显示重发按钮
                PublicTalkMothed.VisibleMsgDiv(arg.WebBrowser, arg.RepeatId);
            }
        }
Ejemplo n.º 23
0
        public static void RightGroupShowPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, List <string> imageId)
        {
            #region 右边展示
            StringBuilder sbRight = new StringBuilder();
            sbRight.AppendLine("function myFunction()");
            //显示内容解析
            List <MixMessageObjDto> receive = JsonConvert.DeserializeObject <List <MixMessageObjDto> >(msg.sourceContent);
            sbRight.AppendLine("{ var first=document.createElement('div');");
            sbRight.AppendLine("first.className='rightd';");
            sbRight.AppendLine("first.id='" + msg.messageId + "';");

            //时间显示层
            sbRight.AppendLine("var timeDiv=document.createElement('div');");
            sbRight.AppendLine("timeDiv.className='rightTimeStyle';");
            sbRight.AppendLine("timeDiv.innerHTML='" + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbRight.AppendLine("first.appendChild(timeDiv);");

            //头像显示层
            sbRight.AppendLine("var second=document.createElement('div');");
            sbRight.AppendLine("second.className='rightimg';");
            sbRight.AppendLine("var img = document.createElement('img');");
            sbRight.AppendLine("img.src='" + PictureAndTextMixMethod.HeadImgUrl() + "';");
            sbRight.AppendLine("img.className='divcss5';");
            sbRight.AppendLine("second.appendChild(img);");
            sbRight.AppendLine("first.appendChild(second);");

            //图文混合展示层
            //sbRight.AppendLine("var node = document.createElement('div')");
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");
            sbRight.AppendLine(PublicTalkMothed.divRightCopyContent(divid, msg.messageId));
            sbRight.AppendLine("node.id='" + divid + "';");
            sbRight.AppendLine("node.className='speech right';");
            int i = 0;
            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();
            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    //sbRight.AppendLine("node.innerHTML ='" + list.content.Replace("\r\n", "<br/>").Replace("\n", "<br/>") + "';");
                    break;

                //图片
                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content?.ToString());
                    sbInside.Append("<img id=\"" + imageId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgRightProportion\" ondblclick=\"myFunctions(event)\"/>");
                    i++;
                    break;

                //换行
                case "0000":
                    sbInside.Append("<br/>");
                    break;

                //@消息
                case "1008":
                    List <At_content> at    = JsonConvert.DeserializeObject <List <At_content> >(list.content.ToString());
                    string            strAt = "";
                    foreach (var atList in at)
                    {
                        if (atList.type == "1112")
                        {
                            foreach (var atName in atList.names)
                            {
                                strAt += "@" + atName;
                            }
                            sbInside.Append(strAt);
                        }
                        else
                        {
                            #region @全体成员
                            sbInside.Append("@全体成员");
                            #endregion
                        }
                    }
                    break;
                }
            }
            sbRight.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbRight.AppendLine("first.appendChild(node);");
            //获取body层

            sbRight.AppendLine("document.body.appendChild(first);}");

            sbRight.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbRight.ToString());
            #endregion
        }
Ejemplo n.º 24
0
        public static void LeftGroupScrollPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, List <AntSdkGroupMember> GroupMembers, List <string> imageId)
        {
            AntSdkGroupMember user = PictureAndTextMixMethod.getGroupMembersUser(GroupMembers, msg);
            //显示内容解析
            List <MixMessageObjDto> receive = JsonConvert.DeserializeObject <List <MixMessageObjDto> >(msg.sourceContent);
            StringBuilder           sbLeft  = new StringBuilder();

            sbLeft.AppendLine("function myFunction()");

            sbLeft.AppendLine("{ var nodeFirst=document.createElement('div');");
            sbLeft.AppendLine("nodeFirst.className='leftd';");
            sbLeft.AppendLine("nodeFirst.id='" + msg.messageId + "';");

            //头像显示层
            sbLeft.AppendLine("var second=document.createElement('div');");
            sbLeft.AppendLine("second.className='leftimg';");
            sbLeft.AppendLine("var img = document.createElement('img');");
            sbLeft.AppendLine("img.src='" + PictureAndTextMixMethod.getPathImage(GroupMembers, msg) + "';");
            sbLeft.AppendLine("img.className='divcss5Left';");
            sbLeft.AppendLine("img.id='" + user.userId + "';");
            sbLeft.AppendLine("img.addEventListener('click',clickImgCallUserId);");
            sbLeft.AppendLine("second.appendChild(img);");
            sbLeft.AppendLine("nodeFirst.appendChild(second);");

            //时间显示
            sbLeft.AppendLine("var timeshow = document.createElement('div');");
            sbLeft.AppendLine("timeshow.className='leftTimeText';");
            sbLeft.AppendLine("timeshow.innerHTML ='" + user.userNum + user.userName + "  " + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(timeshow);");
            int i = imageId.Count();
            //图文混合展示层
            //sbLeft.AppendLine("var node = document.createElement('div');");
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");

            sbLeft.AppendLine(PublicTalkMothed.divLeftCopyContent(divid));
            sbLeft.AppendLine("node.id='" + divid + "';");
            sbLeft.AppendLine("node.className='speech left';");

            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();

            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    break;

                //图片
                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content.ToString());
                    sbInside.Append("<img id=\"" + imageId[i - 1] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgLeftProportion\" ondblclick=\"myFunctions(event)\"/>");
                    i--;
                    break;

                //@消息
                case "1008":
                    List <At_content> at    = JsonConvert.DeserializeObject <List <At_content> >(list.content.ToString());
                    string            strAt = "";
                    foreach (var atList in at)
                    {
                        if (atList.type == "1112")
                        {
                            foreach (var atName in atList.names)
                            {
                                strAt += "@" + atName;
                            }
                            sbInside.Append(strAt);
                        }
                        else
                        {
                            #region @全体成员
                            sbInside.Append("@全体成员");
                            #endregion
                        }
                    }
                    break;

                //换行
                case "0000":
                    sbInside.Append("<br/>");
                    break;
                }
            }
            sbLeft.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(node);");
            //获取body层
            sbLeft.AppendLine("var listbody = document.getElementById('bodydiv');");
            sbLeft.AppendLine("listbody.insertBefore(nodeFirst,listbody.childNodes[0]);}");
            //sbLeft.AppendLine("document.body.appendChild(nodeFirst);");

            sbLeft.AppendLine("myFunction();");
            cef.EvaluateScriptAsync(sbLeft.ToString());;
        }