Example #1
0
        /// <summary>
        /// contestId must be set in the url
        /// </summary>
        /// <returns></returns>
        string GetContestEnties()
        {
            if (HttpContext.Current.Request["contestid"] == null)
            {
                return("");
            }
            AWAPI_BusinessLibrary.library.ContestLibrary lib = new AWAPI_BusinessLibrary.library.ContestLibrary();
            long contestId = Convert.ToInt64(HttpContext.Current.Request["contestid"]);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();


            //GET CONTEST IFNO
            AWAPI_Data.CustomEntities.ContestExtended contest = lib.GetContest(contestId, false);
            if (contest == null)
            {
                return("");
            }
            sb.Append("Contest entries report\n");
            sb.AppendFormat("Report date:,{0}\n\n", DateTime.Now);

            sb.AppendFormat("ContestId:,{0}\n", contest.contestId.ToString());
            sb.AppendFormat("Name:,{0}\n", contest.title);
            sb.AppendFormat("Description:,{0}\n", contest.description.Replace(",", " ").Replace("\n", " ")).Replace("\"", " ");;
            sb.AppendFormat("StartDate:,{0}\n", contest.pubDate);
            sb.AppendFormat("EndDate:,{0}\n", contest.pubEndDate);

            sb.Append("\n");
            IList <AWAPI_Data.CustomEntities.ContestEntryExtended> list = lib.GetContestEntryList(contestId);

            if (list == null || list.Count == 0)
            {
                return("");
            }

            sb.Append("entryId,isEnabled,cultureCode,email,firstName,lastName,title, " +
                      "fileUrl,phone,phoneType,address,city,province," +
                      "postalCode,country,createDate,description\n");
            foreach (AWAPI_Data.CustomEntities.ContestEntryExtended c in list)
            {
                c.email       = c.email == null ? "" : c.email.Replace(",", " ").Replace("\"", " ");
                c.firstName   = c.firstName == null ? "" : c.firstName.Replace(",", " ").Replace("\"", " ");;
                c.lastName    = c.lastName == null ? "" : c.lastName.Replace(",", " ").Replace("\"", " ");;
                c.title       = c.title == null ? "" : c.title.Replace(",", " ").Replace("\"", " ");;
                c.fileUrl     = c.fileUrl == null ? "" : c.fileUrl.Replace(",", " ").Replace("\"", " ");;
                c.tel         = c.tel == null ? "" : c.tel.Replace(",", " ").Replace("\"", " ");;
                c.telType     = c.telType == null ? "" : c.telType.Replace(",", " ").Replace("\"", " ");;
                c.address     = c.address == null ? "" : c.address.Replace(",", " ").Replace("\"", " ");;
                c.city        = c.city == null ? "" : c.city.Replace(",", " ").Replace("\"", " ");;
                c.province    = c.province == null ? "" : c.province.Replace(",", " ").Replace("\"", " ");;
                c.postalCode  = c.postalCode == null ? "" : c.postalCode.Replace(",", " ").Replace("\"", " ");;
                c.country     = c.country == null ? "" : c.country.Replace(",", " ").Replace("\"", " ");;
                c.description = c.description == null ? "" : c.description.Replace(",", " ").Replace("\n", " ").Replace("\r", "").Replace("\"", " ");;

                sb.AppendFormat("{0},{1},{2},{3},{4},{5}," +
                                "{6},{7},{8},{9},{10},{11},{12}," +
                                "{13},{14},{15},{16}",
                                c.contestEntryId, c.isEnabled, c.cultureCode, c.email.Replace(",", " "),
                                c.firstName.Replace(",", " "),
                                c.lastName.Replace(",", " "),
                                c.title.Replace(",", " "),
                                c.fileUrl.Replace(",", " "),
                                c.tel.Replace(",", " "),
                                c.telType.Replace(",", " "),
                                c.address.Replace(",", " "),
                                c.city.Replace(",", " "),
                                c.province.Replace(",", " "),
                                c.postalCode.Replace(",", " "),
                                c.country.Replace(",", " "),
                                c.createDate,
                                c.description.Replace(",", " ").Replace("\n", " ").Replace("\r", "") + "\n");
            }

            return(sb.ToString());
        }
Example #2
0
        void PopulateList(string sortName)
        {
            _todaysEntries.Text = "0";
            _totalEntries.Text  = "0";

            _list.DataSource = null;
            IList <AWAPI_Data.CustomEntities.ContestEntryExtended> lst = null;

            if (GroupId > 0)
            {
                lst = _contestLib.GetContestEntryListByGroupId(GroupId, _keywordSearch.Text.Trim().ToLower(), null);
            }
            else
            {
                lst = _contestLib.GetContestEntryList(ContestId, null, _keywordSearch.Text.Trim().ToLower(), null);
            }

            if (lst != null)
            {
                switch (sortName.ToLower())
                {
                case "email":
                    if (_sortDirection == SortDirection.Ascending)
                    {
                        _list.DataSource = lst.OrderBy(l => l.email).ToArray();
                    }
                    else
                    {
                        _list.DataSource = lst.OrderByDescending(l => l.email).ToArray();
                    }
                    break;

                case "firstname":
                    if (_sortDirection == SortDirection.Ascending)
                    {
                        _list.DataSource = lst.OrderBy(l => l.firstName).ToArray();
                    }
                    else
                    {
                        _list.DataSource = lst.OrderByDescending(l => l.firstName).ToArray();
                    }
                    break;

                case "lastname":
                    if (_sortDirection == SortDirection.Ascending)
                    {
                        _list.DataSource = lst.OrderBy(l => l.lastName).ToArray();
                    }
                    else
                    {
                        _list.DataSource = lst.OrderByDescending(l => l.lastName).ToArray();
                    }
                    break;

                case "createdate":
                    if (_sortDirection == SortDirection.Ascending)
                    {
                        _list.DataSource = lst.OrderBy(l => l.createDate).ToArray();
                    }
                    else
                    {
                        _list.DataSource = lst.OrderByDescending(l => l.createDate).ToArray();
                    }
                    break;

                default:
                    _list.DataSource = lst;
                    break;
                }

                if (lst != null)
                {
                    _totalEntries.Text = lst.Count.ToString();

                    DateTime dtTodayStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                    var      list2        = from l in lst
                                            where l.createDate > dtTodayStart && l.createDate <= DateTime.Now
                                            select l;
                    if (list2 != null)
                    {
                        _todaysEntries.Text = list2.Count().ToString();
                    }
                }
            }
            _list.DataBind();
        }