コード例 #1
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);
            }
        }
コード例 #2
0
        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
                {
                }
            }
        }
コード例 #3
0
ファイル: AddError.cs プロジェクト: eyedia/idpe
        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);
                }
            }
        }
コード例 #4
0
ファイル: WriteTraceToCurrentRow.cs プロジェクト: eyedia/idpe
        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));
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
0
ファイル: DeletePersistVariable.cs プロジェクト: eyedia/idpe
        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);
            }
        }
コード例 #7
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);
                }
            }
        }
コード例 #8
0
ファイル: SendEmail.cs プロジェクト: eyedia/idpe
        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);
        }
コード例 #9
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 });
        }
コード例 #10
0
ファイル: BulkInsert.cs プロジェクト: eyedia/idpe
        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;
            }

            bool      createTable             = context.GetValue(this.CreateTable);
            DataTable table                   = context.GetValue(this.Table);
            string    connectionStringKeyName = context.GetValue(this.ConnectionStringKeyName);
            string    tableName               = context.GetValue(this.TableName);
            string    specificColumnTypes     = context.GetValue(this.SpecificColumnTypes);
            int       timeOut                 = context.GetValue(this.TimeOut);

            if (timeOut == 0)
            {
                timeOut = 5;//default
            }
            int batchSize = context.GetValue(this.BatchSize);

            if (batchSize == 0)
            {
                batchSize = 5000;//default
            }
            IdpeKey connectionStringKey = null;

            if (string.IsNullOrEmpty(connectionStringKeyName))
            {
                //default is repository database
                connectionStringKey       = new IdpeKey();
                connectionStringKey.Name  = "cs";
                connectionStringKey.Type  = (int)Information.EyediaCoreConfigurationSection.Database.DatabaseType.GetSreType();
                connectionStringKey.Value = ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ToString();
            }
            else
            {
                connectionStringKey = dataSource.Keys.GetKey(connectionStringKeyName);
                if (connectionStringKey == null)
                {
                    throw new Exception(string.Format("Can not load data table, the connection string was null! Connection string key name was '{0}'"
                                                      , connectionStringKeyName));
                }
            }
            try
            {
                #region Bulk Insert
                bool keepNulls = true;

                SqlCeBulkCopyOptions options = new SqlCeBulkCopyOptions();
                if (keepNulls)
                {
                    options = options |= SqlCeBulkCopyOptions.KeepNulls;
                }

                DatabaseTypes databaseType = connectionStringKey.GetDatabaseType();
                if (databaseType == DatabaseTypes.SqlServer)
                {
                    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionStringKey.Value))
                    {
                        bulkCopy.BulkCopyTimeout = timeOut * 60;
                        bulkCopy.BatchSize       = batchSize;
                        for (int c = 0; c < table.Columns.Count; c++)
                        {
                            bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(table.Columns[c].ColumnName, table.Columns[c].ColumnName));
                        }
                        bulkCopy.DestinationTableName = tableName;
                        bulkCopy.WriteToServer(table);
                    }
                }

                else
                {
                    if (createTable)
                    {
                        SqlCeTableCreator.Create(table, new System.Data.SqlServerCe.SqlCeConnection(connectionStringKey.Value), tableName, specificColumnTypes);
                    }

                    using (SqlCeBulkCopy bulkCopy = new SqlCeBulkCopy(connectionStringKey.Value, options))
                    {
                        bulkCopy.BulkCopyTimeout = timeOut * 60;
                        bulkCopy.BatchSize       = batchSize;
                        for (int c = 0; c < table.Columns.Count; c++)
                        {
                            bulkCopy.ColumnMappings.Add(new SqlCeBulkCopyColumnMapping(table.Columns[c].ColumnName, table.Columns[c].ColumnName));
                        }
                        bulkCopy.DestinationTableName = tableName;
                        bulkCopy.WriteToServer(table);
                    }
                }

                #endregion Bulk Insert
            }
            catch (Exception ex)
            {
                context.SetValue(ErrorMessage, ex.Message);
            }
        }
コード例 #11
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);
        }