예제 #1
0
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// UpdateSettings saves the modified settings to the Database
    /// </summary>
    /// -----------------------------------------------------------------------------
    public override void UpdateSettings()
    {
        try
        {
            if (!string.IsNullOrEmpty(txtChallengeReference.Text))
            {
                challengeComponent = new ChallengeComponent(txtChallengeReference.Text);
            }
            else
            {
                challengeComponent = new ChallengeComponent();
            }

            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, "ChallengeReference", txtChallengeReference.Text);
            modules.UpdateModuleSetting(ModuleId, "RadEditor", RadEditor.Text);
            modules.UpdateModuleSetting(ModuleId, "PublishState", ddPublishState.SelectedValue.ToString());
            modules.UpdateModuleSetting(ModuleId, "ThemeFilter", txtThemeFilter.Text.ToString());
            modules.UpdateModuleSetting(ModuleId, "BeneficiaryFilter", txtBeneficiaryFilter.Text.ToString());

            SaveChallenge();
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
예제 #2
0
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// UpdateSettings saves the modified settings to the Database
    /// </summary>
    /// -----------------------------------------------------------------------------
    public override void UpdateSettings()
    {
        try
        {
            ModuleController modules = new ModuleController();
            if (!string.IsNullOrEmpty(txtChallengeReference.Text))
            {
                challengeComponent = new ChallengeComponent(txtChallengeReference.Text);
            }
            else
            {
                challengeComponent = new ChallengeComponent();
            }

            if (!string.IsNullOrEmpty(txtChallengeReferences.Text))
            {
                challengeReferences = txtChallengeReferences.Text;
            }
            else
            {
                challengeReferences = "";
            }


            modules.UpdateModuleSetting(ModuleId, "ChallengeReference", txtChallengeReference.Text);
            modules.UpdateModuleSetting(ModuleId, "ChallengeReferences", txtChallengeReferences.Text);
            //the following are two sample Module Settings, using the text boxes that are commented out in the ASCX file.
            //module settings
            //modules.UpdateModuleSetting(ModuleId, "Setting1", txtSetting1.Text);
            //modules.UpdateModuleSetting(ModuleId, "Setting2", txtSetting2.Text);

            //tab module settings
            //modules.UpdateTabModuleSetting(TabModuleId, "Setting1",  txtSetting1.Text);
            //modules.UpdateTabModuleSetting(TabModuleId, "Setting2",  txtSetting2.Text);
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
예제 #3
0
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// LoadSettings loads the settings from the Database and displays them
    /// </summary>
    /// -----------------------------------------------------------------------------
    public override void LoadSettings()
    {
        try
        {
            if (Settings.Contains("ChallengeReference"))
            {
                challengeComponent = new ChallengeComponent(Settings["ChallengeReference"].ToString());
            }
            else
            {
                challengeComponent = new ChallengeComponent();
            }

            if (Settings.Contains("ChallengeReferences"))
            {
                challengeReferences = (Settings["ChallengeReferences"].ToString());
            }
            else
            {
                challengeReferences = "";
            }


            if (Page.IsPostBack == false)
            {
                if (Settings.Contains("ChallengeReference"))
                {
                    txtChallengeReference.Text = Settings["ChallengeReference"].ToString();
                }
                if (Settings.Contains("ChallengeReferences"))
                {
                    txtChallengeReferences.Text = Settings["ChallengeReferences"].ToString();
                }
            }
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
예제 #4
0
파일: Edit.ascx.cs 프로젝트: OOcm1987/Nexso
    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);
        }
    }
예제 #5
0
 private void LoadSettings()
 {
     challengeReferences = new List <string>();
     if (Settings.Contains("ChallengeReference"))
     {
         if (!string.IsNullOrEmpty(Settings["ChallengeReference"].ToString()))
         {
             challengeComponent = new ChallengeComponent(Settings["ChallengeReference"].ToString());
         }
         else
         {
             challengeComponent = new ChallengeComponent();
         }
     }
     else
     {
         challengeComponent = new ChallengeComponent();
     }
     if (Settings["ChallengeReferences"] != null)
     {
         string references = Regex.Replace(Settings["ChallengeReferences"].ToString(), @"\s+", "");
         references = !string.IsNullOrEmpty(references) ? references : "";
         if (references.Contains(","))
         {
             challengeReferences = references.Split(',').ToList();
         }
         else
         {
             challengeReferences.Add(references);
         }
     }
     else
     {
         challengeReferences.Add("");
     }
 }
예제 #6
0
    protected string createContext(ChallengeCustomData challengeCustomData, ChallengePage challengePage)
    {
        //main contenxt
        NZChallengePage.ContextPage objReturn = new NZChallengePage.ContextPage();
        objReturn.ChallengeCustomDatalId = challengeCustomData.ChallengeCustomDatalId.ToString();
        objReturn.ChallengeReference     = challengeCustomData.ChallengeReference;
        objReturn.SolutionType           = solutionType;
        objReturn.Description            = challengeCustomData.Description;
        objReturn.Language = challengeCustomData.Language;
        objReturn.TagLine  = challengeCustomData.TagLine;
        objReturn.Tags     = challengeCustomData.Tags;
        objReturn.Title    = challengeCustomData.Title;
        ChallengeComponent challengeComponent = new ChallengeComponent(challengeCustomData.ChallengeReference);
        var file = challengeComponent.Challenge.ChallengeFiles.FirstOrDefault(x => x.Language == challengeCustomData.Language && x.ObjectType == "Banner Challenge" && (x.Delete == null || x.Delete == false));

        if (file != null)
        {
            objReturn.BannerImage = file.ObjectLocation;
        }


        objReturn.ChallengeSchemaContext               = new ChallengeSchemaContext();
        objReturn.ChallengeSchemaContext.Closed        = challengeCustomData.ChallengeSchema.Closed.GetValueOrDefault(DateTime.MinValue).ToString();;
        objReturn.ChallengeSchemaContext.EnterUrl      = challengeCustomData.ChallengeSchema.EnterUrl;
        objReturn.ChallengeSchemaContext.EntryFrom     = challengeCustomData.ChallengeSchema.EntryFrom.GetValueOrDefault(DateTime.MinValue).ToString();
        objReturn.ChallengeSchemaContext.EntryTo       = challengeCustomData.ChallengeSchema.EntryTo.GetValueOrDefault(DateTime.MinValue).ToString();
        objReturn.ChallengeSchemaContext.Flavor        = challengeCustomData.ChallengeSchema.Flavor;
        objReturn.ChallengeSchemaContext.Launch        = challengeCustomData.ChallengeSchema.Launch.GetValueOrDefault(DateTime.MinValue).ToString();
        objReturn.ChallengeSchemaContext.OutUrl        = challengeCustomData.ChallengeSchema.OutUrl;
        objReturn.ChallengeSchemaContext.PreLaunch     = challengeCustomData.ChallengeSchema.PreLaunch.GetValueOrDefault(DateTime.MinValue).ToString();
        objReturn.ChallengeSchemaContext.PublishType   = challengeCustomData.ChallengeSchema.PublishType;
        objReturn.ChallengeSchemaContext.ScoringL1From = challengeCustomData.ChallengeSchema.ScoringL1From.GetValueOrDefault(DateTime.MinValue).ToString();
        objReturn.ChallengeSchemaContext.ScoringL2From = challengeCustomData.ChallengeSchema.ScoringL2From.GetValueOrDefault(DateTime.MinValue).ToString();
        objReturn.ChallengeSchemaContext.Url           = challengeCustomData.ChallengeSchema.Url;

        var judgesPage = challengeCustomData.ChallengePages.SingleOrDefault(a => a.Reference == "judges");

        if (judgesPage != null)
        {
            objReturn.Judges = GetGenericObjectList(judgesPage.Content);
        }
        objReturn.Dictionary         = GetGenericListDictionary(challengeCustomData.Tags);
        objReturn.TimesLine          = GenerateTimeLine(challengeCustomData, objReturn.Dictionary);
        objReturn.CurrentPageContext = new CurrentPageContext();
        objReturn.CurrentPageContext.ChallengePageId = challengePage.ChallengePageId.ToString();
        objReturn.CurrentPageContext.Content         = challengePage.Content;
        objReturn.CurrentPageContext.ContentType     = challengePage.ContentType;
        objReturn.CurrentPageContext.Description     = challengePage.Description;
        objReturn.CurrentPageContext.Order           = challengePage.Order.GetValueOrDefault(0).ToString();
        objReturn.CurrentPageContext.Reference       = challengePage.Reference;
        objReturn.CurrentPageContext.Tagline         = challengePage.Tagline;
        objReturn.CurrentPageContext.Title           = challengePage.Title;
        objReturn.CurrentPageContext.Url             = challengePage.Url;
        objReturn.CurrentPageContext.Visibility      = challengePage.Visibility;
        objReturn.Eligibility = GetGenericElegibility(challengeCustomData.EligibilityTemplate);


        switch (challengePage.Reference)
        {
        case "judges":
        {
            objReturn.CurrentPageContext.GenericObject = objReturn.Judges;
            break;
        }

        case "faq":
        {
            objReturn.CurrentPageContext.GenericObject = GetGenericFAQ(challengePage.Content);
            break;
        }

        case "partners":
        {
            objReturn.CurrentPageContext.GenericObject = GetGenericObjectList(challengePage.Content);
            break;
        }
        }


        objReturn.PagesContext = new List <PagesContext>();


        foreach (var item in challengeCustomData.ChallengePages.OrderBy(a => a.Order))
        {
            if (item.Title != string.Empty)
            {
                objReturn.PagesContext.Add(new PagesContext
                {
                    Tagline    = item.Tagline,
                    Title      = item.Title,
                    Url        = item.Url,
                    Visibility = item.Visibility
                });
            }
        }



        return(JsonConvert.SerializeObject(objReturn));
    }
예제 #7
0
    /// -----------------------------------------------------------------------------
    /// <summary>
    /// LoadSettings loads the settings from the Database and displays them
    /// </summary>
    /// -----------------------------------------------------------------------------
    public override void LoadSettings()
    {
        try
        {
            if (Settings.Contains("ChallengeReference"))
            {
                challengeComponent = new ChallengeComponent(Settings["ChallengeReference"].ToString());
            }
            else
            {
                challengeComponent = new ChallengeComponent();
            }

            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("RadEditor"))
                {
                    RadEditor.RichText.Text        = string.Empty;
                    RadEditor.BasicTextEditor.Text = string.Empty;
                    RadEditor.Text = Settings["RadEditor"].ToString();
                }
                if (!string.IsNullOrEmpty(challengeComponent.Challenge.EntryFrom.ToString()))
                {
                    dtAvailableFrom.SelectedDate = Convert.ToDateTime(challengeComponent.Challenge.EntryFrom.ToString());
                }
                if (!string.IsNullOrEmpty(challengeComponent.Challenge.EntryTo.ToString()))
                {
                    dtAvailableTo.SelectedDate = Convert.ToDateTime(challengeComponent.Challenge.EntryTo.ToString());
                }
                if (!string.IsNullOrEmpty(challengeComponent.Challenge.Closed.ToString()))
                {
                    dtCloseDate.SelectedDate = Convert.ToDateTime(challengeComponent.Challenge.Closed.ToString());
                }

                txtChallengeTitle.Text = challengeComponent.Challenge.ChallengeTitle;
                txtTagUrl.Text         = challengeComponent.Challenge.Url;
                txtOutUrl.Text         = challengeComponent.Challenge.OutUrl;
                txtEnterUrl.Text       = challengeComponent.Challenge.EnterUrl;

                var list          = ListComponent.GetListPerCategory("Flavor", Thread.CurrentThread.CurrentCulture.Name).ToList();
                var listEmptyItem = new NexsoProDAL.List();
                listEmptyItem.Key   = "Default";
                listEmptyItem.Label = Localization.GetString("SelectItem", LocalResourceFile);
                list.Insert(0, listEmptyItem);

                ddFlavor.DataSource = list;
                ddFlavor.DataBind();

                ddFlavor.SelectedValue = challengeComponent.Challenge.Flavor;

                list                = ListComponent.GetListPerCategory("PublishState", Thread.CurrentThread.CurrentCulture.Name).ToList();
                listEmptyItem       = new NexsoProDAL.List();
                listEmptyItem.Value = "1000";
                listEmptyItem.Label = Localization.GetString("SelectItem", LocalResourceFile);
                list.Insert(0, listEmptyItem);


                ddPublishState.DataSource = list;
                ddPublishState.DataBind();


                if (Settings.Contains("PublishState"))
                {
                    ddPublishState.SelectedValue = Settings["PublishState"].ToString();
                }
                if (Settings.Contains("ThemeFilter"))
                {
                    txtThemeFilter.Text = Settings["ThemeFilter"].ToString();
                }
                if (Settings.Contains("BeneficiaryFilter"))
                {
                    txtBeneficiaryFilter.Text = Settings["BeneficiaryFilter"].ToString();
                }
            }
        }
        catch (Exception exc) //Module failed to load
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }
예제 #8
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));
            }
        }