Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
        public IDictionary <string, object> Execute(Job job, WorkerData data)
        {
            IDictionary <string, object> outArgs = null;
            Dictionary <string, object>  inArgs  = new Dictionary <string, object>();
            string preFix = string.Empty;

            try
            {
                if ((this.RuleSetType == RuleSetTypes.SqlPullInit) ||
                    (this.RuleSetType == RuleSetTypes.PreValidate) ||
                    (this.RuleSetType == RuleSetTypes.PostValidate))
                {
                    job.ThrowErrorIfNull(this.Activity.DisplayName);
                    inArgs.Add("Job", job);
                    preFix = ExtensionMethods.GetTracePrefix(job);
                }
                else
                {
                    data.ThrowErrorIfNull(this.Activity.DisplayName);
                    inArgs.Add("Data", data);
                    preFix = ExtensionMethods.GetTracePrefix(data);
                }
                if (inArgs.Keys.Count == 0)
                {
                    throw new ArgumentNullException(string.Format("{0}All Pre/PostValidate rules should have Job argument and all Row Preparing/Prepared/Validate should have Data as argument!",
                                                                  preFix));
                }


                if (this.Activity != null)
                {
                    if (string.IsNullOrEmpty(this.Activity.Name))
                    {
                        string datasourceName = string.Empty;
                        if (job != null)
                        {
                            datasourceName = job.DataSource.Name;
                        }
                        else if (data != null)
                        {
                            datasourceName = data.Job.DataSource.Name;
                        }

                        throw new Exception(string.Format("{0}Corrupt rule found while executing a '{1} type rule, associated with '{2}' datasource.", preFix, this.RuleSetType.ToString(), datasourceName));
                    }


                    string traceInfo = string.Format("{0}BRE - '{1}' - '{2}'", preFix, this.RuleSetType.ToString(), this.Activity.Name);
                    if (data != null)
                    {
                        data.CurrentRow.TraceLog.WriteLine(traceInfo);
                    }
                    else
                    {
                        ExtensionMethods.TraceInformation(traceInfo);  //pre/postvalidate
                    }
                    WorkflowInvoker invoker = new WorkflowInvoker(this.Activity);
                    outArgs = invoker.Invoke(inArgs);
                }
            }
            catch (BusinessException ex)
            {
                ExtensionMethods.TraceInformation(ex.Message);   //It is actually not an exception or error
                new PostMan(job, false).Send(PostMan.__warningStartTag + ex.Message + PostMan.__warningEndTag);
            }
            catch (Exception ex)
            {
                //There was some issue with the job and it was aborted/errored out, in that case we dont have log multiple errors
                if (!job.IsErrored)
                {
                    if (!job.AbortRequested)
                    {
                        job.IsErrored = true;
                        job.TraceError("{0}.Error. Job = '{1}', Rule Name = '{2}' Rule Type = '{3}'. {4}{5}",
                                       preFix, job.JobIdentifier, this.Activity.Name, this.RuleSetType, Environment.NewLine, ex.ToString());
                        Trace.Flush();
                        throw ex;
                    }
                }
            }

            return(outArgs);
        }