public void Execute(IUBotStudio ubotStudio, Dictionary <string, string> parameters) { var sqLiteFilePath = parameters["SQLite File Path"]; var sqLiteQuery = parameters["Query String"]; var sqLite = new SqLiteDatabase(sqLiteFilePath); var dataTable = sqLite.GetDataTable(sqLiteQuery); var dataArray = new string[dataTable.Rows.Count, dataTable.Columns.Count]; for (var i = 0; i < dataTable.Rows.Count; i++) { for (var j = 0; j < dataTable.Columns.Count; j++) { dataArray[i, j] = dataTable.Rows[i][j].ToString(); } } ubotStudio.SetTable(parameters["Table Report"], dataArray); _returnValue = "Success"; }
public void Execute(IUBotStudio ubotStudio, Dictionary <string, string> parameters) { var inicontainer = (FBcontainer)ubotStudio.ContainerParent; var token = inicontainer.Token; try { var facebook = new FacebookGraphApi(token.Trim()); facebook.ProxyStr = inicontainer.Proxy; facebook.FBversion = inicontainer.Version; //get my friends info var friends = facebook.GetConnections(parameters["Parent"], "friends", null); var table = new string[friends["data"].Count(), 2]; var i = 0; foreach (var friend in friends["data"]) { table[i, 0] = friend["id"].ToString(); table[i, 1] = friend["name"].ToString(); i++; } ubotStudio.SetTable(parameters["Details"], table); } catch (Exception exp) { if (exp.GetType() == typeof(FacebookGraphApiException)) { inicontainer.Error = (exp as FacebookGraphApiException).Message; } else { inicontainer.Error = exp.Message; } } }
public void Execute(IUBotStudio ubotStudio, Dictionary <string, string> parameters) { var inicontainer = (FBcontainer)ubotStudio.ContainerParent; var token = inicontainer.Token; try { var facebook = new FacebookGraphApi(token.Trim()); facebook.ProxyStr = inicontainer.Proxy; facebook.FBversion = inicontainer.Version; //JArray data = new JArray(); var ScrapedData = new List <string>(); var dict = new Dictionary <string, string>(); dict.Add("q", parameters["keyword"]); dict.Add("type", "group"); dict.Add("limit", "100"); var ObjectFb = facebook.GetConnections("", "search", dict); //_returnValue = facebook.JsonText; var Jpath = JsonPathParser(facebook.JsonText, "$..next"); foreach (var group in ObjectFb["data"]) { ScrapedData.Add(group["name"] + "|" + group["id"]); } var fbNext = ""; if (Jpath.Length != 0) { fbNext = Jpath[0]; } while (fbNext != string.Empty) { var wc = new WebClient(); var reply = wc.DownloadString(fbNext.Replace(@"\", "")); var jo = JObject.Parse(reply); foreach (var group in jo["data"]) { ScrapedData.Add(group["name"] + "|" + group["id"]); } var JpathW = JsonPathParser(reply, "$..next"); fbNext = ""; if (JpathW.Length != 0) { fbNext = JpathW[0]; } } var data = new string[ScrapedData.Count, 2]; for (var i = 0; i < ScrapedData.Count; i++) { var LocD = ScrapedData[i].Split('|'); data[i, 0] = LocD[0]; data[i, 1] = LocD[1]; } ubotStudio.SetTable(parameters["Data"], data); } catch (Exception exp) { if (exp.GetType() == typeof(FacebookGraphApiException)) { inicontainer.Error = (exp as FacebookGraphApiException).Message; } else { inicontainer.Error = exp.Message; } } }
public void Execute(IUBotStudio ubotStudio, Dictionary <string, string> parameters) { string minimum_chart = parameters["Minimum Character Length"]; int minimum_char = Convert.ToInt32(minimum_chart); string top_how_manyt = parameters["Return Top How Many?"]; int top_how_many = Convert.ToInt32(top_how_manyt); string table_name = parameters["Table Name"]; // Read a file into a string (this file must live in the same directory as the executable) string inputString = parameters["Text"]; // Convert our input to lowercase inputString = inputString.ToLower(); // Define characters to strip from the input and do it // REMOVED FOR NOW /* * string[] stripChars = { ";", ",", ".", "-", "_", "^", "(", ")", "[", "]", * "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\n", "\t", "\r" }; * foreach (string character in stripChars) * { * inputString = inputString.Replace(character, ""); * } */ string[] stripChars = { ";", ",", ".", "^", "(", ")", "[", "]", "\n", "\t", "\r" }; foreach (string character in stripChars) { inputString = inputString.Replace(character, ""); } // Split on spaces into a List of strings List <string> wordList = inputString.Split(' ').ToList(); // Define and remove stopwords // REMOVED FOR NOW /* * string[] stopwords = new string[] { "and", "the", "she", "for", "this", "you", "but" }; * foreach (string word in stopwords) * { * // While there's still an instance of a stopword in the wordList, remove it. * // If we don't use a while loop on this each call to Remove simply removes a single * // instance of the stopword from our wordList, and we can't call Replace on the * // entire string (as opposed to the individual words in the string) as it's * // too indiscriminate (i.e. removing 'and' will turn words like 'bandage' into 'bdage'!) * while (wordList.Contains(word)) * { * wordList.Remove(word); * } * } */ // Create a new Dictionary object Dictionary <string, int> dictionary = new Dictionary <string, int>(); // Loop over all over the words in our wordList... foreach (string word in wordList) { // If the length of the word is at least three letters... if (word.Length >= minimum_char) { // ...check if the dictionary already has the word. if (dictionary.ContainsKey(word)) { // If we already have the word in the dictionary, increment the count of how many times it appears dictionary[word]++; } else { // Otherwise, if it's a new word then add it to the dictionary with an initial count of 1 dictionary[word] = 1; } } // End of word length check } // End of loop over each word in our input // Create a dictionary sorted by value (i.e. how many times a word occurs) var sortedDict = (from entry in dictionary orderby entry.Value descending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); // Loop through the sorted dictionary and output the top most frequently occurring words int count = 1; int count_dictionary_org = dictionary.Count; int count_dictionary = count_dictionary_org + 1; // Create a table to store the data returned. string[,] table = new string[count_dictionary, 2]; table[0, 0] = "Word"; table[0, 1] = "Number of times shown"; //sw.WriteLine("---- Most Frequent Terms in the Text: " + inputString + " ----"); //sw.WriteLine(""); //sw.WriteLine("Word" + delimiter_table + "Number of times shown"); int i = 1; foreach (KeyValuePair <string, int> pair in sortedDict) { table[i, 0] = pair.Key; table[i, 1] = pair.Value.ToString(); // Output the most frequently occurring words and the associated word counts //sw.WriteLine(count + delimiter_table + pair.Key + delimiter_table + pair.Value); //sw.WriteLine(pair.Key + delimiter_table + pair.Value); //sw.WriteLine(pair.Key + "," + pair.Value); count++; i++; // Only display the top 10 words then break out of the loop! if (count > top_how_many) { break; } } // Wait for the user to press a key before exiting //string console_read = sw.GetStringBuilder().ToString(); //string[,] stringArray = new string[,] { console_read }; //_returnValue = console_read.ToString(); ubotStudio.SetTable(table_name, table); }