Beispiel #1
0
        protected override void Execute(CodeActivityContext context)
        {
            Job job = context.GetValue(this.Job);

            if (job != null)
            {
                job.Errors.Add(context.GetValue(this.ErrorMessage));
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);

                string errorMessage = context.GetValue(this.ErrorMessage);
                string columnName   = context.GetValue(this.ColumnName);

                if (!(string.IsNullOrEmpty(columnName)))
                {
                    data.CurrentRow.AddError(errorMessage, columnName);
                }
                else
                {
                    data.CurrentRow.AddError(errorMessage);
                }
            }
        }
Beispiel #2
0
        protected override void Execute(CodeActivityContext context)
        {
            Job    job = context.GetValue(this.Job);
            string connectionStringKeyName = context.GetValue(this.ConnectionStringKeyName);
            string query                   = context.GetValue(this.Query);
            string columnName              = context.GetValue(ColumnName);
            bool   isSystemColumn          = context.GetValue(IsSystemColumn);
            bool   throwErrorIfNullOrEmpty = context.GetValue(ThrowErrorIfNullOrEmpty);
            string theResult               = string.Empty;

            if (job != null)
            {
                theResult = job.DataSource.Lookup(connectionStringKeyName, query);
                context.SetValue(Result, theResult);

                if ((throwErrorIfNullOrEmpty) && (string.IsNullOrEmpty(theResult)))
                {
                    job.AddContainerError(-1, string.Format("Look up result was empty or null! Connection = '{0}', Query = '{1}'",
                                                            connectionStringKeyName, query));
                }
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                theResult = data.Job.DataSource.Lookup(connectionStringKeyName, query);
                new CodeActivityTraceWriter(job, data).WriteLine(string.Format("Lookup:'{0}, Return:'{1}'", query, theResult));
                context.SetValue(Result, theResult);

                if ((throwErrorIfNullOrEmpty) && ((!(string.IsNullOrEmpty(columnName))) && (string.IsNullOrEmpty(theResult))))
                {
                    data.CurrentRow.AddError(string.Format("Look up result was empty or null! Connection = '{0}', Query = '{1}'",
                                                           connectionStringKeyName, query), columnName, isSystemColumn);
                }
            }
        }
Beispiel #3
0
        protected override void Execute(CodeActivityContext context)
        {
            Job        job  = context.GetValue(this.Job);
            WorkerData data = context.GetValue(this.Data);

            string cacheName               = context.GetValue(CacheName);
            string criteria                = context.GetValue(Criteria);
            string attributeName           = context.GetValue(AttributeName);
            bool   isSystemAttribute       = context.GetValue(IsSystemAttribute);
            string returnColumn            = context.GetValue(ReturnColumn);
            bool   throwErrorIfNullOrEmpty = context.GetValue(ThrowErrorIfNullOrEmpty);
            string theResult               = string.Empty;
            object obj = Registry.Instance.CachedTables.GetValueOrDefault(cacheName, null);

            if (obj != null)
            {
                DataTable table = obj as DataTable;

                theResult = table.LookUp(criteria, returnColumn);
                new CodeActivityTraceWriter(job, data).WriteLine(string.Format("CLookup:'{0}, Return:'{1}' - '{2}'", criteria, returnColumn, theResult));

                context.SetValue(Result, theResult);

                if ((throwErrorIfNullOrEmpty) && ((!(string.IsNullOrEmpty(attributeName))) && (string.IsNullOrEmpty(theResult))))
                {
                    data.CurrentRow.AddError(string.Format("Cache look up result was empty or null! Cache name = '{0}', Criteria = '{1}'",
                                                           cacheName, criteria), attributeName, isSystemAttribute);
                }
            }
            else
            {
                job.TraceError(string.Format("The cache '{0}' was not initialized!", cacheName));
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            //Even though concurrent dictionary is threadsafe, our threads are not executing synchronized
            //hence in this case a lock is needed

            Job job = context.GetValue(this.Job);

            if (job == null)
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);
                job = data.Job;
            }
            lock (job._lock)
            {
                string key   = context.GetValue(this.Key);
                object value = context.GetValue(this.Value);
                job.ProcessVariables.AddOrUpdate(key, value, (keyx, oldValue) => value);
                if (value != null)
                {
                    string strValue = value.ToString();
                    new CodeActivityTraceWriter(job).WriteLine(string.Format("PV : Key='{0}', Value='{1}'", key,
                                                                             strValue.Length > 5 ? strValue.Substring(0, 5) + string.Format("...({0})", strValue.Length) : strValue));
                }
                else
                {
                }
            }
        }
Beispiel #5
0
        protected override void Execute(CodeActivityContext context)
        {
            Job    job                      = context.GetValue(this.Job);
            string variableName             = context.GetValue(this.Name);
            int    dataSourceId             = context.GetValue(this.DataSourceId);
            IdpePersistentVariable variable = null;


            if (job != null)
            {
                if (dataSourceId == 0)
                {
                    dataSourceId = job.DataSource.Id;
                }
                variable = new Manager().GetPersistentVariable(dataSourceId, variableName);
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);

                if (dataSourceId == 0)
                {
                    dataSourceId = data.Job.DataSource.Id;
                }
                variable = new Manager().GetPersistentVariable(dataSourceId, variableName);
            }

            if (variable != null)
            {
                context.SetValue(ReutrnValue, variable.Value);
            }
        }
Beispiel #6
0
        protected override void Execute(CodeActivityContext context)
        {
            WorkerData data = context.GetValue(this.Data);
            //new CodeActivityTraceWriter(data).WriteLine(string.Format("Assigning values to {0}", this.DisplayName));

            Attribute toAttribute = context.GetValue(this.ToAttribute);

            if (toAttribute == null)
            {
                return;
            }

            Attribute fromAttribute = context.GetValue(this.FromAttribute);

            string fromValue = context.GetValue(this.FromValue);

            if (fromAttribute != null)
            {
                toAttribute.Assign(context.GetValue(this.FromAttribute));
            }
            else
            {
                toAttribute.Value = string.IsNullOrEmpty(fromValue) ? string.Empty : fromValue;
            }
        }
Beispiel #7
0
        protected override void Execute(CodeActivityContext context)
        {
            Job       job  = context.GetValue(this.Job);
            string    name = context.GetValue(this.Name);
            string    connectionStringKeyName = context.GetValue(this.ConnectionStringKeyName);
            string    query = context.GetValue(this.Query);
            bool      throwErrorIfNullOrEmpty = context.GetValue(ThrowErrorIfNullOrEmpty);
            DataTable table = null;

            new CodeActivityTraceWriter(job).WriteLine(string.Format("Initializing cache '{0}'...", name));
            Trace.Flush();
            if (job != null)
            {
                table = job.DataSource.LoadDataTable(connectionStringKeyName, query);
                //job.ProcessVariables.AddOrUpdate(name, table, (keyx, oldValue) => table);
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                table = data.Job.DataSource.LoadDataTable(connectionStringKeyName, query);
                //data.Job.ProcessVariables.AddOrUpdate(name, table, (keyx, oldValue) => table);
            }

            new CodeActivityTraceWriter(job).WriteLine(string.Format("Cache initialized with connection string name:'{0}', query:'{1}';{2} records.",
                                                                     connectionStringKeyName, query, table.Rows.Count));

            //keeping in global instance
            Registry.Instance.CachedTables.AddOrUpdate(name, table, (keyx, oldValue) => table);

            if ((throwErrorIfNullOrEmpty) && (table.Rows.Count == 0))
            {
                job.AddContainerError(-1, string.Format("Init cache the query result was empty or null! Connection = '{0}', Query = '{1}'",
                                                        connectionStringKeyName, query));
            }
        }
Beispiel #8
0
 public static void ThrowErrorIfNull(this WorkerData data, string activityName = null)
 {
     if (data == null)
     {
         throw new Exception(string.Format("A valid instance of 'Data' object has not been passed! Please make sure that a valid instance of 'WorkerData' has been passed as argument to this activity '{0}'"
                                           , string.IsNullOrEmpty(activityName) ? string.Empty : activityName));
     }
 }
Beispiel #9
0
        protected override void Execute(CodeActivityContext context)
        {
            WorkerData data             = context.GetValue(this.Data);
            int        originalPosition = context.GetValue(this.OriginalPostion);

            data.Job.PerformanceCounter.Start(data.Job.JobIdentifier, RowPerformanceTaskNames.LoopReset, originalPosition);
            data.RowPosition++;
            data.Job.PerformanceCounter.Stop(data.Job.JobIdentifier, RowPerformanceTaskNames.LoopReset, originalPosition);
        }
Beispiel #10
0
        public static string GetTracePrefix(WorkerData data)
        {
            string prefix = string.Format("{0}. . :", EyediaCoreConfigurationSection.CurrentConfig.InstanceName);

            if (data != null)
            {
                prefix = string.Format("{0}.{1}.{2}:", EyediaCoreConfigurationSection.CurrentConfig.InstanceName, TrimDataSourceName(data.Job.DataSource.Name), data.Job.FileNameOnly);
            }
            return(prefix);
        }
Beispiel #11
0
        protected override void Execute(CodeActivityContext context)
        {
            WorkerData data = context.GetValue(this.Data);

            data.ThrowErrorIfNull(this.DisplayName);
            if (data.CurrentRow != null)
            {
                data.CurrentRow.TraceLog.WriteLine(context.GetValue(this.Message));
            }
        }
Beispiel #12
0
        /// <summary>
        /// Executes business rules based on ruleSetType. Executes all business rules if ruleSetType is not passed
        /// </summary>
        /// <param name="job">The job in context</param>
        /// <param name="data">The worker data in context</param>
        /// <param name="ruleSetType">The ruleSetType (Executes all business rules if ruleSetType is not passed)</param>
        public void Execute(Job job, WorkerData data, RuleSetTypes ruleSetType = RuleSetTypes.Unknown)
        {
            List <BusinessRule> businessRules = ruleSetType == RuleSetTypes.Unknown ? this : this.Where(bs => bs.RuleSetType == ruleSetType).OrderBy(bp => bp.Priority).ToList();

            foreach (BusinessRule businessRule in businessRules)
            {
                businessRule.Execute(job, data);
                //businessRule.ExceptionOccurred = true;
                //this.ExceptionOccurred = true;
            }
        }
Beispiel #13
0
 public static void TraceError(this WorkerData data, string message)
 {
     if (data != null)
     {
         Trace.TraceError(GetTracePrefix(data) + message);
     }
     else
     {
         TraceError(message);
     }
 }
Beispiel #14
0
        protected override void Execute(CodeActivityContext context)
        {
            WorkerData data = context.GetValue(this.Data);

            if (data == null)
            {
                throw new ArgumentNullException("Data", "ForcedIsValid activity requires Data argument!");
            }

            bool isValidValue = context.GetValue(this.IsValid);

            data.CurrentRow.IsValidColumn.Value = isValidValue.ToString();
            data.CurrentRow.IsValidForced       = true;
        }
Beispiel #15
0
        protected override void Execute(NativeActivityContext context)
        {
            Job job = context.GetValue(this.Job);

            if (job == null)
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);
                job = data.Job;
            }
            lock (job._lock)
            {
                InternalExecute(context, null);
            }
        }
Beispiel #16
0
        protected override void Execute(CodeActivityContext context)
        {
            WorkerData data             = context.GetValue(this.Data);
            int        originalPosition = context.GetValue(this.OriginalPostion);

            bool thisRowIsHavingContainerError = context.GetValue(this.ThisRowIsHavingContainerError);

            data.Job.PerformanceCounter.Start(data.Job.JobIdentifier, RowPerformanceTaskNames.StoreBadData, originalPosition);
            if ((data.CurrentRow.HasAnyError()) ||
                (thisRowIsHavingContainerError))
            {
                data.BadDataInCsvFormat.Add(data.Job.JobSlices[data.SlicePosition].CSVRows[data.RowPosition]);
            }
            data.Job.PerformanceCounter.Stop(data.Job.JobIdentifier, RowPerformanceTaskNames.StoreBadData, originalPosition);
        }
Beispiel #17
0
        protected override void Execute(CodeActivityContext context)
        {
            Job    job = context.GetValue(this.Job);
            string connectionStringKeyName = context.GetValue(this.ConnectionStringKeyName);
            string query   = context.GetValue(this.Query);
            int    timeOut = context.GetValue(this.TimeOut);

            if (timeOut == 0)
            {
                timeOut = 5;//default
            }
            bool throwErrorIfNullOrEmpty = context.GetValue(ThrowErrorIfNullOrEmpty);
            bool silent = context.GetValue(Silent);

            DataTable table = null;

            if (!silent)
            {
                new CodeActivityTraceWriter(job).WriteLine(string.Format("Executing query '{0}' using connection string '{1}'", query, connectionStringKeyName));
            }
            Trace.Flush();
            string errorMessage = string.Empty;

            if (job != null)
            {
                table = job.DataSource.LoadDataTable(connectionStringKeyName, query, ref errorMessage, timeOut, silent);
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                table = data.Job.DataSource.LoadDataTable(connectionStringKeyName, query, ref errorMessage, timeOut, silent);
            }
            if (!silent)
            {
                new CodeActivityTraceWriter(job).WriteLine(string.Format("Executed query with connection:'{0}', query:'{1}';{2} records.",
                                                                         connectionStringKeyName, query, table.Rows.Count));
            }

            context.SetValue(Result, table);
            context.SetValue(QueryHasError, string.IsNullOrEmpty(errorMessage) ? false : true);
            context.SetValue(ErrorMessage, errorMessage);

            if ((throwErrorIfNullOrEmpty) && (table.Rows.Count == 0))
            {
                job.AddContainerError(-1, string.Format("Execute query's result was empty or null! Connection = '{0}', Query = '{1}'",
                                                        connectionStringKeyName, query));
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            Job        job  = context.GetValue(this.Job);
            WorkerData data = context.GetValue(this.Data);
            string     name = context.GetValue(this.Name);

            context.SetValue(Value, string.Empty);
            Trace.TraceInformation("GetSreEnvironmentVariable: Trying to get" + name);
            Trace.Flush();
            if (Registry.Instance.EnvironmentVariables.ContainsKey(name))
            {
                Trace.TraceInformation("GetSreEnvironmentVariable: got" + Registry.Instance.EnvironmentVariables[name]);
                Trace.Flush();
                context.SetValue(Value, Registry.Instance.EnvironmentVariables[name]);
            }
        }
Beispiel #19
0
        internal void WorkerCompleted(WorkflowApplicationCompletedEventArgs e)
        {
            if (!(e.Outputs.ContainsKey("ProcessedData")))
            {
                if (!job.AbortRequested)
                {
                    ExtensionMethods.TraceInformation("The worker '{0}' was aborted with exception.", e.InstanceId);//dont want print if abort was requested
                }
                AbortJob();
                return;
            }

            if (job.IsFinished)  //if job is already finished (most probably because of some error), dont do anything
            {
                return;
            }

            WorkerData data = e.Outputs["ProcessedData"] as WorkerData;

            if (!job.AbortRequested)
            {
                job.TraceInformation("The worker '{0}' has finished its task. Slice position:{1}", e.InstanceId, data.SlicePosition);
            }

            if (e.CompletionState == ActivityInstanceState.Faulted)
            {
                ExtensionMethods.TraceInformation(string.Format("Worker {0} Terminated.", e.InstanceId.ToString()));
                ExtensionMethods.TraceInformation(string.Format("Exception: {0}\n{1}",
                                                                e.TerminationException.GetType().FullName,
                                                                e.TerminationException.Message));
                Trace.Flush();
            }
            else if (e.CompletionState == ActivityInstanceState.Canceled)
            {
                ExtensionMethods.TraceInformation("Worker {0} was Canceled!", e.InstanceId);
                Trace.Flush();
            }
            else
            {
                DoWithData(data);
                CompleteJobIfAllWorkersCompleted();
            }

            AllThreadsAreBusy.Set();
            Trace.Flush();
        }
Beispiel #20
0
        protected override void Execute(CodeActivityContext context)
        {
            WorkerData data             = context.GetValue(this.Data);
            int        originalPosition = context.GetValue(this.OriginalPostion);

            data.Job.PerformanceCounter.Start(data.Job.JobIdentifier, RowPerformanceTaskNames.RowValidateMandatory, originalPosition);
            SreTraceLogWriter traceLog = data.CurrentRow.TraceLog;

            if ((data.CurrentRow.HasAnyError()) &&
                (data.CurrentRow.IsValidForced == false))
            {
                data.CurrentRow.ColumnsSystem["IsValid"].Value = "false";
            }


            data.Job.PerformanceCounter.Stop(data.Job.JobIdentifier, RowPerformanceTaskNames.RowValidateMandatory, originalPosition);
        }
Beispiel #21
0
        protected override void Execute(CodeActivityContext context)
        {
            Job    job          = context.GetValue(this.Job);
            string variableName = context.GetValue(this.Name);

            if (job != null)
            {
                new Manager().DeletePersistentVariable(job.DataSource.Id, variableName);
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);

                new Manager().GetPersistentVariable(data.Job.DataSource.Id, variableName);
            }
        }
Beispiel #22
0
        protected override void Execute(CodeActivityContext context)
        {
            Job job = context.GetValue(this.Job);

            if (job != null)
            {
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);

                string defaultValue  = context.GetValue(this.DefaultValue);
                int    attributeType = context.GetValue(this.AttributeType);
                bool   ifNullOrEmpty = context.GetValue(this.IfNullOrEmpty);

                List <Services.Attribute> columns       = new List <Services.Attribute>();
                List <Services.Attribute> columnsSystem = new List <Services.Attribute>();

                if (!ifNullOrEmpty)
                {
                    columns       = data.CurrentRow.Columns;
                    columnsSystem = data.CurrentRow.ColumnsSystem;
                }
                else
                {
                    columns       = data.CurrentRow.Columns.Where(c => String.IsNullOrEmpty(c.Value)).ToList();
                    columnsSystem = data.CurrentRow.ColumnsSystem.Where(c => String.IsNullOrEmpty(c.Value)).ToList();
                }

                if (attributeType == 0) //all
                {
                    SetDefaultValueOfAColumn(columns, defaultValue);
                    SetDefaultValueOfAColumn(columnsSystem, defaultValue);
                }
                else if (attributeType == 1) //attribute
                {
                    SetDefaultValueOfAColumn(columns, defaultValue);
                }
                else if (attributeType == 2) //system attribute
                {
                    SetDefaultValueOfAColumn(columnsSystem, defaultValue);
                }
            }
        }
Beispiel #23
0
        protected override void Execute(CodeActivityContext context)
        {
            Job        job  = context.GetValue(this.Job);
            WorkerData data = context.GetValue(this.Data);

            IdpeRule rule     = null;
            int      ruleId   = context.GetValue(this.RuleId);
            string   ruleName = context.GetValue(this.RuleName);

            if (ruleId > 0)
            {
                rule = new Manager().GetRule(ruleId);
            }
            else if (!string.IsNullOrEmpty(ruleName))
            {
                rule = new Manager().GetRule(ruleName);
            }

            if (rule != null)
            {
                Stream          stream   = new MemoryStream(ASCIIEncoding.Default.GetBytes(rule.Xaml));
                DynamicActivity activity = ActivityXamlServices.Load(stream) as DynamicActivity;

                IDictionary <string, object> outArgs = null;
                Dictionary <string, object>  inArgs  = context.GetValue(this.InArgs);

                if (job != null)
                {
                    inArgs.Add("Job", job);
                }
                else
                {
                    inArgs.Add("Data", data);
                }

                WorkflowInvoker invoker = new WorkflowInvoker(activity);
                //outArgs = invoker.Invoke(inArgs);
                invoker.Invoke(inArgs);
                //context.SetValue(OutArgs, outArgs);
            }
            else
            {
                job.TraceError("Could not execute rule {0}, as it is not defined yet!", ruleName);
            }
        }
Beispiel #24
0
        protected override void Execute(CodeActivityContext context)
        {
            Job          job         = context.GetValue(this.Job);
            WorkerData   data        = context.GetValue(this.Data);
            RuleSetTypes ruleSetType = context.GetValue(this.RuleSetType);

            int originalPosition = context.GetValue(this.OriginalPostion);

            job = job == null ? data.Job : job;

            StartPerformanceCounter(job, ruleSetType, originalPosition);
            job.DataSource.BusinessRules.Execute(job, data, ruleSetType);
            //if (job.DataSource.BusinessRules.ExceptionOccurred)
            //{
            //    job.AbortRequested = true;
            //    job.AbortReason = Services.Job.AbortReasons.BusinessRuleFailed;
            //}
            StopPerformanceCounter(job, ruleSetType, originalPosition);
        }
Beispiel #25
0
        protected override void Execute(CodeActivityContext context)
        {
            DataSource dataSource = null;
            Job        job        = context.GetValue(this.Job);

            if (job != null)
            {
                dataSource = job.DataSource;
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);
                dataSource = data.Job.DataSource;
            }

            string subject = context.GetValue(this.Subject);
            string body    = context.GetValue(this.Body);

            new PostMan(dataSource, false).Send(body, subject, true);
        }
Beispiel #26
0
        protected override void Execute(CodeActivityContext context)
        {
            Job        job  = context.GetValue(this.Job);
            WorkerData data = context.GetValue(this.Data);
            string     name = context.GetValue(this.Name);
            CodeActivityTraceWriter writer = new CodeActivityTraceWriter(job, data);

            writer.WriteLine(string.Format("Clearing cache '{0}'...", name));

            object obj = Registry.Instance.CachedTables.GetValueOrDefault(name, null);

            if (obj != null)
            {
                if (obj is DataTable)
                {
                    ((DataTable)obj).Clear();
                    GC.Collect();
                    writer.WriteLine(string.Format("Cleared cache '{0}'...", name));
                }
            }
            Trace.Flush();
        }
Beispiel #27
0
        protected override void Execute(CodeActivityContext context)
        {
            WorkerData        data             = context.GetValue(this.Data);
            int               originalPosition = context.GetValue(this.OriginalPostion);
            SreTraceLogWriter traceLog         = data.CurrentRow.TraceLog;

            data.Job.PerformanceCounter.Start(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_ParseInit, originalPosition);
            AttributeParser dtp = new AttributeParser(data.Job.DataSource.Id, data.Job.DataSource.Name, data.CurrentRow.ColumnsSystem, data.Job.Parameters, data.Job.SqlClientManager, data.Job.DataSource.Keys);

            data.Job.PerformanceCounter.Stop(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_ParseInit, originalPosition);

            data.Job.PerformanceCounter.Start(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_AttributesSystem1, originalPosition);
            dtp.Parse(data.Job.DataSource.AttributesSystem, data.CurrentRow.ColumnsSystem, true, originalPosition, true);  //If anything can be processed without input attributes.
            data.Job.PerformanceCounter.Stop(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_AttributesSystem1, originalPosition);

            data.Job.PerformanceCounter.Start(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_Attributes, originalPosition);
            dtp.Parse(data.Job.DataSource.Attributes, data.CurrentRow.Columns, false, originalPosition, false);
            data.Job.PerformanceCounter.Stop(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_Attributes, originalPosition);

            data.Job.PerformanceCounter.Start(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_AttributesSystem2, originalPosition);
            dtp.OtherAvailableAttributes = data.CurrentRow.Columns;
            dtp.Parse(data.Job.DataSource.AttributesSystem, data.CurrentRow.ColumnsSystem, true, originalPosition, false);  //If anything to be processed with input attributes.
            data.Job.PerformanceCounter.Stop(data.Job.JobIdentifier, RowPerformanceTaskNames.ParseDataTypes_AttributesSystem2, originalPosition);
        }
Beispiel #28
0
        protected override void Execute(CodeActivityContext context)
        {
            Job    job = context.GetValue(this.Job);
            string connectionStringKeyName = context.GetValue(this.ConnectionStringKeyName);
            string query          = context.GetValue(this.Query);
            string columnName     = context.GetValue(ColumnName);
            bool   isSystemColumn = context.GetValue(IsSystemColumn);
            bool   throwErrorIfZeroRecordAffected = context.GetValue(ThrowErrorIfZeroRecordAffected);
            bool   silent = context.GetValue(Silent);

            int theResult = 0;

            if (job != null)
            {
                theResult = job.DataSource.ExecuteNonQuery(connectionStringKeyName, query, silent);
                context.SetValue(Result, theResult);

                if ((throwErrorIfZeroRecordAffected) && (theResult == 0))
                {
                    job.AddContainerError(-1, string.Format("Executed non-query but 0 records affected! Connection = '{0}', Query = '{1}'",
                                                            connectionStringKeyName, query));
                }
            }
            else
            {
                WorkerData data = context.GetValue(this.Data);
                theResult = data.Job.DataSource.ExecuteNonQuery(connectionStringKeyName, query, silent);
                context.SetValue(Result, theResult);

                if ((throwErrorIfZeroRecordAffected) && ((!(string.IsNullOrEmpty(columnName))) && (theResult == 0)))
                {
                    data.CurrentRow.AddError(string.Format("Executed non-query but 0 records affected! Connection = '{0}', Query = '{1}'",
                                                           connectionStringKeyName, query), columnName, isSystemColumn);
                }
            }
        }
Beispiel #29
0
        protected override void Execute(CodeActivityContext context)
        {
            Job job = context.GetValue(this.Job);

            if (job == null)
            {
                WorkerData data = context.GetValue(this.Data);
                data.ThrowErrorIfNull(this.DisplayName);
            }

            Object obj        = context.GetValue(this.Object);
            string objectType = context.GetValue(this.ObjectType);
            string code       = context.GetValue(this.Code);
            string additionalUsingNamespace = context.GetValue(this.AdditionalUsingNamespace);
            string additionalReferences     = context.GetValue(this.AdditionalReferences);


            CSharpCodeInformation csharpCodeInformation = new CSharpCodeInformation();

            csharpCodeInformation.CodeType = CSharpCodeInformation.CodeTypes.Execute;
            csharpCodeInformation.Code     = string.Format("(({0})obj).{1}", objectType, code);
            if (string.IsNullOrEmpty(additionalUsingNamespace))
            {
                csharpCodeInformation.AdditionalUsingNamespace = additionalUsingNamespace;
            }

            if (string.IsNullOrEmpty(additionalReferences))
            {
                csharpCodeInformation.AdditionalReferences = "System.Linq.dll";
            }

            ExecuteCSharpCode cSharpCodeExecutor = new ExecuteCSharpCode("Eyedia.IDPE.Common.CSharpCode", null,
                                                                         ExecuteCSharpCode.CompilerVersions.v40, csharpCodeInformation.GetReferencedAssemblies());

            cSharpCodeExecutor.Execute(csharpCodeInformation.CompleteCode, "Execute", new object[] { obj });
        }
Beispiel #30
0
        /// <summary>
        /// This method is used when 'Caller' wants to parse complete file at a time.
        /// </summary>
        /// <param name="xmlInput">Input data in xml format.</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>Output xml. for details, read documentation.</returns>
        public StringBuilder ProcessXml(string xmlInput, string processingBy)
        {
            int    dataSourceId   = 0;
            Job    job            = null;
            string dataSourceName = string.Empty;

            try
            {
                List <string> xmlValidationErrors   = new List <string>();
                List <string> xmlValidationWarnings = new List <string>();

                DataSource unknownDataSource = new DataSource(dataSourceId, dataSourceName);
                new SreXmlToDataTable(unknownDataSource).ParseDataSourceDetails(xmlInput, ref dataSourceId, ref dataSourceName, ref xmlValidationErrors, ref xmlValidationWarnings);

                if (string.IsNullOrEmpty(xmlInput))   //we can not accept empty string
                {
                    job.TraceError("Input xml was blank! Nothing to parse.");
                    return(new StringBuilder());
                }
                else if (xmlValidationErrors.Count > 0)
                {
                    job.TraceError("Input xml had validation errors! {0}", xmlValidationErrors.ToLine());
                    return(new StringBuilder());
                }

                job = new Job(dataSourceId, dataSourceName, processingBy);
                if (!job.IsValid)
                {
                    job.TraceInformation("Job could not be initialized, application is not defined. Application id ={0}, name = '{1}'", dataSourceId, dataSourceName);
                    return(new StringBuilder());
                }
                this.JobId = job.JobIdentifier.ToString();

                //WorkerData data = new WorkerData(newJob.DataSource, newJob.JobIdentifier, newJob.ProcessingBy);
                WorkerData data = new WorkerData(job, 0); //todo
                data.RowPosition = 1;
                job.Warnings.AddRange(data.Warnings);


                if ((job.CsvRows.Count == 0) ||
                    (job.CsvRows.Count == 1))
                {
                    //blank file
                    job.TraceInformation("System expects at least one request.");
                    return(new StringBuilder());
                }

                Registry.Instance.Entries.Add(job.JobIdentifier, job);
                ExecuteWorkerManager(job);

                //Get the results from worker (data)
                job.Errors.AddRange(data.Errors);                         //get all errors
                job.Warnings.AddRange(data.Warnings);
                job.BadDataInCsvFormat.AddRange(data.BadDataInCsvFormat); //bad csv data (invalid)
                Trace.Flush();
                return(job.DataSource.OutputWriter.GetOutput());
            }
            catch (BusinessException ex)
            {
                job.TraceInformation(ex.Message);   //It is actually not an exception or error
                new PostMan(job, false).Send(PostMan.__warningStartTag + ex.Message + PostMan.__warningEndTag);
                return(new StringBuilder());
            }
            catch (Exception ex)
            {
                string errorId      = Guid.NewGuid().ToString();
                string errorMessage = errorId + ex.ToString() + (ex.InnerException == null ? string.Empty : ex.InnerException.Message);
                job.TraceError("A server exception occurred. Please contact support. ErrorId={0}, Time={1}\n{2}", errorId, DateTime.Now, errorMessage);
                Trace.Flush();
                return(new StringBuilder());
            }
        }