コード例 #1
0
ファイル: ChangePassword.cs プロジェクト: egacheru/G2
        private void ux_buttonOk_Click(object sender, EventArgs e)
        {
            try
            {
                _webServices = new WebServices(_webServiceURL, ux_textboxUsername.Text, SharedUtils.SHA1EncryptionBase64(ux_textboxCurrentPassword.Text), ux_textboxCurrentPassword.Text, _site);
                DataSet userData = _webServices.ValidateLogin();
                if (userData != null &&
                    userData.Tables.Contains("validate_login") &&
                    userData.Tables["validate_login"].Rows.Count > 0)
                {

                    DataSet newPasswordResults = _webServices.ChangePassword(SharedUtils.SHA1EncryptionBase64(ux_textboxNewPassword.Text));
                    if (newPasswordResults != null &&
                        newPasswordResults.Tables.Contains("ExceptionTable") &&
                        newPasswordResults.Tables["ExceptionTable"].Rows.Count == 0)
                    {
                        _password = ux_textboxNewPassword.Text;
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else if (newPasswordResults != null &&
                        newPasswordResults.Tables.Contains("ExceptionTable") &&
                        newPasswordResults.Tables["ExceptionTable"].Rows.Count > 0)
                    {
            //MessageBox.Show("There was an unexpected error changing your password.\n\nFull error message:\n" + newPasswordResults.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error changing your password.\n\nFull error message:\n{0}", "Change Password Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage1";
            if (_sharedUtils != null) _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, newPasswordResults.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            ggMessageBox.ShowDialog();
                    }
                    else
                    {
            //MessageBox.Show("There was an unexpected error changing your password.");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error changing your password.", "Change Password Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage2";
            if (_sharedUtils != null) _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            ggMessageBox.ShowDialog();
                    }
                }
                else
                {
            //MessageBox.Show("Error: The Username/Password are not valid for server:\n\n" + _webServiceURL + "\n\nPlease correct and try again.");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error: The Username/Password are not valid for server:\n\n{0}\n\nPlease correct and try again.", "Invalid Username or Password", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage3";
            if (_sharedUtils != null) _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _webServiceURL);
            ggMessageBox.ShowDialog();
                }
            }
            catch
            {
            //MessageBox.Show("Error connecting to server: " + _webServiceURL);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error connecting to server: {0}", "Server Connection Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage4";
            if (_sharedUtils != null) _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _webServiceURL);
            ggMessageBox.ShowDialog();
            }
        }
コード例 #2
0
ファイル: Login.cs プロジェクト: egacheru/G2
        public Login(string userName, string password, string preferredWebServiceURL, string webServiceHostsfileFullPath, bool hideServerList)
        {
            InitializeComponent();
            _userName = userName;
            _passwordClearText = password;
            _hideServerList = hideServerList;
            _selectedWebServiceURL = preferredWebServiceURL;
            try
            {
                _GRINGlobalWebServices = new WebServices(_selectedWebServiceURL, _userName, SharedUtils.SHA1EncryptionBase64(_passwordClearText), _passwordClearText, _userSite);
            }
            catch
            {
            }

            // First make sure the user's CT app data directory exists (and if not create it) just in case the CT was not installed under their name...
            if (!System.IO.Directory.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\"))
            {
                System.IO.Directory.CreateDirectory(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\");
            }
            if (!System.IO.Directory.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool\"))
            {
                System.IO.Directory.CreateDirectory(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool\");
            }

            if (!string.IsNullOrEmpty(webServiceHostsfileFullPath))
            {
                if (System.IO.File.Exists(webServiceHostsfileFullPath))
                {
                    _webServiceURLs = LoadWebServiceURLs(webServiceHostsfileFullPath);
                }
                else
                {
                    _webServiceURLs = new Dictionary<string, string>();
                    _webServiceURLs.Add("localhost", "http://localhost/GRINGlobal/GUI.asmx");
                }
            }
            else
            {
                // Now check to see if the WebServiceURL.txt file is there...
                if (System.IO.File.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool\WebServiceURL.txt"))
                {
                    _webServiceURLs = LoadWebServiceURLs(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool\WebServiceURL.txt");
                }
                // and if not look in the All Users app directory (built during installation)...
                else if (System.IO.File.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\GRIN-Global\Curator Tool\WebServiceURL.txt"))
                {
                    System.IO.File.Copy(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\GRIN-Global\Curator Tool\WebServiceURL.txt",
                                        System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool\WebServiceURL.txt", true);
                    _webServiceURLs = LoadWebServiceURLs(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool\WebServiceURL.txt");
                }
                // and if all else fails make one on the fly...
                else
                {
                    _webServiceURLs = new Dictionary<string, string>();
                    _webServiceURLs.Add("localhost", "http://localhost/GRINGlobal/GUI.asmx");
                }
            }
        }
コード例 #3
0
ファイル: AppSettings.cs プロジェクト: egacheru/G2
 public AppSettings(WebServices webServices, int lang, string appName)
 {
     _appResources = new DataTable();
     _webServices = webServices;
     if (lang != null) _lang = lang;
     if (!string.IsNullOrEmpty(appName)) _appName = appName;
     Load();
 }
コード例 #4
0
ファイル: UserSettings.cs プロジェクト: egacheru/G2
 public UserSettings(WebServices webServices, string cno, string app)
 {
     _userSettings = new DataTable();
     _webServices = webServices;
     _cno = cno;
     _app = app;
     Load();
 }
コード例 #5
0
ファイル: LookupTables.cs プロジェクト: egacheru/G2
        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");
        }
コード例 #6
0
ファイル: DataviewTabProperties.cs プロジェクト: egacheru/G2
        //public DataviewTabProperties(SharedUtils sharedUtils, DataviewProperties dataviewProperties, FormsData[] formsList)
        public DataviewTabProperties(WebServices webServices, DataviewProperties dataviewProperties)
        {
            InitializeComponent();

            // Create a SharedUtils object...
            SharedUtils sharedUtils = new SharedUtils(webServices.Url, webServices.Username, webServices.Password_ClearText, true);

            // Get the list of dataviews...
            DataSet _dataviewData = sharedUtils.GetWebServiceData("get_dataview_list", "", 0, 0);
            // Populate the combobox with the list of available dataviews...
            if (_dataviewData.Tables.Contains("get_dataview_list"))
            {
                _dataviewList = _dataviewData.Tables["get_dataview_list"].Copy();
                _dataviewList.Columns.Add("display_member", typeof(string));
                _dataviewList.Columns.Add("category_name", typeof(string));
                _dataviewList.Columns.Add("database_area", typeof(string));
                foreach (DataRow dr in _dataviewList.Rows)
                {
                    string friendlyName = "";
                    if (dr.Table.Columns.Contains("title")) friendlyName += dr["title"].ToString().Trim();
                    dr["display_member"] = friendlyName;
                    if (!string.IsNullOrEmpty(dr["category_code"].ToString()))
                    {
                        dr["category_name"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["category_code"].ToString(), dr.Table.Columns["category_code"].ExtendedProperties["group_name"].ToString(), dr["category_code"].ToString());
                    }
                    else
                    {
                        dr["category_name"] = "";
                    }

                    if (!string.IsNullOrEmpty(dr["database_area_code"].ToString()))
                    {
                        dr["database_area"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["database_area_code"].ToString(), dr.Table.Columns["database_area_code"].ExtendedProperties["group_name"].ToString(), dr["database_area_code"].ToString());
                    }
                    else
                    {
                        dr["database_area"] = "";
                    }
                }
                // Build the distinct list of categories and bind it to the combobox...
                _category = _dataviewList.DefaultView.ToTable(true, new string[] { "category_name" });
                _category.DefaultView.Sort = "category_name asc";
                ux_comboboxDataviewCategory.DisplayMember = "category_name";
                ux_comboboxDataviewCategory.ValueMember = "category_name";
                ux_comboboxDataviewCategory.DataSource = _category;

                // Bind the list to the dropdown combobox...
                if (_dataviewList.Columns.Contains("display_member")) _dataviewList.DefaultView.Sort = "display_member asc";
                ux_comboboxDataviews.DisplayMember = "display_member";
                ux_comboboxDataviews.ValueMember = "dataview_name";
                ux_comboboxDataviews.DataSource = _dataviewList;
            }
            else
            {
                // Did not return the dataview list - bail out now...
                return;
            }

            // Get the dataview record that matches what is in the dataviewProperties.dataviewname property (there should only be one with this name)...
            DataRow[] currentDataviewRows = _dataviewList.Select("is_enabled='Y' AND dataview_name='" + dataviewProperties.DataviewName + "'");
            DataRow currentDataviewRow = null;
            if (currentDataviewRows.Length > 0) currentDataviewRow = currentDataviewRows[0];

            // Build the list of compatible forms and bind it to the combobox...
            FormsData[] formsDataList = sharedUtils.GetDataviewFormsData();

            if (formsDataList != null &&
                formsDataList.Length > 0)
            {
                _formsList.Columns.Add("DisplayMember", typeof(string));
                _formsList.Columns.Add("ValueMember", typeof(string));
                _formsList.Columns.Add("PreferredDataviewName", typeof(string));
                //_formsList.PrimaryKey = new DataColumn[] { _formsList.Columns["ValueMember"] };
                foreach (FormsData fd in formsDataList)
                {
                    if (!string.IsNullOrEmpty(fd.PreferredDataviewName))
                    {
                        string[] preferredDataviews = fd.PreferredDataviewName.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string preferredDataview in preferredDataviews)
                        {
                            if (fd.ConstInfo != null &&
                                !string.IsNullOrEmpty(fd.StrongFormName))
                            {
                                DataRow newRow = _formsList.NewRow();
                                newRow["DisplayMember"] = fd.FormName + "   (" + fd.ConstInfo.Module.Name + ")";
                                newRow["ValueMember"] = fd.StrongFormName;
                                newRow["PreferredDataviewName"] = preferredDataview.Trim().ToLower();
                                _formsList.Rows.Add(newRow);
                            }
                        }
                    }
                }
            }
            // Set the tab properties to the values passed into the dialog...
            this.TabProperties = dataviewProperties;

            // Populate the controls with the currently chosen dataview (if this is not a brand new dataview)...
            // (order matters here - first choose category, then DB area, and finally dataview)
            // STEP 1 - Catetory
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviewCategory.SelectedValue = currentDataviewRow["category_name"].ToString();
            }
            // STEP 2 - Database Area
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDatabaseArea.SelectedValue = currentDataviewRow["database_area"].ToString();
            }
            // STEP 3 - Dataview
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviews.SelectedValue = currentDataviewRow["dataview_name"].ToString();
            }

            // Disable the OK button and the radio buttons for forms viewer (by default)...
            if (ux_comboboxDataviews.SelectedValue == null)
            {
                ux_buttonOK.Enabled = false;
                ux_radiobuttonFormStyle.Enabled = false;
                ux_radiobuttonBothStyle.Enabled = false;
                ux_comboboxForm.Enabled = false;
                ux_checkboxAlwayOnTop.Enabled = false;
                ux_checkboxAlwayOnTop.Hide();
            }
            sharedUtils.UpdateControls(this.Controls, this.Name);
        }
コード例 #7
0
ファイル: UserInterfaceUtils.cs プロジェクト: egacheru/G2
 public UserInterfaceUtils(WebServices webServices)
 {
     _webServices = webServices;
 }
コード例 #8
0
ファイル: SharedUtils.cs プロジェクト: egacheru/G2
        /*
        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);
            }
        }
コード例 #9
0
ファイル: SharedUtils.cs プロジェクト: egacheru/G2
        private bool TestCredentials(string webServiceURL, string webServiceUsername, string webServicePassword)
        {
            bool validLoginCredentials = false;

            // Bail out now if the URL or username are empty strings...
            if (string.IsNullOrEmpty(webServiceURL) || string.IsNullOrEmpty(webServiceUsername)) return validLoginCredentials;

            try
            {
                _webServices = new WebServices(webServiceURL, webServiceUsername, SHA1EncryptionBase64(webServicePassword), webServicePassword, _userSite);
                DataSet userData = _webServices.ValidateLogin();
                if (userData != null &&
                    userData.Tables.Contains("validate_login") &&
                    userData.Tables["validate_login"].Rows.Count > 0)
                {
                    // Successful login...
                    validLoginCredentials = true;
                    if (userData.Tables["validate_login"].Columns.Contains("cooperator_id")) _userCooperatorID = userData.Tables["validate_login"].Rows[0]["cooperator_id"].ToString();
                    if (userData.Tables["validate_login"].Columns.Contains("site_code")) _userSite = userData.Tables["validate_login"].Rows[0]["site_code"].ToString();
                    if (userData.Tables["validate_login"].Columns.Contains("site")) _userSite = userData.Tables["validate_login"].Rows[0]["site"].ToString();
                    string langString = "0";
                    if (userData.Tables["validate_login"].Columns.Contains("sec_lang_id")) langString = userData.Tables["validate_login"].Rows[0]["sec_lang_id"].ToString();
                    if (userData.Tables["validate_login"].Columns.Contains("sys_lang_id")) langString = userData.Tables["validate_login"].Rows[0]["sys_lang_id"].ToString();
                    int langInt = 0;
                    if (int.TryParse(langString, out langInt)) _userLanguageCode = langInt;
                }
            }
            catch
            {
                // Unsuccessful login...
                validLoginCredentials = false;
            }
            return validLoginCredentials;
        }
コード例 #10
0
ファイル: SharedUtils.cs プロジェクト: egacheru/G2
        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);
            }
        }
コード例 #11
0
        //public DataviewTabProperties(SharedUtils sharedUtils, DataviewProperties dataviewProperties, FormsData[] formsList)
        public DataviewTabProperties(WebServices webServices, DataviewProperties dataviewProperties)
        {
            InitializeComponent();

            // Create a SharedUtils object...
            SharedUtils sharedUtils = new SharedUtils(webServices.Url, webServices.Username, webServices.Password_ClearText, true);

            // Get the list of dataviews...
            DataSet _dataviewData = sharedUtils.GetWebServiceData("get_dataview_list", "", 0, 0);

            // Populate the combobox with the list of available dataviews...
            if (_dataviewData.Tables.Contains("get_dataview_list"))
            {
                _dataviewList = _dataviewData.Tables["get_dataview_list"].Copy();
                _dataviewList.Columns.Add("display_member", typeof(string));
                _dataviewList.Columns.Add("category_name", typeof(string));
                _dataviewList.Columns.Add("database_area", typeof(string));
                foreach (DataRow dr in _dataviewList.Rows)
                {
                    string friendlyName = "";
                    if (dr.Table.Columns.Contains("title"))
                    {
                        friendlyName += dr["title"].ToString().Trim();
                    }
                    dr["display_member"] = friendlyName;
                    if (!string.IsNullOrEmpty(dr["category_code"].ToString()))
                    {
                        dr["category_name"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["category_code"].ToString(), dr.Table.Columns["category_code"].ExtendedProperties["group_name"].ToString(), dr["category_code"].ToString());
                    }
                    else
                    {
                        dr["category_name"] = "";
                    }

                    if (!string.IsNullOrEmpty(dr["database_area_code"].ToString()))
                    {
                        dr["database_area"] = sharedUtils.GetLookupDisplayMember("code_value_lookup", dr["database_area_code"].ToString(), dr.Table.Columns["database_area_code"].ExtendedProperties["group_name"].ToString(), dr["database_area_code"].ToString());
                    }
                    else
                    {
                        dr["database_area"] = "";
                    }
                }
                // Build the distinct list of categories and bind it to the combobox...
                _category = _dataviewList.DefaultView.ToTable(true, new string[] { "category_name" });
                _category.DefaultView.Sort = "category_name asc";
                ux_comboboxDataviewCategory.DisplayMember = "category_name";
                ux_comboboxDataviewCategory.ValueMember   = "category_name";
                ux_comboboxDataviewCategory.DataSource    = _category;

                // Bind the list to the dropdown combobox...
                if (_dataviewList.Columns.Contains("display_member"))
                {
                    _dataviewList.DefaultView.Sort = "display_member asc";
                }
                ux_comboboxDataviews.DisplayMember = "display_member";
                ux_comboboxDataviews.ValueMember   = "dataview_name";
                ux_comboboxDataviews.DataSource    = _dataviewList;
            }
            else
            {
                // Did not return the dataview list - bail out now...
                return;
            }

            // Get the dataview record that matches what is in the dataviewProperties.dataviewname property (there should only be one with this name)...
            DataRow[] currentDataviewRows = _dataviewList.Select("is_enabled='Y' AND dataview_name='" + dataviewProperties.DataviewName + "'");
            DataRow   currentDataviewRow  = null;

            if (currentDataviewRows.Length > 0)
            {
                currentDataviewRow = currentDataviewRows[0];
            }

            // Build the list of compatible forms and bind it to the combobox...
            FormsData[] formsDataList = sharedUtils.GetDataviewFormsData();

            if (formsDataList != null &&
                formsDataList.Length > 0)
            {
                _formsList.Columns.Add("DisplayMember", typeof(string));
                _formsList.Columns.Add("ValueMember", typeof(string));
                _formsList.Columns.Add("PreferredDataviewName", typeof(string));
                //_formsList.PrimaryKey = new DataColumn[] { _formsList.Columns["ValueMember"] };
                foreach (FormsData fd in formsDataList)
                {
                    if (!string.IsNullOrEmpty(fd.PreferredDataviewName))
                    {
                        string[] preferredDataviews = fd.PreferredDataviewName.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string preferredDataview in preferredDataviews)
                        {
                            if (fd.ConstInfo != null &&
                                !string.IsNullOrEmpty(fd.StrongFormName))
                            {
                                DataRow newRow = _formsList.NewRow();
                                newRow["DisplayMember"]         = fd.FormName + "   (" + fd.ConstInfo.Module.Name + ")";
                                newRow["ValueMember"]           = fd.StrongFormName;
                                newRow["PreferredDataviewName"] = preferredDataview.Trim().ToLower();
                                _formsList.Rows.Add(newRow);
                            }
                        }
                    }
                }
            }
            // Set the tab properties to the values passed into the dialog...
            this.TabProperties = dataviewProperties;

            // Populate the controls with the currently chosen dataview (if this is not a brand new dataview)...
            // (order matters here - first choose category, then DB area, and finally dataview)
            // STEP 1 - Catetory
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviewCategory.SelectedValue = currentDataviewRow["category_name"].ToString();
            }
            // STEP 2 - Database Area
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDatabaseArea.SelectedValue = currentDataviewRow["database_area"].ToString();
            }
            // STEP 3 - Dataview
            if (currentDataviewRow != null &&
                ux_comboboxDataviewCategory.Items.Count > 0)
            {
                ux_comboboxDataviews.SelectedValue = currentDataviewRow["dataview_name"].ToString();
            }

            // Disable the OK button and the radio buttons for forms viewer (by default)...
            if (ux_comboboxDataviews.SelectedValue == null)
            {
                ux_buttonOK.Enabled             = false;
                ux_radiobuttonFormStyle.Enabled = false;
                ux_radiobuttonBothStyle.Enabled = false;
                ux_comboboxForm.Enabled         = false;
                ux_checkboxAlwayOnTop.Enabled   = false;
                ux_checkboxAlwayOnTop.Hide();
            }
            sharedUtils.UpdateControls(this.Controls, this.Name);
        }
コード例 #12
0
        private void ux_buttonOk_Click(object sender, EventArgs e)
        {
            try
            {
                _webServices = new WebServices(_webServiceURL, ux_textboxUsername.Text, SharedUtils.SHA1EncryptionBase64(ux_textboxCurrentPassword.Text), ux_textboxCurrentPassword.Text, _site);
                DataSet userData = _webServices.ValidateLogin();
                if (userData != null &&
                    userData.Tables.Contains("validate_login") &&
                    userData.Tables["validate_login"].Rows.Count > 0)
                {
                    DataSet newPasswordResults = _webServices.ChangePassword(SharedUtils.SHA1EncryptionBase64(ux_textboxNewPassword.Text));
                    if (newPasswordResults != null &&
                        newPasswordResults.Tables.Contains("ExceptionTable") &&
                        newPasswordResults.Tables["ExceptionTable"].Rows.Count == 0)
                    {
                        _password         = ux_textboxNewPassword.Text;
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else if (newPasswordResults != null &&
                             newPasswordResults.Tables.Contains("ExceptionTable") &&
                             newPasswordResults.Tables["ExceptionTable"].Rows.Count > 0)
                    {
//MessageBox.Show("There was an unexpected error changing your password.\n\nFull error message:\n" + newPasswordResults.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
                        GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error changing your password.\n\nFull error message:\n{0}", "Change Password Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                        ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage1";
                        if (_sharedUtils != null)
                        {
                            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                        }
                        if (ggMessageBox.MessageText.Contains("{0}"))
                        {
                            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, newPasswordResults.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
                        }
                        ggMessageBox.ShowDialog();
                    }
                    else
                    {
//MessageBox.Show("There was an unexpected error changing your password.");
                        GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error changing your password.", "Change Password Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                        ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage2";
                        if (_sharedUtils != null)
                        {
                            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                        }
                        ggMessageBox.ShowDialog();
                    }
                }
                else
                {
//MessageBox.Show("Error: The Username/Password are not valid for server:\n\n" + _webServiceURL + "\n\nPlease correct and try again.");
                    GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error: The Username/Password are not valid for server:\n\n{0}\n\nPlease correct and try again.", "Invalid Username or Password", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                    ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage3";
                    if (_sharedUtils != null)
                    {
                        _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                    }
                    if (ggMessageBox.MessageText.Contains("{0}"))
                    {
                        ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _webServiceURL);
                    }
                    ggMessageBox.ShowDialog();
                }
            }
            catch
            {
//MessageBox.Show("Error connecting to server: " + _webServiceURL);
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error connecting to server: {0}", "Server Connection Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "ChangePassword_ux_buttonOKMessage4";
                if (_sharedUtils != null)
                {
                    _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                }
                if (ggMessageBox.MessageText.Contains("{0}"))
                {
                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _webServiceURL);
                }
                ggMessageBox.ShowDialog();
            }
        }