//窗口加载时进行更新检测,并进行更新 private void Window_Loaded(object sender, RoutedEventArgs e) { //获取配置文件中服务器地址 //判断文件是否存在 try { if (File.Exists(address)) { FileStream file = new FileStream(address, FileMode.Open); StreamReader reader = new StreamReader(file); String temp = reader.ReadLine(); serverPath = temp; file.Close(); reader.Close(); } } catch (IOException) { } ; Update update = new Update(); String serverDbName = GetFileName.GetFileNameWithonExtension(serverPath); if (serverDbName == null) { return; } String localDbName = GetFileName.GetFileNameWithonExtension(localPath); if (update.AntoUpdateOrNot()) { MessageBoxResult result = MessageBox.Show("当前软件需要更新", "提示", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { String filename = Assembly.GetExecutingAssembly().Location; File.Move(filename, filename + ".delete"); File.Copy(serverPath + "\\" + "TeamProjectDevelopment.exe", filename); String DbName = GetFileName.getFileName(serverPath); String conStr = databaseCon + serverPath + "\\" + DbName; OleDbConnection connection = CreateDb.getConn(conStr); connection.Open(); String selectString = "delete from config1 where fileName=\"TeamProjectDevelopment.exe\""; OleDbCommand command = new OleDbCommand(selectString, connection); command.ExecuteNonQuery(); connection.Close(); update.AutoUpdate(); } } if (update.UpdateOrNot()) { MessageBoxResult result = MessageBox.Show("当前有版本更新,需要更新吗?", "更新", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { update.update(this); } } }
//另存为 private void Button_Click_1(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); //openFileDialog.Multiselect = false; saveFileDialog.Filter = "mdb|*.*"; saveFileDialog.ShowDialog(); SaveAddress = saveFileDialog.FileName; CreateDb createDb = new CreateDb(); createDb.createDb(extension.Text); InsertFile insertFile = new InsertFile(); insertFile.insertData(extension.Text, files, dg); String version = extension.Text; FileInfo file = new FileInfo(@"..\otherDbs\" + version + ".mdb"); file.CopyTo(SaveAddress); MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); }
//确定 private void Button_Click(object sender, RoutedEventArgs e) { String versionNum = extension.Text; CreateDb createDb = new CreateDb(); createDb.createDb(versionNum); InsertFile insertFile = new InsertFile(); insertFile.insertData(versionNum, files, dg); }
static SetupDBFixtureTest() { //Create Schema File NHHelper.CreateShemaExportFile("sqlSchemaScript.sql", "Default"); CreateDb script = new CreateDb(sqlRootFolderPath, dbName, serverName, "sqlSchemaScript.sql"); //script.Execute("Default"); server = new Server(serverName); }
public myContext() { //If embedded database does not exist yet, set it up and //create test records CreateDb setup = new CreateDb(); if (!setup.DbExists()) { setup.CreateDatabase(); } }
private void MailBox_Load(object sender, EventArgs e) { CreateDb createDb = new CreateDb(); createDb.execute(); Entrada entrada = new Entrada(); entrada.Dock = DockStyle.Fill; Modules.ViewController.Controller.Entrada = entrada; painel_central.Controls.Add(entrada); }
private void btnCreateDB_Click(object sender, RoutedEventArgs e) { ConnectionString ConnectionData = new ConnectionString(); CreateDb cdb = new CreateDb(ConnectionData); cdb.Owner = this; if (cdb.ShowDialog().Value) { AddNewConnection(ConnectionData); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { //MainWindow window = new MainWindow(); //window.Show(); String versionNum = extension.Text; CreateDb createDb = new CreateDb(); createDb.createDb(versionNum); InsertFile insertFile = new InsertFile(); insertFile.insertData(versionNum, files, dg); this.Close(); }
private void SetupDB() { // Setup DB string sqlRootFolder = ConfigurationManager.AppSettings["SqlRootFolder"]; string sqlServerName = ConfigurationManager.AppSettings["SqlServerName"]; NHHelper.CreateShemaExportFile(HttpContext.Current.Server.MapPath("CreateSchema.sql"), TenantContext.TenantKey); CreateDb dbsetup = new CreateDb(sqlRootFolder, TenantContext.DbName, sqlServerName, HttpContext.Current.Server.MapPath("CreateSchema.sql")); if (!dbsetup.DBExist()) { dbsetup.Execute(TenantContext.TenantKey); } }
public void CheckDatabaseState() { mDb = Manager.GetContext; if (!System.IO.File.Exists(datafile)) { UpdateDb creator = new CreateDb(); creator.DoUpdate(); UpdateDb inserter = new InsertData(); inserter.DoUpdate(); mDb.Configs.First(c => c.Key == "db_version").Value = CURRENT_VERSION.ToString(); } UpdateDatabase(); mDb.SubmitChanges(); }
public void CreateAndSaveLocal() { IKp2aApp app = new TestKp2aApp(); IOConnectionInfo ioc = new IOConnectionInfo { Path = DefaultFilename }; File outputDir = new File(DefaultDirectory); outputDir.Mkdirs(); File targetFile = new File(ioc.Path); if (targetFile.Exists()) { targetFile.Delete(); } bool createSuccesful = false; //create the task: CreateDb createDb = new CreateDb(app, Application.Context, ioc, new ActionOnFinish((success, message) => { createSuccesful = success; if (!success) { Android.Util.Log.Debug("KP2A_Test", message); } }), false); //run it: createDb.Run(); //check expectations: Assert.IsTrue(createSuccesful); Assert.IsNotNull(app.GetDb()); Assert.IsNotNull(app.GetDb().KpDatabase); //the create task should create two groups: Assert.AreEqual(2, app.GetDb().KpDatabase.RootGroup.Groups.Count()); //ensure the the database can be loaded from file: PwDatabase loadedDb = new PwDatabase(); loadedDb.Open(ioc, new CompositeKey(), null, new KdbxDatabaseFormat(KdbxFormat.Default)); //Check whether the databases are equal AssertDatabasesAreEqual(loadedDb, app.GetDb().KpDatabase); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); var appSettingsSection = Configuration.GetSection("ApplicationSettings"); services.Configure <ApplicationSettings>(appSettingsSection); _appSettings = appSettingsSection.Get <ApplicationSettings>(); try { string path = Directory.GetCurrentDirectory(); CreateDb createDb = new CreateDb(); createDb.CreateDataBase (path + _appSettings.PathScriptDataBase, _appSettings.ConnectMaster, _appSettings.ConnectDB); } catch (Exception ex) { Console.WriteLine(ex.Message); } services.AddDbContext <AppDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); services.AddDependencyInjection(); services.AddControllers(); services.AddCors(options => { options.AddPolicy(name: _specificOrigins, builder => { builder.WithOrigins("http://localhost:3000") .AllowAnyHeader() .AllowAnyMethod(); }); }); }
public void SoftwareUpdate() { String filename = Assembly.GetExecutingAssembly().Location; File.Move(filename, filename + ".delete"); File.Copy(serverPath + "\\" + softwareName, filename); String DbName = GetFileName.getFileName(serverPath); String conStr = databaseCon + serverPath + "\\" + DbName; OleDbConnection connection = CreateDb.getConn(conStr); connection.Open(); String selectString = "delete from config1 where fileName=\"" + softwareName + "\""; OleDbCommand command = new OleDbCommand(selectString, connection); command.ExecuteNonQuery(); connection.Close(); AutoUpdate(); }
public void generateLocalVersion(String DbPath) { CopyFile copyFile = new CopyFile(); String DbName = GetFileName.getFileName(DbPath); OleDbDataReader reader = CreateDb.DbConnect(DbPath); String path = versionFile; System.IO.Directory.CreateDirectory(path + "\\" + "本地版本" + Path.GetFileNameWithoutExtension(DbName)); DirectoryInfo dir = new DirectoryInfo(path + "\\" + "本地版本" + Path.GetFileNameWithoutExtension(DbName)); dir.Create(); while (reader.Read()) { String tempStr = (String)reader["path"]; String targetDir = dir + "\\" + Path.GetFileName(tempStr); copyFile.copyFile(tempStr, targetDir); } copyFile.copyFile(DbPath + "\\" + DbName, dir + "\\" + DbName); MessageBox.Show("生成版本成功", "提示", MessageBoxButton.OK); }
public void update(Window oldWindow) { //判断文件是否存在 CopyFile copyFile = new CopyFile(); String serverDbName = GetFileName.getFileName(serverPath); OleDbDataReader reader = CreateDb.DbConnect(serverPath); while (reader.Read()) { String tempStr = (String)reader["fileName"]; String originFile = serverPath + "\\" + tempStr; String updateMethod = (String)reader["updateMethod"]; if (updateMethod.Equals("删除") && File.Exists(localPath + "\\" + tempStr)) { File.Delete(localPath + "\\" + tempStr); } else { copyFile.copyFile(originFile, localPath + "\\" + tempStr); } } if (reader != null) { reader.Close(); } //最后复制服务器配置文件到本地,并删除原来的配置文件 String localDbName = GetFileName.getFileName(localPath); copyFile.copyFile(serverPath + "\\" + serverDbName, localPath + "\\" + localDbName); /* * if (serverDbName != localDbName) * File.Delete(localPath + "\\" + localDbName); */ SuccessTips(oldWindow); }
public bool AntoUpdateOrNot() { //判断文件是否存在 String serverDbName = GetFileName.getFileName(serverPath); if (serverDbName == null) { return(false); } OleDbDataReader serverReader = CreateDb.DbConnect(serverPath); while (serverReader.Read()) { if (serverReader["fileName"].Equals(softwareName)) { serverReader.Close(); return(true); } } serverReader.Close(); return(false); }
public void BTO_DefaultDBExist() { int result = (int)server.ConnectionContext.ExecuteScalar(CreateDb.DBExistQuery(dbName)); Assert.AreEqual(1, result); }
public void CanGetCreateDBScript() { Assert.IsNotNull(CreateDb.GetCreateDBScript(sqlRootFolderPath, dbName)); }