Ejemplo n.º 1
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Delete(CMSContent cmsContent, bool deleteLinkedThreads)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContent);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = this.Delete(cmsContent.CMSContentId, deleteLinkedThreads);
                if (num == 0 || num == -1003)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected;
                }
                else if (num < 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                    _Log.WarnFormat("CMSContent {0} was not deleted from the database (ErrorCode: {1})."
                                    , DebugUtility.GetObjectString(cmsContent)
                                    , num);
                }
                else
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.Success;
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSContent {0} was not deleted from the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsContent)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 2
0
        public BusinessObjectActionReport <DataRepositoryActionStatus> Update(IDepartmentModel department)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(department);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                        num = dataStoreContext.wm_Departments_Update(department.DepartmentId, department.ParentDepartmentId, department.Name, department.OfficeId);
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at wm_Departments_Update", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num == 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected;
                    _Log.ErrorFormat("Department {0} was not updated at the database, NoRecordRowAffected"
                                     , DebugUtility.GetObjectString(department));
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("Department {0} was not updated at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(department)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 3
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Delete(CMSThreadRating cmsThreadRating)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsThreadRating);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_ThreadRatings_Delete(cmsThreadRating.CMSUserId, cmsThreadRating.CMSThreadId);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_ThreadRatings_Delete", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num != 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                    _Log.WarnFormat("CMSThreadRating {0} was not deleted from the database (ErrorCode: {1})."
                                    , DebugUtility.GetObjectString(cmsThreadRating), num);
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSThreadRating {0} was not deleted from the database because the validation failed.\nReport: {1}", DebugUtility.GetObjectString(cmsThreadRating), businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 4
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Update(CMSGroup cmsGroup)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsGroup);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                        businessObjectActionReport.Status = (DataRepositoryActionStatus)dataStoreContext.cms_Groups_InsertOrUpdate(cmsGroup.CMSGroupId, cmsGroup.Name, cmsGroup.Description, cmsGroup.CMSGroupType);

                    return(businessObjectActionReport);
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_Groups_InsertOrUpdate", ex);
                    throw new DataStoreException(ex, true);
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSGroup {0} was not updated at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsGroup)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 5
0
        public BusinessObjectActionReport <DataRepositoryActionStatus> Delete(IApplication application)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(application);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                        num = dataStoreContext.wm_Applications_Delete(application.ApplicationId);
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at wm_Applications_Delete", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num == 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                    _Log.WarnFormat("Application {0} was not deleted from the database (ErrorCode: {1})."
                                    , DebugUtility.GetObjectString(application)
                                    , num);
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("Application {0} was not deleted from the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(application)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 6
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Update(CMSContent cmsContent, string[] tags, bool doReindex)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContent);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_Contents_Update(
                            cmsContent.CMSContentId
                            , cmsContent.CMSThreadId
                            , cmsContent.CMSParentContentId
                            , cmsContent.AuthorUserId
                            , cmsContent.CMSContentLevel
                            , cmsContent.Subject
                            , cmsContent.FormattedBody
                            , cmsContent.IsApproved
                            , cmsContent.IsLocked
                            , cmsContent.CMSContentType
                            , cmsContent.CMSContentStatus
                            , cmsContent.CMSExtraInfo
                            , cmsContent.CMSBaseContentId
                            , cmsContent.UrlFriendlyName
                            , tags);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_Contents_Update", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num != 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                    _Log.ErrorFormat("CMSContent {0} was not updated from the database (ErrorCode: {1})."
                                     , DebugUtility.GetObjectString(cmsContent)
                                     , num);
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSContent {0} was not updated at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsContent)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 7
0
        internal BusinessObjectActionReport <RatingDataRepositoryActionStatus> Create(CMSContentRating cmsContentRating, bool getBaseRatingInfo, bool allowSelfRating, out BaseRatingInfo baseRatingInfo)
        {
            baseRatingInfo = null;
            BusinessObjectActionReport <RatingDataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <RatingDataRepositoryActionStatus>(RatingDataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContentRating);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_ContentRatings_InsertOrUpdate(cmsContentRating.Rating, cmsContentRating.CMSContentId, cmsContentRating.CMSUserId, allowSelfRating);
                        if (getBaseRatingInfo)
                        {
                            baseRatingInfo = dataStoreContext.cms_Contents_GetBaseRatingInfo(cmsContentRating.CMSContentId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_ContentRatings_InsertOrUpdate, cms_Contents_GetBaseRatingInfo", ex);
                    throw new DataStoreException(ex, true);
                }
                switch (num)
                {
                case -1:
                    businessObjectActionReport.Status = RatingDataRepositoryActionStatus.SelfRatingNotAllowed;
                    break;

                case 0:
                    cmsContentRating.DateCreatedUtc = DateTime.UtcNow;
                    break;

                default:
                    businessObjectActionReport.Status = RatingDataRepositoryActionStatus.SqlError;
                    _Log.ErrorFormat("CMSContentRating {0} was not inserted at the database (ErrorCode: {1})."
                                     , DebugUtility.GetObjectString(cmsContentRating), num);
                    break;
                }
            }
            else
            {
                businessObjectActionReport.Status = RatingDataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSContentRating {0} was not inserted at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsContentRating)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 8
0
        public BusinessObjectActionReport <DataRepositoryActionStatus> Create(IEmail email)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(email);
            int num;

            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                        num = dataStoreContext.wm_Emails_Insert(
                            email.ApplicationId
                            , email.Subject
                            , email.Body
                            , email.Recipients
                            , email.Sender
                            , email.CreatedByUserId
                            , email.Status
                            , email.Priority
                            , email.EmailType);
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at wm_Emails_Insert", ex);
                    throw new DataStoreException(ex, true);
                }

                if (num > 0)
                {
                    email.EmailId = num;
                }
                else
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                    _Log.ErrorFormat("Email was not inserted at the database (ErrorCode: {0}).", num);
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("Email {0} was not inserted at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(email)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 9
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Create(CMSThread cmsThread)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsThread);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = -1;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_Threads_Insert(
                            cmsThread.CMSSectionId
                            , cmsThread.CMSName
                            , cmsThread.CMSStickyDateUtc
                            , cmsThread.IsLocked
                            , cmsThread.CMSIsSticky
                            , cmsThread.IsApproved
                            , cmsThread.CMSThreadStatus);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_Threads_Insert", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num > 0)
                {
                    cmsThread.CMSThreadId    = num;
                    cmsThread.DateCreatedUtc = DateTime.UtcNow;
                }
                else
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected;
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSThread {0} was not inserted at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsThread)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 10
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Update(CMSSection cmsSection)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsSection);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_Sections_Update(cmsSection.CMSSectionId, cmsSection.CMSParentSectionId, cmsSection.CMSGroupId
                                                                   , cmsSection.Name, cmsSection.Description, cmsSection.CMSSectionType, cmsSection.IsActive, cmsSection.IsModerated);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_Sections_Update", ex);
                    throw new DataStoreException(ex, true);
                }
                // TODO (Roman): make sure we return the right values from db
                if (num != -1003)
                {
                    if (num == 0)
                    {
                        businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected;
                    }
                }
                else
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.NameNotUnique;
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSSection {0} was not updated at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsSection)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 11
0
        public BusinessObjectActionReport <DataRepositoryActionStatus> Create(int applicationId, IOfficeModel office)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(office);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                        num = dataStoreContext.wm_Offices_Insert(applicationId, office);
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at wm_Offices_Insert", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num <= 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                    _Log.ErrorFormat("Office {0} was not inserted at the database (ErrorCode: {1})."
                                     , DebugUtility.GetObjectString(office)
                                     , num);
                }
                else
                {
                    office.OfficeId = num;
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("Office {0} was not inserted at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(office)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 12
0
        public void Test_ObjectDebugString()
        {
            Trace.WriteLine(Configuration.GetGenericHeader());

            DummyDataManager dtm  = new DummyDataManager(Configuration.DummyDataXmlPath);
            DummyUser        user = dtm.GetDummy();

            Trace.WriteLine(DebugUtility.GetObjectString(user));

            DummyClass c = new DummyClass()
            {
                Names = new List <string>()
                {
                    "Huey", "Dewey", "Louie"
                },
                Name = "Duckburg"
            };

            Trace.WriteLine(DebugUtility.GetObjectString(c));

            Trace.WriteLine(Configuration.GetGenericFooter());
        }
Ejemplo n.º 13
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Create(CMSContentUser cmsContentUser)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContentUser);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_ContentUser_InsertOrUpdate(cmsContentUser.CMSContentId, cmsContentUser.CMSReceivingUserId);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_ContentUser_InsertOrUpdate", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num != 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.NoRecordRowAffected;
                }
                else
                {
                    cmsContentUser.DateReceivedUtc = DateTime.UtcNow;
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSContentUser {0} was not updated at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsContentUser), businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Ejemplo n.º 14
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Create(CMSContent cmsContent, string[] tags, string[] contentLevelNodeNames
                                                                                , bool checkUrlFriendlyName
                                                                                , bool createLinkedThread, int?linkedThreadSectionId, bool?isLinkedThreadEnabled, LinkedThreadRelationshipType?linkedThreadRelationshipType)
        {
            // TODO (Roman): checkUrlFriendlyName
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContent);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = -1;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_Contents_Insert(
                            cmsContent.CMSThreadId
                            , cmsContent.CMSParentContentId
                            , cmsContent.AuthorUserId
                            , cmsContent.CMSContentLevel
                            , cmsContent.Subject
                            , cmsContent.FormattedBody
                            , cmsContent.IsApproved
                            , cmsContent.IsLocked
                            , cmsContent.CMSContentType
                            , cmsContent.CMSContentStatus
                            , cmsContent.CMSExtraInfo
                            , cmsContent.UrlFriendlyName
                            , tags
                            , contentLevelNodeNames
                            , createLinkedThread
                            , linkedThreadSectionId
                            , isLinkedThreadEnabled ?? false
                            , linkedThreadRelationshipType);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_Contents_Insert", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num > 0)
                {
                    cmsContent.CMSContentId = num;
                }
                else
                {
                    if (num == -1003)
                    {
                        businessObjectActionReport.Status = DataRepositoryActionStatus.NameNotUnique;
                    }
                    else
                    {
                        businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                        _Log.ErrorFormat("CMSContent {0} was not inserted at the database (ErrorCode: {1})."
                                         , DebugUtility.GetObjectString(cmsContent)
                                         , num);
                    }
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSContent {0} was not inserted at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsContent)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }