Ejemplo n.º 1
0
 /// <summary>
 /// 发送心跳包
 /// </summary>
 /// <returns></returns>
 public bool SendHeartBeat()
 {
     byte[] msgBytes   = Encoding.UTF8.GetBytes(TmoShare.SetValueToJson(DateTime.Now));
     byte[] headBytes  = BitConverter.GetBytes(7777);
     byte[] heartBytes = new byte[headBytes.Length + msgBytes.Length];
     headBytes.CopyTo(heartBytes, 0);
     msgBytes.CopyTo(heartBytes, 4);
     return(SendBS(heartBytes));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取json类型的值
        /// </summary>
        /// <returns></returns>
        public string GetJsonValue()
        {
            object value = GetValue();

            if (value == null)
            {
                return(null);
            }
            return(TmoShare.SetValueToJson(value));
        }
Ejemplo n.º 3
0
        string GetDataJsonString()
        {
            List <Control> list = TmoComm.GetChildrenControl(xtraTabControlMain, true);
            Dictionary <string, object> listdata = new Dictionary <string, object>();

            if (_aclb_id != -1)
            {
                listdata.Add("aclb_id", _aclb_id);
            }

            list.ForEach(x =>
            {
                if (x.Tag != null)
                {
                    string key = x.Tag.ToString();
                    if (x is BaseEdit)
                    {
                        BaseEdit be  = (BaseEdit)x;
                        object value = null;
                        if (x is DateEdit)
                        {
                            if (be.EditValue != null)
                            {
                                value = be.EditValue;
                            }
                            else
                            {
                                value = default(DateTime);
                            }
                        }
                        else
                        {
                            value = be.EditValue == null ? "" : be.EditValue;
                        }

                        listdata.Add(key, value);
                    }
                    else if (x is CheckedListBoxControl)
                    {
                        CheckedListBoxControl chkControl = (CheckedListBoxControl)x;
                        string str = GetCheckedListBoxChecked(chkControl);
                        if (!string.IsNullOrEmpty(str))
                        {
                            listdata.Add(key, str);
                        }
                    }
                    else if (x is DateTimePicker)
                    {
                        DateTimePicker dateTimeControl = (DateTimePicker)x;
                        listdata.Add(key, dateTimeControl.Value);
                    }
                }
            });
            return(TmoShare.SetValueToJson(listdata));
        }
Ejemplo n.º 4
0
 private void Instance_DataReceived(TCPServerClient client, int head, byte[] buffer, string strdata = null)
 {
     if (head == 7777) //心跳包
     {
         string updateStr = CheckUpdate(client.ClientVer);
         if (updateStr != null) //存在新版本客户端
         {
             string upStr = string.Format("发现新版本客户端,请重启软件更新!\n{0}", updateStr);
             client.SendString(upStr);
         }
     }
     else if (head == 102) //生日提醒反馈
     {
         string userid = TCPServerClient.ParserString(buffer);
         Dictionary <string, object> dic = new Dictionary <string, object>();
         dic.Add("birthday_remid_year", DateTime.Now.Year);
         bool suc = Tmo_FakeEntityManager.Instance.SubmitData(DBOperateType.Update, "tmo_userinfo", "user_id",
                                                              userid, dic);
         LogHelper.Log.Info("生日提醒:" + userid + " - " + suc);
     }
     else if (head == 200) //用户登录
     {
         strdata = TCPServerClient.ParserString(buffer);
         if (string.IsNullOrEmpty(strdata))
         {
             client.SendCommand(200, TmoShare.SetValueToJson(new DocInfo()
             {
                 err_Code = -1
             }), false);
         }
         else
         {
             string[] strarray = strdata.Split(';');
             if (strarray.Length < 2)
             {
                 client.SendCommand(200, TmoShare.SetValueToJson(new DocInfo()
                 {
                     err_Code = -1
                 }), false);
             }
             else
             {
                 string  uid = strarray[0];
                 string  pwd = strarray[1];
                 DocInfo doc = tmo_docInfoManager.Instance.CheckDocAuth(uid, pwd);
                 if (doc.err_Code != 0)
                 {
                     client.SendCommand(200, TmoShare.SetValueToJson(doc), false);
                 }
                 else
                 {
                     if (TCPServer.Instance.Clients.Any(x => x.DocInfo != null && x.DocInfo != client.DocInfo && x.DocInfo.doc_id == doc.doc_id)
                         ) //存在 证明登录相同用户
                     {
                         client.SendCommand(200, TmoShare.SetValueToJson(new DocInfo()
                         {
                             err_Code = 3
                         }), false);
                     }
                     else
                     {
                         client.DocInfo = doc;
                         client.SendCommand(200, TmoShare.SetValueToJson(doc), false);
                     }
                 }
             }
         }
     }
 }