Esempio n. 1
0
 public override bool Delete(params object[] keys)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         var congressHtmlBO = new CongressHtmlBO();
         var obj            = congressHtmlBO.Get(this.ConnectionHandler, keys);
         if (!congressHtmlBO.Delete(this.ConnectionHandler, keys))
         {
             throw new Exception("خطایی در حذف Html همایش وجود دارد");
         }
         if (
             !ContentManagerComponent.Instance.HtmlDesginTransactinalFacade(this.ContentManagerConnection)
             .Delete(obj.HtmlDesginId))
         {
             throw new Exception("خطایی در حذف Html وجود دارد");
         }
         this.ConnectionHandler.CommitTransaction();
         this.ContentManagerConnection.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         this.ContentManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         this.ContentManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Esempio n. 2
0
        public bool ConfigByDefaulToHoma(Guid homaId)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);

                var defaulthoma = new HomaBO().FirstOrDefault(ConnectionHandler, x => x.IsDefaultForConfig);
                var configurationTranscationFacade        = new ConfigurationBO();
                var configurationContentTranscationFacade = new ConfigurationContentBO();
                var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection);
                if (defaulthoma != null)
                {
                    var homa = new HomaBO().FirstOrDefault(ConnectionHandler, x => x.Id == homaId);
                    if (defaulthoma.Id == homa.Id)
                    {
                        return(true);
                    }
                    if (homa.Configuration == null || homa.Configuration.CongressId == Guid.Empty)
                    {
                        var configuration1 = new ConfigurationBO().Get(ConnectionHandler, defaulthoma.Id);
                        if (configuration1 != null)
                        {
                            configuration1.CongressId = homa.Id;
                            var configurationContents = new ConfigurationContentBO().Where(ConnectionHandler, x => x.ConfigurationId == defaulthoma.Id);
                            configurationTranscationFacade.Insert(ConnectionHandler, configuration1);
                            foreach (var configurationContent in configurationContents)
                            {
                                configurationContent.ConfigurationId = homa.Id;
                                if (configurationContent != null)
                                {
                                    if (configurationContent.AttachRefereeFile != null)
                                    {
                                        var AttachRefereeFile = Guid.NewGuid();
                                        configurationContent.AttachRefereeFile.Id = AttachRefereeFile;
                                        configurationContent.AttachRefereeFileId  = AttachRefereeFile;
                                        fileTransactionalFacade.Insert(configurationContent.AttachRefereeFile);
                                    }
                                    if (configurationContent.BoothMapAttachment != null)
                                    {
                                        var BoothMapAttachment = Guid.NewGuid();
                                        configurationContent.BoothMapAttachment.Id = BoothMapAttachment;
                                        configurationContent.BoothMapAttachmentId  = BoothMapAttachment;
                                        fileTransactionalFacade.Insert(configurationContent.BoothMapAttachment);
                                    }
                                    if (configurationContent.OrginalPoster != null)
                                    {
                                        var OrginalPoster = Guid.NewGuid();
                                        configurationContent.OrginalPoster.Id = OrginalPoster;
                                        configurationContent.OrginalPosterId  = OrginalPoster;
                                        fileTransactionalFacade.Insert(configurationContent.OrginalPoster);
                                    }
                                    if (configurationContent.MiniPoster != null)
                                    {
                                        var MiniPoster = Guid.NewGuid();
                                        configurationContent.MiniPoster.Id = MiniPoster;
                                        configurationContent.MiniPosterId  = MiniPoster;
                                        fileTransactionalFacade.Insert(configurationContent.MiniPoster);
                                    }
                                    if (configurationContent.Logo != null)
                                    {
                                        var logoId = Guid.NewGuid();
                                        configurationContent.Logo.Id = logoId;
                                        configurationContent.LogoId  = logoId;
                                        fileTransactionalFacade.Insert(configurationContent.Logo);
                                    }
                                    if (configurationContent.Header != null)
                                    {
                                        var headerId = Guid.NewGuid();
                                        configurationContent.HeaderId  = headerId;
                                        configurationContent.Header.Id = headerId;
                                        fileTransactionalFacade.Insert(configurationContent.Header);
                                    }
                                    if (configurationContent.Footer != null)
                                    {
                                        var logoId = Guid.NewGuid();
                                        configurationContent.FooterId  = logoId;
                                        configurationContent.Footer.Id = logoId;
                                        fileTransactionalFacade.Insert(configurationContent.Footer);
                                    }
                                    if (configurationContent.HallMap != null)
                                    {
                                        var HallMap = Guid.NewGuid();
                                        configurationContent.HallMapId  = HallMap;
                                        configurationContent.HallMap.Id = HallMap;
                                        fileTransactionalFacade.Insert(configurationContent.HallMap);
                                    }
                                }
                                configurationContentTranscationFacade.Insert(ConnectionHandler, configurationContent);
                            }
                        }
                    }
                    var congressLanguageBo = new CongressLanguageBO();
                    var congressLanguages  = congressLanguageBo.Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id);
                    if (congressLanguages != null)
                    {
                        var congressMenuTranscationFacade = congressLanguageBo;
                        foreach (var congressLanguage in congressLanguages)
                        {
                            congressLanguage.CongressId = homa.Id;
                            congressMenuTranscationFacade.Insert(ConnectionHandler, congressLanguage);
                        }
                    }

                    var congressContentBo = new CongressContentBO();
                    var congressContents  = congressContentBo.Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id);
                    if (congressContents != null)
                    {
                        var contentContentFacade = ContentManagerComponent.Instance.ContentTransactionalFacade(ConnectionHandler);
                        var contentFacade        = ContentManagerComponent.Instance.ContentContentTransactionalFacade(ConnectionHandler);
                        foreach (var congressContent in congressContents)
                        {
                            var oldid    = congressContent.ContentId;
                            var contents = contentFacade.Where(x => x.Id == oldid);
                            contentContentFacade.Insert(congressContent.Content);
                            foreach (var contentContent in contents)
                            {
                                contentContent.Id = congressContent.Content.Id;
                                contentFacade.Insert(contentContent);
                            }
                            congressContent.CongressId = homa.Id;
                            congressContent.ContentId  = congressContent.Content.Id;
                            congressContentBo.Insert(ConnectionHandler, congressContent);
                        }
                    }

                    var congressContainers = new CongressContainerBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id);
                    if (congressContainers != null)
                    {
                        var congressMenuTranscationFacade = new CongressContainerFacade(ConnectionHandler);
                        foreach (var congressMenu in congressContainers)
                        {
                            var newGuid = Guid.NewGuid();
                            congressMenu.Container.Id = newGuid;
                            congressMenu.ContainerId  = newGuid;
                            congressMenu.CongressId   = homa.Id;
                            congressMenuTranscationFacade.Insert(homa.Id, congressMenu.Container);
                        }
                    }
                    var congressMenus = new CongressMenuHtmlBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id);
                    if (congressMenus != null)
                    {
                        var congressMenuTranscationFacade = new CongressMenuHtmlFacade(ConnectionHandler);
                        foreach (var congressMenu in congressMenus)
                        {
                            var newGuid = Guid.NewGuid();
                            congressMenu.MenuHtml.Id = newGuid;
                            congressMenu.MenuHtmlId  = newGuid;
                            congressMenu.CongressId  = homa.Id;
                            congressMenuTranscationFacade.Insert(homa.Id, congressMenu.MenuHtml);
                        }
                    }
                    var @where = new CongressHtmlBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id);
                    if (@where != null)
                    {
                        var congressMenuTranscationFacade = new CongressHtmlFacade(ConnectionHandler);
                        foreach (var congressMenu in @where)
                        {
                            var oldId   = congressMenu.HtmlDesginId;
                            var newGuid = Guid.NewGuid();
                            congressMenu.HtmlDesgin.Id = newGuid;
                            congressMenu.HtmlDesginId  = newGuid;
                            congressMenu.CongressId    = homa.Id;
                            congressMenuTranscationFacade.Insert(homa.Id, congressMenu.HtmlDesgin);
                            var partialLoadTransactionalFacade = ContentManagerComponent.Instance.PartialLoadTransactionalFacade(ConnectionHandler);
                            var list = partialLoadTransactionalFacade.Where(x => x.HtmlDesginId == oldId);
                            foreach (var partialLoad in list)
                            {
                                partialLoad.HtmlDesginId = newGuid;
                                partialLoadTransactionalFacade.Insert(partialLoad);
                            }
                        }
                    }

                    var congressId = new CongressMenuBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id);
                    if (congressId != null)
                    {
                        var congressMenuTranscationFacade = new CongressMenuFacade(ConnectionHandler);
                        foreach (var congressMenu in congressId)
                        {
                            var newGuid = Guid.NewGuid();
                            congressMenu.Menu.Id    = newGuid;
                            congressMenu.MenuId     = newGuid;
                            congressMenu.CongressId = homa.Id;
                            congressMenuTranscationFacade.Insert(homa.Id, congressMenu.Menu, null);
                        }
                    }
                    var formAssigmentTransactionalFacade = FormGeneratorComponent.Instance.FormAssigmentTransactionalFacade(ConnectionHandler);
                    var congressFormses = new CongressFormsBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id);
                    if (congressFormses != null)
                    {
                        var congressFormsFacade = new CongressFormsFacade(ConnectionHandler);
                        foreach (var congressForms in congressFormses)
                        {
                            var oldId                  = congressForms.FomId;
                            var formAssigments         = formAssigmentTransactionalFacade.Where(x => x.FormStructureId == oldId);
                            var newGuid                = Guid.NewGuid();
                            var newGuidStructureFileId = Guid.NewGuid();
                            congressForms.FormStructure.Id = newGuid;
                            congressForms.FomId            = newGuid;
                            congressForms.CongressId       = homa.Id;
                            if (!string.IsNullOrEmpty(congressForms.FormStructure.StructureFileId))
                            {
                                var file = fileTransactionalFacade.Get(congressForms.FormStructure.StructureFileId);
                                if (file != null)
                                {
                                    file.Id = newGuidStructureFileId;
                                    fileTransactionalFacade.Insert(file);
                                    congressForms.FormStructure.StructureFileId = newGuidStructureFileId.ToString();
                                }
                            }
                            congressFormsFacade.Insert(homa.Id, congressForms.FormStructure);
                            foreach (var formAssigment in formAssigments)
                            {
                                formAssigment.FormStructureId = newGuid;
                                formAssigmentTransactionalFacade.Insert(formAssigment);
                            }
                        }
                    }
                }
                this.ConnectionHandler.CommitTransaction();
                this.FileManagerConnection.CommitTransaction();
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                throw new KnownException(ex.Message, ex);
            }

            return(true);
        }