internal static void SaveSolutionSettings(UISolution uisolution) { try { string path = Environment.GetEnvironmentVariable("AppData") + @"\JIRAConnector"; string filename = "usersettings.xml"; string fullPath = path + "\\" + filename; //if the settings file doesn't exists, create it. UserSettings data; DataRow solution; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } data = new UserSettings(); if (File.Exists(fullPath)) { data.ReadXml(fullPath); } if (data.Solutions.Rows.Contains(uisolution.FullName)) { //the solution exists, so use it solution = data.Solutions.Rows.Find(uisolution.FullName); solution["FullName"] = uisolution.FullName; solution["LoadType"] = (int) uisolution.LoadType; } else { //the solution doesn't exists, create it data.Solutions.AddSolutionsRow(uisolution.FullName, (int) uisolution.LoadType, uisolution.Settings.Username, uisolution.Settings.Password, uisolution.Settings.Url, uisolution.Settings.Port, uisolution.Settings.ProjectKey); } data.WriteXml(fullPath); } catch (Exception e) { LogManager.WriteMessage(e.Message + "\n" + e.StackTrace); } }
/// <summary> /// Checks is the solution is linked to a JIRA project /// </summary> /// <param name="uisolution">The solution to check for</param> /// <returns>True if the solution is linked, False otherwise</returns> public static bool IsSolutionLinked(UISolution uisolution) { bool linked = false; try { string path = Environment.GetEnvironmentVariable("AppData") + @"\JIRAConnector"; string filename = "usersettings.xml"; string fullPath = path + "\\" + filename; //if the settings file exists check for the solution. UserSettings data; DataRow solution; if (Directory.Exists(path)) { if (File.Exists(fullPath)) { data = new UserSettings(); data.ReadXml(fullPath); if (data.Solutions.Rows.Contains(uisolution.FullName)) { //the solution exists, so use it solution = data.Solutions.Rows.Find(uisolution.FullName); uisolution.LoadType = (SolutionLoadType) solution["LoadType"]; uisolution.Settings.Password = (solution["Password"] is DBNull ? "" : (string)solution["Password"]); uisolution.Settings.Port = (solution["Port"] is DBNull ? "" : (string)solution["Port"]); uisolution.Settings.ProjectKey = (solution["ProjectKey"] is DBNull ? "" : (string)solution["ProjectKey"]); uisolution.Settings.Url = (solution["Url"] is DBNull ? "" : (string)solution["Url"]); uisolution.Settings.Username = (solution["UserName"] is DBNull ? "" : (string)solution["UserName"]); linked = true; } else { //the solution doesn't exists, create it data.Solutions.AddSolutionsRow(uisolution.FullName, (int) uisolution.LoadType, uisolution.Settings.Username, uisolution.Settings.Password, uisolution.Settings.Url, uisolution.Settings.Port, uisolution.Settings.ProjectKey); } } } } catch (Exception e) { LogManager.WriteMessage(e.Message + "\n" + e.StackTrace); } return linked; }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); UserSettings ds = new UserSettings(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "SolutionsDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return type; }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { UserSettings ds = new UserSettings(); System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; return type; }