Example #1
0
        public virtual Terrasoft.Core.DB.Update CreateUpdateQuery(ProcessExecutingContext context)
        {
            var parameters = CreateParameters(context) as System.Collections.Generic.Dictionary <
                Guid, object>;

            if (parameters == null || parameters.Count == 0)
            {
                return(null);
            }
            var entity             = context.Process.GetPropertyValue("Entity") as Terrasoft.Core.Entities.Entity;
            var entitySchema       = entity.Schema;
            var parentEntityColumn = entitySchema.Columns.GetByUId(ParentEntityColumnUId);
            var parentEntitySchema = parentEntityColumn.ReferenceSchema;
            var update             = new Terrasoft.Core.DB.Update(context.UserConnection, parentEntitySchema.Name);

            foreach (var parameterKey in parameters.Keys)
            {
                var parentColumn     = parentEntitySchema.Columns.GetByUId(parameterKey);
                var parentColumnName = parentColumn.ColumnValueName;
                var parameterValue   = parameters[parameterKey];
                update.Set(parentColumnName, Terrasoft.Core.DB.Column.Parameter(parameterValue, parentColumn.DataValueType));
            }
            var primaryColumn     = parentEntitySchema.PrimaryColumn;
            var primaryColumnName = primaryColumn.ColumnValueName;

            update.Where(primaryColumnName).IsEqual(
                Terrasoft.Core.DB.Column.Parameter(entity.GetColumnValue(parentEntityColumn.ColumnValueName),
                                                   primaryColumn.DataValueType));
            return(update);
        }
Example #2
0
        public virtual void CloseCurrentJob()
        {
            var entitySchemaManager = UserConnection.EntitySchemaManager;
            var schema = entitySchemaManager.GetInstanceByName("ContactCareer");
            var update = new Terrasoft.Core.DB.Update(UserConnection, schema.Name);
            var column = schema.Columns.GetByName("Current");

            update.Set(column.ColumnValueName, Terrasoft.Core.DB.Column.Parameter(false, column.DataValueType));
            column = schema.Columns.GetByName("DueDate");
            update.Set(column.ColumnValueName, Terrasoft.Core.DB.Column.Parameter(DateTime.Now, column.DataValueType));
            column = schema.Columns.GetByName("Contact");
            update.Where(column.ColumnValueName).IsEqual(Terrasoft.Core.DB.Column.Parameter(Entity.PrimaryColumnValue, column.DataValueType));
            column = schema.Columns.GetByName("Current");
            update.And(column.ColumnValueName).IsEqual(Terrasoft.Core.DB.Column.Parameter(true, column.DataValueType));
            column = schema.Columns.GetByName("Primary");
            update.And(column.ColumnValueName).IsEqual(Terrasoft.Core.DB.Column.Parameter(true, column.DataValueType));
            update.Execute();
        }