Ejemplo n.º 1
0
 public static bool HasLegacySecurity()
 {
     using (var ctx = new TicketDeskContext(null))
     {
         return(HasLegacySecurity(ctx));
     }
 }
Ejemplo n.º 2
0
 public static bool IsLegacyDatabase()
 {
     using (var ctx = new TicketDeskContext(null))
     {
         return(IsLegacyDatabase(ctx));
     }
 }
Ejemplo n.º 3
0
 public DatabaseStatusViewModel()
 {
     using (var ctx = new TicketDeskContext(null))
     {
         DatabaseExists          = ctx.Database.Exists();
         IsCompatibleWithEfModel = DatabaseExists && !IsEmptyDatabase && ctx.Database.CompatibleWithModel(false);
     }
 }
Ejemplo n.º 4
0
 private static void AddLocalizedCategorySettingList(string lang, ICollection <KeyValuePair <string, object> > content)
 {
     using (var ctx = new TicketDeskContext())
     {
         var baseItem  = ctx.Settings.GetAvailableCategories().ToArray();
         var localItem = ctx.Settings.GetAvailableCategories(lang).ToArray();
         AddLocalizedSettingList(content, "Category", localItem, baseItem);
     }
 }
Ejemplo n.º 5
0
 public ActionResult RemoveDemoData()
 {
     using (var ctx = new TicketDeskContext(null))
     {
         DemoDataManager.RemoveAllData(ctx);
     }
     DemoIdentityDataManager.RemoveAllIdentity(IdentityContext);
     ViewBag.DemoDataRemoved = true;
     return(View("Demo"));
 }
Ejemplo n.º 6
0
 private static void CleanUp()
 {
     using (var ctx = new TicketDeskContext("TicketDesk"))
     {
         ctx.Database.Delete();
     }
     using (var ctx = new EmptyDatabaseContext("TicketDesk2xRefernece"))
     {
         ctx.Database.Delete();
     }
 }
 private static void CleanUp()
 {
     using (var ctx = new TicketDeskContext("TicketDesk"))
     {
         ctx.Database.Delete();
     }
     using (var ctx = new EmptyDatabaseContext("TicketDesk2xRefernece"))
     {
         ctx.Database.Delete();
     }
 }
Ejemplo n.º 8
0
        public ActionResult CreateDemoData()
        {
            using (var ctx = new TicketDeskContext(null))
            {
                DemoDataManager.SetupDemoData(ctx);
            }
            DemoIdentityDataManager.SetupDemoIdentityData(IdentityContext);

            ViewBag.DemoDataCreated = true;
            return(View("Demo"));
        }
Ejemplo n.º 9
0
        public void CanInitializeNewDb()
        {
            using (var ctx = new TicketDeskContext("TicketDesk"))
            {
                var dbInit = new TicketDeskDatabaseInitializer("TicketDesk");
                dbInit.InitializeDatabase(ctx);

                var versionRow = ctx.Settings.SingleOrDefault(s => s.SettingName == "Version");
                var isTd2      = (versionRow != null && versionRow.SettingValue == "3.0.0.001");
                Assert.IsTrue(isTd2, "unable to verify TicketDesk 3.x DB created");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TicketCenterListViewModel" /> class.
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="context">The context.</param>
        /// <param name="userId">The user identifier.</param>
        private TicketCenterListViewModel(int currentPage, string listName, TicketDeskContext context, string userId)
        {
            UserListSettings = context.UserSettings.GetUserListSettings(userId).OrderBy(lp => lp.ListMenuDisplayOrder);
            CurrentPage      = currentPage;
            if (string.IsNullOrEmpty(listName))
            {
                listName = UserListSettings.First().ListName;
            }
            CurrentListSetting = context.UserSettings.GetUserListSettingByName(listName, userId);

            FilterBar = new FilterBarViewModel(CurrentListSetting);
        }
        public void CanInitializeNewDb()
        {

            using (var ctx = new TicketDeskContext("TicketDesk"))
            {
                var dbInit = new TicketDeskDatabaseInitializer("TicketDesk");
                dbInit.InitializeDatabase(ctx);

                var versionRow = ctx.Settings.SingleOrDefault(s => s.SettingName == "Version");
                var isTd2 = (versionRow != null && versionRow.SettingValue == "3.0.0.001");
                Assert.IsTrue(isTd2, "unable to verify TicketDesk 3.x DB created");
            }
        }
Ejemplo n.º 12
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();
        }
Ejemplo n.º 13
0
        public void CanDowngradeLegacyDb()
        {
            MakeLegacyDb();
            MigrateLegacyDb();
            UnMigrateLegacyDb();

            using (var ctx = new TicketDeskContext("TicketDesk2xRefernece"))
            {
                var versionRow = ctx.Settings.SingleOrDefault(s => s.SettingName == "Version");

                var isTd2 = (versionRow != null && versionRow.SettingValue == "2.0.2");

                Assert.IsTrue(isTd2, "unable to verify TicketDesk 2.x DB was downgraded");
            }
        }
        public void CanDowngradeLegacyDb()
        {
            MakeLegacyDb();
            MigrateLegacyDb();
            UnMigrateLegacyDb();

            using (var ctx = new TicketDeskContext("TicketDesk2xRefernece"))
            {
                var versionRow = ctx.Settings.SingleOrDefault(s => s.SettingName == "Version");
                
                var isTd2 = (versionRow != null && versionRow.SettingValue == "2.0.2");

                Assert.IsTrue(isTd2, "unable to verify TicketDesk 2.x DB was downgraded");

            }
        }
        public ActionResult CreateDatabase()
        {
            using (var ctx = new TicketDeskContext(null))
            {
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion <TicketDeskContext, Configuration>(true));
                ctx.Database.Initialize(true);
            }
            var filter = GlobalFilters.Filters.FirstOrDefault(f => f.Instance is DbSetupFilter);

            if (filter != null)
            {
                GlobalFilters.Filters.Remove(filter.Instance);
            }
            return(RedirectToAction("Index"));
        }
        public Task <IPagedList <Ticket> > ListTicketsAsync(int pageIndex, TicketDeskContext context)
        {
            var filterColumns = CurrentListSetting.FilterColumns.ToList();
            var sortColumns   = CurrentListSetting.SortColumns.ToList();

            var pageSize = CurrentListSetting.ItemsPerPage;



            var query = context.GetObjectQueryFor(context.Tickets);


            query = filterColumns.ApplyToQuery(query);
            query = sortColumns.ApplyToQuery(query);


            return(query.ToPagedListAsync(pageIndex, pageSize));
        }
Ejemplo n.º 17
0
        public void CanUpgradeLegacyDb()
        {
            MakeLegacyDb();

            using (var ctx = new TicketDeskContext("TicketDesk2xRefernece"))
            {
                var versionRow = ctx.Settings.SingleOrDefault(s => s.SettingName == "Version");
                var isTd2      = (versionRow != null && versionRow.SettingValue == "2.0.2");

                Assert.IsTrue(isTd2, "unable to verify reference TicketDesk 2.x DB created");

                MigrateLegacyDb();

                ctx.Entry(versionRow).Reload();
                var isTd3 = (versionRow != null && versionRow.SettingValue == "3.0.0.001");

                Assert.IsTrue(isTd3, "unable to verify reference TicketDesk 2.x DB migrated to 3.0.0.001");
            }
        }
        public void CanUpgradeLegacyDb()
        {

            MakeLegacyDb();

            using (var ctx = new TicketDeskContext("TicketDesk2xRefernece"))
            {
                var versionRow = ctx.Settings.SingleOrDefault(s => s.SettingName == "Version");
                var isTd2 = (versionRow != null && versionRow.SettingValue == "2.0.2");

                Assert.IsTrue(isTd2, "unable to verify reference TicketDesk 2.x DB created");

                MigrateLegacyDb();

                ctx.Entry(versionRow).Reload();
                var isTd3 = (versionRow != null && versionRow.SettingValue == "3.0.0.001");

                Assert.IsTrue(isTd3, "unable to verify reference TicketDesk 2.x DB migrated to 3.0.0.001");
            }


        }
Ejemplo n.º 19
0
        public static void RegisterDatabase()
        {
            var setupEnabled    = ConfigurationManager.AppSettings["ticketdesk:SetupEnabled"];
            var firstRunEnabled = !string.IsNullOrEmpty(setupEnabled) &&
                                  setupEnabled.Equals("true", StringComparison.InvariantCultureIgnoreCase);


            if (firstRunEnabled && !IsDatabaseReady)
            {
                //add a global filter to send requests to the database managment first run functions
                GlobalFilters.Filters.Add(new DbSetupFilter());
            }
            else
            {
                var demoRefresh         = ConfigurationManager.AppSettings["ticketdesk:ResetDemoDataOnStartup"];
                var firstRunDemoRefresh = !string.IsNullOrEmpty(demoRefresh) &&
                                          demoRefresh.Equals("true", StringComparison.InvariantCultureIgnoreCase) &&
                                          IsDatabaseReady;//only do this if database was ready on startup, otherwise migrator will take care of it

                //run any pending migrations automatically to bring the DB up to date
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion <TicketDeskContext, Configuration>(true));
                using (var ctx = new TicketDeskContext(null))
                {
                    try
                    {
                        ctx.Database.Initialize(!ctx.Database.CompatibleWithModel(true));
                    }
                    catch (Exception)//no metadata in DB, force run initializer anyway
                    {
                        ctx.Database.Initialize(true);
                    }
                    if (firstRunDemoRefresh)
                    {
                        DemoDataManager.SetupDemoData(ctx);
                    }
                }
            }
        }
Ejemplo n.º 20
0
 public SearchManagerController(TicketDeskContext context)
 {
     Context = context;
 }
Ejemplo n.º 21
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();
        }
Ejemplo n.º 22
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();
        }
Ejemplo n.º 23
0
 public TicketActivityController(TicketDeskContext context)
 {
     Context = context;
 }
        public static async Task <TicketCenterListViewModel> GetViewModelAsync(int currentPage, string listName, TicketDeskContext context, string userId)
        {
            var vm = new TicketCenterListViewModel(currentPage, listName, context, userId);

            vm.Tickets = await vm.ListTicketsAsync(currentPage, context);

            return(vm);
        }
 public TicketCenterController(TicketDeskContext context)
 {
     Context = context;
 }
 public AutoCompleteController(TicketDeskContext context)
 {
     Context = context;
 }