Beispiel #1
0
 void gec_AllCompleted(GlobalEventArgs e)
 {
     ExtensionMethods.TraceInformation("GEC: '{0}' completed, executing commands!", e.GlobalEventName);
     e.GlobalEvent.ExecuteCommand(e.PullersEventArgs);
     ExtensionMethods.TraceInformation("GEC: commands executed for '{0}'.", e.GlobalEventName);
     e.GlobalEvent.Reset();
 }
Beispiel #2
0
        public override IdpeMessage Parse(bool onlyConstraints)
        {
            try
            {
                if (_IsHavingSqlQuery && !onlyConstraints)
                {
                    ExtensionMethods.TraceInformation("Generating 'Generated' type '{0}', executing query '{1}'", ColumnName, Formula);
                    bool isErrored = false;

                    _Value = SqlClientManager.ExecuteQuery(ConnectionString, DatabaseType, Formula, ref isErrored);
                    if (isErrored)
                    {
                        this._ParseResult         = new IdpeMessage(IdpeMessageCodes.IDPE_GENERATED_TYPE_DATA_VALIDATION_FAILED);
                        this._ParseResult.Message = string.Format(this._ParseResult.Message, PrintRowColPosition(), string.Empty, ColumnName);
                    }
                }
                CheckConstraints();
            }
            catch (Exception ex)
            {
                this._ParseResult         = new IdpeMessage(IdpeMessageCodes.IDPE_GENERATED_TYPE_DATA_VALIDATION_FAILED);
                this._ParseResult.Message = string.Format(this._ParseResult.Message, PrintRowColPosition(), Formula, ColumnName);
                ExtensionMethods.TraceError(ex.ToString());
            }
            _IsParsed = true;
            return(this._ParseResult);
        }
Beispiel #3
0
        public bool PrepareOutput(StringBuilder result)
        {
            if (File.Exists(OutputFileName))
            {
                string buName = Path.Combine(OutputFolder, string.Format("{0}_{1}", RenamedToIdentifier, Path.GetFileName(OutputFileName)));
                new FileUtility().FileCopy(OutputFileName, buName, true); //backup existing
            }

            if (((InputFileExtension.ToLower() == ".zip") || (InputFileExtension.ToLower() == ".rar") || (InputFileExtension.ToLower() == ".tar")) &&
                (Keys.GetKeyValue(IdpeKeyTypes.ZipDoNotCreateAcknoledgementInOutputFolder).ParseBool()))
            {
                ExtensionMethods.TraceInformation("Pullers - The data source '{0}' has been configured as not to copy zip acknoledgement file. File will not be created!",
                                                  DataSourceId);
                return(false);
            }

            if (result.Length > 0)
            {
                using (StreamWriter tw = new StreamWriter(OutputFileName))
                {
                    tw.Write(result);
                    tw.Close();
                }

                ExtensionMethods.TraceInformation("{0} successfully processed. Output file was {1}", InputFileName, OutputFileName);
                //InvokeFileProcessed(dataSourceId, jobProcessor.JobId, Keys, OutputFileName, actualOutputFolder, zipUniuqeId);
                return(true);
            }
            else
            {
                ExtensionMethods.TraceInformation("Pullers - Failed to process '{0}', empty data came from output writer! Check log for more details.", InputFileName);
                return(false);
            }
        }
Beispiel #4
0
        private void BindFromRawString()
        {
            MatchCollection matches = GetConfigCollection(_RawString);

            if (matches.Count <= 0)
            {
                ExtensionMethods.TraceInformation("Invalid key value - " + _RawString);
            }
            else
            {
                //extract header
                if (matches.Count >= 1)
                {
                    HeaderRawString = matches[0].Groups[1].Value;
                    string[] DBConDetails = (HeaderRawString).Split(new string[] { "," }, StringSplitOptions.None);
                    this.ConnectionKey        = ConnectionKeys.GetKey(DBConDetails[0]);
                    this.ConnectionKeyRunTime = DBConDetails[1];
                    this.TargetTableName      = DBConDetails[2].ToString();
                    this.NoOfRecordsinBatch   = (int)DBConDetails[3].ToString().ParseInt();
                }
                //extract Column Details
                if (matches.Count > 1)
                {
                    for (int i = 1; i < matches.Count; i++)
                    {
                        ColumnMapInfo oneColumn = new ColumnMapInfo(this.DataSourceId, matches[i].Groups[1].Value);
                        this.Add(oneColumn);
                    }
                }
            }
        }
Beispiel #5
0
        public override IdpeMessage Parse(bool onlyConstraints)
        {
            try
            {
                if (!onlyConstraints)
                {
                    _IsParsed = true;
                    ExtensionMethods.TraceInformation("Validating 'Not Referenced' type '{0}' value '{1}', executing query '{1}' with '{2}'", Value, Formula, ConnectionString);
                    if (SqlClientManager.CheckReferenceKey(ConnectionString, DatabaseType, Formula, Value))
                    {
                        this._ParseResult         = new IdpeMessage(IdpeMessageCodes.IDPE_NOT_REFERENCED_TYPE_DATA_RESULT_FOUND);
                        this._ParseResult.Message = string.Format(this._ParseResult.Message, PrintRowColPosition(), Value, ColumnName);
                        return(this._ParseResult);
                    }
                    else
                    {
                        this._ParseResult = new IdpeMessage(IdpeMessageCodes.IDPE_NOT_REFERENCED_TYPE_DATA_RESULT_NOT_FOUND);
                        return(this._ParseResult);
                    }
                }
            }
            catch (Exception ex)
            {
                ExtensionMethods.TraceError(ex.ToString());
            }

            return(this._ParseResult);
        }
Beispiel #6
0
        protected override void Execute(CodeActivityContext context)
        {
            
            Job job = context.GetValue(this.Job);
            if (job != null)
            {
                job.PreValidationRuleFailed = true;
                string[] uniquenessColumns = GetUniquenessColumns(job, context.GetValue(this.UniquenessCriteriaKeyName));
                ValidateUniquenessColumns(job, uniquenessColumns);

                //generate incoming record table
                DataTable filterTable = GenerateFilterTable(job, uniquenessColumns);
                if (filterTable.Rows.Count == 0)
                    return;

                //check duplicates within the file
                List<string> dupResult = filterTable.CheckDuplicates(uniquenessColumns, false);
                if (dupResult.Count > 0)
                {
                    string errorMessage = "Duplicate records found within the file!";
                    job.Errors.Add(errorMessage);
                    job.Errors.AddRange(dupResult);
                    ExtensionMethods.TraceInformation(errorMessage);
                    job.PreValidationRuleFailed = false;
                    return;
                }

                if (context.GetValue(CheckWithInTheFileOnly))
                    return;

                //check duplicates against consumer's database                
                job.PreValidationRuleFailed = CheckDuplicate(job, filterTable, GetConnectionString(job, context.GetValue(this.ConnectionStringKeyName)));
            }
        }
Beispiel #7
0
        private void FeedZipped()
        {
            string fileExtension = string.Empty;
            Job    currentJob    = Registry.Instance.Entries[Job.JobIdentifier] as Job;

            if (currentJob == null)
            {
                currentJob.TraceError("Could not find job information of job id '{0}'. Aborting.", Job.JobIdentifier);
                return;
            }
            fileExtension = currentJob.FileExtension;
            switch (fileExtension)
            {
            case ".CSV":
            case ".csv":
                FeedCsv();
                break;

            case ".XML":
            case ".xml":
                FeedXml();
                break;

            default:
                string warnMessage = string.Format("System is not configured to handle a '{0}' type file within a zip file. The file '{1}' was ignored."
                                                   , fileExtension, ZipFileWatcher.RenameToOriginal(currentJob.FileName));
                new PostMan(currentJob, false).Send(PostMan.__warningStartTag + warnMessage + PostMan.__warningEndTag, null, true);
                ExtensionMethods.TraceInformation(warnMessage);
                Trace.Flush();
                return;
            }
        }
Beispiel #8
0
        static void LoadCodeSets()
        {
            string connectedTo = "Unknown";

            if (EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType == DatabaseTypes.SqlCe)
            {
                connectedTo = ConfigurationManager.ConnectionStrings["cs"].GetSdfFileName();
            }
            else if (EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType == DatabaseTypes.SqlCe)
            {
                connectedTo = string.Format("{0}\\{1}", ConfigurationManager.ConnectionStrings["cs"].GetSqlServerName(),
                                            ConfigurationManager.ConnectionStrings["cs"].GetSqlServerDatabaseName());
            }

            ExtensionMethods.TraceInformation("Connected to = {0}, Database type = '{1}'",
                                              connectedTo,
                                              EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType.ToString());
            ExtensionMethods.TraceInformation("Initializing code sets.");
            Registry.Instance.CodeSets = Cache.Instance.Bag["codesets.default"] as List <CodeSet>;
            if (Registry.Instance.CodeSets == null)
            {
                Registry.Instance.CodeSets = CoreDatabaseObjects.Instance.GetCodeSets();
                Cache.Instance.Bag.Add("codesets.default", Registry.Instance.CodeSets);
            }

            ExtensionMethods.TraceInformation("Done. {0} code sets found.", Registry.Instance.CodeSets.Count);
        }
Beispiel #9
0
        /// <summary>
        /// returns specific key
        /// </summary>
        /// <param name="idpeKeyType">specific key</param>
        /// <returns></returns>
        public IdpeKey Key(IdpeKeyTypes idpeKeyType)
        {
            if ((idpeKeyType == IdpeKeyTypes.Custom) ||
                (idpeKeyType.IsConnectionStringType()))
            {
                return(null);
            }

            List <IdpeKey> keys = (from e in this.Keys
                                   where e.Type == (int)idpeKeyType
                                   select e).ToList();

            if (keys.Count > 0)
            {
                if (keys.Count > 1)
                {
                    ExtensionMethods.TraceInformation("Warning:: More than one key of type '{0}' defined in data source '{1}'. Taking first key.",
                                                      idpeKeyType.ToString(), this.Id);
                }
                return(keys[0]);
            }
            else
            {
                //throw new Exception(string.Format("No key of type '{0}' is defined in data source '{1}'",
                //    idpeKeyType.ToString(), this.Id));
                return(null);
            }
        }
Beispiel #10
0
        protected override void Execute(CodeActivityContext context)
        {
            string restUrl      = context.GetValue(this.RestUrl);
            string restResource = context.GetValue(this.RestResource);
            string method       = context.GetValue(this.Method);
            string json         = context.GetValue(this.Json);

            if (string.IsNullOrEmpty(method))
            {
                method = "GET";
            }

            int timeOut = context.GetValue(this.TimeOut);

            if (timeOut == 0)
            {
                timeOut = 2 * 60 * 1000;//default is 2 minutes
            }
            RestApiClient restClient         = new RestApiClient(restUrl, timeOut);
            string        responseStatusCode = restClient.Execute(restResource, method, json);

            ExtensionMethods.TraceInformation("Executing REST API {0}{1}. Return Code = {2}", restUrl, restResource, responseStatusCode);
            Trace.Flush();
            RestResponseStatusCode.Set(context, responseStatusCode);
            RestResponse.Set(context, restClient.ResponseContent);
            RestResponseJObject.Set(context, restClient.ResponseContentJObject);
            RestResponseDataTable.Set(context, restClient.ResponseContentDataTable);
            RestResponseErrorMessage.Set(context, restClient.ResponseErrorMessage);
        }
Beispiel #11
0
        /// <summary>
        /// Start called when 'Caller' wants to parse one row at a time. Initiate a new job based on input parameters.
        /// Either applicationId should contain a valid application id or applicationName should be a valid application name.
        /// </summary>
        /// <param name="dataSourceId">Should be a valid application id. If this is filled, then applicationName is optional.</param>
        /// <param name="dataSourceName">Should be a valid application name. If this is filled, then applicationId is optional.</param>
        /// <param name="processingBy">user name who is processing, we could get this from context, but for scenario like 'a126042, Deb'jyoti Das', let caller decide the user name.</param>
        /// <returns>Retruns process identifier as GUID or string.empty (fail condition)</returns>
        public string InitializeJob(int dataSourceId, string dataSourceName, string processingBy)
        {
            if ((dataSourceId <= 0) && (string.IsNullOrEmpty(dataSourceName)))
            {
                ExtensionMethods.TraceInformation("Job could not be initialized, data source is not defined. Id = {0}, name = '{1}'", dataSourceId, dataSourceName);
                return(string.Empty);    //fail response
            }

            try
            {
                Job newJob = new Job(dataSourceId, dataSourceName, processingBy);

                if (!newJob.IsValid)
                {
                    ExtensionMethods.TraceInformation("Job could not be initialized, data source is not defined. Id ={0}, name = '{1}'", dataSourceId, dataSourceName);
                    return(string.Empty);    //fail response
                }

                Registry.Instance.Entries.Add(newJob.JobIdentifier, newJob);
                Trace.Flush();
                return(newJob.JobIdentifier);
            }
            catch (Exception ex)
            {
                string errorMessage = ex.ToString() + (ex.InnerException == null ? string.Empty : ex.InnerException.Message);
                ExtensionMethods.TraceError(errorMessage);
                Trace.Flush();
                throw ex;
            }
        }
Beispiel #12
0
        private void Clean()
        {
            ExtensionMethods.TraceInformation("Clearing global cache.");
            Cache.Instance.Bag.Clear();
            ExtensionMethods.TraceInformation("Done.");


            ExtensionMethods.TraceInformation("Clearing temp directories.");
            Directory.Delete(Path.Combine(EyediaCoreConfigurationSection.CurrentConfig.TempDirectory, "idpe"), true);
            ExtensionMethods.TraceInformation("Done.");

            ExtensionMethods.TraceInformation("Clearing data cache...");
            if (Registry.Instance.CachedTables != null)
            {
                foreach (object obj in Registry.Instance.CachedTables)
                {
                    if (obj is DataTable)
                    {
                        DataTable cachedLookup = obj as DataTable;
                        cachedLookup.Dispose();
                    }
                }
            }
            ExtensionMethods.TraceInformation("Done.");

            ExtensionMethods.TraceInformation("Clearing tracked emails...");
            new Eyedia.Core.Net.EmailTracker().Clean();
            ExtensionMethods.TraceInformation("Done.");

            LastCleaned = DateTime.Now;
        }
Beispiel #13
0
        public void Download()
        {
            if ((DateTime.Now - LastRunTime).TotalMinutes < this.IntervalInMinutes)
            {
                return;
            }

            if (DataSourceIsDisabled())
            {
                return;
            }

            ExtensionMethods.TraceInformation("Ftp downloading T:{0}:{1}", this.DataSourceParameters["DataSourceId"], this.FtpLocationToWatch);
            this.IsRunning = true;
            string[] FilesList = GetFilesList(this.FtpLocationToWatch, this.FtpUserName, this.FtpPassword, this.DataSourceParameters["DataSourceId"].ToString());
            if (FilesList == null || FilesList.Length < 1)
            {
                return;
            }
            foreach (string FileName in FilesList)
            {
                if (!string.IsNullOrEmpty(FileName))
                {
                    DownloadFile(FileName.Trim());
                    if (!this.KeepOrignal)
                    {
                        DeleteFile(FileName.Trim());
                    }
                }
            }
            this.LastRunTime = DateTime.Now;
            this.IsRunning   = false;
        }
Beispiel #14
0
        /// <summary>
        /// This method will get called for each file found within the zip file.
        /// </summary>
        /// <param name="unzippedFileName">Un zipped full file name</param>
        /// <param name="onlyFileName">Un zipped file name</param>
        /// <param name="extension">file extension</param>
        /// <param name="fileStatus">file status</param>
        public virtual void Handle(string unzippedFileName, string onlyFileName, string extension, FileStatus fileStatus)
        {
            string destFileName = string.Empty;
            string zipId        = string.Empty;

            unzippedFileName = ExtractActualFileName(unzippedFileName);
            zipId            = ExtractUniqueId(onlyFileName);

            ExtensionMethods.TraceInformation("Actual name = '{0}', zip id = '{1}', extension = '{2}', and status = '{3}'",
                                              Path.GetFileName(unzippedFileName), zipId, extension, fileStatus);


            switch (fileStatus)
            {
            case FileStatus.Process:

                destFileName = Path.Combine(DataSource.GetArchiveFolder(DataSourceId, DataSourceKeys), onlyFileName);
                Registry.Instance.Pullers._LocalFileSystemWatcher.Process(unzippedFileName, onlyFileName, this.DataSourceId);
                break;

            case FileStatus.IgnoreMoveToOutput:

                AddIgnoredFileCountToZipFileInfo(zipId);
                //moving to output
                string myOutputFolder = Path.Combine(DataSource.GetOutputFolder(DataSourceId, DataSourceKeys), zipId);
                if (!Directory.Exists(myOutputFolder))
                {
                    Directory.CreateDirectory(myOutputFolder);
                }

                destFileName = string.Format("{0}\\{1}", myOutputFolder, onlyFileName);
                destFileName = ExtractActualFileName(destFileName);

                if (File.Exists(destFileName))
                {
                    string buName = Path.Combine(OutputFolder, string.Format("{0}_{1}", RenamedToIdentifier, onlyFileName));
                    new FileUtility().FileCopy(destFileName, buName, true);     //backup existing
                }

                new FileUtility().FileCopy(unzippedFileName, destFileName, false);      //ignored and copied to output folder
                List <IdpeKey> appKeys = _datasourceKeys;
                if (appKeys == null)
                {
                    appKeys = Cache.Instance.Bag[DataSourceId + ".keys"] as List <IdpeKey>;
                }
                Registry.Instance.Pullers.InvokeFileProcessed(this.DataSourceId, string.Empty, appKeys,
                                                              destFileName, DataSource.GetOutputFolder(DataSourceId, DataSourceKeys), this.ZipUniqueId);

                break;

            case FileStatus.Ignore:

                AddIgnoredFileCountToZipFileInfo(zipId);
                break;

            default:
                throw new Exception("'fileStatus' can be set either to 'Ignore' or 'IgnoreMoveToOutput'!");
            }
        }
Beispiel #15
0
 private bool DataSourceIsTemporarilyStopped()
 {
     if (IsTemporarilyStopped)
     {
         ExtensionMethods.TraceInformation(" - ignored as temporarily stopped");
         return(true);
     }
     return(false);
 }
Beispiel #16
0
        public Pullers()
        {
            InitDoWorkTimer           = new System.Timers.Timer(30 * 1000);
            InitDoWorkTimer.AutoReset = true;
            InitDoWorkTimer.Enabled   = true;
            InitDoWorkTimer.Elapsed  += new System.Timers.ElapsedEventHandler(InitDoWorkTimer_Interval);

            ExtensionMethods.TraceInformation("Pullers - Instantiated...");
        }
Beispiel #17
0
 public void Stop()
 {
     ExtensionMethods.TraceInformation("Pullers - Trying to stop all 'Pullers'");
     if (_LocalFileSystemWatcher != null)
     {
         _LocalFileSystemWatcher.Stop();
     }
     ExtensionMethods.TraceInformation("All 'Pullers' stopped.");
 }
Beispiel #18
0
 public string ClearLog()
 {
     ExtensionMethods.TraceInformation("Cleaing log!");
     Trace.Flush();
     SetupTrace.Clear(Information.EventLogSource, Information.EventLogName);
     ExtensionMethods.TraceInformation("New log created.");
     Trace.Flush();
     return("true");
 }
Beispiel #19
0
        private StringBuilder WriteOutputToDatabaseSqlCe(List <Row> rows)
        {
            StringBuilder sb = new StringBuilder();

            DateTime StartTime = DateTime.Now;

            ExtensionMethods.TraceInformation("Converting to DataTable - " + StartTime.ToString());
            DataTable outDataTable = ToDataTable(rows);

            sb = outDataTable.ToCsvStringBuilder();
            DateTime EndTime = DateTime.Now;

            ExtensionMethods.TraceInformation("Converted - {0}. Time taken: {1}", EndTime, (EndTime - StartTime).ToString());

            bool keepNulls = true;
            SqlCeBulkCopyOptions options = new SqlCeBulkCopyOptions();

            if (keepNulls)
            {
                options = options |= SqlCeBulkCopyOptions.KeepNulls;
            }
            using (SqlCeBulkCopy bulkCopy = new SqlCeBulkCopy(ConnectionStringKey.Value, options))
            {
                bulkCopy.DestinationTableName = DatabaseMap.TargetTableName;
                foreach (ColumnMapInfo columnMapInfo in DatabaseMap)
                {
                    if ((!string.IsNullOrEmpty(columnMapInfo.InputColumn)) &&
                        (columnMapInfo.InputColumn != ColumnMapInfo.DatabaseDefault))
                    {
                        SqlCeBulkCopyColumnMapping mapInfo = new SqlCeBulkCopyColumnMapping(columnMapInfo.InputColumn, columnMapInfo.OutputColumn);
                        bulkCopy.ColumnMappings.Add(mapInfo);
                    }
                }

                try
                {
                    bulkCopy.WriteToServer(outDataTable);
                }
                catch (Exception ex)
                {
                    IsErrored = true;
                    _Job.TraceError(GetBulkCopyFailedData(outDataTable, bulkCopy.ColumnMappings));
                }
                finally
                {
                    if (outDataTable != null)
                    {
                        outDataTable.Dispose();
                    }
                }
            }

            return(sb);
        }
Beispiel #20
0
 private void MidnightSwiffer()
 {
     if (DateTime.Now.Hour > 1 && DateTime.Now.Hour < 3)
     {
         if (Math.Round(DateTime.Now.Subtract(LastCleaned).TotalDays, 0) > 0)
         {
             ExtensionMethods.TraceInformation("Midnight Swiffer last run at '{0}', starting cleaning process...", LastCleaned);
             Clean();
         }
     }
 }
Beispiel #21
0
 internal void CompleteJobIfAllWorkersCompleted()
 {
     if (Interlocked.Decrement(ref NumberOfWorkerRemains) == 0)
     {
         TheJobCompleted.Set();
     }
     else
     {
         ExtensionMethods.TraceInformation("{0} worker(s) are still working. Waiting...", NumberOfWorkerRemains);
     }
 }
Beispiel #22
0
        void StartLocalFileSystemWatcher()
        {
            ExtensionMethods.TraceInformation("Pullers - Initializing local file watcher...");

            _LocalFileSystemWatcher = new LocalFileSystemWatcher(IdpeConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryPull, IdpeConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryArchive);
            Watchers.FileSystemWatcherEventHandler handler = new Watchers.FileSystemWatcherEventHandler(FileDownloaded);
            _LocalFileSystemWatcher.FileDownloaded -= handler;
            _LocalFileSystemWatcher.FileDownloaded += handler;
            _LocalFileSystemWatcher.Run();

            ExtensionMethods.TraceInformation("Pullers - Local file watcher initialized  with Pull = '{0}' and Archive = '{1}'.",
                                              IdpeConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryPull, IdpeConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryArchive);
        }
Beispiel #23
0
        private StringBuilder WriteOutputToDatabaseSql(List <Row> rows)
        {
            StringBuilder sb = new StringBuilder();

            using (SqlConnection sourceConnection = new SqlConnection(ConnectionStringKey.Value))
            {
                DateTime StartTime = DateTime.Now;
                ExtensionMethods.TraceInformation("Converting to DataTable - " + StartTime.ToString());
                DataTable outDataTable = ToDataTable(rows);
                sb = outDataTable.ToCsvStringBuilder();
                DateTime EndTime = DateTime.Now;
                ExtensionMethods.TraceInformation("Converted - {0}. Time taken: {1}", EndTime, (EndTime - StartTime).ToString());

                sourceConnection.Open();

                using (SqlBulkCopy bulkCopy = new SqlBulkCopy(ConnectionStringKey.Value))
                {
                    bulkCopy.BulkCopyTimeout      = 15 * 60; //15 minutes
                    bulkCopy.DestinationTableName = DatabaseMap.TargetTableName;

                    foreach (ColumnMapInfo columnMapInfo in DatabaseMap)
                    {
                        if ((!string.IsNullOrEmpty(columnMapInfo.InputColumn)) &&
                            (columnMapInfo.InputColumn != ColumnMapInfo.DatabaseDefault))
                        {
                            SqlBulkCopyColumnMapping mapInfo = new SqlBulkCopyColumnMapping(columnMapInfo.InputColumn, columnMapInfo.OutputColumn);
                            bulkCopy.ColumnMappings.Add(mapInfo);
                        }
                    }

                    try
                    {
                        bulkCopy.WriteToServer(outDataTable);
                    }
                    catch (Exception ex)
                    {
                        IsErrored = true;
                        //we are not throwing as we need sb to return as it may useful for debugging
                        _Job.TraceError(GetBulkCopyFailedData(outDataTable, bulkCopy.ColumnMappings));
                    }
                    finally
                    {
                        if (outDataTable != null)
                        {
                            outDataTable.Dispose();
                        }
                    }
                }
            }
            return(sb);
        }
Beispiel #24
0
        /// <summary>
        /// Thread safe agreegate function, should be called from Pre/Post validate only. The result will be stored in container data
        /// </summary>
        /// <param name="columnName">Name of the column which is to be agreegated</param>
        /// <param name="isSytemColumn">True if the system columns to be searched</param>
        /// <param name="operationType">Aggregate operation type; default is 'Sum'</param>
        /// <param name="containerDataKeyName">Name of the container data key where the result will be added or updated</param>
        /// <returns>calculated value as double</returns>
        public double Aggregate(string columnName, bool isSytemColumn = false, AggregateOperationTypes operationType = AggregateOperationTypes.Sum, string containerDataKeyName = null)
        {
            double calculatedValue = 0;

            lock (_lock)
            {
                List <double> values = new List <double>();
                if (isSytemColumn)
                {
                    values = (from r in Rows
                              select r.ColumnsSystem[columnName].ValueDouble).ToList();
                }
                else
                {
                    values = (from r in Rows
                              select r.Columns[columnName].ValueDouble).ToList();
                }

                switch (operationType)
                {
                case AggregateOperationTypes.Sum:
                    calculatedValue = values.Sum();
                    break;

                case AggregateOperationTypes.Average:
                    calculatedValue = values.Average();
                    break;

                case AggregateOperationTypes.Min:
                    calculatedValue = values.Min();
                    break;

                case AggregateOperationTypes.Max:
                    calculatedValue = values.Max();
                    break;
                }
                calculatedValue = Math.Round(calculatedValue, 2);
                if (containerDataKeyName != null)
                {
                    ProcessVariables.AddOrUpdate(containerDataKeyName, calculatedValue, (keyx, oldValue) => calculatedValue);
                    ExtensionMethods.TraceInformation("Aggregate method '{0}' has been called on '{1}' and calculated value '{2}' has been assigned to ContainerData with key as '{3}'"
                                                      , operationType.ToString(), calculatedValue, containerDataKeyName, containerDataKeyName);
                }
                else
                {
                    ExtensionMethods.TraceInformation("Aggregate method '{0}' has been called on '{1}' and calculated value '{2}' was returned."
                                                      , operationType.ToString(), calculatedValue, containerDataKeyName);
                }
                return(calculatedValue);
            }
        }
Beispiel #25
0
 private void CreateOneEvent(string rawStringOneEvent)
 {
     ExtensionMethods.TraceInformation("    GEC:Initializing 1 GEC:" + rawStringOneEvent);
     if (rawStringOneEvent.Contains("|"))
     {
         //RawString = name|101,102,103|5|dos commands
         GlobalEventsOnComplete gec = GlobalEventsOnComplete.ParseRawString(rawStringOneEvent);
         if (gec != null)
         {
             gec.TimedOut     += new GlobalEvents.GlobalEventsHandler(gec_TimedOut);
             gec.AllCompleted += new GlobalEvents.GlobalEventsHandler(gec_AllCompleted);
             this.Add(gec);
         }
     }
 }
Beispiel #26
0
        private void InitDoWorkTimer_Interval(object source, System.Timers.ElapsedEventArgs e)
        {
            //this will be executed only once after starting the service
            //  - Reduce starting time
            //  - Handle existing file after starting the service

            ExtensionMethods.TraceInformation("Pullers - Initial checks started.");
            InitDoWorkTimer.Enabled = false;
            Start();
            _LocalFileSystemWatcher.HandleExistingFiles();

            ExtensionMethods.TraceInformation("Pullers - Initial checks ended. System is Ready!");
            PrepareEnvironment();
            Trace.Flush();
        }
Beispiel #27
0
 public void WriteLine(string message)
 {
     if (Data != null)
     {
         Data.CurrentRow.TraceLog.WriteLine(ExtensionMethods.GetTracePrefix(Data) + message);
     }
     else if (Job != null)
     {
         Job.TraceInformation(message);
     }
     else
     {
         ExtensionMethods.TraceInformation(message);
     }
 }
Beispiel #28
0
        void WorkerManagerCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            if (e.CompletionState == ActivityInstanceState.Faulted)
            {
                ExtensionMethods.TraceInformation(string.Format("WorkerManager {0} Terminated.", e.InstanceId.ToString()));
                ExtensionMethods.TraceInformation(string.Format("Exception: {0}\n{1}",
                                                                e.TerminationException.GetType().FullName,
                                                                e.TerminationException.Message));
            }
            else if (e.CompletionState == ActivityInstanceState.Canceled)
            {
                ExtensionMethods.TraceInformation("WorkerManager Canceled!");
            }

            eventDone.Set();
        }
Beispiel #29
0
        protected override void OnComplete(int dataSourceId, PullersEventArgs e)
        {
            if (DataSources.ContainsKey(dataSourceId))
            {
                DataSources[dataSourceId] = true;
                ExtensionMethods.TraceInformation("GEC:Completed:{0}", dataSourceId);
            }

            else
            {
                ExtensionMethods.TraceInformation("GEC:The data source {0} was not registered with global event '{1}'! This operation was ignored.",
                                                  dataSourceId, Name);
            }

            CheckIfAllCompleted(e);
        }
Beispiel #30
0
        private StringBuilder WriteOutput(List <Row> rows)
        {
            StringBuilder sb = new StringBuilder();

            if (rows != null)
            {
                DateTime StartTime = DateTime.Now;
                ExtensionMethods.TraceInformation("Outputwriter Database started - " + StartTime.ToString());
                InitConfig();
                sb = WriteOutputToDatabase(rows);
                DateTime EndTime = DateTime.Now;
                ExtensionMethods.TraceInformation("Outputwriter Database Completed - {0}. Time taken: {1}", EndTime, (EndTime - StartTime).ToString());
            }

            return(sb);
        }