Beispiel #1
0
 private JsonCollection ParseCollection()
 {
     JsonCollection jsons;
     string str;
     this.SkipWhiteSpace();
     bool flag = false;
     if (this.s[this.c] == '{')
     {
         flag = false;
         jsons = new JsonObjectCollection();
     }
     else
     {
         if (this.s[this.c] != '[')
         {
             throw new FormatException();
         }
         flag = true;
         jsons = new JsonArrayCollection();
     }
     this.c++;
     this.SkipWhiteSpace();
 Label_0060:
     str = string.Empty;
     if (!flag)
     {
         str = this.ParseName();
     }
     JsonObject item = this.ParseSomethingWithoutName();
     if (item == null)
     {
         throw new Exception();
     }
     if (!flag)
     {
         item.Name = str;
     }
     jsons.Add(item);
     this.SkipWhiteSpace();
     if (this.s[this.c] == ',')
     {
         this.c++;
         this.SkipWhiteSpace();
         goto Label_0060;
     }
     this.SkipWhiteSpace();
     if (flag)
     {
         if (this.s[this.c] != ']')
         {
             throw new FormatException();
         }
     }
     else if (this.s[this.c] != '}')
     {
         throw new FormatException();
     }
     this.c++;
     return jsons;
 }
Beispiel #2
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());
        }
        public static JsonObjectCollection ConvertStatisticToJson(SpeedStatistics statistic, string statisticName)
        {
            JsonObjectCollection jsonTest = new JsonObjectCollection(statisticName);
            JsonArrayCollection jsonRecords = new JsonArrayCollection("Records");
            JsonArrayCollection jsonTime = new JsonArrayCollection("Time");
            JsonArrayCollection jsonAverageSpeed = new JsonArrayCollection("AverageSpeed");
            JsonArrayCollection jsonMomentSpeed = new JsonArrayCollection("MomentSpeed");

            for (int i = 0; i < BenchmarkTest.INTERVAL_COUNT; i++)
            {
                // Number of records & timespan.
                var rec = statistic.GetRecordAt(i);
                jsonRecords.Add(new JsonNumericValue(rec.Key));
                jsonTime.Add(new JsonNumericValue(rec.Value.TotalMilliseconds));

                // Average speed.
                var averageSpeed = statistic.GetAverageSpeedAt(i);
                jsonAverageSpeed.Add(new JsonNumericValue(averageSpeed));

                // Moment write speed.
                var momentSpeed = statistic.GetMomentSpeedAt(i);
                jsonMomentSpeed.Add(new JsonNumericValue(momentSpeed));
            }

            jsonTest.Add(jsonRecords);
            jsonTest.Add(jsonTime);
            jsonTest.Add(jsonAverageSpeed);
            jsonTest.Add(jsonMomentSpeed);

            return jsonTest;
        }
        public static JsonObjectCollection ConvertToJson(UserInfo user)
        {
            JsonObjectCollection jsonUser = new JsonObjectCollection("User");
            jsonUser.Add(new JsonStringValue("Email", user.Email));
            jsonUser.Add(new JsonStringValue("AdditionalInfo", user.AdditionalInfo));

            return jsonUser;
        }
Beispiel #5
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());
            }

        }
Beispiel #9
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();
    }
Beispiel #10
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());
        }
Beispiel #11
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();
        }
Beispiel #12
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());
        }
 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);
     }
 }
        //
        /// <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();
        }
 /// <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();
 }
Beispiel #16
0
        private JsonCollection ParseCollection()
        {
            JsonCollection jsons;
            string         str;

            this.SkipWhiteSpace();
            bool flag = false;

            if (this.s[this.c] == '{')
            {
                flag  = false;
                jsons = new JsonObjectCollection();
            }
            else
            {
                if (this.s[this.c] != '[')
                {
                    throw new FormatException();
                }
                flag  = true;
                jsons = new JsonArrayCollection();
            }
            this.c++;
            this.SkipWhiteSpace();
Label_0060:
            str = string.Empty;
            if (!flag)
            {
                str = this.ParseName();
            }
            JsonObject item = this.ParseSomethingWithoutName();

            if (item == null)
            {
                throw new Exception();
            }
            if (!flag)
            {
                item.Name = str;
            }
            jsons.Add(item);
            this.SkipWhiteSpace();
            if (this.s[this.c] == ',')
            {
                this.c++;
                this.SkipWhiteSpace();
                goto Label_0060;
            }
            this.SkipWhiteSpace();
            if (flag)
            {
                if (this.s[this.c] != ']')
                {
                    throw new FormatException();
                }
            }
            else if (this.s[this.c] != '}')
            {
                throw new FormatException();
            }
            this.c++;
            return(jsons);
        }
        public static JsonObjectCollection ConvertToJson(BenchmarkTest benchmark, ReportType type)
        {
            JsonObjectCollection jsonBenchmark = new JsonObjectCollection("BenchmarkTest");

            // Test info parameters.
            JsonObjectCollection jsonSettings = new JsonObjectCollection("TestInfo");
            jsonSettings.Add(new JsonNumericValue("FlowCount", benchmark.FlowCount));
            jsonSettings.Add(new JsonNumericValue("RecordCount", benchmark.RecordCount));
            jsonSettings.Add(new JsonNumericValue("Randomness", benchmark.Randomness * 100));

            long elapsedTime = benchmark.EndTime.Ticks - benchmark.StartTime.Ticks;
            jsonSettings.Add(new JsonNumericValue("ElapsedTime", new TimeSpan(elapsedTime).TotalMilliseconds));

            JsonObjectCollection jsonDatabase = new JsonObjectCollection("Database");
            jsonDatabase.Add(new JsonStringValue("Name", benchmark.Database.Name));
            jsonDatabase.Add(new JsonStringValue("IndexingTechnology", benchmark.Database.IndexingTechnology.ToString()));
            jsonDatabase.Add(new JsonStringValue("Category", benchmark.Database.Name));

            jsonDatabase.Add(new JsonNumericValue("AverageWriteSpeed", benchmark.GetSpeed(TestMethod.Write)));
            jsonDatabase.Add(new JsonNumericValue("AverageReadSpeed", benchmark.GetSpeed(TestMethod.Read)));
            jsonDatabase.Add(new JsonNumericValue("AverageSecondaryReadSpeed", benchmark.GetSpeed(TestMethod.SecondaryRead)));

            jsonDatabase.Add(new JsonNumericValue("WritePeakMemoryUsage", benchmark.GetPeakWorkingSet(TestMethod.Write) / (1024.0 * 1024.0)));
            jsonDatabase.Add(new JsonNumericValue("ReadPeakMemoryUsage", benchmark.GetPeakWorkingSet(TestMethod.Read) / (1024.0 * 1024.0)));
            jsonDatabase.Add(new JsonNumericValue("SecondaryReadPeakMemoryUsage", benchmark.GetPeakWorkingSet(TestMethod.SecondaryRead) / (1024.0 * 1024.0)));

            jsonDatabase.Add(new JsonNumericValue("Size", benchmark.DatabaseSize / (1024.0 * 1024.0)));

            JsonObjectCollection jsonDatabaseSettings = new JsonObjectCollection("Settings");

            if (benchmark.Database.Settings != null)
            {
                foreach (var item in benchmark.Database.Settings)
                    jsonDatabaseSettings.Add(new JsonStringValue(item.Key, item.Value));
            }

            jsonDatabase.Add(jsonDatabaseSettings);

            // Test results.
            JsonObjectCollection jsonTestData = new JsonObjectCollection("TestResults");
            JsonObject jsonWrite = null;
            JsonObject jsonRead = null;
            JsonObject jsonSecondaryRead = null;

            if (type == ReportType.Summary)
            {
                jsonWrite = new JsonNumericValue("Write", benchmark.GetSpeed(TestMethod.Write));
                jsonRead = new JsonNumericValue("Read", benchmark.GetSpeed(TestMethod.Read));
                jsonSecondaryRead = new JsonNumericValue("SecondaryRead", benchmark.GetSpeed(TestMethod.SecondaryRead));
            }
            else // type == ReportType.Detailed
            {
                // Get statistics and convert them to JSON.
                SpeedStatistics writeStat = benchmark.SpeedStatistics[(int)TestMethod.Write];
                SpeedStatistics readStat = benchmark.SpeedStatistics[(int)TestMethod.Read];
                SpeedStatistics secondaryReadStat = benchmark.SpeedStatistics[(int)TestMethod.SecondaryRead];

                jsonWrite = ConvertStatisticToJson(writeStat, "Write");
                jsonRead = ConvertStatisticToJson(readStat, "Read");
                jsonSecondaryRead = ConvertStatisticToJson(secondaryReadStat, "SecondaryRead");
            }

            jsonTestData.Add(jsonWrite);
            jsonTestData.Add(jsonRead);
            jsonTestData.Add(jsonSecondaryRead);

            // Form the end JSON structure.
            jsonBenchmark.Add(jsonSettings);
            jsonBenchmark.Add(jsonDatabase);
            jsonBenchmark.Add(jsonTestData);

            return jsonBenchmark;
        }
        public static JsonArrayCollection ConvertToJson(List<StorageDeviceInfo> storageDrives)
        {
            JsonArrayCollection jsonStorages = new JsonArrayCollection("Storages");

            int index = 0;
            foreach (var storage in storageDrives)
            {
                JsonObjectCollection storageDevice = new JsonObjectCollection();

                storageDevice.Add(new JsonStringValue("Model", storage.Model));
                storageDevice.Add(new JsonNumericValue("Capacity", storage.Size));

                jsonStorages.Add(storageDevice);
                index++;
            }

            return jsonStorages;
        }
        /// <summary>
        /// Exports the given data into a JSON file.
        /// </summary>
        public static void ExportToJson(string path, ComputerConfiguration configuration, List<BenchmarkTest> benchmarks, ReportType type)
        {
            List<JsonObjectCollection> collection = new List<JsonObjectCollection>();

            collection.Add(ConvertToJson(configuration));

            foreach (var benchmark in benchmarks)
                collection.Add(ConvertToJson(benchmark, type));

            using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                StreamWriter writer = new StreamWriter(stream);

                JsonObjectCollection json = new JsonObjectCollection(collection);
                json.WriteTo(writer);

                writer.Flush();
            }
        }
Beispiel #20
0
        private JsonCollection ParseCollection()
        {
            SkipWhiteSpace();

            JsonCollection result;
            bool           is_array = false;

            if (s[c] == '{')
            {
                is_array = false;
                result   = new JsonObjectCollection();
            }
            else if (s[c] == '[')
            {
                is_array = true;
                result   = new JsonArrayCollection();
            }
            else
            {
                throw new FormatException();
            }

            // skip open bracket
            c++;
            SkipWhiteSpace();

            // parse collection items
            for (; ;)
            {
                string name = string.Empty;
                if (!is_array)
                {
                    name = ParseName();
                }

                JsonObject obj = ParseSomethingWithoutName();

                if (obj == null)
                {
                    throw new Exception();
                }

                // add name to item, if object.
                if (!is_array)
                {
                    obj.Name = name;
                }

                result.Add(obj);

                SkipWhiteSpace();

                if (s[c] == ',')
                {
                    c++;

                    SkipWhiteSpace();
                }
                else
                {
                    break;
                }
            }

            SkipWhiteSpace();

            if (is_array)
            {
                if (s[c] != ']')
                {
                    throw new FormatException();
                }
            }
            else
            {
                if (s[c] != '}')
                {
                    throw new FormatException();
                }
            }

            c++;

            return(result);
        }
Beispiel #21
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());
                        }
                    }

                }
            }

        }
Beispiel #22
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);

        }
Beispiel #23
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 = "";
        }
        private void BuildJsonItemDataList(ListView listView, JsonObjectCollection jObj)
        {
            listView.BeginUpdate();

            foreach(var token in jObj)
            {
                if( token.GetType() == typeof(JsonObjectCollection) && token.Name == "Items" )
                {
                    foreach (var gameItem in (JsonObjectCollection)token)
                    {
                        ListViewItem itemObj = new ListViewItem(gameItem.Name);
                        listView.Items.Add(itemObj);
                    }
                }
            }

            listView.EndUpdate();
        }
Beispiel #25
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());
        }
        public static JsonObjectCollection ConvertToJson(ComputerConfiguration configuration)
        {
            var jsonOS = ConvertToJson(configuration.OperatingSystem);
            var jsonProcessors = ConvertToJson(configuration.Processors);
            var jsonMemoryModules = ConvertToJson(configuration.MemoryModules);
            var jsonStorageDevices = ConvertToJson(configuration.StorageDevices);

            JsonObjectCollection jsonConfiguration = new JsonObjectCollection("ComputerConfiguration");

            jsonConfiguration.Add(jsonOS);
            jsonConfiguration.Add(jsonProcessors);
            jsonConfiguration.Add(jsonMemoryModules);
            jsonConfiguration.Add(jsonStorageDevices);

            return jsonConfiguration;
        }
Beispiel #27
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());
        }
        public static JsonObjectCollection ConvertToJson(OperatingSystemInfo operatingSystem)
        {
            JsonObjectCollection jsonOS = new JsonObjectCollection("OperatingSystem");
            jsonOS.Add(new JsonStringValue("Name", operatingSystem.Name));
            jsonOS.Add(new JsonBooleanValue("Is64Bit", operatingSystem.Is64bit));

            return jsonOS;
        }
Beispiel #29
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());
                                }
                            }
                        }

                    }
                }
            }
                        
        }
        public static JsonArrayCollection ConvertToJson(List<CpuInfo> processors)
        {
            JsonArrayCollection jsonProcessors = new JsonArrayCollection("Processors");

            int index = 0;
            foreach (var processor in processors)
            {
                JsonObjectCollection jsonCPU = new JsonObjectCollection();

                jsonCPU.Add(new JsonStringValue("Name", processor.Name));
                jsonCPU.Add(new JsonNumericValue("Threads", processor.Threads));
                jsonCPU.Add(new JsonNumericValue("MaxClockSpeed", processor.MaxClockSpeed));

                jsonProcessors.Add(jsonCPU);
                index++;
            }

            return jsonProcessors;
        }
        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());
        }
        public static JsonArrayCollection ConvertToJson(List<RamInfo> memoryModules)
        {
            JsonArrayCollection jsonMemoryModules = new JsonArrayCollection("MemoryModules");

            int index = 0;
            foreach (var module in memoryModules)
            {
                JsonObjectCollection jsonMemoryModule = new JsonObjectCollection();

                jsonMemoryModule.Add(new JsonStringValue("Type", module.MemoryType.ToString()));
                jsonMemoryModule.Add(new JsonNumericValue("Capacity", module.Capacity));
                jsonMemoryModule.Add(new JsonNumericValue("Speed", module.Speed));

                jsonMemoryModules.Add(jsonMemoryModule);
                index++;
            }

            return jsonMemoryModules;
        }