Exemplo n.º 1
0
        /*==================================================================================================================================
        * Private Methods
        *=================================================================================================================================*/
        private questStatus initialize()
        {
            // Initialize
            questStatus status = null;

            try
            {
                _filterFoldersMgr = new FilterFoldersMgr(this.UserSession);
                _filterMgr        = new FilterMgr(this.UserSession);
                _dbFolderMgr      = new DbFolderMgr(this.UserSession);
            }
            catch (System.Exception ex)
            {
                status = new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                       this.GetType().ToString(), MethodInfo.GetCurrentMethod().Name, ex.Message));
                throw new System.Exception(status.Message, ex);
            }
            return(new questStatus(Severity.Success));
        }
Exemplo n.º 2
0
        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Delete(FilterFolderId filterFolderId)
        {
            // Initialize
            questStatus      status = null;
            DbMgrTransaction trans  = null;
            Mgr mgr = new Mgr(this.UserSession);

            try
            {
                // BEGIN TRANSACTION
                status = mgr.BeginTransaction("DeleteFolder_" + filterFolderId.Id.ToString() + "_" + Guid.NewGuid().ToString(), out trans);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Load folder contents
                FolderId            folderId         = new FolderId(filterFolderId.Id);
                List <FilterFolder> filterFolderList = null;
                FilterFoldersMgr    filterFoldersMgr = new FilterFoldersMgr(this.UserSession);
                status = filterFoldersMgr.Load(folderId, out filterFolderList);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // Clear out the folder
                status = clearFolder(trans, filterFolderList);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // Get fitlers in this folder.
                List <Quest.Functional.MasterPricing.Filter> filterList = null;
                FiltersMgr filtersMgr = new FiltersMgr(this.UserSession);
                status = filtersMgr.Read(folderId, out filterList);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // Delete filters in this folder
                foreach (Filter filter in filterList)
                {
                    FilterId filterId = new FilterId(filter.Id);
                    status = _dbFolderMgr.DeleteFilter(filterId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                }

                // Delete the folder.
                status = _filterFoldersMgr.Delete(trans, filterFolderId);
                if (!questStatusDef.IsSuccess(status))
                {
                    mgr.RollbackTransaction(trans);
                    return(status);
                }

                // COMMIT TRANSACTION
                status = mgr.CommitTransaction(trans);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            catch (System.Exception ex)
            {
                if (trans != null)
                {
                    mgr.RollbackTransaction(trans);
                }
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }