public InfoBase GetMetadata(string ProgID, SQLConnectionDialogNotification settings, string tempDirectory)
        {
            Type    comType          = Type.GetTypeFromProgID(ProgID, true); // V83.COMConnector
            dynamic connector        = Activator.CreateInstance(comType);
            string  connectionString = GetConnectionString(settings);
            dynamic session          = connector.Connect(connectionString);

            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ConfigurationWriter.epf");
            string temp = Path.Combine(tempDirectory, "ConfigurationWriter.epf");

            File.Copy(path, temp, true);
            dynamic processor = session.ExternalDataProcessors.Create(temp);
            string  output    = Path.Combine(tempDirectory, "configuration.xml");

            processor.Write(output);
            File.Delete(temp);

            Marshal.ReleaseComObject(processor); processor = null;
            Marshal.ReleaseComObject(session); session     = null;
            Marshal.ReleaseComObject(connector); connector = null;

            InfoBase infoBase = new InfoBase();

            this.Load(output, infoBase);
            File.Delete(output);
            return(infoBase);
        }
Example #2
0
        private void AddMetadata()
        {
            SQLConnectionDialogNotification appInfo = GetConnectionInfo();

            if (appInfo == null)
            {
                return;
            }
            SQLConnectionDialogNotification sqlInfo = GetConnectionInfo();

            if (sqlInfo == null)
            {
                return;
            }
            string temp = GetCatalogPath();

            if (string.IsNullOrEmpty(temp))
            {
                return;
            }

            XMLMetadataAdapter adapter  = new XMLMetadataAdapter();
            string             progID   = "V83.COMConnector";
            InfoBase           infoBase = adapter.GetMetadata(progID, appInfo, temp);

            ImportSQLMetadata(infoBase, sqlInfo);

            MetadataTreeViewModel.InfoBases.Add(infoBase);

            MetadataService service = new MetadataService();

            service.Save(infoBase);
            infoBase.OnPropertyChanged("State");
        }
Example #3
0
        private bool OpenSQLConnectionPopup(InfoBase infoBase)
        {
            bool cancel = false;
            SQLConnectionDialogNotification notification = new SQLConnectionDialogNotification()
            {
                Title    = CONST_ModuleDialogsTitle,
                Server   = infoBase.Server,
                Database = infoBase.Database,
                UserName = "",
                Password = ""
            };

            this.SQLConnectionPopupRequest.Raise(notification, response =>
            {
                if (!response.Confirmed)
                {
                    cancel = true;
                }
                else
                {
                    this.ImportSQLMetadata(infoBase, response);
                }
            });
            return(cancel);
        }
 private string GetConnectionString(SQLConnectionDialogNotification settings)
 {
     return(string.Format("Srvr=\"{0}\";Ref=\"{1}\";Usr=\"{2}\";Pwd=\"{3}\";",
                          settings.Server,
                          settings.Database,
                          settings.UserName,
                          settings.Password));
 }
Example #5
0
        private void ImportSQLMetadata(InfoBase infoBase, SQLConnectionDialogNotification response)
        {
            SqlConnectionStringBuilder helper = new SqlConnectionStringBuilder()
            {
                DataSource         = response.Server,
                InitialCatalog     = response.Database,
                IntegratedSecurity = string.IsNullOrWhiteSpace(response.UserName)
            };

            if (!helper.IntegratedSecurity)
            {
                helper.UserID              = response.UserName;
                helper.Password            = response.Password;
                helper.PersistSecurityInfo = false;
            }
            infoBase.Server   = helper.DataSource;
            infoBase.Database = helper.InitialCatalog;
            infoBase.UserName = helper.UserID;
            infoBase.Password = helper.Password;
            (new SQLMetadataAdapter()).Load(helper.ToString(), infoBase);
        }
Example #6
0
        private SQLConnectionDialogNotification GetConnectionInfo()
        {
            SQLConnectionDialogNotification notification = new SQLConnectionDialogNotification()
            {
                Title    = CONST_ModuleDialogsTitle,
                Server   = "",
                Database = "",
                UserName = "",
                Password = ""
            };

            this.SQLConnectionPopupRequest.Raise(notification, response =>
            {
                if (response.Confirmed)
                {
                    notification = response;
                }
                else
                {
                    notification = null;
                }
            });
            return(notification);
        }