示例#1
0
        static void Main()
        {
            if (ApplicationRunningHelper.AlreadyRunning())
            {
                XtraMessageBox.Show("FG-TRACKING Opened", "Please Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                DevExpress.UserSkins.OfficeSkins.Register();
                DevExpress.UserSkins.BonusSkins.Register();
                DevExpress.Skins.SkinManager.EnableFormSkins();
                //DevExpress.LookAndFeel.LookAndFeelHelper.ForceDefaultLookAndFeelChanged();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);


                //check folder permission
                bool isP = IsPermissionFolder();
                if (!isP)
                {
                    AllowFolderPermission();
                }


                string appSkin = UiUtility.ApplicationStyle;

                if (!string.IsNullOrEmpty(appSkin))
                {
                    DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(appSkin);
                }
                else
                {
                    DevExpress.LookAndFeel.UserLookAndFeel.Default.SetDefaultStyle();
                }



                Cursor.Current = Cursors.WaitCursor;

                //Process objProcess = Process.GetCurrentProcess();
                //string currAppName = objProcess.ProcessName;

                //if (Process.GetProcessesByName(currAppName).Length > 1)
                //{
                //    Cursor.Current = Cursors.Default;

                //    Application.ExitThread();
                //    Application.Exit();
                //}
                //else
                //{
                if (UiUtility.IsAutoCheckVersion)
                {
                    bool    isClearGrid = false;
                    Version curVersion  = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                    Version newVersion  = UiUtility.CheckVersion(false, out isClearGrid);//NewVersion();

                    if (curVersion.CompareTo(newVersion) != 0)
                    {
                        Cursor.Current = Cursors.Default;

                        XtraMessageBox.Show("THE SYSTEM DETECTED NEW VERSION!!", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        string fileUpdate = string.Format("{0}\\{1}", Application.StartupPath, ConfigurationManager.AppSettings["AppUpdate"]);
                        if (File.Exists(fileUpdate))
                        {
                            //Check Clear Grid
                            if (isClearGrid)
                            {
                                ClearGridHistory();
                            }

                            using (Process proc = new Process())
                            {
                                proc.StartInfo.FileName  = fileUpdate;
                                proc.StartInfo.Arguments = string.Format("\"{0}\"", Application.StartupPath);
                                proc.Start();
                            }

                            GC.Collect();
                            GC.WaitForPendingFinalizers();

                            Application.Exit();
                        }
                        else
                        {
                            StartApplication();
                        }
                    }
                    else
                    {
                        Cursor.Current = Cursors.Default;
                        StartApplication();
                    }
                }
                else
                {
                    Cursor.Current = Cursors.Default;
                    StartApplication();
                }

                //}
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                XtraMessageBox.Show(ex.Message);
            }
        }