예제 #1
0
        public ActionResult GetCompareValidator(string Id, string jsonvalue)
        {
            var requiredFieldValidator = new CompareValidator();

            if (!string.IsNullOrEmpty(Id))
            {
                var list           = Extentions.DeSerialize(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
                var firstOrDefault = list.FindControl(Id);
                if (firstOrDefault != null)
                {
                    requiredFieldValidator = (CompareValidator)firstOrDefault;
                }
            }
            ViewBag.Id                  = Id;
            ViewBag.jsonvalue           = jsonvalue;
            ViewBag.ValidationDataTypes = new SelectList(
                EnumUtils.ConvertEnumToIEnumerableInLocalization <ValidationDataType>().Select(
                    keyValuePair =>
                    new KeyValuePair <byte, string>((byte)keyValuePair.Key.ToEnum <ValidationDataType>(),
                                                    keyValuePair.Value)), "Key", "Value");
            ViewBag.ValidationOperators = new SelectList(
                EnumUtils.ConvertEnumToIEnumerableInLocalization <ValidationOperator>().Select(
                    keyValuePair =>
                    new KeyValuePair <byte, string>((byte)keyValuePair.Key.ToEnum <ValidationOperator>(),
                                                    keyValuePair.Value)), "Key", "Value");
            return(PartialView("PVCompareValidator", requiredFieldValidator));
        }
예제 #2
0
        public ActionResult GeneratVaidatorHtml(string jsonvalue, Guid formId)
        {
            var list = Extentions.DeSerialize(Utils.ConvertHtmlToString(jsonvalue.Decompress()));

            ViewBag.jsonvalue = jsonvalue;
            ViewBag.formId    = formId;
            return(PartialView("PartialViewValidatorModify", list));
        }
예제 #3
0
 public void DeSerializeForm(ref FormStructure structure)
 {
     structure.GetFormControl = new Dictionary <string, object>();
     try
     {
         structure.Controls = Extentions.DeSerialize(structure.Structure);
     }
     catch
     {
         structure.Controls = new Controls();
     }
 }
예제 #4
0
        public ActionResult DeleteVaidatorControl(string jsonvalue, string Id)
        {
            if (string.IsNullOrEmpty(Id))
            {
                return(Json(new { Result = true, Value = "" }, JsonRequestBehavior.AllowGet));
            }
            var list           = Extentions.DeSerialize(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
            var firstOrDefault = list.FirstOrDefault(x => ((Control)x).Id == Id);

            if (firstOrDefault != null)
            {
                list.Remove(firstOrDefault);
            }
            return(Json(new { Result = true, Value = list.Serialize().Compress() }, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public ActionResult GetRequiredFieldValidator(string Id, string jsonvalue)
        {
            var requiredFieldValidator = new RequiredFieldValidator();

            if (!string.IsNullOrEmpty(Id))
            {
                var list           = Extentions.DeSerialize(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
                var firstOrDefault = list.FindControl(Id);
                if (firstOrDefault != null)
                {
                    requiredFieldValidator = (RequiredFieldValidator)firstOrDefault;
                }
            }
            ViewBag.Id        = Id;
            ViewBag.jsonvalue = jsonvalue;
            return(PartialView("PVRequiredFieldValidator", requiredFieldValidator));
        }
예제 #6
0
        public ActionResult GetValidatorControl(string Id, string jsonvalue)
        {
            var control = new ValidatorControl();

            if (!string.IsNullOrEmpty(Id))
            {
                var list           = Extentions.DeSerialize(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
                var firstOrDefault = list.FindControl(Id);
                if (firstOrDefault != null)
                {
                    control = (ValidatorControl)firstOrDefault;
                }
            }
            ViewBag.Id        = Id;
            ViewBag.jsonvalue = jsonvalue;
            return(PartialView("PVValidatorControl", control));
        }
예제 #7
0
        public override FormEvaluation Get(IConnectionHandler connectionHandler, params object[] keys)
        {
            var structure = base.Get(connectionHandler, keys);

            if (structure == null)
            {
                return(null);
            }
            if (!string.IsNullOrEmpty(structure.StructureFileId))
            {
                var file = FileManagerComponent.Instance.FileFacade.Get(structure.StructureFileId.ToGuid());
                if (file != null)
                {
                    structure.Controls = Extentions.DeSerialize(StringUtils.Unzip(file.Content));
                }
            }
            return(structure);
        }
예제 #8
0
        public ActionResult BaseValidatorGenerateControl(string Id, string jsonvalue)
        {
            var textControl = new Control()
            {
                Enable = true, Visible = false
            };

            if (!string.IsNullOrEmpty(Id))
            {
                var list           = Extentions.DeSerialize(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
                var firstOrDefault =
                    list.FindControl(Id);
                if (firstOrDefault != null)
                {
                    textControl = (Control)firstOrDefault;
                }
            }
            return(PartialView("PVBaseValidatorGenerateControl", textControl));
        }
예제 #9
0
        public FormEvaluation GetByCulture(IConnectionHandler connectionHandler, string id, string culture)
        {
            var structure = base.GetLanuageContent(connectionHandler, culture, id);

            if (structure == null)
            {
                return(null);
            }
            structure.Controls = new Controls();
            if (!string.IsNullOrEmpty(structure.StructureFileId))
            {
                var file = FileManagerComponent.Instance.FileFacade.Get(structure.StructureFileId);
                if (file != null)
                {
                    structure.Controls = Extentions.DeSerialize(StringUtils.Unzip(file.Content));
                }
            }

            return(structure);
        }
예제 #10
0
        public void SetValidator(string value, Control control, Controls controls, Guid formId)
        {
            var controls1 = new Controls();

            if (!string.IsNullOrEmpty(value))
            {
                controls1.AddRange(Extentions.DeSerialize(Utils.ConvertHtmlToString(StringUtils.Decrypt(value).Decompress())));
            }
            var enumerable     = controls1.Where(x => ((ValidatorControl)x).ControlToValidate == control.Id);
            var allvalidations = controls.GetValidations();

            foreach (ValidatorControl validator in enumerable)
            {
                var firstOrDefault = controls.FindControl(validator.Id);
                if (firstOrDefault != null)
                {
                    controls.Remove(firstOrDefault);
                    validator.Order = control.Order;
                    controls.Add(validator);
                }
            }
            var validators = allvalidations.FindValidationControls(control.Id);

            foreach (ValidatorControl validatorControl in validators)
            {
                var firstOrDefault = controls1.FindControl(validatorControl.Id);
                if (firstOrDefault == null)
                {
                    controls.Remove(validatorControl);
                }
            }
            var validatorlist = controls1.Where(x => ((ValidatorControl)x).ControlToValidate == String.Empty);

            foreach (ValidatorControl validator in validatorlist)
            {
                SetValidatorIdAndName(allvalidations, validator, formId);
                validator.ControlToValidate = control.Id;
                validator.Order             = control.Order;
                controls.Add(validator);
            }
        }
예제 #11
0
        public ActionResult GetVaidatorControlPanel(FormCollection collection)
        {
            try
            {
                var formId = collection["formId"];
                if (string.IsNullOrEmpty(formId))
                {
                    return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                }
                var controls = new Controls();
                controls.AddRange(Extentions.DeSerialize(Utils.ConvertHtmlToString(collection["jsonvalue"].Decompress())));
                var Id = collection["Id"];
                if (!string.IsNullOrEmpty(Id))
                {
                    var firstOrDefault = controls.FindControl(Id);
                    if (firstOrDefault == null)
                    {
                        return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                    }
                    this.RadynTryUpdateModel(firstOrDefault);
                    if (((ValidatorControl)firstOrDefault).Enable)
                    {
                        if (controls.Any(x =>
                                         x.GetType().Name == firstOrDefault.GetType().Name&&
                                         ((ValidatorControl)x).Id != ((ValidatorControl)firstOrDefault).Id &&
                                         ((ValidatorControl)x).Enable))
                        {
                            ShowMessage(Resources.FormGenerator.ThisValidationTypalreadyAdded,
                                        Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error);
                            return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(collection["ValidatorTypeId"]))
                    {
                        return(Content("false"));
                    }
                    var loadFrom = FormGeneratorComponent.Instance.FormStructureFacade.GetValidatorTypes();
                    if (loadFrom == null)
                    {
                        return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                    }
                    var type = loadFrom.FirstOrDefault(x => x.Name == collection["ValidatorTypeId"]);
                    if (type == null)
                    {
                        return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                    }
                    var obj = Activator.CreateInstance(type);
                    this.RadynTryUpdateModel(obj);
                    FormGeneratorComponent.Instance.FormStructureDesgineFacade.SetValidatorIdAndName(controls, obj, formId.ToGuid());
                    if (((ValidatorControl)obj).Enable)
                    {
                        if (controls.Any(x => x.GetType().Name == obj.GetType().Name&& ((ValidatorControl)x).Id != ((ValidatorControl)obj).Id && ((ValidatorControl)x).Enable))
                        {
                            ShowMessage(Resources.FormGenerator.ThisValidationTypalreadyAdded, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error);
                            return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                        }
                    }
                    controls.Add(obj);
                }

                return(Json(new { Result = true, Value = controls.Serialize().Compress() }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
                return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #12
0
        public ActionResult GetValidatorControlCount(string value)
        {
            var list = string.IsNullOrEmpty(value) ? new List <object>() : Extentions.DeSerialize(Utils.ConvertHtmlToString(StringUtils.Decrypt(value).Decompress()));

            return(Json(new { CountItem = list.Count, Added = list.Count > 0 }, JsonRequestBehavior.AllowGet));
        }