Exemple #1
0
        public LookupTables(WebServices webServices, LocalDatabase localData, bool optimizeLUTForSpeed)
        {
            _webServices = webServices;
            _localData = localData;
            _lookupTableStatus = new Dictionary<string, bool>();
            _optimizeLUTForSpeed = optimizeLUTForSpeed;

            // Dictionary for fast lookup...
            _pkeyLUTCacheCollection = LoadPKeyLUTCacheCollection();
            // Dictionary for fast reverse lookup...
            _pkeyRLUTCacheCollection = LoadPKeyRLUTCacheCollection();
            _codevalueLUTCache = LoadCodeValueLUTDictionary("code_value_lookup");
        }
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);
            }
        }
Exemple #3
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 #4
0
        private void LoadCooperators(string localDBInstance)
        {
            DataTable cooperatorTable = null;
            LocalDatabase localDB = new LocalDatabase(localDBInstance);

            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            // If the cooperator_lookup table does not exist in the local DB
            // create it using the GetDisplayMember method which will do three things...
            if (!localDB.TableExists("cooperator_lookup"))
            {
                // This will force the lookupTables class to:
                // 1) retrieve the record for the current cno from the remote DB
                // 2) create a new cooperator_lookup table on the local DB with one row of data
                // 3) copy that table to the in memory MRU table...
                //lookupTables.GetDisplayMember("cooperator_lookup", cno, "", cno);
                _sharedUtils.GetLookupDisplayMember("cooperator_lookup", _usernameCooperatorID, "", _usernameCooperatorID);

                // Now we will background thread the cooperator_lookup table loading - because it is really needed
                // and we can't count on the user to load it manually...
                //new System.Threading.Thread(lookupTables.LoadTableFromDatabase).Start("cooperator_lookup");
                //new System.Threading.Thread(lookupTables.LoadTableFromDatabase).Start("cooperator");
                new System.Threading.Thread(_sharedUtils.LookupTablesLoadTableFromDatabase).Start("cooperator_lookup");
            }
            else
            {
                // Since the cooperator_lookup table exists - make sure the selected cno is one of the rows...
                //lookupTables.GetDisplayMember("cooperator_lookup", cno, "", cno);
                _sharedUtils.GetLookupDisplayMember("cooperator_lookup", _usernameCooperatorID, "", _usernameCooperatorID);
            }
            // Now that we are sure the cooperator lookup table exists use it...
            //cooperatorTable = localDB.GetData("SELECT * FROM cooperator_lookup WHERE is_account_enabled = 'Y'");
            cooperatorTable = localDB.GetData("SELECT * FROM cooperator_lookup WHERE account_is_enabled = @accountisenabled", new string[1] { "@accountisenabled=Y" });
            if (cooperatorTable.Columns.Contains("display_member")) cooperatorTable.DefaultView.Sort = "display_member ASC";
            if (cooperatorTable.Columns.Contains("site")) cooperatorTable.DefaultView.RowFilter = "site = '" + site + "'";
            //if (cooperatorTable.Columns.Contains("site_code")) cooperatorTable.DefaultView.RowFilter = "site_code = '" + site + "'";

            // Bind the control to the data in grinLookups...
            // WARNING!!!: You must set DisplayMember and ValueMember properties BEFORE setting
            //             DataSource - otherwise the cbCooperators.SelectedValue.ToString() method
            //             will return an object of DataRowView instead of the CNO value
            ux_comboboxCNO.DisplayMember = "display_member";
            ux_comboboxCNO.ValueMember = "value_member";
            ux_comboboxCNO.DataSource = cooperatorTable;

            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }