Esempio n. 1
0
        private object GetParameterDateTimeValue(ProcessSchemaParameter parameter)
        {
            object value = GetParameterValue(parameter);

            if (value == null)
            {
                return(null);
            }
            var dateTime = (DateTime)value;

            if (dateTime == DateTime.MinValue)
            {
                return(null);
            }
            if (dateTime.Kind == DateTimeKind.Local)
            {
                value = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
            }
            var dataValueType = (DateTimeDataValueType)parameter.DataValueType;

            return(new {
                dataValueType = (int)dataValueType.ToEnum(),
                value = DateTimeDataValueType.Serialize(value, TimeZoneInfo.Utc)
            });
        }
        public CampaignNextFireTimeResponse GetCampaignNextFireTime(Guid campaignId, bool includeTimezoneOffset)
        {
            var campaignScheduler = new CampaignTimeScheduler(UserConnection);
            var nextFireTime      = campaignScheduler.GetCampaignNextFireTime(campaignId, includeTimezoneOffset);
            var response          = new CampaignNextFireTimeResponse {
                NextFireTime = DateTimeDataValueType.Serialize(nextFireTime, TimeZoneInfo.Utc)
            };

            return(response);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets Search execution info from log
        /// </summary>
        /// <param name="schemaName">Schema name.</param>
        /// <returns>Instance <see cref="DuplicatesSearchResponse"/> results info search process execution.</returns>
        public virtual DuplicatesSearchResponse GetInfo(string schemaName)
        {
            DuplicatesSearchResponse result = new DuplicatesSearchResponse();
            var esq = new EntitySchemaQuery(_userConnection.EntitySchemaManager, "DeduplicateExecLocker");

            esq.PrimaryQueryColumn.IsAlwaysSelect = true;
            esq.AddColumn(esq.RootSchema.GetPrimaryColumnName());
            EntitySchemaQueryColumn completedOnColumn  = esq.AddColumn("Conversation.ExecutedOn");
            EntitySchemaQueryColumn isInProgressColumn = esq.AddColumn("IsInProgress");

            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal,
                                                           "EntitySchemaName", new object[] { schemaName }));
            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal,
                                                           "Operation", new object[] { DeduplicationConsts.SearchOperationId }));
            EntityCollection esqCollection = esq.GetEntityCollection(_userConnection);
            bool             isExists      = CheckExistsSearchDuplicatesJob(schemaName);

            if (esqCollection.Any())
            {
                Entity   entity           = esqCollection[0];
                bool     isInProgress     = entity.GetTypedColumnValue <bool>(isInProgressColumn.Name) || isExists;
                DateTime completedOnValue = entity.GetTypedColumnValue <DateTime>(completedOnColumn.Name);
                result.Success  = true;
                result.Response = new Dictionary <string, string>()
                {
                    {
                        "LastExecutionDate",
                        DateTimeDataValueType.Serialize(completedOnValue, TimeZoneInfo.Utc)
                    },
                    { "IsInProgress", JsonConvert.SerializeObject(isInProgress) }
                };
            }
            else
            {
                if (isExists)
                {
                    result.Success  = true;
                    result.Response = new Dictionary <string, string>()
                    {
                        { "IsInProgress", JsonConvert.SerializeObject(true) }
                    };
                }
            }
            return(result);
        }
 /// <summary>
 /// Serializes value of the entity column.
 /// </summary>
 /// <param name="schemaColumn">Schema column.</param>
 /// <param name="columnValue">Column value.</param>
 /// <returns></returns>
 public virtual object SerializeEntityColumn(CoreEntitySchemaColumn schemaColumn, object columnValue)
 {
     if (schemaColumn == null || columnValue == null)
     {
         return(string.Empty);
     }
     if (schemaColumn.DataValueType is BooleanDataValueType)
     {
         return(DataTypeUtilities.ValueAsType <bool>(columnValue));
     }
     if (schemaColumn.IsLookupType)
     {
         var primaryColumnValue = Column.Parameter(DataTypeUtilities.ValueAsType <Guid>(columnValue));
         var referenceSchema    = schemaColumn.ReferenceSchema;
         var displayValueSelect =
             new Select(UserConnection)
             .Column(referenceSchema.PrimaryDisplayColumn.Name)
             .From(referenceSchema.Name)
             .Where(referenceSchema.PrimaryColumn.Name).IsEqual(primaryColumnValue) as Select;
         return(new {
             value = columnValue,
             displayValue = displayValueSelect?.ExecuteScalar <string>()
         });
     }
     if (schemaColumn.DataValueType is DateTimeDataValueType dateTimeDataValueType)
     {
         var dateTime = (DateTime)columnValue;
         if (dateTime == DateTime.MinValue)
         {
             return(null);
         }
         if (dateTime.Kind != DateTimeKind.Unspecified)
         {
             columnValue = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
         }
         string value = DateTimeDataValueType.Serialize(columnValue, TimeZoneInfo.Utc);
         return(new {
             dataValueType = (int)dateTimeDataValueType.ToEnum(),
             value
         });
     }
     return(DataTypeUtilities.ValueAsType <string>(columnValue));
 }
Esempio n. 5
0
        public List <ActualizedCondition> GetLastActualizedConditionResult(List <string> packageNames)
        {
            var result = new List <ActualizedCondition>();

            if (UserConnection != null)
            {
                foreach (string packageName in packageNames)
                {
                    int      currentConditionCount = UserConnection.LicHelper.GetLicPackageCurrentConditionResult(packageName);
                    DateTime currentConditionDate  = UserConnection.LicHelper.GetLicPackageCurrentConditionDate(packageName);
                    DateTime value     = TimeZoneInfo.ConvertTimeFromUtc(currentConditionDate.ToUniversalTime(), UserConnection.CurrentUser.TimeZone);
                    var      condition = new ActualizedCondition {
                        PackageName    = packageName,
                        ConditionCount = currentConditionCount,
                        ConditionDate  = DateTimeDataValueType.Serialize(value, TimeZoneInfo.Utc)
                    };
                    result.Add(condition);
                }
            }
            return(result);
        }
Esempio n. 6
0
 /// <summary>
 /// Create serialized date in Utc time zone.
 /// </summary>
 protected string GetSerializedDateTime(DateTime dateTime)
 {
     return(DateTimeDataValueType.Serialize(dateTime, TimeZoneInfo.Utc));
 }
Esempio n. 7
0
        public virtual string GenerateParameterConfigs(StringBuilder sb)
        {
            DataValueTypeManager dataValueTypeManager = UserConnection.DataValueTypeManager;

            sb.Append("{");
            bool isNotFirstProperty = false;
            var  processSchema      = Owner.Schema;
            var  schemaElement      = (ProcessSchemaUserTask)GetSchemaElement();

            foreach (ProcessSchemaParameter parameter in schemaElement.Parameters)
            {
                if (parameter.CreatedInSchemaUId != processSchema.UId)
                {
                    continue;
                }
                var    dataValueTypeItem = dataValueTypeManager.GetItemByUId(parameter.DataValueTypeUId);
                object parameterValue    = GetParameterValue(parameter);
                if (parameter.DataValueType.IsLookup)
                {
                    Guid guidPropertyValue = Guid.Empty;
                    if (parameterValue != null)
                    {
                        guidPropertyValue = (Guid)parameterValue;
                    }
                    if (guidPropertyValue == Guid.Empty)
                    {
                        AppendJSonProperty(sb, parameter.Name, null, 0, ref isNotFirstProperty);
                        continue;
                    }
                    string displayValue = string.Empty;
                    if (parameter.ParentMetaSchema == null)
                    {
                        parameter.ParentMetaSchema = processSchema;
                        Log.Warn("[AutoGeneratedPageUserTask]. Parameter metadata modified at runtime.");
                    }
                    if (parameter.ReferenceSchema.PrimaryDisplayColumn != null)
                    {
                        if (guidPropertyValue != Guid.Empty)
                        {
                            var entity = parameter.ReferenceSchema.CreateEntity(UserConnection);
                            entity.UseAdminRights = false;
                            entity.FetchFromDB(parameter.ReferenceSchema.PrimaryColumn, guidPropertyValue,
                                               new Collection <CoreEntitySchemaColumn> {
                                parameter.ReferenceSchema.PrimaryDisplayColumn
                            });
                            displayValue = entity.PrimaryDisplayColumnValue;
                        }
                    }
                    var value = new LookupColumnValue {
                        Value        = parameterValue?.ToString(),
                        DisplayValue = displayValue
                    };
                    AppendJSonProperty(sb, parameter.Name, value, 1, ref isNotFirstProperty);
                }
                else if (dataValueTypeItem.GroupName == "Dates")
                {
                    if (parameterValue == null)
                    {
                        AppendJSonProperty(sb, parameter.Name, parameterValue, 0, ref isNotFirstProperty);
                        continue;
                    }
                    var dateTime = (DateTime)parameterValue;
                    if (dateTime == DateTime.MinValue)
                    {
                        AppendJSonProperty(sb, parameter.Name, parameterValue, 0, ref isNotFirstProperty);
                        continue;
                    }
                    if (dateTime.Kind == DateTimeKind.Local)
                    {
                        parameterValue = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
                    }
                    string value = DateTimeDataValueType.Serialize(parameterValue, TimeZoneInfo.Utc);
                    string dateTimeObjectValue =
                        $"{{\"dataValueType\":{(int)parameter.DataValueType.ToEnum()}, \"value\":\"{value}\"}}";
                    AppendJSonProperty(sb, parameter.Name, dateTimeObjectValue, 3, ref isNotFirstProperty);
                }
                else if (dataValueTypeItem.Name == "Boolean")
                {
                    AppendJSonProperty(sb, parameter.Name, parameterValue, 2, ref isNotFirstProperty);
                }
                else
                {
                    byte type = parameterValue == null ? (byte)0 : (byte)1;
                    AppendJSonProperty(sb, parameter.Name, parameterValue, type, ref isNotFirstProperty);
                }
            }
            sb.Append("}");
            return(sb.ToString());
        }