コード例 #1
0
 public PaymentController(IConfiguration config, IWebHostEnvironment webHostEnvironment, IHttpContextAccessor httpContextAccessor) : base(config, webHostEnvironment, httpContextAccessor)
 {
     _PaymentRepo = new PaymentRepo(ConnString);
     _WorkRepo    = new WorkRepo(ConnString);
     _JobRepo     = new JobRepo(ConnString);
     _LookupRepo  = new LookupRepo(ConnString);
 }
コード例 #2
0
        protected override async Task OnInitializedAsync()
        {
            uid       = await((OBAuthenticationStateProvider)Auth).GetCurrentUserId();
            jobEntity = await JobRepo.Get(JobId);

            jobOptions = JsonConvert.DeserializeObject <JobOptionsWrapper>(jobEntity.JobOptions, settings).Options;
        }
コード例 #3
0
        private async Task Clone()
        {
            var wrapper = new JobOptionsWrapper {
                Options = jobOptions
            };
            var entity = new JobEntity
            {
                Owner        = await GuestRepo.Get(uid),
                CreationDate = DateTime.Now,
                JobType      = jobType,
                JobOptions   = JsonConvert.SerializeObject(wrapper, settings)
            };

            await JobRepo.Add(entity);

            // Get the entity that was just added in order to get its ID
            // entity = await JobRepo.GetAll().Include(j => j.Owner).OrderByDescending(e => e.Id).FirstAsync();

            try
            {
                var job = JobFactory.FromOptions(entity.Id, entity.Owner == null ? 0 : entity.Owner.Id, jobOptions);

                Manager.AddJob(job);
                Nav.NavigateTo($"job/{job.Id}");
            }
            catch (Exception ex)
            {
                await js.AlertException(ex);
            }
        }
コード例 #4
0
 public JobController(IConfiguration configuration)
 {
     _configuration  = configuration;
     scheduleRepo    = new ScheduleRepo(configuration);
     jobRepo         = new JobRepo(configuration);
     auditLogService = new AuditLogService(HttpContext, configuration);
 }
コード例 #5
0
        public static void Apply(NWGameObject player)
        {
            var playerID      = _.GetGlobalID(player);
            var jobType       = _.GetClassByPosition(ClassPosition.First, player);
            var jobDefinition = JobRegistry.Get(jobType);
            var job           = JobRepo.Get(playerID, jobType);
            var abilityList   = jobDefinition.GetAbilityListByLevel(job.Level);

            var allFeats = new List <Feat>(DefaultFeats);

            allFeats.AddRange(abilityList);

            // Remove any feats the player shouldn't have.
            var featCount = NWNXCreature.GetFeatCount(player);

            for (int x = featCount; x >= 0; x--)
            {
                var feat = NWNXCreature.GetFeatByIndex(player, x - 1);
                if (!allFeats.Contains(feat))
                {
                    NWNXCreature.RemoveFeat(player, feat);
                }
            }

            // Add any feats the player needs.
            foreach (var feat in allFeats)
            {
                if (_.GetHasFeat(feat, player))
                {
                    continue;
                }

                NWNXCreature.AddFeatByLevel(player, feat, 1);
            }
        }
コード例 #6
0
 public CommandEngine(JobRepo jobRepo, EmployeeRepo employees, EmployeeFactory employeeFactory, JobFactory jobFactory)
 {
     this.JobRepo         = jobRepo;
     this.Employees       = employees;
     this.EmployeeFactory = employeeFactory;
     this.JobFactory      = jobFactory;
 }
コード例 #7
0
        public async Task Remove(Job job)
        {
            if (job.Status != JobStatus.Idle)
            {
                await js.AlertError(Loc["JobNotIdle"], Loc["JobNotIdleWarning"]);

                return;
            }

            while (!Monitor.TryEnter(removeLock))
            {
                await Task.Delay(100);
            }

            // If the user already deleted this job (e.g. clicked remove twice)
            if (!Manager.Jobs.Contains(job))
            {
                Monitor.Exit(removeLock);
                return;
            }

            try
            {
                var entity = await JobRepo.GetAll().FirstAsync(e => e.Id == job.Id);

                await JobRepo.Delete(entity);

                Manager.Jobs.Remove(job);
            }
            finally
            {
                Monitor.Exit(removeLock);
            }
        }
コード例 #8
0
        public async Task RemoveAll()
        {
            var notIdleJobs = Manager.Jobs.Where(j => CanSeeJob(j.Id) && j.Status != JobStatus.Idle);

            if (notIdleJobs.Any())
            {
                await js.AlertError($"{Loc["JobNotIdle"]} #{notIdleJobs.First().Id}", Loc["JobNotIdleWarning"]);

                return;
            }

            // If admin, just purge all
            if (uid == 0)
            {
                JobRepo.Purge();
                Manager.Jobs.Clear();
            }
            else
            {
                var entities = await JobRepo.GetAll().Include(j => j.Owner)
                               .Where(j => j.Owner.Id == uid).ToListAsync();

                await JobRepo.Delete(entities);

                Manager.Jobs.RemoveAll(j => j.OwnerId == uid);
            }
        }
コード例 #9
0
 public WorkController(IConfiguration config, IWebHostEnvironment webHostEnvironment, IHttpContextAccessor httpContextAccessor) : base(config, webHostEnvironment, httpContextAccessor)
 {
     _WorkRepo    = new WorkRepo(ConnString);
     _PaymentRepo = new PaymentRepo(ConnString);
     _JobRepo     = new JobRepo(ConnString);
     _AppUserRepo = new AppUserRepo(ConnString);
 }
コード例 #10
0
ファイル: PaymentController.cs プロジェクト: gcorron/TimeCard
 public PaymentController()
 {
     _PaymentRepo = new PaymentRepo(ConnString);
     _WorkRepo    = new WorkRepo(ConnString);
     _JobRepo     = new JobRepo(ConnString);
     _LookupRepo  = new LookupRepo(ConnString);
 }
コード例 #11
0
 public ReportFeederController(IConfiguration configuration)
 {
     _configuration    = configuration;
     jobRepo           = new JobRepo(configuration);
     reportFeederRepo  = new ReportFeederRepo(configuration);
     fileUploadService = new FileUploadService(configuration);
     auditLogService   = new AuditLogService(HttpContext, configuration);
 }
コード例 #12
0
        private async Task DeleteGuest()
        {
            if (selectedGuest == null)
            {
                await ShowNoGuestSelectedWarning();

                return;
            }

            if (await js.Confirm(Loc["AreYouSure"], $"{Loc["ReallyDelete"]} {selectedGuest.Username}?", Loc["Cancel"]))
            {
                // We have to delete all the guest's jobs, proxies and wordlists first
                // otherwise we get a FOREIGN KEY CONSTRAINT FAILED exception.
                if (await js.Confirm(Loc["DeleteEverything"], Loc["DeleteEverythingMessage"], Loc["Cancel"]))
                {
                    // Delete jobs
                    var jobsToDelete = await JobRepo.GetAll().Include(j => j.Owner)
                                       .Where(j => j.Owner.Id == selectedGuest.Id).ToListAsync();

                    await JobRepo.Delete(jobsToDelete);

                    // Delete jobs from the service
                    JobManager.Jobs.RemoveAll(j => j.OwnerId == selectedGuest.Id);

                    // Delete proxy groups and their proxies
                    var proxyGroupsToDelete = await ProxyGroupRepo.GetAll().Include(g => g.Owner)
                                              .Where(g => g.Owner.Id == selectedGuest.Id).ToListAsync();

                    foreach (var group in proxyGroupsToDelete)
                    {
                        var toDelete = await ProxyRepo.GetAll()
                                       .Where(p => p.Group.Id == group.Id)
                                       .ToListAsync();

                        await ProxyRepo.Delete(toDelete);
                    }

                    await ProxyGroupRepo.Delete(proxyGroupsToDelete);

                    // Delete wordlists
                    var wordlistsToDelete = await WordlistRepo.GetAll().Include(w => w.Owner)
                                            .Where(w => w.Owner.Id == selectedGuest.Id).ToListAsync();

                    foreach (var w in wordlistsToDelete)
                    {
                        await WordlistRepo.Delete(w, false);
                    }

                    // Delete the guest from the db
                    await GuestRepo.Delete(selectedGuest);

                    // Delete the guest from the local list
                    guests.Remove(selectedGuest);
                }
            }

            await RefreshList();
        }
コード例 #13
0
 private void InitializeJobs(Guid playerID)
 {
     JobRepo.Set(playerID, ClassType.Warrior, new Data.Entity.Job());
     JobRepo.Set(playerID, ClassType.Monk, new Data.Entity.Job());
     JobRepo.Set(playerID, ClassType.WhiteMage, new Data.Entity.Job());
     JobRepo.Set(playerID, ClassType.BlackMage, new Data.Entity.Job());
     JobRepo.Set(playerID, ClassType.Thief, new Data.Entity.Job());
     JobRepo.Set(playerID, ClassType.Ranger, new Data.Entity.Job());
 }
コード例 #14
0
        protected override async Task OnInitializedAsync()
        {
            uid = await((OBAuthenticationStateProvider)Auth).GetCurrentUserId();

            var factory = new JobOptionsFactory();

            jobEntity = await JobRepo.Get(JobId);

            var oldOptions = JsonConvert.DeserializeObject <JobOptionsWrapper>(jobEntity.JobOptions, settings).Options;

            jobOptions = factory.CloneExistant(oldOptions);
            jobType    = jobEntity.JobType;
        }
コード例 #15
0
        public static void Main()
        {
            var data         = Script.GetScriptData <JobChanged>();
            var newJob       = data.NewJob;
            var player       = data.Player;
            var playerID     = GetGlobalID(player);
            var playerEntity = PlayerRepo.Get(playerID);
            var jobEntity    = JobRepo.Get(playerID, newJob);

            playerEntity.CurrentJob = newJob;

            NWNXCreature.SetClassByPosition(player, ClassPosition.First, newJob);
            NWNXCreature.SetLevelByPosition(player, ClassPosition.First, jobEntity.Level);
            SetXP(player, jobEntity.XP);
            PlayerRepo.Set(playerEntity);
        }
コード例 #16
0
ファイル: GainXP.cs プロジェクト: taelon875/NWN.FinalFantasy
        public static void Main()
        {
            var data        = Script.GetScriptData <JobXPGained>();
            var player      = data.Creature;
            var playerID    = GetGlobalID(player);
            var jobType     = GetClassByPosition(ClassPosition.First, player);
            var levelBefore = GetLevelByPosition(ClassPosition.First, player);

            // Auto-level the NWN class.
            // These changes get adjusted as part of our auto-level process.
            LevelUpHenchman(player, jobType);
            var levelAfter = GetLevelByPosition(ClassPosition.First, player);
            var job        = JobRepo.Get(playerID, jobType);

            job.Level = levelAfter;
            job.XP    = GetXP(player);
            JobRepo.Set(playerID, jobType, job);

            if (levelBefore != levelAfter)
            {
                Publish.CustomEvent(player, JobEventPrefix.OnLeveledUp, new LeveledUp(player));
            }
        }
コード例 #17
0
        private async Task Edit()
        {
            var wrapper = new JobOptionsWrapper {
                Options = jobOptions
            };

            jobEntity.JobOptions = JsonConvert.SerializeObject(wrapper, settings);

            await JobRepo.Update(jobEntity);

            try
            {
                var oldJob = Manager.Jobs.First(j => j.Id == JobId);
                var newJob = JobFactory.FromOptions(JobId, jobEntity.Owner == null ? 0 : jobEntity.Owner.Id, jobOptions);

                Manager.Jobs.Remove(oldJob);
                Manager.Jobs.Add(newJob);
                Nav.NavigateTo($"job/{JobId}");
            }
            catch (Exception ex)
            {
                await js.AlertException(ex);
            }
        }
コード例 #18
0
        public override void RegisterGrids()
        {
            UrlHelper UrlHelper = new UrlHelper();

            //Issue6Grid
            MVCGridDefinitionTable.Add("InitialDateGrid", new MVCGridBuilder <IReportInvoiceLine>()
                                       .WithSorting(false)
                                       .WithPaging(false)
                                       .WithAllowChangingPageSize(false)
                                       .WithFiltering(true)
                                       .WithNoResultsMessage("Please enter a year to search for. No results found.")
                                       .AddColumns(cols =>
            {
                cols.Add("Year").WithHeaderText("Year")
                .WithFiltering(true)
                .WithValueExpression(a => a.Year.ToString());

                cols.Add("InvoiceNo").WithHeaderText("Invoice No.")
                .WithVisibility(true, true)
                .WithValueExpression(a => a.InvoiceNumber.ToString());

                cols.Add("City").WithHeaderText("City")
                .WithVisibility(true, true)
                .WithValueExpression(a => a.City);
            })
                                       .WithRetrieveDataMethod((context) =>
            {
                IList <IReportInvoiceLine> list = new List <IReportInvoiceLine>();
                int totalRecords = 0;

                string syear = context.QueryOptions.GetFilterString("Year");
                int year;

                if (Int32.TryParse(syear, out year))
                {
                    list         = ReportInvoiceLines(year);
                    totalRecords = list.Count;
                }

                return(new QueryResult <IReportInvoiceLine>()
                {
                    Items = list,
                    TotalRecords = totalRecords
                });
            })
                                       );


            //Issue6Grid
            MVCGridDefinitionTable.Add("Issue6Grid", new MVCGridBuilder <Job>()
                                       .WithSorting(true)
                                       .WithDefaultSortColumn("Id")
                                       .WithPaging(true)
                                       .WithAllowChangingPageSize(true)
                                       .WithMaxItemsPerPage(100)
                                       .WithItemsPerPage(10)
                                       .WithAdditionalQueryOptionName("globalsearch")
                                       .AddColumns(cols =>
            {
                cols.Add("Id", "Id", row => row.JobId.ToString()).WithSorting(true);
                cols.Add("Name", "Name", row => row.Name).WithSorting(true);

                cols.Add("Contact")
                .WithHeaderText("Contact")
                .WithSorting(false)
                .WithHtmlEncoding(false)
                .WithValueExpression((p, c) => p.Contact != null ? UrlHelper.Action("Edit", "Contact", new { id = p.Contact.Id }) : "")
                .WithValueTemplate("<a href='{Value}'>{Model.Contact.FullName}</a>").WithPlainTextValueExpression((p, c) => p.Contact != null ? p.Contact.FullName : "");

                cols.Add("Delete")
                .WithHtmlEncoding(false)
                .WithSorting(false)
                .WithFiltering(false)
                .WithHeaderText("<input type='checkbox' id='chkselectall'>")
                .WithValueExpression((p, c) => UrlHelper.Action("Save", "Country", new { area = "General", id = p.JobId }))
                .WithValueTemplate("<input type='checkbox' class='select' value='{Model.JobId}'>")
                .WithPlainTextValueExpression((p, c) => "");
            })
                                       .WithRetrieveDataMethod((context) =>
            {
                var options = context.QueryOptions;

                string globalsearch = options.GetAdditionalQueryOptionString("globalsearch");

                JobRepo repo = new JobRepo();
                int totalRecords;
                var data = repo.GetData(out totalRecords, globalsearch, options.GetLimitOffset(),
                                        options.GetLimitRowcount(), options.GetSortColumnData <string>(), options.SortDirection == SortDirection.Dsc);

                return(new QueryResult <Job>()
                {
                    Items = data,
                    TotalRecords = totalRecords
                });
            })
                                       );

            //Issue21Grid
            //ńłóźćłąę.
            MVCGridDefinitionTable.Add("Issue21Grid", new MVCGridBuilder <TestItem>()
                                       .WithAuthorizationType(AuthorizationType.AllowAnonymous)
                                       .AddColumns(cols =>
            {
                cols.Add("Col1").WithValueExpression(p => "ńłóźćłąę.");
                cols.Add("Col2").WithValueExpression(p => p.Col2);
            })
                                       .WithSorting(true, "Col1")
                                       .WithPaging(true, 10)
                                       .WithFiltering(true)
                                       .WithRetrieveDataMethod((context) =>
            {
                var options = context.QueryOptions;

                string col3Filter = context.QueryOptions.GetFilterString("FromDate");

                TestItemRepository repo = new TestItemRepository();
                int totalRecords;
                var items = repo.GetData(out totalRecords, col3Filter, options.GetLimitOffset(), options.GetLimitRowcount(), options.GetSortColumnData <string>(), options.SortDirection == SortDirection.Dsc);



                return(new QueryResult <TestItem>()
                {
                    Items = items,
                    TotalRecords = totalRecords
                });
            })
                                       );

            //Issue17Grid
            MVCGridDefinitionTable.Add("Issue17Grid", new MVCGridBuilder <TestItem>()
                                       .WithAuthorizationType(AuthorizationType.AllowAnonymous)
                                       .AddColumns(cols =>
            {
                cols.Add("Col1").WithValueExpression(p => p.Col1);
                cols.Add("Col2").WithValueExpression(p => p.Col2);


                cols.Add("FromDate").WithHeaderText("From Date").WithFiltering(true).WithValueExpression(x => x.Col3);
            })
                                       .WithSorting(true, "Col1")
                                       .WithPaging(true, 10)
                                       .WithFiltering(true)
                                       .WithRetrieveDataMethod((context) =>
            {
                var options = context.QueryOptions;

                string col3Filter = context.QueryOptions.GetFilterString("FromDate");

                TestItemRepository repo = new TestItemRepository();
                int totalRecords;
                var items = repo.GetData(out totalRecords, col3Filter, options.GetLimitOffset(), options.GetLimitRowcount(), options.GetSortColumnData <string>(), options.SortDirection == SortDirection.Dsc);



                return(new QueryResult <TestItem>()
                {
                    Items = items,
                    TotalRecords = totalRecords
                });
            })
                                       );


            //Issue28Grid
            MVCGridDefinitionTable.Add("Issue28Grid", new MVCGridBuilder <TestItem>()
                                       .WithAuthorizationType(AuthorizationType.AllowAnonymous)
                                       .AddColumns(cols =>
            {
                cols.Add("Col1").WithValueExpression(p => p.Col1);
                cols.Add("Col2").WithValueExpression(p => p.Col2);
                cols.Add("Active").WithValueExpression(p => p.Col4.ToString());

                cols.Add("Actions").WithHtmlEncoding(false).WithValueExpression((p, c) =>
                {
                    // here's how to get an action url
                    string url = UrlHelper.Action("action1", "test");

                    // build whatever html you want
                    StringBuilder sb = new StringBuilder();
                    sb.Append("<img src='action1.png' onclick='someFunction()'>");
                    sb.Append("<img src='action2.png' onclick='someFunction()'>");

                    // conditional html
                    if (p.Col4)
                    {
                        sb.Append("<img src='action3.png' onclick='someFunction()'>");
                    }

                    return(sb.ToString());
                });
            })
                                       .WithSorting(true, "Col1")
                                       .WithPaging(true, 10)
                                       .WithFiltering(true)
                                       .WithRetrieveDataMethod((context) =>
            {
                var options = context.QueryOptions;

                TestItemRepository repo = new TestItemRepository();
                int totalRecords;
                var items = repo.GetData(out totalRecords, null, options.GetLimitOffset(), options.GetLimitRowcount(), options.GetSortColumnData <string>(), options.SortDirection == SortDirection.Dsc);



                return(new QueryResult <TestItem>()
                {
                    Items = items,
                    TotalRecords = totalRecords
                });
            })
                                       );
        }
コード例 #19
0
 public JobController()
 {
     _JobRepo = new JobRepo(ConnString);
 }
コード例 #20
0
        public async Task JobsNotification()
        {
            var accrepo = AccountRepo;
            var skey    = await accrepo.RegisterUser("*****@*****.**", "123");

            var userid = await accrepo.CheckSession(skey);

            var notificationRepo = new NotificationRepo(AccountContextProvider, Logger);
            var skillRepo        = new SkillRepo(AccountContextProvider, Logger, notificationRepo);
            var pilotsRepo       = new PilotRepo(AccountContextProvider, Logger, null);
            var jobsRepo         = new JobRepo(AccountContextProvider, Logger, notificationRepo, pilotsRepo);

            // stage 1
            var userData = new UserDataDto()
            {
                Pilots = new Pilot[]
                {
                    new Pilot()
                    {
                        EveId                = 1,
                        KeyInfoId            = 1,
                        Name                 = "Pilot1",
                        Skills               = new List <Skill>(),
                        MaxManufacturingJobs = 1,
                    }
                }.ToList(),
                Corporations = new List <Corporation>(),
                Jobs         = new List <Job>(),
            };

            await pilotsRepo.Update(userid, userData);

            await jobsRepo.Update(userid, userData);

            var notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(1, notifications.Count);
            var n = notifications.First();

            Assert.AreEqual("Pilot1", n.Message);
            Assert.AreEqual("1 free manufacturing slots", n.Message2);
            await notificationRepo.Remove(n.NotificationId);

            // stage 2
            // Same info provided and expected no further notifications
            await pilotsRepo.Update(userid, userData);

            await jobsRepo.Update(userid, userData);

            notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(0, notifications.Count);
            var pilots = await pilotsRepo.GetAll(userid);

            Assert.AreEqual(1, pilots.Count);
            Assert.AreEqual(1, pilots.First().FreeManufacturingJobsNofificationCount);

            // stage 3
            // First job started - still no notification - but notification flag shoud be reset
            var userData2 = new UserDataDto()
            {
                Pilots = new Pilot[]
                {
                    new Pilot()
                    {
                        EveId                = 1,
                        KeyInfoId            = 1,
                        Name                 = "Pilot1",
                        Skills               = new List <Skill>(),
                        MaxManufacturingJobs = 1,
                    }
                }.ToList(),
                Corporations = new List <Corporation>(),
                Jobs         = new Job[]
                {
                    new Job()
                    {
                        IsManufacturing = true, Owner = "Pilot1"
                    }
                }.ToList(),
            };
            await pilotsRepo.Update(userid, userData2);

            await jobsRepo.Update(userid, userData2);

            notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(0, notifications.Count());
            pilots = await pilotsRepo.GetAll(userid);

            Assert.AreEqual(1, pilots.Count);
            Assert.AreEqual(0, pilots.First().FreeManufacturingJobsNofificationCount);

            // stage 4
            // No running jobs - notification expected
            await pilotsRepo.Update(userid, userData);

            await jobsRepo.Update(userid, userData);

            notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(1, notifications.Count());
            n = notifications.First();
            Assert.AreEqual("Pilot1", n.Message);
            Assert.AreEqual("1 free manufacturing slots", n.Message2);
            await notificationRepo.Remove(n.NotificationId);
        }
コード例 #21
0
ファイル: JobController.cs プロジェクト: gcorron/TimeCardCore
 public JobController(IConfiguration config, IWebHostEnvironment webHostEnvironment, IHttpContextAccessor httpContextAccessor) : base(config, webHostEnvironment, httpContextAccessor)
 {
     _JobRepo = new JobRepo(ConnString);
 }
コード例 #22
0
 public JobsController(RecruitmentSystemContext context, UserManager <SystemUser> userManager, JobRepo jobRepo)
 {
     _userManager = userManager;
     _jobRepo     = jobRepo;
 }
コード例 #23
0
 public HomeController()
 {
     jobRepo = new JobRepo();
 }