Пример #1
0
        public void addLoadedCampaign(string name, string t, string currentDate)
        {
            // since the constructor of campaign requires start date (then adds a note of start date)
            // we have to start a blank campaign and add to that, kinda gross but whatev
            Campaign loadedCampaign = new Campaign(IDManager);

            loadedCampaign.Name        = name;
            loadedCampaign.Tag         = t;
            loadedCampaign.CurrentDate = currentDate;
            CampaignList.Add(loadedCampaign);
        }
Пример #2
0
        protected override void OnShutdown()
        {
            Game.Screen.Elements.Remove(m_campaigns);
            m_campaigns.Dispose();
            m_campaigns = null;

            Game.Screen.Elements.Remove(m_footer);
            m_footer.Dispose();
            m_footer = null;

            base.OnShutdown();
        }
Пример #3
0
        public async Task <IActionResult> GetCampaignsAsync([FromQuery] CampaignGetModel model)
        {
            model.Validate();

            var list = await _campaignRepository.GetCampaignsAsync(model.Keyword, model.Category, model.Type, model.DateType, model.Period, model.Page, model.PageSize);

            if (list == null)
            {
                throw new NotFound400Exception("page");
            }

            return(Ok(CampaignList.GetFrom(list)));
        }
Пример #4
0
        public Campaign setActiveCampaign(Campaign c)
        {
            if (CampaignList.Contains(c))
            {
                ActiveCampaign = c;
                var splitDate = ActiveCampaign.CurrentDate.Split(",");
                calendar = new HarptosCalendar(Int32.Parse(splitDate[0]), Int32.Parse(splitDate[1]), Int32.Parse(splitDate[2]));
            }
            else
            {
                ActiveCampaign = null;
            }

            return(ActiveCampaign);
        }
Пример #5
0
        public CampaignSelectState(Game game, Mod mod = null) : base(game, "menus.campaign_select.title", "levels/empty.level", MenuArrangement.FullScreen)
        {
            m_editor      = (mod != null);
            m_mod         = mod;
            EnableGamepad = !m_editor;

            m_footer               = new ModDownloadStatusText(UIFonts.Smaller, UIColours.Text, TextAlignment.Center);
            m_footer.Anchor        = Anchor.BottomMiddle;
            m_footer.LocalPosition = new Vector2(0.0f, -2.0f * UIFonts.Smaller.Height);

            m_campaigns               = new CampaignList(Game.Screen.Height * 1.3f, game, m_mod);
            m_campaigns.Anchor        = Anchor.CentreMiddle;
            m_campaigns.LocalPosition = new Vector2(-0.5f * m_campaigns.Width, -0.5f * m_campaigns.Height);
            m_campaigns.OnSelection  += delegate(object sender, CampaignEventArgs e)
            {
                OpenCampaign(e.Campaign, e.Mod);
            };
            m_campaigns.OnAction += delegate(object sender, CampaignActionEventArgs e)
            {
                switch (e.Action)
                {
                case CampaignThumbnailAction.Delete:
                {
                    DeleteCampaign(e.Campaign, e.Mod);
                    break;
                }

                case CampaignThumbnailAction.Edit:
                {
                    ShowGamepadWarningThen(delegate()
                        {
                            EditMod(e.Mod);
                        });
                    break;
                }

                case CampaignThumbnailAction.ShowInWorkshop:
                {
                    ShowWorkshopInfo(e.Mod);
                    break;
                }
                }
            };
            m_campaigns.OnBrowseWorkshop += delegate(object sender, EventArgs e)
            {
                if (!m_editor)
                {
                    BrowseWorkshop();
                }
            };
            m_campaigns.OnOpenModsFolder += delegate(object sender, EventArgs e)
            {
                if (!m_editor)
                {
                    OpenModsFolder();
                }
            };
            m_campaigns.OnCreateCampaign += delegate(object sender, EventArgs e)
            {
                if (m_editor)
                {
                    CreateCampaign();
                }
            };
        }
Пример #6
0
 public CampaignListTests()
 {
     repoMock     = new Mock <CampaignRepo>(null);
     campaignList = new CampaignList(repoMock.Object);
 }
Пример #7
0
        // clcondition = CampaignList Condition
        public List<Model.EF.Campaign> GetCampaignList(CampaignList condition, out int total, int company_id)
        {
            using (var scope = new DbContextScope(DbContextScopePurpose.Reading))
            {
                var query = this.RepoCampaign.Find().Where(q => q.AcctCompanyID == company_id);
                query = query.AsQueryable().Include(q => q.CampaignTag.Select(w => w.TagInfo)).Include(q => q.CampaignType)
                    .OrderByDescending(q => q.CampaignID);

                if (condition.TypeID.HasValue)
                {
                    query = query.Where(q => q.TypeID == condition.TypeID.Value);
                }

                if (!string.IsNullOrEmpty(condition.Sort))
                {
                    query = query.AsQueryable().Sort(condition.Sort);
                }

                if (condition.DateStart.HasValue)
                {
                    query = query.Where(q => q.DateStart >= condition.DateStart.Value);
                }

                if (condition.DateEnd.HasValue)
                {
                    query = query.Where(q => q.DateStart <= condition.DateEnd);
                }

                if (!string.IsNullOrEmpty(condition.Keyword))
                {
                    query = query.Where(q => q.Name.ToUpper().Contains(condition.Keyword.ToUpper())
                        || q.CampaignTag.Any(w => w.TagInfo.TagName.ToUpper().Contains(condition.Keyword.ToUpper())));
                }

                if (condition.StatusID.HasValue)
                {
                    query = query.Where(q => q.CampStatus == condition.StatusID);
                }

                if (!string.IsNullOrEmpty(condition.Sort))
                {
                    bool isAsc = condition.Sort.StartsWith("+");

                    switch (condition.Sort.ToLower().Replace("+", string.Empty).Replace("-", string.Empty))
                    {
                        case "camp_status_id":
                            if (isAsc)
                            {
                                query = query.OrderBy(q => q.CampStatus);
                            }
                            else
                            {
                                query = query.OrderByDescending(q => q.CampStatus);
                            }

                            break;
                        case "campaign_id":
                            if (isAsc)
                            {
                                query = query.OrderBy(q => q.CampaignID);
                            }
                            else
                            {
                                query = query.OrderByDescending(q => q.CampaignID);
                            }

                            break;
                        case "date_end":
                            if (isAsc)
                            {
                                query = query.OrderBy(q => q.DateEnd);
                            }
                            else
                            {
                                query = query.OrderByDescending(q => q.DateEnd);
                            }

                            break;
                        case "date_start":
                            if (isAsc)
                            {
                                query = query.OrderBy(q => q.DateStart);
                            }
                            else
                            {
                                query = query.OrderByDescending(q => q.DateStart);
                            }

                            break;
                        case "name":
                            if (isAsc)
                            {
                                query = query.OrderBy(q => q.Name);
                            }
                            else
                            {
                                query = query.OrderByDescending(q => q.Name);
                            }

                            break;
                        case "type_id":
                            if (isAsc)
                            {
                                query = query.OrderBy(q => q.TypeID);
                            }
                            else
                            {
                                query = query.OrderByDescending(q => q.TypeID);
                            }

                            break;
                    }
                }

                if (!condition.Limit.HasValue)
                {
                    condition.Limit = 10;
                }

                if (!condition.Offset.HasValue)
                {
                    condition.Offset = 0;
                }

                query = query.AsQueryable().Paged(condition.Offset.Value, condition.Limit.Value, out total);

                var result = query.ToList();

                //// 如果沒有做以下的Code的話會沒辦法找到TagInfo 會Disposed掉,導致無法

                var langKeyList = this.RepoLangKey.Find().Where(q => q.Local == "zh-TW").ToList();
                result.ForEach(campaign =>
                {
                    campaign.CampaignType = campaign.CampaignType;
                    var lang = langKeyList.FirstOrDefault(q => q.Key == campaign.CampaignType.LanguageKey);
                    if (lang != null)
                    {
                        campaign.CampaignType.LanguageKey = lang.Word;
                    }

                    campaign.CampaignTag.ToList().ForEach(campaignTag => campaignTag.TagInfo = campaignTag.TagInfo);
                });
                return result;
            }
        }
Пример #8
0
        public void addNewCampaign(string name, string t, string startDate)
        {
            Campaign newCampaign = new Campaign(name, t, startDate, IDManager);

            CampaignList.Add(newCampaign);
        }
Пример #9
0
 public Campaign setActiveCampaign(string tag)
 {
     return(setActiveCampaign(CampaignList.FindIndex(c => c.Tag == tag)));
 }
Пример #10
0
 public int numOfCampaigns()
 {
     return(CampaignList.Count());
 }
Пример #11
0
 public bool deleteCampaign(string tag)
 {
     return(CampaignList.Remove(CampaignList.Find(x => x.Tag == tag)));
 }
Пример #12
0
 public void AddCampaign(Campaign c)
 {
     CampaignList.Add(c);
 }
Пример #13
0
 public ProjectApiController(CampaignList campaignList, ProjectList projectList, LocationService locationService)
 {
     this.campaignList    = campaignList;
     this.projectList     = projectList;
     this.locationService = locationService;
 }
Пример #14
0
        private Negotiator GetCampaignList(ReqGetCampaignList req)
        {
            if (req.date_start.HasValue && req.date_end.HasValue)
            {
                if (req.date_start.Value > req.date_end.Value)
                {
                    return Negotiate.WithOnlyJson(new RspFrame(CustomStatusCode.不正確的參數));
                }
            }

            var reqProp = new CampaignList()
            {
                TypeID = req.type_id,
                DateStart = req.date_start,
                DateEnd = req.date_end,
                Offset = req.offset,
                Limit = req.limit,
                Keyword = req.keyword,
                Sort = req.sort,
                StatusID = req.camp_status
            };

            int total = 0;
            var camps = this.CampaignService.GetCampaignList(reqProp, out total, this.GetCurrentUser().AccountCompanyID);

            return Negotiate.WithOnlyJson(
                new RspCampaignList(CustomStatusCode.OK, Nancy.HttpStatusCode.OK.ToString(), camps, total), CustomStatusCode.OK);
        }
Пример #15
0
 public HomeController(CampaignList campaign, ProjectList project)
 {
     this.campaignList = campaign;
     this.projectList  = project;
 }
Пример #16
0
 public CampaignListVM()
 {
     campaignList      = CampaignList.Inst;
     CmdAddNewCampagin = new RelayCommand(AddNewCampaign);
 }