예제 #1
0
        public static void RemoveAllData(TicketDeskContext context)
        {
            context.TicketEventNotifications.RemoveRange(context.TicketEventNotifications);
            context.UserSettings.RemoveRange(context.UserSettings);
            context.TicketAttachments.RemoveRange(context.TicketAttachments);
            context.TicketTags.RemoveRange(context.TicketTags);
            context.TicketEvents.RemoveRange(context.TicketEvents);
            context.Tickets.RemoveRange(context.Tickets);

            context.TicketDeskSettings = new ApplicationSetting();

            context.SaveChanges();
        }
예제 #2
0
        public static void SetupDemoData(TicketDeskContext context)
        {
            RemoveAllData(context);
            context.SaveChanges();



            context.Tickets.AddOrUpdate(t => t.Title,
                                        new Ticket
            {
                Title              = "Test Unassigned Ticket",
                AffectsCustomer    = false,
                Category           = "Hardware",
                CreatedBy          = "17f78f38-fa68-445f-90de-38896140db28",
                TicketStatus       = TicketStatus.Active,
                CurrentStatusDate  = DateTimeOffset.Now,
                CurrentStatusSetBy = "72bdddfb-805a-4883-94b9-aa494f5f52dc",
                Details            =
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit fusce vel sapien elit in malesuada semper mi, id sollicitudin urna fermentum ut fusce varius nisl ac ipsum gravida vel pretium tellus.",
                IsHtml         = false,
                LastUpdateBy   = "72bdddfb-805a-4883-94b9-aa494f5f52dc",
                LastUpdateDate = DateTimeOffset.Now,
                Owner          = "17f78f38-fa68-445f-90de-38896140db28",
                Priority       = "Low",
                TagList        = "test,moretest",
                TicketType     = "Problem",
                TicketEvents   = new[] { TicketEvent.CreateActivityEvent("17f78f38-fa68-445f-90de-38896140db28", TicketActivity.Create, null, null, null) }
            });

            var titles = new[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1", "I1", "J1", "K1", "L1", "M1", "N1", "O1", "P1", "Q1", "R1" };
            var n      = 0;

            foreach (var p in titles)
            {
                n--;
                string cc;
                string tt;
                string oo;
                if (Math.Abs(n) % 2 == 0)
                {
                    tt = "Question";
                    cc = "Hardware";
                    oo = "64165817-9cb5-472f-8bfb-6a35ca54be6a";
                }
                else
                {
                    tt = "Problem";
                    cc = "Software";
                    oo = "17f78f38-fa68-445f-90de-38896140db28";
                }


                var now = DateTimeOffset.Now.AddDays(n);
                context.Tickets.AddOrUpdate(t => t.Title,
                                            new Ticket
                {
                    Title              = "Test Ticket " + p,
                    AffectsCustomer    = false,
                    AssignedTo         = "64165817-9cb5-472f-8bfb-6a35ca54be6a",
                    Category           = cc,
                    CreatedBy          = oo,
                    TicketStatus       = (p == "L") ? TicketStatus.Closed : TicketStatus.Active,
                    CurrentStatusDate  = now,
                    CurrentStatusSetBy = "72bdddfb-805a-4883-94b9-aa494f5f52dc",
                    Details            =
                        "Lorem ipsum dolor sit amet, consectetur adipiscing elit fusce vel sapien elit in malesuada semper mi, id sollicitudin urna fermentum ut fusce varius nisl ac ipsum gravida vel pretium tellus.",
                    IsHtml         = false,
                    LastUpdateBy   = "72bdddfb-805a-4883-94b9-aa494f5f52dc",
                    LastUpdateDate = now.AddHours(2),
                    Owner          = oo,
                    Priority       = "Low",
                    TagList        = "test,moretest",
                    TicketType     = tt,
                    TicketEvents   = new[] { TicketEvent.CreateActivityEvent(oo, TicketActivity.Create, null, null, null) }
                });
            }
            context.SaveChanges();
        }
예제 #3
0
        protected override void Seed(TicketDesk.Domain.TicketDeskContext context)
        {
            var titles = new[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R" };

            foreach (var p in titles)
            {
                context.Tickets.AddOrUpdate(t => t.Title,
                                            new Ticket
                {
                    Title              = "Test Ticket " + p,
                    AffectsCustomer    = false,
                    AssignedTo         = "admin",
                    Category           = "Hardware",
                    CreatedBy          = "otherstaffer",
                    TicketStatus       = (p == "L") ? TicketStatus.Closed: TicketStatus.Active,
                    CurrentStatusDate  = DateTimeOffset.Now,
                    CurrentStatusSetBy = "otherstaffer",
                    Details            = "Lorem ipsum dolor sit amet, consectetur adipiscing elit fusce vel sapien elit in malesuada semper mi, id sollicitudin urna fermentum ut fusce varius nisl ac ipsum gravida vel pretium tellus.",
                    IsHtml             = false,
                    LastUpdateBy       = "otherstaffer",
                    LastUpdateDate     = DateTimeOffset.Now,
                    Owner              = "otherstaffer",
                    Priority           = "Low",
                    PublishedToKb      = false,
                    TagList            = "test,moretest",
                    TicketType         = "Problem"
                });
            }

            context.Settings.AddOrUpdate(
                s => s.SettingName,
                new Setting
            {
                SettingName        = "CategoryList",
                SettingValue       = "Hardware,Software,Network",
                DefaultValue       = "Hardware,Software,Network",
                SettingType        = "StringList",
                SettingDescription = "This is the list of possible selections for the Category dropdown list.\n\nIs is advised that your use generic categories. The recommended rule-of-thumb is that there should be one option that fits any possible ticket a user might create, and there should NOT be a value such as 'other', 'N/A', or 'unknown'. Keeping the values general in nature increases the odds that users will pick a meaningful value."
            },
                new Setting
            {
                SettingName        = "CategoryList-es",
                SettingValue       = "¿Hardware?,¿Software?,¿Network?",
                DefaultValue       = "¿Hardware?,¿Software?,¿Network?",
                SettingType        = "StringList",
                SettingDescription = "spanish translation."
            },
                new Setting
            {
                SettingName        = "PriorityList",
                SettingValue       = "High,Low,Medium",
                DefaultValue       = "High,Low,Medium",
                SettingType        = "StringList",
                SettingDescription = "This is the list of possible selections for the Priority dropdown list."
            },
                new Setting
            {
                SettingName        = "PriorityList-es",
                SettingValue       = "¿High?,¿Low?,¿Medium?",
                DefaultValue       = "¿High?,¿Low?,¿Medium?",
                SettingType        = "StringList",
                SettingDescription = "spanish translation."
            },
                new Setting
            {
                SettingName        = "TicketTypesList",
                SettingValue       = "Question,Problem,Request",
                DefaultValue       = "Question,Problem,Request",
                SettingType        = "StringList",
                SettingDescription = "This is the list of possible selections for the Ticket Type dropdown list. The type of ticket is usually the 'kind' of issue the user is submitting.\n\nIs is advised that your use generic types. The recommended rule-of-thumb is that there should be one option that fits any possible ticket a user might create, and there should NOT be a value such as 'other', 'N/A', or 'unknown'. Keeping the values general in nature increases the odds that users will pick a meaningful value."
            },
                new Setting
            {
                SettingName        = "TicketTypesList-es",
                SettingValue       = "¿Question?,¿Problem?,¿Request?",
                DefaultValue       = "¿Question?,¿Problem?,¿Request?",
                SettingType        = "StringList",
                SettingDescription = "spanish translation."
            });

            var userManager = new TicketDeskUserManager(context);

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));

            if (!roleManager.RoleExists("Administrator"))
            {
                roleManager.Create(new IdentityRole("Administrator"));
            }

            if (!roleManager.RoleExists("HelpDesk"))
            {
                roleManager.Create(new IdentityRole("HelpDesk"));
            }

            if (!roleManager.RoleExists("TicketSubmitter"))
            {
                roleManager.Create(new IdentityRole("TicketSubmitter"));
            }

            if (userManager.FindByName("admin") == null)
            {
                var user = new UserProfile()
                {
                    UserName = "******", Email = "*****@*****.**"
                };
                var result = userManager.Create(user, "admin");
                if (result.Succeeded)
                {
                    userManager.AddToRole(user.Id, "Administrator");
                    userManager.AddToRole(user.Id, "HelpDesk");
                    userManager.AddToRole(user.Id, "TicketSubmitter");
                }
            }

            if (userManager.FindByName("otherstaffer") == null)
            {
                var user = new UserProfile()
                {
                    UserName = "******", Email = "*****@*****.**"
                };
                var result = userManager.Create(user, "otherstaffer");
                if (result.Succeeded)
                {
                    userManager.AddToRole(user.Id, "TicketSubmitter");
                }
            }

            context = new TicketDeskContext();



            context.SaveChanges();
        }