Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext         = this;
            ConfigCont.Content       = Config;
            VenafiAPiContent.Content = VedAPI;
            OtherAPIContent.Content  = AHControl;

            VedAPI.CallUrls.SelectedIndex = 0;
            SD = new SaveData(UserPath);
            SD.LoadSavedFunctions();
            if (LoadFuncListt.Count > 0)
            {
                foreach (SavedFunctionControl SC in LoadFuncListt)
                {
                    VedAPI.FNames.Add(SC.FunctionName, new List <string>());
                    SavedVariables.Children.Insert(1, SC);
                    this.RegisterName(SC.FunctionName, SC);
                }
            }
            if (AHLoadFuncListt.Count > 0)
            {
                foreach (AHSavedFunction SC in AHLoadFuncListt)
                {
                    AHSavedFunction SF1 = new AHSavedFunction(SC.FunctionData);
                    AHControl.FuncNames.Add(SF1.FunctionData.FunctionName);
                    SavedVariables.Children.Insert(1, SF1);
                    this.RegisterName(SF1.FunctionData.FunctionName.Replace('-', '_'), SF1);
                }
            }
        }
        private void AHSave_Click(object sender, RoutedEventArgs e)
        {
            AdaptableHelper.AHFunctionData AFD = new AdaptableHelper.AHFunctionData();
            AHSavedFunction AHNewSF;
            List <Dictionary <string, string> > AHheaders = new List <Dictionary <string, string> >();

            AFD.FunctionName = CustomFunctionName.Text;
            AFD.CallURL      = AHURL.Text;
            AFD.CBIndex.Add(AHFunctionNames.Name, AHFunctionNames.SelectedIndex);
            AFD.RequestMethod = AHMethod.SelectedValue.ToString();
            AFD.CBIndex.Add(AHMethod.Name, AHMethod.SelectedIndex);
            AFD.RequestType = AHRequestType.SelectedValue.ToString();
            AFD.CBIndex.Add(AHRequestType.Name, AHRequestType.SelectedIndex);
            AFD.CommandType = AHPScommand.SelectedValue.ToString();
            AFD.CBIndex.Add(AHPScommand.Name, AHPScommand.SelectedIndex);
            AFD.FunctionDescription = AH.FunctionDescription[AFD.FunctionName];

            foreach (AddedHeader HeaderItem in CustomConfig.Children.OfType <AddedHeader>())
            {
                AHheaders.Add(HeaderItem.ReturnObject());
            }
            AFD.CallHeaders = AHheaders;
            switch (AHRequestType.SelectedValue.ToString())
            {
            case "Json":
                AFD.RequestBody = JH.ReturnJsonString(true, true);
                break;

            case "SOAP":
                AFD.RequestBody = SH.ReturnXMLString();
                break;

            default:
                break;
            }

            AFD.Used = true;
            AFD      = AH.AHBuildFunction(AFD);

            if (!FuncNames.Contains(AFD.FunctionName))
            {
                AHNewSF = new AHSavedFunction(AFD);
                UIElement GenerateScriptBTN = MReference.SavedVariables.Children.OfType <Button>().Single();
                int       BeforeButton      = MReference.SavedVariables.Children.IndexOf(GenerateScriptBTN);
                MReference.SavedVariables.RegisterName(AFD.FunctionName.Replace('-', '_'), AHNewSF);
                MReference.SavedVariables.Children.Insert(BeforeButton, AHNewSF);
                FuncNames.Add(AFD.FunctionName);
            }
            else
            {
                AHNewSF = (AHSavedFunction)MReference.SavedVariables.FindName(AFD.FunctionName.Replace('-', '_'));
                AHNewSF.FunctionData = AFD;
            }
            AHCodeOut.Text = AFD.FunctionCode;
        }
Esempio n. 3
0
        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;
                    }
                }
            }
        }