Example #1
0
 private void BindDgConfig()
 {
     if (this.ConfigurationInfo != null)
     {
         this.dg_Config.Visible    = true;
         this.dg_Config.DataSource = this.ConfigurationInfo.ConfigurationParams;
         this.dg_Config.DataBind();
         for (int i = 0; i < this.ConfigurationInfo.ConfigurationParams.Count; i++)
         {
             ConfigurationParam temp = this.ConfigurationInfo.ConfigurationParams[i];
             string             name = temp.Name;
             if (temp.Mandatory)
             {
                 name = name + " *";
             }
             this.dg_Config.Items[i].Cells[1].Text = name;
             this.dg_Config.Items[i].Cells[2].Text = temp.Type.ToString();
             HiddenField hf = new HiddenField();
             hf.Value = temp.Name;
             this.dg_Config.Items[i].Cells[0].Controls.Add(hf);
             ObjectTypeControlStrategy.Instances[temp.Type].AddControl(this.Page, this.dg_Config.Items[i].Cells[3].Controls, temp, CssClass);
         }
         this.fillDescription();
     }
 }
Example #2
0
        public override void AddControl(Page page, ControlCollection controls, ConfigurationParam param, string cssClass)
        {
            TextBox res = new TextBox();

            res.CssClass = cssClass;
            res.Text     = param.Value;
            controls.Add(res);
        }
Example #3
0
        public override void AddControl(Page page, ControlCollection controls, ConfigurationParam param, string cssClass)
        {
            CheckBox res = new CheckBox();

            if ("true".Equals(param.Value))
            {
                res.Checked = true;
            }
            controls.Add(res);
        }
Example #4
0
 private void FillConfigurationInfo(MemberInfo memberInfo, ConfigurationInfo res)
 {
     IntegrationObjectTypeAttribute[] attrs = (IntegrationObjectTypeAttribute[])memberInfo.GetCustomAttributes(typeof(IntegrationObjectTypeAttribute), true);
     foreach (IntegrationObjectTypeAttribute temp in attrs)
     {
         ConfigurationParam tempParam = new ConfigurationParam();
         tempParam.Name      = temp.Name;
         tempParam.Type      = temp.Type;
         tempParam.Mandatory = temp.Mandatory;
         res.ConfigurationParams.Add(tempParam);
     }
 }
Example #5
0
        public override void AddControl(Page page, ControlCollection controls, ConfigurationParam param, string cssClass)
        {
            Label      lbl = new Label();
            FileUpload res = new FileUpload();

            res.CssClass = cssClass;

            HiddenField hf = new HiddenField();

            if (!string.IsNullOrEmpty(param.Value))
            {
                hf.Value = param.Value;
                FileType temp = FileType.Decode(param.Value);
                lbl.Text = temp.Filename;
            }
            controls.Add(hf);
            controls.Add(lbl);
            controls.Add(res);
        }
Example #6
0
        public ValidationResult ValidateConfig()
        {
            ValidationResult res = new ValidationResult();

            try
            {
                if (string.IsNullOrEmpty(this.ddl_Adapter.SelectedValue))
                {
                    res.IsValid      = false;
                    res.ErrorMessage = "Selezionare un adapter";
                }
                ConfigurationInfo configInfo = new ConfigurationInfo();
                configInfo.Value = ConfigurationValue;
                GetAdapterFromSelect().Init(configInfo);
                res.IsValid = true;
            }
            catch (ConfigurationException ce)
            {
                res.IsValid = false;
                if (ce.Errors.Count > 0)
                {
                    ConfigurationParam temp = ce.Errors[0].Param;
                    if (ce.Errors[0].Code == ValidationErrorCode.NOT_VALID_VALUE)
                    {
                        string message = "Il parametro " + temp.Name + " ha valore non valido";
                        if (!string.IsNullOrEmpty(ce.Errors[0].Message))
                        {
                            message = message + " : " + ce.Errors[0].Message;
                        }
                        res.ErrorMessage = message;
                    }
                    else
                    {
                        res.ErrorMessage = "Il parametro " + temp.Name + " è obbligatorio";
                    }
                }
                else
                {
                    res.ErrorMessage = ce.ErrorMessage;
                }
            }
            return(res);
        }
Example #7
0
 private void SetConfigurationField(ConfigurationParam confParam, List <ValidationError> errors)
 {
     foreach (FieldInfo field in Fields)
     {
         IntegrationObjectTypeAttribute[] attrs = (IntegrationObjectTypeAttribute[])field.GetCustomAttributes(typeof(IntegrationObjectTypeAttribute), true);
         foreach (IntegrationObjectTypeAttribute temp in attrs)
         {
             if (temp.Name.Equals(confParam.Name))
             {
                 logger.Debug("setting " + temp.Name + "...");
                 if (temp.Mandatory && string.IsNullOrEmpty(confParam.Value))
                 {
                     logger.Debug("mandatory field " + temp.Name + " not set");
                     errors.Add(new ValidationError(confParam, ValidationErrorCode.MANDATORY_VALUE));
                     return;
                 }
                 if (string.IsNullOrEmpty(confParam.Value))
                 {
                     return;
                 }
                 try
                 {
                     field.SetValue(this, temp.GetValue(confParam.Value));
                 }
                 catch (ObjectValidationException ove)
                 {
                     errors.Add(new ValidationError(confParam, ValidationErrorCode.NOT_VALID_VALUE, ove.ErrorMessage));
                 }
                 catch (Exception e)
                 {
                     logger.Error("exception in setting " + temp.Name + ": " + e);
                     errors.Add(new ValidationError(confParam, ValidationErrorCode.NOT_VALID_VALUE));
                 }
                 return;
             }
         }
     }
     foreach (PropertyInfo property in Properties)
     {
         IntegrationObjectTypeAttribute[] attrs = (IntegrationObjectTypeAttribute[])property.GetCustomAttributes(typeof(IntegrationObjectTypeAttribute), true);
         foreach (IntegrationObjectTypeAttribute temp in attrs)
         {
             if (temp.Name.Equals(confParam.Name))
             {
                 logger.Debug("setting " + temp.Name + "...");
                 if (temp.Mandatory && string.IsNullOrEmpty(confParam.Value))
                 {
                     logger.Debug("mandatory field " + temp.Name + " not set");
                     errors.Add(new ValidationError(confParam, ValidationErrorCode.MANDATORY_VALUE));
                     return;
                 }
                 if (string.IsNullOrEmpty(confParam.Value))
                 {
                     return;
                 }
                 try
                 {
                     property.SetValue(this, temp.GetValue(confParam.Value), null);
                 }
                 catch (ObjectValidationException ove)
                 {
                     errors.Add(new ValidationError(confParam, ValidationErrorCode.NOT_VALID_VALUE, ove.ErrorMessage));
                 }
                 catch (Exception e)
                 {
                     logger.Error("exception in setting " + temp.Name + ": " + e);
                     errors.Add(new ValidationError(confParam, ValidationErrorCode.NOT_VALID_VALUE));
                 }
                 return;
             }
         }
     }
 }
Example #8
0
 public abstract void AddControl(Page page, ControlCollection controls, ConfigurationParam param, string cssClass);