示例#1
0
 public static bool IsLegacyDatabase()
 {
     using (var ctx = new TdDomainContext(null))
     {
         return(IsLegacyDatabase(ctx));
     }
 }
示例#2
0
        public async Task <IPagedList <Ticket> > ListTicketsAsync(int pageIndex, TdDomainContext context)
        {
            var filterColumns = CurrentListSetting.FilterColumns.ToList();

            //if filtering by project, add filter for selected project
            var projectId = await context.UserSettingsManager.GetUserSelectedProjectIdAsync(context);

            if (projectId != default(int))
            {
                filterColumns.Add(new UserTicketListFilterColumn("ProjectId", true, projectId));
            }
            DisplayProjects = context.Projects.Count() > 1;

            DateTime toDate   = Convert.ToDateTime(filterColumns.FirstOrDefault(w => w.ColumnName.Equals("ToDate")).ColumnValue);
            DateTime fromDate = Convert.ToDateTime(filterColumns.FirstOrDefault(w => w.ColumnName.Equals("FromDate")).ColumnValue);

            var sortColumns = CurrentListSetting.SortColumns.ToList();
            var pageSize    = CurrentListSetting.ItemsPerPage;
            var query       = context.GetObjectQueryFor(context.Tickets);

            query = filterColumns.ApplyToQuery(query);
            query = sortColumns.ApplyToQuery(query);
            if (query != null)
            {
                Expression <Func <Ticket, bool> > filter = m => m.DueDate >= toDate && m.DueDate <= fromDate;
                query = query.Where(filter) as ObjectQuery <Ticket>;
            }
            return(await query.ToPagedListAsync(pageIndex, pageSize));
        }
        public PushNotificationSettingsController(TdPushNotificationContext noteContext, TdDomainContext domainContext)
        {
            ViewBag.Saved = false;

            NoteContext   = noteContext;
            DomainContext = domainContext;
        }
        public HttpResponseMessage Post([FromBody] UserSignInViewModel model)
        {
            TdIdentityContext context = new TdIdentityContext();
            var          userStore    = new UserStore <TicketDeskUser>(context);
            var          roleStore    = new RoleStore <TicketDeskRole>(context);
            var          userManager  = new TicketDeskUserManager(userStore);
            var          roleManager  = new TicketDeskRoleManager(roleStore);
            IOwinContext context1     = HttpContext.Current.GetOwinContext();

            //UserSignInViewModel model = new UserSignInViewModel();
            //model.UserNameOrEmail = "*****@*****.**";
            //model.Password = "******";
            //model.RememberMe = false;
            HttpResponseMessage     result;
            TicketDeskSignInManager signinmanager = new TicketDeskSignInManager(userManager, context1.Authentication);
            TdDomainContext         domain        = new TdDomainContext(null);
            UserController          controller    = new UserController(userManager, signinmanager, domain);

            controller.SignInApi(model, "");

            //var response = Request.CreateResponse(HttpStatusCode.Moved);
            //response.Headers.Location = new Uri("https://localhost:44373/ticket/new") ;
            //return response;
            result = Request.CreateResponse(HttpStatusCode.OK, "https://localhost:44373/ticket/new");
            return(result);
            //var employee = "Megha";
            //if (employee == null)
            //{
            //	return NotFound();
            //}
            //return Ok(employee);
        }
示例#5
0
 public static bool HasLegacySecurity()
 {
     using (var ctx = new TdDomainContext(null))
     {
         return(HasLegacySecurity(ctx));
     }
 }
 public DatabaseStatusViewModel()
 {
     using (var ctx = new TdDomainContext(null))
     {
         DatabaseExists          = ctx.Database.Exists();
         IsCompatibleWithEfModel = DatabaseExists && !IsEmptyDatabase && ctx.Database.CompatibleWithModel(false);
     }
 }
示例#7
0
 public UserAdministrationController(
     TicketDeskUserManager userManager,
     TicketDeskRoleManager roleManager,
     TdDomainContext domainContext)
 {
     UserManager   = userManager;
     RoleManager   = roleManager;
     DomainContext = domainContext;
 }
示例#8
0
 public UserController(
     TicketDeskUserManager userManager,
     TicketDeskSignInManager signInManager,
     TdDomainContext domainContext)
 {
     UserManager = userManager;
     SignInManager = signInManager;
     DomainContext = domainContext;
 }
示例#9
0
 public UserController(
     TicketDeskUserManager userManager,
     TicketDeskSignInManager signInManager,
     TdDomainContext domainContext)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
     DomainContext = domainContext;
 }
示例#10
0
        public async Task <PartialViewResult> FilterList(
            string listName,
            int pageSize,
            int projectId,
            string ticketStatus,
            string owner,
            string assignedTo)
        {
            string   daterange = HttpContext.Request.Params.Get("daterange");
            DateTime toDate    = Convert.ToDateTime("01/01/" + DateTime.Now.Year);
            DateTime fromDate  = Convert.ToDateTime("12/31/" + DateTime.Now.Year);

            if (daterange != null && daterange.Length > 1)
            {
                List <string> lstTime = daterange.Split('-').ToList();
                toDate   = Convert.ToDateTime(lstTime[0]);
                fromDate = Convert.ToDateTime(lstTime[1]);
            }
            var uId         = Context.SecurityProvider.CurrentUserId;
            var userSetting = await Context.UserSettingsManager.GetSettingsForUserAsync(uId);

            if (userSetting != null && userSetting.ListSettings.Any())
            {
                for (int i = 0; i < userSetting.ListSettings.Count; i++)
                {
                    if (userSetting.ListSettings[i].ListName.ToLower().Equals(listName.ToString().ToLower()))
                    {
                        foreach (var item in userSetting.ListSettings[i].FilterColumns)
                        {
                            if (item.ColumnName.Equals("ToDate"))
                            {
                                item.ColumnValue = toDate.ToString("MM/dd/yyyy");
                            }
                            if (item.ColumnName.Equals("FromDate"))
                            {
                                item.ColumnValue = fromDate.ToString("MM/dd/yyyy");
                            }
                        }
                    }
                }
            }
            using (var tempCtx = new TdDomainContext())
            {
                await tempCtx.UserSettingsManager.AddOrUpdateSettingsForUser(userSetting);

                await tempCtx.SaveChangesAsync();
            }
            var currentListSetting = userSetting.GetUserListSettingByName(listName);

            currentListSetting.ModifyFilterSettings(pageSize, projectId, ticketStatus, owner, assignedTo, toDate, fromDate);//Tứ bổ sung projectId toDate, fromDate cho filter 13/03/2020

            await Context.SaveChangesAsync();

            return(await GetTicketListPartial(null, listName));
        }
示例#11
0
 public ActionResult CreateDemoData()
 {
     using (var ctx = new TdDomainContext(null))
     {
         DemoDataManager.SetupDemoData(ctx);
     }
     DemoIdentityDataManager.SetupDemoIdentityData(IdentityContext, User.Identity.GetUserId());
     DemoPushNotificationDataManager.SetupDemoPushNotificationData(PushNotificationContext);
     ViewBag.DemoDataCreated = true;
     return(View("Demo"));
 }
 public ActionResult RemoveDemoData()
 {
     using (var ctx = new TdDomainContext(null))
     {
         DemoDataManager.RemoveAllData(ctx);
     }
     DemoIdentityDataManager.RemoveAllIdentity(IdentityContext);
     DemoPushNotificationDataManager.RemoveAllPushNotificationData(PushNotificationContext);
     ViewBag.DemoDataRemoved = true;
     return View("Demo");
 }
示例#13
0
 public ActionResult RemoveDemoData()
 {
     using (var ctx = new TdDomainContext(null))
     {
         DemoDataManager.RemoveAllData(ctx);
     }
     DemoIdentityDataManager.RemoveAllIdentity(IdentityContext);
     DemoPushNotificationDataManager.RemoveAllPushNotificationData(PushNotificationContext);
     ViewBag.DemoDataRemoved = true;
     return(View("Demo"));
 }
 public ActionResult CreateDemoData()
 {
     using (var ctx = new TdDomainContext(null))
     {
         DemoDataManager.SetupDemoData(ctx);
     }
     DemoIdentityDataManager.SetupDemoIdentityData(IdentityContext);
     DemoPushNotificationDataManager.SetupDemoPushNotificationData(PushNotificationContext);
     ViewBag.DemoDataCreated = true;
     return View("Demo");
 }
        public async Task <ActionResult> CreateDatabase(string email, string password, string displayName)
        {
            using (var ctx = new TdDomainContext(null))
            {
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion <TdDomainContext, Configuration>(true));
                ctx.Database.Initialize(true);
            }



            var filter = GlobalFilters.Filters.FirstOrDefault(f => f.Instance is DbSetupFilter);

            if (filter != null)
            {
                GlobalFilters.Filters.Remove(filter.Instance);
            }

            Database.SetInitializer(new TdIdentityDbInitializer());
            var existingUser = UserManager.FindByName(email);

            if (existingUser == null)
            {
                var user = new TicketDeskUser {
                    UserName = email, Email = email, DisplayName = displayName
                };
                await UserManager.CreateAsync(user, password);

                await UserManager.AddToRoleAsync(user.Id, "TdAdministrators");
            }
            else
            {
                //should only happen if user entered one of the demo user names when setting up the DB
                //reset the password to the one the user entered here, and set the admin role if needed
                var token = await UserManager.GeneratePasswordResetTokenAsync(existingUser.Id);

                await UserManager.ResetPasswordAsync(existingUser.Id, token, password);

                existingUser.DisplayName = displayName;
                await UserManager.UpdateAsync(existingUser);

                if (!UserManager.IsTdAdministrator(existingUser.Id))
                {
                    await UserManager.AddToRoleAsync(existingUser.Id, "TdAdministrators");
                }
            }
            Database.SetInitializer(new TdPushNotificationDbInitializer());

            Startup.ConfigurePushNotifications();
            UpdateSearchIndex();
            return(RedirectToAction("Index"));
        }
        public ActionResult CreateDemoData()
        {
            using (var ctx = new TdDomainContext(null))
            {
                DemoDataManager.SetupDemoData(ctx);
            }
            DemoIdentityDataManager.SetupDemoIdentityData(IdentityContext, User.Identity.GetUserId());
            DemoPushNotificationDataManager.SetupDemoPushNotificationData(PushNotificationContext);
            ViewBag.DemoDataCreated = true;
            Task.Delay(500).ContinueWith(t => System.Web.HttpRuntime.UnloadAppDomain()).ConfigureAwait(false);

            return(View("Demo"));
        }
 private void UpdateSearchIndex()
 {
     //TODO: duplicated in DatabaseConfig.cs, should refactor extension method or something... just not sure what the most appropriate place is
     HostingEnvironment.QueueBackgroundWorkItem(async(ct) =>
     {
         using (var ctx = new TdDomainContext(null))
         {
             await TdSearchContext.Current.IndexManager.RunIndexMaintenanceAsync();
             var searchItems = ctx.Tickets.Include("TicketEvents").ToSeachIndexItems();
             await TdSearchContext.Current.IndexManager.AddItemsToIndexAsync(searchItems);
         }
     });
 }
示例#18
0
        public static void RemoveAllData(TdDomainContext context)
        {
            context.UserSettings.RemoveRange(context.UserSettings);
            context.TicketTags.RemoveRange(context.TicketTags);
            context.TicketEventNotifications.RemoveRange(context.TicketEventNotifications);
            context.TicketSubscribers.RemoveRange(context.TicketSubscribers);
            context.TicketEvents.RemoveRange(context.TicketEvents);
            context.Tickets.RemoveRange(context.Tickets);
            context.Projects.RemoveRange(context.Projects.Where(p => p.ProjectName != "Default"));
            context.TicketDeskSettings = new ApplicationSetting() {};

            context.SaveChanges();
        }
示例#19
0
 public async Task<UserSetting> GetSettingsForUserAsync(string userId)
 {
     var settings = await Context.UserSettings.FindAsync(userId);
     if (settings == null)
     {
         //settings for user not found, make default and save on separate context (so we don't commit other changes on this context as a side-effect).
         settings = UserSetting.GetDefaultSettingsForUser(userId, Context.SecurityProvider.IsTdHelpDeskUser || Context.SecurityProvider.IsTdAdministrator);
         using (var tempCtx = new TdDomainContext())
         {
             tempCtx.UserSettingsManager.AddSettingsForUser(settings);
             await tempCtx.SaveChangesAsync();
         }
     }
     return settings;
 }
示例#20
0
        public static void RemoveAllData(TdDomainContext context)
        {
            context.UserSettings.RemoveRange(context.UserSettings);
            context.TicketTags.RemoveRange(context.TicketTags);
            context.TicketEventNotifications.RemoveRange(context.TicketEventNotifications);
            context.TicketSubscribers.RemoveRange(context.TicketSubscribers);
            context.TicketEvents.RemoveRange(context.TicketEvents);
            context.Tickets.RemoveRange(context.Tickets);
            context.Projects.RemoveRange(context.Projects.Where(p => p.ProjectName != "Default"));
            context.TicketDeskSettings = new ApplicationSetting()
            {
            };

            context.SaveChanges();
        }
示例#21
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
            {


                //run any pending migrations automatically to bring the DB up to date
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion<TdDomainContext, Configuration>(true));
                using (var ctx = new TdDomainContext(null))
                {
                    try
                    {
                        ctx.Database.Initialize(!ctx.Database.CompatibleWithModel(true));
                    }
                    catch (Exception)//no metadata in DB, force run initializer anyway
                    {
                        ctx.Database.Initialize(true);
                    }
                    if (IsFirstRunDemoRefreshEnabled())
                    {
                        DemoDataManager.SetupDemoData(ctx);

                        //TODO: duplicated in FirstRunSetup controller, should refactor extension method or something... just not sure what the most appropriate place is 
                        HostingEnvironment.QueueBackgroundWorkItem(async (ct) =>
                        {
                            using (var dctx = new TdDomainContext(null))
                            {
                                await TdSearchContext.Current.IndexManager.RunIndexMaintenanceAsync();
                                var searchItems = dctx.Tickets.Include("TicketEvents").ToSeachIndexItems();
                                await TdSearchContext.Current.IndexManager.AddItemsToIndexAsync(searchItems);
                            }
                        });
                    }
                }
            }
        }
        public static async Task<TicketCenterListViewModel> GetViewModelAsync(int currentPage, string listName, TdDomainContext context, string userId)
        {
            var userSettings = await context.UserSettingsManager.GetSettingsForUserAsync(userId);
            var vm = new TicketCenterListViewModel()
            {
                UserListSettings = userSettings.ListSettings.OrderBy(
                        lp => lp.ListMenuDisplayOrder),
                CurrentPage = currentPage,
                CurrentListSetting = await context.UserSettingsManager.GetUserListSettingByNameAsync(listName, userId)
            };


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

            return vm;
        }
示例#23
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
            {
                //run any pending migrations automatically to bring the DB up to date
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion <TdDomainContext, Configuration>(true));
                using (var ctx = new TdDomainContext(null))
                {
                    try
                    {
                        ctx.Database.Initialize(!ctx.Database.CompatibleWithModel(true));
                    }
                    catch (Exception)//no metadata in DB, force run initializer anyway
                    {
                        ctx.Database.Initialize(true);
                    }
                    if (IsFirstRunDemoRefreshEnabled())
                    {
                        DemoDataManager.SetupDemoData(ctx);

                        //TODO: duplicated in FirstRunSetup controller, should refactor extension method or something... just not sure what the most appropriate place is
                        HostingEnvironment.QueueBackgroundWorkItem(async(ct) =>
                        {
                            using (var dctx = new TdDomainContext(null))
                            {
                                await TdSearchContext.Current.IndexManager.RunIndexMaintenanceAsync();
                                var searchItems = dctx.Tickets.Include("TicketEvents").ToSeachIndexItems();
                                await TdSearchContext.Current.IndexManager.AddItemsToIndexAsync(searchItems);
                            }
                        });
                    }
                }
            }
        }
示例#24
0
        private void MigrateDatabase()
        {
            RaiseStatusChangedOnMainThread(new[] { "Converting database." });

            using (var ctx = new TdDomainContext(null))
            {
                TdLegacyDatabaseInitializer <TdDomainContext> .InitDatabase(ctx);
            }
            RaiseStatusChangedOnMainThread(new[] { "Converion complete." });
            RaiseStatusChangedOnMainThread(new[] { "Migrating database to latest version." });

            using (var ctx = new TdDomainContext(null))
            {
                Database.SetInitializer(new MigrateDatabaseToLatestVersion <TdDomainContext, Configuration>(true));
                ctx.Database.Initialize(true);
            }
            RaiseStatusChangedOnMainThread(new[] { "Database migrated to latest version." });
        }
示例#25
0
        private void MigrateImages()
        {
            const string contentQueryText = "SELECT FileContents FROM dbo.TicketAttachments WHERE FileId = @p0";
            const string modelQuery       =
                "SELECT TicketId, FileId, FileName, FileSize, IsPending FROM dbo.TicketAttachments";
            const int pgSize = 20;

            using (var ctx = new TdDomainContext(null))
            {
                var q      = ctx.Database.SqlQuery <TicketAttachment>(modelQuery);
                var numRec = q.Count();
                RaiseStatusChangedOnMainThread(new[] { string.Format("Importing {0} Images from legacy database.", numRec) });
                var i = 0;
                while (i < numRec)
                {
                    var res = q.Skip(i).Take(pgSize).ToArray();
                    i += pgSize;
                    foreach (var file in res)
                    {
                        if (file.TicketId.HasValue)
                        {
                            var container = file.TicketId.Value.ToString(CultureInfo.InvariantCulture);
                            if (!TicketDeskFileStore.FileExists(file.FileName, container, false))
                            {
                                var contentQuery = ctx.Database.SqlQuery <byte[]>(contentQueryText, file.FileId);
                                var stream       = new MemoryStream(contentQuery.First());



                                TicketDeskFileStore
                                .SaveAttachmentAsync(stream, file.FileName, container, false)
                                .Wait();
                                RaiseStatusChangedOnMainThread(new[] { string.Format("    Image {0} for ticket #{1} imported.", file.FileName, file.TicketId) });
                            }
                            else
                            {
                                RaiseStatusChangedOnMainThread(new[] { string.Format("    Image {0} for ticket #{1} already exists, skipping.", file.FileName, file.TicketId) });
                            }
                        }
                    }
                }
                RaiseStatusChangedOnMainThread(new[] { "Image import complete." });
            }
        }
        public ActionResult CreateDatabase()
        {
            using (var ctx = new TdDomainContext(null))
            {
                Database.SetInitializer(
                    new MigrateDatabaseToLatestVersion <TdDomainContext, Configuration>(true));
                ctx.Database.Initialize(true);
            }
            var filter = GlobalFilters.Filters.FirstOrDefault(f => f.Instance is DbSetupFilter);

            if (filter != null)
            {
                GlobalFilters.Filters.Remove(filter.Instance);
            }
            Database.SetInitializer(new TdIdentityDbInitializer());
            Database.SetInitializer(new TdPushNotificationDbInitializer());
            Startup.ConfigurePushNotifications();
            UpdateSearchIndex();
            return(RedirectToAction("Index"));
        }
示例#27
0
        public static async Task<int> GetUserSelectedProjectIdAsync(this UserSettingsManager userSettingsManager, TdDomainContext context)
        {
            //TODO: We have to take the source context as a param because we have sync callers (child action in navigation).
            //      Trying to use dependency resolver with a sync caller results in the context being invoked without a security provider.
            //      The entire concept of child actions are heavily refactored in MVC 6, so this should not be an issue in future versions.

            var projects = context.Projects;
            var settings = await userSettingsManager.GetSettingsForUserAsync(context.SecurityProvider.CurrentUserId);
            var projectId = settings.SelectedProjectId ?? 0;

            //if user's selected project points to a project that no longer exists, reset
            //  normally this wouldn't happen since the dbcontext will update user settings when projects are deleted 
            if (projectId != 0 && projects.All(p => p.ProjectId != projectId))
            {
                projectId = 0;
                await UpdateUserSelectedProjectAsync(userSettingsManager, projectId, context.SecurityProvider.CurrentUserId);
                context.SaveChanges();
            }
            return projectId;

        }
        public async Task<IPagedList<Ticket>> ListTicketsAsync(int pageIndex, TdDomainContext context)
        {
            var filterColumns = CurrentListSetting.FilterColumns.ToList();

            //if filtering by project, add filter for selected project
            var projectId = await context.UserSettingsManager.GetUserSelectedProjectIdAsync(context);
            if (projectId != default(int))
            {
                filterColumns.Add(new UserTicketListFilterColumn("ProjectId", true, projectId));
            }

            DisplayProjects = context.Projects.Count() > 1;


            var sortColumns = CurrentListSetting.SortColumns.ToList();
            var pageSize = CurrentListSetting.ItemsPerPage;
            var query = context.GetObjectQueryFor(context.Tickets);

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

            return await query.ToPagedListAsync(pageIndex, pageSize);
        }
        public async Task <IPagedList <Ticket> > ListTicketsAsync(int pageIndex, TdDomainContext context)
        {
            var filterColumns = CurrentListSetting.FilterColumns.ToList();

            //if filtering by project, add filter for selected project
            var projectId = await context.UserSettingsManager.GetUserSelectedProjectIdAsync(context);

            if (projectId != default(int))
            {
                filterColumns.Add(new UserTicketListFilterColumn("ProjectId", true, projectId));
            }

            DisplayProjects = context.Projects.Count() > 1;


            var sortColumns = CurrentListSetting.SortColumns.ToList();
            var pageSize    = CurrentListSetting.ItemsPerPage;
            var query       = context.GetObjectQueryFor(context.Tickets);

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

            return(await query.ToPagedListAsync(pageIndex, pageSize));
        }
 public ActionResult CreateDatabase()
 {
     using (var ctx = new TdDomainContext(null))
     {
         Database.SetInitializer(
             new MigrateDatabaseToLatestVersion<TdDomainContext, Configuration>(true));
         ctx.Database.Initialize(true);
     }
     var filter = GlobalFilters.Filters.FirstOrDefault(f => f.Instance is DbSetupFilter);
     if (filter != null)
     {
         GlobalFilters.Filters.Remove(filter.Instance);
     }
     Database.SetInitializer(new TdIdentityDbInitializer());
     Database.SetInitializer(new TdPushNotificationDbInitializer());
     Startup.ConfigurePushNotifications();
     UpdateSearchIndex();
     return RedirectToAction("Index");
 }
 public TicketActivityController(TdDomainContext context)
 {
     Context = context;
 }
 public PushNotificationSettingsController(TdPushNotificationContext noteContext, TdDomainContext domainContext)
 {
     NoteContext   = noteContext;
     DomainContext = domainContext;
 }
示例#33
0
 public TicketController(TdDomainContext context)
 {
     Context = context;
 }
示例#34
0
 public NavigationController(TdDomainContext context)
 {
     Context = context;
 }
 public AutoCompleteController(TdDomainContext context)
 {
     Context = context;
 }
示例#36
0
 public EmailTestController(TdDomainContext context)
 {
     Context = context;
 }
示例#37
0
        public static void SetupDemoData(TdDomainContext context)
        {
            
            RemoveAllData(context);
            context.SaveChanges();
            context.Projects.AddOrUpdate(p => p.ProjectName, new Project() {ProjectName = "NullSoft", ProjectDescription = "NullSoft Rocks"});
            var dProj = context.Projects.First();
            context.Tickets.AddOrUpdate(t => t.Title,
                   new Ticket
                   {
                       ProjectId = dProj.ProjectId,
                       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",
                       TicketTags = new List<TicketTag> { new TicketTag() { TagName = "test" }, { new TicketTag() { TagName = "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
                    {
                        ProjectId = dProj.ProjectId,
                        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",
                        TicketTags = new List<TicketTag> { new TicketTag() { TagName = "test" }, { new TicketTag() { TagName = "moretest" } } },
                        TicketType = tt,
                        TicketEvents = new[] { TicketEvent.CreateActivityEvent(oo, TicketActivity.Create, null, null, null) }
                    });
            }
            context.SaveChanges();
        }
示例#38
0
 public TicketCenterController(TdDomainContext context)
 {
     Context = context;
 }
 public ProjectSettingsController(TdDomainContext context)
 {
     Context = context;
 }
        public static async Task <TicketCenterListViewModel> GetViewModelAsync(int currentPage, string listName, TdDomainContext context, string userId)
        {
            var userSettings = await context.UserSettingsManager.GetSettingsForUserAsync(userId);

            var vm = new TicketCenterListViewModel()
            {
                UserListSettings = userSettings.ListSettings.OrderBy(
                    lp => lp.ListMenuDisplayOrder),
                CurrentPage        = currentPage,
                CurrentListSetting = await context.UserSettingsManager.GetUserListSettingByNameAsync(listName, userId)
            };


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

            return(vm);
        }
示例#41
0
 public static bool HasLegacySecurity()
 {
     using (var ctx = new TdDomainContext(null))
     {
         return HasLegacySecurity(ctx);
     }
 }
示例#42
0
 public ApplicationSettingsController(TdDomainContext context)
 {
     Context = context;
     IsAzureSearchDetected = TdSearchContext.Current.IndexManager.GetType() == typeof(AzureIndexProvider);
 }
示例#43
0
 public EmailTestController(TdDomainContext context)
 {
     Context = context;
 }
示例#44
0
 public AutoCompleteController(TdDomainContext context)
 {
     Context = context;
 }
示例#45
0
 public static bool IsEmptyDatabase()
 {
     using (var ctx = new TdDomainContext(null))
     {
         return IsEmptyDatabase(ctx);
     }
 }
 public SearchManagerController(TdDomainContext context)
 {
     Context = context;
 }
示例#47
0
        public static async Task <int> GetUserSelectedProjectIdAsync(this UserSettingsManager userSettingsManager, TdDomainContext context)
        {
            //TODO: We have to take the source context as a param because we have sync callers (child action in navigation).
            //      Trying to use dependency resolver with a sync caller results in the context being invoked without a security provider.
            //      The entire concept of child actions are heavily refactored in MVC 6, so this should not be an issue in future versions.

            var projects = context.Projects;
            var settings = await userSettingsManager.GetSettingsForUserAsync(context.SecurityProvider.CurrentUserId);

            var projectId = settings.SelectedProjectId ?? 0;

            //if user's selected project points to a project that no longer exists, reset
            //  normally this wouldn't happen since the dbcontext will update user settings when projects are deleted
            if (projectId != 0 && projects.All(p => p.ProjectId != projectId))
            {
                projectId = 0;
                await UpdateUserSelectedProjectAsync(userSettingsManager, projectId, context.SecurityProvider.CurrentUserId);

                context.SaveChanges();
            }
            return(projectId);
        }
 private void UpdateSearchIndex()
 {
     //TODO: duplicated in DatabaseConfig.cs, should refactor extension method or something... just not sure what the most appropriate place is
     HostingEnvironment.QueueBackgroundWorkItem(async (ct) =>
     {
         using (var ctx = new TdDomainContext(null))
         {
             await TdSearchContext.Current.IndexManager.RunIndexMaintenanceAsync();
             var searchItems = ctx.Tickets.Include("TicketEvents").ToSeachIndexItems();
             await TdSearchContext.Current.IndexManager.AddItemsToIndexAsync(searchItems);
         }
     });
 }
 public ApplicationSettingsController(TdDomainContext context)
 {
     Context = context;
     IsAzureSearchDetected = TdSearchContext.Current.IndexManager.GetType() == typeof(AzureIndexProvider);
 }
示例#50
0
 public UserSettingsManager(TdDomainContext context)
 {
     Context = context;
 }
示例#51
0
 public DatabaseStatusViewModel()
 {
     using (var ctx = new TdDomainContext(null))
     {
         DatabaseExists = ctx.Database.Exists();
         IsCompatibleWithEfModel = DatabaseExists && !IsEmptyDatabase && ctx.Database.CompatibleWithModel(false);
     }
 }
 public PushNotificationSettingsController(TdPushNotificationContext noteContext, TdDomainContext domainContext)
 {
     NoteContext = noteContext;
     DomainContext = domainContext;
 }
示例#53
0
 public SearchController(TdDomainContext context)
 {
     Context = context;
 }
 public TicketActivityController(TdDomainContext context)
 {
     Context = context;
 }
 public ProjectSettingsController(TdDomainContext context)
 {
     Context = context;
 }