예제 #1
0
        private void DisplayDatabases(PFSConnectModel model)
        {
            try
            {
                this.databaseList.DisplayMember = "DisplayName";

                this.databaseList.DataSource = model.Databases.GetList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        PFSConnectModel ParseIniContent()
        {
            PFSConnectModel model = new PFSConnectModel();

            bool isDefaultDatabase = true;
            string line = string.Empty;
            string dbModelDataSource = string.Empty;
            string dbModelCatalog = string.Empty;
            string dbModelUserId = string.Empty;
            string dbModelPassword = string.Empty;

            using (System.IO.StringReader contentReader = new System.IO.StringReader(iniFileContent))
            {
                while ((line = contentReader.ReadLine()) != null)
                {
                    if (!String.IsNullOrEmpty(line))
                    {

                        if (line.ToUpper().Contains("DATASOURCE") | (line.ToUpper().Contains("CATALOG")) | line.ToUpper().Contains("USERID") | (line.ToUpper().Contains("PASSWORD")))
                        {
                            isDefaultDatabase = (
                                !(
                                    (line.ToUpper().StartsWith("#DATASOURCE")) |
                                    (line.ToUpper().StartsWith("#CATALOG")) |
                                    (line.ToUpper().StartsWith("#USERID")) |
                                    (line.ToUpper().StartsWith("#PASSWORD"))
                                ));

                            if (line.StartsWith("#"))
                            {
                                line = line.TrimStart('#');
                            }

                            string[] keyValue = line.Split('=');

                            if (keyValue[KEY].ToUpper() == "DATASOURCE")
                            {
                                dbModelDataSource = keyValue[VALUE];
                            }
                            else if (keyValue[KEY].ToUpper() == "CATALOG")
                            {
                                dbModelCatalog = keyValue[VALUE];
                            }
                            else if (keyValue[KEY].ToUpper() == "USERID")
                            {
                                dbModelUserId = keyValue[VALUE];
                            }
                            else if (keyValue[KEY].ToUpper() == "PASSWORD")
                            {
                                dbModelPassword = keyValue[VALUE];
                            }

                            if ((!String.IsNullOrEmpty(dbModelDataSource)) && (!String.IsNullOrEmpty(dbModelCatalog)) && (!String.IsNullOrEmpty(dbModelUserId)) && (!String.IsNullOrEmpty(dbModelPassword)))
                            {
                                model.Databases.Add(new DatabaseModel(dbModelDataSource, dbModelCatalog, dbModelUserId, dbModelPassword, isDefaultDatabase));
                                dbModelDataSource = string.Empty;
                                dbModelCatalog = string.Empty;
                                isDefaultDatabase = true;
                            }
                        }
                        else
                        {
                            if (!line.StartsWith("#") && !line.StartsWith("[") && !String.IsNullOrEmpty(line))
                            {
                                string[] keyValue = line.Split('=');

                                PropertyInfo propertyInfo = model.GetType().GetProperty(keyValue[KEY].ToUpper());

                                propertyInfo.SetValue(model, Convert.ChangeType(keyValue[VALUE], propertyInfo.PropertyType), null);

                            }
                        }
                    }
                }
            }

            return model;
        }
예제 #3
0
 public IniWriter(PFSConnectModel model)
 {
     IniModel = model;
 }
예제 #4
0
        private void ReadIniFile()
        {
            loading = true;

            string content = System.IO.File.ReadAllText(iniFileNameTextBox.Text);

            model = PFSConnectModel.GetPFSConnectModel(content);

            DisplayDatabases(model);

            pFSConnectModelBindingSource.DataSource = model;

            databaseList.SelectedItem = model.DefaultDatabase;

            loading = false;
        }
        void PopulateDatabaseSelectionControl(PFSConnectModel model)
        {
            loading = true;

            this.databaseList.DisplayMember = "DisplayName";

            this.databaseList.DataSource = model.Databases.GetList();

            loading = false;

            this.databaseList.SelectedItem = model.Databases.DefaultDatabase;
        }
        void GetPFSConnectModel()
        {
            string content = File.ReadAllText(PFSConnectLibrary.Common.DEFAULT_FILE_PATH);

            model = PFSConnectModel.GetPFSConnectModel(content);
        }