Exemplo n.º 1
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     _SMain = new EcranPrincipal();
     Application.Run(_SMain);
 }
Exemplo n.º 2
0
        static void Main()
        {
            bool    existaDejaInAceeasiSesiune = false;
            Process current          = Process.GetCurrentProcess();
            bool    esteMultiSesiune = false;

            if (!esteMultiSesiune)
            {
                //Pentru cazurile in care avem mai multe sesiuni (Windows Server)
                //Trebuie ca fiecare utilizator sa poata rula aplicatia o singura data
                if (Process.GetProcessesByName(current.ProcessName).Length > 1)
                {
                    Process[] runningProcesses = Process.GetProcesses();
                    var       currentSessionID = Process.GetCurrentProcess().SessionId;

                    Process[] sameAsThisSession = (from c in runningProcesses where c.SessionId == currentSessionID select c).ToArray();

                    foreach (var process in sameAsThisSession)
                    {
                        //}

                        //foreach (Process process in Process.GetProcessesByName(current.ProcessName))
                        //{
                        if (process.Id != current.Id)
                        {
                            SetForegroundWindow(process.MainWindowHandle);
                            ShowWindow(process.MainWindowHandle, (int)EnumWindowStates.SW_SHOWMAXIMIZED);

                            return;
                        }
                    }
                }
            }

            //ro-RO
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.CurrentCulture = new System.Globalization.CultureInfo("ro-RO");
            //Application.CurrentInputLanguage = InputLanguage.FromCulture(Application.CurrentCulture);
            Thread.CurrentThread.CurrentUICulture = Application.CurrentCulture;
            Thread.CurrentThread.CurrentCulture   = Application.CurrentCulture;

            //Trebuie sa ruleze cu prioritate
            current.PriorityClass        = ProcessPriorityClass.High;
            current.PriorityBoostEnabled = true;

            EcranPrincipal _SMain = null;

            try
            {
                do
                {
                    //Afisam ecranul de asteptare pe care il inchidem dupa incarcarea ecranului principal (frmStoma)
                    //lEcranAstepare = new EcranAsteptare();
                    //lEcranAstepare.Show();

                    _SMain = new EcranPrincipal();
                    if (_SMain.IsDisposed == false)
                    {
                        try
                        {
                            URLSecurityZoneAPI.InternetSetFeatureEnabled(URLSecurityZoneAPI.InternetFeaturelist.DISABLE_NAVIGATION_SOUNDS, URLSecurityZoneAPI.SetFeatureOn.PROCESS, true);
                        }
                        catch (Exception)
                        {
                            //Nu este nicio problema daca nu reusim sa dezactivam sunetele de la IE
                        }

                        //Ca sa aiba toate functiile Internet Explorer
                        var fileName = System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName);
                        SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode());

                        Application.Run(_SMain);
                    }
                    else
                    {
                        //lEcranAstepare.Close();
                    }
                } while (_SMain.InchideAplicatia != true);
            }
            catch (Exception ex)
            {
                if (_SMain != null)
                {
                    _SMain.inchideEcranAsteptare();
                }

                if (ex is InvalidOperationException || ex is SqlException)
                {
                    //Serverul nu este pornit
                    MessageBox.Show(string.Concat("Serverul nu este pornit", CConstante.LinieNoua, CUtil.GetTextCompletExceptie(ex)), "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    //Alta eroare
                    MessageBox.Show(CUtil.GetTextCompletExceptie(ex), "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //_SMain = new EcranPrincipal();
            //Application.Run(_SMain);
        }
Exemplo n.º 3
0
 internal static void Deconectare(Form pMain)
 {
     pMain.Close();
     _SMain = new EcranPrincipal();
     Application.Restart();
 }
Exemplo n.º 4
0
        private void bwVerifica_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (this.lEtapa == 0)
                {
                    //Activeaza licenta
                    if (this.lActivare.Equals("66"))
                    {
                        //Userul nu exista
                        //"Informațiile furnizate nu sunt valide!"
                        MessageBox.Show("Informatiile introduse nu sunt valide", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        this.lNumarIncercari++;

                        if (this.lNumarIncercari > 3)
                        {
                            this.lEtapa = 13; //fortam inchiderea ecranului
                        }
                    }
                    else
                    {
                        if (this.lActivare.Equals("33"))
                        {
                            //Eroare tehnica
                            MessageBox.Show("Contactati un reprezentant IDAVA SOLUTIONS", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            //Totul este ok => scriem in registri si trecem la BDD
                            EcranPrincipal.updateLicenta(this.txtLicenta.Text.Trim());

                            this.lEtapa = 1;
                        }
                    }
                }
                else
                {
                    if (this.lEtapa == 1)
                    {
                        this.lEtapa = 2;
                    }
                    else
                    {
                        this.lEtapa = 3;
                    }
                }

                if (this.lEtapa <= 2)
                {
                    afiseazaEtapa();
                }

                if (this.lEtapa > 2)
                {
                    if (this.lActivare.Equals("13"))
                    {
                        iStoma.VerificareSoapClient verif = new iStoma.VerificareSoapClient();

                        verif.ActualizeazaInformatiiConexiune(this.lCodClient, CSecuritate.GetMd5Hash(this.lParolaISTOMA), this.lLicenta, BMasina.getIdMasina(), this.lNumeServer, this.lNumeInstanta, this.lNumeUser, this.lNumeBDD, this.lCaleFolderDocumente);
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                        this.Close();
                    }
                }

                if (!string.IsNullOrEmpty(lExceptie))
                {
                    //Avem exceptie
                    MessageBox.Show(lExceptie, "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    zoneActive(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                zoneActive(true);
            }
        }