Example #1
0
        private bool ConnectToArchiveDatabase()
        {
            try
            {
                if (m_StoredUserPermissions == null)
                {
                    m_StoredUserPermissions = EidssUserContext.User.Permissions;
                }
                var credentials = new ConnectionCredentials(null, "Archive");
                ConnectionManager.DefaultInstance.SetCredentials(null, null, null, null, null, "Archive");
                DbManagerFactory.SetSqlFactory(credentials.ConnectionString);
                if (credentials.IsCorrect)
                {
                    using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                    {
                        if (!manager.TestConnection())
                        {
                            ErrorForm.ShowError("errArchiveConnectionError");
                            return(false);
                        }
                    }
                }
                else
                {
                    ErrorForm.ShowError("errArchiveConnectionError");
                    return(false);
                }

                var readOnlyPermissions = new Dictionary <string, bool>();
                foreach (string key in m_StoredUserPermissions.Keys)
                {
                    if (key.StartsWith(EIDSSPermissionObject.HumanCaseDeduplication.ToString()) ||
                        key.StartsWith(EIDSSPermissionObject.NotificationSubscription.ToString())
                        )
                    {
                        continue;
                    }
                    readOnlyPermissions.Add(key, key.EndsWith(".Select") ? m_StoredUserPermissions[key] : false);
                }
                EidssUserContext.User.Permissions = readOnlyPermissions;
                BaseFormManager.ArchiveMode       = true;
                return(true);
            }
            catch (Exception e)
            {
                if (!SqlExceptionHandler.Handle(e))
                {
                    ErrorForm.ShowError("errArchiveConnectionError", e);
                }
                return(false);
            }
        }
Example #2
0
        public static void ShowMessageDirect(Form owner, string msg, FormType fType, string detailError = null)
        {
            if (Utils.IsReportsServiceRunning || Utils.IsAvrServiceRunning)
            {
                string error =
                    string.Format("Could not show message form from the service.{0}Error message:{0}'{1}'{0} Error details:{0}'{2}'",
                                  Environment.NewLine, msg, detailError);
                throw new ApplicationException(error);
            }

            using (ErrorForm f = Create(owner, msg, fType, detailError))
            {
                ShowForm(f, owner);
            }
        }
Example #3
0
        public static bool IsMutexCreated(string mutexName)
        {
            if (mutexName == null)
            {
                return(false);
            }
            Dbg.Debug("trying to create mutex:" + mutexName);
            try
            {
                Mutex mutex = Mutex.OpenExisting(mutexName, MutexRights.FullControl);
                if (mutex != null)
                {
                    return(false);
                }
            }
            catch (WaitHandleCannotBeOpenedException)
            {
                //не найден, можно продолжать работу
            }
            catch (UnauthorizedAccessException)
            {
                return(false);
            }
            bool newMutexCreated = false;

            try
            {
                m_Mutex = new Mutex(true, mutexName, out newMutexCreated);
            }
            catch (Exception ex)
            {
                ErrorForm.ShowError(StandardError.UnprocessedError, ex);
                Application.Exit();
            }

            if (newMutexCreated)
            {
                Dbg.Debug("new mutex is created:" + mutexName);
                return(true);
            }
            Dbg.Debug("mutex with name " + mutexName + " exits already");
            return(false);
        }
Example #4
0
        private bool ReloadMenu()
        {
            m_LangageInitialized = false;
            ResetLanguage(ModelUserContext.CurrentLanguage);

            try
            {
                WinClientContext.SiteCaption = "( " + EidssSiteContext.Instance.SiteType + " - " +
                                               EidssSiteContext.Instance.SiteID + ") " +
                                               EidssSiteContext.Instance.SiteABR;
            }
            catch (Exception ex)
            {
                ErrorForm.ShowError(
                    EidssMessages.Get("errSiteNotDefined",
                                      "EIDSS site is not defined. Please reinstall the application with correct Site ID"),
                    ex);
                ExitApp(true);
                return(false);
            }
            return(true);
        }
Example #5
0
        private static ErrorForm Create(Form owner, string msg, FormType fType, string detailError = null)
        {
            if (owner == null)
            {
                owner = ActiveForm;
            }
            var f = new ErrorForm
            {
                ErrorText = msg,
                Type      = fType
            };

            //f.cmdDetail.Visible = !string.IsNullOrEmpty(detailError);
            if (!string.IsNullOrEmpty(detailError))
            {
                f.FullErrorText = detailError;
            }
            //f.cmdDetail_Click(null, EventArgs.Empty);
            f.StartPosition = owner != null ? FormStartPosition.CenterParent : FormStartPosition.CenterScreen;
            RtlHelper.SetRTL(f);
            return(f);
        }
Example #6
0
        void TimerUpdateListener_Elapsed(object sender, EventArgs e)
        {
            if (!UpdateMessenger.CanConnect())
            {
                //if there is no connection, let's check updates more rarely
                TimerUpdateListener.Interval = 100 * 1000;
                return;
            }
            //Restore default listen interval if connection exists
            TimerUpdateListener.Interval = UpdateMessenger.ListenInterval;
            //обновим, что данный экземпляр EIDSS ещё живёт
            UpdateMessenger.CreateRunningApps(ModelUserContext.ClientID, AppCode);
            //проверяем не начался ли апдейт
            //апдейт можно игнорировать, если соблюдаются те же бизнес-правила, что и для старта приложения

            if (!UpdateMessenger.CanRunApplication(ModelUserContext.ClientID, AppCode))
            {
                //отключаем один таймер и включаем другой, который через 10 минут принудительно выключит приложение
                TimerUpdateListener.Enabled = false;
                TimerExit.Enabled           = true;
                ErrorForm.ShowMessageDirect(EidssMessages.Get("ApplicationMustBeClosed"));
            }
        }
Example #7
0
 private static DialogResult ShowForm(ErrorForm f, Form owner)
 {
     if (owner == null)
     {
         owner = ActiveForm;
     }
     try
     {
         WaitDialog.Hide();
         f.TopMost = true;
         if (UnitTestMode)
         {
             f.Show(owner);
             Thread.Sleep(2000);
             return(DialogResult.OK);
         }
         return(f.ShowDialog(owner));
     }
     finally
     {
         WaitDialog.Restore();
     }
 }
Example #8
0
 private void RunEpiInfo()
 {
     if (!String.IsNullOrEmpty(BaseSettings.EpiInfoPath) && File.Exists(BaseSettings.EpiInfoPath))
     {
         try
         {
             var pi         = new ProcessStartInfo(BaseSettings.EpiInfoPath);
             var epiInfoDir = Path.GetDirectoryName(BaseSettings.EpiInfoPath);
             if (epiInfoDir != null)
             {
                 pi.WorkingDirectory = epiInfoDir;
             }
             Process.Start(pi);
         }
         catch (Exception e)
         {
             ErrorForm.ShowError("errEpiInfoLaunch", "Error during launching Epi Info.", e);
         }
     }
     else
     {
         ErrorForm.ShowWarningFormat("msgInvalidEpiInfoPath", "Wrong path to EPI Info in configuration file <{0}>.", BaseSettings.EpiInfoPath);
     }
 }
Example #9
0
        private bool Login()
        {
            if (!BaseFormManager.CloseAll(true))
            {
                return(true);
            }
            if (m_ActivityMonitor != null)
            {
                m_ActivityMonitor.Enabled = false;
            }
            var manager = new EidssSecurityManager();

            manager.LogOut();
            Visible = false;
            if (!LoginForm.DefaultLogin())
            {
                ExitApp(true);
                return(false);
            }

            //reset connection
            UpdateMessenger.SetConnection((SqlConnection)ConnectionManager.CreateNew().Connection);

            //check for can run application
            if (!UpdateMessenger.CanRunApplication(ModelUserContext.ClientID, AppCode))
            {
                ErrorForm.ShowMessageDirect(EidssMessages.Get("ApplicationMustBeClosed"));
                ExitApp(true);
                return(false);
            }

            if (m_Server == null)
            {
                try
                {
                    RemotingServer.Init();
                    RemoteEventManager.Singleton.MainForm = this;
                    m_Server = RemoteEventManager.Singleton;
                }
                catch (Exception)
                {
                    ErrorForm.ShowMessageDirect(EidssMessages.Get("errRemotingSockeError",
                                                                  "Unable to start server for communication with EIDSS Client Agent. Please check that no EIDSS application is started in other Windows session or ask adminisrtators to correct TCP port used by EIDSS. If you see this message, you will be not able to open EIDSS form directly from EIDSS Client Agent. Other EIDSS functionality is not changed."));
                }
            }
            CommonResourcesCache.Reset();
            EIDSS_LookupCacheHelper.Init();
            BaseForm.ReplicationNeeded         = EidssSiteContext.Instance.RealSiteType != SiteType.CDR;
            CustomCultureHelper.CurrentCountry = EidssSiteContext.Instance.CountryID;
            if (EidssSiteContext.Instance.IsAzerbaijanCustomization)
            {
                panel1.BackgroundImage = Properties.Resources.EIDSS_AZ_Background;
                Appearance.BackColor   = Color.White;
            }
            else if (EidssSiteContext.Instance.IsIraqCustomization)
            {
                panel1.BackgroundImage = Properties.Resources.EIDSS_IQ_Background;
                Appearance.BackColor   = Color.White;
                //Appearance.BackColor =Color.FromArgb(96,199,242);
            }
            else if (EidssSiteContext.Instance.IsThaiCustomization)
            {
                panel1.BackgroundImage = Properties.Resources.EIDSS_TH_Logo;
                Appearance.BackColor   = Color.White;
                //Appearance.BackColor =Color.FromArgb(96,199,242);
            }
            else
            {
                panel1.BackgroundImage = Properties.Resources.EIdss_background;
                Appearance.BackColor   = Color.FromArgb(184, 199, 230);
            }
            //eidss.model.Core.EidssSiteContext.Instance.CountryID = EIDSS.model.Core.EidssSiteContext.Instance.CountryID;
            Splash.ShowSplash();
            if (!ReloadMenu())
            {
                return(false);
            }
            Visible = true;
            InitAutoLogoutMonitor();

            if (BaseSettings.ScanFormsMode)
            {
                MessageBox.Show("Change config setting 'ScanFormsMode' to false!!", "ScanFormsMode = true!!");
            }

            return(true);
        }
Example #10
0
 public static void ShowMandatoryError(string fieldName)
 {
     ErrorForm.ShowErrorDirect(StandardErrorHelper.Error(StandardError.Mandatory, fieldName));
 }