示例#1
0
        public void Execute(IConnection connection, SDK.Database.IDatabaseInterface databaseInterface, ReportProgressMethod reportProgress)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.CreateNoWindow         = true;
            startInfo.FileName               = "cmd.exe";
            startInfo.Arguments              = "/C " + this.Configuration.CmdValue;
            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;

            using (Process process = new Process())
            {
                process.StartInfo = startInfo;
                process.Start();

                process.WaitForExit();

                string output = process.StandardOutput.ReadToEnd();
                string error  = process.StandardError.ReadToEnd();

                if (!String.IsNullOrEmpty(error))
                {
                    throw new Exception("An error occured on execution of " + this.Configuration.CmdValue + ":\n\n" + error);
                }
            }
        }
        public void Execute(IConnection connection, SDK.Database.IDatabaseInterface databaseInterface, ReportProgressMethod reportProgress)
        {
            string[] eventLogConnection = connection.GetConnection() as string[];
            EventLog eventLog           = new EventLog();

            eventLog.Source = eventLogConnection[0];
            eventLog.Log    = eventLogConnection[1];
            EventLogEntryType level = (EventLogEntryType)Enum.Parse(typeof(EventLogEntryType), this.Configuration.Level.ToString());

            eventLog.WriteEntry(this.Configuration.Message, level);
        }
示例#3
0
        public void Execute(IConnection connection, SDK.Database.IDatabaseInterface databaseInterface, ReportProgressMethod reportProgress)
        {
            using (OdbcConnection sqlConnection = connection.GetConnection() as OdbcConnection)
            {
                if (sqlConnection.State != System.Data.ConnectionState.Open)
                {
                    sqlConnection.Open();
                }

                using (OdbcCommand odbcCommand = new OdbcCommand(Configuration.SqlValue, sqlConnection))
                {
                    odbcCommand.ExecuteNonQuery();
                }
            }
        }
示例#4
0
        public void TransformData(IConnection connection, SDK.Database.IDatabaseInterface databaseInterface, SDK.Database.IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            foreach (var transformation in this.Configuration.DefaultValues)
            {
                reportProgress(new SimpleProgressReport("Start add default value column " + transformation.ColumnName + ". Value: " + transformation.Value));

                dataObject.AddColumn(new ColumnMetadata(transformation.ColumnName));

                for (int i = 0; i < dataObject.Count; i++)
                {
                    dataObject.SetValue(i, dataObject.Metadata.Columns[transformation.ColumnName].ColumnIndex, transformation.Value);
                }

                reportProgress(new SimpleProgressReport("Finished add default value column " + transformation.ColumnName + ". Value: " + transformation.Value));
            }
        }
示例#5
0
        public void Execute(IConnection connection, SDK.Database.IDatabaseInterface databaseInterface, ReportProgressMethod reportProgress)
        {
            SmtpClient  smtpClient  = connection.GetConnection() as SmtpClient;
            MailMessage mailMessage = new MailMessage(
                this.Configuration.From,
                this.Configuration.To,
                this.Configuration.Subject,
                this.Configuration.Body);

            mailMessage.IsBodyHtml = this.Configuration.IsBodyHtml;
            if (String.IsNullOrEmpty(this.Configuration.Cc) == false)
            {
                mailMessage.CC.Add(new MailAddress(this.Configuration.Cc));
            }

            smtpClient.Send(mailMessage);
        }
        public void WriteData(IConnection connection, SDK.Database.IDatabaseInterface databaseInterface, SDK.Database.IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            ExcelConnectionObject excelConnection = (ExcelConnectionObject)connection.GetConnection();
            ExcelWorksheet        worksheet       = excelConnection.Worksheet;

            // Write columnheaders into the worksheet
            foreach (var column in dataObject.Metadata.Columns)
            {
                worksheet.SetValue(1, column.Value.ColumnIndex + 1, column.Value.ColumnName);
            }

            // Write data into the worksheet
            for (int row = 0; row < dataObject.Count; row++)
            {
                object[] data = dataObject[row];
                for (int column = 0; column < data.Length; column++)
                {
                    worksheet.SetValue(row + 2, column + 1, data[column]);
                }
            }

            excelConnection.Package.Save();
        }
示例#7
0
 public void Execute(IConnection connection, SDK.Database.IDatabaseInterface databaseInterface, ReportProgressMethod reportProgress)
 {
     System.Threading.Thread.Sleep(this.Configuration.DelayInMilliseconds);
     throw new Exception("Error");
 }