public static ShowError ( |
||
ex | ||
return | void |
public override void Run() { string file = FileService.OpenFile(Res.GetString("TITLE_CONNECT_SQLITE"), Res.GetString("FILTER_SQLITE")); if (FileService.FileExists(file)) { FdoConnection conn = ExpressUtility.CreateFlatFileConnection("OSGeo.SQLite", file); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); NamingService namer = ServiceManager.Instance.GetService <NamingService>(); string name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), namer.GetDefaultConnectionName("OSGeo.SQLite")); if (name == null) { return; } while (name == string.Empty || mgr.NameExists(name)) { Msg.ShowError(Res.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS")); name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), name); if (name == null) { return; } } mgr.AddConnection(name, conn); } }
public override void Run() { string dir = FileService.GetDirectory(Res.GetString("TITLE_CONNECT_SHP_DIR")); if (FileService.DirectoryExists(dir)) { FdoConnection conn = new FdoConnection("OSGeo.SHP", "DefaultFileLocation=" + dir); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); NamingService namer = ServiceManager.Instance.GetService <NamingService>(); string name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), namer.GetDefaultConnectionName("OSGeo.SHP")); if (name == null) { return; } while (string.IsNullOrEmpty(name) || mgr.NameExists(name)) { Msg.ShowError(Res.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS")); name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), name); if (name == null) { return; } } mgr.AddConnection(name, conn); } }
public override void Run() { TreeNode schemaNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); if (schemaNode.Level == 2 && MessageService.AskQuestion("Are you sure you want to delete this schema?")) { FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); FdoConnection conn = mgr.GetConnection(schemaNode.Parent.Name); using (FdoFeatureService service = conn.CreateFeatureService()) { try { service.DestroySchema(schemaNode.Name); Msg.ShowMessage(Res.GetString("MSG_SCHEMA_DELETED"), Res.GetString("TITLE_DELETE_SCHEMA")); Log.InfoFormatted(Res.GetString("LOG_SCHEMA_DELETED"), schemaNode.Name, schemaNode.Parent.Name); mgr.RefreshConnection(schemaNode.Parent.Name); } catch (OSGeo.FDO.Common.Exception ex) { Msg.ShowError(ex); } } } }
/// <summary> /// Loads a list of .addin files, ensuring that dependencies are satisfied. /// This method is normally called by <see cref="CoreStartup.RunInitialization"/>. /// </summary> /// <param name="addInFiles"> /// The list of .addin file names to load. /// </param> /// <param name="disabledAddIns"> /// The list of disabled AddIn identity names. /// </param> public static void Load(List <string> addInFiles, List <string> disabledAddIns) { List <AddIn> list = new List <AddIn>(); Dictionary <string, Version> dict = new Dictionary <string, Version>(); Dictionary <string, AddIn> addInDict = new Dictionary <string, AddIn>(); foreach (string fileName in addInFiles) { AddIn addIn; try { addIn = AddIn.Load(fileName); } catch (AddInLoadException ex) { LoggingService.Error(ex); if (ex.InnerException != null) { MessageService.ShowError("Error loading AddIn " + fileName + ":\n" + ex.InnerException.Message); } else { MessageService.ShowError("Error loading AddIn " + fileName + ":\n" + ex.Message); } addIn = new AddIn(); addIn.addInFileName = fileName; addIn.CustomErrorMessage = ex.Message; } if (addIn.Action == AddInAction.CustomError) { list.Add(addIn); continue; } addIn.Enabled = true; if (disabledAddIns != null && disabledAddIns.Count > 0) { foreach (string name in addIn.Manifest.Identities.Keys) { if (disabledAddIns.Contains(name)) { addIn.Enabled = false; break; } } } if (addIn.Enabled) { foreach (KeyValuePair <string, Version> pair in addIn.Manifest.Identities) { if (dict.ContainsKey(pair.Key)) { MessageService.ShowError("Name '" + pair.Key + "' is used by " + "'" + addInDict[pair.Key].FileName + "' and '" + fileName + "'"); addIn.Enabled = false; addIn.Action = AddInAction.InstalledTwice; break; } else { dict.Add(pair.Key, pair.Value); addInDict.Add(pair.Key, addIn); } } } list.Add(addIn); } checkDependencies: for (int i = 0; i < list.Count; i++) { AddIn addIn = list[i]; if (!addIn.Enabled) { continue; } Version versionFound; foreach (AddInReference reference in addIn.Manifest.Conflicts) { if (reference.Check(dict, out versionFound)) { MessageService.ShowError(addIn.Name + " conflicts with " + reference.ToString() + " and has been disabled."); DisableAddin(addIn, dict, addInDict); goto checkDependencies; // after removing one addin, others could break } } foreach (AddInReference reference in addIn.Manifest.Dependencies) { if (!reference.Check(dict, out versionFound)) { if (versionFound != null) { MessageService.ShowError(addIn.Name + " has not been loaded because it requires " + reference.ToString() + ", but version " + versionFound.ToString() + " is installed."); } else { MessageService.ShowError(addIn.Name + " has not been loaded because it requires " + reference.ToString() + "."); } DisableAddin(addIn, dict, addInDict); goto checkDependencies; // after removing one addin, others could break } } } foreach (AddIn addIn in list) { try { InsertAddIn(addIn); } catch (AddInLoadException ex) { LoggingService.Error(ex); MessageService.ShowError("Error loading AddIn " + addIn.FileName + ":\n" + ex.Message); } } }
public static void Load(List <string> addInFiles, List <string> disabledAddIns) { _loadErrors.Clear(); int errCnt = 1; List <AddIn> list = new List <AddIn>(); Dictionary <string, Version> dict = new Dictionary <string, Version>(); Dictionary <string, AddIn> addInDict = new Dictionary <string, AddIn>(); foreach (string fileName in addInFiles) { // Revision: Added by Ali Özgür on 15.05.2007 if (!File.Exists(fileName)) { _loadErrors.Add(String.Format("AddIn Load Error {0}: File does not exist! \"{1}\".", errCnt, fileName)); errCnt++; continue; } AddIn addIn = AddIn.Load(fileName); if (addIn.Action == AddInAction.CustomError) { list.Add(addIn); continue; } addIn.Enabled = true; if (disabledAddIns != null && disabledAddIns.Count > 0) { foreach (string name in addIn.Manifest.Identities.Keys) { if (disabledAddIns.Contains(name)) { addIn.Enabled = false; break; } } } if (addIn.Enabled) { foreach (KeyValuePair <string, Version> pair in addIn.Manifest.Identities) { if (dict.ContainsKey(pair.Key)) { MessageService.ShowError("Name '" + pair.Key + "' is used by " + "'" + addInDict[pair.Key].FileName + "' and '" + fileName + "'"); addIn.Enabled = false; addIn.Action = AddInAction.InstalledTwice; break; } else { dict.Add(pair.Key, pair.Value); addInDict.Add(pair.Key, addIn); } } } list.Add(addIn); } checkDependencies: for (int i = 0; i < list.Count; i++) { AddIn addIn = list[i]; if (!addIn.Enabled) { continue; } Version versionFound; foreach (AddInReference reference in addIn.Manifest.Conflicts) { if (reference.Check(dict, out versionFound)) { MessageService.ShowError(addIn.Name + " conflicts with " + reference.ToString() + " and has been disabled."); DisableAddin(addIn, dict, addInDict); goto checkDependencies; // after removing one addin, others could break } } foreach (AddInReference reference in addIn.Manifest.Dependencies) { if (!reference.Check(dict, out versionFound)) { if (versionFound != null) { MessageService.ShowError(addIn.Name + " has not been loaded because it requires " + reference.ToString() + ", but version " + versionFound.ToString() + " is installed."); } else { MessageService.ShowError(addIn.Name + " has not been loaded because it requires " + reference.ToString() + "."); } DisableAddin(addIn, dict, addInDict); goto checkDependencies; // after removing one addin, others could break } } } foreach (AddIn addIn in list) { InsertAddIn(addIn); } }