private void SaveButton(object sender, RoutedEventArgs e) { CommandType = Command.SelectedValue.ToString(); CallUrl = CallUrls.SelectedValue.ToString(); UpdateJson(sender, e); SavedFunctionControl NorO; string CodeString = CHelper.BuildFunction(CommandType, FunctionName, CallUrl, JHelper.ReturnJsonString(false), MReference.Config.LanguageSelect.SelectedValue.ToString(), Foreach); Foreach = false; if (!FNames.ContainsKey(FunctionName)) { NorO = new SavedFunctionControl(FunctionName, JHelper.ReturnJsonString(true, true), CodeString, CallUrls.SelectedIndex); FNames.Add(FunctionName, new List <string>()); MReference.SavedVariables.RegisterName(FunctionName, NorO); UIElement GenerateScriptBTN = MReference.SavedVariables.Children.OfType <Button>().Single(); int BeforeButton = MReference.SavedVariables.Children.IndexOf(GenerateScriptBTN); MReference.SavedVariables.Children.Insert(BeforeButton, NorO); } else { NorO = (SavedFunctionControl)MReference.SavedVariables.FindName(FunctionName); NorO.FunctionCode = CodeString; NorO.CallUrl = CallUrls.SelectedIndex; NorO.JsonData = JHelper.ReturnJsonString(true, true); } GenerateButton(sender, e); if (!APITest) { TestApi(sender, e); NorO.ResponseData = JHelper.ReturnJsonString(true, false, true); } CodeOut.Text = CodeString; }
public SaveFunc(SavedFunctionControl NS) { FunctionName = NS.FunctionName; FunctionCode = NS.FunctionCode; JsonData = NS.JsonData; ResponseData = NS.ResponseData; CallUrl = NS.CallUrl; }
private void NCB_SelectionChanged(object sender, SelectionChangedEventArgs e) { string SelectionString; string SubSelectionString; string SelectedFunction = SelFunc.SelectedValue.ToString(); if (SelectedFunction == "General" || SelectedFunction == "Specific") { SelectionString = textLabel.Content.ToString(); SubSelectionString = SelectionString; if (_fromSOAP) { MReference.AHControl.UpdateBodyOrHeaderInput(); } else { SelectedJson = MReference.AHControl.JH.selectToken(SubSelectionString, false); MReference.AHControl.AHUpdateJson(sender, (RoutedEventArgs)e); } } else { SelectionString = NCB.SelectedValue.ToString(); if (SelectionString.Contains("-")) { SubSelectionString = SelectionString.Substring(0, SelectionString.IndexOf('-') - 1); } else if (!SelectionString.Contains("[") && SelectionString.Contains(".")) { SubSelectionString = SelectionString.Substring(0, SelectionString.IndexOf('.')); } else { SubSelectionString = SelectionString; } SavedFunctionControl ResponseJson = (SavedFunctionControl)MReference.SavedVariables.FindName(SelectedFunction); string RJ = ResponseJson.ResponseData.ToString(); SelectedJson = MReference.VedAPI.JHelper.selectToken(SubSelectionString, true, RJ); if (_fromAH && !_fromSOAP) { MReference.AHControl.AHUpdateJson(sender, (RoutedEventArgs)e); } else if (_fromSOAP) { MReference.AHControl.UpdateBodyOrHeaderInput(); } else { MReference.VedAPI.UpdateJson(sender, (RoutedEventArgs)e); } } }
public void LoadSavedFunctions() { string Jdata; if (File.Exists(FileLocation)) { using (StreamReader file = new StreamReader(FileLocation, true)) { Jdata = file.ReadLine(); } if (Jdata != null || Jdata != "") { SaveDataFileInfo NN = new SaveDataFileInfo(); NN = JsonConvert.DeserializeObject <SaveDataFileInfo>(Jdata); if (NN != null) { foreach (SaveDataFileInfo.AHSaveFunc AHFSF in NN.AHFuncInfo.Reverse <SaveDataFileInfo.AHSaveFunc>()) { AHSavedFunction Nor1 = new AHSavedFunction(AHFSF.AHD); MReference.AHLoadFuncListt.Add(Nor1); } foreach (SaveDataFileInfo.SaveFunc SF in NN.FuncInfo.Reverse <SaveDataFileInfo.SaveFunc>()) { SavedFunctionControl NorO = new SavedFunctionControl(SF.FunctionName, SF.JsonData, SF.FunctionCode, SF.CallUrl); MReference.LoadFuncListt.Add(NorO); } foreach (KeyValuePair <string, string> SGV in NN.ConfigInfo.AHGlobalVars) { MReference.Config.Globals.Children.Add(new GlobalVariables(SGV.Key, SGV.Value)); } foreach (KeyValuePair <string, string> SGV in NN.ConfigInfo.AHParamVars) { MReference.Config.Parameters.Children.Add(new GlobalVariables(SGV.Key, SGV.Value)); } MReference.Config.VenafiAPIURL = NN.ConfigInfo.VenafiAPIurl; MReference.Config.Username = NN.ConfigInfo.Username; MReference.Config.Password = NN.ConfigInfo.Password; MReference.Config.SSLTrust = NN.ConfigInfo.SSLtrust; MReference.Config.FileLocation = NN.ConfigInfo.FileLocation; MReference.Config.CodeLanguage = NN.ConfigInfo.CodeLanguage; } } } }
public void UpdateJson(UIElementCollection LOT) { forjsonText = JObject.Parse(JsonObject.ToString()); foreach (LabelAndField LF in LOT) { JToken FJT = forjsonText.SelectToken(LF.textLabel.Content.ToString()); if (LF.NCB != null) { if (LF.SelectedJson != null) { string FNV = LF.SelectedJson.Select(x => x.Key).Single().ToString(); FJT.Replace(FNV); } } else { FJT.Replace(LF.txtValue.Text); } JToken NJT = JsonObject.SelectToken(LF.textLabel.Content.ToString()); if (LF.NCB != null) { if (LF.NCB.SelectedValue != null) { string Selection; string subSelection; string functionSelection; string[] subSelectionFor = { "", "" }; string NCV; string NNCV; if (_fromAH) { Selection = LF.NCB.SelectedValue.ToString(); functionSelection = LF.SelFunc.SelectedValue.ToString(); subSelection = Selection; } else { Selection = LF.NCB.SelectedValue.ToString(); functionSelection = LF.SelFunc.SelectedValue.ToString(); SavedFunctionControl SFC = (SavedFunctionControl)MReference.SavedVariables.FindName(functionSelection); if (Selection.Contains("-")) { subSelection = Selection.Substring(0, Selection.IndexOf('-') - 1); } else if (!Selection.Contains("[")) { if (Selection.Contains(".")) { subSelectionFor = Selection.Split('.'); subSelection = "$I." + subSelectionFor[1]; } else { subSelection = "$I." + Selection; } MReference.VedAPI.Foreach = true; } else { subSelection = Selection; } } if (MReference.Config.LanguageSelect.Text == "Powershell") { if (subSelection.Contains("$I")) { NNCV = "'+" + subSelection + "+'"; if (subSelection.EndsWith("DN") || subSelection.Contains("Parent")) { NCV = "'+((" + subSelection + ") -replace '\\','\\\\')+' "; } else { NCV = "'+" + subSelection.Split('.')[0] + "+'"; } if (MReference.VedAPI.ForloopFunction.ContainsKey(functionSelection + "." + subSelectionFor[0])) { MReference.VedAPI.ForloopFunction[functionSelection + "." + subSelectionFor[0]] = NNCV; } else { MReference.VedAPI.ForloopFunction.Add(functionSelection + "." + subSelectionFor[0], NNCV); } } else { if (subSelection.EndsWith("DN") || subSelection.Contains("Parent")) { NCV = "'+$(((" + functionSelection + ")." + subSelection + ") -replace '\\','\\\\')+'"; } else { if (functionSelection == "General") { NCV = "'+$($" + functionSelection + "." + subSelection + ")+'"; } else { NCV = "'+$((" + functionSelection + ")." + subSelection + ")+'"; } } } } else { StringBuilder Sel = new StringBuilder(); string[] SubSel = subSelection.Split('.'); foreach (string S in SubSel) { string AddSTR; if (S.Contains("[")) { Sel.Append("['"); AddSTR = S.Replace("[", "']["); Sel.Append(AddSTR); } else { Sel.Append("['" + S + "']"); } } if (subSelection.EndsWith("DN") || subSelection.Contains("Parent")) { NCV = "'+json.loads(json.dumps(_" + functionSelection + "()))" + Sel.ToString() + ".replace('\\','\\\\')+'"; } else { NCV = "'+json.loads(json.dumps(_" + functionSelection + "()))" + Sel.ToString() + "+'"; } } NJT.Replace(NCV); } } else { NJT.Replace(LF.txtValue.Text); } } }
public void SaveFunction(SavedFunctionControl NS) { SaveFunc SF = new SaveFunc(NS); FuncInfo.Add(SF); }