/// <summary> /// 保存列表控件的布局信息 /// </summary> /// <param name="control">控件</param> /// <param name="attr">授权属性</param> private void StoreLayout(Control control, AuthorizationAttribute attr) { // 表格控件 if (control is GridControl) { foreach (BaseView view in ((GridControl)control).Views) { using (MemoryStream stream = new MemoryStream()) { view.SaveLayoutToStream(stream); Layout layout = new Layout(Thread.CurrentPrincipal.Identity.Name, ConbinPath(attr.AuthorizationUri, view.Name)); layout.Data = stream.ToArray(); LayoutService.StoreLayout(layout); // 保存布局 } } } // 列表控件 if (control is TreeList) { using (MemoryStream stream = new MemoryStream()) { TreeList list = (TreeList)control; list.SaveLayoutToStream(stream); Layout layout = new Layout(Thread.CurrentPrincipal.Identity.Name, ConbinPath(attr.AuthorizationUri, list.Name)); layout.Data = stream.ToArray(); LayoutService.StoreLayout(layout); // 保存布局 } } // 递归处理所有的列表控件 foreach (Control ctrl in control.Controls) { StoreLayout(ctrl, attr); } }
/// <summary> /// 保存列表布局到数据库 /// </summary> /// <param name="layout">布局信息</param> public void StoreLayout(Layout layout) { DeleteLayout(layout.User, layout.AppUri); db.Store(layout); }