static void Main(string [] args) { var parser = new ArgumentParser(args); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); PreferredSiteList.InitCulture(); IServerConnection conn = null; if (!parser.IsDefined(CommandLineArguments.Provider) || !parser.IsDefined(CommandLineArguments.Session)) { var login = new LoginDialog(); if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK) { conn = login.Connection; } } else { string prov = parser.GetValue(CommandLineArguments.Provider); conn = ConnectionProviderRegistry.CreateConnection(prov, parser.GetAllArgumentsWithValues()); } if (conn == null) return; Application.Run(new MainForm(conn.FeatureService, conn.ResourceService)); }
public override void Run() { var login = new LoginDialog(); login.Owner = Workbench.Instance; if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var conn = login.Connection; //TODO: Determine if this is a http connection. If not, //wrap it in an IServerConnection decorator that will do all the //request dispatch broadcasting. This will solve trac #1505 and will //work for any future non-http implementations var mgr = ServiceRegistry.GetService<ServerConnectionManager>(); Debug.Assert(mgr != null); // Connection display names should be unique. A duplicate means we are connecting to the same MG server LoggingService.Info("Connection created: " + conn.DisplayName); //NOXLATE if (mgr.GetConnection(conn.DisplayName) == null) { mgr.AddConnection(conn.DisplayName, conn); Workbench.Instance.ActiveSiteExplorer.FullRefresh(); } else { MessageService.ShowError(Strings.ConnectionAlreadyEstablished); } var vmgr = ServiceRegistry.GetService<ViewContentManager>(); } }
public override void Run() { var wb = Workbench.Instance; var svc = ServiceRegistry.GetService<ServerConnectionManager>(); var exp = wb.ActiveSiteExplorer; if (exp.SelectedItems.Length > 0) { var source = svc.GetConnection(exp.ConnectionName); var login = new LoginDialog(); if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var target = login.Connection; var migrate = new CopyMoveToServerDialog(source, target); var srcIds = new List<string>(); foreach (var item in exp.SelectedItems) { srcIds.Add(item.ResourceId); } migrate.SourceResourceIds = srcIds.ToArray(); if (migrate.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int affected = DoMigrate(source, target, migrate); MessageService.ShowMessage(string.Format(Strings.ItemsMigrated, affected)); if (affected > 0 && migrate.SelectedAction == MigrationAction.Move) { var parent = exp.SelectedItems[0].Parent; if (parent != null) exp.RefreshModel(source.DisplayName, parent.ResourceId); else exp.RefreshModel(source.DisplayName, StringConstants.RootIdentifier); } } } } }
public override void Run() { var wb = Workbench.Instance; var svc = ServiceRegistry.GetService<ServerConnectionManager>(); var exp = wb.ActiveSiteExplorer; if (exp.SelectedItems.Length == 1 && !exp.SelectedItems[0].IsFolder) { var source = svc.GetConnection(exp.ConnectionName); var login = new LoginDialog(); if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var target = login.Connection; var dlg = new MigrateDialog(source, target); dlg.ResourceID = exp.SelectedItems[0].ResourceId; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DoMigrate(source, target, dlg.ResourceID, dlg.DependentResources, dlg.OverwriteExisting); MessageService.ShowMessage(string.Format(Strings.ResourceMigrated, exp.SelectedItems[0].ResourceId)); } } } }
public static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.DoEvents(); PreferredSiteList.InitCulture(); ModelSetup.Initialize(); //Ensures that > 1.0.0 Map Definitions are recognised //Parameters: //mapagent= //username= //password= //mapdefinition= //scaleindex=0,1,2,3,4,5 //basegroups="x","y" //extentoverride=minx,miny,maxx,maxy Boolean batchMode = false; string mapagent = "http://localhost/mapguide"; string username = "******"; string password = ""; string mapdefinitions = ""; string scaleindex = ""; string basegroups = ""; string limitRows = ""; string limitCols = ""; string tileWidth = ""; string tileHeight = ""; string DPI = ""; string metersPerUnit = ""; IEnvelope overrideExtents = null; List<string> largs = new List<string>(args); Dictionary<string, string> opts = CommandLineParser.ExtractOptions(largs); if (opts.ContainsKey("mapagent")) mapagent = opts["mapagent"]; if (opts.ContainsKey("username")) username = opts["username"]; if (opts.ContainsKey("password")) password = opts["password"]; if (opts.ContainsKey("mapdefinitions")) mapdefinitions = opts["mapdefinitions"]; if (opts.ContainsKey("scaleindex")) scaleindex = opts["scaleindex"]; if (opts.ContainsKey("basegroups")) basegroups = opts["basegroups"]; if (opts.ContainsKey("limitrows")) limitRows = opts["limitrows"]; if (opts.ContainsKey("limitcols")) limitCols = opts["limitcols"]; if (opts.ContainsKey("tilewidth")) tileWidth = opts["tilewidth"]; if (opts.ContainsKey("tileheight")) tileHeight = opts["tileheight"]; if (opts.ContainsKey("DPI")) DPI = opts["DPI"]; if (opts.ContainsKey("metersperunit")) metersPerUnit = opts["metersperunit"]; if (opts.ContainsKey("extentoverride")) { string[] parts = opts["extentoverride"].Split(','); if (parts.Length == 4) { double minx; double miny; double maxx; double maxy; if ( double.TryParse(parts[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out minx) && double.TryParse(parts[1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out miny) && double.TryParse(parts[2], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxx) && double.TryParse(parts[3], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxy) ) { overrideExtents = ObjectFactory.CreateEnvelope(minx, miny, maxx, maxy); } } } if (largs.IndexOf("batch") >= 0 || largs.IndexOf("/batch") >= 0 || largs.IndexOf("commandline") >= 0 || largs.IndexOf("/commandline") >= 0) { batchMode = true; } try { Console.Clear(); m_logableProgress = true; } catch { hasConsole = false; m_logableProgress = false; } IServerConnection connection = null; string[] maps = mapdefinitions.Split(','); SetupRun sr = null; if (!opts.ContainsKey("username") || (!opts.ContainsKey("mapagent"))) { if (!batchMode) { if (opts.ContainsKey("provider") && opts.ContainsKey("connection-params")) { var initP = ConnectionProviderRegistry.ParseConnectionString(opts["connection-params"]); connection = ConnectionProviderRegistry.CreateConnection(opts["provider"], initP); sr = new SetupRun(connection, maps, opts); } else { var frm = new LoginDialog(); if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; connection = frm.Connection; sr = new SetupRun(frm.Username, frm.Password, connection, maps, opts); } try { mapagent = connection.GetCustomProperty("BaseUrl").ToString(); } catch { } } } if (connection == null) { var initP = new NameValueCollection(); if (!opts.ContainsKey("native-connection")) { initP["Url"] = mapagent; initP["Username"] = username; initP["Password"] = password; initP["Locale"] = System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; initP["AllowUntestedVersion"] = "true"; connection = ConnectionProviderRegistry.CreateConnection("Maestro.Http", initP); } else if (opts.ContainsKey("provider") && opts.ContainsKey("connection-params")) { initP = ConnectionProviderRegistry.ParseConnectionString(opts["connection-params"]); connection = ConnectionProviderRegistry.CreateConnection(opts["provider"], initP); } else { string serverconfig = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "webconfig.ini"); initP["ConfigFile"] = serverconfig; initP["Username"] = username; initP["Password"] = password; initP["Locale"] = System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; connection = ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", initP); } } if (!batchMode) { if (sr == null) sr = new SetupRun(connection, maps, opts); sr.ShowDialog(); return; } TilingRunCollection bx = new TilingRunCollection(connection); int x; if (!string.IsNullOrEmpty(limitCols) && int.TryParse(limitCols, out x)) bx.LimitCols(x); if (!string.IsNullOrEmpty(limitRows) && int.TryParse(limitRows, out x)) bx.LimitRows(x); if (!string.IsNullOrEmpty(tileWidth) && int.TryParse(tileWidth, out x)) bx.Config.TileWidth = x; if (!string.IsNullOrEmpty(tileHeight) && int.TryParse(tileHeight, out x)) bx.Config.TileHeight = x; if (!string.IsNullOrEmpty(DPI) && int.TryParse(DPI, out x)) bx.Config.DPI = x; double d; if (!string.IsNullOrEmpty(metersPerUnit) && double.TryParse(metersPerUnit, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.CurrentCulture, out d)) { bx.Config.MetersPerUnit = d; bx.Config.UseOfficialMethod = true; } if (opts.ContainsKey("random-tile-order")) bx.Config.RandomizeTileSequence = true; if (opts.ContainsKey("threadcount") && int.TryParse(opts["threadcount"], out x) && x > 0) bx.Config.ThreadCount = x; //Now that all global parameters are set, we can now add the map definitions bx.AddMapDefinitions(maps); //basegroups must be set in each mapdefinition if (!string.IsNullOrEmpty(basegroups)) { List<string> groups = new List<string>(); foreach (string s in basegroups.Split(',')) { string f = s; if (f.StartsWith("\"")) f = f.Substring(1); if (f.EndsWith("\"")) f = f.Substring(0, f.Length - 1); groups.Add(f); } bx.SetGroups(groups.ToArray()); } if (overrideExtents != null) { List<int> scales = new List<int>(); int tmp; foreach (string s in scaleindex.Split(',')) if (int.TryParse(s, out tmp)) scales.Add(tmp); foreach (MapTilingConfiguration bm in bx.Maps) bm.SetScalesAndExtend(scales.ToArray(), overrideExtents); } else if (!string.IsNullOrEmpty(scaleindex)) { List<int> scales = new List<int>(); int tmp; foreach (string s in scaleindex.Split(',')) if (int.TryParse(s, out tmp)) scales.Add(tmp); bx.SetScales(scales.ToArray()); } if (!batchMode) { Progress pg = new Progress(bx); pg.ShowDialog(); } else { bx.BeginRenderingMap += new ProgressCallback(bx_BeginRenderingMap); bx.FinishRenderingMap += new ProgressCallback(bx_FinishRenderingMap); bx.BeginRenderingGroup += new ProgressCallback(bx_BeginRenderingGroup); bx.FinishRenderingGroup += new ProgressCallback(bx_FinishRenderingGroup); bx.BeginRenderingScale += new ProgressCallback(bx_BeginRenderingScale); bx.FinishRenderingScale += new ProgressCallback(bx_FinishRenderingScale); bx.BeginRenderingTile += new ProgressCallback(bx_BeginRenderingTile); bx.FinishRenderingTile += new ProgressCallback(bx_FinishRenderingTile); bx.FailedRenderingTile += new ErrorCallback(bx_FailedRenderingTile); mapCount = 0; lastUpdate = DateTime.Now; bx.RenderAll(); } }