コード例 #1
0
ファイル: Form1.cs プロジェクト: zls3201/dbschemareader
 private void BackgroundWorker1RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         //it errored
         errorProvider1.SetError(ConnectionString, e.Error.Message);
         toolStripStatusLabel1.Text = e.Error.Message;
     }
     else
     {
         //it worked
         toolStripStatusLabel1.Text = string.Empty;
         _databaseSchema            = e.Result as DatabaseSchema;
         if (_databaseSchema != null)
         {
             SchemaToTreeview.PopulateTreeView(_databaseSchema, treeView1);
             toolStripButton1.Enabled = true;
             toolStripButton2.Enabled = true;
             saveSchema.Enabled       = true;
         }
     }
     StopWaiting();
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zls3201/dbschemareader
 private void OpenSchemaClick(object sender, EventArgs e)
 {
     using (var picker = new OpenFileDialog())
     {
         picker.DefaultExt       = ".xml";
         picker.Title            = "Open saved schema.";
         picker.InitialDirectory =
             Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
         var result = picker.ShowDialog();
         if (result == DialogResult.OK)
         {
             using (var stream = picker.OpenFile())
             {
                 var serializer = new XmlSerializer(typeof(DatabaseSchema));
                 try
                 {
                     _databaseSchema = serializer.Deserialize(stream) as DatabaseSchema;
                     DatabaseSchemaFixer.UpdateReferences(_databaseSchema);
                 }
                 catch (SerializationException)
                 {
                     toolStripStatusLabel1.Text = "Invalid serialization format";
                 }
             }
             if (_databaseSchema != null)
             {
                 ConnectionString.Text = _databaseSchema.ConnectionString;
                 SchemaOwner.Text      = _databaseSchema.Owner;
                 SelectProvider(_databaseSchema.Provider);
                 SchemaToTreeview.PopulateTreeView(_databaseSchema, treeView1);
                 toolStripButton1.Enabled = true;
                 toolStripButton2.Enabled = true;
                 saveSchema.Enabled       = true;
             }
         }
     }
 }