/// <summary> /// 若找到对应的数据实体则返回 true,否则返回 false . /// </summary> /// <returns></returns> public bool Load() { try { DatabaseCollection dbCollection = Context.RequestServices.GetService(typeof(DatabaseCollection)) as DatabaseCollection; if (dbCollection == null) { throw new Exception("未配置应用程序的数据库信息."); } service = DataService.Get <TestDataItemService>(dbCollection.Current); if (Context.Request.Query.ContainsKey("id")) { int dataId = -1; editMode = int.TryParse(Context.Request.Query["id"].ToString(), out dataId); if (!editMode) { throw new Exception("给定的记录 id 不正确."); } entity = service.Details(dataId); if (entity == null) { throw new Exception("未找到指定的记录,它可能已经被其它用户删除!"); } } return(true); } catch (Exception Ex) { Error = Ex.Message; return(false); } }
// 初始化用户集合对象 // parameters: // userDbs 帐户库集合 // strError out参数,返回出错信息 // return: // -1 出错 // 0 成功 // 线:安全的 public int Initial(DatabaseCollection dbs, out string strError) { strError = ""; this.m_dbs = dbs; //*********对帐户集合加写锁**************** m_lock.AcquireWriterLock(m_nTimeOut); #if DEBUG_LOCK this.m_dbs.WriteDebugInfo("Initial(),对用户集合加写锁。"); #endif try { // 清空成员 this.Clear(); } finally { m_lock.ReleaseWriterLock(); //解写锁 #if DEBUG_LOCK this.m_dbs.WriteDebugInfo("Initial(),对用户集合解写锁。"); #endif } StartWorkerThread(); return(0); }
/// <summary> /// 类型:方法 /// 名称:Setup /// 作者:taixihuase /// 作用:启动并初始化客户端 /// 编写日期:2015/7/12 /// </summary> protected override void Setup() { // 创建日志 GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(ApplicationRootPath, "log"); string path = Path.Combine(BinaryPath, "log4net.config"); var file = new FileInfo(path); if (file.Exists) { LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance); XmlConfigurator.ConfigureAndWatch(file); } Log.Debug(DateTime.Now + " : Server is running"); // 初始化数据库操作列表 Data = new DatabaseCollection(this); // 初始化用户列表 Users = new UserCollection(this); // 初始化玩家角色列表 Characters = new CharacterCollection(this); }
protected override void OnExecute(object parameter) { var database = parameter as DatabaseElement; if (database == null) { ModernDialog.ShowMessage("no field detected.", "error", MessageBoxButton.OK); return; } var parent = database.Parent; var table = new TableElement() { BaseClass = null, DbType = "SQLite", Description = null, Inherits = null, Name = "New Table", PrimaryKey = "id", Fields = { new FieldElement() { DataName = "id", DataTypeNative = "Int64", DataType = "INTEGER" } } }; table.Fields[0].Parent = table; table.Parent = database; DatabaseCollection.Rechild(database, table); database.Children.Add(table); View.RefreshDataTree(database); }
// #region Database Details // to load database names public void loaddbNames(ComboBox cbo) { //return objSQL.loaddbNames(); DatabaseCollection dbnamesCol = objSQL.loaddbNames(); cbo.Items.Clear(); cbo.Items.Add(""); if (dbnamesCol != null) { string dbnames = ""; int ival = 0; foreach (Database db in dbnamesCol) { if (ival < 6) { if (db.Name != "master") { cbo.Items.Add(db.Name); } } else { break; } ival = ival + 1; //if (db.Name != "master") //{ // cbo.Items.Add(db.Name); //} } } cbo.SelectedIndex = 0; }
private void button3_Click(object sender, EventArgs e) { int dbname = listBoxDb.SelectedIndex; string table = listBoxTbl.SelectedItem.ToString(); SpGenerate spGenerate = new SpGenerate(); DatabaseCollection dbs = server.GetDatabases(); Database db = dbs[dbname]; TableCollection tables = db.Tables; ColumnCollection columns = tables[listBoxTbl.SelectedIndex].Columns; List <string> spList = spGenerate.GenerateAllSp(columns, table); Server s = server.GetServer(); foreach (var item in spList) { StoredProcedure sp = new StoredProcedure(); //db.StoredProcedures.Add(); txtStoredProcedure.Text += item; txtStoredProcedure.Text += " "; } /* * * List<tip> : Verilen Tipte sinamik Liste olusturur. * string[] splist = new string[10]; */ }
private void comDatabases_DropDown(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; if (!this.blDbDropped) { if (!this.chkTrusted.Checked) { serverConnection = new ServerConnection(this.comServers.Text, this.txtUserName.Text, this.txtPassword.Text); } else { serverConnection = new ServerConnection(this.comServers.Text, this.txtUserName.Text, this.txtPassword.Text); //serverConnection = new ServerConnection(this.comServers.Text); } Server server = new Server(serverConnection); DatabaseCollection databases = server.Databases; this.comDatabases.Items.Clear(); foreach (Database database in databases) { this.comDatabases.Items.Add(database.Name); } //this.comDatabases.Items.Add("QlCg"); } //this.blDbDropped = true; this.Cursor = Cursors.Default; }
public List <DatabaseCollection> GetDatabaseNames() { try { var dbList = Client.ListDatabases().ToList(); Databases = new List <DatabaseCollection>(); foreach (string item in dbList) { IMongoDatabase db = Client.GetDatabase(item); DatabaseCollection t = new DatabaseCollection(); t.DatabasName = item; t.Collections = db.ListCollectionNames().ToList(); foreach (string col in t.Collections) { Entities.Add(GetEntityStructure(col)); } } return(Databases); } catch (Exception ex) { DMEEditor.AddLogMessage("Error", "Could not Get Databases From RavenDB " + ConnProp.ConnectionName, DateTime.Now, -1, ConnProp.Url, Errors.Failed); return(null); } }
public void GetDatabaseCollectionTest() { var schemaProvider = ServiceLocator.Instance.GetService <IDbSchemaProvider>(); DatabaseCollection databaseCollection = schemaProvider.GetDatabaseCollection(ConnectionString); Assert.IsNotNull(databaseCollection); Assert.IsTrue(databaseCollection.Count > 0); }
public void Collect(DatabaseCollection database) { TotalDatabases = database.Databases.Count; TotalFingers = database.FingerCount; TotalViews = database.FpCount; MatchingPairCount = database.GetMatchingPairCount(); NonMatchingPairCount = database.GetNonMatchingPairCount(); }
private void PrintCollectionInfo <T>(DatabaseCollection <T> collection) where T : DatabaseElement { string plural = collection.Type == DataFileType.GameSeries || collection.Type == DataFileType.News || collection.Type == DataFileType.CommonNames ? "" : "s"; Debug.Log($"Database - Loaded {collection.Collection.Count} {collection.Type}{plural}."); }
void RunExtractorBenchmark() { Console.WriteLine("Running extractor benchmark"); ExtractorReport report = ExtractorBenchmark.Run(); Console.WriteLine("Saving extractor report"); report.Save("Extractor"); MatcherBenchmark.TestDatabase = TestDatabase = report.Templates; }
internal static IEnumerable <Database> AllDb(DatabaseCollection databases) { var count = databases.Count; for (var i = 0; i < count; ++i) { yield return(databases[i]); } }
private void load(DatabaseCollection databases) { database = databases[0]; foreach (var o in Level.LevelObjects) { Add(new ObjectBase(o)); } }
private void CreateDataBase() { //bool check = CheckDataBase(); try { //if (check == false) //{ DatabaseCollection DB = server.Databases; for (int i = 0; i < DB.Count; i++) { if (DB[i].Name == "DB_A54A03_Resturant") { return; } } var script = File.ReadAllText(Application.StartupPath + @"\scripts.sql"); var sqlQuary = script.Split(new[] { "GO" }, StringSplitOptions.RemoveEmptyEntries); // var CONN = new SqlConnection(@"server =.\SQLExpress;integrated security=true"); var CONN = new SqlConnection(@"server =.;integrated security=true"); var cmd = new SqlCommand("query", CONN); CONN.Open(); foreach (var queary in sqlQuary) { cmd.CommandText = queary; cmd.ExecuteNonQuery(); } CONN.Close(); //var x = @"server =.\SQLExpress;integrated security=true"; //var script = File.ReadAllText(Application.StartupPath + @"\scripts.sql"); //SqlConnection CONN = new SqlConnection(x); //Server servers = new Server(new ServerConnection(CONN)); //servers.ConnectionContext.ExecuteNonQuery(script); //} } catch (Exception) { } }
public void SetDataGridView_ASDatabases(Server S) { DatabaseCollection DC = S.Databases; foreach (Database D in DC) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells[0].Value = D.Name; } }
private void load(DatabaseCollection databases, TextureStore ts) { database = databases[0]; texStore = ts; background.Texture = texStore.Get("Backgrounds/game_bg_01_001-uhd.png"); Anchor = Anchor.Centre; Origin = Anchor.Centre; AddMenuItems(); }
private static bool LoadDataFile <T>(string dataFile, DataFileType dataType, DatabaseCollection <T> existing) where T : DatabaseElement { // JSON formatting string dataFileContent = JsonFormatter.Format(File.ReadAllText(dataFile)); if (dataFileContent == null) { Debug.LogWarning($"Database - Invalid {dataType} JSON format in \"{dataFile}\" data file."); return(false); } // JSON parsing DatabaseCollection <T> additions; try { additions = JsonUtility.FromJson <DatabaseCollection <T> >(dataFileContent); } catch (ArgumentException e) { Debug.LogError($"Database.LoadDataFile(\"{dataFile}\", {dataType}) : JSON error :\n{e.Message}"); Debug.LogError($"Formatted JSON :\n{dataFileContent}"); return(false); } if (additions == null) { Debug.LogWarning( $"Database - Invalid {dataType} JSON in \"{dataFile}\" data file."); return(false); } // Database processing foreach (var element in additions.Collection) { if (existing.Collection.Any(e => element.Id == e.Id)) { Debug.LogWarning( $"Database - {dataType} element of ID \"{element.Id}\" already exists."); continue; } if (existing.NamesAreUnique && existing.Collection.Any(e => element.Name == e.Name)) { Debug.LogWarning( $"Database - {dataType} element of name \"{element.Name}\" already exists (unique names activated)."); continue; } if (!element.IsValid()) { Debug.LogWarning($"Database - {dataType} element of ID \"{element.Id}\" is invalid."); continue; } existing.Collection.Add(element); } return(true); }
/// <summary> /// 连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnConnect_Click(object sender, EventArgs e) { string strServer = this.txtServerName.Text.Trim(); string strUname = this.txtUname.Text.Trim(); string strPwd = this.txtPwd.Text.Trim(); if (!string.IsNullOrEmpty(strServer)) { if (!string.IsNullOrEmpty(strUname)) { if (!string.IsNullOrEmpty(strPwd)) { ServerConnection sc = null; try { Server ser = new Server(); ser.ConnectionContext.ServerInstance = strServer; sc = ser.ConnectionContext; sc.LoginSecure = false; //指定是windows身份验证还是sqlservere验证 sc.Login = strUname; sc.Password = strPwd; dbs = ser.Databases; sc.Connect(); bindDataBaseToCombox(); } catch (Exception ex) { MessageBox.Show(string.Format("发生错误,连接失败!\r\n错误原因:{0}", ex.Message), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (sc != null) { sc.Cancel(); } } } else { MessageBox.Show("请输入密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("请输入用户名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("请输入服务器名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnConnect_Click(object sender, EventArgs e) { string strServer = this.txtServerName.Text.Trim(); string strUname = this.txtUname.Text.Trim(); string strPwd = this.txtPwd.Text.Trim(); if (!string.IsNullOrEmpty(strServer)) { if (!string.IsNullOrEmpty(strUname)) { if (!string.IsNullOrEmpty(strPwd)) { ServerConnection sc=null; try { Server ser = new Server(); ser.ConnectionContext.ServerInstance = strServer; sc = ser.ConnectionContext; sc.LoginSecure = false; //指定是windows身份验证还是sqlservere验证 sc.Login = strUname; sc.Password = strPwd; dbs = ser.Databases; sc.Connect(); bindDataBaseToCombox(); } catch (Exception ex) { MessageBox.Show(string.Format("发生错误,连接失败!\r\n错误原因:{0}", ex.Message), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (sc != null) { sc.Cancel(); } } } else { MessageBox.Show("请输入密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("请输入用户名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("请输入服务器名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnCheck_Click(object sender, EventArgs e) { // prvo provjeri konekciju // potom provjeri dotiènu bazu Server server = new Server(txtServer1.Text); DatabaseCollection dbs = server.Databases; Database db = dbs[txtDB1.Text]; //db.UserName = txtUN1.Text; }
// empty #region GeneratorDataCollectionCreate #if !NCORE // FIXME: THIS DOES NOTHING?! /// <summary> /// this is a template method—as in that it is generally an empty method. /// </summary> static public void GeneratorDataCollectionCreate() { sfd.Filter = "xconfig|*.xconfig|xml|*.xml|all files|*"; #if WPF4 if (!sfd.ShowDialog().Value) { return; } #elif !NCORE if (sfd.ShowDialog() != DialogResult.OK) { return; } #endif List <string> list = new List <string>(); string fname = sfd.FileName; DatabaseCollection c = DatabaseCollection.Load(fname); int dbid = 1, tid = 1; foreach (DatabaseElement elmDb in c.Databases) { using (var ct = new System.Cor3.Data.Context.SQLiteContext()) { foreach (TableElement elmT in elmDb.Items) { foreach (FieldElement elmF in elmT.Fields) { } tid++; } } dbid++; } // string output = string.Empty; // using (SQLiteContext c0 = new SQLiteContext()) // { // c.Select("select * from sqlite_master"); // using (DataView v = c.Data.GetDataView(0)) // { // foreach (DataRowView row in v) // { // list.Add(string.Format("# {0}",row["name"])); // list.Add(""); // list.Add(row["sql"].ToString()); // list.Add(""); // } // } // } }
// TODO: 改进为可以重复调用。然后被 Dispose() 调用 // 关闭 public void Close() { eventClose.Set(); // 令工作线程退出 // 等待工作线程真正退出 // 因为可能正在回写数据库 eventFinished.WaitOne(5000, false); // 最多5秒 if (this.Dbs != null) { try { this.Dbs.Close(); } catch (Exception ex) { this.WriteErrorLog("Dbs Close() error : " + ex.Message); } // this.Dbs.WriteErrorLog("在GlobalInfo.Close()处保存database.xml"); } try { if (this.Users != null) { this.Users.Close(); this.Users = null; } } catch (Exception ex) { this.WriteErrorLog("Users Close() error : " + ex.Message); } if (this.ResultSets != null) { try { this.ResultSets.Clean(new TimeSpan(0, 0, 0)); // 立即全部清除 } catch (Exception ex) { this.WriteErrorLog("释放 ResultSets 遇到异常:" + ExceptionUtil.GetDebugText(ex)); } } this.WriteErrorLog("kernel application 成功降落。"); this.Dbs = null; }
private void button4_Click(object sender, EventArgs e) { int dbname = listBoxDb.SelectedIndex; string table = listBoxTbl.SelectedItem.ToString(); SpGenerate spGenerate = new SpGenerate(); DatabaseCollection dbs = server.GetDatabases(); Database db = dbs[dbname]; TableCollection tables = db.Tables; ColumnCollection columns = tables[listBoxTbl.SelectedIndex].Columns; spGenerate.AddCrudSp(db, "Shippers", columns); }
private void listBoxDb_SelectedIndexChanged(object sender, EventArgs e) { int dbname = listBoxDb.SelectedIndex; DatabaseCollection dbs = server.GetDatabases(); Database db = dbs[dbname]; TableCollection tables = db.Tables; listBoxTbl.Items.Clear(); foreach (var item in tables) { listBoxTbl.Items.Add(item.ToString()); } }
void InitializeConfiguration(object o, RoutedEventArgs a) { // try { Model.Databases = DatabaseCollection.Load(Model.Configuration.datafile); Model.Templates = TemplateCollection.Load(Model.Configuration.templatefile); // why is this necessary? Model.Databases.Rechild(); a.Handled = true; // } catch (Exception e) { // throw e; // } finally { if (InitializeCompleteAction != null) { InitializeCompleteAction.Invoke(); } // } }
public string[] ListDatabases(string ConnectionString) { List <string> databaseNames = new List <string>(); Server server = new Server(new ServerConnection(new SqlConnection(ConnectionString))); DatabaseCollection databases = server.Databases; for (int i = 0; i < databases.Count; i++) { if (!databases[i].IsSystemObject) { databaseNames.Add(databases[i].Name); } } return(databaseNames.ToArray()); }
static public string Parse( DatabaseCollection databases, DatabaseElement database, TemplateCollection templates, TableElement table, TableTemplate template ) { return(Parse( new DataCfg() { Databases = databases, Database = database, Table = table, Templates = templates, Template = template })); }
private void DeleteDataBase() { try { DatabaseCollection DB = server.Databases; for (int i = 0; i < DB.Count; i++) { if (DB[i].Name == "DB_A54A03_Resturant") { server.KillDatabase("DB_A54A03_Resturant"); MessageBox.Show("تم مسح قاعدة البيانات بنجاح"); } } } catch (Exception) { } }
/// <summary> /// For Database related all Functions /// </summary> /// <returns> </returns> #region Database Details /// <summary> /// This method is to get all the database name and return the DatabaseCollections /// </summary> /// <returns> return the DatabaseCollections</returns> #region load Database public DatabaseCollection loaddbNames() { DatabaseCollection dbNames = null; try { if (SqlServerConnect()) { Server srv = new Server(servConn); dbNames = srv.Databases; SqlServerDisconnect(); } } catch (Exception ex) { writeLogMessage(ex.Message.ToString()); } return(dbNames); }
public IDictionary <string, IDictionary <string, string[]> > ListDatabaseTables(string ConnectionString, string DatabaseName) { Server server = new Server(new ServerConnection(new SqlConnection(ConnectionString))); IDictionary <string, IDictionary <string, string[]> > databaseDictionary = new SortedDictionary <string, IDictionary <string, string[]> >(); IDictionary <string, string[]> tableDictionary = null; List <string> columnNameList = null; DatabaseCollection databases = server.Databases; for (int i = 0; i < databases.Count; i++) { if ((!databases[i].IsSystemObject) && (databases[i].Name.ToLower() == DatabaseName.ToLower())) { tableDictionary = new SortedDictionary <string, string[]>(); for (int j = 0; j < databases[i].Tables.Count; j++) { if (!databases[i].Tables[j].IsSystemObject) { columnNameList = new List <string>(); for (int k = 0; k < databases[i].Tables[j].Columns.Count; k++) { columnNameList.Add(databases[i].Tables[j].Columns[k].Name); } tableDictionary.Add(databases[i].Tables[j].Name, columnNameList.ToArray()); } } databaseDictionary.Add(databases[i].Name, tableDictionary); break; } } return(databaseDictionary); }
public DatabaseTicker() { databases = new DatabaseCollection(); }
private static IList<string> GetDatabasesInfo(DatabaseCollection databases) { var lst = new List<string>(); for (var i = 0; i < databases.Count; ++i) { lst.Add(string.Format("Name:{0}", databases[i].Name)); } return lst; }