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; }
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; }
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()); }
/// <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(); }
// /// <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 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; }
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; }
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 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 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); }
public static JsonArrayCollection CreateContentsPlayListBySector() { try { string scheduleText = GetLatestScheuleFileText(); var parser = new JsonTextParser(); var jsonObj = parser.Parse(@scheduleText); // abstract cmd var colArry = (JsonArrayCollection)jsonObj; foreach (var o in colArry) { int fldKeyId = 0; int fldParent = 0; int fldOrder = 0; var oneJsonSchdObj = (JsonObjectCollection) o; var vtotSector = oneJsonSchdObj[JsonColName.JsonSchdTotSec].GetValue(); //총구간 int totSector = int.Parse(vtotSector.ToString()); // create Json object array of play contents list by sector order if (totSector > 0) { //var jsonPlayContentsListObj = new JsonObjectCollection(); var arrColPlayContentsList = new JsonArrayCollection(); for (int idx = 0; idx < totSector; ++idx) { var jsonContentsObj = new JsonObjectCollection(); #region create parent sector ++fldKeyId; jsonContentsObj.Add(new JsonNumericValue("fldKeyId", fldKeyId)); // Key ID // 구간 Added for displaying Sector field that parent tab in tree list jsonContentsObj.Add(new JsonNumericValue("fldSector", idx + 1)); jsonContentsObj.Add(new JsonNumericValue("fldParentKey", 0)); fldParent = fldKeyId; arrColPlayContentsList.Add(jsonContentsObj); #endregion //jsonPlayContentsListObj.Add(arrColPlayContentsList); // abstract contents list to Json array collections var colArrayContentsList = (JsonArrayCollection) oneJsonSchdObj[JsonColName.JsonContentsList]; foreach (var oc in colArrayContentsList) { var oneJsonContentsObj = (JsonObjectCollection)oc; string cntsSectors = oneJsonContentsObj["cntsSectors"].GetValue().ToString(); var arrSectors = cntsSectors.Split(','); if (arrSectors.Contains((idx + 1).ToString())) // if this content is included this sector then create play content list { //var arrColPlayContentsList2 = new JsonArrayCollection(); var jsonContentsObj2 = new JsonObjectCollection(); ++fldKeyId; ++fldOrder; jsonContentsObj2.Add(new JsonNumericValue("fldKeyId", fldKeyId)); // Key ID jsonContentsObj2.Add(new JsonNumericValue("fldOrder", fldOrder)); // 순서 jsonContentsObj2.Add(new JsonNumericValue("fldParentKey", fldParent)); // ParentKey // 구간 Added for displaying Sector field that parent tab in tree list jsonContentsObj2.Add(new JsonNumericValue("fldSector", idx + 1)); jsonContentsObj2.Add(oneJsonContentsObj["cntsKey"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsName"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsUpdateDt"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsPlayTime"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsStartDt"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsEndDt"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsStartTime"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsEndTime"]); jsonContentsObj2.Add(oneJsonContentsObj["fileName"]); jsonContentsObj2.Add(oneJsonContentsObj["mute"]); arrColPlayContentsList.Add(jsonContentsObj2); //jsonPlayContentsListObj.Add(arrColPlayContentsList2); } } } return arrColPlayContentsList; } else { return null; } } } catch (Exception) { LogFile.ThreadWriteLog("[JSON-ERR]" + Current.SchdName.Name + " 구간별 상영 리스트 생성 오류", LogType.LOG_ERROR); return null; } return null; }
private static JsonArrayCollection CreateNotDownlodedContents() { try { string scheduleText = GetLatestScheuleFileText(); var parser = new JsonTextParser(); var jsonObj = parser.Parse(@scheduleText); // abstract cmd var colArry = (JsonArrayCollection) jsonObj; //var col = (JsonObjectCollection)jsonObj; var arrColPlayContentsList = new JsonArrayCollection(); foreach (var o in colArry) { var oneJsonSchdObj = (JsonObjectCollection) o; var col = (JsonObjectCollection) o; AppInfoStrc.UrlDownloadWebServer = col[JsonColName.UrlDownloadWebServer].GetValue().ToString(); AppInfoStrc.ExtDownloadWebServer = col[JsonColName.ExtDownloadWebServer].GetValue().ToString(); AppInfoStrc.BridgePath = col[JsonColName.BridgePath].GetValue().ToString(); AppInfoStrc.CurrentScheduleKey = col[JsonColName.JsonSchdKey].GetValue().ToString(); var colArrayContentsList = (JsonArrayCollection)oneJsonSchdObj[JsonColName.JsonContentsList]; if (colArrayContentsList != null) { foreach (var oc in colArrayContentsList) { var oneJsonContentsObj = (JsonObjectCollection) oc; var jsonContentsObj2 = new JsonObjectCollection(); if (!isAreadyExist(arrColPlayContentsList, oneJsonContentsObj["cntsKey"])) { jsonContentsObj2.Add(oneJsonContentsObj["cntsKey"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsUpdateDt"]); jsonContentsObj2.Add(oneJsonContentsObj["fileName"]); arrColPlayContentsList.Add(jsonContentsObj2); } } } } return arrColPlayContentsList; } catch (Exception) { LogFile.ThreadWriteLog("[JSON-ERR]" + Current.SchdName.Name + " 다운받을 콘텐츠 리스트 생성 오류", LogType.LOG_ERROR); return null; } }
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(); }
private void SinglePostData(string deviceid, string pushmessage) { string PostData = string.Empty; // JsonObjectCollection totalCollection = new JsonObjectCollection(); // JsonObjectCollection collNoti = new JsonObjectCollection("notification"); // JsonObjectCollection collTo = new JsonObjectCollection("to"); // // JsonArrayCollection arrayCollection = new JsonArrayCollection("to"); // // collNoti.Add(new JsonStringValue("title", "xuzhu msg")); // collNoti.Add(new JsonStringValue("text", pushmessage)); // collTo.Add(new JsonStringValue(null,deviceid)); // // arrayCollection.Add(new JsonStringValue(null, deviceid)); // //Collection.Add(new JsonStringValue(null, type1)); // //Collection.Add(new JsonStringValue(null, type2)); // totalCollection.Add(collNoti); // totalCollection.Add(collTo); JsonObjectCollection totalCollection = new JsonObjectCollection(); // JsonObjectCollection Collection = new JsonObjectCollection("data"); JsonObjectCollection Collection = new JsonObjectCollection("notification"); //JsonObjectCollection dryrunCollection = new JsonObjectCollection("dry_run"); JsonArrayCollection arrayCollection = new JsonArrayCollection("registration_ids"); Collection.Add(new JsonStringValue("title", "xuzhu msg")); Collection.Add(new JsonStringValue("text", pushmessage)); //Collection.Add(new JsonStringValue(null, type1)); //Collection.Add(new JsonStringValue(null, type2)); // Collection.Add(new JsonStringValue("msg", pushmessage)); arrayCollection.Add(new JsonStringValue(null, deviceid)); totalCollection.Add(arrayCollection); totalCollection.Add(Collection); SendGCMNotification(API_KEY, totalCollection.ToString()); }