Пример #1
0
    /// <summary>
    /// Load ChallengePageComponent from database
    /// </summary>
    private void LoadContext()
    {
        var challengeCustomDataComponent = new ChallengeCustomDataComponent(challengeReference, Thread.CurrentThread.CurrentCulture.Name);
        var page = new ChallengePageComponent(challengeCustomDataComponent.ChallengeCustomData.ChallengeCustomDatalId, pageReference);

        jsonData = createContext(challengeCustomDataComponent.ChallengeCustomData, page.ChallengePage);
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //The object of the solution is obtained
            if (Settings.Contains("ChallengeReference"))
            {
                challengeCustomDataComponent = new ChallengeCustomDataComponent(Settings["ChallengeReference"].ToString(), Language);
            }
            else
            {
                challengeCustomDataComponent = new ChallengeCustomDataComponent();
            }

            //The object of the corresponding solution is obtained
            solutionComponent = new SolutionComponent(SolutionId);
            if (!IsPostBack)
            {
                RegisterScripts();
                //data upload
                FillData();
            }
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
Пример #3
0
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// UpdateSettings saves the modified settings to the Database
    /// </summary>
    /// -----------------------------------------------------------------------------
    public override void UpdateSettings()
    {
        try
        {
            var modules = new ModuleController();

            //the following are two sample Module Settings, using the text boxes that are commented out in the ASCX file.
            //module settings
            modules.UpdateModuleSetting(ModuleId, "RedirectPage", txtRedirectPage.Text);
            modules.UpdateModuleSetting(ModuleId, "ButtonText", txtButtonText.Text);
            modules.UpdateModuleSetting(ModuleId, "ChallengeReference", txtChallengeReference.Text);

            challengeCustomDataComponent = new ChallengeCustomDataComponent(Settings["ChallengeReference"].ToString(), Language);
            SaveChallengeCustomData();
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
Пример #4
0
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// LoadSettings loads the settings from the Database and displays them
    /// </summary>
    /// -----------------------------------------------------------------------------
    public override void LoadSettings()
    {
        try
        {
            if (Settings.Contains("ChallengeReference"))
            {
                challengeCustomDataComponent = new ChallengeCustomDataComponent(Settings["ChallengeReference"].ToString(), Language);
            }
            else
            {
                challengeCustomDataComponent = new ChallengeCustomDataComponent();
            }

            if (Page.IsPostBack == false)
            {
                //Check for existing settings and use those on this page
                //Settings["SettingName"]

                if (Settings.Contains("ChallengeReference"))
                {
                    txtChallengeReference.Text = Settings["ChallengeReference"].ToString();
                }

                if (Settings.Contains("RedirectPage"))
                {
                    txtRedirectPage.Text = Settings["RedirectPage"].ToString();
                }

                if (Settings.Contains("ButtonText"))
                {
                    txtButtonText.Text = Settings["ButtonText"].ToString();
                }

                fillData();
            }
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
Пример #5
0
    protected void Page_Load(System.Object sender, System.EventArgs e)
    {
        try
        {
            bool sw = false;
            if (Settings.Contains("ChallengeReference"))
            {
                challengeComponent = new ChallengeComponent(Settings["ChallengeReference"].ToString());
                if (!string.IsNullOrEmpty(challengeComponent.Challenge.ChallengeReference))
                {
                    challengeCustomDataComponent = new ChallengeCustomDataComponent(challengeComponent.Challenge.ChallengeReference, Language);
                    sw = true;
                }
            }

            if (!sw)
            {
                challengeCustomDataComponent = new ChallengeCustomDataComponent();
                challengeComponent           = new ChallengeComponent();
            }

            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(challengeCustomDataComponent.ChallengeCustomData.CustomDataTemplate))
                {
                    txtCustomDataTemplate.Text = challengeCustomDataComponent.ChallengeCustomData.CustomDataTemplate.ToString();
                }
                if (!string.IsNullOrEmpty(challengeCustomDataComponent.ChallengeCustomData.Scoring))
                {
                    TxtScoring.Text = challengeCustomDataComponent.ChallengeCustomData.Scoring.ToString();
                }
            }
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
Пример #6
0
        public List <ChallengeModel> GetList(string language = "en-US", int rows = 10, int page = 0, string brand = "")
        {
            try
            {
                IOrderedQueryable <ChallengeSchema> result = null;
                if (string.IsNullOrEmpty(brand))
                {
                    result = ChallengeComponent.GetChallengesFront().OrderByDescending(x => x.EntryTo);
                }
                else
                {
                    result = ChallengeComponent.GetChallengesFront(brand).OrderByDescending(x => x.EntryTo);
                }

                var totalCount = result.Count();
                var totalPages = (int)Math.Ceiling((double)totalCount / rows);


                var prevLink = page > 0 ? string.Format("/Challenges/GetList?rows={0}&page={1}", rows, page - 1) : "";
                var nextLink = page < totalPages - 1 ? string.Format("/Challenges/GetList?rows={0}&page={1}", rows, page + 1) : "";
                List <ChallengeModel> ChallengeModel = new List <ChallengeModel>();

                foreach (var resultTmp in result.Skip(rows * page).Take(rows).ToList())
                {
                    var challengeCustomDataComponent = new ChallengeCustomDataComponent(resultTmp.ChallengeReference, language);


                    var isOpen = true;


                    if (!string.IsNullOrEmpty(resultTmp.EntryFrom.ToString()) && !string.IsNullOrEmpty(resultTmp.EntryTo.ToString()))
                    {
                        if (!(Convert.ToDateTime(resultTmp.EntryFrom) < DateTime.Now && Convert.ToDateTime(resultTmp.EntryTo) > DateTime.Now))
                        {
                            isOpen = false;
                        }
                    }


                    var    Open           = Convert.ToDateTime(resultTmp.EntryFrom.GetValueOrDefault());
                    var    Close          = Convert.ToDateTime(resultTmp.EntryTo.GetValueOrDefault());
                    string dateValueOpen  = Open.ToString("MMM dd, yyyy", new CultureInfo(language, false));
                    string dateValueClose = Close.ToString("MMM dd, yyyy", new CultureInfo(language, false));



                    ChallengeModel.Add(new ChallengeModel()
                    {
                        ChallengeReference = resultTmp.ChallengeReference,
                        Title        = challengeCustomDataComponent.ChallengeCustomData.Title,
                        Description  = challengeCustomDataComponent.ChallengeCustomData.Description,
                        Open         = dateValueOpen,
                        Close        = dateValueClose,
                        IfOpen       = isOpen,
                        UrlBanner    = challengeCustomDataComponent.ChallengeCustomData.BannerFront,
                        UrlChallenge = challengeCustomDataComponent.ChallengeCustomData.UrlChallengeFront
                    });
                }

                var paginationHeader = new
                {
                    TotalCount   = totalCount,
                    TotalPages   = totalPages,
                    PrevPageLink = prevLink,
                    NextPageLink = nextLink
                };

                System.Web.HttpContext.Current.Response.Headers.Add("X-Pagination",
                                                                    Newtonsoft.Json.JsonConvert.SerializeObject(paginationHeader));

                return(ChallengeModel);
            }
            catch (HttpResponseException e)
            {
                throw e;
            }
            catch (Exception ee)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ee);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }