Exemple #1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (!Commons.IsIPAddress(TextIP.Text))
            {
                MessageBox.Show(Strings.ClientFormMsg1);
                return;
            }

            if (this.SelectedID > 0)
            {
                DialogResult res = MessageBox.Show(Strings.ClientFormMsg2, Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                if (res == DialogResult.Cancel)
                    return;
            }

            JsonObjectCollection data = new JsonObjectCollection();
            data.Add(new JsonNumericValue("id", this.SelectedID));
            data.Add(new JsonStringValue("name", TextName.Text));
            data.Add(new JsonStringValue("ip", TextIP.Text));

            if(ChkIsAdmin1.Checked)
                data.Add(new JsonNumericValue("is_admin", 1));
            else
                data.Add(new JsonNumericValue("is_admin", 0));

            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CLIENT_ADD));
            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
        }
Exemple #2
0
        private void MenuClassForm_Load(object sender, EventArgs e)
        {
            this.Text = Strings.MenuClassFormTitle;
            this.BtnAdd.Text = Strings.MenuClassFormBtnAdd;
            this.BtnDelete.Text = Strings.MenuClassFormBtnDelete;

            //获取分类数据
            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_LIST));
            ConnHelper.SendString(jsonData.ToString());
        }
        public static bool JsonOutput(string filename, List<Core.Node> ChildList)
        {
            JsonUtility.GenerateIndentedJsonText = true;
            JsonArrayCollection collection = new JsonArrayCollection("Map");

            foreach (var child in ChildList)
            {
                JsonObjectCollection obj = new JsonObjectCollection();
                JsonArrayCollection array;
                float[] arrayValue;

                // class Name
                obj.Add(new JsonStringValue("Class", child.GetClassName()));
                // Object Name
                obj.Add(new JsonStringValue("Name", child.GetObjectName()));

                /////////////// Positon ///////////////
                array = new JsonArrayCollection("Position");
                arrayValue = child.GetPosition();
                array.Add(new JsonNumericValue(null, arrayValue[0]));
                array.Add(new JsonNumericValue(null, arrayValue[1]));
                array.Add(new JsonNumericValue(null, arrayValue[2]));

                obj.Add(array);

                //////////////// Scale ////////////////
                array = new JsonArrayCollection("Scale");
                arrayValue = child.GetScale();
                array.Add(new JsonNumericValue(null, arrayValue[0]));
                array.Add(new JsonNumericValue(null, arrayValue[1]));
                array.Add(new JsonNumericValue(null, arrayValue[2]));

                obj.Add(array);

                ///////////// Front Vector ////////////
                array = new JsonArrayCollection("FrontVector");
                arrayValue = child.GetFrontVector();
                array.Add(new JsonNumericValue(null, arrayValue[0]));
                array.Add(new JsonNumericValue(null, arrayValue[1]));
                array.Add(new JsonNumericValue(null, arrayValue[2]));

                obj.Add(array);

                // Add This Object
                collection.Add(obj);
            }
            JsonObjectCollection root = new JsonObjectCollection();
            root.Add(collection);
            System.IO.File.WriteAllText("test.json", root.ToString());

            return true;
        }
        private void BtnGetData_Click(object sender, EventArgs e)
        {
            long timeFrom = Commons.UnixTimeTo(DateTime.Parse(TimeFromDateTimePicker.Text));
            long timeTo = Commons.UnixTimeTo(DateTime.Parse(TimeToDateTimePicker.Text));

            JsonObjectCollection data = new JsonObjectCollection();
            data.Add(new JsonNumericValue("time_from", timeFrom));
            data.Add(new JsonNumericValue("time_to", timeTo));

            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_REPORT_MONTH));
            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
        }
        private void MenuBigImgViewForm_Load(object sender, EventArgs e)
        {
            if(this.MenuID == 0)
            {
                //本地路径
                BigImagePictureBox.Image = new Bitmap(this.BigImagePath);
            }
            else
            {
                //远程路径
                JsonObjectCollection jsonData = new JsonObjectCollection();
                jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_BIG_IMAGE));
                jsonData.Add(new JsonNumericValue("data", this.MenuID));
                ConnHelper.SendString(jsonData.ToString());
            }

        }
Exemple #6
0
        private void ClientForm_Load(object sender, EventArgs e)
        {
            this.Text = Strings.ClientFormTitle;

            //设置行高
            ImageList imageList = new ImageList();
            imageList.ImageSize = new Size(1, 25);
            this.ClientList.SmallImageList = imageList;

            this.ClientList.Columns.Add("", 0);
            this.ClientList.Columns.Add(Strings.ClientFormListTitle1, 150).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.ClientList.Columns.Add(Strings.ClientFormListTitle2, 180).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.ClientList.Columns.Add(Strings.ClientFormListTitle3, 150).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

            //获取客户端列表数据
            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CLIENT_LIST));
            ConnHelper.SendString(jsonData.ToString());
        }
Exemple #7
0
        private void MenuForm_Load(object sender, EventArgs e)
        {
            this.Text = Strings.MenuFormTitle;
            this.LabMenuClass.Text = Strings.MenuFormLabMenuClass;
            this.BtnAdd.Text = Strings.MenuFormBtnAdd;

            //设置行高
            ImageList imageList = new ImageList();
            imageList.ImageSize = new Size(1, 25);
            this.MenuDataList.SmallImageList = imageList;

            this.MenuDataList.Columns.Add("", 0);
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle1, 180).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle2, 120).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle3, 120).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.MenuDataList.Columns.Add(Strings.MenuFormListTitle4, 120).TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            
            //获取分类数据
            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_LIST));
            ConnHelper.SendString(jsonData.ToString());
        }
Exemple #8
0
        private void OrderDetailList_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (this.OrderDetailList.SelectedItems.Count == 1)
                {
                    this.OrderDetailListSelectedIndex = this.OrderDetailList.SelectedItems[0].Index;
                    if (this.OrderDetailStatusList[this.OrderDetailListSelectedIndex] == 0)
                    {
                        //弹出开通确认框
                        DialogResult res = MessageBox.Show(string.Format(Strings.MainFormOrderDetailDialogMsg, this.OrderDetailNameList[this.OrderDetailListSelectedIndex]), Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                        if (res == DialogResult.OK)
                        {
                            JsonObjectCollection jsonData = new JsonObjectCollection();
                            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ORDER_DETAIL_CHANGE_STATUS));
                            jsonData.Add(new JsonNumericValue("data", this.OrderDetailIDList[this.OrderDetailListSelectedIndex]));
                            ConnHelper.SendString(jsonData.ToString());
                        }
                    }

                }
            }

        }
Exemple #9
0
        public void WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            JsonTextParser parser = new JsonTextParser();
            JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(e.Message); 
            if (((JsonNumericValue)jsonData["ok"]).Value == 1)
            {
                //子窗口相关
                if (this.SubForm != null)
                {
                    if (this.SubForm is OrderDayReportForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_REPORT_DAY))                    
                        ((OrderDayReportForm)this.SubForm).ShowData(e.Message); //订单日报表
                    else if (this.SubForm is OrderMonthReportForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_REPORT_MONTH))
                        ((OrderMonthReportForm)this.SubForm).ShowData(e.Message); //订单月报表
                    else if (this.SubForm is ClientForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_CLIENT_LIST))
                        ((ClientForm)this.SubForm).ShowData(e.Message); //客户端管理
                    else if (this.SubForm is MenuClassForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU_CLASS))
                        ((MenuClassForm)this.SubForm).ShowData(e.Message); //菜单分类
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU_CLASS))
                        ((MenuForm)this.SubForm).ShowData(e.Message); //菜单列表的分类部分
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU))
                        ((MenuForm)this.SubForm).ShowData(e.Message); //菜单列表的数据部分
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_BIG_IMAGE))
                    {
                        if (((MenuForm)this.SubForm).SubForm != null && ((MenuAddForm)((MenuForm)this.SubForm).SubForm).SubForm != null)
                            ((MenuBigImgViewForm)((MenuAddForm)((MenuForm)this.SubForm).SubForm).SubForm).ShowData(e.Message); //菜单显示图片
                    }
                    else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_SELECTED_MENU_CLASS))                    
                        ((MenuForm)this.SubForm).MenuClassListSelectedWithID((int)((JsonNumericValue)jsonData["data"]).Value); //添加修改删除菜单数据后更新菜单数据列表
                    
                }

                if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_TOMAIN) || ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_GET_ONLINE_LIST))
                {
                    { 
                        //发送获取在线列表的请求
                        jsonData = new JsonObjectCollection();
                        jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ONLINE_LIST));
                        ConnHelper.SendString(jsonData.ToString());
                    }
                    
                    {
                        //获取下单明细列表
                        jsonData = new JsonObjectCollection();
                        jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ORDER_DETAIL));
                        ConnHelper.SendString(jsonData.ToString());
                    }
                }
                else if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_ONLINE_LIST))
                { 
                    //显示在线列表

                    this.InformationDeskIndices = new List<int>();
                    this.ClientOrderStatusList = new Dictionary<int, int>();
                    this.ClientStatusList = new Dictionary<int, int>();
                    this.ClientNameList = new Dictionary<int, string>();
                    this.OnlineList.Items.Clear();

                    JsonArrayCollection data = (JsonArrayCollection)jsonData["data"];
                    for (int i = 0; i < data.Count; i++)
                    {
                        JsonObjectCollection itemData = (JsonObjectCollection)data[i];

                        if (((JsonNumericValue)itemData["is_admin"]).Value == 1)
                        {
                            //服务台
                            ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonStringValue)itemData["ip"]).Value, Strings.MainFormInformationDeskName, Strings.MainFormInformationDeskStatus });
                            this.OnlineList.Items.Add(item);

                            this.InformationDeskIndices.Add(i);
                        }
                        else
                        {
                            //一般
                            string status = Strings.MainFormClientStatus;

                            if (itemData["o_status"].GetValue() != null)
                            {
                                float totalPrice = 0.0f;
                                if (itemData["total_price"].GetValue() != null)
                                    totalPrice = (float)((JsonNumericValue)itemData["total_price"]).Value;

                                if (((JsonNumericValue)itemData["o_status"]).Value == 0)
                                    status = string.Format(Strings.MainFormClientStatus0, totalPrice.ToString("f1"));
                                else if (((JsonNumericValue)itemData["o_status"]).Value == 1)
                                    status = string.Format(Strings.MainFormClientStatus1, totalPrice.ToString("f1"));

                                this.ClientOrderStatusList.Add(i, (int)((JsonNumericValue)itemData["o_status"]).Value);                                
                            }

                            this.ClientNameList.Add(i, ((JsonStringValue)itemData["name"]).Value);
                            this.ClientStatusList.Add(i, (int)((JsonNumericValue)itemData["status"]).Value);

                            ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonStringValue)itemData["ip"]).Value, Strings.MainFormClientClassName, status });
                            this.OnlineList.Items.Add(item);
                            
                        }                        
                        
                    }

                    if (this.ClientListSelectedIndex > -1)
                        this.OnlineList.Items[this.ClientListSelectedIndex].Selected = true;

                }
                else if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_ORDER_DETAIL))
                {
                    //下单明细列表

                    this.OrderDetailIDList = new List<int>();
                    this.OrderDetailStatusList = new List<int>();
                    this.OrderDetailNameList = new List<string>();

                    this.OrderDetailList.Items.Clear();
                    JsonArrayCollection data = (JsonArrayCollection)jsonData["data"];

                    for (int i = 0; i < data.Count; i++)
                    {
                        JsonObjectCollection itemData = (JsonObjectCollection)data[i];

                        string status = Strings.MainFormOrderDetailStatus0;
                        if((int)((JsonNumericValue)itemData["status"]).Value == 1)
                            status = Strings.MainFormOrderDetailStatus1;

                        this.OrderDetailIDList.Add((int)((JsonNumericValue)itemData["id"]).Value);
                        this.OrderDetailStatusList.Add((int)((JsonNumericValue)itemData["status"]).Value);
                        this.OrderDetailNameList.Add(((JsonStringValue)itemData["menu_name"]).Value);

                        ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["c_name"]).Value, ((JsonStringValue)itemData["menu_name"]).Value, ((float)((JsonNumericValue)itemData["price"]).Value).ToString("f1"), ((int)((JsonNumericValue)itemData["quantity"]).Value).ToString(), Commons.UnixTimeFrom((long)((JsonNumericValue)itemData["add_time"]).Value).ToString("HH:mm:ss"), status });
                        this.OrderDetailList.Items.Add(item);
                    }

                    if (this.OrderDetailListSelectedIndex > -1)
                        this.OrderDetailList.Items[this.OrderDetailListSelectedIndex].Selected = true;

                }

            }
            else
                MessageBox.Show(((JsonStringValue)jsonData["message"]).Value);

        }
Exemple #10
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            DialogResult res = MessageBox.Show(Strings.MenuClassFormMsg1, Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
            if (res == DialogResult.Cancel)
                return;

            this.SelectedID = this.MenuClassIDList[this.PrevSelectedIndex];

            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_DELETE));
            jsonData.Add(new JsonNumericValue("data", this.SelectedID));
            ConnHelper.SendString(jsonData.ToString());

            this.SelectedID = 0;
            this.PrevSelectedIndex = 0;
            TextName.Text = "";
        }
 /// <summary>
 /// 获取准备发送的“硬件终端的开关屏时间 设置”信息
 /// </summary>        
 /// <returns></returns>
 public string GetReadySendTerminalSwitchScreenTime(string SessionID, int TerminalEquipmentID)
 {
     JsonObjectCollection delivered = new JsonObjectCollection();
     delivered.Add(new JsonNumericValue("status", 1));
     delivered.Add(new JsonNumericValue("TerminalEquipmentID", TerminalEquipmentID));
     delivered.Add(new JsonStringValue("msg", "成功发送硬件终端的开关屏时间设置信息。"));
     delivered.Add(new JsonStringValue("key", SessionID));
     JsonArrayCollection collection1 = new JsonArrayCollection();
     collection1.Name = "data";
     List<TerminalSwitchScreenTime_EntityModel> psslEnt = multimediaSysOperate.GetTerminalSwitchScreenTime3(true, 0, 1, TerminalEquipmentID);  //TerminalStatus为1表示查询在线的设备。SendStatus为0表示正在等待发送。
     foreach (TerminalSwitchScreenTime_EntityModel item in psslEnt)
     {
         JsonObjectCollection clt = new JsonObjectCollection();
         clt.Add(new JsonNumericValue("TerminalSwitchScreenTimeID", Convert.ToInt32(item.TerminalSwitchScreenTimeID)));
         clt.Add(new JsonStringValue("TurnOnTime", item.TurnOnTime.ToString()));
         clt.Add(new JsonStringValue("TurnOffTime", item.TurnOffTime.ToString()));
         clt.Add(new JsonStringValue("IsMonday", item.IsMonday.ToString()));
         clt.Add(new JsonStringValue("IsTuesday", item.IsTuesday.ToString()));
         clt.Add(new JsonStringValue("IsWednesday", item.IsWednesday.ToString()));
         clt.Add(new JsonStringValue("IsThursday", item.IsThursday.ToString()));
         clt.Add(new JsonStringValue("IsFriday", item.IsFriday.ToString()));
         clt.Add(new JsonStringValue("IsSaturday", item.IsSaturday.ToString()));
         clt.Add(new JsonStringValue("IsSunday", item.IsSunday.ToString()));
         clt.Add(new JsonStringValue("UpdateTime", item.UpdateTime.ToString()));
         collection1.Add(clt);
     }
     delivered.Add(collection1);
     return delivered.ToString();
 }
        private void createProjectInformationFile()
        {
            // Create Project Information File
            JsonObjectCollection luamingJson = new JsonObjectCollection();
            JsonStringValue projectNameJson = new JsonStringValue("PROJECT_NAME");
            projectNameJson.Value = projectName;
            JsonStringValue packageNameJson = new JsonStringValue("PACKAGE_NAME");
            packageNameJson.Value = packageName;
            JsonStringValue versionNameJson = new JsonStringValue("VERSION_NAME");
            versionNameJson.Value = "1.0.0";
            JsonNumericValue versionCodeJson = new JsonNumericValue("VERSION_CODE");
            versionCodeJson.Value = 1;
            JsonStringValue offlineIconJson = new JsonStringValue("OFFLINE_ICON");
            offlineIconJson.Value = "icon.png";
            JsonStringValue mainScriptJson = new JsonStringValue("MAIN_SCRIPT");
            mainScriptJson.Value = "main.lua";
            JsonStringValue orientationJson = new JsonStringValue("ORIENTATION");
            if (isLandscape == true)
                orientationJson.Value = "landscape";
            else
                orientationJson.Value = "portrait";
            luamingJson.Add(projectNameJson);
            luamingJson.Add(packageNameJson);
            luamingJson.Add(versionNameJson);
            luamingJson.Add(versionCodeJson);
            luamingJson.Add(offlineIconJson);
            luamingJson.Add(mainScriptJson);
            luamingJson.Add(orientationJson);

            StreamWriter sw = File.CreateText(dstPath + @"\assets\LuamingProject.json");
            sw.Write(luamingJson.ToString());
            sw.Close();
        }
Exemple #13
0
        private void Send_Login_Message()
        {
            JsonObjectCollection coll = new JsonObjectCollection();
            coll.Add(new JsonStringValue("cmd", "login"));

            coll.Add(new JsonStringValue( "user", txtUser.Text.Trim() ) );
            coll.Add(new JsonStringValue( "passwd", txtPw.Text.Trim() ) );

            myNetwork.SendMessage(coll.ToString());
        }
        private void createProjectInformationFile()
        {
            // Create Project Information File
            JsonObjectCollection luamingJson = new JsonObjectCollection();
            JsonStringValue projectNameJson = new JsonStringValue("PROJECT_NAME");
            projectNameJson.Value = project_name_textbox.Text.ToString();
            JsonStringValue packageNameJson = new JsonStringValue("PACKAGE_NAME");
            packageNameJson.Value = package_name_textbox.Text.ToString();
            JsonStringValue versionNameJson = new JsonStringValue("VERSION_NAME");
            versionNameJson.Value = version_name_textbox.Text.ToString();
            JsonNumericValue versionCodeJson = new JsonNumericValue("VERSION_CODE");
            versionCodeJson.Value = Int32.Parse(version_code_textbox.Text.ToString());
            JsonStringValue offlineIconJson = new JsonStringValue("OFFLINE_ICON");
            offlineIconJson.Value = offline_icon_textbox.Text.ToString();
            JsonStringValue mainScriptJson = new JsonStringValue("MAIN_SCRIPT");
            mainScriptJson.Value = main_script_textbox.Text.ToString();
            JsonStringValue orientationJson = new JsonStringValue("ORIENTATION");
            if (radioLandscape.IsChecked == true)
                orientationJson.Value = "landscape";
            else
                orientationJson.Value = "portrait";
            luamingJson.Add(projectNameJson);
            luamingJson.Add(packageNameJson);
            luamingJson.Add(versionNameJson);
            luamingJson.Add(versionCodeJson);
            luamingJson.Add(offlineIconJson);
            luamingJson.Add(mainScriptJson);
            luamingJson.Add(orientationJson);

            StreamWriter sw = File.CreateText(MainWindow.projectPath + @"\assets\LuamingProject.json");
            sw.Write(luamingJson.ToString());
            sw.Close();
        }
Exemple #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        JsonObjectCollection root = new JsonObjectCollection();

        SqlConnection objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
        string strCmd;
        strCmd = @"SELECT
                     TASKID,PROCESSNAME,PROCESSVERSION,INCIDENT,STEPID,STEPLABEL,RECIPIENT,RECIPIENTTYPE,TASKUSER,ASSIGNEDTOUSER,
                     STATUS,SUBSTATUS,STARTTIME,ENDTIME
                     FROM ultimusdba.TASKS" + condition();

        objConnection.Open();
        SqlCommand cmd = new SqlCommand(strCmd, objConnection);

        SqlDataReader dr = cmd.ExecuteReader();

        JsonArrayCollection list = new JsonArrayCollection("tasks");
        while (dr.Read())
        {
            {
                JsonObjectCollection sub = new JsonObjectCollection();
                sub.Add(new JsonStringValue("taskid", dr["TASKID"].ToString()));
                sub.Add(new JsonStringValue("processname", dr["PROCESSNAME"].ToString()));
                sub.Add(new JsonStringValue("processversion", dr["PROCESSVERSION"].ToString()));
                sub.Add(new JsonStringValue("incident", dr["INCIDENT"].ToString()));
                sub.Add(new JsonStringValue("stepid", dr["STEPID"].ToString()));
                sub.Add(new JsonStringValue("steplabel", dr["STEPLABEL"].ToString()));
                sub.Add(new JsonStringValue("recipient", dr["RECIPIENT"].ToString()));
                sub.Add(new JsonStringValue("recipienttype", dr["RECIPIENTTYPE"].ToString()));
                sub.Add(new JsonStringValue("taskuser", dr["TASKUSER"].ToString()));
                sub.Add(new JsonStringValue("assignedtouser", dr["ASSIGNEDTOUSER"].ToString()));
                sub.Add(new JsonStringValue("status", dr["STATUS"].ToString()));
                sub.Add(new JsonStringValue("substatus", dr["SUBSTATUS"].ToString()));
                sub.Add(new JsonStringValue("starttime", dr["STARTTIME"].ToString()));
                sub.Add(new JsonStringValue("endtime", dr["ENDTIME"].ToString()));
                sub.Add(new JsonStringValue("url", task(int.Parse(dr["INCIDENT"].ToString()), dr["PROCESSNAME"].ToString())));
                list.Add(sub);
            }
        }
        root.Add(list);
        objConnection.Close();

        Response.AppendHeader("contnet-type", "text/json");
        Response.Write(root.ToString());
        Response.End();
    }
        void client_PlaintextReceived(object sender, ReceivedEventArgs<string> e)
        {
            JsonMutualObject JsonMutualObject1 = new JsonMutualObject();
            this.txtReceive.Dispatcher.Invoke(new Action(() => { txtReceive.Text = e.Datagram;
            if (e.Datagram.IndexOf(ConfigurationManager.AppSettings["CustomTerminatorSign"])>0)  //判断当前服务器端返回的消息是否有终结符,如果没有,则表示信息丢失了,或传输不完整。
            {
                string BackInfo = e.Datagram.Replace(ConfigurationManager.AppSettings["CustomTerminatorSign"], "");
                if (BackInfo.IndexOf("Welcome:") == 0)  //判断是否是连接服务器之后,服务器返回的欢迎消息。
                {
                    string msgTmp = BackInfo.Replace("Welcome:", ""); //Welcome:为和服务器端约定的业务协议简述。然后再把终结符也取消掉。剩下的就是一个标准的json
                    BasicMsgEntity deviceLoginEntity = JsonMutualObject1.ScriptDeserialize<BasicMsgEntity>(msgTmp);  //Json字符串转换为类
                    if (deviceLoginEntity != null)
                    {
                        SessionID_Temp = deviceLoginEntity.key;
                    }
                }
                else if (BackInfo.IndexOf("DeviceLogin:"******"\"status\": 1")>0)  //status:1表示登录成功
                    {
                        btnUserLogin.IsEnabled = false;
                    }
                }
                else if (BackInfo.IndexOf("TerminalEquipment:") == 0)  //服务器端发来的“终端指令信息。”,CommandTypeId表示发送的指令类型,1表示开机,2表示关机,3表示重启,4表示播放,5表示停止,6表示暂停,7表示文字类时时公告信息
                {
                    #region//模拟已经成功执行指令,返回正确信息给服务器
                    string msgTmp = BackInfo.Replace("TerminalEquipment:", "");
                    TerminalEquipmentSerialCommand_EntityModel terminalEquipmentEntity = JsonMutualObject1.ScriptDeserialize<TerminalEquipmentSerialCommand_EntityModel>(msgTmp);  //Json字符串转换为类
                    if (terminalEquipmentEntity!=null)
                    {
                        if (terminalEquipmentEntity.status==0)
                        {
                            MessageBox.Show(terminalEquipmentEntity.msg);
                        }
                        else
                        {
                            string ReadySendMsg = "TerminalEquipment:";  //分号前面表示 大的业务类别简述,是一个和服务器端通讯的约定。此时表示服务器发送的 终端指令信息
                            JsonObjectCollection delivered = new JsonObjectCollection();
                            delivered.Add(new JsonStringValue("ReceiveBackTime", DateTime.Now.ToString()));
                            delivered.Add(new JsonStringValue("msg", "客户端已成功执行终端指令"));
                            delivered.Add(new JsonNumericValue("TerSerialCommandID", Convert.ToInt32(terminalEquipmentEntity.TerSerialCommandID)));
                            delivered.Add(new JsonNumericValue("status", 1));
                            ReadySendMsg = ReadySendMsg + delivered.ToString();
                            client.Send(ReadySendMsg);
                        }
                    }
                    #endregion
                }
                else if (BackInfo.IndexOf("TerminalProgram:") == 0)  //服务器端发来的“节目制作信息。”
                {
                    #region//模拟已经成功执行指令,返回正确信息给服务器
                    string msgTmp = BackInfo.Replace("TerminalProgram:", "");
                    try
                    {
                        ProgramSendSerialList_EntityModel programSendSerialList_EntityModel = JsonMutualObject1.ScriptDeserialize<ProgramSendSerialList_EntityModel>(msgTmp);  //Json字符串转换为类
                        if (programSendSerialList_EntityModel != null)
                        {
                            if (programSendSerialList_EntityModel.status == 0)
                            {
                                MessageBox.Show(programSendSerialList_EntityModel.msg);
                            }
                            else
                            {
                                string ReadySendMsg = "TerminalProgram:";  //分号前面表示 大的业务类别简述,是一个和服务器端通讯的约定。此时表示服务器发送的 终端指令信息
                                JsonObjectCollection delivered = new JsonObjectCollection();
                                delivered.Add(new JsonStringValue("ReceiveBackTime", DateTime.Now.ToString()));
                                delivered.Add(new JsonStringValue("msg", "客户端已成功执行终端指令"));
                                delivered.Add(new JsonNumericValue("ProgramSendSerialID", Convert.ToInt32(programSendSerialList_EntityModel.ProgramSendSerialID)));
                                delivered.Add(new JsonNumericValue("status", 1));
                                ReadySendMsg = ReadySendMsg + delivered.ToString();
                                client.Send(ReadySendMsg);
                            }
                        }
                    }
                    catch //(Exception)
                    {
                        string ReadySendMsg = "TerminalProgram:";  //分号前面表示 大的业务类别简述,是一个和服务器端通讯的约定。此时表示服务器发送的 终端指令信息
                        JsonObjectCollection delivered = new JsonObjectCollection();
                        delivered.Add(new JsonStringValue("ReceiveBackTime", DateTime.Now.ToString()));
                        delivered.Add(new JsonStringValue("msg", "客户端接收到的json格式不对,疑似数据包丢失"));
                        delivered.Add(new JsonNumericValue("ProgramSendSerialID", 0));
                        delivered.Add(new JsonNumericValue("status", 0));
                        ReadySendMsg = ReadySendMsg + delivered.ToString();
                        client.Send(ReadySendMsg);
                    }
                    #endregion
                }
            }

            }));
        }
 private void UserLogin_Click(object sender, RoutedEventArgs e)
 {
     if (SessionID_Temp!="")
     {
         string ReadySendMsg = "DeviceLogin:"******"DeviceCode", ConfigurationManager.AppSettings["Local_DeviceCode"]));
         delivered.Add(new JsonStringValue("UserName", txtUsername.Text));
         string strPwdTmp = FormsAuthentication.HashPasswordForStoringInConfigFile(SessionID_Temp.ToUpper() + FormsAuthentication.HashPasswordForStoringInConfigFile(txtPwd.Text,"md5"), "md5");
         delivered.Add(new JsonStringValue("Password",strPwdTmp));
         ReadySendMsg = ReadySendMsg + delivered.ToString();
         client.Send(ReadySendMsg);
     }
 }
Exemple #18
0
        private void Send_Chat_Message()
        {
            JsonObjectCollection coll = new JsonObjectCollection();
            coll.Add(new JsonStringValue("cmd", "chat"));

            if (txtMessage.Lines.Length >= 1)
            {
                coll.Add(new JsonStringValue("msg",
                    " [ "+ txtUser.Text.Trim() +" ]  " + txtMessage.Text.Trim() ));

                // send message
                myNetwork.SendMessage(coll.ToString());

                txtMessage.Lines = null;
            }
            txtMessage.Text = "";
        }
        //
        /// <summary>
        /// 获取准备发送的广告信息
        /// </summary>
        /// <param name="SessionID"></param>
        /// <returns></returns>
        public string GetReadySendProgramInfo(string SessionID, int ProgramInfoID, int ProgramSendSerialID)
        {
            JsonObjectCollection delivered = new JsonObjectCollection();
            delivered.Add(new JsonNumericValue("status", 1));
            delivered.Add(new JsonNumericValue("ProgramSendSerialID", ProgramSendSerialID));
            delivered.Add(new JsonStringValue("msg", "成功发送节目信息。"));
            delivered.Add(new JsonStringValue("key", SessionID));

            JsonArrayCollection collection1 = new JsonArrayCollection();
            collection1.Name = "data";
            List<ProgramInfoList_EntityModel> psslEnt = multimediaSysOperate.GetProgramInfoList1(ProgramInfoID);  //TerminalStatus为1表示查询在线的设备。SendStatus为0表示正在等待发送。
            foreach (ProgramInfoList_EntityModel item in psslEnt)
            {
                JsonObjectCollection clt = new JsonObjectCollection();
                clt.Add(new JsonNumericValue("ProgramInfoID", Convert.ToInt32(item.ProgramInfoID)));
                clt.Add(new JsonNumericValue("ProgramWidth", Convert.ToInt32(item.ProgramWidth)));
                clt.Add(new JsonNumericValue("ProgramHeight", Convert.ToInt32(item.ProgramHeight)));
                clt.Add(new JsonNumericValue("ProgramStatus", Convert.ToInt32(item.ProgramStatus)));
                clt.Add(new JsonNumericValue("CreateUserId", Convert.ToInt32(item.CreateUserId)));
                clt.Add(new JsonStringValue("ProgramTitle", item.ProgramTitle));
                clt.Add(new JsonStringValue("CreateTime", item.CreateTime.ToString()));
                clt.Add(new JsonStringValue("UpdateTime", item.UpdateTime.ToString()));
                //开始
                JsonArrayCollection collectionLayer = new JsonArrayCollection();
                collectionLayer.Name = "ProgramInfoLists";
                List<IGrouping<int?, ProgramInfoListItem_EntityModel>> psslEntLayer = multimediaSysOperate.GetProgramInfoListItem3(ProgramInfoID);  //TerminalStatus为1表示查询在线的设备。SendStatus为0表示正在等待发送。
                foreach (IGrouping<int?, ProgramInfoListItem_EntityModel> item_layer in psslEntLayer)
                {
                    JsonObjectCollection clt_layer = new JsonObjectCollection();
                    clt_layer.Add(new JsonNumericValue("ProgramInfoItemLayer", Convert.ToInt32(item_layer.Key)));
                    //666666
                    #region
                    JsonArrayCollection collection2 = new JsonArrayCollection();
                    collection2.Name = "ProgramInfoListItems";
                    List<ProgramInfoListItem_EntityModel> psslEnt2 = multimediaSysOperate.GetProgramInfoListItem2(ProgramInfoID, Convert.ToInt32(item_layer.Key));  //TerminalStatus为1表示查询在线的设备。SendStatus为0表示正在等待发送。
                    foreach (ProgramInfoListItem_EntityModel item2 in psslEnt2)
                    {
                        JsonObjectCollection clt2 = new JsonObjectCollection();
                        clt2.Add(new JsonNumericValue("ProgramInfoItemID", Convert.ToInt32(item2.ProgramInfoItemID)));
                        clt2.Add(new JsonStringValue("ProgramInfoItemTitle", item2.ProgramInfoItemTitle));
                        clt2.Add(new JsonNumericValue("ProgramInfoItemLeft", Convert.ToDouble(item2.ProgramInfoItemLeft)));
                        clt2.Add(new JsonNumericValue("ProgramInfoItemTop", Convert.ToDouble(item2.ProgramInfoItemTop)));
                        clt2.Add(new JsonNumericValue("ProgramInfoItemLayer", Convert.ToInt32(item2.ProgramInfoItemLayer)));
                        clt2.Add(new JsonNumericValue("ProgramInfoItemHeight", Convert.ToInt32(item2.ProgramInfoItemHeight)));
                        clt2.Add(new JsonNumericValue("ProgramInfoItemWidth", Convert.ToInt32(item2.ProgramInfoItemWidth)));
                        clt2.Add(new JsonNumericValue("ProgramInfoItemType", Convert.ToInt32(item2.ProgramInfoItemType)));
                        clt2.Add(new JsonNumericValue("IsShowWater", Convert.ToInt32(item2.IsShowWater)));
                        if (item2.ProgramInfoItemType == 1)//节目子元素的类型。1为图片,2为音乐,3为视频,4为文档元素(WORD、EXCEL、PPT、PDF),5为网页元素,6为文字元素,7为日期元素,8为时间元素,9为天气元素,0为其它类型
                        {
                            JsonArrayCollection collection_image = new JsonArrayCollection();
                            collection_image.Name = "ProgramInfoListItems_Image";
                            List<ProgramInfoItem_ImageDetail_EntityModel> psslEnt_image = multimediaSysOperate.GetProgramInfoItem_ImageDetail1(Convert.ToInt32(item2.ProgramInfoItemID));
                            foreach (ProgramInfoItem_ImageDetail_EntityModel item_image in psslEnt_image)
                            {
                                JsonObjectCollection clt_image = new JsonObjectCollection();
                                clt_image.Add(new JsonNumericValue("ID", Convert.ToInt32(item_image.ID)));
                                clt_image.Add(new JsonNumericValue("ProgramInfoItemID", Convert.ToInt32(item_image.ProgramInfoItemID)));
                                clt_image.Add(new JsonNumericValue("ImageLayer", Convert.ToInt32(item_image.ImageLayer)));
                                clt_image.Add(new JsonNumericValue("TimeLength", Convert.ToInt32(item_image.TimeLength)));
                                clt_image.Add(new JsonNumericValue("CartoonType", Convert.ToInt32(item_image.CartoonType)));
                                clt_image.Add(new JsonStringValue("ImageUrl", item_image.ImageUrl));
                                collection_image.Add(clt_image);
                            }
                            clt2.Add(collection_image);
                        }
                        else if (item2.ProgramInfoItemType == 3)
                        {
                            JsonArrayCollection collection_video = new JsonArrayCollection();
                            collection_video.Name = "ProgramInfoListItems_Video";
                            List<ProgramInfoItem_VideoDetail_EntityModel> psslEnt_video = multimediaSysOperate.GetProgramInfoItem_VideoDetail1(Convert.ToInt32(item2.ProgramInfoItemID));
                            foreach (ProgramInfoItem_VideoDetail_EntityModel item_video in psslEnt_video)
                            {
                                JsonObjectCollection clt_image = new JsonObjectCollection();
                                clt_image.Add(new JsonNumericValue("ID", Convert.ToInt32(item_video.ID)));
                                clt_image.Add(new JsonNumericValue("ProgramInfoItemID", Convert.ToInt32(item_video.ProgramInfoItemID)));
                                clt_image.Add(new JsonNumericValue("VideoLayer", Convert.ToInt32(item_video.VideoLayer)));
                                clt_image.Add(new JsonNumericValue("VideoVoice", Convert.ToInt32(item_video.VideoVoice)));
                                List<MaterialManagementDetail> jjj_materialManagementDetail = multimediaSysOperate.Getjjj_MaterialManagementDetail1(item_video.VideoUrl);
                                if (jjj_materialManagementDetail.Count>0)
                                {
                                    clt_image.Add(new JsonStringValue("VideoUrl", jjj_materialManagementDetail[0].TransformFilePath));
                                }
                                else
                                {
                                    clt_image.Add(new JsonStringValue("VideoUrl", item_video.VideoUrl));
                                }
                                collection_video.Add(clt_image);
                            }
                            clt2.Add(collection_video);
                        }
                        else if (item2.ProgramInfoItemType == 4)
                        {
                            JsonArrayCollection collection_video = new JsonArrayCollection();
                            collection_video.Name = "ProgramInfoListItems_Document";
                            List<ProgramInfoItem_DocumentDetail_EntityModel> psslEnt_document = multimediaSysOperate.GetProgramInfoItem_DocumentDetail1(Convert.ToInt32(item2.ProgramInfoItemID));
                            foreach (ProgramInfoItem_DocumentDetail_EntityModel item_document in psslEnt_document)
                            {
                                JsonObjectCollection clt_image = new JsonObjectCollection();
                                clt_image.Add(new JsonNumericValue("ID", Convert.ToInt32(item_document.ID)));
                                clt_image.Add(new JsonNumericValue("ProgramInfoItemID", Convert.ToInt32(item_document.ProgramInfoItemID)));
                                clt_image.Add(new JsonNumericValue("DocumentLayer", Convert.ToInt32(item_document.DocumentLayer)));
                                clt_image.Add(new JsonNumericValue("TimeLength", Convert.ToInt32(item_document.TimeLength)));
                                clt_image.Add(new JsonNumericValue("CartoonType", Convert.ToInt32(item_document.CartoonType)));
                                clt_image.Add(new JsonStringValue("DocumentUrl", item_document.DocumentUrl));
                                collection_video.Add(clt_image);
                            }
                            clt2.Add(collection_video);
                        }
                        else if (item2.ProgramInfoItemType == 6)
                        {
                            JsonArrayCollection collection_video = new JsonArrayCollection();
                            collection_video.Name = "ProgramInfoListItems_Text";
                            List<ProgramInfoItem_TextDetail_EntityModel> psslEnt_text = multimediaSysOperate.GetProgramInfoItem_TextDetail1(Convert.ToInt32(item2.ProgramInfoItemID));
                            foreach (ProgramInfoItem_TextDetail_EntityModel item_text in psslEnt_text)
                            {
                                JsonObjectCollection clt_image = new JsonObjectCollection();
                                clt_image.Add(new JsonNumericValue("ID", Convert.ToInt32(item_text.ID)));
                                clt_image.Add(new JsonNumericValue("ProgramInfoItemID", Convert.ToInt32(item_text.ProgramInfoItemID)));
                                clt_image.Add(new JsonNumericValue("TextLayer", Convert.ToInt32(item_text.TextLayer)));
                                clt_image.Add(new JsonNumericValue("TextDirectionType", Convert.ToInt32(item_text.TextDirectionType)));
                                clt_image.Add(new JsonNumericValue("IsBackgroundTransparent", Convert.ToInt32(item_text.IsBackgroundTransparent)));
                                clt_image.Add(new JsonNumericValue("IsBold", Convert.ToInt32(item_text.IsBold)));
                                clt_image.Add(new JsonNumericValue("FontSize", Convert.ToInt32(item_text.FontSize)));
                                clt_image.Add(new JsonNumericValue("PlayCount", Convert.ToInt32(item_text.PlayCount)));
                                clt_image.Add(new JsonNumericValue("PlaySpeed", Convert.ToInt32(item_text.PlaySpeed)));
                                clt_image.Add(new JsonStringValue("TextContent", item_text.TextContent));
                                clt_image.Add(new JsonStringValue("BackgroundColor", item_text.BackgroundColor));
                                clt_image.Add(new JsonStringValue("foreColor", item_text.foreColor));
                                clt_image.Add(new JsonStringValue("FontFamily", item_text.FontFamily));
                                collection_video.Add(clt_image);
                            }
                            clt2.Add(collection_video);
                        }
                        else if (item2.ProgramInfoItemType == 8)
                        {
                            JsonArrayCollection collection_video = new JsonArrayCollection();
                            collection_video.Name = "ProgramInfoListItems_Time";
                            List<ProgramInfoItem_TimeDetail_EntityModel> psslEnt_time = multimediaSysOperate.GetProgramInfoItem_TimeDetail1(Convert.ToInt32(item2.ProgramInfoItemID));
                            foreach (ProgramInfoItem_TimeDetail_EntityModel item_time in psslEnt_time)
                            {
                                JsonObjectCollection clt_image = new JsonObjectCollection();
                                clt_image.Add(new JsonNumericValue("ID", Convert.ToInt32(item_time.ID)));
                                clt_image.Add(new JsonNumericValue("ProgramInfoItemID", Convert.ToInt32(item_time.ProgramInfoItemID)));
                                clt_image.Add(new JsonNumericValue("FontSize", Convert.ToInt32(item_time.FontSize)));
                                clt_image.Add(new JsonNumericValue("IsBackgroundTransparent", Convert.ToInt32(item_time.IsBackgroundTransparent)));
                                clt_image.Add(new JsonNumericValue("IsBold", Convert.ToInt32(item_time.IsBold)));
                                clt_image.Add(new JsonStringValue("FontFamily", item_time.FontFamily));
                                clt_image.Add(new JsonStringValue("FontFormat", item_time.FontFormat));
                                clt_image.Add(new JsonStringValue("BackgroundColor", item_time.BackgroundColor));
                                clt_image.Add(new JsonStringValue("foreColor", item_time.foreColor));
                                collection_video.Add(clt_image);
                            }
                            clt2.Add(collection_video);
                        }
                        collection2.Add(clt2);
                    }
                    clt_layer.Add(collection2);
                    #endregion
                    //666666
                    collectionLayer.Add(clt_layer);
                }
                clt.Add(collectionLayer);
                //结束
                collection1.Add(clt);
            }

            delivered.Add(collection1);
            return delivered.ToString();
        }
        public static void handleRequest(HttpProcessor p, StreamReader inputData, string method)
        {
            paymentServer_dataBase DBHandler = new paymentServer_dataBase();

            JsonObjectCollection headers;
            JsonObjectCollection messageType;
            JsonObjectCollection user;
            JsonObjectCollection merchant;
            JsonObjectCollection customer;
            JsonObjectCollection transactions;

            //Define outgoing JSON message structures
            JsonStringValue Accept_Encoding = new JsonStringValue("Accept-Encoding", "gzip,deflate,sdch");
            JsonStringValue Cookie = new JsonStringValue("Cookie", "_gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1");
            JsonStringValue Accept_Language = new JsonStringValue("Accept-Language", "en-CA,en-GB,en-US;q=0.8,en;q=0.6");
            JsonStringValue Accept = new JsonStringValue("Accept", "application/json, text/json");
            JsonStringValue Host = new JsonStringValue("Host", "paymentserver.dynu.com");
            JsonStringValue Referer = new JsonStringValue("Referer", "https://paymentserver.dynu.com");
            JsonStringValue Connection = new JsonStringValue("Connection", "close");
            JsonStringValue User_Agent = new JsonStringValue("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36");
            headers = new JsonObjectCollection();
            headers.Name = "headers";
            headers.Add(Accept_Encoding);
            headers.Add(Cookie);
            headers.Add(Accept_Language);
            headers.Add(Accept);
            headers.Add(Host);
            headers.Add(Referer);
            headers.Add(Connection);
            headers.Add(User_Agent);

            JsonNumericValue code = new JsonNumericValue("code", -1);
            JsonBooleanValue request = new JsonBooleanValue("request", false);
            JsonBooleanValue response = new JsonBooleanValue("response", false);
            JsonStringValue details = new JsonStringValue("details", "");
            messageType = new JsonObjectCollection();
            messageType.Name = "messageType";
            messageType.Add(code);
            messageType.Add(request);
            messageType.Add(response);
            messageType.Add(details);

            JsonStringValue bankCode = new JsonStringValue("bankCode", "");
            JsonStringValue accountNum = new JsonStringValue("accountNum", "");
            JsonStringValue accountPWD = new JsonStringValue("accountPWD", "");
            JsonNumericValue acctBalance = new JsonNumericValue("acctBalance", -1);
            JsonObjectCollection account = new JsonObjectCollection();
            account.Name = "account";
            account.Add(bankCode);
            account.Add(accountNum);
            account.Add(accountPWD);
            account.Add(acctBalance);

            JsonNumericValue POSHWID = new JsonNumericValue("POSHWID", -1);
            JsonStringValue currentDK = new JsonStringValue("currentDK", "");
            JsonStringValue nextDK = new JsonStringValue("nextDK", "");
            JsonObjectCollection hardwareInfo = new JsonObjectCollection();
            hardwareInfo.Name = "hardwareInfo";
            hardwareInfo.Add(POSHWID);
            hardwareInfo.Add(currentDK);
            hardwareInfo.Add(nextDK);

            JsonNumericValue DOBDay = new JsonNumericValue("DOBDay", -1);
            JsonNumericValue DOBMonth = new JsonNumericValue("DOBMonth", -1);
            JsonNumericValue DOBYear = new JsonNumericValue("DOBYear", -1);
            JsonObjectCollection dateOfBirth = new JsonObjectCollection();
            dateOfBirth.Name = "dateOfBirth";
            dateOfBirth.Add(DOBDay);
            dateOfBirth.Add(DOBMonth);
            dateOfBirth.Add(DOBYear);

            JsonStringValue firstName = new JsonStringValue("firstName", "");
            JsonStringValue middleName = new JsonStringValue("middleName", "");
            JsonStringValue lastName = new JsonStringValue("lastName", "");
            JsonStringValue occupation = new JsonStringValue("occupation", "");
            JsonNumericValue SIN = new JsonNumericValue("SIN", -1);
            JsonStringValue address1 = new JsonStringValue("address1", "");
            JsonStringValue address2 = new JsonStringValue("address2", "");
            JsonStringValue city = new JsonStringValue("city", "");
            JsonStringValue province = new JsonStringValue("province", "");
            JsonStringValue country = new JsonStringValue("country", "");
            JsonStringValue postalCode = new JsonStringValue("postalCode", "");
            JsonStringValue email = new JsonStringValue("email", "");
            JsonNumericValue phoneNumber = new JsonNumericValue("phoneNumber", -1);
            JsonObjectCollection personalInfo = new JsonObjectCollection();
            personalInfo.Name = "personalInfo";
            personalInfo.Add(firstName);
            personalInfo.Add(middleName);
            personalInfo.Add(lastName);
            personalInfo.Add(email);
            personalInfo.Add(dateOfBirth);
            personalInfo.Add(occupation);
            personalInfo.Add(SIN);
            personalInfo.Add(address1);
            personalInfo.Add(address2);
            personalInfo.Add(city);
            personalInfo.Add(province);
            personalInfo.Add(country);
            personalInfo.Add(postalCode);
            personalInfo.Add(phoneNumber);

            JsonStringValue username = new JsonStringValue("username", "");
            JsonStringValue password = new JsonStringValue("password", "");
            JsonObjectCollection userID = new JsonObjectCollection();
            userID.Name = "userID";
            userID.Add(username);
            userID.Add(password);

            JsonBooleanValue receiveCommunication = new JsonBooleanValue("receiveCommunication", false);
            JsonStringValue userType = new JsonStringValue("userType", "");
            JsonNumericValue userNo = new JsonNumericValue("userNo", -1);
            JsonStringValue transactionHistory = new JsonStringValue("transactionHistory", "");
            user = new JsonObjectCollection();
            user.Name = "user";
            user.Add(userNo);
            user.Add(userType);
            user.Add(transactionHistory);
            user.Add(receiveCommunication);
            user.Add(account);
            user.Add(hardwareInfo);
            user.Add(userID);
            user.Add(personalInfo);

            JsonNumericValue merchantID = new JsonNumericValue("merchantID", -1);
            JsonStringValue merchantName = new JsonStringValue("merchantName", "");
            merchant = new JsonObjectCollection();
            merchant.Name = "merchant";
            merchant.Add(merchantID);
            merchant.Add(merchantName);

            JsonStringValue custUsername = new JsonStringValue("custUsername", "");
            JsonStringValue custPWD = new JsonStringValue("custPWD", "");
            customer = new JsonObjectCollection();
            customer.Name = "customer";
            customer.Add(custUsername);
            customer.Add(custPWD);

            JsonNumericValue year = new JsonNumericValue("year", -1);
            JsonNumericValue month = new JsonNumericValue("month", -1);
            JsonNumericValue day = new JsonNumericValue("day", -1);
            JsonObjectCollection transactionDate = new JsonObjectCollection();
            transactionDate.Name = "transactionDate";
            transactionDate.Add(year);
            transactionDate.Add(month);
            transactionDate.Add(day);

            JsonNumericValue hour = new JsonNumericValue("hour", -1);
            JsonNumericValue minute = new JsonNumericValue("minute", -1);
            JsonNumericValue second = new JsonNumericValue("second", -1);
            JsonObjectCollection transactionTime = new JsonObjectCollection();
            transactionTime.Name = "transactionTime";
            transactionTime.Add(hour);
            transactionTime.Add(minute);
            transactionTime.Add(second);

            JsonStringValue merchantUsername = new JsonStringValue("merchantUsername", "");
            JsonStringValue merchantPWD = new JsonStringValue("merchantPWD", "");
            JsonObjectCollection merchantIdent = new JsonObjectCollection();
            merchantIdent.Name = "merchantIdent";
            merchantIdent.Add(merchantUsername);
            merchantIdent.Add(merchantPWD);

            JsonNumericValue transactionID = new JsonNumericValue("transactionID", -1);
            JsonNumericValue amount = new JsonNumericValue("debitAmount", -1);
            JsonBooleanValue isRefund = new JsonBooleanValue("isRefund", false);
            JsonNumericValue balance = new JsonNumericValue("balance", -1);
            JsonNumericValue receiptNo = new JsonNumericValue("receiptNo", -1);
            transactions = new JsonObjectCollection();
            transactions.Name = "transactions";
            transactions.Add(transactionID);
            transactions.Add(amount);
            transactions.Add(isRefund);
            transactions.Add(balance);
            transactions.Add(receiptNo);
            transactions.Add(transactionDate);
            transactions.Add(transactionTime);
            transactions.Add(merchantID);

            //create JSON object
            JsonObjectCollection defineResponse = new JsonObjectCollection();

            if (method == "GET")
            {
                Console.WriteLine("GET request: {0}", p.http_url);

                //build response content from already defined JSON Objects
                defineResponse.Insert(0, headers);
                defineResponse.Add(messageType);
                defineResponse.Add(user);
                defineResponse.Add(merchantIdent);
                defineResponse.Add(customer);
                defineResponse.Add(transactions);
            }

            /*
             * Handle 'POST' message. Requests form the mobile application are handled here
             */
            if (method == "POST")
            {
                Console.WriteLine("POST request: {0}", p.http_url);

                //parse the input data
                string data = inputData.ReadToEnd();
                JObject received = JObject.Parse(data);
                JObject msgType = (JObject)received.SelectToken("messageType");
                int transactionCode = (int)msgType.SelectToken("code");
                Console.WriteLine("Transaction code: {0}", transactionCode);

                //Determine anad handle the received transaction code
                switch (transactionCode)
                {
                    /*
                     * handle user authentication request
                     */
                    case ((int)clientIncomingCodeEnum.IN_CODE_LOGIN_REQ):
                        JObject cust = (JObject)received.SelectToken("customer");
                        string authString = "";
                        string uName = (string)cust.SelectToken("custUsername");
                        string PWD = (string)cust.SelectToken("custPWD");
                        authString += uName;
                        authString += PWD;
                        Console.WriteLine("custUsename: {0}", uName);
                        Console.WriteLine("custPWD: {0}", PWD);

                        //Call the ServerWorker function
                        if (paymentServer_requestWorker.authenticateUser(DBHandler, authString))
                        {
                            messageType = insert(messageType, code, new JsonNumericValue("code", (int)clientOutgoingCodeEnum.OUT_CODE_LOGIN_SUCCESS));
                            messageType = insert(messageType, response, new JsonBooleanValue("response", true));
                            messageType = insert(messageType, request, new JsonBooleanValue("request", false));
                            messageType = insert(messageType, details, new JsonStringValue("details", "Authentication Successful"));
                        }
                        else{
                            messageType = insert(messageType, code, new JsonNumericValue("code", (int)clientOutgoingCodeEnum.OUT_CODE_LOGIN_FAILURE));
                            messageType = insert(messageType, response, new JsonBooleanValue("response", true));
                            messageType = insert(messageType, request, new JsonBooleanValue("request", false));
                            messageType = insert(messageType, details, new JsonStringValue("details", "Invalid username and passowrd combination"));
                        }
                        //build response message content from already defined JSON Objects
                        defineResponse.Insert(0, headers);
                        defineResponse.Add(messageType);
                        break;

                    /*
                     * handle new user sign-up request
                     */
                    case ((int)clientIncomingCodeEnum.IN_CODE_SIGN_UP_REQ):
                        UserProfile newProfile = new UserProfile();

                        //Retrieve encapsulated JSON objects from message
                        JObject newUser = (JObject)received.SelectToken("user");
                        JObject acct = (JObject)newUser.SelectToken("account");
                        JObject UID = (JObject)newUser.SelectToken("userID");
                        JObject persInfo = (JObject)newUser.SelectToken("personalInfo");
                        JObject DOB = (JObject)persInfo.SelectToken("dateOfBirth");
                        JObject HWInfo = (JObject)newUser.SelectToken("hardwareInfo");

                        //Populate the newProfile object with the information received from the client
                        newProfile.userType = (string)newUser.SelectToken("userType");
                        newProfile.receiveCommunication = Convert.ToInt16((bool)newUser.SelectToken("receiveCommunication"));
                        newProfile.bankCode = (string)acct.SelectToken("bankCode");
                        newProfile.accountNum = (string)acct.SelectToken("accountNum");
                        newProfile.accountPWD = (string)acct.SelectToken("accountPWD");
                        newProfile.username = (string)UID.SelectToken("username");
                        newProfile.password = (string)UID.SelectToken("password");
                        newProfile.firstName = (string)persInfo.SelectToken("firstName");
                        newProfile.middleName = (string)persInfo.SelectToken("middleName");
                        newProfile.lastName = (string)persInfo.SelectToken("lastName");
                        newProfile.DOBDay = (int)DOB.SelectToken("DOBDay");
                        newProfile.DOBMonth = (int)DOB.SelectToken("DOBMonth");
                        newProfile.DOBYear = (int)DOB.SelectToken("DOBYear");
                        newProfile.occupation = (string)persInfo.SelectToken("occupation");
                        newProfile.SIN = (int)persInfo.SelectToken("SIN");
                        newProfile.address1 = (string)persInfo.SelectToken("address1");
                        newProfile.address2 = (string)persInfo.SelectToken("address2");
                        newProfile.city = (string)persInfo.SelectToken("city");
                        newProfile.province = (string)persInfo.SelectToken("province");
                        newProfile.country = (string)persInfo.SelectToken("country");
                        newProfile.postalCode = (string)persInfo.SelectToken("postalCode");
                        newProfile.email = (string)persInfo.SelectToken("email");
                        newProfile.phoneNumber = (int)persInfo.SelectToken("phoneNumber");
                        newProfile.POSHWID = (int)HWInfo.SelectToken("POSHWID");
                        newProfile.authenticationString = "";
                        newProfile.authenticationString += newProfile.username;
                        newProfile.authenticationString += newProfile.password;

                        //pass the populated newProfile information to ServerWorker to try and create a new profile
                        //and build response message to client based on the return code receiveed from ServerWorker
                        if (paymentServer_requestWorker.createNewProfile(DBHandler, newProfile) == ResultCodeType.RESULT_CREATE_PROFILE_SUCCESS)
                        {
                            messageType = insert(messageType, code, new JsonNumericValue("code", (int)clientOutgoingCodeEnum.OUT_CODE_SIGN_UP_SUCCESS));
                            messageType = insert(messageType, response, new JsonBooleanValue("response", true));
                            messageType = insert(messageType, request, new JsonBooleanValue("request", false));
                            messageType = insert(messageType, details, new JsonStringValue("details", "User account created"));
                        }
                        else
                        {
                            messageType = insert(messageType, code, new JsonNumericValue("code", (int)clientOutgoingCodeEnum.OUT_CODE_SIGN_UP_FAILURE));
                            messageType = insert(messageType, response, new JsonBooleanValue("response", true));
                            messageType = insert(messageType, request, new JsonBooleanValue("request", false));
                            messageType = insert(messageType, details, new JsonStringValue("details", "Could not create profile. The email provided is already registered"));
                        }

                        //build response message content from already defined JSON Objects
                        defineResponse.Insert(0, headers);
                        defineResponse.Add(messageType);
                        break;

                    /*
                    * handle get user profile request
                    */
                    case ((int)clientIncomingCodeEnum.IN_CODE_GET_USER_PROFILE):
                        //Retrieve encapsulated JSON objects from message
                        JObject requester = (JObject)received.SelectToken("user");
                        int userNum = (int)requester.SelectToken("userNo");

                        GetProfileResultType UserProf = paymentServer_requestWorker.getUserProfile(DBHandler, userNum);
                        if (UserProf.status == ResultCodeType.UPDATE_USER_PROFILE_SUCCESS)
                        {
                            //populate messageType fields
                            messageType = insert(messageType, code, new JsonNumericValue("code", (int)clientOutgoingCodeEnum.OUT_CODE_SEND_USER_PROFILE_SUCCESS));
                            messageType = insert(messageType, response, new JsonBooleanValue("response", true));
                            messageType = insert(messageType, request, new JsonBooleanValue("request", false));

                            //populate User fields
                            user = insert(user, userNo, new JsonNumericValue("userNo", (int)UserProf.profile.userNo));
                            user = insert(user, userType, new JsonStringValue("userType", (string)UserProf.profile.userType));
                            user = insert(user, transactionHistory, new JsonStringValue("transactionHistory", (string)UserProf.profile.transactionHistory));
                            user = insert(user, receiveCommunication, new JsonBooleanValue("receiveCommunication", Convert.ToBoolean(UserProf.profile.receiveCommunication)));

                            account = insert(account, bankCode, new JsonStringValue("bankCode", (string)UserProf.profile.bankCode));
                            account = insert(account, accountNum, new JsonStringValue("accountNum", (string)UserProf.profile.accountNum));
                            account = insert(account, accountPWD, new JsonStringValue("accountPWD", (string)UserProf.profile.accountPWD));
                            account = insert(account, acctBalance, new JsonNumericValue("acctBalance", (int)UserProf.profile.acctBalance));
                            user = insert(user, account, account);

                            hardwareInfo = insert(hardwareInfo, POSHWID, new JsonNumericValue("POSHWID", (int)UserProf.profile.POSHWID));
                            hardwareInfo = insert(hardwareInfo, currentDK, new JsonStringValue("currentDK", (string)UserProf.profile.currentDK));
                            hardwareInfo = insert(hardwareInfo, nextDK, new JsonStringValue("nextDK", (string)UserProf.profile.nextDK));
                            user = insert(user, hardwareInfo, hardwareInfo);

                            userID = insert(userID, username, new JsonStringValue("username", (string)UserProf.profile.username));
                            userID = insert(userID, password, new JsonStringValue("password", (string)UserProf.profile.password));
                            user = insert(user, userID, userID);

                            personalInfo = insert(personalInfo, firstName, new JsonStringValue("firstName", (string)UserProf.profile.firstName));
                            personalInfo = insert(personalInfo, lastName, new JsonStringValue("lastName", (string)UserProf.profile.lastName));
                            personalInfo = insert(personalInfo, middleName, new JsonStringValue("middleName", (string)UserProf.profile.middleName));
                            personalInfo = insert(personalInfo, email, new JsonStringValue("email", (string)UserProf.profile.email));
                            personalInfo = insert(personalInfo, occupation, new JsonStringValue("occupation", (string)UserProf.profile.occupation));
                            personalInfo = insert(personalInfo, SIN, new JsonNumericValue("SIN", (int)UserProf.profile.SIN));
                            personalInfo = insert(personalInfo, address1, new JsonStringValue("address1", (string)UserProf.profile.address1));
                            personalInfo = insert(personalInfo, address2, new JsonStringValue("address2", (string)UserProf.profile.address2));
                            personalInfo = insert(personalInfo, city, new JsonStringValue("email", (string)UserProf.profile.city));
                            personalInfo = insert(personalInfo, province, new JsonStringValue("province", (string)UserProf.profile.province));
                            personalInfo = insert(personalInfo, country, new JsonStringValue("country", (string)UserProf.profile.country));
                            personalInfo = insert(personalInfo, postalCode, new JsonStringValue("postalCode", (string)UserProf.profile.postalCode));
                            personalInfo = insert(personalInfo, phoneNumber, new JsonNumericValue("phoneNumber", (int)UserProf.profile.phoneNumber));
                            dateOfBirth = insert(dateOfBirth, DOBDay, new JsonNumericValue("DOBDay", (int)UserProf.profile.DOBDay));
                            dateOfBirth = insert(dateOfBirth, DOBMonth, new JsonNumericValue("DOBMonthr", (int)UserProf.profile.DOBMonth));
                            dateOfBirth = insert(dateOfBirth, DOBYear, new JsonNumericValue("DOBYear", (int)UserProf.profile.DOBYear));
                            personalInfo = insert(personalInfo, dateOfBirth, dateOfBirth);
                            user = insert(user, personalInfo, personalInfo);
                        }
                        else
                        {
                            messageType = insert(messageType, code, new JsonNumericValue("code", (int)clientOutgoingCodeEnum.OUT_CODE_SEND_USER_PROFILE_FAILURE));
                            messageType = insert(messageType, response, new JsonBooleanValue("response", true));
                            messageType = insert(messageType, request, new JsonBooleanValue("request", false));
                            messageType = insert(messageType, details, new JsonStringValue("details", "Server error - Could not get profile data"));
                        }
                        //build response message content from already defined JSON Objects
                        defineResponse.Insert(0, headers);
                        defineResponse.Add(messageType);
                        defineResponse.Add(user);
                        break;

                    case ((int)clientIncomingCodeEnum.IN_CODE_PROCESS_PAYMENT_REQ):
                        break;
                }
            }

            //finalize outgoing JSON message
            JsonObjectCollection completeResponse = new JsonObjectCollection();
            JsonObjectCollection packagedResponse = new JsonObjectCollection();
            completeResponse.Add(defineResponse);

            //Write message to client
            Console.WriteLine("Response to Client: \n{0}", completeResponse.ToString());
            byte[] message = JsonStringToByteArray(completeResponse.ToString());
            p.sslStream.Write(message);
        }
 void timer_current_Tick(object sender, EventArgs e)
 {
     try
     {
         Action action = new Action(
             delegate()
             {
                 timer_current.Stop(); //暂时先停止此timer,
                 TelnetServer tsTmpServer = bootstrap.GetServerByName("TelnetServer") as TelnetServer;
                 #region//开始扫描,看是否有未发送的终端管理指令或普通公告文字信息
                 List<TerminalEquipmentSerialCommand_EntityModel> TerInfos = multimediaSysOperate.GetTerminalEquipmentSerialCommand1(1, 0);  //TerminalStatus为1表示查询在线的设备。SendStatus为0表示正在等待发送。
                 foreach (TerminalEquipmentSerialCommand_EntityModel item in TerInfos)
                 {
                     foreach (var session in tsTmpServer.GetAllSessions())
                     {
                         if (session.SessionID == item.SessionId)
                         {
                             string CommandMsgTitle = "";//表示发送的指令类型,1表示开机,2表示关机,3表示重启,4表示播放,5表示停止,6表示暂停,7表示文字类时时公告信息
                             switch (Convert.ToInt32(item.CommandTypeId))
                             {
                                 case 1:
                                     CommandMsgTitle = "开机";
                                     break;
                                 case 2:
                                     CommandMsgTitle = "关机";
                                     break;
                                 case 3:
                                     CommandMsgTitle = "重启";
                                     break;
                                 case 4:
                                     CommandMsgTitle = "播放";
                                     break;
                                 case 5:
                                     CommandMsgTitle = "停止";
                                     break;
                                 case 6:
                                     CommandMsgTitle = "暂停";
                                     break;
                                 case 7:
                                     CommandMsgTitle = "时时公告信息";
                                     break;
                                 default:
                                     break;
                             }
                             JsonObjectCollection delivered = new JsonObjectCollection();
                             delivered.Add(new JsonNumericValue("status", 1));
                             delivered.Add(new JsonStringValue("msg", "服务器发送了[" + CommandMsgTitle + "]的指令操作。"));
                             delivered.Add(new JsonStringValue("key", session.SessionID));
                             delivered.Add(new JsonNumericValue("CommandTypeId", Convert.ToInt32(item.CommandTypeId)));
                             delivered.Add(new JsonNumericValue("TerSerialCommandID", Convert.ToInt32(item.TerSerialCommandID)));
                             delivered.Add(new JsonStringValue("SendTime", Convert.ToString(item.SendTime)));
                             delivered.Add(new JsonStringValue("SendContent", item.SendContent));
                             session.Send("TerminalEquipment:" + delivered.ToString());
                             //发送成功后,要修改发送流水记录的状态,修改为1,已发送。
                             int tmp1 = multimediaSysOperate.UpdateTerminalEquipmentSerialCommand2(Convert.ToInt32(item.TerSerialCommandID), 1);
                             Thread.Sleep(50);
                         }
                     }
                 }
                 #endregion
                 #region//开始扫描,看看哪个硬件终端有未发送的 节目信息。然后发送
                 List<ProgramSendSerialList_EntityModel> psslEnt = multimediaSysOperate.GetProgramSendSerialList1(1, 0);  //TerminalStatus为1表示查询在线的设备。SendStatus为0表示正在等待发送。
                 foreach (ProgramSendSerialList_EntityModel item in psslEnt)
                 {
                     foreach (var session in tsTmpServer.GetAllSessions())
                     {
                         if (session.SessionID == item.SessionId)
                         {
                             //开始拼装要发送的json节目信息,ProgramInfoID表示节目id,ProgramSendSerialID发送节目流水号
                             string ReadySendMsg = GetReadySendProgramInfo(item.SessionId, Convert.ToInt32(item.ProgramInfoID), Convert.ToInt32(item.ProgramSendSerialID));
                             session.Send("TerminalProgram:" + ReadySendMsg);
                             //发送成功后,要修改发送流水记录的状态,修改为1,已发送。
                             int tmp6 = multimediaSysOperate.Updatejjj_ProgramSendSerialList1(Convert.ToInt32(item.ProgramSendSerialID), 1);
                         }
                     }
                 }
                 #endregion
                 #region  //开始扫描,看看哪些硬件终端的【开关屏时间】 设置记录信息有更新,即查询jjj_TerminalSwitchScreenTime表
                 List<IGrouping<int?, TerminalSwitchScreenTime_EntityModel>> tsstEnt = multimediaSysOperate.GetTerminalSwitchScreenTime2(true, 0, 1);
                 foreach (IGrouping<int?, TerminalSwitchScreenTime_EntityModel> item_layer in tsstEnt)
                 {
                     List<TerminalEquipmentInfo_EntityModel> terEquiEntity = multimediaSysOperate.GetTerminalEquipmentInfo2(Convert.ToInt32(item_layer.Key));
                     foreach (var session in tsTmpServer.GetAllSessions())
                     {
                         if (session.SessionID == terEquiEntity[0].SessionId)
                         {
                             //开始拼装要发送的json信息
                             string ReadySendMsg = GetReadySendTerminalSwitchScreenTime(session.SessionID, Convert.ToInt32(item_layer.Key));
                             session.Send("TerminalSwitchScreenTime:" + ReadySendMsg);
                             //发送成功后,要修改发送流水记录的状态,修改为1,已发送。
                             int tmp6 = multimediaSysOperate.Updatejjj_TerminalSwitchScreenTime1(Convert.ToInt32(item_layer.Key), 1);
                         }
                     }
                 }
                 #endregion
                 #region//开始扫描,看是否有未发送的终端管理指令或普通公告文字信息
                 List<TerminalEquipmentInfo_EntityModel> TerInfo2 = multimediaSysOperate.GetTerminalEquipmentInfo3(0,1);  //TerminalStatus为1表示查询在线的设备。SendStatus为0表示正在等待发送。
                 foreach (TerminalEquipmentInfo_EntityModel item in TerInfo2)
                 {
                     foreach (var session in tsTmpServer.GetAllSessions())
                     {
                         if (session.SessionID == item.SessionId)
                         {
                             JsonObjectCollection delivered = new JsonObjectCollection();
                             delivered.Add(new JsonNumericValue("status", 1));
                             delivered.Add(new JsonStringValue("msg", "服务器发送了一条终端设备基础信息数据。"));
                             delivered.Add(new JsonStringValue("key", session.SessionID));
                             delivered.Add(new JsonStringValue("DeviceCode", item.DeviceCode));
                             delivered.Add(new JsonStringValue("TerminalVersion", item.TerminalVersion));
                             delivered.Add(new JsonNumericValue("IsRegister",Convert.ToInt32(item.IsRegister)));
                             delivered.Add(new JsonStringValue("DownloadStartTime", item.DownloadStartTime.ToString()));
                             delivered.Add(new JsonStringValue("DownloadEndTime", item.DownloadEndTime.ToString()));
                             session.Send("TerminalEquipmentBasicInfo:" + delivered.ToString());
                             //发送成功后,要修改记录的状态
                             int tmp1 = multimediaSysOperate.UpdateTerminalEquipmentInfo3(Convert.ToInt32(item.TerminalEquipmentID), 1);
                             Thread.Sleep(50);
                         }
                     }
                 }
                 #endregion
             });
         action.BeginInvoke(new AsyncCallback(
             delegate
             {
                 timer_current.Start();
             }),
             null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #22
0
        private void SendPlayerStatusInfo()
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            collection.Add(new JsonStringValue(JsonColName.JsonTxtHndId, AppInfoStrc.TextHandlerId));   // textHandlerID
            collection.Add(new JsonStringValue(JsonColName.JsonPlyrId, AppInfoStrc.PlayerId));          // PlayerID
            collection.Add(new JsonStringValue(JsonColName.JsonCmd, JsonCmd.PlayerSysStatus));          // cmd
            collection.Add(new JsonNumericValue(JsonColName.JsonTimestamp, CommonFunctions.ConvertToUnixTimestamp(DateTime.Now)));

            JsonObjectCollection dataInfo = new JsonObjectCollection();
            //collection.Add(new JsonObjectCollection(JsonColName.JsonData));             // cmd
            dataInfo.Add(new JsonNumericValue(JsonColName.JsonDataCpu, AppInfoStrc.PlyrCpUusage));
            dataInfo.Add(new JsonNumericValue(JsonColName.JsonDataMem, AppInfoStrc.PlyrMemUsage));
            dataInfo.Add(new JsonNumericValue(JsonColName.JsonDataHdd, AppInfoStrc.PlyrAvailableHdd));
            dataInfo.Add(new JsonNumericValue(JsonColName.JsonDataNet, AppInfoStrc.PlyrNetUsage));
            dataInfo.Add(new JsonStringValue(JsonColName.JsonDataVer, Application.ProductVersion));
            JsonObjectCollection subData = new JsonObjectCollection(JsonColName.JsonData, dataInfo);
            collection.Add(subData);

            var jsonText = collection.ToString();

            if (!_fConnection.Closed)
            {
                _fConnection.SendText(jsonText);
            }
        }
Exemple #23
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (this.SelectedID == 0)
                this.PrevSelectedIndex = 1; //新增的话,选定第二项

            JsonObjectCollection data = new JsonObjectCollection();
            data.Add(new JsonNumericValue("id", this.SelectedID));
            data.Add(new JsonStringValue("name", TextName.Text));

            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_CLASS_ADD));
            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
        }
Exemple #24
0
        private void SendRequestScheduleSending()
        {
            try
            {
                JsonObjectCollection collection = new JsonObjectCollection();
                collection.Add(new JsonStringValue(JsonColName.JsonTxtHndId, AppInfoStrc.TextHandlerId));   // textHandlerID
                collection.Add(new JsonStringValue(JsonColName.JsonPlyrId, AppInfoStrc.PlayerId));          // PlayerID
                collection.Add(new JsonStringValue(JsonColName.JsonCmd, JsonCmd.SchedueleDown));            // cmd
                collection.Add(new JsonNumericValue(JsonColName.JsonTimestamp,
                    CommonFunctions.ConvertToUnixTimestamp(DateTime.Now)));

                var jsonText = collection.ToString();

                if (!_fConnection.Closed)
                {
                    _fConnection.SendText(jsonText);
                }

            }
            catch (Exception ex)
            {
                LogFile.ThreadWriteLog("[SEND-ERR]" + "SendRequestScheduleSending():" + ex.Message , LogType.LOG_ERROR);
            }
        }
Exemple #25
0
        public void WebSocket_Opened(object sender, EventArgs e)
        {
            this.Text = Strings.MainFormConnectedTitle;

            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CHK_CLIENT));
            ConnHelper.SendString(jsonData.ToString());
        }
Exemple #26
0
        private void PluralPostData(string message)
        {
            string postData = string.Empty;

            int count = this.DicDeviceID.Count;

            if (count > APPLY_COUNT)
            {
                int nCount = 0;

                JsonObjectCollection totalCollection = new JsonObjectCollection();
                JsonObjectCollection Collection = new JsonObjectCollection("data");
                JsonArrayCollection arrayCollection = new JsonArrayCollection("registration_ids");

                //Collection.Add(new JsonStringValue("type", type));
                Collection.Add(new JsonStringValue("msg", message));

                foreach (KeyValuePair<Int64, DeviceInfo> each in this.DicDeviceID)
                {
                    if (nCount > APPLY_COUNT)
                    {
                        totalCollection.Add(arrayCollection);
                        totalCollection.Add(Collection);

                        Console.WriteLine("SendGCMNotification1");
                        SendGCMNotification(API_KEY, totalCollection.ToString());

                        arrayCollection.Clear();
                        nCount = 0;
                    }
                    arrayCollection.Add(new JsonStringValue(null, each.Value.deviceid));
                    nCount++;
                }
                totalCollection.Add(arrayCollection);
                totalCollection.Add(Collection);

                Console.WriteLine("SendGCMNotification2");
                SendGCMNotification(API_KEY, totalCollection.ToString());
            }
            else
            {
                JsonObjectCollection Collection = new JsonObjectCollection("data");
                JsonObjectCollection totalCollection = new JsonObjectCollection();
                JsonArrayCollection arrayCollection = new JsonArrayCollection("registration_ids");

                foreach (KeyValuePair<Int64, DeviceInfo> each in this.DicDeviceID)
                {
                    arrayCollection.Add(new JsonStringValue(null, each.Value.deviceid));
                }

                Collection.Add(new JsonStringValue(null, message));
                totalCollection.Add(arrayCollection);
                totalCollection.Add(Collection);

                Console.WriteLine("SendGCMNotification3");
                SendGCMNotification(API_KEY, totalCollection.ToString());
            }

            Console.WriteLine("SendGCMNotification4");
            SendGCMNotification(API_KEY, postData);
        }
Exemple #27
0
        private void OnlineList_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (this.OnlineList.SelectedItems.Count == 1)
                {
                    //确保只选中一个

                    if (!this.InformationDeskIndices.Contains(this.OnlineList.SelectedItems[0].Index))
                    {
                        this.ClientListSelectedIndex = this.OnlineList.SelectedItems[0].Index;

                        //客户端状态:0为空闲中,1为开通中
                        if (this.ClientStatusList[this.ClientListSelectedIndex] == 0)
                        {
                            //弹出开通确认框
                            DialogResult res = MessageBox.Show(string.Format(Strings.MainFormDialogOpenClientMsg1, this.ClientNameList[this.ClientListSelectedIndex]), Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                            if (res == DialogResult.OK)
                            {
                                JsonObjectCollection jsonData = new JsonObjectCollection();
                                jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_OPEN_CLIENT));
                                jsonData.Add(new JsonStringValue("data", this.OnlineList.SelectedItems[0].SubItems[2].Text));
                                ConnHelper.SendString(jsonData.ToString());
                            }
                        }
                        else
                        {
                            //订单状态:0为消费中,1为结账中,2为已归档
                            if (this.ClientOrderStatusList[this.ClientListSelectedIndex] == 1)
                            {
                                //已结账中的时候,弹出归档确认框
                                DialogResult res = MessageBox.Show(string.Format(Strings.MainFormDialogOpenClientMsg2, this.ClientNameList[this.ClientListSelectedIndex]), Strings.CommonsDialogTitle, MessageBoxButtons.OKCancel);
                                if (res == DialogResult.OK)
                                {
                                    JsonObjectCollection jsonData = new JsonObjectCollection();
                                    jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_CLOSE_CLIENT));
                                    jsonData.Add(new JsonStringValue("data", this.OnlineList.SelectedItems[0].SubItems[2].Text));
                                    ConnHelper.SendString(jsonData.ToString());
                                }
                            }
                        }

                    }
                }
            }
                        
        }
Exemple #28
0
        private void SinglePostData(string deviceid, string pushmessage)
        {
            string PostData = string.Empty;

            JsonObjectCollection totalCollection = new JsonObjectCollection();
            JsonObjectCollection Collection = new JsonObjectCollection("data");
            //JsonObjectCollection dryrunCollection = new JsonObjectCollection("dry_run");
            JsonArrayCollection arrayCollection = new JsonArrayCollection("registration_ids");

            //Collection.Add(new JsonStringValue(null, type1));
            //Collection.Add(new JsonStringValue(null, type2));
            Collection.Add(new JsonStringValue("msg", pushmessage));

            arrayCollection.Add(new JsonStringValue(null, deviceid));
            //            arrayCollection.Add(new JsonStringValue(null, "APA91bHELKNHPFrZEslHDF3vlpdRQwYzxz-tc5FEjPxUPvzoLG6jRQfz-3kgNovBQNKmuKNGS8x0FX8pUxmIYWDFzCm0NB3eghaRG0h-lDh0I2JStwjaOq39rT1ypLLYzQO34tPLP8kl"));

            totalCollection.Add(arrayCollection);
            totalCollection.Add(Collection);

            SendGCMNotification(API_KEY, totalCollection.ToString());
        }
        private void button1_Click(object sender, EventArgs e)
        {
            FileIO.JsonOutput("AA", Scene.GetChildList());
            return;
//             const string jsonText =
//             "{" +
//             " \"FirstValue\": 1.1," +
//             " \"SecondValue\": \"some text\"," +
//             " \"TrueValue\": true" +
//             "}";

//             // 1. parse sample
//             richTextBox1.AppendText("\n");
//             richTextBox1.AppendText("Source data:\n");
//             richTextBox1.AppendText(jsonText);
//             richTextBox1.AppendText("\n");
// 
//              JsonTextParser parser = new JsonTextParser();
//              JsonObject obj = parser.Parse(jsonText);
// 
//             richTextBox1.AppendText("\n");
//             richTextBox1.AppendText("Parsed data with indentation in JSON data format:\n");
//             richTextBox1.AppendText(obj.ToString());
//             richTextBox1.AppendText("\n");
// 
//             JsonUtility.GenerateIndentedJsonText = false;
// 
//             richTextBox1.AppendText("\n");
//             richTextBox1.AppendText("Parsed data without indentation in JSON data format:\n");
//             richTextBox1.AppendText(obj.ToString());
//             richTextBox1.AppendText("\n");
// 
//             // enumerate values in json object
//             richTextBox1.AppendText("\n");
//             richTextBox1.AppendText("Parsed object contains these nested fields:\n");

//             foreach (JsonObject field in obj as JsonObjectCollection)
//             {
//                 string name = field.Name;
//                 string value = string.Empty;
//                 string type = field.GetValue().GetType().Name;
// 
//                 // try to get value.
//                 switch (type)
//                 {
//                     case "String":
//                         value = (string)field.GetValue();
//                         break;
//                     case "Double":
//                         value = field.GetValue().ToString();
//                         break;
//                     case "Boolean":
//                         value = field.GetValue().ToString();
//                         break;
//                     default:
//                         // in this sample we'll not parse nested arrays or objects.
//                         throw new NotSupportedException();
//                 }
//                 richTextBox1.AppendText(String.Format("{0} {1} {2}",
//                 name.PadLeft(15), type.PadLeft(10), value.PadLeft(15)));
//             }
//             richTextBox1.AppendText("\n");
// 
//             // 2. generate sample
//             richTextBox1.AppendText("\n");

            // root object
            JsonObjectCollection collection = new JsonObjectCollection();

            // nested values
            //new JsonArrayCollection()
            JsonArrayCollection aa = new JsonArrayCollection("TEST");
            aa.Add(new JsonStringValue(null, "a"));
            aa.Add(new JsonStringValue(null, "b"));
            aa.Add(new JsonStringValue(null, "c"));

            JsonStringValue[] temp = new JsonStringValue[3];
            temp[0] = new JsonStringValue("Array", "A");
            temp[1] = new JsonStringValue("Array", "B");
            temp[2] = new JsonStringValue("Array", "C");

            JsonStringValue[] temp2 = new JsonStringValue[3];
            temp2[0] = new JsonStringValue("Object", "1");
            temp2[1] = new JsonStringValue("Object", "2");
            temp2[2] = new JsonStringValue("Object", "3");

            
            collection.Add((aa));
            collection.Add(new JsonArrayCollection(temp));
            collection.Add(new JsonObjectCollection(temp2));
            collection.Add(new JsonStringValue("FirstName", "Pavel"));
            collection.Add(new JsonStringValue("LastName", "Lazureykis"));
            collection.Add(new JsonNumericValue("Age", 23));
            collection.Add(new JsonStringValue("Email", "*****@*****.**"));
            collection.Add(new JsonBooleanValue("HideEmail", true));

            richTextBox1.AppendText("Generated object:\n");
            JsonUtility.GenerateIndentedJsonText = true;
            richTextBox1.AppendText(collection.ToString());
            richTextBox1.AppendText("\n");
            // 3. generate own library for working with own custom json objects
            /// 
            /// Note that generator in this pre-release version of library supports
            /// only JsonObjectCollection in root level ({...}) and only simple
            /// value types can be nested. Not arrays or other objects.
            /// Also names of nested values cannot contain spaces or starts with
            /// numeric symbols. They must comply with C# variable declaration rules.
            /// 
            //             JsonGenerator generator = new JsonGenerator();
            //             generator.GenerateLibrary("Person", collection, @"C:\");
            richTextBox1.AppendText("\n");

            System.IO.File.WriteAllText("test.json", collection.ToString());
        }
Exemple #30
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (this.MenuClassList.SelectedIndex == 0)
            {
                MessageBox.Show(Strings.MenuAddFormMsg2);
                return;
            }

            JsonObjectCollection jsonData = new JsonObjectCollection();
            jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_MENU_ADD));

            JsonObjectCollection data = new JsonObjectCollection();

            JsonObjectCollection menuData = new JsonObjectCollection();
            menuData.Add(new JsonNumericValue("id", this.MenuID));
            menuData.Add(new JsonStringValue("name", TextName.Text));
            menuData.Add(new JsonNumericValue("price", float.Parse(TextPrice.Text)));

            JsonObjectCollection itemData = (JsonObjectCollection)this.MenuClassData[this.MenuClassList.SelectedIndex -1];
            menuData.Add(new JsonNumericValue("class_id", ((JsonNumericValue)itemData["id"]).Value));
            
            data.Add(new JsonObjectCollection("menu_data", menuData));

            if (this.IsSelectedImage && TextBigImage.Text != "" && File.Exists(TextBigImage.Text))
            {
                FileStream fs = File.OpenRead(TextBigImage.Text);
                BinaryReader br = new BinaryReader(fs);
                byte[] bt = br.ReadBytes(Convert.ToInt32(fs.Length));
                string imgBase64Str = Convert.ToBase64String(bt);
                br.Close();
                fs.Close();

                data.Add(new JsonStringValue("img_base64str", imgBase64Str));
            }
            
            jsonData.Add(new JsonObjectCollection("data", data));
            ConnHelper.SendString(jsonData.ToString());
            this.Close();
        }