Example #1
0
        /// <summary>
        /// Log in to a server
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="ConnectionUri"></param>
        private void LoginToServer(String Title, Uri ConnectionUri)
        {
            frmWindowsSecurityDialog SecurityDialog = new frmWindowsSecurityDialog();

            SecurityDialog.CaptionText = Application.ProductName + " " + Application.ProductVersion;
            SecurityDialog.MessageText = "Enter the credentials to log into Macomber Map Server " + Title;
            string    Username, Password, Domain;
            Exception LoginError;

            if (SecurityDialog.ShowLoginDialog(out Username, out Password, out Domain))
            {
                if (MM_Server_Interface.TryLogin(Title, ConnectionUri, Username, Password, out LoginError))
                {
                    tpProgress.Show();
                    tcMain.SelectedTab = tpProgress;

                    StartupDelegate = new Data_Integration.StartupModelDelegate(Data_Integration.StartupModel);
                    IAsyncResult Resp = StartupDelegate.BeginInvoke(MM_Server_Interface.Client, this, false, HandleServerLoginCompletion, null);


                    MM_Repository.user = Username;
                    MM_Repository.pw   = Password;
                }
                else
                {
                    MessageBox.Show("Unable to log into Macomber Map Server: " + LoginError.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        /// <summary>Report the server name</summary>
        /// <returns></returns>
        public string ServerName()
        {
            try
            {
                return(innerChannel.ServerName());
            } catch (Exception ex)
            {
                MM_System_Interfaces.LogError(ex.Message);

                try
                {
                    if (ex.Message.IndexOf("aborted", StringComparison.OrdinalIgnoreCase) >= 0 || ex.Message.IndexOf("Faulted", StringComparison.OrdinalIgnoreCase) >= 0 && (!lastConnect.HasValue || (DateTime.Now - lastConnect.Value).TotalSeconds > 10))
                    {
                        // can we reconnect?
                        Exception error = null;
                        // this login method should reconnect us.
                        if (MM_Server_Interface.TryLogin(MM_Server_Interface.ServerName, MM_Server_Interface.ConnectionURI, MM_Server_Interface.UserName, MM_Server_Interface.Password, out error))
                        {
                            return(MM_Server_Interface.ServerName);
                        }
                        lastConnect = DateTime.Now;
                        if (error != null)
                        {
                            throw error;
                        }
                    }
                }
                catch (Exception exp)
                {
                    MM_System_Interfaces.LogError(exp.Message);
                }

                return("SERVER ERROR");
            }
        }
Example #3
0
        /// <summary>
        /// Report the user status
        /// </summary>
        /// <param name="Status"></param>
        /// <returns></returns>
        public bool ReportUserStatus(MacomberMapCommunications.Messages.MM_Client_Status Status)
        {
            try
            {
                return(innerChannel.ReportUserStatus(Status));
            }
            catch (Exception ex)
            {
                MM_System_Interfaces.LogError(ex.Message);

                try
                {
                    if (ex.Message.IndexOf("aborted", StringComparison.OrdinalIgnoreCase) >= 0 || ex.Message.IndexOf("Faulted", StringComparison.OrdinalIgnoreCase) >= 0 && (!lastConnect.HasValue || (DateTime.Now - lastConnect.Value).TotalSeconds > 10))
                    {
                        // can we reconnect?
                        Exception error = null;
                        // this login method should reconnect us.
                        MM_Server_Interface.TryLogin(MM_Server_Interface.ServerName, MM_Server_Interface.ConnectionURI, MM_Server_Interface.UserName, MM_Server_Interface.Password, out error);
                        lastConnect = DateTime.Now;
                        if (error != null)
                        {
                            throw error;
                        }
                    }
                }
                catch (Exception exp)
                {
                    MM_System_Interfaces.LogError(exp.Message);
                }
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// Log in to a server
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="ConnectionUri"></param>
        private void LoginToServer(String Title, Uri ConnectionUri)
        {
            frmWindowsSecurityDialog SecurityDialog = new frmWindowsSecurityDialog();

            SecurityDialog.CaptionText = Application.ProductName + " " + Application.ProductVersion;
            SecurityDialog.MessageText = "Enter the credentials to log into Macomber Map Server " + Title;
            string    Username, Password, Domain;
            Exception LoginError;

            if (SecurityDialog.ShowLoginDialog(out Username, out Password, out Domain))
            {
                if (MM_Server_Interface.TryLogin(Title, ConnectionUri, Username, Password, out LoginError))
                {
                    MM_Server_Interface.UserName = Username;
                    MM_Server_Interface.Password = Password;
                }
                else
                {
                    MessageBox.Show("Unable to log into Macomber Map Server: " + LoginError.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #5
0
        static void Main(params string[] args)
        {
            // CreateModelXml user password filepath (Build thMM_System_Interfacesis as a console app for this job).
            if (args.Length > 0 && args[0].Equals("CreateModelXml", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    System.Console.Error.WriteLine("Starting XML Model creator client");
                    MM_Server_Interface.LoadModelFromSql = true;
                    MM_System_Interfaces.Headless        = true;
                    MM_Repository.OverallDisplay         = new MM_Display();
                    MM_Coordinates coord = new MM_Coordinates(-109f, 29f, -86f, 51f, 1f);

                    System.Console.Error.WriteLine("Waiting for server...");
                    while (MM_Server_Interface.MMServers == null || MM_Server_Interface.MMServers.Count == 0)
                    {
                        Thread.Sleep(3000);
                    }

                    var list = MM_Server_Interface.MMServers.Values.ToList();

                    System.Console.Error.WriteLine("Connecting to server: " + list[0].ServerName);

                    string user     = "******";
                    string password = "";
                    string file     = "MacomberMap-Combined.MM_Model";

                    if (args.Length > 1)
                    {
                        if (args[1].EndsWith(".MM_Model"))
                        {
                            file = args[1];
                        }
                        else
                        {
                            user = args[1];
                        }
                    }
                    if (args.Length > 2)
                    {
                        if (args[2].EndsWith(".MM_Model"))
                        {
                            file = args[2];
                        }
                        else
                        {
                            password = args[2];
                        }
                    }
                    if (args.Length > 3)
                    {
                        file = args[3];
                    }
                    Exception exp = new Exception();
                    MM_Server_Interface.TryLogin(list[0].ServerName, list[0].ServerURI, user, password, out exp);
                    MM_Server_Interface.LoadMacomberMapConfiguration();

                    Data_Integration.InitializationComplete = false;
                    System.Console.Error.WriteLine("Starting SQL Model Loader...");
                    SqlModelLoader sqlModelLoader = new SqlModelLoader();
                    sqlModelLoader.ConnectionString = Settings.Default.ModelDatabase;
                    sqlModelLoader.LoadStaticRepository();
                    System.Console.Error.WriteLine("Rolling up Elements...");
                    Data_Integration.UseEstimates = false;
                    Data_Integration.RollUpElementsToSubstation();
                    Data_Integration.CommLoaded                 = true;
                    Data_Integration.ModelLoadCompletion        = DateTime.Now;
                    Data_Integration.NetworkSource              = new MM_Data_Source();
                    Data_Integration.NetworkSource.Estimates    = false;
                    Data_Integration.NetworkSource.Database     = "NETMOM";
                    Data_Integration.NetworkSource.Application  = "RTNET";
                    Data_Integration.NetworkSource.BackColor    = Color.Blue;
                    Data_Integration.NetworkSource.Telemetry    = true;
                    Data_Integration.NetworkSource.Default      = true;
                    Data_Integration.NetworkSource.Master       = true;
                    Data_Integration.NetworkSource.ViolationApp = "RTCA";
                    Data_Integration.InitializationComplete     = true;
                    // Data_Integration.RestartModel(MM_Server_Interface.Client);
                    Data_Integration.SaveXMLData(file, coord);
                    System.Console.WriteLine("Waiting for data...");
                    for (int i = 0; i < 60 * 8; i++)
                    {
                        System.Console.Write(".");
                        Thread.Sleep(1000); // wait for EMS data to flow in.
                    }
                    Data_Integration.SaveXMLData(file, coord);
                }
                catch (Exception ex)
                {
                    System.Console.Error.WriteLine(ex.Message);
                    System.Console.Error.WriteLine(ex.StackTrace);
                    System.Environment.Exit(1);
                }
                System.Environment.Exit(0);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;
            //   Application.Run(new frmControlTester());
            // return;
            try
            {
                Microsoft.Win32.RegistryKey key;
                key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Policies", true);

                if (!key.GetSubKeyNames().Contains("Chromium"))
                {
                    key.CreateSubKey("Chromium");
                }
                key = key.OpenSubKey("Chromium", true);
                if (!key.GetSubKeyNames().Contains("EnabledPlugins"))
                {
                    key.CreateSubKey("EnabledPlugins");
                }
                key = key.OpenSubKey("EnabledPlugins", true);

                if (!key.GetValueNames().Contains("1"))
                {
                    key.SetValue("1", "Silverlight*");
                    key.SetValue("2", "npapi");
                }
            }
            catch (Exception ex)
            {
                MM_System_Interfaces.LogError(ex);
            }
            if (Environment.CommandLine.IndexOf("/Test", StringComparison.CurrentCultureIgnoreCase) != -1)
            {
                Application.Run(new frmTest());
            }
            else
            {
                using (MM_Startup_Form Startup = new MM_Startup_Form())
                    if (Startup.ShowDialog(StartNetworkMap) == DialogResult.OK)
                    {
                        Application.Run();
                    }
                    else
                    {
                        Application.Exit();
                    }
            }
        }