Exemple #1
0
        /*
        public SharedUtils(string webServiceURL, string webServiceUsername, string webServicePassword, string localDBInstance, string appName, string cno)
        {
            _isConnected = TestCredentials(webServiceURL, webServiceUsername, webServicePassword);
            _appName = appName;
            if (!_isConnected)
            {
                Login loginDialog = new Login(webServiceUsername, webServicePassword, webServiceURL, null, false);
        loginDialog.StartPosition = FormStartPosition.CenterScreen;
                loginDialog.ShowDialog();
                if (DialogResult.OK == loginDialog.DialogResult)
                {
                    _isConnected = true;
                    webServiceURL = loginDialog.SelectedWebServiceURL;
                    webServiceUsername = loginDialog.UserName;
                    webServicePassword = loginDialog.Password_ClearText;
                    //_userCooperatorID = loginDialog.UserCooperatorID;
                    int langCode = 1;
                    if (int.TryParse(loginDialog.UserLanguageCode, out langCode))
                    {
                        _userLanguageCode = langCode;
                    }
                    else
                    {
                        _userLanguageCode = 1;
                    }
                    _userSite = loginDialog.UserSite;
                    _webServiceURLs = loginDialog.WebServiceURLs;
                }
            }

            if (_isConnected)
            {
                _webServices = new WebServices(webServiceURL, webServiceUsername, SHA1EncryptionBase64(webServicePassword), webServicePassword, _userSite);
                _localDatabase = new LocalDatabase(localDBInstance);
                _userSettings = new UserSettings(_webServices, cno, _appName);
                _appSettings = new AppSettings(_webServices, _userLanguageCode, appName);
                _userInterfaceUtils = new UserInterfaceUtils(_webServices);
                bool optimizeLUTForSpeed = false;
                bool.TryParse(_userSettings["", "ux_checkboxOptimizeLUTForSpeed", "Checked"], out optimizeLUTForSpeed);
                _lookupTables = new LookupTables(_webServices, _localDatabase, optimizeLUTForSpeed);
            }
        }
        */
        public SharedUtils(string webServiceURL, string webServiceUsername, string webServicePassword, bool hideServerList, string appName)
        {
            _isConnected = TestCredentials(webServiceURL, webServiceUsername, webServicePassword);
            _appName = appName;
            if (string.IsNullOrEmpty(appName)) _appName = "GRINGlobalClientCuratorTool";
            if (!_isConnected)
            {
                Login loginDialog = new Login(webServiceUsername, webServicePassword, webServiceURL, null, hideServerList);
            loginDialog.StartPosition = FormStartPosition.CenterScreen;
                loginDialog.ShowDialog();
                if (DialogResult.OK == loginDialog.DialogResult)
                {
                    _isConnected = true;
                    webServiceURL = loginDialog.SelectedWebServiceURL;
                    webServiceUsername = loginDialog.UserName;
                    webServicePassword = loginDialog.Password_ClearText;
                    _userCooperatorID = loginDialog.UserCooperatorID;
                    int langCode = 1;
                    if (int.TryParse(loginDialog.UserLanguageCode, out langCode))
                    {
                        _userLanguageCode = langCode;
                    }
                    else
                    {
                        _userLanguageCode = 1;
                    }
                    _userSite = loginDialog.UserSite;
                    _webServiceURLs = loginDialog.WebServiceURLs;
                }
            }

            if (_isConnected)
            {
                // Build the local DB name from the web service URL...
                string localDBInstance = webServiceURL.ToLower().Replace("http://", "").Replace("https://", "").Replace("/gringlobal/gui.asmx", "").Replace("/gringlobal_remote_debug/gui.asmx", "").Replace('-', '_').Replace('.', '_').Replace(':', '_');
                localDBInstance = "GRINGlobal_" + localDBInstance;
                _webServices = new WebServices(webServiceURL, webServiceUsername, SHA1EncryptionBase64(webServicePassword), webServicePassword, _userSite);
                _localDatabase = new LocalDatabase(localDBInstance);
                _userSettings = new UserSettings(_webServices, _userCooperatorID, _appName);
                DataSet userData = _webServices.ValidateLogin();
                if (userData != null &&
                    userData.Tables.Contains("validate_login") &&
                    userData.Tables["validate_login"].Rows.Count > 0)
                {
                    int sys_lang_id = 1;
                    if (int.TryParse(userData.Tables["validate_login"].Rows[0]["sys_lang_id"].ToString(), out sys_lang_id))
                    {
                        _userLanguageCode = sys_lang_id;
                    }
                    else
                    {
                        _userLanguageCode = 1;
                    }
                }
                _appSettings = new AppSettings(_webServices, _userLanguageCode, _appName);
                _userInterfaceUtils = new UserInterfaceUtils(_webServices);
                bool optimizeLUTForSpeed = false;
                bool.TryParse(_userSettings["", "ux_checkboxOptimizeLUTForSpeed", "Checked"], out optimizeLUTForSpeed);
                _lookupTables = new LookupTables(_webServices, _localDatabase, optimizeLUTForSpeed);
            }
        }
Exemple #2
0
        public SharedUtils(string webServiceURL, string webServiceUsername, string webServicePassword, string localDBInstance, string appName, string cno)
        {
            _isConnected = TestCredentials(webServiceURL, webServiceUsername, webServicePassword);
            _appName = appName;
            if (!_isConnected)
            {
                Login loginDialog = new Login(webServiceUsername, webServicePassword, webServiceURL, null, false);
            loginDialog.StartPosition = FormStartPosition.CenterScreen;
                loginDialog.ShowDialog();
                if (DialogResult.OK == loginDialog.DialogResult)
                {
                    _isConnected = true;
                    webServiceURL = loginDialog.SelectedWebServiceURL;
                    webServiceUsername = loginDialog.UserName;
                    webServicePassword = loginDialog.Password_ClearText;
                    //_userCooperatorID = loginDialog.UserCooperatorID;
                    int langCode = 1;
                    if (int.TryParse(loginDialog.UserLanguageCode, out langCode))
                    {
                        _userLanguageCode = langCode;
                    }
                    else
                    {
                        _userLanguageCode = 1;
                    }
                    _userSite = loginDialog.UserSite;
                    _webServiceURLs = loginDialog.WebServiceURLs;
                }
            }

            if (_isConnected)
            {
                _webServices = new WebServices(webServiceURL, webServiceUsername, SHA1EncryptionBase64(webServicePassword), webServicePassword, _userSite);
                _localDatabase = new LocalDatabase(localDBInstance);
                _userSettings = new UserSettings(_webServices, cno);
                _appSettings = new AppSettings(_webServices, _userLanguageCode, appName);
                _userInterfaceUtils = new UserInterfaceUtils(_webServices);
                bool optimizeLUTForSpeed = false;
                bool.TryParse(_userSettings["ux_checkboxOptimizeLUTForSpeed", "Checked"], out optimizeLUTForSpeed);
                _lookupTables = new LookupTables(_webServices, _localDatabase, optimizeLUTForSpeed);
            }
        }