Example #1
0
 public override bool Delete(params object[] keys)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         var slideItemBo = new SlideItemBO();
         if (!slideItemBo.Delete(this.ConnectionHandler, this.FileManagerConnection, keys))
         {
             throw new Exception("خطایی در حذف اسلاید  آیتم وجود دارد");
         }
         this.ConnectionHandler.CommitTransaction();
         this.FileManagerConnection.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         this.FileManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         this.FileManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Example #2
0
        public bool Update(SlideItem slideItem, HttpPostedFileBase image)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.CommonConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);

                if (image != null)
                {
                    var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection);
                    var lanuageContent          = new SlideItemBO().GetLanuageContent(base.ConnectionHandler,
                                                                                      slideItem.CurrentUICultureName, slideItem.Id);
                    if (!string.IsNullOrEmpty(lanuageContent.ImageId))
                    {
                        fileTransactionalFacade
                        .Update(image, lanuageContent.ImageId.ToGuid());
                    }
                    else
                    {
                        slideItem.ImageId =
                            fileTransactionalFacade
                            .Insert(image, new File()
                        {
                            MaxSize = 300
                        }).ToString();
                    }
                }

                if (!new SlideItemBO().Update(this.ConnectionHandler, slideItem))
                {
                    throw new Exception("خطایی در ذخیره اسلاید  آیتم وجود دارد");
                }
                this.ConnectionHandler.CommitTransaction();
                this.CommonConnection.CommitTransaction();
                this.FileManagerConnection.CommitTransaction();
                return(true);
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.CommonConnection.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.CommonConnection.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
Example #3
0
        public override bool Delete(params object[] keys)
        {
            try
            {
                ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                SlideBO     slideBo         = new SlideBO();
                Slide       obj             = slideBo.Get(ConnectionHandler, keys);
                SlideItemBO slideItemFacade = new SlideItemBO();

                List <SlideItem> list = new SlideItemBO().Where(ConnectionHandler,
                                                                supporter => supporter.SlideId == obj.Id);
                foreach (SlideItem slideItem in list)
                {
                    if (
                        !slideItemFacade.Delete(ConnectionHandler, FileManagerConnection, slideItem.Id))
                    {
                        throw new Exception("خطایی در ");
                    }
                }

                if (!slideBo.Delete(ConnectionHandler, keys))
                {
                    throw new Exception("خطایی در حذف اسلاید وجود دارد");
                }

                ConnectionHandler.CommitTransaction();
                FileManagerConnection.CommitTransaction();
                return(true);
            }

            catch (KnownException ex)
            {
                ConnectionHandler.RollBack();
                FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                ConnectionHandler.RollBack();
                FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }