public ActionResult Ajax_Find() { var sr = new StreamReader(Request.InputStream); // 获取post请求中的表单数据流 var stream = sr.ReadToEnd(); var dict = String2Dict(stream); DataBaseServer dbserver = new DataBaseServer(); var result = dbserver.GetFPY(dict["proc"], dict["line"], dict["stime"]); // 查询数据 List <string> x = new List <string>(); // 准备ECharts需要的数据和格式 List <int> passcount = new List <int>(); List <int> failcount = new List <int>(); List <double> rate = new List <double>(); List <double> stime = new List <double>(); foreach (var i in result) { x.Add(i["hour"] + "时"); passcount.Add(int.Parse(i["passcount"])); failcount.Add(int.Parse(i["failcount"])); rate.Add(int.Parse(i["passcount"]) * 100 / int.Parse(i["scount"])); stime.Add(double.Parse(i["stime"])); } var json_data = new // 合并到一起转json,注:一定要用这种方式,否则js不能直接解析。 { hour = x, passcounts = passcount, failcounts = failcount, rates = rate, stimes = stime }; return(Json(json_data, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(DataBaseServer dataBaseServer, FormCollection form) { var oldserver = db.DataBaseServers.Find(dataBaseServer.ServerID); SetFilePaths(oldserver, form); nt.TestSqlConnection(dataBaseServer); if (ModelState.IsValid && nt.Errors.Count == 0) { oldserver.BranchID = dataBaseServer.BranchID; oldserver.DataBaseAccountID = dataBaseServer.DataBaseAccountID; oldserver.DataBaseName = dataBaseServer.DataBaseName; oldserver.Machine.MachineIP = dataBaseServer.Machine.MachineIP; oldserver.Machine.MachineName = dataBaseServer.Machine.MachineName; oldserver.NetworkAccountID = dataBaseServer.NetworkAccountID; db.Entry(oldserver).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DataBaseAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.SQL), "AccountID", "AccountName", dataBaseServer.DataBaseAccountID); ViewBag.BranchID = new SelectList(db.Branches, "BranchID", "BranchName", dataBaseServer.BranchID); ViewBag.NetworkAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.Windows), "AccountID", "AccountName", dataBaseServer.NetworkAccountID); return(View(dataBaseServer)); }
// 填充下拉表单 public ActionResult Find() { DataBaseServer dbserver = new DataBaseServer(); var proc_items = dbserver.GetProcs(); ViewData["downData"] = new SelectList(proc_items, "Value", "Text"); var line_items = new List <SelectListItem> { new SelectListItem { Text = "AL-01D-A" }, new SelectListItem { Text = "AL-02D-B" }, new SelectListItem { Text = "LL-01D" }, new SelectListItem { Text = "LL-06D" } }; ViewData["line_items"] = new SelectList(line_items, "Text", "Text"); return(View()); }
public void run() { try { BeginCase("BeginTransaction"); tran = con.BeginTransaction(); Compare(tran == null, false); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } con.Close(); con.Open(); try { BeginCase("BeginTransaction - IsolationLevel ReadCommitted"); tran = con.BeginTransaction(IsolationLevel.ReadCommitted); Compare(tran == null, false); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } DataBaseServer dbType = ConnectedDataProvider.GetDbType(con); //Not supported by JDBC driver for oracle if (dbType != DataBaseServer.Oracle) { con.Close(); con.Open(); try { BeginCase("BeginTransaction - IsolationLevel ReadUncommitted"); tran = con.BeginTransaction(IsolationLevel.ReadUncommitted); Compare(tran == null, false); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } con.Close(); con.Open(); try { BeginCase("BeginTransaction - IsolationLevel RepeatableRead"); tran = con.BeginTransaction(IsolationLevel.RepeatableRead); Compare(tran == null, false); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } con.Close(); con.Open(); try { BeginCase("BeginTransaction - IsolationLevel Serializable"); tran = con.BeginTransaction(IsolationLevel.Serializable); Compare(tran == null, false); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } } }
public ServerActor() { Context.ActorOf(ClientServer.Props(), "ClientServer"); Context.ActorOf(LocalServer.Props(), "LocalServer"); Context.ActorOf(DataBaseServer.Props(), "DataBaseServer"); Receive <MessageOfListViewUpdateLocalList>(updatedLocal => LocalToClient_Send_CreatedLocalID(updatedLocal)); Receive <MessageOfRequestLocalIDs>(requestedLocalID => RequestAllLocalID(requestedLocalID)); Receive <MessageOfReturnLocalID>(returnLocal => ReturnAllLocalID(returnLocal)); Receive <UpdateMonitor>(receivedLocalData => SendToClient_DataOfLocal(receivedLocalData)); Receive <UnsubscribeMonitorLocal>(deletedLocal => DeleteLocal(deletedLocal)); Schedule = Context .System .Scheduler .ScheduleTellRepeatedlyCancelable( TimeSpan.Zero, // The time period that has to pass before the first message is sent. TimeSpan.FromSeconds(1), // The interval, i.e. the time period that has to pass between messages are being sent. Self, // The receiver. new Start(), // The message. Self); // The sender. Receive <Start>(_ => Handle(_)); }
public void TestBeginTransactionChaos() { DataBaseServer dbType = ConnectedDataProvider.GetDbType(con); // not supported on DB2 and Oracle and Sybase if (dbType != DataBaseServer.Oracle && dbType != DataBaseServer.DB2 && dbType != DataBaseServer.Sybase) { con.Close(); con.Open(); try { BeginCase("BeginTransaction - IsolationLevel Chaos"); tran = con.BeginTransaction(IsolationLevel.Chaos); Compare(tran == null, false); } catch (Exception ex) { exp = ex; } finally{ EndCase(exp); exp = null; } } /* not supported by MSSQL,DB2,Oracle * con.Close(); * con.Open(); * try * { * BeginCase("BeginTransaction - IsolationLevel Unspecified"); * tran = con.BeginTransaction(IsolationLevel.Unspecified ); * Compare(tran == null, false); * } * catch(Exception ex){exp = ex;} * finally{EndCase(exp); exp = null;} */ }
public int RefreshDatabaseFileSize(DataBaseServer srv, bGomlaDBreportEntities db) { var files = srv.DataBaseFiles; if (!srv.Online) { return(0); } foreach (var file in files) { var fs = file.DataBaseFilesSizes.OrderByDescending(x => x.DateTaken).FirstOrDefault(); if (fs.DateTaken.Date != DateTime.Now.Date) { var curent = FileSizeMB(file); file.DataBaseFilesSizes.Add(new DataBaseFilesSize { DateTaken = DateTime.Now, Size = curent }); } } return(db.SaveChanges()); }
private void SetFilePaths(DataBaseServer srv, FormCollection form) { if (srv.DataBaseFiles.Count == 0) { DataBaseServer s = new DataBaseServer(db); srv.DataBaseFiles = s.DataBaseFiles; } DataBaseFile dbf = new DataBaseFile(); foreach (var item in _app.DB.DataBaseFilesName) { dbf = srv.DataBaseFiles.FirstOrDefault(x => x.DataBaseFilesName.FileID == item.FileID); dbf.FilePath = form["filepath_" + item.FileName].ToString(); if (dbf.DataBaseFilesSizes.Count > 0) { if (dbf.DataBaseFilesSizes.OrderByDescending(x => x.DateTaken).FirstOrDefault().DateTaken.Date < DateTime.Now.Date) { dbf.DataBaseFilesSizes.Add(new DataBaseFilesSize { DateTaken = DateTime.Now, Size = file.FileSizeMB(dbf, srv) }); } } else { dbf.DataBaseFilesSizes.Add(new DataBaseFilesSize { DateTaken = DateTime.Now, Size = file.FileSizeMB(dbf, srv) }); } } }
private void GetDBSpecificSyntax(DataBaseServer dbServer, out string beginStatement, out string endStatement, out string commandDelimiter) { switch (dbServer) { case DataBaseServer.SQLServer: case DataBaseServer.PostgreSQL: beginStatement = ""; endStatement = ""; commandDelimiter = ";"; break; case DataBaseServer.Sybase: beginStatement = "BEGIN"; endStatement = "END"; commandDelimiter = ""; break; case DataBaseServer.Oracle: beginStatement = "BEGIN"; endStatement = "END;"; commandDelimiter = ";"; break; case DataBaseServer.DB2: beginStatement = "BEGIN ATOMIC"; endStatement = "END"; commandDelimiter = ";"; break; default: this.Fail("Unknown DataBaseServer type"); throw new ApplicationException("Unknown DataBaseServer type"); } }
private void btnTestConnection_Click(object sender, System.EventArgs e) { if (WindowsAutentificaction.Checked && txtServer.Text.Trim() == String.Empty) { return; } if (txtServer.Text.Trim() == String.Empty) { return; } try { if (DataBaseServer.TestConnection(txtServer.Text.Trim(), txtUserName.Text.Trim(), txtPassword.Text.Trim(), WindowsAutentificaction.Checked)) { MessageBox.Show("La conexion se realizo con exito"); ConnectionOK = true; OnConnectionSourceChangeEvent(); } else { MessageBox.Show("La conexion fallo", "Error de coneccion"); ConnectionOK = false; } } catch (Exception ex) { string wErrMessage = "Error al intentar conetar al servidor de Base de Datos" + Environment.NewLine; wErrMessage += ex.Message; MessageBox.Show(wErrMessage, "Error de conección"); } }
public decimal FileSizeMB(DataBaseFile dbf, DataBaseServer srv) { _app.Networking nt = new Networking(); string filePath = nt.RelosveFullPath(srv, dbf.FilePath); // access admin share to file path return(FileSizeMB(filePath)); }
public ActionResult DeleteConfirmed(int id) { DataBaseServer dataBaseServer = db.DataBaseServers.Find(id); db.DataBaseServers.Remove(dataBaseServer); db.SaveChanges(); return(RedirectToAction("Index")); }
private void TypesTests(DbTypeParametersCollection typesToTest) { exp = null; DbTypeParametersCollection currentlyTested = new DbTypeParametersCollection(typesToTest.TableName); string rowId = "13289"; object dbValue; OracleDataReader rdr = null; OracleConnection selectCon = null; DataBaseServer testedDbServer = ConnectedDataProvider.GetDbType(); foreach (DbTypeParameter currentParamType in typesToTest) { BeginCase("Test value of db type: " + currentParamType.DbTypeName); //Prepare data: rowId = string.Format("13289_{0}", this.TestCaseNumber); currentlyTested.Clear(); currentlyTested.Add(currentParamType); currentlyTested.ExecuteInsert(rowId); try { currentlyTested.ExecuteSelectReader(rowId, out rdr, out selectCon); rdr.Read(); dbValue = WorkaroundOracleCharsPaddingLimitation(testedDbServer, currentParamType, rdr.GetValue(0)); if (currentParamType.Value.GetType().IsArray) { Compare(dbValue as Array, currentParamType.Value as Array); } else { Compare(dbValue, currentParamType.Value); } } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; if (rdr != null && !rdr.IsClosed) { rdr.Close(); } if (selectCon != null && selectCon.State != ConnectionState.Closed) { selectCon.Close(); } currentlyTested.ExecuteDelete(rowId); } } }
public override void Process() { Server serverInfo = DataBaseServer.GetServerInfo(serverId); serverInfo.channels = DataBaseServer.GetServerChannel(serverInfo.id); if (!AgentServer.SvrListInfo.Contains(serverInfo)) { AgentServer.SvrListInfo.Add(serverInfo); Log.Info("Registered Server ID: {0} - {1} Channels..", serverInfo.id, serverInfo.channels.Count); } }
/// <summary> /// This is a workaround for the extra white spaces added in oracle to NCHAR & NVARCHAR values. /// The problem is a documented GH limitation, see bug #3417. /// The workaround is to trim the lemgth of the returned string to the specified length of the parameter/column. /// </summary> /// <param name="testedServer">The database server we are currently running on.</param> /// <param name="val">The value returned from the database.</param> /// <returns>The normalized value..</returns> private object WorkaroundOracleCharsPaddingLimitation(DataBaseServer testedServer, DbTypeParameter currentParam, object val) { object origVal = val; string dbTypeName = currentParam.DbTypeName.ToUpper(); if ((testedServer == DataBaseServer.Oracle) && (dbTypeName == "CHAR" || dbTypeName == "NCHAR")) { val = ((string)val).Substring(0, currentParam.Size); Log(string.Format("Worked around oracle chars padding limitation by triming '{0}' to '{1}'", origVal, val)); } return(val); }
public int RefreshBackupLog(DataBaseServer srv, bGomlaDBreportEntities db) { _app.Files fe = new Files(); _app.Networking nt = new Networking(); int i = 0; if (!srv.Online) { return(i); } foreach (var bkt in srv.ServerBackups) { // mark all files as do not exitis if (bkt.LastFile.DateCreated.AddMinutes(bkt.intervalMin) < DateTime.Now) { foreach (var item in bkt.BackupLogs) { item.FileExists = false; } BackupLog log = new BackupLog(); var fls = fe.FilesInFolder(nt.RelosveFullPath(bkt.DataBaseServer, bkt.Location), bkt.BackupType.FilesExtintion); foreach (var f in fls) { log = bkt.BackupLogs.FirstOrDefault(x => x.FileName == f.Name); if (log == null) { log = new BackupLog { FileName = f.Name, DateCreated = f.CreationTime, SrvBkId = bkt.DbServerID, FilePath = bkt.Location, FileSize = fe.FileSizeMB(f), }; bkt.BackupLogs.Add(log); } log.FileExists = true; } i += db.SaveChanges(); } } return(i); }
// GET: DataBaseServers/Create public ActionResult Create() { ViewBag.DataBaseAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.SQL), "AccountID", "AccountName"); ViewBag.BranchID = new SelectList(db.Branches, "BranchID", "BranchName"); ViewBag.NetworkAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.Windows), "AccountID", "AccountName"); // ViewBag.ServerID = new SelectList(db.Machines, "MachineID", "MachineName"); DataBaseServer srv = new DataBaseServer(db); // srv.DataBaseFiles.Add( new DataBaseFile { DataBaseFilesName = }) return(View(srv)); }
/// <summary> /// Establece los valores de los controles que muestran la informacion de coneccions .- /// </summary> public void InitialiceControl() { try { _DataBaseServer = new DataBaseServer(true); if (_DataBaseServer.CnnString == null) { return; } txtServer.Text = _DataBaseServer.CnnString.DataSource; cnnStringListBindingSource.DataSource = _DataBaseServer.CnnStringList; cmbConnections.SelectedIndex = 0; cmbConnections.Refresh(); WindowsAutentificaction.Checked = _DataBaseServer.CnnString.WindowsAutentification; if (!_DataBaseServer.CnnString.WindowsAutentification) { txtUserName.Text = _DataBaseServer.CnnString.User; txtPassword.Text = _DataBaseServer.CnnString.Password; } else { txtUserName.Text = String.Empty; txtPassword.Text = String.Empty; } cmbDataBases.Items.Add(_DataBaseServer.CnnString.InitialCatalog); cmbDataBases.Text = _DataBaseServer.CnnString.InitialCatalog; } catch (DataBaseExeption ex) { txtServer.Text = ex.CnnString.DataSource; txtUserName.Text = ex.CnnString.User; txtPassword.Text = ex.CnnString.Password; txtPassword.Focus(); WindowsAutentificaction.Checked = ex.CnnString.WindowsAutentification; cmbDataBases.Items.Add(ex.CnnString.InitialCatalog); cmbDataBases.Text = ex.CnnString.InitialCatalog; MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error de conección"); } }
// GET: DataBaseServers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DataBaseServer dataBaseServer = db.DataBaseServers.Find(id); if (dataBaseServer == null) { return(HttpNotFound()); } return(View(dataBaseServer)); }
public void SetUp() { Exception exp = null; BeginCase("Setup"); try { con = new OleDbConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); con.Open(); tr = con.BeginTransaction(); cmd = new OleDbCommand("", con, tr); dbServerType = ConnectedDataProvider.GetDbType(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); Assert.AreEqual("Setup", "Setup"); } catch(Exception ex) {exp = ex;} finally {EndCase(exp); exp = null;} }
public void SetUp() { Exception exp = null; BeginCase("Setup"); try { con = new OleDbConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); con.Open(); tr = con.BeginTransaction(); cmd = new OleDbCommand("", con, tr); dbServerType = ConnectedDataProvider.GetDbType(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString); Assert.AreEqual("Setup", "Setup"); } catch (Exception ex) { exp = ex; } finally { EndCase(exp); exp = null; } }
public ActionResult Create(DataBaseServer dataBaseServer, FormCollection form) { SetFilePaths(dataBaseServer, form); nt.TestSqlConnection(dataBaseServer); if (ModelState.IsValid && nt.Errors.Count == 0) { db.DataBaseServers.Add(dataBaseServer); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DataBaseAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.SQL), "AccountID", "AccountName", dataBaseServer.DataBaseAccountID); ViewBag.BranchID = new SelectList(db.Branches, "BranchID", "BranchName", dataBaseServer.BranchID); ViewBag.NetworkAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.Windows), "AccountID", "AccountName", dataBaseServer.NetworkAccountID); // ViewBag.ServerID = new SelectList(db.Machines, "MachineID", "MachineName", dataBaseServer.ServerID); return(View(dataBaseServer)); }
// GET: DataBaseServers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DataBaseServer dataBaseServer = db.DataBaseServers.Find(id); if (dataBaseServer == null) { return(HttpNotFound()); } ViewBag.DataBaseAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.SQL).ToList(), "AccountID", "AccountName", dataBaseServer.DataBaseAccountID); ViewBag.BranchID = new SelectList(db.Branches, "BranchID", "BranchName", dataBaseServer.BranchID); ViewBag.NetworkAccountID = new SelectList(db.AccessAccounts.Where(x => x.TypeID == _app.Auth.Windows), "AccountID", "AccountName", dataBaseServer.NetworkAccountID); return(View(dataBaseServer)); }
//Create the compund sql statement according to the dbserver. private string CreateCompundSqlStatement(string[] sqlStatements, DataBaseServer dbServer) { string beginStatement; string endStatement; string commandDelimiter; GetDBSpecificSyntax(dbServer, out beginStatement, out endStatement, out commandDelimiter); StringBuilder cmdBuilder = new StringBuilder(); cmdBuilder.Append(beginStatement); cmdBuilder.Append(" "); foreach (string statement in sqlStatements) { cmdBuilder.Append(statement); cmdBuilder.Append(commandDelimiter); cmdBuilder.Append(" "); } cmdBuilder.Append(endStatement); return(cmdBuilder.ToString()); }
public void TestSqlConnection(DataBaseServer server) { string str = @"data source={servername};initial catalog={dabasename};Integrated Security=false; User ID={userid}; Password={password};"; str = str.Replace("{servername}", server.Machine.MachineName); str = str.Replace("{dabasename}", server.DataBaseName); AccessAccount acc = new AccessAccount(); if (server.DBAccount == null) { bGomlaDBreportEntities db = new bGomlaDBreportEntities(); acc = db.AccessAccounts.FirstOrDefault(x => x.AccountID == server.DataBaseAccountID); } else { acc = server.DBAccount; } str = str.Replace("{userid}", acc.AccountName); str = str.Replace("{password}", acc.AccountPassword); SqlConnection con = new SqlConnection(str); try { con.Open(); } catch (Exception e) { addError(e.Message); } }
private void GetDBSpecificSyntax(DataBaseServer dbServer, out string beginStatement, out string endStatement, out string commandDelimiter) { switch (dbServer) { case DataBaseServer.SQLServer: beginStatement = "BEGIN"; endStatement = "END"; commandDelimiter = ";"; break; case DataBaseServer.Sybase: beginStatement = "BEGIN"; endStatement = "END"; commandDelimiter = "\r\n"; break; case DataBaseServer.Oracle: beginStatement = "BEGIN"; endStatement = "END;"; commandDelimiter = ";"; break; case DataBaseServer.DB2: { beginStatement = ""; endStatement = ""; } commandDelimiter = ";"; break; case DataBaseServer.PostgreSQL: beginStatement = ""; endStatement = ""; commandDelimiter = ";"; break; default: this.Fail("Unknown DataBaseServer type"); throw new ApplicationException("Unknown DataBaseServer type"); } }
public string ResloveMachineName(DataBaseServer srv) { return(@"\\" + srv.Machine.MachineName); }
private void cmbDataBases_Click(object sender, System.EventArgs e) { DataBaseServer wDataBaseServer = null; try { wDataBaseServer = new DataBaseServer(true); if (WindowsAutentificaction.Checked) { if (txtServer.Text.Trim() == String.Empty) { return; } } else { if (txtServer.Text.Trim() == String.Empty || txtUserName.Text.Trim() == String.Empty) { return; } } if (ComboDataBasesLoad == false) { if (DataBaseServer.TestConnection(txtServer.Text.Trim(), txtUserName.Text.Trim(), txtPassword.Text.Trim(), WindowsAutentificaction.Checked)) { cmbDataBases.Items.Clear(); if (wDataBaseServer.CnnString == null) { wDataBaseServer.CreateConnection(); } wDataBaseServer.CnnString.DataSource = txtServer.Text.Trim(); wDataBaseServer.CnnString.User = txtUserName.Text.Trim(); wDataBaseServer.CnnString.Password = txtPassword.Text.Trim(); wDataBaseServer.CnnString.WindowsAutentification = WindowsAutentificaction.Checked; DataTable dttDataBases = wDataBaseServer.GetDataBases(); foreach (DataRow dtr in dttDataBases.Rows) { cmbDataBases.Items.Add(dtr["DATABASE_NAME"].ToString()); } ComboDataBasesLoad = true; } else { MessageBox.Show("Los parametros de conexion no son validos.- Verifique nombre de usuario y contraseña", "Error de conección"); ConnectionOK = false; } } } catch (DataBaseExeption wDataBaseExeption) { txtServer.Text = wDataBaseExeption.CnnString.DataSource; txtUserName.Text = wDataBaseExeption.CnnString.User; txtPassword.Text = wDataBaseExeption.CnnString.Password; txtPassword.Focus(); WindowsAutentificaction.Checked = wDataBaseExeption.CnnString.WindowsAutentification; cmbDataBases.Items.Add(wDataBaseExeption.CnnString.InitialCatalog); cmbDataBases.Text = wDataBaseExeption.CnnString.InitialCatalog; MessageBox.Show(wDataBaseExeption.Message, "Error de conección"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error de conección"); } }
/// <summary> /// Establece los valores de los controles que muestran la informacion de coneccions .- /// </summary> public void InitialiceControl() { try { _DataBaseServer = new DataBaseServer(true); if (_DataBaseServer.CnnString == null) return; txtServer.Text = _DataBaseServer.CnnString.DataSource; cnnStringListBindingSource.DataSource = _DataBaseServer.CnnStringList; cmbConnections.SelectedIndex = 0; cmbConnections.Refresh(); WindowsAutentificaction.Checked = _DataBaseServer.CnnString.WindowsAutentification; if (!_DataBaseServer.CnnString.WindowsAutentification) { txtUserName.Text = _DataBaseServer.CnnString.User; txtPassword.Text = _DataBaseServer.CnnString.Password; } else { txtUserName.Text = String.Empty; txtPassword.Text = String.Empty; } cmbDataBases.Items.Add(_DataBaseServer.CnnString.InitialCatalog); cmbDataBases.Text = _DataBaseServer.CnnString.InitialCatalog; } catch (DataBaseExeption ex) { txtServer.Text = ex.CnnString.DataSource; txtUserName.Text = ex.CnnString.User; txtPassword.Text = ex.CnnString.Password; txtPassword.Focus(); WindowsAutentificaction.Checked = ex.CnnString.WindowsAutentification; cmbDataBases.Items.Add(ex.CnnString.InitialCatalog); cmbDataBases.Text = ex.CnnString.InitialCatalog; MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error de conección"); } }
private void btnGuardar_Click(object sender, System.EventArgs e) { //DataBaseServer wDataBaseServer = null; if (String.IsNullOrEmpty(txtServer.Text)) { MessageBox.Show("Falta ingresar nombre del servidor"); txtServer.Focus(); return; } if (!WindowsAutentificaction.Checked) { if (String.IsNullOrEmpty(txtUserName.Text)) { MessageBox.Show("Falta ingresar nombre de usuario"); txtUserName.Focus(); return; } } try { _DataBaseServer = new DataBaseServer(true); CnnString wCnnString = GetAuxiliarCnnString(); //Pregunto si los datos ingresados dan OK a una coneccion antes de //guardar la configuracion.- if (DataBaseServer.TestConnection(wCnnString)) { FillCurrentCnnString(); //wDataBaseServer.SaveSetting(wCnnString); if (_DataBaseServer.SaveSetting(wCnnString)) { //wDataBaseServer.CurrentCnnString.Name = cmbConnections.Text; } ConnectionOK = true; } else { MessageBox.Show("La conexion no se pudo realizar", "Error de conección"); ConnectionOK = false; } } catch (DataBaseExeption wDataBaseExeption) { ConnectionOK = false; txtServer.Text = wDataBaseExeption.CnnString.DataSource; txtUserName.Text = wDataBaseExeption.CnnString.User; txtPassword.Text = wDataBaseExeption.CnnString.Password; WindowsAutentificaction.Checked = wDataBaseExeption.CnnString.WindowsAutentification; cmbDataBases.Items.Add(wDataBaseExeption.CnnString.InitialCatalog); cmbDataBases.Text = wDataBaseExeption.CnnString.InitialCatalog; txtPassword.Focus(); MessageBox.Show(wDataBaseExeption.Message); } catch (Exception ex) { ConnectionOK = false; MessageBox.Show(ex.Message, "Error de conección"); } finally { OnAceptEvent(ConnectionOK); } }
private void btnGuardar_Click(object sender, System.EventArgs e) { //DataBaseServer wDataBaseServer = null; if (String.IsNullOrEmpty(txtServer.Text)) { MessageBox.Show("Falta ingresar nombre del servidor"); txtServer.Focus(); return; } if (!WindowsAutentificaction.Checked) if (String.IsNullOrEmpty(txtUserName.Text)) { MessageBox.Show("Falta ingresar nombre de usuario"); txtUserName.Focus(); return; } try { _DataBaseServer = new DataBaseServer(true); CnnString wCnnString = GetAuxiliarCnnString(); //Pregunto si los datos ingresados dan OK a una coneccion antes de //guardar la configuracion.- if (DataBaseServer.TestConnection(wCnnString)) { FillCurrentCnnString(); //wDataBaseServer.SaveSetting(wCnnString); if (_DataBaseServer.SaveSetting(wCnnString)) { //wDataBaseServer.CurrentCnnString.Name = cmbConnections.Text; } ConnectionOK = true; } else { MessageBox.Show("La conexion no se pudo realizar", "Error de conección"); ConnectionOK = false; } } catch (DataBaseExeption wDataBaseExeption) { ConnectionOK = false; txtServer.Text = wDataBaseExeption.CnnString.DataSource; txtUserName.Text = wDataBaseExeption.CnnString.User; txtPassword.Text = wDataBaseExeption.CnnString.Password; WindowsAutentificaction.Checked = wDataBaseExeption.CnnString.WindowsAutentification; cmbDataBases.Items.Add(wDataBaseExeption.CnnString.InitialCatalog); cmbDataBases.Text = wDataBaseExeption.CnnString.InitialCatalog; txtPassword.Focus(); MessageBox.Show(wDataBaseExeption.Message); } catch (Exception ex) { ConnectionOK = false; MessageBox.Show(ex.Message, "Error de conección"); } finally { OnAceptEvent(ConnectionOK); } }
private void cmbDataBases_Click(object sender, System.EventArgs e) { DataBaseServer wDataBaseServer = null; try { wDataBaseServer = new DataBaseServer(true); if (WindowsAutentificaction.Checked) { if (txtServer.Text.Trim() == String.Empty) return; } else { if (txtServer.Text.Trim() == String.Empty || txtUserName.Text.Trim() == String.Empty) return; } if (ComboDataBasesLoad == false) { if (DataBaseServer.TestConnection(txtServer.Text.Trim(), txtUserName.Text.Trim(), txtPassword.Text.Trim(), WindowsAutentificaction.Checked)) { cmbDataBases.Items.Clear(); if (wDataBaseServer.CnnString == null) { wDataBaseServer.CreateConnection(); } wDataBaseServer.CnnString.DataSource = txtServer.Text.Trim(); wDataBaseServer.CnnString.User = txtUserName.Text.Trim(); wDataBaseServer.CnnString.Password = txtPassword.Text.Trim(); wDataBaseServer.CnnString.WindowsAutentification = WindowsAutentificaction.Checked; DataTable dttDataBases = wDataBaseServer.GetDataBases(); foreach (DataRow dtr in dttDataBases.Rows) { cmbDataBases.Items.Add(dtr["DATABASE_NAME"].ToString()); } ComboDataBasesLoad = true; } else { MessageBox.Show("Los parametros de conexion no son validos.- Verifique nombre de usuario y contraseña", "Error de conección"); ConnectionOK = false; } } } catch (DataBaseExeption wDataBaseExeption) { txtServer.Text = wDataBaseExeption.CnnString.DataSource; txtUserName.Text = wDataBaseExeption.CnnString.User; txtPassword.Text = wDataBaseExeption.CnnString.Password; txtPassword.Focus(); WindowsAutentificaction.Checked = wDataBaseExeption.CnnString.WindowsAutentification; cmbDataBases.Items.Add(wDataBaseExeption.CnnString.InitialCatalog); cmbDataBases.Text = wDataBaseExeption.CnnString.InitialCatalog; MessageBox.Show(wDataBaseExeption.Message, "Error de conección"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error de conección"); } }
public string RelosveFullPath(DataBaseServer srv, string filepath) { return(ResloveMachineName(srv) + @"\" + ResloveAdminSharePath(filepath)); }
private static void RunServer() { Stopwatch sw = Stopwatch.StartNew(); AppDomain.CurrentDomain.UnhandledException += UnhandledException; Console.WriteLine("----===== Revolution WorldServer =====----\n\n" + "Copyright (C) 2013 Revolution Team\n\n" + "This program is CLOSE SOURCE project.\n" + "You DON'T have any right's, if you are NOT autor\n" + "or authorized representative of him.\n" + "Using that program without any right's is ILLEGAL\n\n" + "Authors: Jenose, IMaster\n" + "Authorized representative: netgame.in.th\n\n" + "-------------------------------------------"); Log.Info("Init Services..."); AccountService = new AccountService(); AiService = new AiService(); ChatService = new ChatService(); ControllerService = new ControllerService(); FeedbackService = new FeedbackService(); MapService = new MapService(); ObserverService = new ObserverService(); PlayerService = new PlayerService(); TeamService = new TeamService(); SkillsLearnService = new SkillsLearnService(); StatsService = new StatsService(); ShopService = new ShopService(); StorageService = new StorageService(); TeleportService = new TeleportService(); VisibleService = new VisibleService(); Log.Info("Init Engines..."); ScriptEngine = new ScriptEngine.ScriptEngine(); AdminEngine = new AdminEngine.AdminEngine(); SkillEngine = new SkillEngine.SkillEngine(); QuestEngine = new QuestEngine.QuestEngine(); Console.WriteLine("\n-------------------------------------------\n"); GlobalLogic.ServerStart(); Console.WriteLine("\n-------------------------------------------\n"); CountryCode = (CountryCode)Enum.Parse(typeof(CountryCode), Settings.Default.COUNTRY_CODE); InnerNetworkOpcode.Init(); OuterNetworkOpcode.Init(); InnerClient = new InnerNetworkClient("127.0.0.1", 22323); InnerClient.BeginConnect(); foreach (var channel in DataBaseServer.GetServerChannel(Settings.Default.SERVER_ID)) { var OuterNetwork = new OuterNetworkListener("*", channel.port, channel.max_user); OuterNetwork.BeginListening(); OuterNetworks.Add(OuterNetwork); } InnerNetworkClient.SendAllThread.Start(); OuterNetworkConnection.SendAllThread.Start(); sw.Stop(); Console.WriteLine("-------------------------------------------"); Console.WriteLine(" Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s")); Console.WriteLine("-------------------------------------------"); }
//Create the compund sql statement according to the dbserver. private string CreateCompundSqlStatement(string[] sqlStatements, DataBaseServer dbServer) { string beginStatement; string endStatement; string commandDelimiter; GetDBSpecificSyntax(dbServer, out beginStatement, out endStatement, out commandDelimiter); StringBuilder cmdBuilder = new StringBuilder(); cmdBuilder.Append(beginStatement); cmdBuilder.Append(" "); foreach (string statement in sqlStatements) { cmdBuilder.Append(statement); cmdBuilder.Append(commandDelimiter); cmdBuilder.Append(" "); } cmdBuilder.Append(endStatement); return cmdBuilder.ToString(); }
public SpRegisteredServer() { // todo load server & channel info serverInfo = DataBaseServer.GetServerInfo(Properties.Settings.Default.SERVER_ID); serverInfo.channels = DataBaseServer.GetServerChannel(Properties.Settings.Default.SERVER_ID); }
/// <summary> /// This is a workaround for the extra white spaces added in oracle to NCHAR & NVARCHAR values. /// The problem is a documented GH limitation, see bug #3417. /// The workaround is to trim the lemgth of the returned string to the specified length of the parameter/column. /// </summary> /// <param name="testedServer">The database server we are currently running on.</param> /// <param name="val">The value returned from the database.</param> /// <returns>The normalized value..</returns> private object WorkaroundOracleCharsPaddingLimitation(DataBaseServer testedServer, DbTypeParameter currentParam, object val) { object origVal = val; string dbTypeName = currentParam.DbTypeName.ToUpper(); if ( (testedServer == DataBaseServer.Oracle) && (dbTypeName == "CHAR" || dbTypeName == "NCHAR") ) { val = ((string)val).Substring(0, currentParam.Size); Log(string.Format("Worked around oracle chars padding limitation by triming '{0}' to '{1}'", origVal, val)); } return val; }