Esempio n. 1
0
        public bool Insert(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnectionHandler, FormStructure formPostModel)
        {
            var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(filemanagerconnectionHandler);

            foreach (var source in formPostModel.GetFormControl.Where(x => x.Key.Contains(typeof(FileUpload).Name)).ToList())
            {
                if (source.Value != null && !Equals(source.Value, "") && source.Value.GetType() == typeof(HttpPostedFileWrapper))
                {
                    formPostModel.GetFormControl[source.Key] = fileTransactionalFacade.Insert((HttpPostedFileBase)source.Value).ToString();
                }
            }
            var formData = new FormData
            {
                RefId       = formPostModel.RefId,
                StructureId = formPostModel.Id,
                ObjectName  = formPostModel.ObjectName,
                Data        = Extentions.GetFormData(formPostModel.GetFormControl)
            };

            formData.CurrentUICultureName = formPostModel.CurrentUICultureName;
            if (!this.Insert(connectionHandler, formData))
            {
                throw new Exception("خطایی در ذخیره اطلاعات فرم وجود دارد");
            }
            return(true);
        }
Esempio n. 2
0
        public bool Update(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnectionHandler, FormStructure formPostModel, FormData frm)
        {
            var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(filemanagerconnectionHandler);
            var controlData             = Extentions.GetControlData(frm.Data);

            foreach (var source in formPostModel.GetFormControl.Where(x => x.Key.Contains(typeof(FileUpload).Name)).ToList())
            {
                var keyValuePair = new KeyValuePair <string, object>();
                if (controlData != null)
                {
                    keyValuePair = controlData.FirstOrDefault(x => x.Key == source.Key);
                }
                if (source.Value != null && !Equals(source.Value, ""))
                {
                    if (source.Value.GetType() == typeof(HttpPostedFileWrapper))
                    {
                        if (keyValuePair.Value != null && !Equals(keyValuePair.Value, ""))
                        {
                            fileTransactionalFacade.Delete(((string)keyValuePair.Value).ToGuid());
                        }
                        formPostModel.GetFormControl[source.Key] = fileTransactionalFacade.Insert((HttpPostedFileBase)source.Value).ToString();
                    }
                }
                else
                {
                    if (keyValuePair.Value != null && !Equals(keyValuePair.Value, ""))
                    {
                        fileTransactionalFacade.Delete(((string)keyValuePair.Value).ToGuid());
                    }
                }
            }
            frm.CurrentUICultureName = formPostModel.CurrentUICultureName;
            frm.StructureId          = formPostModel.Id;
            frm.Data = Extentions.GetFormData(formPostModel.GetFormControl);
            if (!this.Update(connectionHandler, frm))
            {
                throw new Exception("خطایی در ویرایش اطلاعات فرم وجود دارد");
            }

            return(true);
        }
Esempio n. 3
0
        internal bool ModifyEvaluation(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnectionHandler, FormEvaluation formEvaluation, string culture)
        {
            FileManager.Facade.Interface.IFileFacade fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(filemanagerconnectionHandler);
            var serialize  = formEvaluation.Controls.Serialize();
            var formData   = Extentions.GetFormData(formEvaluation.GetFormControl);
            var evaluation = this.GetByCulture(connectionHandler, formEvaluation.ControlId, culture);

            if (evaluation != null)
            {
                formEvaluation.StructureFileId = evaluation.StructureFileId;
                formEvaluation.DataFileId      = evaluation.DataFileId;
                if (!this.Update(connectionHandler, formEvaluation))
                {
                    throw new KnownException("خطایی در ذخیره فرم وجود دارد");
                }
            }
            else
            {
                if (!this.Insert(connectionHandler, formEvaluation))
                {
                    throw new KnownException("خطایی در ذخیره فرم وجود دارد");
                }
            }
            if (!string.IsNullOrEmpty(formEvaluation.StructureFileId))
            {
                FileManager.DataStructure.File file = fileTransactionalFacade.Get(formEvaluation.StructureFileId.ToGuid());
                if (file != null)
                {
                    file.Content = StringUtils.Zip(serialize);
                    if (!fileTransactionalFacade.Update(file))
                    {
                        throw new Exception("خطایی در ذخیره فرم وجود دارد");
                    }
                }
            }
            else
            {
                FileManager.DataStructure.File file = new Radyn.FileManager.DataStructure.File
                {
                    Content     = StringUtils.Zip(serialize),
                    FileName    = "Structure",
                    Extension   = "zip",
                    ContentType = "zip"
                };
                if (fileTransactionalFacade.InsertFile(file) == Guid.Empty)
                {
                    throw new Exception("خطایی در ذخیره فایل وجود دارد");
                }
                formEvaluation.StructureFileId = file.Id.ToString();
            }

            if (!string.IsNullOrEmpty(formEvaluation.DataFileId))
            {
                FileManager.DataStructure.File file = fileTransactionalFacade.Get(formEvaluation.DataFileId.ToGuid());
                if (file != null)
                {
                    file.Content = StringUtils.Zip(formData);
                    if (!fileTransactionalFacade.Update(file))
                    {
                        throw new Exception("خطایی در ذخیره فرم وجود دارد");
                    }
                }
            }
            else
            {
                FileManager.DataStructure.File file = new Radyn.FileManager.DataStructure.File
                {
                    Content     = StringUtils.Zip(formData),
                    FileName    = "StructureData",
                    Extension   = "zip",
                    ContentType = "zip"
                };
                if (fileTransactionalFacade.InsertFile(file) == Guid.Empty)
                {
                    throw new Exception("خطایی در ذخیره فایل وجود دارد");
                }
                formEvaluation.DataFileId = file.Id.ToString();
            }
            formEvaluation.CurrentUICultureName = culture;
            this.Update(connectionHandler, formEvaluation);
            return(true);
        }