Example #1
0
        static void Main(string[] args)
        {
            try
            {
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                CheckForUpgradeSettings();

                string dataMartClientId = Properties.Settings.Default.DataMartClientId;
                if (dataMartClientId == null || dataMartClientId == string.Empty)
                {
                    dataMartClientId = Properties.Settings.Default.DataMartClientId = Guid.NewGuid().ToString().ToUpper();
                }

                log4net.GlobalContext.Properties["LogFilePath"] = Properties.Settings.Default.LogFilePath;

                XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile));
                logWatcher = new LogWatcher(Properties.Settings.Default.LogLevel, Properties.Settings.Default.LogFilePath, dataMartClientId);
                log.Info("Started DataMart Client Application");
                SystemInfo.LogUserMachineInfo();
                Configuration.LogNetworkSettingsFile();
                log.Info("Check for single instance");

                CheckForShortcut();

                if (!SingleInstanceChecker.Start())
                {
                    StartupParams.WriteStartupParamsToFile(args);
                    SingleInstanceChecker.ShowFirstInstance();
                    return;
                }

                Dictionary <string, string> AddNetworkStartupParamsDict = StartupParams.GetAddNetworkStartupParamsDictionary(StartupParams.GetStartupParamsXml(args));

                log.Info("Run instance");

                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls;
                System.Net.ServicePointManager.CheckCertificateRevocationList       = true;
                System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                {
                    ////Commented out for removal of Thumprint Check
                    // return ValidateCertificate((System.Net.HttpWebRequest)sender, certificate, chain);
                    return(true);
                };


                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new RequestListForm(AddNetworkStartupParamsDict));
            }
            catch (Exception ex)
            {
                log.Fatal("Following error occured starting DataMartClient: " + ex.Message, ex);
                MessageBox.Show("Error occured starting DataMartClient. Please contact administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            SingleInstanceChecker.Stop();
        }
 /// <summary>
 /// Code to show single instance.
 /// </summary>
 /// <param name="message"></param>
 protected override void WndProc(ref Message message)
 {
     try
     {
         if (message.Msg == SingleInstanceChecker.WM_SHOWFIRSTINSTANCE)
         {
             ShowWindow();
             ShowConnectToNetworkDialog(StartupParams.GetAddNetworkStartupParamsDictionary(StartupParams.ReadStartupParamsFromFile(true)));
         }
         base.WndProc(ref message);
     }
     catch (Exception ex)
     {
         log.Error(ex);
         // Log it and keep going.
     }
 }