private void ReadUserControlValues(UserControl userControl, ref Models.InputConfiguration item)
        {
            item.Enabled   = (bool)(userControl.FindControl("cbEnabled") as RadCheckBox).Checked;
            item.InputName = (userControl.FindControl("txtInputName") as RadTextBox).Text;
            item.InputType = (Models.InputType)((userControl.FindControl("DropDownListType") as RadDropDownList).SelectedItem.Index);
            //item.InputType = MapInputType(item.InputTypeStr);
            item.NamingMask = (userControl.FindControl("txtNamingMask") as RadTextBox).Text;
            item.Separators = (userControl.FindControl("txtSeparators") as RadTextBox).Text;

            item.SearchMask = (userControl.FindControl("txtSearchMask") as RadTextBox).Text;
            item.StableTime = (int)(userControl.FindControl("RadNumericStableTime") as RadNumericTextBox).Value;
            item.PollTime   = (int)(userControl.FindControl("RadNumericPollTime") as RadNumericTextBox).Value;

            item.InputPath       = (userControl.FindControl("txtInputFolder") as RadTextBox).Text;
            item.UseSpecificUser = (bool)(userControl.FindControl("cbSpecificUser") as RadCheckBox).Checked;
            item.UserName        = (userControl.FindControl("txtUserName") as RadTextBox).Text;
            item.Password        = (userControl.FindControl("txtPassword") as RadTextBox).Text;
            item.UseRegex        = (bool)(userControl.FindControl("cbRegex") as RadCheckBox).Checked;

            item.FTPserver   = (userControl.FindControl("txtFtpServer") as RadTextBox).Text;
            item.FTPusername = (userControl.FindControl("txtFtpUsername") as RadTextBox).Text;
            item.FTPpassword = (userControl.FindControl("txtFtpPassword") as RadTextBox).Text;
            item.FTPfolder   = (userControl.FindControl("txtFtpFolder") as RadTextBox).Text;
            item.FTPpasw     = (bool)(userControl.FindControl("cbFtpPassive") as RadCheckBox).Checked;
            item.FTPxcrc     = (bool)(userControl.FindControl("cbFtpXcrc") as RadCheckBox).Checked;
            item.FTPxcrc     = (bool)(userControl.FindControl("cbFtpXcrc") as RadCheckBox).Checked;
            item.FTPtls      = (Models.EncryptionType)((userControl.FindControl("RadDropDownListEncryption") as RadDropDownList).SelectedItem.Index);
        }
        protected void RadGridInput_InsertCommand(object source, GridCommandEventArgs e)
        {
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);

            Models.InputConfiguration newItem = new Models.InputConfiguration()
            {
                InputID = 0
            };

            ReadUserControlValues(userControl, ref newItem);

            DataProviders.DBaccess db = new DataProviders.DBaccess();
            if (db.InsertUpdateInputConfiguration(newItem, out string errmsg) == false)
            {
                LabelError.Text = errmsg;
                e.Canceled      = true;
            }
            Session["EditedInputDataItem"] = null;
        }
        protected void RadGridInput_UpdateCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editedItem  = e.Item as GridEditableItem;
            UserControl      userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);

            if (editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["InputID"] == null)
            {
                RadGridInput.Controls.Add(new LiteralControl("Unable to locate the InputID for updating."));
                e.Canceled = true;
                return;
            }
            int?inputID = (int?)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["InputID"];

            if (inputID.HasValue == false)
            {
                RadGridInput.Controls.Add(new LiteralControl("Unable to locate the InputID for updating."));
                e.Canceled = true;
                return;
            }

            Models.InputConfiguration selectedItem = new Models.InputConfiguration()
            {
                InputID = inputID.Value
            };

            ReadUserControlValues(userControl, ref selectedItem);

            selectedItem.RegularExpressions = ((Models.InputConfiguration)Session["EditedInputDataItem"]).RegularExpressions;
            DataProviders.DBaccess db = new DataProviders.DBaccess();
            if (db.InsertUpdateInputConfiguration(selectedItem, out string errmsg) == false)
            {
                LabelError.Text = errmsg;
                e.Canceled      = true;
            }

            Session["EditedInputDataItem"] = null;
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Models.InputConfiguration input = new Models.InputConfiguration
                {
                    InputID = 0
                };

                RadTextBoxTestResult.Text = "";

                int inputIDFromMainForm;
                if (Request.QueryString["InputID"] != null)
                {
                    inputIDFromMainForm = Utils.StringToInt(Request.QueryString["InputID"]);
                    DataProviders.DBaccess db = new DataProviders.DBaccess();
                    if (db.GetInputConfiguration(ref input, inputIDFromMainForm, out string errmsg) == false)
                    {
                        Utils.WriteLog(false, "ERROR: db.GetInputConfiguration() - " + errmsg);
                    }

                    btnUpdate.Text = "Update";
                }

                Input = input;

                if (Input != null)
                {
                    cbEnabled.Checked = Input.Enabled;
                    txtInputName.Text = Input.InputName;
                    DropDownListType.SelectedIndex = (int)Input.InputType;
                    //Input.InputType = MapInputType(item.InputTypeStr);
                    txtNamingMask.Text = Input.NamingMask;
                    txtSeparators.Text = Input.Separators;

                    txtSearchMask.Text         = Input.SearchMask;
                    RadNumericStableTime.Value = Input.StableTime;
                    RadNumericPollTime.Value   = Input.PollTime;

                    txtInputFolder.Text    = Input.InputPath;
                    cbSpecificUser.Checked = Input.UseSpecificUser;
                    txtUserNameX.Text      = Input.UserName;
                    txtPasswordX.Text      = Input.Password;
                    cbRegex.Checked        = Input.UseRegex;

                    txtFtpServer.Text    = Input.FTPserver;
                    txtFtpUsername.Text  = Input.FTPusername;
                    txtFtpPassword.Text  = Input.FTPpassword;
                    txtFtpFolder.Text    = Input.FTPfolder;
                    cbFtpPassive.Checked = Input.FTPpasw;
                    cbFtpXcrc.Checked    = Input.FTPxcrc;
                    RadDropDownListEncryption.SelectedIndex = (int)Input.FTPtls;

                    cbArchive.Checked  = Input.MakeCopy;
                    txtCopyFolder.Text = Input.CopyFolder;

                    RadCheckBoxAckFile.Checked   = Input.SendAckFile;
                    RadNumericAckCode.Value      = Input.AckFlagValue;
                    RadTextBoxAckFileFolder.Text = Input.AckFileFolder;
                }
                DropDownListType_SelectedIndexChanged(null, null);
            }
        }