Beispiel #1
0
        string IUpgradeable.UpgradeModule(string Version)
        {
            var message = string.Format("R7.News upgradeable actions for version {0}.)", Version);

            switch (Version)
            {
            case "01.00.00":

                var contentTypeController = new ContentTypeController();

                if (!contentTypeController.GetContentTypes().Any(ct => ct.ContentType == Const.ContentType))
                {
                    // register new content type, return value is new contentTypeId
                    contentTypeController.AddContentType(new ContentType(Const.ContentType));
                    message += "Added content type for workflow." + Environment.NewLine;

                    /*
                     * var workflowActionManager = new WorkflowActionManager ();
                     *
                     * // register 5 workflow actions
                     * workflowActionManager.RegisterWorkflowAction (new WorkflowAction {
                     *  ContentTypeId = contentTypeId,
                     *  ActionType = WorkflowActionTypes.StartWorkflow.ToString (),
                     *  ActionSource = typeof (WorkflowStartAction).AssemblyQualifiedName
                     * });
                     *
                     * workflowActionManager.RegisterWorkflowAction (new WorkflowAction {
                     *  ContentTypeId = contentTypeId,
                     *  ActionType = WorkflowActionTypes.CompleteWorkflow.ToString (),
                     *  ActionSource = typeof (WorkflowCompleteAction).AssemblyQualifiedName
                     * });
                     *
                     * workflowActionManager.RegisterWorkflowAction (new WorkflowAction {
                     *  ContentTypeId = contentTypeId,
                     *  ActionType = WorkflowActionTypes.DiscardWorkflow.ToString (),
                     *  ActionSource = typeof (WorkflowDiscardAction).AssemblyQualifiedName
                     * });
                     *
                     * workflowActionManager.RegisterWorkflowAction (new WorkflowAction {
                     *  ContentTypeId = contentTypeId,
                     *  ActionType = WorkflowActionTypes.DiscardState.ToString (),
                     *  ActionSource = typeof (StateDiscardAction).AssemblyQualifiedName
                     * });
                     *
                     * workflowActionManager.RegisterWorkflowAction (new WorkflowAction {
                     *  ContentTypeId = contentTypeId,
                     *  ActionType = WorkflowActionTypes.CompleteState.ToString (),
                     *  ActionSource = typeof (StateCompleteAction).AssemblyQualifiedName
                     * });
                     *
                     * message += "Added workflow actions. " + Environment.NewLine;
                     *
                     */
                }
                break;
            }

            return(message);
        }
        private int CreateContentType()
        {
            ContentTypeController ctc         = new ContentTypeController();
            ContentType           contentType = new ContentType();

            contentType.ContentType = Consts.ContentTypeName;
            return(ctc.AddContentType(contentType));
        }
Beispiel #3
0
        /// <summary>
        /// Creates a Content Type (for taxonomy) in the data store.
        /// </summary>
        /// <returns>The primary key value of the new ContentType.</returns>
        private static int CreateContentType(string ContentTypeName)
        {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType {
                ContentType = ContentTypeName
            };

            return(typeController.AddContentType(objContentType));
        }
Beispiel #4
0
        /// <summary>
        ///     Creates a Content Type (for taxonomy) in the data store.
        /// </summary>
        /// <returns>The primary key value of the new ContentType.</returns>
        private static int CreateContentType(string contentTypeConstant)
        {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType {
                ContentType = contentTypeConstant
            };

            return(typeController.AddContentType(objContentType));
        }
Beispiel #5
0
        private static int CreateContentTypeCategory()
        {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType {
                ContentType = Constants.ContentTypeNameCategory
            };

            return(typeController.AddContentType(objContentType));
        }
        public void ContentTypeController_AddContentType_Throws_On_Null_ContentType()
        {
            //Arrange
            var mockDataService       = new Mock <IDataService>();
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws <ArgumentNullException>(() => contentTypeController.AddContentType(null));
        }
        /// <summary>
        /// Creates a unique content type for this module
        /// </summary>
        /// <returns></returns>
        private static int CreateContentType()
        {
            var typeController = new ContentTypeController();
            var objContentType = new ContentType {
                ContentType = MODULE_TYPE_NAME
            };

            return(typeController.AddContentType(objContentType));
        }
        public void ContentTypeController_AddContentType_Calls_DataService_On_Valid_Arguments()
        {
            //Arrange
            var mockDataService       = new Mock <IDataService>();
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            ContentType contentType = ContentTestHelper.CreateValidContentType();

            //Act
            int contentTypeId = contentTypeController.AddContentType(contentType);

            //Assert
            mockDataService.Verify(ds => ds.AddContentType(contentType));
        }
        public void ContentTypeController_AddContentType_Returns_ValidId_On_Valid_ContentType()
        {
            //Arrange
            var mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.AddContentType(It.IsAny <ContentType>())).Returns(Constants.CONTENTTYPE_AddContentTypeId);
            var contentTypeController = new ContentTypeController(mockDataService.Object);

            var contentType = ContentTestHelper.CreateValidContentType();

            //Act
            int contentTypeId = contentTypeController.AddContentType(contentType);

            //Assert
            Assert.AreEqual(Constants.CONTENTTYPE_AddContentTypeId, contentTypeId);
        }
        private int getContentType()
        {
            ContentTypeController ctCtrl = new ContentTypeController();
            var ct = ctCtrl.GetContentTypes().FirstOrDefault(c => c.ContentType == DATAACCESSITEM_CONTENTTYPE);

            if (ct != null)
            {
                return(ct.ContentTypeId);
            }
            else
            {
                // Add our custom content type
                return(ctCtrl.AddContentType(new ContentType {
                    ContentType = DATAACCESSITEM_CONTENTTYPE, KeyID = 0
                }));
            }
        }
        private static void CreateContentItem(DesktopModuleInfo desktopModule)
        {
            IContentTypeController typeController = new ContentTypeController();
            ContentType            contentType    = ContentType.DesktopModule;

            if (contentType == null)
            {
                contentType = new ContentType {
                    ContentType = "DesktopModule"
                };
                contentType.ContentTypeId = typeController.AddContentType(contentType);
            }

            IContentController contentController = Util.GetContentController();

            desktopModule.Content       = desktopModule.FriendlyName;
            desktopModule.Indexed       = false;
            desktopModule.ContentTypeId = contentType.ContentTypeId;
            desktopModule.ContentItemId = contentController.AddContentItem(desktopModule);
        }
        private static void CreateContentItem(DesktopModuleInfo desktopModule)
        {
            IContentTypeController typeController = new ContentTypeController();
            ContentType            contentType    = (from t in typeController.GetContentTypes()
                                                     where t.ContentType == "DesktopModule"
                                                     select t).SingleOrDefault();

            if (contentType == null)
            {
                contentType = new ContentType {
                    ContentType = "DesktopModule"
                };
                contentType.ContentTypeId = typeController.AddContentType(contentType);
            }

            IContentController contentController = Util.GetContentController();

            desktopModule.Content       = desktopModule.FriendlyName;
            desktopModule.Indexed       = false;
            desktopModule.ContentTypeId = contentType.ContentTypeId;
            desktopModule.ContentItemId = contentController.AddContentItem(desktopModule);
        }
Beispiel #13
0
        private static ContentItem CreateDnnContentItem()
        {
            var typeController  = new ContentTypeController();
            var contentTypeFile = (from t in typeController.GetContentTypes() where t.ContentType == "File" select t).SingleOrDefault();

            if (contentTypeFile == null)
            {
                contentTypeFile = new ContentType {
                    ContentType = "File"
                };
                contentTypeFile.ContentTypeId = typeController.AddContentType(contentTypeFile);
            }

            var dnnContentItem = new ContentItem
            {
                ContentTypeId = contentTypeFile.ContentTypeId,
                Indexed       = false,
            };

            dnnContentItem.ContentItemId = Util.GetContentController().AddContentItem(dnnContentItem);

            return(dnnContentItem);
        }
Beispiel #14
0
        /// <summary>
        /// UpgradeModule implements the IUpgradeable Interface
        /// </summary>
        /// <param name="Version">The current version of the module</param>
        public string UpgradeModule(string Version)
        {
            WorkflowActionManager _workflowActionManager = new WorkflowActionManager();

            var message = String.Format(" Workflow Module -  Workflow Upgradeable actions for version {0}.)", Version);

            switch (Version)
            {
            case "00.00.03":


                // Create content type for module
                var typeController = new ContentTypeController();
                var objContentType = new ContentType {
                    ContentType = "WorkflowModule_Item"
                };
                int contentTypeId = typeController.AddContentType(objContentType);

                message += "Added content type for workflow module. " + Environment.NewLine;

                // Register 5 workflow actions: StartWorkflow, CompleteWorkflow, DiscardWorkflow, DiscardState, CompleteState
                _workflowActionManager.RegisterWorkflowAction(new WorkflowAction
                {
                    ContentTypeId = contentTypeId,
                    ActionType    = WorkflowActionTypes.StartWorkflow.ToString(),
                    ActionSource  = typeof(WorkflowStartAction).AssemblyQualifiedName
                });

                _workflowActionManager.RegisterWorkflowAction(new WorkflowAction
                {
                    ContentTypeId = contentTypeId,
                    ActionType    = WorkflowActionTypes.CompleteWorkflow.ToString(),
                    ActionSource  = typeof(WorkflowCompleteAction).AssemblyQualifiedName
                });

                _workflowActionManager.RegisterWorkflowAction(new WorkflowAction
                {
                    ContentTypeId = contentTypeId,
                    ActionType    = WorkflowActionTypes.DiscardWorkflow.ToString(),
                    ActionSource  = typeof(WorkflowDiscardAction).AssemblyQualifiedName
                });

                _workflowActionManager.RegisterWorkflowAction(new WorkflowAction
                {
                    ContentTypeId = contentTypeId,
                    ActionType    = WorkflowActionTypes.DiscardState.ToString(),
                    ActionSource  = typeof(StateDiscardAction).AssemblyQualifiedName
                });

                _workflowActionManager.RegisterWorkflowAction(new WorkflowAction
                {
                    ContentTypeId = contentTypeId,
                    ActionType    = WorkflowActionTypes.CompleteState.ToString(),
                    ActionSource  = typeof(StateCompleteAction).AssemblyQualifiedName
                });

                message += "Added workflow actions. " + Environment.NewLine;
                break;
            }

            return(message);
        }