Example #1
0
        public static List <PageDataModel> GetBlogPages()
        {
            List <PageDataModel> pages = new List <PageDataModel>();

            MySqlConnection  connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]);
            MySqlDataAdapter adapter    = new MySqlDataAdapter("GetBlogPages", connection);
            DataTable        results    = new DataTable();

            adapter.Fill(results);

            foreach (DataRow item in results.Rows)
            {
                PageDataModel page = new PageDataModel();

                page.ID            = Convert.ToInt32(item["ID"]);
                page.Name          = Convert.ToString(item["Name"]);
                page.Content       = Convert.ToString(item["Content"]);
                page.FeaturedImage = Convert.ToString(item["FeaturedImage"]);
                page.MainImage     = Convert.ToString(item["MainImage"]);
                if (item["Blog"].GetType() != typeof(DBNull))
                {
                    page.Blog = Convert.ToBoolean(item["Blog"]);
                }
                page.Metakeywords    = Convert.ToString(item["Metakeywords"]);
                page.MetaDescription = Convert.ToString(item["MetaDescription"]);

                pages.Add(page);
            }

            return(pages);
        }
Example #2
0
        public IActionResult Dynamic()
        {
            dataModel = new PageDataModel();

            var countryData = Integration.GetDropdownValues(2020);

            if (countryData.Status)
            {
                dataModel.Country = countryData.Result;
            }
            else
            {
                ViewBag.CountryError = countryData.Message;
            }
            var paymenyData = Integration.GetDropdownValues(17055);

            if (paymenyData.Status)
            {
                dataModel.PaymentMethods = paymenyData.Result;
            }
            else
            {
                ViewBag.CountryError = paymenyData.Message;
            }

            return(View(dataModel));
        }
Example #3
0
        public ActionResult MyClubsData(int page, int limit)
        {
            List <UserClubModel> datas = new List <UserClubModel>();

            foreach (UserClubs uc in db.UserClubs.Where(u => u.User.UserId == User.Identity.Name && u.State < (int)EnumState.已失效).OrderBy(c => c.Id).Skip((page - 1) * limit).Take(limit).ToList())
            {
                UserClubModel data = new UserClubModel()
                {
                    Id         = uc.Id,
                    UserId     = uc.User.UserId,
                    User       = uc.User.UserName,
                    ClubId     = uc.Club.ClubId,
                    Club       = uc.Club.Name,
                    Status     = Enum.GetName(typeof(UCStatus), uc.Status),
                    CreateDate = uc.CreateDate == null ? "未知" : uc.CreateDate.ToString(),
                    Desc       = uc.Desc,
                    Enable     = uc.State,
                    state      = uc.Club.State ?? 0
                };
                data.CState = Enum.GetName(typeof(EnumState), uc.Club.State);
                datas.Add(data);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = db.UserClubs.Where(u => u.User.UserId == User.Identity.Name).Count(),
                data  = datas.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public ActionResult GetNoticeListData(int page)
        {
            int count = 6;//单页显示数量
            IQueryable <Notice> notices = db.Notices.OrderByDescending(a => a.Id).Skip((page - 1) * count).Take(count);
            List <NoticeView>   models  = new List <NoticeView>();

            foreach (Notice n in notices)
            {
                NoticeView nv = new NoticeView
                {
                    Id         = n.Id,
                    type       = n.type,
                    Title1     = n.Title1,
                    Content    = n.Content,
                    CreateDate = n.CreateDate.ToLongDateString(),
                };
                models.Add(nv);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = (int)Math.Ceiling((double)db.Notices.Count() / count),
                data  = models.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        //查询社团调用
        public ActionResult GetAllClubData(int page, int limit)
        {
            List <ClubListModel> datas = new List <ClubListModel>();

            foreach (ClubNumber club in db.ClubNumbers.Where(c => c.State > (int)EnumState.待审批).OrderBy(c => c.ClubId).Skip((page - 1) * limit).Take(limit).ToList())
            {
                ClubListModel data = new ClubListModel()
                {
                    cid            = club.ClubId,
                    name           = club.Name ?? "无",
                    Desc           = club.Desc ?? "无",
                    CreateDate     = club.CreateDate2?.ToString(),
                    CreateUser     = club.User?.UserId,
                    CreateUserName = club.User?.UserName
                };
                datas.Add(data);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = db.Users.Count(),
                data  = datas.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public ActionResult GetActiveListData2(int page, int limit, string cid)
        {
            List <ActiveListModel>  models = new List <ActiveListModel>();
            IQueryable <Activities> actlist;

            if (string.IsNullOrEmpty(cid))
            {
                actlist = db.Activities.OrderByDescending(a => a.Id).Skip((page - 1) * limit).Take(limit);
            }
            else
            {
                actlist = db.Activities.Where(a => a.Club.ClubId == cid).OrderByDescending(a => a.Id).Skip((page - 1) * limit).Take(limit);
            }
            foreach (Activities act in actlist)
            {
                ActiveListModel model = new ActiveListModel()
                {
                    Id         = act.Id,
                    Title1     = act.Title1,
                    Title2     = act.Title2,
                    Time1      = act.Time1.ToString("yyyy/MM/dd hh:mm"),
                    Time2      = act.Time2.ToString("yyyy/MM/dd hh:mm"),
                    CreateDate = act.CreateDate.ToString(),
                    UserID     = act.User.UserId,
                    UserName   = act.User.UserName,
                    VoteCount  = db.Votings.Where(v => v.Active.Id == act.Id).Count().ToString(),
                    State      = Enum.GetName(typeof(ActiveState), act.State),
                    Votes0     = string.IsNullOrEmpty(act.Votes0) ? "0" : act.Votes0
                };
                if (act.State > (int)ActiveState.已取消)
                {
                    if (act.Time1 > DateTime.Now)
                    {
                        model.State = "未开始";
                    }
                    else if (act.Time2 > DateTime.Now)
                    {
                        model.State = "进行中";
                    }
                    else
                    {
                        model.State = "已结束";
                    }
                }

                models.Add(model);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = db.Activities.Count(),
                data  = models.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #7
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public ActionResult UserList(int currentPage, int pageSize)
        {
            var users = UserManager.Users.Skip(currentPage).Take(pageSize).ToList();
            PageDataModel <TUser> dataList = new PageDataModel <TUser>();

            dataList.DataList    = users;
            dataList.PageNum     = currentPage;
            dataList.PageSize    = pageSize;
            dataList.RecordCount = UserManager.Users.Count();
            return(View(dataList));
        }
Example #8
0
        public static void Create(PageDataModel page)
        {
            if (page.fileFeaturedImage != null)
            {
                page.FeaturedImage = FileManager.SaveFile(page.fileFeaturedImage);
            }
            if (page.fileMainImage != null)
            {
                page.MainImage = FileManager.SaveFile(page.fileMainImage);
            }

            PageDAL.Create(page);
        }
        public PageDataModel <OrderDataModel> GetOrdersPage(DataFilterBase filter)
        {
            var count  = _dbContext.Orders.Count();
            var orders = _dbContext.Orders
                         .AsNoTracking()
                         .OrderByDescending(o => o.CreatedDateTime)
                         .Skip(filter.Skip)
                         .Take(filter.Take)
                         .ToList();
            var result = new PageDataModel <OrderDataModel>(count, orders);

            return(result);
        }
Example #10
0
        public IPageDataModel CreatePageDataModel()
        {
            IPageDataModel Data = new PageDataModel();

            Schools currentSchools = GetCurrentSchools();

            CreateHeader(Data, TitleMessage);

            StatusMessage = $"  Start {CurrentIndex} of {MaxIndex}";
            CreateDataContentStrings(Data, currentSchools, currentSchools.schools.Length);

            return(Data);
        }
Example #11
0
        public ActionResult PageData(int page, int limit)
        {
            var           userdata = db.UserNumbers.OrderBy(u => u.UserId).Skip((page - 1) * limit).Take(limit);
            PageDataModel model    = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = db.UserNumbers.Count(),
                data  = userdata
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        string getKey(int i, string KEY_FIELD_NAME, string DATASOURCE_NAME, PageDataModel pageModel, EntityRecord record)
        {
            string key = "";

            if (KEY_FIELD_NAME.Contains("$"))
            {
                key = pageModel.GetProperty(DATASOURCE_NAME + "[" + i + "]." + KEY_FIELD_NAME).ToString();
            }
            else
            {
                key = record[KEY_FIELD_NAME].ToString();
            }
            return(key);
        }
        string getValue(int i, string VALUE_FIELD_NAME, string DATASOURCE_NAME, PageDataModel pageModel, EntityRecord record)
        {
            string value = "";

            if (VALUE_FIELD_NAME.Contains("$"))
            {
                value = pageModel.GetProperty(DATASOURCE_NAME + "[" + i + "]." + VALUE_FIELD_NAME).ToString();
            }
            else
            {
                value = record[VALUE_FIELD_NAME].ToString();
            }
            return(value);
        }
Example #14
0
        public IPageDataModel CreatePageDataModel(int nextIndex)
        {
            IPageDataModel Data = new PageDataModel();

            Schools currentSchools = GetCurrentSchools(nextIndex);

            CreateHeader(Data, TitleMessage);
            StatusMessage = $"  Start {CurrentIndex} of {MaxIndex}";

            int count = GetCount(currentSchools, MaxIndexPerPage);

            CreateDataContentStrings(Data, currentSchools, count);

            return(Data);
        }
Example #15
0
        public static void Update(PageDataModel page)
        {
            MySqlConnection  connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]);
            MySqlDataAdapter adapter    = new MySqlDataAdapter("UpdatePage", connection);

            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;


            MySqlParameter paramID = new MySqlParameter("pID", page.ID);

            paramID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramID);
            MySqlParameter paramName = new MySqlParameter("pName", page.Name);

            paramName.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramName);
            MySqlParameter paramContent = new MySqlParameter("pContent", page.Content);

            paramContent.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramContent);
            MySqlParameter paramFeaturedImage = new MySqlParameter("pFeaturedImage", page.FeaturedImage);

            paramFeaturedImage.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramFeaturedImage);
            MySqlParameter paramMainImage = new MySqlParameter("pMainImage", page.MainImage);

            paramMainImage.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramMainImage);
            MySqlParameter paramBlog = new MySqlParameter("pBlog", page.Blog);

            paramBlog.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramBlog);
            MySqlParameter paramMetakeywords = new MySqlParameter("pMetakeywords", page.Metakeywords);

            paramMetakeywords.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramMetakeywords);
            MySqlParameter paramMetaDescription = new MySqlParameter("pMetaDescription", page.MetaDescription);

            paramMetaDescription.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramMetaDescription);

            DataTable results = new DataTable();

            adapter.Fill(results);
        }
Example #16
0
        public PageDataModel <CountryDataModel> GetCountriesPage(CountryDataFilter filter)
        {
            var filteredCountries = _dbContext.Countries
                                    .Include(t => t.CountryImages)
                                    .OrderBy(t => t.Category)
                                    .ThenBy(t => t.Name)
                                    .Where(t => string.IsNullOrWhiteSpace(filter.TourType) || t.Category == filter.TourType);

            var count          = filteredCountries.Count();
            var pageCollection = filteredCountries
                                 .Skip(filter.Skip)
                                 .Take(filter.Take)
                                 .AsNoTracking()
                                 .ToList();

            var result = new PageDataModel <CountryDataModel>(count, pageCollection);

            return(result);
        }
        public List <PageDataModel> Convert(List <PageData> pageDataList)
        {
            List <PageDataModel> list = new List <PageDataModel>();

            foreach (var page in pageDataList)
            {
                PageDataModel model = new PageDataModel();
                model.angle     = page.Angle;
                model.height    = page.Height;
                model.isVisible = page.IsVisible;
                model.name      = page.Name;
                model.number    = page.Number;
                model.rows      = page.Rows;
                model.width     = page.Width;
                list.Add(model);
            }

            return(list);
        }
Example #18
0
        // GET: GetData 获取已注册用户,权限控制页面调用
        public async Task <ActionResult> UserSimpleData(int page, int limit)
        {
            List <UserSimpleModel> datas = new List <UserSimpleModel>();

            foreach (AppUser us in db.Users.OrderBy(u => u.Id).Skip((page - 1) * limit).Take(limit).ToList())
            {
                UserSimpleModel data = new UserSimpleModel()
                {
                    id   = us.UserName,
                    name = us.Email,
                    ifup = true,
                };
                if (us.Roles.Count > 0)
                {
                    foreach (Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole userrole in us.Roles)
                    {
                        var role = await RoleManager.FindByIdAsync(userrole.RoleId);

                        data.roles += role.Name + "/";
                        if (role.Name == "BAdmin")
                        {
                            data.ifup = false;
                        }
                    }
                    data.roles = data.roles.Substring(0, data.roles.Length - 1);
                }
                else
                {
                    data.roles = "无";
                }
                datas.Add(data);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = db.Users.Count(),
                data  = datas.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #19
0
        public static void Update(PageDataModel page)
        {
            if (page.ID > 0)
            {
                if (page.fileFeaturedImage != null)
                {
                    page.FeaturedImage = FileManager.SaveFile(page.fileFeaturedImage);
                }
                if (page.fileMainImage != null)
                {
                    page.MainImage = FileManager.SaveFile(page.fileMainImage);
                }

                PageDAL.Update(page);
            }
            else
            {
                throw new Exception("Page not found");
            }
        }
Example #20
0
        public ActionResult GetApplyData(int page, int limit, string state)
        {
            List <ApplyAudit> models = new List <ApplyAudit>();
            int st = 0;

            if (!string.IsNullOrEmpty(state) && int.TryParse(state, out st))
            {
                models = db.ApplyAudits.Where(a => a.Type.Id == (int)SQType.创建活动 && a.CheckState == st).OrderBy(a => a.Id).ToList();
            }
            else
            {
                models = db.ApplyAudits.Where(a => a.Type.Id == (int)SQType.创建活动).OrderBy(a => a.Id).ToList();
            }
            List <ApplyView> datas = new List <ApplyView>();

            foreach (ApplyAudit applys in models)
            {
                ApplyView apply = new ApplyView
                {
                    Id         = applys.Id.ToString(),
                    Type       = applys.Type.Name,
                    Club       = applys.Club?.Name,
                    ApplyUser  = applys.ApplyUser.UserName,
                    CheckState = Enum.GetName(typeof(EnumAuditState), applys.CheckState),
                    ApplyDate  = applys.ApplyDate.ToString(),
                    AuditDate  = applys.AuditDate.ToString(),
                    AuditTimes = applys.AuditTimes ?? 0
                };
                datas.Add(apply);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = models.Count(),
                data  = datas.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #21
0
        //获取所有账号池
        public ActionResult UserNumberData(int page, int limit)
        {
            List <UserNumberModel> datas = new List <UserNumberModel>();

            foreach (UserNumber us in db.UserNumbers.OrderBy(u => u.UserId).Skip((page - 1) * limit).Take(limit).ToList())
            {
                UserNumberModel data = new UserNumberModel()
                {
                    id      = us.UserId,
                    relname = us.RelName ?? "无",
                    state   = Enum.GetName(typeof(EnumState), us.State)
                };
                datas.Add(data);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = db.UserNumbers.Count(),
                data  = datas.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #22
0
        public static PageDataModel Get(int id)
        {
            PageDataModel page = null;

            MySqlConnection  connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]);
            MySqlDataAdapter adapter    = new MySqlDataAdapter("GetPageByID", connection);
            MySqlParameter   paramID    = new MySqlParameter("pId", id);

            paramID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            adapter.SelectCommand.Parameters.Add(paramID);

            DataTable results = new DataTable();

            adapter.Fill(results);

            if (results.Rows.Count > 0)
            {
                DataRow item = results.Rows[0];
                page = new PageDataModel();

                page.ID            = Convert.ToInt32(item["ID"]);
                page.Name          = Convert.ToString(item["Name"]);
                page.Content       = Convert.ToString(item["Content"]);
                page.FeaturedImage = Convert.ToString(item["FeaturedImage"]);
                page.MainImage     = Convert.ToString(item["MainImage"]);
                if (item["Blog"].GetType() != typeof(DBNull))
                {
                    page.Blog = Convert.ToBoolean(item["Blog"]);
                }
                page.Metakeywords    = Convert.ToString(item["Metakeywords"]);
                page.MetaDescription = Convert.ToString(item["MetaDescription"]);
            }

            return(page);
        }
        public ActionResult Create(PageDataModel page)
        {
            PageBO.Create(page);

            return(RedirectToAction("Index"));
        }
Example #24
0
        public ActionResult ClubsNumberData(int page, int limit)
        {
            List <ClubsNumberModel> models = new List <ClubsNumberModel>();

            foreach (ClubNumber club in db.ClubNumbers.OrderBy(c => c.ClubId).Skip((page - 1) * limit).Take(limit))
            {
                ClubsNumberModel model = new ClubsNumberModel();
                model.ClubId = club.ClubId;
                switch (club.State)
                {
                case ((int)EnumState.未使用):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "black";
                    break;

                case ((int)EnumState.系统锁定):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "gray";
                    break;

                case ((int)EnumState.待提交):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "red";
                    break;

                case ((int)EnumState.正常):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "green";
                    break;

                case ((int)EnumState.待审批):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "orange";
                    break;

                case ((int)EnumState.查封):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "pink";
                    break;

                case ((int)EnumState.冻结):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "bule";
                    break;

                case ((int)EnumState.制裁):
                    model.State = Enum.GetName(typeof(EnumState), club.State);
                    model.Style = "red";
                    break;

                default:
                    model.State = "未知";
                    model.Style = "yellow";
                    break;
                }
                model.CreateDate = club.CreateDate == null ? "无" : club.CreateDate.ToString();
                models.Add(model);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = db.ClubNumbers.Count(),
                data  = models.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
Example #25
0
        public ActionResult GetActiveListData(int page, string cid)
        {
            int count = 6;//单页显示数量
            List <ActiveListModel>  models = new List <ActiveListModel>();
            IQueryable <Activities> actlist;

            if (string.IsNullOrEmpty(cid))
            {
                actlist = db.Activities.Where(a => a.State > 2).OrderByDescending(a => a.Id).Skip((page - 1) * count).Take(count);
            }
            else
            {
                actlist = db.Activities.Where(a => a.Club.ClubId == cid).OrderByDescending(a => a.Id).Skip((page - 1) * count).Take(count);
            }
            foreach (Activities act in actlist)
            {
                ActiveListModel model = new ActiveListModel()
                {
                    Id         = act.Id,
                    Labels     = act.Label.Split(',').ToList(),
                    HeadImg    = act.Club.HeadImg,
                    Title1     = act.Title1,
                    Title2     = act.Title2,
                    Content    = act.Content,
                    MaxUser    = act.MaxUser,
                    Area1      = act.Area?.Name,
                    Time1      = act.Time1.ToString("yyyy/MM/dd hh:mm"),
                    Time2      = act.Time2.ToString("yyyy/MM/dd hh:mm"),
                    CreateDate = act.CreateDate.ToString(),
                    UserID     = act.User.UserId,
                    UserName   = act.User.UserName,
                    ClubID     = act.Club.ClubId,
                    ClubName   = act.Club.Name,
                    VoteCount  = db.Votings.Where(v => v.Active.Id == act.Id).Count().ToString(),
                    // State = Enum.GetName(typeof(ActiveState), act.State),
                    Votes0 = string.IsNullOrEmpty(act.Votes0)?"0":act.Votes0
                };
                if (act.Time1 > DateTime.Now)
                {
                    model.State = "未开始";
                }
                else if (act.Time2 > DateTime.Now)
                {
                    model.State = "进行中";
                }
                else
                {
                    model.State = "已结束";
                }
                if (act.Area == null)
                {
                    if (string.IsNullOrEmpty(act.Area0))
                    {
                        model.Area1 = "未知";
                    }
                    else
                    {
                        model.Area1 = act.Area0;
                    }
                }

                models.Add(model);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = (int)Math.Ceiling((double)db.Activities.Count() / count),
                data  = models.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
        public override object Execute(Dictionary <string, object> arguments)
        {
            var result = new List <SelectOption>();

            //if pageModel is not provided, returns empty List<SelectOption>()
            if (arguments.ContainsKey("PageModel") && arguments.ContainsKey("DataSourceName") && !string.IsNullOrWhiteSpace((string)arguments["DataSourceName"]))
            {
                //replace constants with your values
                string DATASOURCE_NAME       = (string)arguments["DataSourceName"];
                string KEY_FIELD_NAME        = (string)arguments["KeyPropName"];
                string VALUE_FIELD_NAME      = (string)arguments["ValuePropName"];
                string VALUE_FIELD_NAME1     = (string)arguments["Value1PropName"];
                string VALUE_FIELD_NAME2     = (string)arguments["Value2PropName"];
                string ICON_CLASS_FIELD_NAME = (string)arguments["IconClassPropName"];
                string COLOR_FIELD_NAME      = (string)arguments["ColorPropName"];
                string SORT_ORDER_FIELD_NAME = (string)arguments["SortOrderPropName"];
                string SORT_TYPE_NAME        = (string)arguments["SortTypePropName"];

                PageDataModel pageModel = arguments["PageModel"] as PageDataModel;
                if (pageModel == null)
                {
                    return(result);
                }

                try
                {
                    //try read data source by name and get result as specified type object
                    var dataSource = pageModel.GetProperty(DATASOURCE_NAME);

                    //if data source not found or different type, return empty List<SelectOption>()
                    if (dataSource == null)
                    {
                        return(result);
                    }

                    if (dataSource is List <EntityRecord> )
                    {
                        var recordsList = (List <EntityRecord>)dataSource;
                        if (!String.IsNullOrWhiteSpace(SORT_ORDER_FIELD_NAME) && recordsList.Count > 1 && recordsList[0].Properties.ContainsKey(SORT_ORDER_FIELD_NAME) &&
                            recordsList[0][SORT_ORDER_FIELD_NAME] != null)
                        {
                            bool isDecimal = false;
                            if (decimal.TryParse((recordsList[0][SORT_ORDER_FIELD_NAME] ?? "").ToString(), out decimal outDecimal))
                            {
                                isDecimal = true;
                            }

                            if (SORT_TYPE_NAME.ToLowerInvariant() == "desc")
                            {
                                if (isDecimal)
                                {
                                    dataSource = recordsList.OrderByDescending(x => (decimal?)x[SORT_ORDER_FIELD_NAME]).ToList();
                                }
                                else
                                {
                                    dataSource = recordsList.OrderByDescending(x => (string)x[SORT_ORDER_FIELD_NAME]).ToList();
                                }
                            }
                            else
                            {
                                if (isDecimal)
                                {
                                    dataSource = recordsList.OrderBy(x => (decimal?)x[SORT_ORDER_FIELD_NAME]).ToList();
                                }
                                else
                                {
                                    dataSource = recordsList.OrderBy(x => (string)x[SORT_ORDER_FIELD_NAME]).ToList();
                                }
                            }
                        }
                        int i = 0;
                        foreach (var record in (List <EntityRecord>)dataSource)
                        {
                            if (record.Properties.ContainsKey(ICON_CLASS_FIELD_NAME) && record[ICON_CLASS_FIELD_NAME] != null)
                            {
                                var color = "#999";
                                if (record.Properties.ContainsKey(COLOR_FIELD_NAME) && record[COLOR_FIELD_NAME] != null)
                                {
                                    color = record[COLOR_FIELD_NAME].ToString();
                                }
                                var key   = getKey(i, KEY_FIELD_NAME, DATASOURCE_NAME, pageModel, record);
                                var value = getValue(i, VALUE_FIELD_NAME, DATASOURCE_NAME, pageModel, record);
                                if (VALUE_FIELD_NAME1 == "label1")
                                {
                                    result.Add(new SelectOption(key.ToString(), value.ToString(), record[ICON_CLASS_FIELD_NAME].ToString(), color));
                                }
                                else if (VALUE_FIELD_NAME2 == "label2")
                                {
                                    var value1 = getValue(i, VALUE_FIELD_NAME1, DATASOURCE_NAME, pageModel, record);
                                    result.Add(new SelectOption(key, "" + value + " - " + Environment.NewLine +
                                                                "" + value1, record[ICON_CLASS_FIELD_NAME].ToString(), color));
                                }
                                else
                                {
                                    var value1 = getValue(i, VALUE_FIELD_NAME1, DATASOURCE_NAME, pageModel, record);
                                    var value2 = getValue(i, VALUE_FIELD_NAME2, DATASOURCE_NAME, pageModel, record);
                                    result.Add(new SelectOption(key, "" + value + " - " + Environment.NewLine +
                                                                "" + value1 + "    -    " + value2 + "", record[ICON_CLASS_FIELD_NAME].ToString(), color));
                                }
                                //if (!record.Properties.ContainsKey(VALUE_FIELD_NAME1) || VALUE_FIELD_NAME1 == null)
                                //{
                                //	result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), record[VALUE_FIELD_NAME].ToString(), record[ICON_CLASS_FIELD_NAME].ToString(), color));
                                //}
                                //else if (VALUE_FIELD_NAME1 == null)
                                //{

                                //	result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), "" + record[VALUE_FIELD_NAME].ToString() + " - " + Environment.NewLine +
                                //		"" + record[VALUE_FIELD_NAME1].ToString(), record[ICON_CLASS_FIELD_NAME].ToString(), color));
                                //}
                                //else
                                //{
                                //	result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), "" + record[VALUE_FIELD_NAME].ToString() + " - " + Environment.NewLine +
                                //		"" + record[VALUE_FIELD_NAME1].ToString() + "    -    " + record[VALUE_FIELD_NAME2].ToString() + "", record[ICON_CLASS_FIELD_NAME].ToString(), color));

                                //}
                            }
                            else
                            {
                                var key   = getKey(i, KEY_FIELD_NAME, DATASOURCE_NAME, pageModel, record);
                                var value = getValue(i, VALUE_FIELD_NAME, DATASOURCE_NAME, pageModel, record);
                                if (VALUE_FIELD_NAME1 == "label1")
                                {
                                    result.Add(new SelectOption(key.ToString(), value.ToString()));
                                }
                                else if (VALUE_FIELD_NAME2 == "label2")
                                {
                                    var value1 = getValue(i, VALUE_FIELD_NAME1, DATASOURCE_NAME, pageModel, record);
                                    result.Add(new SelectOption(key, "" + value + " - " + Environment.NewLine +
                                                                "" + value1));
                                }
                                else
                                {
                                    var value1 = getValue(i, VALUE_FIELD_NAME1, DATASOURCE_NAME, pageModel, record);
                                    var value2 = getValue(i, VALUE_FIELD_NAME2, DATASOURCE_NAME, pageModel, record);
                                    result.Add(new SelectOption(key, "" + value + " - " + Environment.NewLine +
                                                                "" + value1 + "    -    " + value2 + ""));
                                }
                            }
                            i++;
                        }
                    }
                    else if (dataSource is EntityRecord)
                    {
                        var record = (EntityRecord)dataSource;
                        if (record.Properties.ContainsKey(ICON_CLASS_FIELD_NAME) && record[ICON_CLASS_FIELD_NAME] != null)
                        {
                            var color = "#999";
                            if (record.Properties.ContainsKey(COLOR_FIELD_NAME) && record[COLOR_FIELD_NAME] != null)
                            {
                                color = record[COLOR_FIELD_NAME].ToString();
                            }
                            result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), record[VALUE_FIELD_NAME].ToString(), record[ICON_CLASS_FIELD_NAME].ToString(), color));
                        }
                        else
                        {
                            result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), record[VALUE_FIELD_NAME].ToString()));
                        }
                    }
                    else
                    {
                        throw new Exception("Input Datasource value should be of type List<EntityRecord> or EntityRecord");
                    }
                }
                catch (PropertyDoesNotExistException)
                {
                }
            }
            return(result);
        }
        public ActionResult Edit(PageDataModel page)
        {
            PageBO.Update(page);

            return(RedirectToAction("Index"));
        }
Example #28
0
        public IPageDataModel CreatePageDataModel()
        {
            IPageDataModel Data = new PageDataModel();

            // First setup field
            AddField("Performance", 36);
            AddField("Update", 10);
            AddField("Read", 8);
            AddField("Read2", 8);

            Data.Title      = TitleMessage;
            Data.HasMessage = false;

            // Make header
            Data.Header    = MakeHeader();
            Data.HasHeader = true;

            Task.Run(async() =>
            {
                HttpClient http = GetHttplClient(HtmlClientApi);
                currentPerf     = await http.GetFromJsonAsync <PerformanceRecord>("SchoolPerformance");
            }).Wait();

            if (currentPerf != null)
            {
                // Create content
                Data.HasContent      = true;
                Data.ContentFontSize = 24;
                Data.Content         = new string[11];

                List <string> strings = new List <string>
                {
                    "Initialize Performance",
                    "",
                    currentPerf.InitPerformance.ToString()
                };
                string str = MakeContent(strings);
                Data.Content[0] = str;
                strings         = new List <string>
                {
                    "Json Performance",
                    "",
                    currentPerf.JsonPerformance.ToString(),
                    currentPerf.JsonPerformance2.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[1] = str;
                strings         = new List <string>
                {
                    "Dapper Performance",
                    currentPerf.DapperUpdatePerformance.ToString(),
                    currentPerf.DapperPerformance.ToString(),
                    currentPerf.DapperPerformance2.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[2] = str;
                strings         = new List <string>
                {
                    "Entity Framework Performance",
                    currentPerf.EFUpdatePerformance.ToString(),
                    currentPerf.EFPerformance.ToString(),
                    currentPerf.EFPerformance2.ToString()
                };
                ;
                str             = MakeContent(strings);
                Data.Content[3] = str;
                strings         = new List <string>
                {
                    "Simulated Performance",
                    currentPerf.SimUpdatePerformance.ToString(),
                    currentPerf.SimPerformance.ToString(),
                    currentPerf.SimPerformance2.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[4] = str;
                strings         = new List <string>
                {
                    "Use Simulated",
                    "",
                    currentPerf.UseSIM.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[5] = str;
                strings         = new List <string>
                {
                    "Use Entity Framework",
                    "",
                    currentPerf.UseEF.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[6] = str;
                strings         = new List <string>
                {
                    "Use Dapper Framework",
                    "",
                    currentPerf.UseDapper.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[7] = str;
                strings         = new List <string>
                {
                    "Allow Entity Framework",
                    "",
                    currentPerf.AllowEF.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[8] = str;
                strings         = new List <string>
                {
                    "Allow Dapper Framework",
                    "",
                    currentPerf.AllowDapper.ToString()
                };
                str             = MakeContent(strings);
                Data.Content[9] = str;
                strings         = new List <string>
                {
                    "Max Records",
                    "",
                    currentPerf.MaxPage.ToString(),
                    currentPerf.Records.ToString()
                };
                str = MakeContent(strings);
                Data.Content[10] = str;
            }

            return(Data);
        }
Example #29
0
        public override object Execute(Dictionary <string, object> arguments)
        {
            var result = new List <SelectOption>();

            //if pageModel is not provided, returns empty List<SelectOption>()
            if (arguments.ContainsKey("PageModel") && arguments.ContainsKey("DataSourceName") && !string.IsNullOrWhiteSpace((string)arguments["DataSourceName"]))
            {
                //replace constants with your values
                string DATASOURCE_NAME       = (string)arguments["DataSourceName"];
                string KEY_FIELD_NAME        = (string)arguments["KeyPropName"];
                string VALUE_FIELD_NAME      = (string)arguments["ValuePropName"];
                string ICON_CLASS_FIELD_NAME = (string)arguments["IconClassPropName"];
                string COLOR_FIELD_NAME      = (string)arguments["ColorPropName"];

                PageDataModel pageModel = arguments["PageModel"] as PageDataModel;
                if (pageModel == null)
                {
                    return(result);
                }

                try
                {
                    //try read data source by name and get result as specified type object
                    var dataSource = pageModel.GetProperty(DATASOURCE_NAME);

                    //if data source not found or different type, return empty List<SelectOption>()
                    if (dataSource == null)
                    {
                        return(result);
                    }

                    if (dataSource is List <EntityRecord> )
                    {
                        foreach (var record in (List <EntityRecord>)dataSource)
                        {
                            if (record.Properties.ContainsKey(ICON_CLASS_FIELD_NAME) && record[ICON_CLASS_FIELD_NAME] != null)
                            {
                                var color = "#999";
                                if (record.Properties.ContainsKey(COLOR_FIELD_NAME) && record[COLOR_FIELD_NAME] != null)
                                {
                                    color = record[COLOR_FIELD_NAME].ToString();
                                }
                                result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), record[VALUE_FIELD_NAME].ToString(), record[ICON_CLASS_FIELD_NAME].ToString(), color));
                            }
                            else
                            {
                                result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), record[VALUE_FIELD_NAME].ToString()));
                            }
                        }
                    }
                    else if (dataSource is EntityRecord)
                    {
                        var record = (EntityRecord)dataSource;
                        if (record.Properties.ContainsKey(ICON_CLASS_FIELD_NAME) && record[ICON_CLASS_FIELD_NAME] != null)
                        {
                            var color = "#999";
                            if (record.Properties.ContainsKey(COLOR_FIELD_NAME) && record[COLOR_FIELD_NAME] != null)
                            {
                                color = record[COLOR_FIELD_NAME].ToString();
                            }
                            result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), record[VALUE_FIELD_NAME].ToString(), record[ICON_CLASS_FIELD_NAME].ToString(), color));
                        }
                        else
                        {
                            result.Add(new SelectOption(record[KEY_FIELD_NAME].ToString(), record[VALUE_FIELD_NAME].ToString()));
                        }
                    }
                    else
                    {
                        throw new Exception("Input Datasource value should be of type List<EntityRecord> or EntityRecord");
                    }
                }
                catch (PropertyDoesNotExistException)
                {
                }
            }
            return(result);
        }