예제 #1
0
        public int UpdateFrom3()
        {
            ContentDefinitionManager.AlterPartDefinition("WidgetPart", builder => builder.Attachable());

            return(4);
        }
예제 #2
0
        public int Create()
        {
            // Record Definition
            SchemaBuilder.CreateTable("CategoryPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <string>("CategoryName", column => column.WithLength(255))
                                      .Column <string>("Description", column => column.WithLength(500))
                                      );

            SchemaBuilder.CreateTable("CalendarPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <string>("ShortDescription", column => column.WithLength(500))
                                      .Column("Description", DbType.String, column => column.Unlimited())
                                      .Column <string>("FeedProxyUrl")
                                      );

            SchemaBuilder.CreateTable("EventPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <DateTime>("StartDate")
                                      .Column <DateTime>("EndDate")
                                      .Column("Description", DbType.String, column => column.Unlimited())
                                      .Column <string>("TimeZone")
                                      .Column <bool>("AllDayEvent")
                                      .Column <string>("RecurrenceId")
                                      .Column <string>("RecurrenceRule")
                                      .Column <string>("RecurrenceException")
                                      .Column <bool>("ImportedFromGoogleCalendar")
                                      .Column <string>("ImportUid")
                                      .Column <string>("Url")
                                      .Column <string>("AddressLocation")
                                      .Column <string>("ParentEventIdentifier")
                                      );


            SchemaBuilder.CreateTable("CalendarCategoryJoinRecord",
                                      table => table
                                      .Column <int>("Id", column => column.PrimaryKey().Identity())
                                      .Column <int>("CategoryPartRecord_Id")
                                      .Column <int>("CalendarPartRecord_Id")
                                      );

            SchemaBuilder.CreateTable("EventCategoryJoinRecord",
                                      table => table
                                      .Column <int>("Id", column => column.PrimaryKey().Identity())
                                      .Column <int>("CategoryPartRecord_Id")
                                      .Column <int>("EventPartRecord_Id")
                                      );

            // Part Definition
            ContentDefinitionManager.AlterPartDefinition(
                typeof(AddressPart).Name, cfg => cfg.Attachable());

            ContentDefinitionManager.AlterPartDefinition(
                typeof(EventPart).Name, cfg =>
                cfg.Attachable(false)
                .WithField("EventImage", field => field
                           .OfType("MediaLibraryPickerField")
                           .WithDisplayName("Event Image")
                           .WithSetting("MediaLibraryPickerFieldSettings.Required", "false")
                           .WithSetting("MediaLibraryPickerFieldSettings.Multiple", "false"))
                .WithSetting("MediaLibraryPickerFieldSettings.Hint", "Select a main image for the event: 778px x 250px")
                );

            ContentDefinitionManager.AlterTypeDefinition(
                "Event", cfg => cfg
                .WithPart(typeof(TitlePart).Name)
                .WithPart(typeof(EventPart).Name)
                .WithPart(typeof(CommonPart).Name)
                .WithPart(typeof(IdentityPart).Name)
                .WithPart(typeof(AutoroutePart).Name)
                .WithPart(typeof(ContentPermissionsPart).Name)
                .DisplayedAs("Calendar Event Item")
                .WithPart(typeof(AutoroutePart).Name, builder => builder
                          .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                          .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                          .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: 'events/{Content.Slug}', Description: 'my-projections'}]")
                          .WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
                );


            // Type Definition
            ContentDefinitionManager.AlterTypeDefinition(
                "Calendar", cfg => cfg
                .WithPart(typeof(TitlePart).Name)
                .WithPart(typeof(CalendarPart).Name)
                .WithPart(typeof(CommonPart).Name)
                .WithPart(typeof(IdentityPart).Name)
                .WithPart("AutoroutePart", builder => builder
                          .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                          .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                          .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-projections'}]")
                          .WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
                .WithPart("ContentPermissionsPart")
                .DisplayedAs("Event Calendar")
                );

            ContentDefinitionManager.AlterTypeDefinition(
                "CalendarWidget", cfg => cfg
                .WithPart(typeof(CalendarWidgetPart).Name)
                .WithPart(typeof(CommonPart).Name)
                .WithPart(typeof(IdentityPart).Name)
                .WithPart(typeof(ContentPermissionsPart).Name)
                .WithPart("WidgetPart")
                .WithSetting("Stereotype", "Widget")
                .DisplayedAs("Event Calendar Widget")
                );

            ContentDefinitionManager.AlterTypeDefinition(
                "EventCategory", cfg => cfg
                .WithPart(typeof(CategoryPart).Name)
                .WithPart(typeof(IdentityPart).Name)
                .WithPart(typeof(CommonPart).Name)
                .DisplayedAs("Event Category")
                );

            return(1);
        }
        public int Create()
        {
            SchemaBuilder.CreateTable(typeof(PersonListPartRecord).Name,
                                      table => table
                                      // Since PersonListPartRecord is a ContentPartRecord we have to use this method here. For ContentPartVersionRecord we would
                                      // simply use ContentPartVersionRecord()
                                      .ContentPartRecord()
                                      .Column <string>("Sex")
                                      .Column <int>("MaxCount")
                                      );

            /*
             * We make PersonListPart attachable. This means from the admin UI you'll be able to attach this part to any conent type. This step
             * is not necessary to attach the part to types from migrations like we do it from here.
             * Default is not attachable.
             */
            ContentDefinitionManager.AlterPartDefinition(typeof(PersonListPart).Name,
                                                         builder => builder.Attachable());

            /*
             * We create a new content type. Note that there's only an alter method: this will create the type if it doesn't exist or modify it
             * if it does. Make sure you understand what content types are: http://docs.orchardproject.net/Documentation/Content-types
             * The content type's name is arbitrary, but choose a meaningful one.
             * Notice that we attach parts by specifying their name. For our own parts we use typeof().Name: this is not mandatory but serves
             * great if we change the part's name during development. (The same goes for record name BTW.)
             */
            ContentDefinitionManager.AlterTypeDefinition("PersonList",
                                                         cfg => cfg
                                                                                // Setting display name for the type. BTW the default is the technical name separated on capital letters, so the same here.
                                                         .DisplayedAs("Person List")
                                                         .WithPart("TitlePart") // So the list can have a title; TitlePart is a core part
                                                                                // AutoroutePart so the list can have a friendly URL. That's why this feature depends on Orchard.Autoroute.
                                                         .WithPart("AutoroutePart", builder => builder
                                                                                // These are TypePart settings: settings for a part on a specific type. I.e. AutoroutePart have the following settings
                                                                                // for PersonList. Take a look at AutoroutePart settings on the type editor UI of PersonList to see what these mean.
                                                                   .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                                                                   .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                                                                   // Specifying a custom URL-pattern for PersonList items
                                                                   .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: 'person-lists/{Content.Slug}', Description: 'my-list'}]")
                                                                   .WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
                                                         .WithPart(typeof(PersonListPart).Name)
                                                                      // CommonPart includes e.g. creation date and owner. Take a look at it (search with Ctrl+comma).
                                                                      // Also without it we can't list content types of this type on the admin UI (because the dates stored in it are needed for
                                                                      // ordering).
                                                         .WithPart("CommonPart")
                                                         .Creatable() // This means users will be able to create such items from the admin UI. Default is the opposite.
                                                         );

            /*
             * With the same part we also create a widget. That's why this feature also depends on Orchard.Widgets!
             * Note that widgets should
             * - Have CommonPart attached
             * - Have WidgetPart attached
             * - Have the stereotype "Widget"
             */
            ContentDefinitionManager.AlterTypeDefinition("PersonListWidget",
                                                         cfg => cfg
                                                         .WithPart(typeof(PersonListPart).Name)
                                                         .WithPart("WidgetPart")
                                                         .WithPart("CommonPart")
                                                         .WithSetting("Stereotype", "Widget")
                                                         );


            return(1);

            // Please don't read UpdateFrom1() yet.

            // You read it, didn't you? Stop spoiling.

            // NEXT STATION: Handlers/PersonListPartHandler
        }
예제 #4
0
        public int Create()
        {
            ContentDefinitionManager.AlterPartDefinition("MenuPart", builder => builder
                                                         .Attachable()
                                                         .WithDescription("Provides an easy way to create a ContentMenuItem from the content editor."));

            SchemaBuilder.CreateTable("MenuItemPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <string>("Url", column => column.WithLength(1024))
                                      );

            SchemaBuilder.CreateTable("MenuPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <string>("MenuText")
                                      .Column <string>("MenuPosition")
                                      .Column <int>("MenuId")
                                      );

            ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg
                                                         .WithPart("MenuPart")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .DisplayedAs("Custom Link")
                                                         .WithSetting("Description", "Represents a simple custom link with a text and an url.")
                                                         .WithSetting("Stereotype", "MenuItem") // because we declare a new stereotype, the Shape MenuItem_Edit is needed
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Menu", cfg => cfg
                                                         .WithPart("CommonPart", p => p.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false"))
                                                         .WithPart("TitlePart")
                                                         );

            SchemaBuilder.CreateTable("MenuWidgetPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <int>("StartLevel")
                                      .Column <int>("Levels")
                                      .Column <bool>("Breadcrumb")
                                      .Column <bool>("AddHomePage")
                                      .Column <bool>("AddCurrentPage")
                                      .Column <int>("Menu_id")
                                      );

            ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("WidgetPart")
                                                         .WithPart("MenuWidgetPart")
                                                         .WithSetting("Stereotype", "Widget")
                                                         );

            SchemaBuilder.CreateTable("AdminMenuPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <string>("AdminMenuText")
                                      .Column <string>("AdminMenuPosition")
                                      .Column <bool>("OnAdminMenu")
                                      );

            ContentDefinitionManager.AlterTypeDefinition("HtmlMenuItem", cfg => cfg
                                                         .WithPart("MenuPart")
                                                         .WithPart("BodyPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("IdentityPart")
                                                         .DisplayedAs("Html Menu Item")
                                                         .WithSetting("Description", "Renders some custom HTML in the menu.")
                                                         .WithSetting("BodyPartSettings.FlavorDefault", "html")
                                                         .WithSetting("Stereotype", "MenuItem")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("AdminMenuPart", builder => builder
                                                         .Attachable()
                                                         .WithDescription("Adds a menu item to the Admin menu that links to this content item."));

            SchemaBuilder.CreateTable("ShapeMenuItemPartRecord",
                                      table => table.ContentPartRecord()
                                      .Column <string>("ShapeType")
                                      );

            ContentDefinitionManager.AlterTypeDefinition("ShapeMenuItem",
                                                         cfg => cfg
                                                         .WithPart("ShapeMenuItemPart")
                                                         .WithPart("MenuPart")
                                                         .WithPart("CommonPart")
                                                         .DisplayedAs("Shape Link")
                                                         .WithSetting("Description", "Injects menu items from a Shape")
                                                         .WithSetting("Stereotype", "MenuItem")
                                                         );

            return(4);
        }
예제 #5
0
        public int Create()
        {
            SchemaBuilder.CreateTable("ProductPartRecord", table => table
                                      // The following method will create an "Id" column for us and set it as the primary key for the table
                                      .ContentPartRecord()
                                      // Create a column named "Price" of type "decimal"
                                      .Column <decimal>("Price")
                                      // Create the "Sku" column and specify a maximum length of 50 characters
                                      .Column <string>("Sku", column => column.WithLength(50))
                                      );
            // Return the version that this feature will be after this method completes

            // From Update 1
            ContentDefinitionManager.AlterPartDefinition("ProductPart", part => part
                                                         .Attachable()
                                                         );

            // From Update 2
            ContentDefinitionManager.AlterTypeDefinition("ShoppingCartWidget", type => type
                                                         .WithPart("ShoppingCartWidgetPart")
                                                         .WithPart("WidgetPart")
                                                         .WithSetting("Stereotype", "Widget")
                                                         );

            // From Update 3
            ContentDefinitionManager.AlterTypeDefinition("ShoppingCartWidget", type => type
                                                         .WithPart("CommonPart")
                                                         );

            // From Update 4
            SchemaBuilder.CreateTable("CustomerPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <string>("FirstName", c => c.WithLength(50))
                                      .Column <string>("LastName", c => c.WithLength(50))
                                      .Column <string>("Title", c => c.WithLength(10))
                                      .Column <DateTime>("CreatedUtc")
                                      );

            SchemaBuilder.CreateTable("AddressPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <int>("CustomerId")
                                      .Column <string>("type", c => c.WithLength(50))
                                      );

            ContentDefinitionManager.AlterPartDefinition("CustomerPart", part => part
                                                         .Attachable(false)
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Customer", type => type
                                                         .WithPart("CustomerPart")
                                                         .WithPart("UserPart")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("AddressPart", part => part
                                                         .Attachable(false)
                                                         .WithField("Name", f => f.OfType("TextField"))
                                                         .WithField("AddressLine1", f => f.OfType("TextField"))
                                                         .WithField("AddressLine2", f => f.OfType("TextField"))
                                                         .WithField("Zipcode", f => f.OfType("TextField"))
                                                         .WithField("City", f => f.OfType("TextField"))
                                                         .WithField("Country", f => f.OfType("TextField"))
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Address", type => type
                                                         .WithPart("CommonPart")
                                                         .WithPart("AddressPart")
                                                         );

            return(5);
        }
 public int UpdateFrom1()
 {
     ContentDefinitionManager.AlterPartDefinition("TitlePart", builder => builder
                                                  .WithDescription("Provides a Title for your content item."));
     return(2);
 }
예제 #7
0
        public int Create()
        {
            SchemaBuilder.CreateTable("MediaPartRecord", t => t
                                      .ContentPartRecord()
                                      .Column <string>("MimeType")
                                      .Column <string>("Caption", c => c.Unlimited())
                                      .Column <string>("AlternateText", c => c.Unlimited())
                                      .Column <string>("FolderPath", c => c.WithLength(2048))
                                      .Column <string>("FileName", c => c.WithLength(2048))
                                      );

            //SchemaBuilder.AlterTable("MediaPartRecord", t => t
            //    .CreateIndex("IDX_MediaPartRecord_FolderPath", "FolderPath")
            //);

            ContentDefinitionManager.AlterPartDefinition("MediaPart", part => part
                                                         .Attachable()
                                                         .WithDescription("Turns a content type into a Media. Note: you need to set the stereotype to \"Media\" as well.")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("ImagePart", part => part
                                                         .Attachable()
                                                         .WithDescription("Provides common metadata for an Image Media.")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("VectorImagePart", part => part
                                                         .Attachable()
                                                         .WithDescription("Provides common metadata for a Vector Image Media.")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("VideoPart", part => part
                                                         .Attachable()
                                                         .WithDescription("Provides common metadata for a Video Media.")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("AudioPart", part => part
                                                         .Attachable()
                                                         .WithDescription("Provides common metadata for an Audio Media.")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("DocumentPart", part => part
                                                         .Attachable()
                                                         .WithDescription("Provides common metadata for a Document Media.")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("OEmbedPart", part => part
                                                         .Attachable()
                                                         .WithDescription("Provides common metadata for an OEmbed Media.")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Image", td => td
                                                         .DisplayedAs("Image")
                                                         .WithSetting("Stereotype", "Media")
                                                         .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("MediaPart")
                                                         .WithPart("ImagePart")
                                                         .WithPart("TitlePart")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("VectorImage", td => td
                                                         .DisplayedAs("Vector Image")
                                                         .WithSetting("Stereotype", "Media")
                                                         .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("MediaPart")
                                                         .WithPart("VectorImagePart")
                                                         .WithPart("TitlePart")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Video", td => td
                                                         .DisplayedAs("Video")
                                                         .WithSetting("Stereotype", "Media")
                                                         .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("MediaPart")
                                                         .WithPart("VideoPart")
                                                         .WithPart("TitlePart")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Audio", td => td
                                                         .DisplayedAs("Audio")
                                                         .WithSetting("Stereotype", "Media")
                                                         .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("MediaPart")
                                                         .WithPart("AudioPart")
                                                         .WithPart("TitlePart")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Document", td => td
                                                         .DisplayedAs("Document")
                                                         .WithSetting("Stereotype", "Media")
                                                         .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("MediaPart")
                                                         .WithPart("DocumentPart")
                                                         .WithPart("TitlePart")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td
                                                         .DisplayedAs("External Media")
                                                         .WithSetting("Stereotype", "Media")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("MediaPart")
                                                         .WithPart("OEmbedPart")
                                                         .WithPart("TitlePart")
                                                         );

            return(7);
        }
예제 #8
0
        public int UpdateFrom2()
        {
            ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg
                                                         .WithPart("MenuPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("IdentityPart")
                                                         .DisplayedAs("Custom Link")
                                                         .WithSetting("Description", "Represents a simple custom link with a text and an url.")
                                                         .WithSetting("Stereotype", "MenuItem") // because we declare a new stereotype, the Shape MenuItem_Edit is needed
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Menu", cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("TitlePart")
                                                         );

            SchemaBuilder.CreateTable("MenuWidgetPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <int>("StartLevel")
                                      .Column <int>("Levels")
                                      .Column <bool>("Breadcrumb")
                                      .Column <bool>("AddHomePage")
                                      .Column <bool>("AddCurrentPage")
                                      .Column <int>("Menu_id")
                                      );

            ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("WidgetPart")
                                                         .WithPart("MenuWidgetPart")
                                                         .WithSetting("Stereotype", "Widget")
                                                         );

            SchemaBuilder
            .AlterTable("MenuPartRecord", table => table.DropColumn("OnMainMenu"))
            .AlterTable("MenuPartRecord", table => table.AddColumn <int>("MenuId"))
            ;

            ContentDefinitionManager.AlterTypeDefinition("HtmlMenuItem", cfg => cfg
                                                         .WithPart("MenuPart")
                                                         .WithPart("BodyPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("IdentityPart")
                                                         .DisplayedAs("Html Menu Item")
                                                         .WithSetting("Description", "Renders some custom HTML in the menu.")
                                                         .WithSetting("BodyPartSettings.FlavorDefault", "html")
                                                         .WithSetting("Stereotype", "MenuItem")
                                                         );

            ContentDefinitionManager.AlterPartDefinition("NavigationPart", builder => builder.Attachable());

            SchemaBuilder.CreateTable("ContentMenuItemPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <int>("ContentMenuItemRecord_id")
                                      );

            ContentDefinitionManager.AlterTypeDefinition("ContentMenuItem", cfg => cfg
                                                         .WithPart("MenuPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("ContentMenuItemPart")
                                                         .DisplayedAs("Content Menu Item")
                                                         .WithSetting("Description", "Adds a Content Item to the menu.")
                                                         .WithSetting("Stereotype", "MenuItem")
                                                         );

            // create a Main Menu
            var mainMenu = _menuService.Create("Main Menu");

            // assign the Main Menu to all current menu items
            foreach (var menuItem in _menuService.Get())
            {
                // if they don't have a position or a text, then they are not displayed
                if (string.IsNullOrWhiteSpace(menuItem.MenuPosition) || string.IsNullOrEmpty(menuItem.MenuText))
                {
                    continue;
                }
                menuItem.Menu = mainMenu.ContentItem;
            }

            // at this point a widget should still be created to display the navigation

            return(3);
        }
예제 #9
0
        private void CreateBusinessUnitsAndTeam()
        {
            // Create TeamPartRecord table
            SchemaBuilder.CreateTable("TeamPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <string>("Name", c => c.WithLength(50))
                                      .Column <string>("Description", c => c.WithLength(200))
                                      .Column <int>("BusinessUnitPartRecord_Id", c => c.Nullable())
                                      );

            // Create TeamMemberRecord table
            SchemaBuilder.CreateTable("TeamMemberPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <int>("TeamPartRecord_Id", c => c.Nullable())
                                      .Column <int>("UserPartRecord_Id", c => c.Nullable())
                                      );

            // Create BusinessUnitMemberRecord table
            SchemaBuilder.CreateTable("BusinessUnitMemberPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <int>("BusinessUnitPartRecord_Id", c => c.Nullable())
                                      .Column <int>("UserPartRecord_Id", c => c.Nullable())
                                      );

            // Create BusinessUnitPartRecord table
            SchemaBuilder.CreateTable("BusinessUnitPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <string>("Name", c => c.WithLength(50))
                                      .Column <string>("Description", c => c.WithLength(200))
                                      .Column <int>("Parent_Id", c => c.Nullable())
                                      );

            ContentDefinitionManager.AlterPartDefinition("TeamMemberPart",
                                                         builder => builder.Attachable());

            ContentDefinitionManager.AlterPartDefinition("BusinessUnitMemberPart",
                                                         builder => builder.Attachable());

            ContentDefinitionManager.AlterPartDefinition("EntityAccessPart",
                                                         builder => builder.Attachable());

            ContentDefinitionManager.AlterTypeDefinition("TeamMember",
                                                         cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("TeamMemberPart")
                                                         .DisplayedAs("TeamMember")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("BusinessUnitMember",
                                                         cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("BusinessUnitMemberPart")
                                                         .DisplayedAs("Business Unit Member")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Team",
                                                         cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("TeamPart")
                                                         .DisplayedAs("Team")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("BusinessUnit",
                                                         cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("BusinessUnitPart")
                                                         .DisplayedAs("Business Unit")
                                                         );
        }
예제 #10
0
        private void CreateTicketAndCommentsAndRelatedData()
        {
            // CRMCommentPartRecord
            SchemaBuilder.CreateTable("CRMCommentPartRecord",
                                      table => table
                                      .ContentPartRecord()
                                      .Column <int>("User_Id")
                                      .Column <int>("CRMCommentsPartRecord_Id")
                                      .Column <DateTime>("CommentDateUtc")
                                      .Column <string>("CommentText", column => column.Unlimited())
                                      .Column <bool>("IsEmail", column => column.NotNull().WithDefault(false))
                                      .Column <bool>("IsHtml", column => column.NotNull().WithDefault(false))
                                      .Column <string>("CC", column => column.Nullable().WithLength(200))
                                      .Column <string>("Subject", column => column.Nullable().WithLength(200))
                                      .Column <string>("BCC", column => column.Nullable().WithLength(200))
                                      .Column <string>("MTo", column => column.Nullable().WithLength(200))
                                      .Column <string>("MFrom", column => column.Nullable().WithLength(200))
                                      );

            // CRMCommentPartRecord main index
            SchemaBuilder.AlterTable("CRMCommentPartRecord", table => table.CreateIndex(
                                         "CRMCommentPartRecord_MainIndex",
                                         new string[]
            {
                "User_Id",
                "CRMCommentsPartRecord_Id",
                "CommentDateUtc"
            }));

            // CRMCommentsPartRecord
            SchemaBuilder.CreateTable("CRMCommentsPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <bool>("ThreadedComments")
                                      .Column <int>("CommentsCount")
                                      );

            ContentDefinitionManager.AlterPartDefinition("CRMCommentPart", builder => builder.Attachable());
            ContentDefinitionManager.AlterPartDefinition("CRMCommentsPart", builder => builder.Attachable());

            // Create ServiceRecord table
            SchemaBuilder.CreateTable("ServiceRecord", table => table
                                      .Column <int>("Id", c => c.Identity().PrimaryKey())
                                      .Column <string>("Name", c => c.WithLength(50))
                                      .Column <string>("Description", c => c.WithLength(500))
                                      .Column <bool>("Deleted", c => c.WithDefault(false).NotNull())
                                      );

            // Create Priority table
            SchemaBuilder.CreateTable("PriorityRecord", table => table
                                      .Column <int>("Id", c => c.Identity().PrimaryKey())
                                      .Column <string>("Name", c => c.WithLength(50).Nullable())
                                      .Column <bool>("IsHardCode", c => c.WithDefault(false))
                                      .Column <int>("OrderId", c => c.Nullable())
                                      );

            // Create TicketType table
            SchemaBuilder.CreateTable("TicketTypeRecord", table => table
                                      .Column <int>("Id", c => c.Identity().PrimaryKey())
                                      .Column <string>("Name", c => c.WithLength(50).Nullable())
                                      .Column <bool>("IsHardCode", c => c.WithDefault(false))
                                      .Column <int>("OrderId", c => c.Nullable())
                                      .Column <bool>("Deleted", c => c.WithDefault(false).NotNull())
                                      );

            // Create Status table
            SchemaBuilder.CreateTable("StatusRecord", table => table
                                      .Column <int>("Id", c => c.Identity().PrimaryKey())
                                      .Column <string>("Name", c => c.WithLength(50).Nullable())
                                      .Column <int>("StatusTypeId", c => c.Nullable())
                                      .Column <bool>("IsHardCode", c => c.WithDefault(false))
                                      .Column <int>("OrderId", c => c.Nullable())
                                      .Column <bool>("Deleted", c => c.WithDefault(false).NotNull())
                                      );

            SchemaBuilder.CreateTable("TicketIdentityRecord", table =>
                                      table.Column <int>("Id", c => c.Identity().PrimaryKey())
                                      .Column <string>("TempData", c => c.WithLength(100))
                                      );

            // Create TicketPartRecord table
            SchemaBuilder.CreateTable("TicketPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <string>("Title", c => c.WithLength(100))
                                      .Column <int>("RelatedContentItem_Id", c => c.Nullable())
                                      .Column <int>("Parent_Id", c => c.Nullable())
                                      .Column <int>("SourceId", c => c.Nullable())
                                      .Column <string>("SourceData", c => c.Nullable().WithLength(100))
                                      .Column <int>("RequestingUser_Id", c => c.Nullable())
                                      .Column <int>("TicketType_Id", c => c.Nullable())
                                      .Column <int>("PriorityRecord_Id", c => c.Nullable())
                                      .Column <int>("Identity_Id", c => c.Nullable())
                                      .Column <DateTime>("DueDate", c => c.Nullable())
                                      .Column <int>("Service_Id", c => c.Nullable())
                                      .Column <int>("StatusRecord_Id", c => c.Nullable())
                                      .Column <string>("Description", c => c.Unlimited())
                                      );

            // Identity index
            SchemaBuilder.AlterTable("TicketPartRecord", table => table.CreateIndex(
                                         "Ticket_IdentityIndex",
                                         new string[] { "Identity_Id" }));

            // RelatedContentItem index
            SchemaBuilder.AlterTable("TicketPartRecord", table => table.CreateIndex(
                                         "Ticket_RelatedContentItem_IdIndex",
                                         new string[] { "RelatedContentItem_Id" }));

            // Parent index
            SchemaBuilder.AlterTable("TicketPartRecord", table => table.CreateIndex(
                                         "Ticket_ParentIndex",
                                         new string[] { "Parent_Id" }));

            // main index
            SchemaBuilder.AlterTable("TicketPartRecord", table => table.CreateIndex(
                                         "Ticket_MainIndex",
                                         new string[]
            {
                "StatusRecord_Id",
                "DueDate",
                "TicketType_Id",
                "PriorityRecord_Id",
                "Service_Id",
                "Parent_Id",
                "RequestingUser_Id",
                "RelatedContentItem_Id",
                "Identity_Id"
            }));

            // ContentItemVersionRecord main index
            SchemaBuilder coreSchemaBuilder = new SchemaBuilder(this.SchemaBuilder.Interpreter, "Orchard_Framework_");

            coreSchemaBuilder.AlterTable(
                "ContentItemVersionRecord",
                table => table
                .CreateIndex("ContentItemVersionRecord_ContentItemRecord_id",
                             "ContentItemRecord_id"));

            // Create ContentItemPermissionDetailRecord table
            SchemaBuilder.CreateTable("ContentItemPermissionDetailRecord", table => table
                                      .Column <int>("Id", c => c.Identity().PrimaryKey())
                                      .Column <int>("Team_Id", c => c.Nullable())
                                      .Column <int>("BusinessUnit_Id", c => c.Nullable())
                                      .Column <int>("User_Id", c => c.Nullable())
                                      .Column <int>("ContentItemPermissionPartRecord_Id", c => c.Nullable())
                                      .Column <int>("Parent_Id", c => c.Nullable())
                                      .Column <byte>("AccessType", c => c.Nullable())
                                      );

            // ContentItemPermissionDetailRecord main index
            SchemaBuilder.AlterTable("ContentItemPermissionDetailRecord", table => table.CreateIndex(
                                         "ContentItemPermissionDetailRecord_MainIndex",
                                         new string[]
            {
                "BusinessUnit_Id",
                "User_Id",
                "Team_Id",
                "ContentItemPermissionPartRecord_Id",
                "AccessType",
                "Parent_Id"
            }));


            // Create ContentItemPermissionPartRecord table
            SchemaBuilder.CreateTable("ContentItemPermissionPartRecord", table => table
                                      .ContentPartRecord()
                                      .Column <int>("Ticket_Id", c => c.Nullable())
                                      .Column <bool>("HasOwner", c => c.WithDefault(false))
                                      );

            // ContentItemPermissionPartRecord main index
            SchemaBuilder.AlterTable("ContentItemPermissionPartRecord", table => table.CreateIndex(
                                         "ContentItemPermissionPartRecord_MainIndex",
                                         new string[]
            {
                "Ticket_Id",
                "HasOwner"
            }));

            ContentDefinitionManager.AlterPartDefinition("ContentItemPermissionPart",
                                                         builder => builder.Attachable());

            ContentDefinitionManager.AlterPartDefinition("TicketPart",
                                                         builder => builder.Attachable());

            ContentDefinitionManager.AlterTypeDefinition("Ticket",
                                                         cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("TicketPart")
                                                         .WithPart("ContentItemPermissionPart")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CRMCommentsPart")
                                                         .WithPart("FileUploadPart")
                                                         .DisplayedAs("Ticket"));

            ContentDefinitionManager.AlterTypeDefinition("CRMComment",
                                                         cfg => cfg
                                                         .WithPart("IdentityPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("CRMCommentPart")
                                                         .DisplayedAs("CRMComment"));
        }
예제 #11
0
        public int Create()
        {
            this.CreateFileUploadRecordAndPart();
            this.CreateBusinessUnitsAndTeam();
            this.CreateTicketAndCommentsAndRelatedData();
            this.CreateMenuRecordsAndParts();
            this.CreateActivityHistory();
            this.CreateProjectAndAttachToProjectTypes();

            ContentDefinitionManager.AlterPartDefinition("ProjectionWithDynamicSortPart", builder => builder.Attachable());
            ContentDefinitionManager.AlterPartDefinition("DashboardPart", builder => builder.Attachable());
            ContentDefinitionManager.AlterPartDefinition("TicketsForContentItemPart", builder => builder.Attachable());

            ContentDefinitionManager.AlterTypeDefinition("TicketsDashboardWidget",
                                                         cfg => cfg
                                                         .WithPart("WidgetPart")
                                                         .WithPart("CommonPart")
                                                         .WithPart("IdentityPart")
                                                         .WithPart("DashboardPart")
                                                         .WithPart("ActivityStreamPart")
                                                         .WithSetting("Stereotype", "Widget")
                                                         .DisplayedAs("Tickets Dashboard")
                                                         );

            ContentDefinitionManager.AlterTypeDefinition("Dashboard",
                                                         cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("TitlePart")
                                                         .WithPart("AutoroutePart")
                                                         .WithPart("MenuPart")
                                                         .WithPart("DashboardPart")
                                                         .WithPart("ActivityStreamPart")
                                                         .WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "5"))
                                                         .Creatable()
                                                         .DisplayedAs("Tickets Dashboard"));


            ContentDefinitionManager.AlterTypeDefinition("ProjectionWithDynamicSortPage",
                                                         cfg => cfg
                                                         .WithPart("CommonPart")
                                                         .WithPart("TitlePart")
                                                         .WithPart("AutoroutePart", builder => builder
                                                                   .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                                                                   .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                                                                   .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-projections'}]")
                                                                   .WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
                                                         .WithPart("MenuPart")
                                                         .WithPart("ProjectionWithDynamicSortPart")
                                                         .WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "5"))
                                                         .DisplayedAs("Projection With DynamicSort")
                                                         );

            SchemaBuilder.CreateTable("EmailTemplateRecord", table => table
                                      .Column <int>("Id", c => c.PrimaryKey().Identity())
                                      .Column <string>("Name", c => c.WithLength(100).NotNull())
                                      .Column <string>("Subject", c => c.WithLength(100).NotNull())
                                      .Column <int>("TypeId", c => c.NotNull())
                                      .Column <string>("Body", c => c.NotNull().WithLength(2000)));

            this.crmSetup.Value.AddBasicData();
            return(5);
        }
예제 #12
0
        public int UpgradeFrom1()
        {
            ContentDefinitionManager.AlterPartDefinition("ContentTreeSettingsPart", part => part.Attachable());

            return(2);
        }
예제 #13
0
 public int UpdateFrom1()
 {
     ContentDefinitionManager.AlterPartDefinition("AutoroutePart", part => part
                                                  .WithDescription("将高级URL配置选项添加到内容类型中,以完全自定义内容项的URL模式"));
     return(2);
 }