public static IApplication GetInstance() { if (n_Instance == null) { n_Instance = new ApplicationWinForm(); } return(n_Instance); }
private bool TestConnection() { FillClass(true); if (Connection.Instance.Connect()) { return(ApplicationWinForm.ConnectToDI(true)); } return(false); }
/// <summary> /// Faz uma validação de conexão a DI API /// </summary> /// <param name="pUseCahe">Caso queira usar um cache ( Lista de Usuário ) true , se não quiser usar ( false ) </param> /// <returns>True - para conectado com sucesso, false para não conectado </returns> internal static bool ConnectToDI(bool pUseCahe) { ApplicationWinForm myApp = new ApplicationWinForm(); //Create table if dosent exists myApp.CreateUserCacheTable(); if (pUseCahe && myApp.UserExistOnCache()) { //Se a senha não mudou if (!myApp.IsChangedCompamyPassword()) { if (myApp.ValidatePassword()) { return(true); } else { throw new Exception("Usuário ou senha inválido"); } } //Valida a senha } DICompany dicompany = new DICompany(); var param = Connection.Instance.ConnectionParameter; dicompany.Server = param.Server; dicompany.DbUserName = param.DBUser; dicompany.DbPassword = param.DBPassword; dicompany.LicenseServer = param.LicenseServer; dicompany.CompanyDB = param.CompanyDb; dicompany.DbServerType = param.DbServerType; dicompany.UserName = param.UserName; dicompany.Password = param.Password; dicompany.language = BoLanguages.ln_Portuguese_Br; if (dicompany.Connect() != 0) { throw new Exception( string.Format("{0} - {1}", dicompany.GetLastErrorCode(), dicompany.GetLastErrorDescription())); } myApp.SavePasswordOnCache(); return(true); }
public bool StartApplication(string pNameSpace, eAppType pAppType) { NameSpace = pNameSpace; AppType = pAppType; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("pt-BR"); DevExpress.LookAndFeel.LookAndFeelHelper.ForceDefaultLookAndFeelChanged(); DevExpress.Skins.SkinManager.EnableFormSkins(); DevExpress.Skins.SkinManager.EnableMdiFormSkins(); ExtractLocation(); switch (AppType) { case eAppType.WinForms: m_Concrete = ApplicationWinForm.GetInstance(); break; case eAppType.SAPForms: m_Concrete = ApplicationSAP.GetInstance(); break; default: throw new NotSupportedException(AppType.ToString()); } m_Concrete.CheckHostedEnvironment = CheckHostedEnvironment; m_Concrete.AppEvent += ConcreteAppEvent; m_Concrete.MenuEvent += ConcreteMenuEvent; m_Concrete.OnStartConnection += m_Concrete_OnStartConnection; m_Concrete.OnStartCreateMenu += m_Concrete_OnStartCreateMenu; m_Concrete.OnShutDown += m_Concrete_OnShutDown; m_Concrete.OnChangeCompany += m_Concrete_OnChangeCompany; m_Concrete.AddonIdentifiers = AddonIdentiers; return(m_Concrete.StartApplication(NameSpace)); }