private void OpenCSVFile(string srcFile) { if (!File.Exists(srcFile)) { "FileNotFound".GetFromResourece().Show(); return; } LoginInfo_CSV info = new LoginInfo_CSV() { Database = srcFile, IsFirstRowIsColumnName = true, }; App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.CSV).X_Handler; try { App.MainEngineer.Open(info); if (App.MainEngineer.IsOpened) { App.MainEngineer.CurDatabase = info.Database; App.MainEngineer.CurPwd = info.Pwd; RibbionIDE ide = new RibbionIDE(); ide.ShowDialog(); } } catch (Exception ee) { App.ResetMainEngineer(); ee.HandleMyException(); } }
private void butConnectWithConStr_Directly_Click(object sender, RoutedEventArgs e) { string connStr = string.Empty; connStr = this.txtConnStr.Text; if (string.IsNullOrEmpty(connStr)) { "Please input the connection string".Notify(); return; } CoreEA.CoreE c = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlServer); try { c.X_Handler.Open(connStr); if (c.X_Handler.IsOpened) { RibbionIDE ide = new RibbionIDE(); ide.ShowDialog(); } else { MessageBox.Show(c.X_Handler.LastErrorMsg); } } catch (Exception ee) { XLCS.Common.ProcessException.DisplayErrors(ee); } }
private void OpenExcelFile(string srcFile, CoreEA.LoginInfo.OleDBVersion curVersion) { if (!File.Exists(srcFile)) { "FileNotFound".GetFromResourece().Show(); return; } LoginInfo_Excel info = new LoginInfo_Excel() { Database = srcFile, IsFirstRowIsColumnName = (bool)chkIsFirstRowIsColumnName.IsChecked, CurrentOleDBVersion = curVersion, }; App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.Excel).X_Handler; try { App.MainEngineer.Open(info); if (App.MainEngineer.IsOpened) { App.MainEngineer.CurDatabase = info.Database; App.MainEngineer.CurPwd = info.Pwd; RibbionIDE ide = new RibbionIDE(); ide.ShowDialog(); } } catch (Exception ee) { App.ResetMainEngineer(); ee.HandleMyException(); } }
void ConnectCmd_Executed(object sender, ExecutedRoutedEventArgs e) { if (string.IsNullOrEmpty(txtServername.Text)) { return; } if (string.IsNullOrEmpty(txtUsername.Text)) { return; } LoginInfo_MySql info = new LoginInfo_MySql() { Server = txtServername.Text, Database = txtDbName.Text, Username = txtUsername.Text, Pwd = passwordBox1.Password, Port = int.Parse(txtPort.Text), ConnectionTimeOut = 2000, }; try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.MySql).X_Handler; App.MainEngineer.Open(info); if (App.MainEngineer.IsOpened) { #region Save to Opened History Info MySqlObjects mysqlItem = new MySqlObjects(); mysqlItem.ServerAddress = info.Server; mysqlItem.Port = info.Port; mysqlItem.Username = info.Username; if (!SerializeClass.DatabaseHistoryInfo.MySqlHistory.IsContainSubValue(mysqlItem.ServerAddress)) { HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo; oldObject.MySqlHistory.Add(mysqlItem); SerializeClass.DatabaseHistoryInfo = oldObject; } #endregion App.MainEngineer.CurDatabase = txtDbName.Text; App.MainEngineer.CurPwd = passwordBox1.Password; RibbionIDE ide = new RibbionIDE(); ide.Title = info.Server; ide.ShowDialog(); } } catch (Exception ee) { //ee._获取我的异常详细信息().Show(); App.ResetMainEngineer(); ee.HandleMyException(); } }
private void OpenOleDbFile(string srcFile, CoreEA.LoginInfo.OleDBVersion curVersion) { if (!System.IO.File.Exists(srcFile)) { "FileNotFound".GetFromResourece().Show(); return; } LoginInfo_Oledb info = new LoginInfo_Oledb() { Database = srcFile, Pwd = pwd.Password, CurrentOleDBVersion = curVersion, }; App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.OleDb).X_Handler; try { App.MainEngineer.Open(info); if (App.MainEngineer.IsOpened) { OleDbObjects oleItem = new OleDbObjects(); oleItem.DbFileFullPath = info.Database; if (!SerializeClass.DatabaseHistoryInfo.OleDbHistory.IsContainSubValue(oleItem.DbFileFullPath)) { HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo; oldObject.OleDbHistory.Add(oleItem); SerializeClass.DatabaseHistoryInfo = oldObject; } App.MainEngineer.CurDatabase = info.Database; App.MainEngineer.CurPwd = info.Pwd; pwd.Password = ""; txtFileInput.X_FileName = ""; RibbionIDE ide = new RibbionIDE(); ide.ShowDialog(); } } catch (Exception ee) { App.ResetMainEngineer(); ee.HandleMyException(); } finally { } }
public void ConnectCmd_Execute(object sender, ExecutedRoutedEventArgs e) { LoginInfo_Oracle info = new LoginInfo_Oracle() { SID = txtServerName.Text, Username = txtUsername.Text, Password = passwordBox1.Password, HostName = txtHostName.Text, Port = int.Parse(txtPort.Text), }; try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.Oracle).X_Handler; App.MainEngineer.Open(info); if (App.MainEngineer.IsOpened) { #region Save to Opened History Info OracleObjects oracleItem = new OracleObjects(); oracleItem.HostName = info.HostName; oracleItem.Username = info.Username; oracleItem.SID = info.SID; if (!SerializeClass.DatabaseHistoryInfo.OracleHistory.IsContainSubValue(oracleItem.HostName)) { HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo; oldObject.OracleHistory.Add(oracleItem); SerializeClass.DatabaseHistoryInfo = oldObject; } #endregion App.MainEngineer.CurPwd = passwordBox1.Password; RibbionIDE ide = new RibbionIDE(); ide.Title = info.SID; ide.ShowDialog(); } } catch (Exception ee) { //ee._获取我的异常详细信息().Show(); App.ResetMainEngineer(); ee.HandleMyException(); } }
private void OpenSqliteFile(string srcFile) { if (!File.Exists(srcFile)) { "FileNotFound".GetFromResourece().Show(); return; } try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.Sqlite).X_Handler; string dbName = srcFile; App.MainEngineer.Open (new CoreEA.LoginInfo.LoginInfo_Sqlite() { DbFile = dbName, Pwd = txtPwd.Password, IsReadOnly = (bool)chkIsReadOnly.IsChecked, IsUnicode = (bool)chkIsUnicode.IsChecked, } ); if (App.MainEngineer.IsOpened) { RibbionIDE ide = new RibbionIDE(); ide.WindowState = WindowState.Maximized; ide.BringIntoView(); ide.ShowDialog(); } } catch (Exception ee) { App.ResetMainEngineer(); ee.HandleMyException(); } }
private void butOpen_Click(object sender, RoutedEventArgs e) { switch (currentDBConnectionType) { case ConnectionType.File: if (txtDbLocation.Text.IsEmpty()) { "TitleInputDbFile".GetFromResourece().Show(); return; } break; case ConnectionType.Memory: if (txtDBName.Text.IsEmpty()) { "TitleInputDbFile".GetFromResourece().Show(); return; } break; } try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.Effiproz).X_Handler; string dbName = string.Empty; switch (currentDBConnectionType) { case ConnectionType.File: string rootPath = System.IO.Path.GetDirectoryName(txtDbLocation.Text); dbName = rootPath + "\\" + System.IO.Path.GetFileNameWithoutExtension(txtDbLocation.Text); break; case ConnectionType.Memory: dbName = txtDBName.Text; break; default: throw new Exception("invalid mode"); } App.MainEngineer.Open (new CoreEA.LoginInfo.LoginInfo_Effiproz() { InitialCatalog = dbName, Username = txtUserName.Text, Password = txtPwd.Password, DBConnectionType = currentDBConnectionType, IsReadOnly = (bool)chkIsReadonly.IsChecked, IsAutoShutdown = (bool)chkIsAutoShutdown.IsChecked, IsAutoCommit = (bool)chkIsAutoCommit.IsChecked, } ); if (App.MainEngineer.IsOpened) { RibbionIDE ide = new RibbionIDE(); try { ide.WindowState = WindowState.Maximized; ide.BringIntoView(); ide.ShowDialog(); } catch (InvalidOperationException ee) { Debug.WriteLine(ee.Message); ee.Message.Show(); } catch (Exception ee) { ee.Message.Show(); } } else { App.ResetMainEngineer(); } } catch (Exception ee) { MessageBox.Show(ee.Message); App.ResetMainEngineer(); return; } }
private void LoginInSqlServer(WPFCommonControl.SqlServerLoginControl.X_CollectionData controlResult) { try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlServer).X_Handler; } catch (Exception ee) { MessageBox.Show(ee.Message); return; } LoginInfo_SqlServer info = new LoginInfo_SqlServer() { X_Server = controlResult.Server, X_Database = controlResult.DbName, X_Pwd = controlResult.PWD, X_UserName = controlResult.UID, X_Port = controlResult.Port.ToString(), X_CurDbConnectionMode = controlResult.CurType.CurConnMode, IsTrustedConn = controlResult.IsTrust, AttchFile = controlResult.DbFileLocation, }; try { App.MainEngineer.Open(info); if (App.MainEngineer.IsOpened) { #region Save to Opened History Info SqlServerObjects sqlserverItem = new SqlServerObjects(); sqlserverItem.ServerAddress = info.X_Server; if (info.X_Port.IsNotEmpty()) { sqlserverItem.Port = int.Parse(info.X_Port); } sqlserverItem.Username = info.X_UserName; if (!SerializeClass.DatabaseHistoryInfo.SqlServerHistory.IsContainSubValue(sqlserverItem.ServerAddress)) { HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo; oldObject.SqlServerHistory.Add(sqlserverItem); SerializeClass.DatabaseHistoryInfo = oldObject; } #endregion App.MainEngineer.CurDatabase = controlResult.DbName; RibbionIDE ide = new RibbionIDE(); //this.Visibility = Visibility.Hidden; //ide.Closed += (a, b) => { this.Visibility = Visibility.Visible; }; ide.Title = info.X_Server; ide.ShowDialog(); } } catch (Exception ee) { App.ResetMainEngineer(); ee.HandleMyException(); } }
private void butOpen_Click(object sender, RoutedEventArgs e) { string dbName = txtDbPath.Text; string dbPwd = txtPwd.Password; if (string.IsNullOrEmpty(dbName)) { "Please input database name".Notify(); return; } if (Utility.DetectNetworkDriver.IsPathOnNetworkDrive(dbName)) { "SQLCE do not support open from network".Notify(); return; } OpenModeClass CurOpenMode = null; if (cmbOpenMode.SelectedItem == null) { CurOpenMode = cmbOpenMode.Items[0] as OpenModeClass; } else { CurOpenMode = cmbOpenMode.SelectedItem as OpenModeClass; } uint maxDbSize = (uint)txtMaxDBSize.Value; //If open db ok ,and get tables info ok , then do //otherwise do nothing try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlCE35).X_Handler; App.MainEngineer.Open(new LoginInfo_SSCE() { DbName = dbName, Pwd = txtPwd.Password, CurOpenMode = CurOpenMode.mode, MaxDbSize = maxDbSize }); } catch (SqlCeInvalidDatabaseFormatException sqe) { Debug.WriteLine("*****************" + sqe.Message); #region if (wf.DialogResult.Yes == wf.MessageBox.Show("Your database format is old version ,do you want to upgrade it ,so this software can modify it?", "Warning", wf.MessageBoxButtons.YesNo, wf.MessageBoxIcon.Question, wf.MessageBoxDefaultButton.Button1)) { try { if (Properties.Settings.Default.AutoBackupOldVersionFileBeforeUpgrade) { if (!Directory.Exists(Config.AutoBackupFolder)) { Directory.CreateDirectory(Config.AutoBackupFolder); } File.Copy(dbName, Config.AutoBackupFolder + Path.GetFileName(dbName), true); } } catch (Exception ee) { #if DEBUG throw ee; #else ee.Message.Show(); #endif } SqlCeEngine d = new SqlCeEngine(CoreEA.ConnSTR.DbConnectionString.SSCE.GetSSCEConnectionString( dbName, dbPwd, (bool)chkIsEncrypted.IsChecked, CurOpenMode)); try { d.Upgrade(); "Upgrade Successful".Notify(); } catch (Exception dee) { dee.Message.Notify(); App.ResetMainEngineer(); return; } goto ReOpen; } else { App.ResetMainEngineer(); return; } #endregion } catch (Exception eee) { eee.Message.Notify(); } ReOpen: if (App.MainEngineer.IsOpened) { App.MainEngineer.CurDatabase = dbName; App.MainEngineer.CurPwd = txtPwd.Password; //this.Hide(); txtDbPath.Text = string.Empty; txtPwd.Password = string.Empty; Properties.Settings.Default.LastestOpenedDb = dbName; Properties.Settings.Default.LastestOpenedDbPwd = dbPwd; Properties.Settings.Default.Save(); #region Save to Opened History Info SSCEObjects ssceItem = new SSCEObjects(); ssceItem.DbFileFullPath = dbName; if (!SerializeClass.DatabaseHistoryInfo.SSCEHistory.IsContainSubValue(ssceItem.DbFileFullPath)) { HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo; ssceItem.LatestVisitTime = DateTime.Now; oldObject.SSCEHistory.Add(ssceItem); SerializeClass.DatabaseHistoryInfo = oldObject; } #endregion RefreshLastOpenedDbsStatus(); RibbionIDE ide = new RibbionIDE(); ide.WindowState = WindowState.Maximized; ide.BringIntoView(); ide.ShowDialog(); } else { App.ResetMainEngineer(); } }