Пример #1
0
        private void GrinGlobalClient_Load(object sender, EventArgs e)
        {
            bool validLogin = false;
            //            bool connectedToWebService = false;
            //            int selectedCNOIndex = -1;
            //string selectedNodeFullPath = "";
            //username = "";
            //password = "";
            _usernameCooperatorID = "";// "117534";
            _currentCooperatorID = "";// "117534";
            site = "";// "NC7";
            languageCode = "";
            lastFullPath = "";
            lastTabName = "";
            commonUserApplicationDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\GRIN-Global\Curator Tool";
            roamingUserApplicationDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool";
            userSettingsXMLFilePath = roamingUserApplicationDataPath + @"\UserSettings_v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.Build.ToString() + ".xml";

            // Wireup the binding navigator and the Main datagridview...
            // NOTE:(right now the binding source is empty - but later on it will get bound to a data table)...
            defaultBindingSource = new BindingSource();
            defaultBindingSource.DataSource = new DataTable();
            ux_bindingnavigatorMain.BindingSource = defaultBindingSource;
            ux_datagridviewMain.DataSource = defaultBindingSource;

            //// Load the images for the tree view(s)...
            //navigatorTreeViewImages.ColorDepth = ColorDepth.Depth32Bit;
            //navigatorTreeViewImages.Images.Add("active_folder", Icon.ExtractAssociatedIcon(@"Images\active_Folder.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_folder", Icon.ExtractAssociatedIcon(@"Images\inactive_Folder.ico"));
            //navigatorTreeViewImages.Images.Add("active_INVENTORY_ID", Icon.ExtractAssociatedIcon(@"Images\active_INVENTORY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_INVENTORY_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_INVENTORY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_ACCESSION_ID", Icon.ExtractAssociatedIcon(@"Images\active_ACCESSION_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_ACCESSION_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_ACCESSION_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_ORDER_REQUEST_ID", Icon.ExtractAssociatedIcon(@"Images\active_ORDER_REQUEST_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_ORDER_REQUEST_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_ORDER_REQUEST_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_COOPERATOR_ID", Icon.ExtractAssociatedIcon(@"Images\active_COOPERATOR_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_COOPERATOR_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_COOPERATOR_ID.ico"));

            //navigatorTreeViewImages.Images.Add("active_GEOGRAPHY_ID", Icon.ExtractAssociatedIcon(@"Images\active_GEOGRAPHY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_GEOGRAPHY_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_GEOGRAPHY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_TAXONOMY_GENUS_ID", Icon.ExtractAssociatedIcon(@"Images\active_TAXONOMY_GENUS_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_TAXONOMY_GENUS_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_TAXONOMY_GENUS_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_CROP_ID", Icon.ExtractAssociatedIcon(@"Images\active_CROP_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_CROP_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_CROP_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_CROP_TRAIT_ID", Icon.ExtractAssociatedIcon(@"Images\active_CROP_TRAIT_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_CROP_TRAIT_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_CROP_TRAIT_ID.ico"));

            //navigatorTreeViewImages.Images.Add("new_tab", Icon.ExtractAssociatedIcon(@"Images\GG_newtab.ico"));
            //navigatorTreeViewImages.Images.Add("search", Icon.ExtractAssociatedIcon(@"Images\GG_search.ico"));

            try
            {
                // Load the wizards from the same directory (and all subdirectories) where the Curator Tool was launched...
                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
                System.IO.FileInfo[] dllFiles = di.GetFiles("Wizards\\*.dll", System.IO.SearchOption.AllDirectories);
                if (dllFiles != null && dllFiles.Length > 0)
                {
                    for (int i = 0; i < dllFiles.Length; i++)
                    {
                        System.Reflection.Assembly newAssembly = System.Reflection.Assembly.LoadFile(dllFiles[i].FullName);
                        foreach (System.Type t in newAssembly.GetTypes())
                        {
                            if (t.GetInterface("IGRINGlobalDataWizard", true) != null)
                            {
                                System.Reflection.ConstructorInfo constInfo = t.GetConstructor(new Type[] { typeof(string), typeof(SharedUtils) });

                                if (constInfo != null)
                                {
                                    string pkeyCollection = ":accessionid=; :inventoryid=; :orderrequestid=; :cooperatorid=; :geographyid=; :taxonomygenusid=; :cropid=";
                                    // Instantiate an object of this type to load...
                                    Form wizardForm = (Form)constInfo.Invoke(new object[] { pkeyCollection, _sharedUtils });
                                    // Get the Form Name and button with this name...
                                    System.Reflection.PropertyInfo propInfo = t.GetProperty("FormName", typeof(string));
                                    string formName = (string)propInfo.GetValue(wizardForm, null);
                                    if (string.IsNullOrEmpty(formName)) formName = t.Name;
                                    ToolStripButton tsbWizard = new ToolStripButton(formName, Icon.ExtractAssociatedIcon(newAssembly.ManifestModule.FullyQualifiedName).ToBitmap(), ux_buttonWizard_Click, "toolStripButton" + newAssembly.ManifestModule.Name);
                                    tsbWizard.Tag = "Wizards\\" + newAssembly.ManifestModule.Name;
                                    toolStrip1.Items.Add(tsbWizard);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception err)
            {
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error binding to Wizard Form.\nError Message: {0}", "Wizard Binding Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GrinGlobalClient_LoadMessage2";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message);
            ggMessageBox.ShowDialog();
            }

            // Create the middle tier utilities class and connect to the web services...
            _sharedUtils = new SharedUtils(url, username, passwordClearText, false);

            // Display the splash page to let the user know that things are happening...
            Splash splash = new Splash();
            splash.StartPosition = FormStartPosition.CenterScreen;
            splash.Show();
            splash.Update();

            //if (validLogin)
            if (_sharedUtils.IsConnected)
            {
                localDBInstance = _sharedUtils.Url.ToLower().Replace("http://", "").Replace("/gringlobal/gui.asmx", "").Replace('-', '_').Replace('.', '_').Replace(':', '_');
                localDBInstance = "GRINGlobal_" + localDBInstance;
            //_sharedUtils = new SharedUtils(GRINGlobalWebServices.Url, username, password, localDBInstance, cno);
                username = _sharedUtils.Username;
                password = _sharedUtils.Password;
                passwordClearText = _sharedUtils.Password_ClearText;
                url = _sharedUtils.Url;
                _usernameCooperatorID = _sharedUtils.UserCooperatorID;
            //_currentCooperatorID = _sharedUtils.UserCooperatorID;
                site = _sharedUtils.UserSite;
                languageCode = _sharedUtils.UserLanguageCode.ToString();

                // Load the application data...
                LoadApplicationData();

            // Check the status of lookup tables and warn the user if some tables are missing data...
            LookupTableStatusCheck();

                // Wire up the list of valid GG servers to the combobox...
                ux_comboboxActiveWebService.DataSource = new BindingSource(_sharedUtils.WebServiceURLs, null);
                ux_comboboxActiveWebService.DisplayMember = "Key";
                ux_comboboxActiveWebService.ValueMember = "Value";
                ux_comboboxActiveWebService.SelectedValue = _sharedUtils.Url;
            // Indicate to the user which URL is the active GG server...
            if (ux_statusCenterMessage.Tag != null)
            {
            if (ux_statusCenterMessage.Tag.ToString().Contains("{0}"))
            {
            ux_statusCenterMessage.Text = string.Format(ux_statusCenterMessage.Tag.ToString(), _sharedUtils.Url);
            }
            else
            {
            ux_statusCenterMessage.Text = ux_statusCenterMessage.Tag.ToString() + " (" + _sharedUtils.Url + ")";
            }
            }
            else
            {
            ux_statusCenterMessage.Text = ux_statusCenterMessage.Text + " (" + _sharedUtils.Url + ")";
            }

            // Get the list of Dataview Forms embedded in assemblies in the CT Forms directiory...
            localFormsAssemblies = _sharedUtils.GetDataviewFormsData();

                // Save the list of valid web service urls...
                // But first make sure the roaming profile directory exists...
                if (!System.IO.Directory.Exists(roamingUserApplicationDataPath)) System.IO.Directory.CreateDirectory(roamingUserApplicationDataPath);
                // Now save the list of GRIN-Global servers...
                System.IO.StreamWriter sw = new System.IO.StreamWriter(roamingUserApplicationDataPath + @"\WebServiceURL.txt");
                foreach (KeyValuePair<string, string> kv in ux_comboboxActiveWebService.Items)
                {
                    if (kv.Key != "New...")
                    {
                        sw.WriteLine(kv.Key + "\t" + kv.Value);
                    }
                }
                sw.Close();
                sw.Dispose();

                // Load the cursors for the DGV...
                _cursorGG = _sharedUtils.LoadCursor(@"Images\cursor_GG.cur");
                if (_cursorGG == null) _cursorGG = Cursors.Default;
                _cursorLUT = _sharedUtils.LoadCursor(@"Images\cursor_LUT.cur");
                if (_cursorLUT == null) _cursorLUT = Cursors.Default;
                _cursorREQ = _sharedUtils.LoadCursor(@"Images\cursor_REQ.cur");
                if (_cursorREQ == null) _cursorREQ = Cursors.Default;
            //this.Cursor = _cursorGG;
            ux_datagridviewMain.Cursor = _cursorGG;
            }
            else
            {
                // Login aborted - disable controls...
                ux_tabcontrolDataviewOptions.Enabled = false;
                ux_tabcontrolCTDataviews.Enabled = false;
                ux_datagridviewMain.Enabled = false;
                ux_comboboxCNO.Enabled = false;
                ux_buttonEditData.Enabled = false;
                // Close the application???
                this.Close();
            }

            // Close the splash page...
            splash.Close();
        }
Пример #2
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);
        }
        //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);
        }