Exemplo n.º 1
0
        private static bool GetIsNotEmptySysSettingsValue(UserConnection userConnection, string sysSettingCode)
        {
            object value;

            if (!SysSettings.TryGetValue(userConnection, sysSettingCode, out value) ||
                string.IsNullOrEmpty(value as string))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        private static bool GetIsValidRequiredLDAPSettings(UserConnection userConnection)
        {
            var requiredLdapSettingsCodeCollection = new List <string> {
                LdapServerSysSettingCode,
                LdapServerLoginSysSettingCode,
                LdapServerPasswordSysSettingCode,
                LdapUsersEntrySysSettingCode,
                LdapGroupsEntrySysSettingCode,
                LdapUsersFilterSysSettingCode,
                LdapGroupsFilterSysSettingCode,
                LdapUsersInGroupFilterSysSettingCode,
                LdapUserLoginAttributeSysSettingCode,
                LdapUserIdentityAttributeSysSettingCode,
                LdapGroupIdentityAttributeSysSettingCode,
                LdapGroupNameAttributeSysSettingCode,
                LdapEntryModifiedOnAttributeSysSettingCode,
                LdapUserFullNameAttributeSysSettingCode
            };

            foreach (string sysSettingCode in requiredLdapSettingsCodeCollection)
            {
                if (!GetIsNotEmptySysSettingsValue(userConnection, sysSettingCode))
                {
                    return(false);
                }
            }
            object intervalValue;

            if (!SysSettings.TryGetValue(userConnection, LdapSynchIntervalSysSettingCode, out intervalValue))
            {
                return(false);
            }
            bool hasIntervalSettingValue = false;

            if (intervalValue is int)
            {
                hasIntervalSettingValue = (int)intervalValue > 0;
            }
            else if (intervalValue is decimal)
            {
                hasIntervalSettingValue = (decimal)intervalValue > 0;
            }
            if (!hasIntervalSettingValue)
            {
                return(false);
            }
            AuthType authType = GetAuthType(userConnection);

            if (authType == AuthType.Kerberos)
            {
                return(GetIsNotEmptySysSettingsValue(userConnection, LdapKeyDistributionCenterSysSettingCode));
            }
            return(true);
        }
Exemplo n.º 3
0
 private static DateTime GetEntryMaxModifiedOn(UserConnection userConnection)
 {
     if (!SysSettings.TryGetValue(userConnection, LdapEntryMaxModifiedOnSysSettingCode,
                                  out var entryMaxModifiedOn))
     {
         return(DateTime.MinValue);
     }
     return(entryMaxModifiedOn != null
                         ? TimeZoneInfo.ConvertTimeToUtc((DateTime)entryMaxModifiedOn, userConnection.CurrentUser.TimeZone)
                         : DateTime.MinValue);
 }
Exemplo n.º 4
0
        protected override bool InternalExecute(ProcessExecutingContext context)
        {
            IForeignExchange foreignExchange = Factories.ClassFactory.Get <IForeignExchange>();

            string currencyCode = GetShortCurrencyCode(Currency);

            IBankResult result = default;

            if (currencyCode == "MXN" && SysSettings.TryGetValue(UserConnection, "bmxToken", out object value))
            {
                string token = value.ToString();
                result = foreignExchange.GetRate(currencyCode, Date, value.ToString());
            }
            else
            {
                result = foreignExchange.GetRate(currencyCode, Date);
            }

            ExchangeRate    = result.ExchangeRate;
            ObservationDate = result.RateDate;
            BankName        = result.BankName;
            return(true);
        }
Exemplo n.º 5
0
        private ResponceApplyChanges ApplyColumnsChanges(Guid entitySchemaId, List <ChangedColumn> changedColumns)
        {
            ResponceApplyChanges responce = new ResponceApplyChanges();

            responce.success = true;

            var entitySchemaManager = UserConnection.EntitySchemaManager;

            string baseCaption      = string.Empty;
            var    baseEntitySchema = entitySchemaManager.FindItemByUId(entitySchemaId);

            if (baseEntitySchema != null)
            {
                baseCaption = baseEntitySchema.Caption;
            }
            ISchemaManagerItem designSchemaItem = entitySchemaManager.DesignItemInCustomPackage(UserConnection, entitySchemaId);

            if (baseCaption != string.Empty)
            {
                designSchemaItem.Caption = baseCaption;
            }
            var entitySchema = designSchemaItem.Instance as EntitySchema;

            if (baseCaption != string.Empty)
            {
                entitySchema.Caption = baseCaption;
            }

            Dictionary <string, string>       newLookupsCollection         = new Dictionary <string, string>();
            Dictionary <string, EntitySchema> newLookupsEntitiesCollection = new Dictionary <string, EntitySchema>();

            var newLookups = changedColumns.Where(c => c.IsNewLookup && entitySchema.Columns.FindByName(c.Name) == null);

            if (newLookups != null)
            {
                foreach (ChangedColumn item in newLookups)
                {
                    var dictionaryEntitySchema = entitySchemaManager.FindItemByName(item.ReferenceSchemaName);
                    if (dictionaryEntitySchema != null)
                    {
                        responce.Code    = "Error.Dictionary.Exists";
                        responce.Message = item.ReferenceSchemaName;
                        responce.success = false;
                        return(responce);
                    }
                    newLookupsCollection.Add(item.ReferenceSchemaName, item.ReferenceSchemaCaption);
                }
            }
            if (newLookupsCollection.Count > 0)
            {
                var sysFolderId = (new Select(UserConnection)
                                   .Column("Id")
                                   .From("SysSchemaFolder")
                                   .Where("ParentId").IsNull() as Select)
                                  .ExecuteScalar <Guid>();
                var baseLookupEntitySchema = entitySchemaManager.GetInstanceByName("BaseLookup");
                var sysLookup       = entitySchemaManager.GetInstanceByName("SysLookup");
                var customPackageId = WorkspaceUtilities.ForceGetCustomPackageUId(UserConnection);
                foreach (var item in newLookupsCollection)
                {
                    var    lookupEntitySchemaItemUId = Guid.NewGuid();
                    object schemaNamePrefix;
                    var    lookupSchemaName = item.Key;
                    if (SysSettings.TryGetValue(UserConnection, "SchemaNamePrefix", out schemaNamePrefix) &&
                        !schemaNamePrefix.Equals(string.Empty))
                    {
                        lookupSchemaName = string.Concat(schemaNamePrefix, lookupSchemaName);
                    }
                    ISchemaManagerItem <EntitySchema> lookupEntitySchemaItem = entitySchemaManager.CreateSchema(lookupSchemaName,
                                                                                                                baseLookupEntitySchema, UserConnection, lookupEntitySchemaItemUId, false);
                    lookupEntitySchemaItem.Caption = item.Value;
                    var lookupEntitySchema = (EntitySchema)lookupEntitySchemaItem.Instance;
                    lookupEntitySchema.Caption = item.Value;
                    entitySchemaManager.SaveDesignedItemInSessionData(lookupEntitySchemaItem);
                    entitySchemaManager.SaveDesignedItemFolderIdInSessionData(UserConnection, lookupEntitySchemaItemUId, sysFolderId);
                    entitySchemaManager.SaveDesignedItemPackageUIdInSessionData(UserConnection, lookupEntitySchemaItemUId, customPackageId);
                    entitySchemaManager.SaveSchema(lookupEntitySchemaItemUId, UserConnection);
                    try {
                        responce = ApplyDbChanges(responce, lookupEntitySchema);
                    } catch (Exception) {
                        responce.success = false;
                        responce.Code    = "Error.DbMetaActions.LookupApply";
                        return(responce);
                    }
                    newLookupsEntitiesCollection.Add(item.Key, lookupEntitySchema);
                    Entity sysLookupEntity = sysLookup.CreateEntity(UserConnection);
                    sysLookupEntity.SetColumnValue("Id", Guid.NewGuid());
                    sysLookupEntity.SetColumnValue("Name", item.Value);
                    sysLookupEntity.SetColumnValue("Description", string.Empty);
                    sysLookupEntity.SetColumnValue("SysFolderId", new Guid("80AB12C2-F36B-1410-A883-16D83CAB0980"));                     //// SysLookupFolder - General
                    sysLookupEntity.SetColumnValue("SysEntitySchemaUId", lookupEntitySchema.UId);
                    sysLookupEntity.SetColumnValue("ProcessListeners", 0);
                    sysLookupEntity.Save();
                }
            }

            foreach (ChangedColumn item in changedColumns)
            {
                EntitySchemaColumn column = entitySchema.Columns.FindByName(item.Name);
                if (column == null)
                {
                    DataValueType dataValueType = GetDataValueTypeByTypeName(item.TypeGroupName, item.TypeName);
                    column                      = entitySchema.Columns.CreateItem();
                    column.UId                  = Guid.NewGuid();
                    column.UsageType            = EntitySchemaColumnUsageType.General;
                    column.Name                 = item.Name;
                    column.DataValueType        = dataValueType;
                    column.DataValueTypeManager = dataValueType.DataValueTypeManager;
                    column.DataValueTypeUId     = dataValueType.UId;
                    if (dataValueType.IsLookup || dataValueType.IsMultiLookup)
                    {
                        EntitySchema referenceEntitySchema;
                        if (item.IsNewLookup)
                        {
                            referenceEntitySchema = newLookupsEntitiesCollection.First(l => l.Key == item.ReferenceSchemaName).Value;
                        }
                        else
                        {
                            referenceEntitySchema = entitySchemaManager.GetInstanceByName(item.ReferenceSchemaName);
                        }
                        column.ReferenceSchema    = referenceEntitySchema;
                        column.ReferenceSchemaUId = referenceEntitySchema.UId;
                    }
                    entitySchema.Columns.Add(column);
                }
                column.Caption         = item.Caption;
                column.IsSimpleLookup  = item.IsEnum;
                column.RequirementType = item.IsRequired ?
                                         EntitySchemaColumnRequirementType.ApplicationLevel : EntitySchemaColumnRequirementType.None;
                column.IsMultiLineText = item.IsMultiline;
            }

            entitySchemaManager.SaveDesignedItemInSessionData(UserConnection, entitySchema as MetaSchema, entitySchema.UId);

            try {
                entitySchemaManager.SaveSchema(entitySchema.UId, UserConnection, false);
                responce         = ApplyDbChanges(responce, entitySchema, true);
                responce.success = true;
            } catch (Exception) {
                responce.success = false;
                responce.Code    = "Error.DbMetaActions.EntitySchemaApply";
            }
            return(responce);
        }