private void buttonSave_Click(object sender, EventArgs e)
        {
            if (comboBoxDatabases.SelectedIndex > -1)
            {
                this.Saved    = true;
                this.Provider = comboBoxProvider.Text;
                IDatabaseInterface sqlInterface = DatabaseInterfaceFactory.Factory(comboBoxProvider.SelectedItem.ToString());

                if (this.checkBoxWindowsAuth.Checked)
                {
                    this.ConnectionString = sqlInterface.CreateConnectionStringUsingWindowsAuthentication(textBoxInstance.Text, comboBoxDatabases.SelectedValue?.ToString());
                }
                else
                {
                    this.ConnectionString = sqlInterface.CreateConnectionString(textBoxInstance.Text, comboBoxDatabases.SelectedValue?.ToString(), textBoxUsername.Text, textBoxPassword.Text);
                }

                ConfigHelper.WriteAppSetting("DatabaseInstance", textBoxInstance.Text);
                ConfigHelper.WriteAppSetting("DatabaseUsername", textBoxUsername.Text);
                ConfigHelper.WriteAppSetting("DatabaseProvider", comboBoxProvider.SelectedItem?.ToString());
                this.Close();
            }
            else
            {
                SetUserMessage("Database not selected...", true);
            }
        }
Esempio n. 2
0
        public void WriteData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            this.reportProgress = reportProgress;

            reportProgress(new SimpleProgressReport("Connection to crm"));
            CrmConnection crmConnection = (CrmConnection)connection.GetConnection();

            this.service    = new OrganizationService(crmConnection);
            this.dataObject = dataObject;

            reportProgress(new SimpleProgressReport("Load required metadata from crm"));
            entity1Metadata      = Crm2013Wrapper.Crm2013Wrapper.GetEntityMetadata(this.service, this.Configuration.Entity1Name);
            entity2Metadata      = Crm2013Wrapper.Crm2013Wrapper.GetEntityMetadata(this.service, this.Configuration.Entity2Name.Split(';')[0]);
            relationshipMetadata = Crm2013Wrapper.Crm2013Wrapper.GetRelationshipMetadata(this.service, this.Configuration.Entity2Name.Split(';')[1]) as ManyToManyRelationshipMetadata;

            reportProgress(new SimpleProgressReport("Cache keys of existing " + entity1Metadata.LogicalName + "-records"));
            var entity1Resolver = new JoinResolver(this.service, entity1Metadata, this.Configuration.Entity1Mapping);

            this.existingEntities1 = entity1Resolver.BuildMassResolverIndex();

            reportProgress(new SimpleProgressReport("Cache keys of existing " + entity2Metadata.LogicalName + "-records"));
            var entity2Resolver = new JoinResolver(this.service, entity2Metadata, this.Configuration.Entity2Mapping);

            this.existingEntities2 = entity2Resolver.BuildMassResolverIndex();

            RelateEntities();
        }
        private async Task TestConnection()
        {
            progressSpinnerDefault.Visible = true;
            IDatabaseInterface sqlInterface = DatabaseInterfaceFactory.Factory(comboBoxProvider.SelectedItem.ToString());

            if (checkBoxWindowsAuth.Checked)
            {
                this.ConnectionString = sqlInterface.CreateConnectionStringUsingWindowsAuthentication(textBoxInstance.Text, comboBoxDatabases.SelectedValue?.ToString());
            }
            else
            {
                this.ConnectionString = sqlInterface.CreateConnectionString(textBoxInstance.Text, comboBoxDatabases.SelectedValue?.ToString(), textBoxUsername.Text, textBoxPassword.Text);
            }

            sqlInterface.SetConnectionString(this.ConnectionString);
            if (await sqlInterface.TestConnectionAsync())
            {
                this.SetUserMessage("Connected!", false);
                await LoadDatabases();
            }
            else
            {
                this.SetUserMessage("Unable to Connect...", true);
            }
            progressSpinnerDefault.Visible = false;
        }
Esempio n. 4
0
        private async void loadFromDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormConnectToDatabase connectToDatabase = new FormConnectToDatabase();

            connectToDatabase.LoadForm();
            connectToDatabase.ShowDialog();
            if (connectToDatabase.Saved)
            {
                this._userControlDBForgeEditor.displayUserMessageSuccess("Loading database schema...");
                this._userControlDBForgeEditor.showSpinner();
                IDatabaseInterface sqlInterface = DatabaseInterfaceFactory.Factory(connectToDatabase.Provider);
                sqlInterface.SetConnectionString(connectToDatabase.ConnectionString);
                DatabaseContainer databaseContainer = null;

                await Task.Run(() =>
                {
                    databaseContainer = sqlInterface.GetDatabaseStructure();
                });

                this._userControlDBForgeEditor.LoadProject(databaseContainer);
                this.ConnectionString = connectToDatabase.ConnectionString;
                this._userControlDBForgeEditor.displayUserMessageSuccess("Database schema loaded...");
                this._userControlDBForgeEditor.hideSpinner();
            }
        }
Esempio n. 5
0
        public void Execute(IConnection connection, IDatabaseInterface databaseInterface, ReportProgressMethod reportProgress)
        {
            reportProgress(new SimpleProgressReport("Yeah, we run our code now!"));

            reportProgress(new SimpleProgressReport("MyConfigValue is " + this.Configuration.MyConfigValue));
            // Your execution code goes here
        }
        public void WriteData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            this.reportProgress = reportProgress;

            reportProgress(new SimpleProgressReport("Connection to crm"));
            this.service    = connection.GetConnection() as IOrganizationService;
            this.dataObject = dataObject;

            reportProgress(new SimpleProgressReport("Load marketinglist metadata"));
            this.listEntityMetaData = Crm2013Wrapper.Crm2013Wrapper.GetEntityMetadata(service, "list");

            reportProgress(new SimpleProgressReport("Resolve existing marketinglists"));
            JoinResolver listResolver = new JoinResolver(this.service, listEntityMetaData, this.Configuration.ListMapping);

            this.existingLists = listResolver.BuildMassResolverIndex();

            reportProgress(new SimpleProgressReport("Load members metadata"));
            EntityMetadata memberEntityMetaData = Crm2013Wrapper.Crm2013Wrapper.GetEntityMetadata(service, this.Configuration.ListMemberType.ToString().ToLower());

            reportProgress(new SimpleProgressReport("Resolve listmembers"));
            JoinResolver memberResolver = new JoinResolver(this.service, memberEntityMetaData, this.Configuration.ListMemberMapping);

            this.existingMembers = memberResolver.BuildMassResolverIndex();

            switch (this.Configuration.JoinList)
            {
            case MarketinglistJoinType.Manual:
                DoManualMarketingList();
                break;

            case MarketinglistJoinType.Join:
                DoJoinMarketingLists();
                break;
            }
        }
Esempio n. 7
0
        public void TransformData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            Dictionary <StringTransformationType, Type> stringTransformationMapping = Helpers.LoadAllTransformationTypes();

            foreach (var transformation in this.Configuration.Transformations)
            {
                reportProgress(new SimpleProgressReport("Start stringtranformation of type " + transformation.TransformationType + " on column " + transformation.ColumnName));

                if (dataObject.Metadata.Columns.Values.Where(t => t.ColumnName == transformation.ColumnName).Count() == 0)
                {
                    throw new Exception("Column " + transformation.ColumnName + " was not found in the sourcedata");
                }

                int columnIndex = dataObject.Metadata.Columns[transformation.ColumnName].ColumnIndex;
                ITransformationExecutor transformer = Activator.CreateInstance(stringTransformationMapping[transformation.TransformationType]) as ITransformationExecutor;

                for (int i = 0; i < dataObject.Count; i++)
                {
                    string transformedValue = transformer.ExecuteTransformation(dataObject[i][columnIndex].ToString(), transformation);
                    dataObject.SetValue(i, columnIndex, transformedValue);
                }

                reportProgress(new SimpleProgressReport("Finished stringtranformation of type " + transformation.TransformationType + " on column " + transformation.ColumnName));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a tree
        /// </summary>
        /// <param name="data">Database interface</param>
        /// <returns>roots of trees</returns>
        static ILogDirectory[] CreateTree(this IDatabaseInterface data)
        {
            Dictionary <object, IParentSet> dictionary  = new Dictionary <object, IParentSet>();
            IEnumerable <object>            list        = data.Elements;
            List <ILogDirectory>            directories = new List <ILogDirectory>();

            foreach (object o in list)
            {
                ILogItem   item = data[o];
                IParentSet ps   = null;
                if (item is ILogInterval)
                {
                    ps = new LogIntervalWrapper(item as ILogInterval);
                }
                else if (item is ILogData)
                {
                    ps = new LogItemWrapper(item as ILogData);
                }
                else
                {
                    ps = new LogDirectoryWrapper(item);
                }
                dictionary[o] = ps;
            }
            foreach (IParentSet ps in dictionary.Values)
            {
                ILogItem it = (ps as ILogItem);
                object   o  = it.ParentId;
                if (!o.Equals(it.Id))
                {
                    if (dictionary.ContainsKey(o))
                    {
                        ps.Parent = dictionary[o] as ILogItem;
                    }
                }
                if (it is ILogInterval)
                {
                    ILogInterval interval = it as ILogInterval;
                    ILogData     d        = dictionary[interval.DataId] as ILogData;
                    (interval as LogIntervalWrapper).DataSet = d;
                }
            }
            List <ILogDirectory> l = new List <ILogDirectory>();

            foreach (IParentSet ps in dictionary.Values)
            {
                if (ps is ILogDirectory)
                {
                    ILogDirectory item = (ps as ILogDirectory);
                    if (item.Parent == null)
                    {
                        l.Add(item);
                    }
                }
            }
            return(l.ToArray());
        }
Esempio n. 9
0
 public void Dispose()
 {
     if (conn == null)
     {
         throw new ObjectDisposedException($"[{this.GetType().Name}] Service already disposed.");
     }
     conn.Dispose();
     conn = null;
 }
Esempio n. 10
0
        public void WriteData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            reportProgress(new SimpleProgressReport("Building logging database"));
            this.logger = new Logger(databaseInterface);
            this.logger.InitializeDatabase();

            reportProgress(new SimpleProgressReport("Connection to crm"));
            CrmConnection crmConnection = (CrmConnection)connection.GetConnection();

            this.service    = new OrganizationService(crmConnection);
            this.dataObject = dataObject;

            reportProgress(new SimpleProgressReport("Load " + this.Configuration.EntityName + " metadata"));
            this.entityMetaData = Crm2013Wrapper.Crm2013Wrapper.GetEntityMetadata(service, this.Configuration.EntityName);

            reportProgress(new SimpleProgressReport("Resolve existing entityrecords"));
            JoinResolver entityResolver = new JoinResolver(this.service, entityMetaData, this.Configuration.DeleteMapping);

            this.existingEntityRecords = entityResolver.BuildMassResolverIndex();

            for (int i = 0; i < this.dataObject.Count; i++)
            {
                string joinKey = JoinResolver.BuildExistingCheckKey(this.dataObject[i], this.Configuration.DeleteMapping, this.dataObject.Metadata);
                if (existingEntityRecords.ContainsKey(joinKey))
                {
                    var existingRecordIds = existingEntityRecords[joinKey];
                    if (existingRecordIds.Length == 1 || this.Configuration.MultipleFoundMode == DeleteInCrmMultipleFoundMode.DeleteAll)
                    {
                        string entityIds      = string.Empty;
                        string deletionFaults = string.Empty;

                        foreach (Guid entityId in existingRecordIds)
                        {
                            entityIds += entityId.ToString() + ",";
                            try
                            {
                                Crm2013Wrapper.Crm2013Wrapper.DeleteRecordInCrm(this.service, this.Configuration.EntityName, entityId);
                            }
                            catch (FaultException <OrganizationServiceFault> ex)
                            {
                                deletionFaults += ex.Detail.Message + "\n";
                            }
                        }
                        entityIds = entityIds.TrimEnd(',');
                        logger.AddRecord(i, joinKey, entityIds, deletionFaults);
                    }
                    else
                    {
                        // TODO Log that multiplerecords were found but none deleted
                    }
                }
                else
                {
                    // TODO Log that no record was found to delete
                }
            }
        }
Esempio n. 11
0
        /*
         * ILogItem SaveFile(string filename)
         * {
         *  IDatabaseInterface d = StaticExtensionEventLogDatabase.Data;
         *  string fn = Path.GetFileNameWithoutExtension(filename).ToLower();
         *  if (d.Filenames.Contains(fn))
         *  {
         *      MessageBox.Show("File already exists");
         *      return null;
         *  }
         *  using (Stream stream = File.OpenRead(filename))
         *  {
         *      ILogDirectory dir = selected.Tag as ILogDirectory;
         *      IEnumerable<byte[]> data = stream.ToObjectEnumerable().ToByteEnumerable();
         *      ILogItem it = dir.CreateData(data, fn, fn, "");
         *      DataGridViewRow row = new DataGridViewRow();
         *      ILogData ld = it as ILogData;
         *      row.Tag = it;
         *      row.CreateCells(dataGridViewFiles,
         *          new object[] { ld.Name, ld.Comment, ld.Length, ld.FileName });
         *      dataGridViewFiles.Rows.Add(row);
         *      return it;
         *  }
         * }
         */

        void Finish()
        {
            try
            {
                IDatabaseInterface d = StaticExtensionDataPerformerInterfaces.Data;
                d.SubmitChanges();
            }
            catch (Exception exception)
            {
                exception.ShowError();
            }
        }
Esempio n. 12
0
 void Finish()
 {
     try
     {
         IDatabaseInterface d = StaticExtensionEventLogDatabase.Data;
         d.SubmitChanges();
     }
     catch (Exception exception)
     {
         exception.ShowError();
     }
 }
        public void WriteData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            reportProgress(new SimpleProgressReport("Aquire database-connection"));
            IDatabaseTargetProvider msSqlTarget = new MsSqlTargetProvider(connection);

            DataStoreConverter dataStoreConverter = new DataStoreConverter(this.Configuration.TargetTable, dataObject.Metadata, this.Configuration.Mapping);

            reportProgress(new SimpleProgressReport("Write records to database"));

            DbTargetWriter dbTargetWriter = new DbTargetWriter(msSqlTarget, dataObject, dataStoreConverter, this.Configuration);

            dbTargetWriter.WriteDataToTarget();
        }
Esempio n. 14
0
        /// <summary>
        /// Creates data
        /// </summary>
        /// <param name="directory">Directory</param>
        /// <param name="data">Data</param>
        /// <param name="name"></param>
        /// <param name="fileName">File name</param>
        /// <param name="comment">Comment</param>
        /// <returns>The data</returns>
        public static ILogInterval CreateIntrerval(this ILogDirectory directory,
                                                   ILogData data, string name, string comment, uint begin, uint end)
        {
            IDatabaseInterface d = StaticExtensionEventLogDatabase.data;

            if (directory.GetDirectoryNames().Contains(name))
            {
                throw new Exception(name + " already exists");
            }
            ILogInterval interval = d.CreateInterval(directory.Id, name, comment, data, begin, end);

            return(new LogIntervalWrapper(directory as LogDirectoryWrapper, interval, data));
        }
Esempio n. 15
0
        public static void Release(IDatabaseInterface conn)
        {
            var container = thread_conns.Value;

            if (container != null && conn == container.conn)
            {
                container.subscribers--;
                if (container.subscribers == 0)
                {
                    thread_conns.Value = null;
                    ReleaseToStack(container);
                }
            }
        }
        public System.Windows.Controls.UserControl RenderLogWindow(IDatabaseInterface databaseInterface)
        {
            LogWindow logWindow = new LogWindow();

            LogSummary logSummary = Logger.LoadLogSummary(databaseInterface);

            logWindow.LogSummaryControl.SetModel(logSummary);

            Logger logger = new Logger(databaseInterface);
            ObservableCollection <RecordLog> recordLogs = logger.ReadPagedRecords(1);

            logWindow.RecordLogListControl.SetModel(recordLogs);
            return(logWindow);
        }
Esempio n. 17
0
        public void Execute()
        {
            var designerItem = itemWorker.DesignerItem;

            IModule     stepModule       = objectResolver.GetModule(designerItem.ID, designerItem.ModuleDescription.ModuleType);
            IConnection connectionObject = null;

            if (designerItem.ModuleDescription.Attributes.RequiresConnection)
            {
                connectionObject = objectResolver.GetConnection(designerItem.ID);
            }
            IDatabaseInterface databaseInterface = SqliteWrapper.GetSqliteWrapper(runLog.RunLogPath, designerItem.ID, designerItem.ItemLabel);

            ((IStep)stepModule).Execute(connectionObject, databaseInterface, ReportProgressMethod);
        }
Esempio n. 18
0
 public virtual void Dispose()
 {
     if (conn != null)
     {
         if (InterfaceDisposer != null)
         {
             InterfaceDisposer(conn);
         }
         else
         {
             conn.Dispose();
         }
         conn = null;
     }
 }
Esempio n. 19
0
        public IDatastore WriteToTarget(DesignerItemBase targetItem, IDatastore dataStore, ReportProgressMethod reportProgressMethod)
        {
            IModule            targetModule      = objectResolver.GetModule(targetItem.ID, targetItem.ModuleDescription.ModuleType);
            IConnection        connectionObject  = objectResolver.GetConnection(targetItem.ID);
            IDatabaseInterface databaseInterface = SqliteWrapper.GetSqliteWrapper(runLog.RunLogPath, targetItem.ID, targetItem.ItemLabel);

            ItemLog itemLog = ItemLog.CreateNew(targetItem.ID, targetItem.ItemLabel, targetItem.ModuleDescription.ModuleType.Name, runLog.RunLogPath + "\\" + databaseInterface.GetDatabaseName());

            ((IDataTarget)targetModule).WriteData(connectionObject, databaseInterface, dataStore, reportProgressMethod);

            itemLog.EndTime = DateTime.Now;
            parentItemLog.SubFlowLogs.Add(itemLog);

            return(dataStore);
        }
Esempio n. 20
0
 static void CreateData(string s)
 {
     if (data != null)
     {
         return;
     }
     try
     {
         IDatabaseInterface inter = DataWarehouse.StaticExtensionDataWarehouse.Coordinator[s];
         data = new DatabaseInterface(new User(null, null, null), inter);
     }
     catch (Exception)
     {
     }
 }
Esempio n. 21
0
        public static LogSummary LoadLogSummary(IDatabaseInterface databaseInterface)
        {
            LogSummary logSummary = new LogSummary();

            object result = null;

            result = databaseInterface.ExecuteScalar("Select count(*) from tblRecordLog");
            logSummary.NumberOfRecordsLoaded = result == null ? -1 : Convert.ToInt32(result);

            result = databaseInterface.ExecuteScalar("Select count(*) from tblRecordLog where DeletionFault IS NULL");
            logSummary.NumberOfSuccessfulRecords = result == null ? -1 : Convert.ToInt32(result);

            result = databaseInterface.ExecuteScalar("Select count(*) from tblRecordLog where DeletionFault IS NOT NULL");
            logSummary.NumberOfFailedRecords = result == null ? -1 : Convert.ToInt32(result);

            return(logSummary);
        }
        /// <summary>
        /// Creates data
        /// </summary>
        /// <param name="directory">Directory</param>
        /// <param name="data">Data</param>
        /// <param name="name"></param>
        /// <param name="fileName">File name</param>
        /// <param name="comment">Comment</param>
        /// <returns>The data</returns>
        public static IBufferData CreateData(this IBufferDirectory directory,
                                             IEnumerable <byte[]> data, string name, string fileName, string comment)
        {
            IDatabaseInterface d = StaticExtensionDataPerformerInterfaces.data;

            /*  !!!    if (d.Filenames.Contains(fileName))
             *    {
             *        throw new Exception("File " + fileName + " already exists");
             *    }*/
            if (directory.GetDirectoryNames().Contains(name))
            {
                throw new Exception(name + " already exists");
            }
            IBufferData ld = d.Create(data, directory.Id, name, fileName, comment);

            return(new BufferItemWrapper(directory as BufferDirectoryWrapper, ld));
        }
Esempio n. 23
0
        /// <summary>
        /// Creates data
        /// </summary>
        /// <param name="directory">Directory</param>
        /// <param name="data">Data</param>
        /// <param name="name"></param>
        /// <param name="fileName">File name</param>
        /// <param name="comment">Comment</param>
        /// <returns>The data</returns>
        public static ILogData CreateData(this ILogDirectory directory,
                                          IEnumerable <byte[]> data, string name, string fileName, string comment)
        {
            IDatabaseInterface d = StaticExtensionEventLogDatabase.data;

            if (d.Filenames.Contains(fileName))
            {
                throw new Exception("File " + fileName + " already exists");
            }
            if (directory.GetDirectoryNames().Contains(name))
            {
                throw new Exception(name + " already exists");
            }
            ILogData ld = d.Create(data, directory.Id, name, fileName, comment);

            d.Filenames.Add(fileName);
            return(new LogItemWrapper(directory as LogDirectoryWrapper, ld));
        }
        public IDatastore TransformData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore datastore1, IDatastore datastore2, ReportProgressMethod reportProgress)
        {
            IDatastore resultDatastore = DataStoreFactory.GetDatastore();

            InitializeOutputColumnsConfiguration();
            InitializeResultDatastore(resultDatastore);
            AnalyzeDatastores(datastore1, datastore2);
            BuildDatastoreKeys();
            JoinDatastoreRecords(resultDatastore);

            if (mappingHasBeenReversed)
            {
                ReverseMapping(); // Reverse it back
                mappingHasBeenReversed = false;
            }

            return(resultDatastore);
        }
        private async Task LoadDatabases()
        {
            try
            {
                IDatabaseInterface sqlInterface = DatabaseInterfaceFactory.Factory(comboBoxProvider.SelectedItem.ToString());
                if (this.checkBoxWindowsAuth.Checked)
                {
                    this.ConnectionString = sqlInterface.CreateConnectionStringUsingWindowsAuthentication(textBoxInstance.Text, comboBoxDatabases.SelectedValue?.ToString());
                }
                else
                {
                    this.ConnectionString = sqlInterface.CreateConnectionString(textBoxInstance.Text, comboBoxDatabases.SelectedValue?.ToString(), textBoxUsername.Text, textBoxPassword.Text);
                }

                progressSpinnerDefault.Visible = true;
                comboBoxDatabases.DataSource   = null;
                resetUserMessage();
                sqlInterface.SetConnectionString(this.ConnectionString);
                bool result = sqlInterface.TestConnection();
                if (result)
                {
                    SetUserMessage("Connected!", false);

                    comboBoxDatabases.DataSource = await Task <List <string> > .Run(() =>
                    {
                        List <string> databases = sqlInterface.GetDatabaseList();
                        databases.Sort();
                        return(databases);
                    });
                }
                else
                {
                    SetUserMessage("Unable to Connect...", true);
                }
            }
            catch (Exception ex)
            {
                SetUserMessage($"Unable to Connect...Error={ex.Message}", true);
            }
            finally
            {
                progressSpinnerDefault.Visible = false;
            }
        }
Esempio n. 26
0
        public void WriteData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            reportProgress(new SimpleProgressReport("Aquire database-connection"));
            IDatabaseTargetProvider mySqlTarget = new MySqlTargetProvider(connection);

            DataStoreConverter dataStoreConverter = new DataStoreConverter(this.Configuration.TargetTable, dataObject.Metadata, this.Configuration.Mapping);

            reportProgress(new SimpleProgressReport("Write records to database"));
            for (int i = 0; i < dataObject.Count; i++)
            {
                object[] rowData  = dataObject[i];
                var      dbRecord = dataStoreConverter.ConvertToDbRecord(rowData);
                dbRecord.Identifiers = DbTargetHelper.BuildRecordIdentifiers((DbTargetCommonConfiguration)Configuration, rowData, dataObject.Metadata);

                var existingRecords = mySqlTarget.ResolveRecordInDatabase(dbRecord);

                UpsertRecordInDatabase(mySqlTarget, dbRecord, existingRecords);
            }
        }
Esempio n. 27
0
        private void loadControls()
        {
            Action loadTypes = () =>
            {
                comboBoxFieldType.Items.Clear();
                IDatabaseInterface sqlInterface = DatabaseInterfaceFactory.Factory(this._provider);
                foreach (var item in sqlInterface.ColumnTypes)
                {
                    comboBoxFieldType.Items.Add(item);
                }
            };


            if (this.comboBoxFieldType.InvokeRequired)
            {
                this.comboBoxFieldType.Invoke(new MethodInvoker(delegate
                {
                    loadTypes();
                }));
            }
            else
            {
                loadTypes();
            }


            if (this.textBoxFieldName.InvokeRequired)
            {
                this.textBoxFieldName.Invoke(new MethodInvoker(delegate
                {
                    textBoxFieldName.Select();
                }));
            }
            else
            {
                textBoxFieldName.Select();
            }
        }
        public void TransformData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            foreach (var transformation in this.Configuration.ColumnConcatenations)
            {
                reportProgress(new SimpleProgressReport("Start column-cocatenation"));

                dataObject.AddColumn(new ColumnMetadata(transformation.OutputColumn));
                
                int leftColumnIndex = dataObject.Metadata.Columns.Values.Where(t => t.ColumnName == transformation.LeftColumn).First().ColumnIndex;
                int rightColumnIndex = dataObject.Metadata.Columns.Values.Where(t => t.ColumnName == transformation.RightColumn).First().ColumnIndex;
                string separator = transformation.ColumnSeparation.Replace("\\n", "\n");
                for (int i = 0; i < dataObject.Count; i++)
                {
                    string leftValue = (dataObject[i][leftColumnIndex] == null || dataObject[i][leftColumnIndex] == DBNull.Value) ? "" : dataObject[i][leftColumnIndex].ToString();
                    string rightValue = (dataObject[i][rightColumnIndex] == null || dataObject[i][rightColumnIndex] == DBNull.Value) ? "" : dataObject[i][rightColumnIndex].ToString();
                    string concatenatedValue = leftValue + separator + rightValue;

                    dataObject.SetValue(i, dataObject.Metadata.Columns[transformation.OutputColumn].ColumnIndex, concatenatedValue);
                }

                reportProgress(new SimpleProgressReport("Finished column concatenation"));
            }
        }
Esempio n. 29
0
        ILogItem SaveFile(string filename)
        {
            IDatabaseInterface d  = StaticExtensionEventLogDatabase.Data;
            string             fn = Path.GetFileNameWithoutExtension(filename).ToLower();

            if (d.Filenames.Contains(fn))
            {
                MessageBox.Show("File already exists");
                return(null);
            }
            using (Stream stream = File.OpenRead(filename))
            {
                ILogDirectory        dir  = selected.Tag as ILogDirectory;
                IEnumerable <byte[]> data = stream.ToObjectEnumerable().ToByteEnumerable();
                ILogItem             it   = dir.CreateData(data, fn, fn, "");
                DataGridViewRow      row  = new DataGridViewRow();
                ILogData             ld   = it as ILogData;
                row.Tag = it;
                row.CreateCells(dataGridViewFiles,
                                new object[] { ld.Name, ld.Comment, ld.Length, ld.FileName });
                dataGridViewFiles.Rows.Add(row);
                return(it);
            }
        }
Esempio n. 30
0
 public void TransformData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
 {
     TransformToDatastore(dataObject, this.Configuration.TransformationXslt, this.Configuration.InputXmlColumn, false);
 }