protected void Page_Load(object sender, EventArgs e) { System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 开始监视代码 using (DNetContext db = new DNetContext()) { StringBuilder sql = new StringBuilder(); List <DbParameter> parameters = new List <DbParameter>(); sql.AppendFormat(@"SELECT {0},A.AuthorName FROM Book B LEFT JOIN Author A ON A.AuthorID=B.AuthorID WHERE", SqlBuilder.GetSelectAllFields <Book>("B")); sql.Append(" B.BookID>@BookID "); parameters.Add(db.GetDbParameter("BookID", 1)); PageFilter pageFilter = new PageFilter { PageIndex = 1, PageSize = 5 }; pageFilter.OrderText = "B.BookID ASC"; PageDataSource <Book> books = db.GetPage <Book>(sql.ToString(), pageFilter, parameters.ToArray()); List <Book> bks = db.GetList <Book>(sql.ToString(), parameters.ToArray()); } stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 double milliseconds = timespan.TotalMilliseconds; // 总毫秒数 Response.Write("执行时间:" + milliseconds + "毫秒"); }
/// <summary> /// 获取分页数据 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pageFilter"></param> /// <returns></returns> public PageDataSource <T> GetPage <T>(PageFilter pageFilter) where T : class, new() { StringBuilder selectSql = new StringBuilder(); List <DbParameter> parms = new List <DbParameter>(); if (pageFilter is PageFilter <T> ) { GetSQLByLambda(selectSql, parms, (Expression <Func <T, bool> >)((PageFilter <T>)pageFilter).WhereExpression); } else { GetSQLByLambda <T>(selectSql, parms, null); } PageDataSource <T> dataSource = new PageDataSource <T>(); int recordCount, pageCount, pageIndex; using (var reader = DataBase.ExecutePageReader(selectSql.ToString(), pageFilter.OrderText, pageFilter.PageIndex, pageFilter.PageSize, out recordCount, out pageCount, out pageIndex, parms.ToArray())) { dataSource.RecordCount = recordCount; dataSource.PageCount = pageCount; dataSource.PageIndex = pageIndex; dataSource.PageSize = pageFilter.PageSize; dataSource.DataSource = new List <T>(); while (reader.Read()) { T entityWhile = new T(); SetEntityMembers <T>(reader, entityWhile); dataSource.DataSource.Add(entityWhile); } return(dataSource); } }
private static PageDataSource DataRowToPageDataSourceConvert(DataRow data) { if (data == null) { return(null); } PageDataSource model = new PageDataSource(); model.Id = new Guid(data["id"].ToString()); model.Name = (string)data["name"]; model.PageId = (Guid)data["page_id"]; model.DataSourceId = (Guid)data["data_source_id"]; if (!string.IsNullOrWhiteSpace((string)data["parameters"])) { model.Parameters = JsonConvert.DeserializeObject <List <DataSourceParameter> >((string)data["parameters"]); } else { model.Parameters = new List <DataSourceParameter>(); } return(model); }
public MyPageViewController() : base(UIPageViewControllerTransitionStyle.Scroll, UIPageViewControllerNavigationOrientation.Horizontal) { View.Frame = UIScreen.MainScreen.Bounds; pages.Add(new ContentViewController(0, UIColor.Red)); pages.Add(new ContentViewController(1, UIColor.Green)); pages.Add(new ContentViewController(2, UIColor.Blue)); DataSource = new PageDataSource(pages); SetViewControllers(new UIViewController[] { pages [0] as UIViewController }, UIPageViewControllerNavigationDirection.Forward, false, null); }
protected void Page_Load(object sender, EventArgs e) { System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 开始监视代码 using (DNetContext db = new DNetContext()) { var author = db.GetSingle <Author>(m => true, q => q.OrderBy(m => m.AuthorID)); var book = db.GetSingle <Book>(m => ((DateTime)m.PublishDate).ToString("yyyy-MM-dd") == "2017-11-11"); var authors = db.GetList <Author>(m => string.IsNullOrEmpty(m.AuthorName) && m.IsValid == true); List <dynamic> name = db.GetDistinctList <Author>(m => m.AuthorName.StartsWith("jim") && m.IsValid == true, m => m.AuthorName + "aaa"); //List<string> name1 = db.GetDistinctList<Author, string>(m => m.AuthorName.IndexOf("jim") == 2 && m.IsValid == true, m => m.AuthorName); var books = db.GetList <Book>(m => SubQuery.GetList <Author>(n => n.AuthorID > 10, n => n.AuthorID).Contains(m.AuthorID)); books = db.GetList <Book>(m => m.AuthorID >= SubQuery.GetSingle <Author>(n => n.AuthorID == 10, n => n.AuthorID)); var authorid = db.GetMax <Author>(m => (int)m.AuthorID); WhereBuilder <Author> where = new WhereBuilder <Author>(); where.And(m => m.AuthorName.Contains("jim")); where.And(m => m.AuthorID == 3); where.Or(m => m.IsValid == true); db.GetList <Author>(where.WhereExpression); PageFilter <Author> page = new PageFilter <Author> { PageIndex = 1, PageSize = 10 }; page.And(m => "jim green".Contains(m.AuthorName)); page.OrderBy(q => q.OrderBy(m => m.AuthorName).OrderByDescending(m => m.AuthorID)); PageDataSource <Author> pageSource = db.GetPage <Author>(page); } stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 double milliseconds = timespan.TotalMilliseconds; // 总毫秒数 Response.Write("执行时间:" + milliseconds + "毫秒"); }
/// <summary> /// 查询分页数据 /// 根据SQL查询 不设置排序则为默认排序 不需要设置LambdaExpression /// </summary> /// <typeparam name="TObject"></typeparam> /// <param name="sql"></param> /// <param name="pageFilter"></param> /// <param name="cmdParms"></param> /// <returns></returns> public PageDataSource <TObject> GetPage <TObject>(string sql, PageFilter pageFilter, params DbParameter[] cmdParms) { PageDataSource <TObject> dataSource = new PageDataSource <TObject>(); int recordCount, pageCount, pageIndex; using (var reader = DataBase.ExecutePageReader(sql, pageFilter.OrderText, pageFilter.PageIndex, pageFilter.PageSize, out recordCount, out pageCount, out pageIndex, cmdParms)) { dataSource.RecordCount = recordCount; dataSource.PageCount = pageCount; dataSource.PageIndex = pageIndex; dataSource.PageSize = pageFilter.PageSize; dataSource.DataSource = new List <TObject>(); while (reader.Read()) { dataSource.DataSource.Add(GetDynamicObject <TObject>(reader)); } return(dataSource); } }
//private: private void initproperties() { _itemnumber = 0; _initialangle = 0.0; _datasource = null; _bordersource = null; _thumbheight = 0; _thumbwidth = 0; _borderheight = 0; _borderwidth = 0.0; _initialposition = 0; _finalposition = 0; _isopen = false; _isfull = false; _touches = 0; _maxthreshold = 100; _ismfull = false; }
public override void WritePropertiesData(DataWriter writer) { writer.WriteStartObject(Name); base.WritePropertiesData(writer); if (Status == Core.Process.ProcessStatus.Inactive) { writer.WriteFinishObject(); return; } if (UseFlowEngineMode) { if (DetailPageContainer != null) { if (DetailPageContainer.GetType().IsSerializable || DetailPageContainer.GetType().GetInterface("ISerializable") != null) { writer.WriteSerializableObjectValue("DetailPageContainer", DetailPageContainer, null); } } } if (UseFlowEngineMode) { if (PageDataSource != null) { if (PageDataSource.GetType().IsSerializable || PageDataSource.GetType().GetInterface("ISerializable") != null) { writer.WriteSerializableObjectValue("PageDataSource", PageDataSource, null); } } } if (!HasMapping("DetailPageFilterName")) { writer.WriteValue("DetailPageFilterName", DetailPageFilterName, null); } if (!HasMapping("ThrowEventName")) { writer.WriteValue("ThrowEventName", ThrowEventName, null); } if (FilterLeftExpressions != null) { if (FilterLeftExpressions.GetType().IsSerializable || FilterLeftExpressions.GetType().GetInterface("ISerializable") != null) { writer.WriteSerializableObjectValue("FilterLeftExpressions", FilterLeftExpressions, null); } } if (FilterRightValue != null) { if (FilterRightValue.GetType().IsSerializable || FilterRightValue.GetType().GetInterface("ISerializable") != null) { writer.WriteSerializableObjectValue("FilterRightValue", FilterRightValue, null); } } if (!HasMapping("FilterName")) { writer.WriteValue("FilterName", FilterName, null); } if (!HasMapping("ParentColumnMetaPath")) { writer.WriteValue("ParentColumnMetaPath", ParentColumnMetaPath, null); } if (!HasMapping("SysEntitySchemaId")) { writer.WriteValue("SysEntitySchemaId", SysEntitySchemaId, Guid.Empty); } writer.WriteFinishObject(); }
/// <summary> /// 多表连查分页 /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="page"></param> /// <returns></returns> public PageDataSource <TModel> GetPage <TModel>(PageFilter page) { List <JoinRelation> tables = new List <JoinRelation>(); SqlBuilder.AppendFormat(" SELECT {0} FROM {1}", SelectFields.ToString().TrimEnd(','), JoinRelations[0].LeftTable); if (WithAlias) { SqlBuilder.AppendFormat(" AS {0}", JoinRelations[0].LeftTableAlias); } foreach (JoinRelation j in JoinRelations) { if (j.JoinType == JoinType.Outer) { SqlBuilder.Append(" LEFT OUTER JOIN "); } else { SqlBuilder.Append(" INNER JOIN "); } if (WithAlias) { if (tables.Count(m => m.LeftTableAlias == j.RightTableAlias || m.RightTableAlias == j.RightTableAlias) == 0) { SqlBuilder.AppendFormat("{0} AS {1}", j.RightTable, j.RightTableAlias); tables.Add(j); } else { SqlBuilder.AppendFormat("{0} AS {1}", j.LeftTable, j.LeftTableAlias); tables.Add(j); } } else { if (tables.Count(m => m.LeftTable == j.RightTable || m.RightTable == j.RightTable) == 0) { SqlBuilder.Append(j.RightTable); tables.Add(j); } else { SqlBuilder.Append(j.LeftTable); tables.Add(j); } } SqlBuilder.AppendFormat(" ON {0}", j.OnSql.TrimEnd("AND".ToCharArray())); } if (WhereClause.Length > 0) { SqlBuilder.AppendFormat(" WHERE {0}", WhereClause.ToString().Trim().TrimEnd("AND".ToCharArray())); } if (GroupByFields.Length > 0) { SqlBuilder.AppendFormat(" GROUP BY {0}", GroupByFields.ToString().Trim().TrimEnd(',')); } if (OrderByFields.Length > 0) { page.OrderText = OrderByFields.ToString().Trim().TrimEnd(','); } //开始组装sql //开始组装sql PageDataSource <TModel> result = DbContext.GetPage <TModel>(SqlBuilder.ToString(), page, Parameters.ToArray()); if (this.IsAutoDisposeDbContext) { DbContext.Dispose(); } return(result); }
void loadLOsInCircle(int index) { var vm = ViewModel as LOViewModel; if (vm.LOsInCircle != null) { for (int i = index; i < vm.LOsInCircle.Count; i++) { ChapterDataSource newchapter = new ChapterDataSource(); newchapter.Title = vm.LOsInCircle[i].lo.title; newchapter.Author = vm.LOsInCircle[i].lo.name + "\n" + vm.LOsInCircle[i].lo.lastname; newchapter.Description = vm.LOsInCircle[i].lo.description; newchapter.ChapterColor = MLConstants.getUIColor(i % 6, 255); newchapter.TemporalColor = MLConstants.getUIColor(0, 255); // newchapter.BackgroundImage = if (vm.LOsInCircle[i].background_bytes != null) { newchapter.BackgroundImage = MLConstants.BytesToUIImage(vm.LOsInCircle[i].background_bytes); } vm.LOsInCircle[i].PropertyChanged += (s1, e1) => { if (e1.PropertyName == "background_bytes") { newchapter.BackgroundImage = MLConstants.BytesToUIImage( (s1 as MLearning.Core.ViewModels.LOViewModel.lo_by_circle_wrapper).background_bytes); } //newchapter.BackgroundImage = MLConstants.BytesToUIImage(vm.LOsInCircle[i].background_bytes); }; //loading the stacks if (vm.LOsInCircle[i].stack.IsLoaded) { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { var page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = s_list[j].PagesList[k].page.description; page.BorderColor = MLConstants.getUIColor(k % 6, 255); /********************* * if (s_list[j].PagesList[k].cover_bytes != null) * page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); * s_list[j].PagesList[k].PropertyChanged += (s2, e2) => * { * if (e2.PropertyName == "cover_bytes") * page.ImageContent = Constants.ByteArrayToImageConverter.Convert((s2 as MLearning.Core.ViewModels.LOViewModel.page_wrapper).cover_bytes);//s_list[j].PagesList[k].cover_bytes); * }; ****************/ stack.Pages.Add(page); } newchapter.Sections.Add(stack); } } else { vm.LOsInCircle[i].stack.PropertyChanged += (s3, e3) => { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { PageDataSource page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = s_list[j].PagesList[k].page.description; page.BorderColor = MLConstants.getUIColor(k % 6, 255); /******************* * if (s_list[j].PagesList[k].cover_bytes != null) * page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); * s_list[j].PagesList[k].PropertyChanged += (s2, e2) => * { * if (e2.PropertyName == "cover_bytes") * page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); * };*********************/ stack.Pages.Add(page); } newchapter.Sections.Add(stack); } }; } booksource.Chapters.Add(newchapter); } //menu.SelectElement(vm.LOCurrentIndex); booksource.TemporalColor = MLConstants.getUIColor(vm.LOCurrentIndex, 255); readerView.booksource = booksource; readerView.InitIndexReader(); //_backgroundscroll.Source = booksource; //_menucontroller.SEtColor(booksource.Chapters[vm.LOCurrentIndex].ChapterColor); } }
void loadLOsInCircle(int index) { var vm = ViewModel as LOViewModel; if (vm.LOsInCircle != null) { for (int i = index; i < vm.LOsInCircle.Count; i++) { ChapterDataSource newchapter = new ChapterDataSource(); newchapter.Title = vm.LOsInCircle[i].lo.title; newchapter.Author = vm.LOsInCircle[i].lo.name + "\n" + vm.LOsInCircle[i].lo.lastname; //newchapter.Description = vm.LOsInCircle[i].lo.description; newchapter.Description = GetPlainTextFromHtml(vm.LOsInCircle[i].lo.description); newchapter.ChapterColor = StaticStyles.Colors[vm.LOsInCircle[i].lo.color_id].MainColor; newchapter.TemporalColor = StaticStyles.Colors[vm.LOsInCircle[index].lo.color_id].MainColor; if (vm.LOsInCircle[i].background_bytes != null) { newchapter.BackgroundImage = Constants.ByteArrayToImageConverter.Convert(vm.LOsInCircle[i].background_bytes); } vm.LOsInCircle[i].PropertyChanged += (s1, e1) => { if (e1.PropertyName == "background_bytes") { newchapter.BackgroundImage = Constants.ByteArrayToImageConverter.Convert((s1 as MLearning.Core.ViewModels.MainViewModel.lo_by_circle_wrapper).background_bytes); } }; //loading the stacks if (vm.LOsInCircle[i].stack.IsLoaded) { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { var page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = GetPlainTextFromHtml(s_list[j].PagesList[k].page.description); if (s_list[j].PagesList[k].cover_bytes != null) { page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); } s_list[j].PagesList[k].PropertyChanged += (s2, e2) => { if (e2.PropertyName == "cover_bytes") { page.ImageContent = Constants.ByteArrayToImageConverter.Convert((s2 as MLearning.Core.ViewModels.LOViewModel.page_wrapper).cover_bytes); } }; stack.Pages.Add(page); } newchapter.Sections.Add(stack); } } else { vm.LOsInCircle[i].stack.PropertyChanged += (s3, e3) => { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { PageDataSource page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = GetPlainTextFromHtml(s_list[j].PagesList[k].page.description); if (s_list[j].PagesList[k].cover_bytes != null) { page.ImageContent = Convert(s_list[j].PagesList[k].cover_bytes, 267, 150); } s_list[j].PagesList[k].PropertyChanged += (s2, e2) => { if (e2.PropertyName == "cover_bytes") { page.ImageContent = Convert(s_list[j].PagesList[k].cover_bytes, 267, 150); } }; stack.Pages.Add(page); } newchapter.Sections.Add(stack); } }; } booksource.Chapters.Add(newchapter); } down_menu.SelectElement(vm.LOCurrentIndex); booksource.TemporalColor = StaticStyles.Colors[vm.LOsInCircle[_currentLO].lo.color_id].MainColor; _backgroundscroll.Source = booksource; logo_image.BackSource = new BitmapImage(new Uri(StaticStyles.LogosScroll[vm.LOsInCircle[_currentLO].lo.color_id])); _menucontroller.SEtColor(StaticStyles.Colors[vm.LOsInCircle[_currentLO].lo.color_id].MainColorA); } }