示例#1
0
 /// <summary>
 /// 关闭系统
 /// </summary>
 private void CloseSystem()
 {
     SocketCls.Emit(ClientSendCmdEnum.logout, "");//退出
     SocketCls.DisConnectServer();
     SocketCls.s.Dispose();
     #region 写日志
     LogModel log = new LogModel()
     {
         Origin       = "汽车衡_" + LoginUser.Role.Name,
         FunctionName = "坐席主窗体_关闭系统",
         Level        = LogConstParam.LogLevel_Info,
         Direction    = LogConstParam.Directions_In,
         Msg          = "发送Socket退出命令【" + ClientSendCmdEnum.logout + "】给任务服务器",
         ParamList    = new List <DataParam>()
         {
             new DataParam()
             {
                 ParamName = "cmd", ParamValue = ClientSendCmdEnum.logout
             }
         },
         CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
         OperateUserName = LoginUser.Name
     };
     Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
     #endregion
     Application.Current.Shutdown();
 }
示例#2
0
        /// <summary>
        /// 系统注销
        /// </summary>
        private void LoginOutSystem()
        {
            SocketCls.Emit(ClientSendCmdEnum.logout, "");//退出
            SocketCls.DisConnectServer();
            SocketCls.s.Dispose();
            SocketCls.s = null;
            #region 写日志
            LogModel log = new LogModel()
            {
                CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                Direction       = LogConstParam.Directions_In,
                FunctionName    = "坐席主窗体_系统注销",
                Level           = LogConstParam.LogLevel_Info,
                Msg             = "注销系统",
                Origin          = "汽车衡_" + LoginUser.Role.Name,
                OperateUserName = LoginUser.Name
            };
            Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
            #endregion

            System.Windows.Forms.Application.Restart();
            System.Threading.Thread.Sleep(500);
            Application.Current.Shutdown(0);

            //Login loginWindow = new Login();
            //loginWindow.Show();
            //isAllowClose = true;
            //this.Close();
        }
示例#3
0
        public int cmd2client(string paramJson, int RandomNum)
        {
            hasStarted   = true;
            getRandomNum = RandomNum;
            int time = 0;

            while (hasStarted)
            {
                if (setreplyCount <= replyCount)
                {
                    if (time >= reSendInterval)
                    {
                        int state = SocketCls.Emit(SeatSendCmdEnum.cmd2client, paramJson);
                        time = 0;
                        setreplyCount++;
                    }
                    Thread.Sleep(50);
                    time += 50;
                    Application.DoEvents();
                    // loadCompleted.WaitOne(5000);
                }
                else
                {
                    SocketCls.listenEvent -= SocketCls_listenEvent;
                    return(-1);
                }
            }
            return(0);
        }
示例#4
0
        /// <summary>
        /// 汽车衡终端关注维护后坐席主页面的处理
        /// </summary>
        /// <param name="wcau"></param>
        private void OperateCarMeasure(WeightClientAttentionUpholdView wcau)
        {
            RemoteCarMeasureViewModel rcmvm = this.DataContext as RemoteCarMeasureViewModel;
            var notCheckedAttionsIds        = (from r in wcau.Attentions where r.IsChecked == false select r.equcode).ToList();
            var checkedAttentions           = (from r in wcau.Attentions where r.IsChecked == true select r).ToList();
            var removeClients = (from r in rcmvm.CarWeighterClientInfos where notCheckedAttionsIds.Contains(r.ClientId) select r).ToList();

            foreach (var item in removeClients)
            {
                rcmvm.CarWeighterClientInfos.Remove(item); //在已有的称点信息中删除未选中的称点
            }
            foreach (var item in checkedAttentions)        //将新添加的称点添加到集合里
            {
                var list = (from r in rcmvm.CarWeighterClientInfos where r.ClientId == item.equcode select r).ToList();
                if (list == null || list.Count == 0)
                {
                    rcmvm.CarWeighterClientInfos.Add(new WeighterClientModel()
                    {
                        ClientId = item.equcode, LeftLightState = LeftLightStates.None, RightLightState = RightLightStates.None, ClientState = WeighterStates.None, ClientName = item.equname, Weight = 0, LeftLine = Visibility.Hidden, RightLine = Visibility.Hidden, ClientConfigName = item.equcode + "_" + item.equname + ".xml"
                    });
                }
            }
            rcmvm.CarWeighterClientInfos = rcmvm.CarWeighterClientInfos.OrderBy(r => Int32.Parse(r.ClientId.Substring(1))).ToList();
            //任务服务器断开然后重新连接
            SocketCls.Emit(ClientSendCmdEnum.logout, ""); //断开与任务服务器的连接
            rcmvm.LoginOut();                             //与任务服务器断开连接后的相关业务处理
            rcmvm.relogin();                              //重新登录时,会将称点关注改变后的称点ID集合发送给任务服务器。
            ConfigSynchronous(checkedAttentions);
        }
示例#5
0
 /// <summary>
 /// 往称点发送信息
 /// </summary>
 private void SendInfoToClient(string infos)
 {
     try
     {
         //logH.SaveLog("随车通知:" + infos);
         #region 日志
         LogModel log = new LogModel()
         {
             CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
             Direction       = LogConstParam.Directions_Out,
             FunctionName    = "坐席_向称点发送通知信息_发送信息",
             Level           = LogConstParam.LogLevel_Info,
             Msg             = "随车通知:" + infos,
             Origin          = LoginUser.Role.Name,
             OperateUserName = LoginUser.Name
         };
         Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
         #endregion
         int unm  = CommonMethod.CommonMethod.GetRandom();
         var para = new
         {
             clientid = clientCode,
             cmd      = ParamCmd.UserNotice,
             msg      = infos + "~$",
             msgid    = unm
         };
         SocketCls.Emit(SeatSendCmdEnum.cmd2client, JsonConvert.SerializeObject(para));
     }
     catch (Exception ex)
     {
         #region 写日志
         LogModel log = new LogModel()
         {
             CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
             Direction    = LogConstParam.Directions_Out,
             FunctionName = "坐席_向称点发送通知信息_发送信息",
             Level        = LogConstParam.LogLevel_Error,
             Msg          = "往秤体发送通知错误:" + ex.Message,
             Origin       = LoginUser.Role.Name,
             IsDataValid  = LogConstParam.DataValid_Ok,
             ParamList    = new List <DataParam>()
             {
                 new DataParam()
                 {
                     ParamName = "cmd", ParamValue = SeatSendCmdEnum.cmd2client
                 }
             },
             OperateUserName = LoginUser.Name
         };
         Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
         #endregion
     }
 }
示例#6
0
        /// <summary>
        /// 向任务服务器发送语音对讲结束的方法
        /// </summary>
        /// <param name="obj"></param>
        public static void SendVoiceTalkEndToMeasure(string measureClientId)
        {
            int unm  = CommonMethod.CommonMethod.GetRandom();
            var para = new
            {
                clientid = measureClientId,
                cmd      = ParamCmd.Voice_Talk_End,
                msg      = "语音对讲结束",
                msgid    = unm
            };

            SocketCls.Emit(SeatSendCmdEnum.cmd2client, JsonConvert.SerializeObject(para));
            // SocketCls.Emit(SeatSendCmdEnum.cmd2client, paraJsonStr)
        }
示例#7
0
        /// <summary>
        /// 向任务服务器发送语音提示的方法
        /// </summary>
        /// <param name="obj"></param>
        public static void SendVoiceInfoToMeasure(object obj, string measureClientId)
        {
            VoiceModel vm   = obj as VoiceModel;
            int        unm  = CommonMethod.CommonMethod.GetRandom();
            var        para = new
            {
                clientid = measureClientId,
                cmd      = ParamCmd.Voice_Prompt,
                msg      = vm,
                msgid    = unm
            };

            SocketCls.Emit(SeatSendCmdEnum.cmd2client, JsonConvert.SerializeObject(para));
        }
示例#8
0
        /// <summary>
        /// 向任务服务器发送打印票据信息
        /// </summary>
        private void SendPrintTicket(string userMemo)
        {
            string carNo   = string.Empty;
            string matchid = string.Empty;

            if (SelectedTabControlIndex == 0)
            {
                carNo   = this.SelectedJingRecord.carno;
                matchid = this.SelectedJingRecord.matchid;
            }
            else if (SelectedTabControlIndex == 1)
            {
                carNo   = this.SelectedMaoRecord.carno;
                matchid = this.SelectedMaoRecord.matchid;
            }
            if (string.IsNullOrEmpty(userMemo))
            {
                userMemo = "补打";
            }
            PrintInfo pm = new PrintInfo()
            {
                carno      = carNo,
                clientcode = this.selectedMeasure.equcode,
                clientname = this.selectedMeasure.equname,
                matchid    = matchid,
                opcode     = LoginUser.Code,
                opname     = LoginUser.Name,
                printtype  = userMemo + "(" + LoginUser.Code + ")",
                TicketType = SelectedTabControlIndex
            };

            int unm  = CommonMethod.CommonMethod.GetRandom();
            var para = new
            {
                clientid = this.selectedMeasure.equcode,
                cmd      = ParamCmd.Supplement,
                msg      = pm,
                msgid    = unm
            };

            SocketCls.Emit(SeatSendCmdEnum.cmd2client, JsonConvert.SerializeObject(para));
            SocketCls.listenEvent += SocketCls_listenEvent;
            isShowChildFormMsg     = false;
            waitPrintReusltTimer.Start();
        }
示例#9
0
 private void btnExit_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("您确定要退出系统吗?", "退出", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         #region log
         LogModel log = new LogModel()
         {
             Origin       = "汽车衡_" + ClientInfo.Name,
             FunctionName = "称点主窗体_MainWindow",
             Level        = LogConstParam.LogLevel_Error,
             CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
             Direction    = LogConstParam.Directions_Out,
             Msg          = "秤点主窗体关闭按钮被点击,退出系统。"
         };
         Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
         #endregion
         SocketCls.Emit(ClientSendCmdEnum.logout, "");//退出
         if (SocketCls.s != null)
         {
             SocketCls.s.Dispose();
         }
         Application.Current.Shutdown();
     }
 }
示例#10
0
        /// <summary>
        /// 选择坐席后转发他人业务实现
        /// </summary>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b    = sender as Button;
            var    list = (from r in Seats where r.seatname == b.Content.ToString().Trim() select r).ToList();

            if (list.Count > 0)
            {
                var data = new
                {
                    clientid  = this.clientId,
                    newseatid = list.First().seatid
                };
                string paramJson = Talent.CommonMethod.InfoExchange.ToJson(data);
                try
                {
                    SocketCls.Emit(SeatlistenCmdEnum.redirectTask, paramJson);
                    this.Focus();
                    #region 写日志
                    LogModel log = new LogModel()
                    {
                        Origin       = LoginUser.Role.Name,
                        FunctionName = "坐席任务处理窗体_关闭窗体_任务转发_选择坐席后转发他人业务实现",
                        Level        = LogConstParam.LogLevel_Info,
                        Direction    = LogConstParam.Directions_Out,
                        Msg          = "发送转发任务命令【" + SeatlistenCmdEnum.redirectTask + "】给任务服务器",
                        Data         = data,
                        IsDataValid  = LogConstParam.DataValid_Ok,
                        ParamList    = new List <DataParam>()
                        {
                            new DataParam()
                            {
                                ParamName = "clientid", ParamValue = this.clientId
                            }, new DataParam()
                            {
                                ParamName = "newseatid", ParamValue = list.First().equcode
                            }
                        },
                        CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        OperateUserName = LoginUser.Name
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
                    #endregion
                    //转发之后自动关闭,去掉等待……
                    CloseTaskWindow.Dispatcher.Invoke(new Action(() =>
                    {
                        CloseTaskWindow.FormState = 2;
                        CloseTaskWindow.Close();
                    }));
                }
                catch (Exception)
                {
                    System.Windows.Forms.MessageBox.Show("任务转发失败,请确认与任务服务器连接是否正常!");
                    #region 写日志
                    LogModel log = new LogModel()
                    {
                        Origin       = LoginUser.Role.Name,
                        FunctionName = "坐席任务处理窗体_关闭窗体_任务转发_选择坐席后转发他人业务实现",
                        Level        = LogConstParam.LogLevel_Error,
                        Direction    = LogConstParam.Directions_Out,
                        Msg          = "发送转发任务命令【" + SeatlistenCmdEnum.redirectTask + "】给任务服务器失败.",
                        Data         = data,
                        IsDataValid  = LogConstParam.DataValid_Ok,
                        ParamList    = new List <DataParam>()
                        {
                            new DataParam()
                            {
                                ParamName = "clientid", ParamValue = this.clientId
                            }, new DataParam()
                            {
                                ParamName = "newseatid", ParamValue = list.First().equcode
                            }
                        },
                        CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        OperateUserName = LoginUser.Name
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
                    #endregion
                }
            }
        }
示例#11
0
 /// <summary>
 /// 发送
 /// </summary>
 /// <param name="sEquecode"></param>
 private void SendClearNotic(List <string> sEquecode)
 {
     for (int i = 0; i < Attentions.Count; i++)
     {
         SeatAttentionWeightModel attion = Attentions[i];
         if (attion.IsChecked)//选中
         {
             try
             {
                 int unm  = CommonMethod.CommonMethod.GetRandom();
                 var para = new
                 {
                     clientid = attion.equcode,
                     cmd      = ParamCmd.UserNotice,
                     msg      = "ClearNoticeInfos",
                     msgid    = unm
                 };
                 SocketCls.Emit(SeatSendCmdEnum.cmd2client, JsonConvert.SerializeObject(para));
                 #region 写日志
                 LogModel log = new LogModel()
                 {
                     CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                     Direction    = LogConstParam.Directions_Out,
                     FunctionName = "坐席_发送通知窗体_发送清空通知",
                     Level        = LogConstParam.LogLevel_Info,
                     Msg          = attion.seatname + "坐席往秤体发送清空通知",
                     Origin       = "汽车衡_" + LoginUser.Role.Name,
                     Data         = para,
                     IsDataValid  = LogConstParam.DataValid_Ok,
                     ParamList    = new List <DataParam>()
                     {
                         new DataParam()
                         {
                             ParamName = "cmd", ParamValue = SeatSendCmdEnum.cmd2client
                         }
                     },
                     OperateUserName = LoginUser.Name
                 };
                 Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
                 #endregion
             }
             catch (Exception ex)
             {
                 #region 写日志
                 LogModel log = new LogModel()
                 {
                     CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                     Direction    = LogConstParam.Directions_Out,
                     FunctionName = "坐席_发送通知窗体_发送清空通知",
                     Level        = LogConstParam.LogLevel_Info,
                     Msg          = attion.seatname + "坐席往秤体发送清空通知:" + ex.Message,
                     Origin       = LoginUser.Role.Name,
                     Data         = "",
                     IsDataValid  = LogConstParam.DataValid_Ok,
                     ParamList    = new List <DataParam>()
                     {
                         new DataParam()
                         {
                             ParamName = "cmd", ParamValue = SeatSendCmdEnum.cmd2client
                         }
                     },
                     OperateUserName = LoginUser.Name
                 };
                 Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
                 #endregion
             }
         }
     }
 }