Esempio n. 1
0
        private void SetFormFromSettings(PostFormSetting oPostFormSetting)
        {
            try
            {
                this.txtUser.Text   = FixSetting(oPostFormSetting.User);
                this.txtDomain.Text = FixSetting(oPostFormSetting.Domain);

                this.cmboAuthentication.Text = FixSetting(oPostFormSetting.Authentication);
                this.txtUrl.Text             = FixSetting(oPostFormSetting.Url);
                this.cmboVerb.Text           = FixSetting(oPostFormSetting.Verb);
                this.cmboContentType.Text    = FixSetting(oPostFormSetting.ContentType);

                //this.chkRawPost.Checked = oPostFormSetting.RawPost;
                UInt32 iTimeoutSeconds = 0;
                iTimeoutSeconds = Convert.ToUInt32(oPostFormSetting.TimeoutSeconds);
                this.numericUpDownTimeoutSeconds.Value = iTimeoutSeconds;
                this.cmboUserAgent.Text = FixSetting(oPostFormSetting.UserAgent);

                this.chkPragmaNocache.Checked = oPostFormSetting.PragmaNoCache;
                this.chkTranslateF.Checked    = oPostFormSetting.TranslateF;
                this.chkAllowRedirect.Checked = oPostFormSetting.AllowAutoRedirect;

                this.txtRequest.Text  = FixSetting(oPostFormSetting.EasRequest);  // .Replace("\n", "\r\n");
                this.txtResponse.Text = FixSetting(oPostFormSetting.EasResponse); //.Replace("\n", "\r\n");

                oPostFormSetting = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error loading settings into form");
            }
        }
Esempio n. 2
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            string          sFile = string.Empty;
            string          sConnectionSettings = string.Empty;
            PostFormSetting oPostFormSetting    = new PostFormSetting();

            SetSettingsFromForm(ref oPostFormSetting);

            if (UserIoHelper.PickSaveFileToFolder(Application.UserAppDataPath, "Connection Settings " + TimeHelper.NowMashup() + ".xml", ref sFile, "XML files (*.xml)|*.xml"))
            {
                //http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.newlinehandling(v=vs.110).aspx
                sConnectionSettings = SerialHelper.SerializeObjectToString <PostFormSetting>(oPostFormSetting);
                if (sConnectionSettings != string.Empty)
                {
                    try
                    {
                        System.IO.File.WriteAllText(sFile, sConnectionSettings);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error Saving File");
                    }
                }
            }
        }
Esempio n. 3
0
        private void btnLoadSettings_Click(object sender, EventArgs e)
        {
            string          sFile = string.Empty;
            string          sConnectionSettings = string.Empty;
            PostFormSetting oPostFormSetting    = null;
            string          sFileContents       = string.Empty;

            if (UserIoHelper.PickLoadFromFile(Application.UserAppDataPath, "*.xml", ref sFile, "XML files (*.xml)|*.xml"))
            {
                try
                {
                    sFileContents    = System.IO.File.ReadAllText(sFile);
                    oPostFormSetting = SerialHelper.DeserializeObjectFromString <PostFormSetting>(sFileContents);
                    if (oPostFormSetting == null)
                    {
                        throw new Exception("Settings file cannot be deserialized.");
                    }
                    SetFormFromSettings(oPostFormSetting);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error Loading File");
                }

                SetFields();
            }
        }
Esempio n. 4
0
        private void SetSettingsFromForm(ref PostFormSetting oPostFormSetting)
        {
            oPostFormSetting.User   = this.txtUser.Text;
            oPostFormSetting.Domain = this.txtDomain.Text;

            oPostFormSetting.Authentication = this.cmboAuthentication.Text;
            oPostFormSetting.Url            = this.txtUrl.Text;
            oPostFormSetting.Verb           = this.cmboVerb.Text;
            oPostFormSetting.ContentType    = this.cmboContentType.Text;


            oPostFormSetting.TimeoutSeconds = (int)this.numericUpDownTimeoutSeconds.Value;

            oPostFormSetting.UserAgent = this.cmboUserAgent.Text;

            oPostFormSetting.PragmaNoCache     = this.chkPragmaNocache.Checked = oPostFormSetting.PragmaNoCache;
            oPostFormSetting.TranslateF        = this.chkTranslateF.Checked;
            oPostFormSetting.AllowAutoRedirect = this.chkAllowRedirect.Checked = oPostFormSetting.AllowAutoRedirect;

            oPostFormSetting.EasRequest  = this.txtRequest.Text;
            oPostFormSetting.EasResponse = this.txtResponse.Text;
        }