public static ConnectionItem LoadConnection(string dbcFile) { if (System.IO.File.Exists(dbcFile)) { try { ConnectionItem ci = XmlSerializerUtility.LoadFromXmlFile <ConnectionItem>(dbcFile); ci.SetLoaded(); return(ci); } catch (Exception err) { FormLog.NotifyException(true, err, "Invalid connection file [{0}]", dbcFile); } } return(null); }
public void MergeFromFile() { string f = GetConnectionFilename(this.ConnectionGuid); if (System.IO.File.Exists(f)) { ConnectionItem ci = XmlSerializerUtility.LoadFromXmlFile <ConnectionItem>(f); if (ci != null) { ci.SetDataFolder(); if (!string.IsNullOrEmpty(ci._name)) { _name = ci._name; } if (ci._cnn != null) { _cnn = ci._cnn; } } } }
public static ConnectionItem LoadConnection(Guid g, bool updateUsage, bool quickLoad) { ConnectionItem ci = null; try { string f = GetConnectionFilename(g); if (!System.IO.File.Exists(f)) { f = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, System.IO.Path.GetFileName(f)); } if (System.IO.File.Exists(f)) { try { ci = XmlSerializerUtility.LoadFromXmlFile <ConnectionItem>(f); ci.SetDataFolder(); ci.SetLoaded(); if (updateUsage) { ci.UpdateUsage(Application.ExecutablePath); } } catch (Exception errXml) { FormLog.NotifyException(true, errXml, "Invalid connection file [{0}] for connection item {1}.", f, g); } } if (quickLoad) { if (ci == null) { Connection cn = GetDefaultConnection(g); if (cn == null) { ci = new ConnectionItem(f); } else { ci = new ConnectionItem(cn); } if (updateUsage) { ci.UpdateUsage(Application.ExecutablePath); } ci.Save(); ci.SetLoaded(); } else { ci.setConnectionID(g); } } else { if (ci == null || !ci.ConnectionObject.IsConnectionReady) { Connection cn = GetDefaultConnection(g); if (cn == null) { if (ci == null) { ci = new ConnectionItem(f); } } else { ci = new ConnectionItem(cn); } if (updateUsage) { ci.UpdateUsage(Application.ExecutablePath); } ci.Save(); ci.SetLoaded(); ci._connectionChecked = true; } } } catch (Exception err) { FormLog.NotifyException(true, err, "Error loading connection item {0}.", g); } return(ci); }