Ejemplo n.º 1
0
 public override bool Delete(params object[] keys)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         var congressContainerBo = new ContainerBO();
         var obj = congressContainerBo.Get(this.ConnectionHandler, keys);
         if (!congressContainerBo.Delete(this.ConnectionHandler, keys))
         {
             throw new Exception("خطایی در حذف قالب وجود دارد");
         }
         if (!ContentManagerComponent.Instance.ContainerTransactionalFacade(this.ContentManagerConnection).Delete(obj.ContainerId))
         {
             throw new Exception("خطایی در حذف قالب وجود دارد");
         }
         this.ConnectionHandler.CommitTransaction();
         this.ContentManagerConnection.CommitTransaction();
         return(true);
     }
     catch (KnownException knownException)
     {
         this.ConnectionHandler.RollBack();
         this.ContentManagerConnection.RollBack();
         throw new KnownException(knownException.Message, knownException);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         this.ContentManagerConnection.RollBack();
         throw new KnownException(ex.Message, ex);
     }
 }
Ejemplo n.º 2
0
        public override bool Delete(params object[] keys)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);

                var containerBO = new ContainerBO();
                var obj         = containerBO.Get(this.ConnectionHandler, keys);
                var contents    = new ContentBO().Any(ConnectionHandler,
                                                      container => container.ContainerId == obj.Id);
                if (contents)
                {
                    throw new Exception("این قالب  در محتوا استفاده شده است و قابل حذف نیست");
                }
                if (!containerBO.Delete(this.ConnectionHandler, keys))
                {
                    throw new Exception("خطایی در حذف  قالب وجود دارد");
                }

                this.ConnectionHandler.CommitTransaction();

                return(true);
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();

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

                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }