public static AGInfo LoadAGInfo(string filename) { AGInfo ag = new AGInfo(); try { DataSet ds = new DataSet(); ds.ReadXml(filename); foreach (DataTable table in ds.Tables) { foreach (var row in table.AsEnumerable()) { ReplicaNode node = new ReplicaNode(); node = new ReplicaNode(); node.replica_id = row["replica_id"].ToString(); node.role_desc = row["role_desc"].ToString(); node.replica_server_name = row["replica_server_name"].ToString(); node.is_commit_participant = Int32.Parse(row["is_commit_participant"].ToString()); if (row["is_local"].ToString() == "1") { ag.node = node; } if (!ag.replicaDict.ContainsKey(node.replica_server_name)) { ag.replicaDict.Add(node.replica_server_name, node); ag.nodes.Add(node); } ag.database_id.Add(Int32.Parse(row["database_id"].ToString())); ag.group_database_id.Add(row["group_database_id"].ToString()); ag.group_id.Add(row["group_id"].ToString()); ag.group_name.Add(row["group_name"].ToString()); } } } catch (Exception ex) { Logger.LogException(ex, Thread.CurrentThread); } return(ag); }
private void button1_Click(object sender, EventArgs e) { if (!isValidfolder(textBox1.Text)) { MessageBox.Show("Primary folder [" + textBox1.Text + "] doesn't exist!"); return; } if (!isValidfolder(textBox2.Text)) { MessageBox.Show("Secondary folder [" + textBox2.Text + "] doesn't exist!"); return; } if (textBox1.Text.Trim() == textBox2.Text.Trim()) { MessageBox.Show("You cannot set primary and secondary to the same folder."); return; } Controller.primaryFolder = textBox1.Text.Trim(); Controller.secondaryFolder = textBox2.Text.Trim(); //check to see if primary.xml and secondary.xml exists or not: if (!File.Exists(Path.Combine(Controller.primaryFolder, "primary.xml"))) { MessageBox.Show("primary.xml not found in [" + Controller.primaryFolder + "]"); return; } if (!File.Exists(Path.Combine(Controller.primaryFolder, "primary.xml"))) { MessageBox.Show("secondary.xml not found in [" + Controller.secondaryFolder + "]"); return; } //Now time to load AGinfo Controller.primaryInfo = null; Controller.secondaryInfo = null; Logger.LogMessage("Parsing primary.xml and secondary.xml..."); Controller.primaryInfo = AGInfo.LoadAGInfo(Path.Combine(Controller.primaryFolder, "primary.xml")); Controller.secondaryInfo = AGInfo.LoadAGInfo(Path.Combine(Controller.secondaryFolder, "secondary.xml")); button1.Enabled = false; if (notStarted) { button1.Text = " Stop"; button1.Image = Properties.Resources.red2; button1.ImageAlign = ContentAlignment.MiddleLeft; Start(); notStarted = false; isAbort = false; } else { DoStop(true); } button1.Enabled = true; }