public static Dictionary <string, Tuple <string, string> > properitesCompare(string PropertiesPath, string Target, RestClient client) { var myprop_dictionary = PropertiesLoad.properitesParser(PropertiesPath); var envprop_dictionary = getProperiesFromEnv(Target, client); var diff_Dictionary = new Dictionary <string, Tuple <string, string> >(); foreach (KeyValuePair <string, string> entry in envprop_dictionary) { //myprop_dictionary.TryGetValue((string)entry.Key, out value) & if (!myprop_dictionary[entry.Key].Equals(entry.Value)) { Tuple <string, string> OldAndNewValues = new Tuple <string, string>(entry.Value, myprop_dictionary[entry.Key]); Console.WriteLine("#################"); Console.WriteLine(OldAndNewValues); Console.WriteLine("#################"); diff_Dictionary.Add((string)entry.Key, OldAndNewValues); } } //printDictionary(myprop_dictionary); //Console.WriteLine("#################"); //printDictionary(diff_Dictionary); return(diff_Dictionary); }
static void Main(string[] args) { Console.WriteLine("HTTP Injector!"); var client = new RestClient("http://localhost:8111"); client.Authenticator = new HttpBasicAuthenticator("ahrochdi", "ROCH21021996."); RestRequest request = new RestRequest("app/rest/projects", Method.GET); IRestResponse response = client.Execute(request); var data = (JObject)JsonConvert.DeserializeObject(response.Content); Console.WriteLine("Status code: " + response.StatusCode); Dictionary <object, object> projects = new Dictionary <object, object>(); /* * foreach(var item in data["project"]){ * projects.Add(item["id"],item["name"]); * Console.WriteLine (item["id"].Type); * }*/ //var projects =(JObject) JsonConvert.DeserializeObject(data["project"][0]); //Console.WriteLine("Status code: " + data["project"]); var diff_dictionary = PropertiesLoad.properitesCompare("myfile.properties", "app/rest/projects", client); //string Paths_Targets="./path_Targets.properties"; //PropertiesLoad.postAllProperties(Paths_Targets,client); //PropertiesLoad.getProperiesFromEnv("app/rest/projects",client); string[] headers = { "key", "Old Value", "New Value" }; string html = PropertiesLoad.ConvertDataTableToHTML(headers, diff_dictionary); PropertiesLoad.WriteHTMLReport(html, "test"); }
public static void postProperties(string PropertiesPath, string Target, RestClient client) { var myprop_dictionary = PropertiesLoad.properitesParser(PropertiesPath); var jObjectBody = PropertiesLoad.loadToJObject(myprop_dictionary); RestRequest postResquest = new RestRequest(Target, Method.POST); postResquest.RequestFormat = DataFormat.Json; postResquest.AddParameter("application/json", jObjectBody, ParameterType.RequestBody); IRestResponse postResponse = client.Execute(postResquest); Console.WriteLine("Status code: " + postResponse.StatusCode); Console.WriteLine("Status message " + postResponse.Content); }