private void OnGroupsGetById(JObject data, String cookie) { if (data[VkRestApi.ResponseBody] == null) { // todo: show err Debug.WriteLine("Group is not found"); return; } var gId = cookie; // group id sent as a cooky // now calculate items in response var count = data[VkRestApi.ResponseBody].Count(); var groups = new List<Group>(); // process response body for (var i = 0; i < count; ++i) { var groupObject = data[VkRestApi.ResponseBody][i].ToObject<JObject>(); if (groupObject == null) continue; var g = new Group(); g.id = Utils.getLongField("id", groupObject); g.name = Utils.getStringField("name", groupObject); g.screen_name = Utils.getStringField("screen_name", groupObject); g.is_closed = Utils.getStringField("is_closed", groupObject); g.type = Utils.getStringField("type", groupObject); g.members_count = Utils.getStringField("members_count", groupObject); g.city = Utils.getStringField("city", "title", groupObject); g.country = Utils.getStringField("country", "title", groupObject); g.photo = Utils.getStringField("photo_50", groupObject); g.description = Utils.getTextField("description", groupObject); g.status = Utils.getTextField("status", groupObject); groups.Add(g); } if (groups.Count > 0) { // update group id and group info groupId = groups[0].id; // group members network document groupNetworkAnalyzer = new GroupNetworkAnalyzer(); var fileName = GenerateGroupFileName(groupId); var writer = File.CreateText(fileName); printGroupHeader(writer); updateGroupFile(groups, writer); writer.Close(); groupId2.Text = groupId.ToString(); groupDescription.Text = groups[0].name; groupDescription.AppendText("\r\n type: " + groups[0].type); groupDescription.AppendText("\r\n members: " + groups[0].members_count); groupDescription.AppendText("\r\n " + groups[0].description); } else { groupId = 0; groupId2.Text = gId; groupDescription.Text = "Not found"; } ActivateControls(); ReadyEvent.Set(); }
private void OnGroupsGetById(JObject data, String cookie) { String gId = cookie; // group id is sent as a cooky if (data[VkRestApi.ResponseBody] == null || data[VkRestApi.ResponseBody].Count() == 0) { this.groupId = 0; this.groupId2.Text = gId; this.groupDescription.Text = "Not found"; Debug.WriteLine("Group is not found"); return; } // process response body var groupObject = data[VkRestApi.ResponseBody][0].ToObject<JObject>(); if (groupObject == null) { this.groupId = 0; this.groupId2.Text = gId; this.groupDescription.Text = "Group read error"; Debug.WriteLine("Group object is empty"); return; } var g = new Group { id = Utils.getLongField("id", groupObject), name = Utils.getStringField("name", groupObject), screen_name = Utils.getStringField("screen_name", groupObject), is_closed = Utils.getStringField("is_closed", groupObject), type = Utils.getStringField("type", groupObject), members_count = Utils.getStringField("members_count", groupObject), city = Utils.getStringField("city", "title", groupObject), country = Utils.getStringField("country", "title", groupObject), photo = Utils.getStringField("photo_50", groupObject), description = Utils.getTextField("description", groupObject), status = Utils.getTextField("status", groupObject) }; // update group id and group info this.groupId = g.id > 0 ? Decimal.Negate(g.id) : g.id;// group id is negative number // create group members network document this.contentNetworkAnalyzer = new ContentNetworkAnalyzer(); // add group as a vertex to the document (some posts come from group only) this.contentNetworkAnalyzer.AddVertex((long)this.groupId, g.name, "User", groupObject); String fileName = Utils.GenerateFileName(this.WorkingFolderTextBox.Text, groupId, g); StreamWriter writer = File.CreateText(fileName); Utils.PrintFileHeader(writer, g); Utils.PrintFileContent(writer, g); writer.Close(); this.groupId2.Text = g.id.ToString(); this.groupDescription.Text = g.name; this.groupDescription.AppendText("\r\n type: " + g.type); this.groupDescription.AppendText("\r\n members: " + g.members_count); this.groupDescription.AppendText("\r\n " + g.description); ActivateControls(); ReadyEvent.Set(); }