private void CreateTestingDataSet() { var inputSize = Convert.ToInt16(InputSize_tb.Text); var outputSize = Convert.ToInt16(OutputSize_tb.Text); var outputOffset = Convert.ToInt16(OutputOffset_tb.Text); var samplesCount = Convert.ToInt16(SamplesCount_tb.Text); var samplesOffset = Convert.ToInt16(SamplesOffset_tb.Text); var meta = new JObject { { "Source", "MongoDB" }, { "DataBase", "traiding_data" }, { "Collection", Collection_cb.SelectedValue.ToString() }, { "InputSize", inputSize }, { "OutputSize", outputSize }, { "OutputOffset", outputOffset }, { "SampleCount", samplesCount }, { "SampleOffset", samplesOffset }, { "DataSetType", "Testing" } }; var timePoints = (from c in _collection.AsQueryable() orderby c.Date descending select c) .Skip(samplesOffset).Take(samplesCount).ToList(); var jObj = new JObject { { "Meta", meta }, { "Inputs", new JArray() } }; var inputArray = (jObj["Inputs"] as JArray); var tmp = new JArray(); foreach (var timePoint in timePoints) { var priceNormalized = timePoint.Close - timePoint.Low; tmp.Add(priceNormalized); if (tmp.Count != inputSize) { continue; } inputArray?.Add(new JArray(tmp)); tmp.Clear(); } tmp.Clear(); if (MessageBox.Show( $"Testing data set created:\nInputs: {inputArray?.Count}\nSave to file?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { Common.SaveJsonToFile(jObj); } }
public void StopMove() { DripStatus preMode = m_dripStatus; m_dripStatus = DripStatus.Idle; m_selectedTubes.Clear(); VsmdController.GetVsmdController().Stop(); if (preMode == DripStatus.PauseMove) { AfterMove(); } }
public void ResetRepoModules() { string json = File.ReadAllText(GetRepoPath()); JObject conf = JObject.Parse(json); JArray list = (JArray)conf["repos"]; list.Clear(); File.WriteAllText(GetRepoPath(), conf.ToString()); json = File.ReadAllText(GetModulePath()); conf = JObject.Parse(json); list = (JArray)conf["modules"]; list.Clear(); File.WriteAllText(GetModulePath(), conf.ToString()); }
public void EndPrintLogBook(object sender, PrintEventArgs e) { i = 0; totalPageNumber = 0; currentPageNumber = 0; allTrArr.Clear(); }
/// <summary> /// Creates a TopicsResponse from the given apiResults /// </summary> /// <param name="apiResults">The message from the API</param> public TopicsResponse(HttpResponseMessage apiResults) : base(apiResults) { Concepts = new List <Concept>(); KeyPhrases = new List <KeyPhrase>(); JArray enumerableResults = this.ContentDictionary.ContainsKey(conceptsKey) ? this.ContentDictionary[conceptsKey] as JArray : new JArray(); foreach (JObject result in enumerableResults) { string phrase = result.Properties().Where((p) => String.Equals(p.Name, phraseKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[phraseKey].ToString() : null; double?salience = result.Properties().Where((p) => String.Equals(p.Name, salienceKey)).Any() ? result[salienceKey].ToObject <double?>() : null; string conceptId = result.Properties().Where((p) => String.Equals(p.Name, conceptIdKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[conceptIdKey].ToString() : null; Concepts.Add(new Concept(phrase, salience, conceptId)); } enumerableResults.Clear(); enumerableResults = this.ContentDictionary.ContainsKey(keyPhrasesKey) ? this.ContentDictionary[keyPhrasesKey] as JArray : new JArray(); foreach (JObject result in enumerableResults) { string phrase = result.Properties().Where((p) => String.Equals(p.Name, phraseKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[phraseKey].ToString() : null; double?salience = result.Properties().Where((p) => String.Equals(p.Name, salienceKey)).Any() ? result[salienceKey].ToObject <double?>() : null; KeyPhrases.Add(new KeyPhrase(phrase, salience)); } }
/// <summary> /// 从存储文件中读取直播间信息 /// </summary> public static void LoadRoomInfo() { if (CheckRoomInfoFileExist() == false) { return; } StreamReader fs = new StreamReader(LiveStateRoomInfoFilePath); string cstr = fs.ReadToEnd(); fs.Close(); LiveRoomList.Clear(); try { JArray j = JArray.Parse(cstr); foreach (JObject v in j) { if (v.Property("live") != null && v.Property("room") != null) { AddRoomInfo(v["live"].ToString(), v["room"].ToString()); } else { MessageBox.Show("该房间信息已损坏,请重新添加,出错内容:\n" + v.ToString()); } } } catch { MessageBox.Show("配置文件遭破坏!请不要修改文件(" + LiveStateRoomInfoFilePath + ")的内容!该配置文件已删除,请重新添加"); } SaveRoomInfo(); }
private void History_Clear() { recordStay = -1; history.SelectedIndex = -1; history.Items.Clear(); Records.Clear(); }
/// <summary> /// Removes all items from the list. /// </summary> /// <exception cref="InvalidOperationException">Thrown if the array has been detached.</exception> public void Clear() { Covenant.Requires <InvalidOperationException>(jArray != null, DetachedError); jArray.Clear(); list.Clear(); }
private static void UpdateBuilds(List <BuildConfigure_ViewModel> _selectedBuilds) { JArray Builds = root["Environment"]["Builds"] as JArray; //Remove hard code here //JObject WorkflowData = root["Environment"]["Workflow"]["Sequences"][2]["Data"] as JObject; JObject WorkflowDataParent = root["Environment"]["Workflow"]["Sequences"] .Where(t => t["Data"] != null) .FirstOrDefault() as JObject; JObject WorkflowData = WorkflowDataParent["Data"] as JObject; Builds.Clear(); var tmp = _selectedBuilds.Select(e => { log.DebugFormat("insert the build {0} into json file", e.BuildName); log.InfoFormat("insert the build {0} into json file", e.BuildName); JObject t = new JObject(); t["BuildId"] = e.BuildName; t["BuildNumber"] = e.BuildNumber; t["BuildPath"] = e.BuildPath; t["ReportingName"] = ""; t["Subdirectories"] = new JArray(e.Subdirectories); t["SyncDirs"] = bool.Parse(e.IsSync.ToString()); Builds.Add(t); var BuildFriendlyNameList = WorkflowData.Properties().Where(dataProperty => dataProperty.Name.IndexOf("_BUILD_FRIENDLY_NAME") >= 0); if (BuildFriendlyNameList.Where(b => b.Name.IndexOf(e.BuildName.ToUpper()) >= 0).FirstOrDefault() == null) { // here a hardcode, as in BuildConfigure_ViewModel, we put the Image-Full as the first, so here,just use the first. WorkflowData[e.BuildName.ToUpper() + "_BUILD_FRIENDLY_NAME"] = e.BuildName + @"\" + e.Subdirectories.FirstOrDefault(); WorkflowData[e.BuildName.ToUpper() + "_LACI_FRIENDLY_NAME"] = e.BuildName + @"\" + e.Subdirectories.Where(sn => sn.IndexOf("LACI") >= 0).FirstOrDefault(); log.DebugFormat("insert the build friendlyName {0} into json file", e.BuildName); log.InfoFormat("insert the build lacifriendlyName {0} into json file", e.BuildName); } return(e); }).ToArray(); }
public void Clear() { m_data.Clear(); m_row = null; m_currentJToken = null; m_matchStack.Clear(); }
private void Button_Click(object sender, RoutedEventArgs e) { array.Clear(); try { array.Add(tbFirstName.Text); array.Add(tbSecondName.Text); array.Add(dateOfBirth.SelectedDate.Value.ToShortDateString()); array.Add(tbDiagnos.Text); array.Add(dateSecond.SelectedDate.Value.ToShortDateString()); array.Add(timeSecond.Text); date[$"{dateFirst.SelectedDate.Value.ToShortDateString() + timeFirst.Text}"] = array; var jsonFile = File.ReadAllText("person.json"); var json = JsonConvert.DeserializeObject(jsonFile); fullJson.Merge(json); try { fullJson.Add(dateFirst.SelectedDate.Value.ToShortDateString() + timeFirst.Text, date[$"{dateFirst.SelectedDate.Value.ToShortDateString() + timeFirst.Text}"]); File.WriteAllText("person.json", fullJson.ToString()); this.Close(); } catch { MessageBox.Show("Данное время занято другим пациентом", "Ошибка", MessageBoxButton.OK); } } catch { MessageBox.Show("Не все поля заполнены!", "Ошибка", MessageBoxButton.OK); } mw.FillWeek(); mw.fillFromJson(); }
private string HttpServer_OnClientRequest(RequestType requestType, string parameter, string content) { if (requestType == RequestType.GET) { string eventresult = OnGETRequest?.Invoke(parameter); if (eventresult != null) { return(eventresult); } if (parameter == "json") { string returnvalue; lock (LockObject) { returnvalue = JsonQueue.ToString(); JsonQueue.Clear(); } return(returnvalue); } else { return("server running"); } } else if (requestType == RequestType.POST) { OnPOSTRequest?.Invoke(JArray.Parse(content)); return("OK"); } else { return("server running"); } }
/// <summary> /// 从配置文件读取配置内容 /// </summary> /// <returns></returns> public static JArray ReLoadConfig() { StreamReader fs = new StreamReader(LiveStateConfigFilePath); string cstr = fs.ReadToEnd(); fs.Close(); Cfg.Clear(); try { JArray j = JArray.Parse(cstr); JObject zero = (JObject)j[0]; if (zero.Property("tip") != null) { j.RemoveAt(0); } foreach (JObject v in j) { if (v.Property("api") != null && v.Property("title") != null && v.Property("state") != null && v.Property("live") != null && v.Property("state_tag") != null && v.Property("rage") != null && v.Property("hostname") != null) { Cfg.Add(v); } else { MessageBox.Show("平台配置出错了,请检查JSON! 出错内容:\n" + v.ToString()); } } } catch { MessageBox.Show("读取配置时出现了一个错误,请检查JSON格式是否正确"); } return(Cfg); }
private JObject GetListsFromGraph(IEnumerable <IEntityQuad> quads, bool useNativeTypes) { var lists = quads.Where(q => (q.Subject.IsBlank && q.Predicate.Equals(RdfRest) && q.Object.Equals(RdfNil))); var locList = new JObject(); foreach (var list in lists) { _listInGraph.Clear(); PrepareLists(list, quads, useNativeTypes); string indexer = _listInGraph.First().ToString(); _listInGraph.First.Remove(); locList.Add(new JProperty(indexer, new JArray(_listInGraph))); _listInGraph.Clear(); } return(locList); }
public void Clear() { JArray a = new JArray {1}; Assert.AreEqual(1, a.Count); a.Clear(); Assert.AreEqual(0, a.Count); }
public void Clear() { JArray a = new JArray { 1 }; Assert.AreEqual(1, a.Count); a.Clear(); Assert.AreEqual(0, a.Count); }
public void carregarRegistros(JArray registros, bool deletarRegistrosAnteriores) { if (deletarRegistrosAnteriores) { registros.Clear(); } this.registros.AddRange(registros.Values <ChequeEmpresarialBack>()); }
private async Task <JToken> PullAllDecklistData() { List <Card> cards = InterpretCardlist().GroupBy(e => e.CardName).Select(e => e.First()).ToList(); JArray collection = new JArray(); if (cards.Count > 75) { JToken fullData = null; List <HttpResponseMessage> responses = new List <HttpResponseMessage>(); int loopAmount = (int)Math.Ceiling(cards.Count / 75f); for (int i = 0; i < loopAmount; i++) { int remainingAmount = cards.Count - (i * 75) > 75 ? 75 : cards.Count - (i * 75); for (int j = 0; j < remainingAmount; j++) { collection.Add(JToken.Parse("{\"name\":\"" + cards[j + i * 75].CardName + "\"}")); } string bigBody = "{\"identifiers\":" + collection.ToString() + "}"; HttpResponseMessage resp = await APIInterface.Post("/cards/collection", new StringContent(bigBody, Encoding.UTF8, "application/json")); if (fullData == null) { fullData = JToken.Parse(resp.Content.ReadAsStringAsync().Result); } else { responses.Add(resp); } collection.Clear(); Thread.Sleep(100); } foreach (HttpResponseMessage resp in responses) { JToken jt = JToken.Parse(resp.Content.ReadAsStringAsync().Result); foreach (JToken data in jt["data"]) { fullData["data"].Value <JArray>().Add(data); } } return(fullData); } else { foreach (Card ca in cards) { collection.Add(JToken.Parse("{\"name\":\"" + ca.CardName + "\"}")); } string body = "{\"identifiers\":" + collection.ToString() + "}"; HttpResponseMessage singleResp = await APIInterface.Post("/cards/collection", new StringContent(body, Encoding.UTF8, "application/json")); //, "include_multilingual=true" return(JToken.Parse(singleResp.Content.ReadAsStringAsync().Result)); } }
public Context Reset() { wrefs.Clear(); refs.Clear(); sb.Clear(); index = 0; RequireNew = null; store.Clear(); return(this); }
private void resetbutton_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { jsondb.Clear(); JObject a = new JObject(); a.Add("domain", "gf-game.girlfrontline.co.kr"); a.Add("route", Form1.frm.serveripaddr); jsondb.Add(a); StringBuilder jsbuilder = new StringBuilder(); jsbuilder.Append("function FindProxyForURL(url, host) {"); jsbuilder.Append("if (dnsDomainIs(host, \"gf-game.girlfrontline.co.kr\")){"); jsbuilder.Append(string.Format("return \"PROXY {0}\";", Form1.frm.serveripaddr) + "}"); jsbuilder.Append("else{ return \"DIRECT\";}}"); File.WriteAllText(@"data/pac/pac.json", jsondb.ToString()); File.WriteAllText(@"data/pac/pac.js", jsbuilder.ToString()); initdb(); MessageBox.Show("Completed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); edited = false; } }
private void OnPersistStorage(Snapshot snapshot) { uint blockIndex = snapshot.Height; if (blockIndex >= Settings.Default.HeightToBegin) { string dirPath = "./Storage"; Directory.CreateDirectory(dirPath); string path = $"{HandlePaths(dirPath, blockIndex)}/dump-block-{blockIndex.ToString()}.json"; JArray array = new JArray(); foreach (DataCache <StorageKey, StorageItem> .Trackable trackable in snapshot.Storages.GetChangeSet()) { JObject state = new JObject(); switch (trackable.State) { case TrackState.Added: state["state"] = "Added"; state["key"] = trackable.Key.ToArray().ToHexString(); state["value"] = trackable.Item.ToArray().ToHexString(); // Here we have a new trackable.Key and trackable.Item break; case TrackState.Changed: state["state"] = "Changed"; state["key"] = trackable.Key.ToArray().ToHexString(); state["value"] = trackable.Item.ToArray().ToHexString(); break; case TrackState.Deleted: state["state"] = "Deleted"; state["key"] = trackable.Key.ToArray().ToHexString(); break; } array.Add(state); } JObject bs_item = new JObject(); bs_item["block"] = blockIndex; bs_item["size"] = array.Count; bs_item["storage"] = array; bs_cache.Add(bs_item); if ((blockIndex % Settings.Default.BlockCacheSize == 0) || (blockIndex > Settings.Default.HeightToStartRealTimeSyncing)) { File.WriteAllText(path, bs_cache.ToString()); bs_cache.Clear(); } } }
public void Fill(Animation animation) { Clear(); save.Clear(); JObject add = new JObject(); add.Add("Type", "Fill"); add.Add("Animation", animation.Name); save.Add(add); wrap = !(random = false); for (int i = 0; i < Game.RESOLUTION_WIDTH + animation.Hitbox.Width; i += animation.Hitbox.Width) { for (int j = 0; j < Game.RESOLUTION_HEIGHT + animation.Hitbox.Height; j += animation.Hitbox.Height) { Sprite s = new Sprite(i, j, Texture, animation); s.Layer = -2; Add(s); Height = j; } Width = i; } }
private void ToJSON() { jArr.Clear(); jArr.Add(_url); jArr.Add(_autoresize); jArr.Add(_width); jArr.Add(_height); jArr.Add(_position); jArr.Add(_top); jArr.Add(_left); jArr.Add(GeneXus.Http.HttpAjaxContext.GetParmsJArray(_oncloseCmds)); jArr.Add(GeneXus.Http.HttpAjaxContext.GetParmsJArray(_returnParms)); jArr.Add(_cssClassName); }
/// <summary> /// This function handles our daily events and sets megadate to all events /// </summary> public void HandleDailyEvents() { _studentService.IncrementAllStudentsByOne(); JArray listToWorkOn = new JArray(); foreach (var i in _dailyList) { listToWorkOn.Add(i); } _dailyList.Clear(); listToWorkOn.OrderBy(obj => obj["megadate"]); _messageService.WorkOnJson(listToWorkOn); SetUpTimer(new TimeSpan(04, 00, 00)); }
public static void CheckUser() { string newUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name; string oldUser = file.SelectToken(Constants.USER).ToString(); if (newUser != oldUser) { JArray array = (JArray)file.SelectToken(Constants.ACCOUNTS); array.Clear(); file[Constants.ACCOUNTS] = array; } file[Constants.USER] = newUser; save(); }
void DisposeEditors() { for (int i = 0; i < editors.Length; i++) { editors[i].Dispose(); } editors.Clear(); disposable?.Dispose(); if (addFiles != null) { addFiles.Element = null; } }
/* Returns JSON for Begin Game Notification */ public static string BeginGame(Player player, List <Player> members, Player leader) { string file = @"..\..\JSONs\BeginGame.json"; string json = ""; if (!File.Exists(file)) { Console.WriteLine("DONE\n"); } else { json = File.ReadAllText(file, Encoding.ASCII); } JObject jObject = JObject.Parse(json); jObject["userGuid"] = player.playerID; jObject["team"] = player.Team == Team.TeamColor.RED ? "red" : "blue"; jObject["role"] = player.role == Player.Role.LEADER ? "leader" : "member"; jObject["teamSize"] = members.Count; JArray teamGuids = (JArray)jObject["teamGuids"]; teamGuids.Clear(); teamGuids.Add(leader.playerID); foreach (var p in members) { if (p.playerID != leader.playerID) { teamGuids.Add(p.playerID); } } JObject location = (JObject)jObject["location"]; location["x"] = player.Column; location["y"] = player.Row; JObject board = (JObject)jObject["board"]; board["width"] = Board.Width; board["tasksHeight"] = Board.TaskHeight; board["goalsHeight"] = Board.GoalHeight; initFilejSON(); insertIntoConfigJSON(jObject.ToString()); return(jObject.ToString()); }
public void OnCommitStorage(Snapshot snapshot) { uint blockIndex = snapshot.Height; if (bs_cache.Count > 0) { if ((blockIndex % Settings.Default.BlockCacheSize == 0) || (Settings.Default.HeightToStartRealTimeSyncing != -1 && blockIndex >= Settings.Default.HeightToStartRealTimeSyncing)) { string dirPath = "./Storage"; Directory.CreateDirectory(dirPath); string path = $"{HandlePaths(dirPath, blockIndex)}/dump-block-{blockIndex.ToString()}.json"; File.WriteAllText(path, bs_cache.ToString()); bs_cache.Clear(); } } }
private void UpdateActionsListByTabCells() { JArray ar = null; try { ar = (JArray)Data["actions"]; } catch (Exception error) { ar = new JArray(); } ar.Clear(); foreach (Control line in STB4.Controls) { TableLayoutPanelCellPosition pos = STB4.GetCellPosition(line); while (pos.Row >= ar.Count) { ar.Add(null); } ar[pos.Row] = (JToken)line.Tag; } Data["actions"] = ar; //Debug.WriteLine(JsonConvert.SerializeObject(Data)); }
/// <summary> /// Removes all items from the list. /// </summary> /// <exception cref="InvalidOperationException">Thrown if the array has been detached.</exception> public void Clear() { Covenant.Requires <InvalidOperationException>(jArray != null, DetachedError); jArray.Clear(); // We need to detach all items before clearing the list. foreach (var item in list) { if (item != null) { item.Changed -= itemChangedHandler; } } list.Clear(); }
private static void PublishTask(string message) { listPhotosFace.Clear(); JObject jobj = new JObject(); dynamic results = JsonConvert.DeserializeObject <dynamic>(message); string facebookID = results.facebook_id; string facebookName = results.facebook_name; string routingKey = "request.facetrain"; jobj["facebook_id"] = facebookID; jobj["facebook_name"] = facebookName; using (var db = new ArangoDatabase(url: ConnectionConstants.ArangoHost, database: ConnectionConstants.ArangoDatabase)) { //facebook_id example : "100007369238236" var result = db.Query <persons>() .Where(p => p.profilFacebookId == facebookID) .Select(p => new persons { _id = p._id, profilFacebookId = p.profilFacebookId, linkPhotosFace = p.linkPhotosFace }).ToList(); var facephotos = result.First().linkPhotosFace; for (int i = 0; i < facephotos.Count; i++) { var photo = facephotos[i]; bool isFace = (bool)facephotos[i]["verified_face"]; if (isFace == true) { listPhotosFace.Add(facephotos[i]["url"]); } } jobj["list_photo_face"] = listPhotosFace; } //Console.WriteLine(jobj.ToString()); byte[] messageBody = Encoding.UTF8.GetBytes(jobj.ToString()); Console.WriteLine("Service {1} : FB ID {0} publish to units processing {2}, {3} face photos", facebookID, DateTime.Now, routingKey, listPhotosFace.Count); channel.BasicPublish("amq.topic", routingKey, null, messageBody); }