示例#1
0
 internal FormStructure GenerateForm(IConnectionHandler connectionHandler, FormStructure formStructure, string culture = null)
 {
     if (formStructure == null || !formStructure.Enable)
     {
         return(null);
     }
     if (!string.IsNullOrEmpty(formStructure.RefId) && formStructure.GetFormControl != null)
     {
         var firstOrDefault = new FormDataBO().GetFormData(connectionHandler, formStructure.Id, formStructure.RefId, formStructure.ObjectName, culture);
         if (firstOrDefault != null)
         {
             if (firstOrDefault.StructureId == formStructure.Id)
             {
                 var list = Extentions.GetControlData(firstOrDefault.Data);
                 foreach (var controlvalueModel in list)
                 {
                     if (!formStructure.GetFormControl.ContainsKey(controlvalueModel.Key))
                     {
                         formStructure.GetFormControl.Add(controlvalueModel.Key, controlvalueModel.Value);
                     }
                 }
             }
         }
     }
     if (string.IsNullOrEmpty(formStructure.RefId) && formStructure.FormState == FormState.DataEntryMode)
     {
         formStructure.FormState = FormState.FirstLoadMode;
     }
     return(formStructure);
 }
示例#2
0
 public FormData GetWithoutGridFormData(IConnectionHandler connectionHandler, FormStructure formStructure, string refId, string objname, string culture)
 {
     if (!string.IsNullOrEmpty(refId))
     {
         var controls  = formStructure.Controls.Where(x => x.GetType().Name != typeof(ControlFactory.Controls.Grid).Name && string.IsNullOrEmpty(((Control)x).GridId)).ToList();
         var formDatas = new FormDataBO().Where(connectionHandler, x => x.RefId.ToLower() == refId.ToLower() && x.ObjectName.ToLower() == objname.ToLower() && x.StructureId == formStructure.Id);
         if (formDatas == null || !formDatas.Any())
         {
             return(null);
         }
         new FormDataBO().GetLanuageContent(connectionHandler, culture, formDatas);
         FormData setformData = null;
         foreach (var formData in formDatas)
         {
             var list = Extentions.GetControlData(formData.Data);
             foreach (var control in controls)
             {
                 if (!list.ContainsKey(((Control)control).Id))
                 {
                     continue;
                 }
                 if (!formData.GetFormControl.ContainsKey(((Control)control).Id))
                 {
                     formData.GetFormControl.Add(((Control)control).Id, list[((Control)control).Id]);
                 }
                 setformData = formData;
             }
             if (setformData != null)
             {
                 return(setformData);
             }
         }
     }
     return(null);
 }
示例#3
0
        public bool Delete(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnectionHandler, params object[] keys)
        {
            var obj = this.Get(connectionHandler, keys);

            var formDataBo = new FormDataBO();

            var fileTransactionalFacade =
                FileManagerComponent.Instance.FileTransactionalFacade(filemanagerconnectionHandler);
            var byFilter = formDataBo.Select(connectionHandler, x => x.Id, x => x.StructureId == obj.Id);

            foreach (var formData in byFilter)
            {
                if (!formDataBo.Delete(connectionHandler, formData))
                {
                    throw new Exception("خطایی در حذف فرم وجود دارد");
                }
            }
            var formAssigmentBo = new FormAssigmentBO();
            var formAssigments  = formAssigmentBo.Select(connectionHandler, x => x.Url, x => x.FormStructureId == obj.Id);

            foreach (var formAssigment in formAssigments)
            {
                if (!formAssigmentBo.Delete(connectionHandler, obj.Id, formAssigment))
                {
                    throw new Exception("خطایی در حذف فرم وجود دارد");
                }
            }

            if (!string.IsNullOrEmpty(obj.StructureFileId))
            {
                if (!fileTransactionalFacade.Delete(obj.StructureFileId.ToGuid()))
                {
                    throw new Exception("خطایی در حذف فرم وجود دارد");
                }
            }

            if (!base.Delete(connectionHandler, keys))
            {
                throw new Exception("خطایی در حذف فرم وجود دارد");
            }

            return(true);
        }
示例#4
0
        public List <FormData> GetGridDataSource(IConnectionHandler connectionHandler, FormStructure formStructure, string objactname, string refId, string gridId, string culture)
        {
            var datas = new List <FormData>();

            if (!string.IsNullOrEmpty(refId))
            {
                var controls  = formStructure.Controls.Where(x => x.GetType().Name != typeof(Grid).Name && ((Control)x).GridId == gridId).ToList();
                var formDatas = new FormDataBO().Where(connectionHandler,
                                                       x =>
                                                       x.RefId.ToLower() == refId.ToLower() && x.ObjectName.ToLower() == objactname.ToLower() &&
                                                       x.StructureId == formStructure.Id);
                if (formDatas == null || !formDatas.Any())
                {
                    return(null);
                }
                new FormDataBO().GetLanuageContent(connectionHandler, culture, formDatas);
                foreach (var formData in formDatas)
                {
                    var  list = Extentions.GetControlData(formData.Data);
                    bool add  = false;
                    foreach (var control in controls)
                    {
                        if (!list.ContainsKey(((Control)control).Id))
                        {
                            continue;
                        }
                        add = true;
                        if (!formData.GetFormControl.ContainsKey(((Control)control).Id))
                        {
                            formData.GetFormControl.Add(((Control)control).Id, list[((Control)control).Id]);
                        }
                    }
                    if (add)
                    {
                        datas.Add(formData);
                    }
                }
            }
            return(datas);
        }