public IEnumerable <User> Get() { using (UserConn entities = new UserConn()) { return(entities.Users.ToList()); } }
public FormTableInfo(TreeNode node) { this.node = node; this.conn = node.Parent.Parent.Tag as UserConn; this.table = node.Tag as IDataTable; InitializeComponent(); }
private DataSchema(UserConn conn) { m_conn = conn; m_initStatus = DataSchemaInitStatus.Initializing; m_initError = String.Empty; ThreadPoolX.QueueUserWorkItem(x => InitDataSchema()); }
/// <summary> /// 根据用户连接获取到数据库架构 /// </summary> /// <param name="conn"></param> /// <returns></returns> public static DataSchema GetInstance(UserConn conn) { if (!s_dataSchemaDict.ContainsKey(conn)) { s_dataSchemaDict.Add(conn, new DataSchema(conn)); } return(s_dataSchemaDict[conn]); }
public IList <User> GetManager() { using (var userContext = new UserConn()) { var data = userContext.Users.SqlQuery("[dbo].[allManagers]").ToList(); return(data); } }
// GET: api/Profile //Get all customers using role public IList <User> GetUsers() { using (var userContext = new UserConn()) { var data = userContext.Users.SqlQuery("[dbo].[allCustomers]").ToList(); return(data); } // return db.Users; }
/// <summary> /// 工具栏-移除数据库连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btiRemoveConn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { UserConn conn = trvDatabase.SelectedNode.Tag as UserConn; if (conn != null) { if (XtraMessageBox.Show(this, "您确定要移除此连接吗?", "信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { trvDatabase.Nodes.Remove(trvDatabase.SelectedNode); conn.Delete(); } } }
/// <summary> /// 增加一个数据库连接 /// </summary> /// <param name="databaseConn"></param> public void AddConn(UserConn conn) { Database databaseConn = conn.Database; TreeNode nodeTable, nodeView; TreeNode nodeDatabase = new TreeNode(databaseConn.ConnName, 7, 7, new TreeNode[]{ nodeTable = new TreeNode("数据表[加载中...]", 6, 6), nodeView = new TreeNode("视图[加载中...]", 6, 6) }); nodeDatabase.Tag = conn; trvDatabase.Nodes.Add(nodeDatabase); DataSchema.InitDataSchema(conn); }
/// <summary> /// 增加一个数据库连接 /// </summary> /// <param name="databaseConn"></param> public void AddConn(UserConn conn) { Database databaseConn = conn.Database; TreeNode nodeTable, nodeView; TreeNode nodeDatabase = new TreeNode(databaseConn.ConnName, 7, 7, new TreeNode[] { nodeTable = new TreeNode("数据表[加载中...]", 6, 6), nodeView = new TreeNode("视图[加载中...]", 6, 6) }); nodeDatabase.Tag = conn; trvDatabase.Nodes.Add(nodeDatabase); DataSchema.InitDataSchema(conn); }
/// <summary> /// 加载表或者视图数据 /// </summary> /// <param name="curNode"></param> private void NodeTableOrViewClick(TreeNode curNode, Boolean isView) { //--如果数据还在加载,则无需任何处理 if (!curNode.Text.Contains("加载中...")) { String connName = curNode.Parent.Text; UserConn conn = UserConn.FindByUserAndConnName(CurrentUser.UserInfo.OID, connName); DAL.AddConnStr(connName, conn.ConnString, null, conn.Database.Provider); List <IDataTable> lstTables = DAL.Create(connName).Tables.FindAll(x => x.IsView == isView); curNode.Tag = lstTables; LoadTableOrViewNodes(curNode, lstTables); } }
private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e) { if (e.Page == tabDataEntity) { List <IDataTable> lstTable = BindingNode.Parent.Tag as List <IDataTable>; UserConn conn = BindingNode.Parent.Parent.Tag as UserConn; String[] sourceFile = CodeGen.Render(table.Name, lstTable, new XConfig(XConfig.TEMPLATE_ENTITY_DATA, conn.Database.DatabaseName)); this.txtDataEntity.Text = sourceFile[0]; } else if (e.Page == tabBizEntity) { List <IDataTable> lstTable = BindingNode.Parent.Tag as List <IDataTable>; UserConn conn = BindingNode.Parent.Parent.Tag as UserConn; String[] sourceFile = CodeGen.Render(table.Name, lstTable, new XConfig(XConfig.TEMPLATE_ENTITY_BIZ, conn.Database.DatabaseName)); this.txtBizEntity.Text = sourceFile[0]; } }
/// <summary> /// 点击数据库节点时检测无效的数据库连接 /// </summary> /// <param name="curNode"></param> private void NodeDatabaseClick(TreeNode curNode) { UserConn conn = curNode.Tag as UserConn; if (curNode.IsExpanded) { this.Cursor = Cursors.WaitCursor; try { DataSchema dataSchema = DataSchema.GetInstance(conn); //--如果数据库架构初始化完成,则更新数据表或则视图节点 if (dataSchema.InitStatus == DataSchemaInitStatus.Initialized) { UpdateNodeText(curNode, dataSchema.TableCount, dataSchema.ViewCount); } else //--如果数据库架构没有初始化完成则订阅其完成事件,用以更新数据表或视图节点 { dataSchema.AddStatusChangeHandler(new EventHandler <StatusChangeEventArgs>((sender, e) => { this.Invoke(new DelegateUpdateNodeText(UpdateNodeText), curNode, dataSchema.TableCount, dataSchema.ViewCount); })); } } catch (Exception ex) { XtraMessageBox.Show("此连接已经失效将被移除,具体原因如下:\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); conn.Database.Delete(); conn.Delete(); trvDatabase.Nodes.Remove(curNode); } finally { this.Cursor = Cursors.Default; } } }
/// <summary> /// 确定添加新连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (dxValidationProvider.Validate()) { Database db = GetDatabaseFromUI(); if (ConnectToDatabase(db)) { db = Database.FindByConnName(ConnName); if (db == null) { db = GetDatabaseFromUI(); db.Insert(); } UserConn conn = UserConn.FindByUserAndDatabaseID(CurrentUser.UserInfo.OID, db.OID); if (conn == null) { conn = new UserConn() { OID = Guid.NewGuid().ToString(), UserID = CurrentUser.UserInfo.OID, DatabaseID = db.OID, ConnString = db.ConnString }; conn.Insert(); DatabaseExplorer.AddConn(conn); this.Close(); } else { XtraMessageBox.Show("此连接您已经添加过了!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
public void AddDebugLine(GameScreen s) { s.DebugDisp.AddLine("DebugMultiplayer", () => $"SERVER(Ping={ProxyPing.Value:0.0000} | Loss={ProxyPackageLossPerc * 100:00.00}% | State={ConnState} | Mode={Mode} | Packages={packageCount} (l={packageModSize}byte) | Ctr={msgIdWraps:00}:{msgId:000})\n" + $" (LagBehind={lagBehindTime} | SendFreq={SendFreq.Frequency:00.0} | UserPings=[{string.Join(",", UserConn.Take(SessionCapacity).Select(u => (u.InGamePing.Value*1000).ToString("F0")))}])\n" + $" (Packages[Out]={SendFreq.HistoryStr})\n" + $" (Packages[In]={RecieveFreq.HistoryStr})\n" + $" {_medium.DebugDisplayString}", this); }
/// <summary> /// 初始化数据库架构 /// </summary> /// <param name="conn"></param> public static void InitDataSchema(UserConn conn) { GetInstance(conn); }
/// <summary> /// 判断架构中是否包含指定的连接 /// </summary> /// <param name="conn"></param> /// <returns></returns> public static Boolean Contains(UserConn conn) { return(s_dataSchemaDict.ContainsKey(conn)); }
/// <summary> /// 根据用户连接获取到数据库架构 /// </summary> /// <param name="conn"></param> /// <returns></returns> public static DataSchema GetInstance(UserConn conn) { if (!s_dataSchemaDict.ContainsKey(conn)) { s_dataSchemaDict.Add(conn, new DataSchema(conn)); } return s_dataSchemaDict[conn]; }
/// <summary> /// 判断架构中是否包含指定的连接 /// </summary> /// <param name="conn"></param> /// <returns></returns> public static Boolean Contains(UserConn conn) { return s_dataSchemaDict.ContainsKey(conn); }