コード例 #1
0
        private static void AddUserPhonesAttributes(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield phonesValue = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "value",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Value",
                AttributeNamePart = null
            };

            AdapterCustomTypeList <Phone> phonesType = new AdapterCustomTypeList <Phone>
            {
                Api           = "user",
                AttributeName = "phones",
                Fields        = new List <AdapterSubfield>()
                {
                    phonesValue
                },
                FieldName              = "phones",
                PropertyName           = "Phones",
                IsPrimaryCandidateType = true,
                KnownTypes             = config.PhonesAttributeFixedTypes?.ToList(),
                SupportsPatch          = false
            };

            type.AttributeAdapters.Add(phonesType);
        }
コード例 #2
0
        private static void AddUserExternalIds(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield value = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "value",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Value",
                AttributeNamePart = null
            };

            AdapterCustomTypeList <ExternalID> customType = new AdapterCustomTypeList <ExternalID>
            {
                Api           = "user",
                AttributeName = "externalIds",
                Fields        = new List <AdapterSubfield>()
                {
                    value
                },
                FieldName     = "externalIds",
                PropertyName  = "ExternalIds",
                KnownTypes    = config.ExternalIDsAttributeFixedTypes?.ToList(),
                SupportsPatch = false
            };

            type.AttributeAdapters.Add(customType);
        }
コード例 #3
0
 public ApiInterfaceContact(string domain, string dnPrefix, MASchemaType type, IManagementAgentParameters config)
 {
     this.domain     = domain;
     this.SchemaType = type;
     this.dnPrefix   = dnPrefix;
     this.config     = config;
 }
コード例 #4
0
        private void AddContactEmailAttributes(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield address = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "address",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Address",
                AttributeNamePart = null
            };

            AdapterGDataCommonAttributeList <EMail> customType = new AdapterGDataCommonAttributeList <EMail>
            {
                Api           = "contact",
                AttributeName = "email",
                Fields        = new List <AdapterSubfield>()
                {
                    address
                },
                FieldName     = "email",
                PropertyName  = "Emails",
                KnownTypes    = config.EmailsAttributeFixedTypes?.ToList(),
                SupportsPatch = false,
                IsEmpty       = (t) => string.IsNullOrWhiteSpace(t.Address),
                KnownRels     = new Dictionary <string, string>()
                {
                    { "http://schemas.google.com/g/2005#work", "work" }, { "http://schemas.google.com/g/2005#home", "home" }, { "http://schemas.google.com/g/2005#other", "other" }
                }
            };

            type.AttributeAdapters.Add(customType);
        }
        public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config)
        {
            MASchemaType type = new MASchemaType
            {
                AttributeAdapters = new List <IAttributeAdapter>(),
                Name = "feature",
                AnchorAttributeNames = new[] { "id" },
                SupportsPatch        = true,
            };

            type.ApiInterface = new ApiInterfaceFeature(config.CustomerID, type, config);

            type.AttributeAdapters.Add(new AdapterPropertyValue
            {
                AttributeType = AttributeType.String,
                FieldName     = "name",
                IsMultivalued = false,
                Operation     = AttributeOperation.ImportOnly,
                AttributeName = "id",
                PropertyName  = "Name",
                Api           = "feature",
                SupportsPatch = true,
                IsAnchor      = true
            });

            yield return(type);
        }
コード例 #6
0
        private void AddContactExternalIds(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield value = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "value",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Value",
                AttributeNamePart = null
            };

            AdapterGDataSimpleAttributeList <ExternalId> customType = new AdapterGDataSimpleAttributeList <ExternalId>
            {
                Api           = "contact",
                AttributeName = "externalIds",
                Fields        = new List <AdapterSubfield>()
                {
                    value
                },
                FieldName     = "externalIds",
                PropertyName  = "ExternalIds",
                KnownTypes    = config.ExternalIDsAttributeFixedTypes?.ToList(),
                SupportsPatch = false,
                KnownRels     = new HashSet <string>()
                {
                    "account", "customer", "network", "organization"
                }
            };

            type.AttributeAdapters.Add(customType);
        }
コード例 #7
0
        private static void AddGmailSettingsAttributes(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterCollection <string> delegates = new AdapterCollection <string>
            {
                AttributeType = AttributeType.Reference,
                FieldName     = null,
                Operation     = AttributeOperation.ImportExport,
                AttributeName = $"{type.Name}_{SchemaConstants.Delegate}",
                PropertyName  = "Delegates",
                Api           = "userdelegates",
                SupportsPatch = true,
            };

            type.AttributeAdapters.Add(delegates);

            AdapterCollection <string> sendas = new AdapterCollection <string>
            {
                AttributeType = AttributeType.String,
                FieldName     = null,
                Operation     = AttributeOperation.ImportExport,
                AttributeName = $"{type.Name}_{SchemaConstants.SendAs}",
                PropertyName  = "SendAs",
                Api           = "usersendas",
                SupportsPatch = true,
            };

            type.AttributeAdapters.Add(sendas);
        }
コード例 #8
0
        public static MASchemaTypes GetSchema(IManagementAgentParameters config)
        {
            MASchemaTypes types = new MASchemaTypes();

            Assembly assembly = Assembly.GetExecutingAssembly();

            foreach (TypeInfo type in assembly.DefinedTypes)
            {
                if (!type.ImplementedInterfaces.Contains(typeof(ISchemaTypeBuilder)))
                {
                    continue;
                }

                ISchemaTypeBuilder builder = (ISchemaTypeBuilder)Activator.CreateInstance(type);
                foreach (MASchemaType schemaType in builder.GetSchemaTypes(config))
                {
                    if (schemaType != null)
                    {
                        types.Add(schemaType);
                    }
                }
            }

            return(types);
        }
コード例 #9
0
        public ApiInterfaceCalendar(string customerID, MASchemaType type, IManagementAgentParameters config)
        {
            this.SchemaType = type;
            this.customerID = customerID;
            this.config     = config;

            this.internalInterfaces = new ApiInterfaceKeyedCollection
            {
                new ApiInterfaceCalendarAcl(config),
            };
        }
コード例 #10
0
        public ApiInterfaceGroup(MASchemaType type, IManagementAgentParameters config)
        {
            this.SchemaType = type;
            this.config     = config;

            this.internalInterfaces = new ApiInterfaceKeyedCollection
            {
                new ApiInterfaceGroupAliases(config),
                new ApiInterfaceGroupMembership(config),
                new ApiInterfaceGroupSettings(config)
            };
        }
コード例 #11
0
        public ApiInterfaceCourse(MASchemaType type, IManagementAgentParameters config)
        {
            this.SchemaType = type;
            this.config     = config;

            this.internalInterfaces = new ApiInterfaceKeyedCollection
            {
                new ApiInterfaceCourseStudents(config, this),
                new ApiInterfaceCourseTeachers(config, this)
            };

            this.UserMappingCache = new ConcurrentDictionary <string, string>();
        }
コード例 #12
0
        private void AddContactPhones(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield phonesValue = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "value",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Value",
                AttributeNamePart = null
            };

            AdapterGDataCommonAttributeList <PhoneNumber> phonesType = new AdapterGDataCommonAttributeList <PhoneNumber>
            {
                Api           = "contact",
                AttributeName = "phones",
                Fields        = new List <AdapterSubfield>()
                {
                    phonesValue
                },
                FieldName     = "phones",
                PropertyName  = "Phonenumbers",
                KnownTypes    = config.PhonesAttributeFixedTypes?.ToList(),
                SupportsPatch = false,
                IsEmpty       = (t) => string.IsNullOrWhiteSpace(t.Value),
                KnownRels     = new Dictionary <string, string>()
                {
                    { "http://schemas.google.com/g/2005#work_pager", "work_pager" },
                    { "http://schemas.google.com/g/2005#work_mobile", "work_mobile" },
                    { "http://schemas.google.com/g/2005#work", "work" },
                    { "http://schemas.google.com/g/2005#tty_tdd", "tty_tdd" },
                    { "http://schemas.google.com/g/2005#telex", "telex" },
                    { "http://schemas.google.com/g/2005#radio", "radio" },
                    { "http://schemas.google.com/g/2005#pager", "pager" },
                    { "http://schemas.google.com/g/2005#other_fax", "other_fax" },
                    { "http://schemas.google.com/g/2005#mobile", "mobile" },
                    { "http://schemas.google.com/g/2005#main", "main" },
                    { "http://schemas.google.com/g/2005#isdn", "isdn" },
                    { "http://schemas.google.com/g/2005#home_fax", "home_fax" },
                    { "http://schemas.google.com/g/2005#home", "home" },
                    { "http://schemas.google.com/g/2005#fax", "fax" },
                    { "http://schemas.google.com/g/2005#company_main", "company_main" },
                    { "http://schemas.google.com/g/2005#car", "car" },
                    { "http://schemas.google.com/g/2005#callback", "callback" },
                    { "http://schemas.google.com/g/2005#assistant", "assistant" },
                }
            };

            type.AttributeAdapters.Add(phonesType);
        }
コード例 #13
0
        public ApiInterfaceUser(MASchemaType type, IManagementAgentParameters config)
        {
            this.InternalInterfaces = new ApiInterfaceKeyedCollection
            {
                new ApiInterfaceUserAliases(config),
                new ApiInterfaceUserMakeAdmin(config),
                new ApiInterfaceUserDelegates(config, type.Name),
                new ApiInterfaceUserSendAs(config, type.Name)
            };

            this.ObjectClass = type.Name;
            this.SchemaType  = type;
            this.config      = config;
        }
コード例 #14
0
        private void AddContactIms(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield im = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "address",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Address",
                AttributeNamePart = "address"
            };

            AdapterSubfield protocol = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "protocol",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Protocol",
                AttributeNamePart = "protocol"
            };

            AdapterGDataCommonAttributeList <IMAddress> customType = new AdapterGDataCommonAttributeList <IMAddress>
            {
                Api           = "contact",
                AttributeName = "ims",
                Fields        = new List <AdapterSubfield>()
                {
                    im, protocol
                },
                FieldName     = "ims",
                PropertyName  = "IMs",
                KnownTypes    = config.IMsAttributeFixedTypes?.ToList(),
                SupportsPatch = false,
                IsEmpty       = (t) => string.IsNullOrWhiteSpace(t.Address),

                KnownRels = new Dictionary <string, string>()
                {
                    { "http://schemas.google.com/g/2005#work", "work" },
                    { "http://schemas.google.com/g/2005#netmeeting", "netmeeting" },
                    { "http://schemas.google.com/g/2005#home", "home" }
                }
            };

            type.AttributeAdapters.Add(customType);
        }
コード例 #15
0
        public static CSEntryChange GetCSEntryChange(object source, SchemaType type, IManagementAgentParameters config)
        {
            MASchemaType maType = ManagementAgent.Schema[type.Name];

            CSEntryChange csentry = CSEntryChange.Create();

            csentry.ObjectModificationType = ObjectModificationType.Add;
            csentry.ObjectType             = type.Name;

            foreach (string anchorAttributeName in maType.AnchorAttributeNames)
            {
                string anchorValue = maType.ApiInterface.GetAnchorValue(anchorAttributeName, source);

                if (anchorValue == null)
                {
                    throw new AttributeNotPresentException(anchorAttributeName);
                }

                csentry.CreateAttributeAdd(anchorAttributeName, anchorValue);
            }

            try
            {
                csentry.DN = maType.ApiInterface.GetDNValue(source);

                foreach (AttributeChange change in maType.ApiInterface.GetChanges(csentry.DN, csentry.ObjectModificationType, type, source))
                {
                    csentry.AttributeChanges.Add(change);
                }

                Trace.WriteLine($"Created CSEntryChange for {csentry.ObjectType} {csentry.DN}");
            }
            catch (Exception ex)
            {
                Logging.Logger.WriteException(ex);
                csentry.ErrorCodeImport = MAImportError.ImportErrorCustomContinueRun;
                csentry.ErrorDetail     = ex.StackTrace;
                csentry.ErrorName       = ex.Message;
                Trace.WriteLine($"Error creating CSEntryChange for {csentry.ObjectType} {csentry.DN} - {ex.Message}");
            }

            return(csentry);
        }
コード例 #16
0
        public void OpenExportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenExportConnectionRunStep exportRunStep)
        {
            this.cancellationToken = new CancellationTokenSource();
            this.Configuration     = new ManagementAgentParameters(configParameters);
            this.DeltaPath         = Path.Combine(MAUtils.MAFolder, ManagementAgent.DeltaFile);

            Logger.LogPath = this.Configuration.MALogFile;
            Logger.WriteLine("Opening export connection");
            this.SetHttpDebugMode();

            this.timer = new Stopwatch();

            ManagementAgent.Schema    = SchemaBuilder.GetSchema(this.Configuration);
            this.operationSchemaTypes = types;

            CSEntryChangeQueue.LoadQueue(this.DeltaPath);

            this.LoadInternalDomainsIfRequired(types);
            this.timer.Start();
        }
コード例 #17
0
        public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config)
        {
            MASchemaType type = new MASchemaType
            {
                AttributeAdapters = new List <IAttributeAdapter>(),
                Name = SchemaConstants.User,
                AnchorAttributeNames = new[] { "id" },
                SupportsPatch        = true,
            };

            this.BuildBaseSchema(type, config);

            if (config.EnableAdvancedUserAttributes)
            {
                SchemaBuilderUsers.AddGmailSettingsAttributes(type, config);
            }

            yield return(type);

            if (!config.SchemaService.HasSchema(config.CustomerID, SchemaConstants.CustomGoogleAppsSchemaName))
            {
                yield break;
            }

            foreach (string objectType in config.CustomUserObjectClasses)
            {
                type = new MASchemaType
                {
                    AttributeAdapters = new List <IAttributeAdapter>(),
                    Name = objectType,
                    AnchorAttributeNames = new[] { "id" },
                    SupportsPatch        = true,
                };

                this.BuildBaseSchema(type, config);
                SchemaBuilderUsers.AddGmailSettingsAttributes(type, config);

                yield return(type);
            }
        }
コード例 #18
0
        private static void AddUserWebSites(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield webSiteValue = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "value",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Value",
                AttributeNamePart = null
            };

            AdapterSubfield webSitePrimary = new AdapterSubfield
            {
                AttributeType     = AttributeType.Boolean,
                FieldName         = "primary",
                IsMultivalued     = false,
                PropertyName      = "Primary",
                Operation         = AttributeOperation.ImportExport,
                AttributeNamePart = "primary"
            };

            AdapterCustomTypeList <ManagedObjects.Website> webSiteType = new AdapterCustomTypeList <Website>
            {
                Api           = "user",
                AttributeName = "websites",
                Fields        = new List <AdapterSubfield>()
                {
                    webSitePrimary, webSiteValue
                },
                FieldName              = "websites",
                PropertyName           = "Websites",
                IsPrimaryCandidateType = true,
                KnownTypes             = config.WebsitesAttributeFixedTypes?.ToList(),
                SupportsPatch          = false
            };

            type.AttributeAdapters.Add(webSiteType);
        }
コード例 #19
0
        private static void AddUserIms(MASchemaType type, IManagementAgentParameters config)
        {
            AdapterSubfield im = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "im",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "IMAddress",
                AttributeNamePart = "address"
            };

            AdapterSubfield protocol = new AdapterSubfield
            {
                AttributeType     = AttributeType.String,
                FieldName         = "protocol",
                IsMultivalued     = false,
                Operation         = AttributeOperation.ImportExport,
                PropertyName      = "Protocol",
                AttributeNamePart = "protocol"
            };

            AdapterCustomTypeList <IM> customType = new AdapterCustomTypeList <IM>
            {
                Api           = "user",
                AttributeName = "ims",
                Fields        = new List <AdapterSubfield>()
                {
                    im, protocol
                },
                FieldName              = "ims",
                PropertyName           = "Ims",
                IsPrimaryCandidateType = true,
                KnownTypes             = config.IMsAttributeFixedTypes?.ToList(),
                SupportsPatch          = false
            };

            type.AttributeAdapters.Add(customType);
        }
コード例 #20
0
        public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            try
            {
                this.cancellationToken = new CancellationTokenSource();
                this.Configuration     = new ManagementAgentParameters(configParameters);
                Logger.LogPath         = this.Configuration.MALogFile;

                this.importRunStep        = importRunStep;
                this.operationSchemaTypes = types;
                this.timer = new Stopwatch();

                this.DeltaPath = Path.Combine(MAUtils.MAFolder, ManagementAgent.DeltaFile);

                Logger.WriteLine("Opening import connection. Page size {0}", this.importRunStep.PageSize);

                if (this.importRunStep.ImportType == OperationType.Delta)
                {
                    CSEntryChangeQueue.LoadQueue(this.DeltaPath);
                    Logger.WriteLine("Delta full import from file started. {0} entries to import", CSEntryChangeQueue.Count);
                }
                else
                {
                    this.OpenImportConnectionFull(types);

                    Logger.WriteLine("Background full import from Google started");
                }

                this.timer.Start();
                return(new OpenImportConnectionResults("<placeholder>"));
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
                throw;
            }
        }
 public ApiInterfaceUserAliases(IManagementAgentParameters config)
 {
     this.config = config;
 }
コード例 #22
0
 public ApiInterfaceGroupSettings(IManagementAgentParameters config)
 {
     this.config = config;
 }
コード例 #23
0
        public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config)
        {
            MASchemaType type = new MASchemaType
            {
                AttributeAdapters = new List <IAttributeAdapter>(),
                Name = "group",
                AnchorAttributeNames = new[] { "id" },
                SupportsPatch        = true,
            };

            type.ApiInterface = new ApiInterfaceGroup(type, config);

            AdapterPropertyValue adminCreated = new AdapterPropertyValue
            {
                AttributeType           = AttributeType.Boolean,
                FieldName               = "adminCreated",
                IsMultivalued           = false,
                Operation               = AttributeOperation.ImportOnly,
                AttributeName           = "adminCreated",
                PropertyName            = "AdminCreated",
                Api                     = "group",
                SupportsPatch           = true,
                NullValueRepresentation = NullValueRepresentation.NullPlaceHolder,
                CastForImport           = (i) => i ?? false
            };

            type.AttributeAdapters.Add(adminCreated);

            AdapterPropertyValue description = new AdapterPropertyValue
            {
                AttributeType           = AttributeType.String,
                FieldName               = "description",
                IsMultivalued           = false,
                Operation               = AttributeOperation.ImportExport,
                AttributeName           = "description",
                PropertyName            = "Description",
                Api                     = "group",
                SupportsPatch           = true,
                NullValueRepresentation = NullValueRepresentation.EmptyString,
            };

            type.AttributeAdapters.Add(description);

            AdapterPropertyValue email = new AdapterPropertyValue
            {
                AttributeType = AttributeType.String,
                FieldName     = "email",
                IsMultivalued = false,
                Operation     = AttributeOperation.ImportOnly,
                AttributeName = "primaryEmail",
                PropertyName  = "Email",
                Api           = "group",
                SupportsPatch = true,
            };

            type.AttributeAdapters.Add(email);

            AdapterPropertyValue id = new AdapterPropertyValue
            {
                AttributeType = AttributeType.String,
                FieldName     = "id",
                IsMultivalued = false,
                Operation     = AttributeOperation.ImportOnly,
                AttributeName = "id",
                PropertyName  = "Id",
                Api           = "group",
                SupportsPatch = true,
                IsAnchor      = true,
            };

            type.AttributeAdapters.Add(id);

            AdapterPropertyValue name = new AdapterPropertyValue
            {
                AttributeType = AttributeType.String,
                FieldName     = "name",
                IsMultivalued = false,
                Operation     = AttributeOperation.ImportExport,
                AttributeName = "name",
                PropertyName  = "Name",
                Api           = "group",
                SupportsPatch = true,
            };

            type.AttributeAdapters.Add(name);

            SchemaBuilderGroups.AddGroupAliases(type);
            SchemaBuilderGroups.AddGroupSettings(type);

            if (config.MembersAsNonReference)
            {
                SchemaBuilderGroups.AddGroupMembersRaw(type);
            }
            else
            {
                SchemaBuilderGroups.AddGroupMembers(type);
            }

            yield return(type);
        }
コード例 #24
0
        private static void AddUserCustomSchema(MASchemaType type, IManagementAgentParameters config)
        {
            G.Schemas schemas = null;

            try
            {
                schemas = config.SchemaService.ListSchemas(config.CustomerID);
            }
            catch (Google.GoogleApiException ex)
            {
                if (ex.HttpStatusCode == System.Net.HttpStatusCode.Forbidden)
                {
                    Trace.WriteLine("Permission to read the user custom schema was denied");
                    return;
                }

                throw;
            }
            catch (TokenResponseException ex)
            {
                if (ex.StatusCode == System.Net.HttpStatusCode.Forbidden || ex.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    Trace.WriteLine("Permission related TokenResponseException while reading the user custom schema");
                    return;
                }
            }

            if (schemas?.SchemasValue == null)
            {
                return;
            }

            AdapterCustomSchemas customSchemas = new AdapterCustomSchemas();

            customSchemas.Api = "user";

            foreach (G.Schema schema in schemas.SchemasValue)
            {
                if (schema.SchemaName.Equals(SchemaConstants.CustomGoogleAppsSchemaName))
                {
                    continue;
                }

                AdapterCustomSchema customSchema = new AdapterCustomSchema();

                customSchema.SchemaName = schema.SchemaName;

                foreach (G.SchemaFieldSpec field in schema.Fields)
                {
                    AdapterCustomSchemaField f;

                    if (field.MultiValued ?? false)
                    {
                        f = new AdapterCustomSchemaMultivaluedField();
                    }
                    else
                    {
                        f = new AdapterCustomSchemaSingleValuedField();
                    }

                    switch (field.FieldType.ToLowerInvariant())
                    {
                    case "int64":
                        f.AttributeType = AttributeType.Integer;
                        break;

                    case "bool":
                        f.AttributeType = AttributeType.Boolean;
                        break;

                    default:
                        f.AttributeType = AttributeType.String;
                        break;
                    }

                    if (f.IsMultivalued && !(f.AttributeType == AttributeType.String || f.AttributeType == AttributeType.Integer))
                    {
                        continue;
                    }

                    f.FieldName               = $"{field.FieldName}";
                    f.SchemaName              = schema.SchemaName;
                    f.Operation               = AttributeOperation.ImportExport;
                    f.MmsAttributeName        = Regex.Replace($"{schema.SchemaName}_{field.FieldName}", "[^a-zA-Z0-9_\\-]", "_", RegexOptions.IgnoreCase);
                    f.PropertyName            = $"{field.FieldName}";
                    f.NullValueRepresentation = NullValueRepresentation.NullPlaceHolder;
                    f.FieldSpec               = field;

                    customSchema.Fields.Add(f);
                }

                if (customSchema.Fields.Count > 0)
                {
                    customSchemas.CustomSchemas.Add(customSchema);
                }
            }

            if (customSchemas.CustomSchemas.Count > 0)
            {
                type.AttributeAdapters.Add(customSchemas);
            }
        }
 public ApiInterfaceUserMakeAdmin(IManagementAgentParameters config)
 {
     this.config = config;
 }
コード例 #26
0
 public ApiInterfaceFeature(string customerID, MASchemaType type, IManagementAgentParameters config)
 {
     this.SchemaType = type;
     this.customerID = customerID;
     this.config     = config;
 }
 public ApiInterfaceUserDelegates(IManagementAgentParameters config, string typeName)
 {
     this.config        = config;
     this.typeName      = typeName;
     this.attributeName = $"{typeName}_{SchemaConstants.Delegate}";
 }
        public IEnumerable <MASchemaType> GetSchemaTypes(IManagementAgentParameters config)
        {
            MASchemaType type = new MASchemaType
            {
                AttributeAdapters = new List <IAttributeAdapter>(),
                Name = "building",
                AnchorAttributeNames = new[] { "id" },
                SupportsPatch        = true,
            };

            type.ApiInterface = new ApiInterfaceBuilding(config.CustomerID, type, config);

            type.AttributeAdapters.Add(new AdapterPropertyValue
            {
                AttributeType = AttributeType.String,
                FieldName     = "buildingId",
                IsMultivalued = false,
                Operation     = AttributeOperation.ImportOnly,
                AttributeName = "id",
                PropertyName  = "BuildingId",
                Api           = "building",
                SupportsPatch = true,
                IsAnchor      = true
            });

            type.AttributeAdapters.Add(new AdapterPropertyValue
            {
                AttributeType           = AttributeType.String,
                FieldName               = "buildingName",
                IsMultivalued           = false,
                Operation               = AttributeOperation.ImportExport,
                AttributeName           = "buildingName",
                PropertyName            = "BuildingName",
                Api                     = "building",
                SupportsPatch           = true,
                NullValueRepresentation = NullValueRepresentation.EmptyString,
                IsAnchor                = false
            });

            type.AttributeAdapters.Add(new AdapterPropertyValue
            {
                AttributeType           = AttributeType.String,
                FieldName               = "description",
                IsMultivalued           = false,
                Operation               = AttributeOperation.ImportExport,
                AttributeName           = "description",
                PropertyName            = "Description",
                Api                     = "building",
                SupportsPatch           = true,
                NullValueRepresentation = NullValueRepresentation.EmptyString,
                IsAnchor                = false
            });

            type.AttributeAdapters.Add(new AdapterPropertyValue
            {
                AttributeType           = AttributeType.String,
                FieldName               = "floorNames",
                IsMultivalued           = false,
                Operation               = AttributeOperation.ImportExport,
                AttributeName           = "floorNames",
                PropertyName            = "FloorNames",
                Api                     = "building",
                SupportsPatch           = true,
                NullValueRepresentation = NullValueRepresentation.EmptyString,
                CastForExport           = i => ((string)i)?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(),
                CastForImport           = i => i == null ? null : string.Join(",", ((IList <string>)i)),
                IsAnchor                = false
            });

            AdapterSubfield latitude = new AdapterSubfield
            {
                AttributeType           = AttributeType.String,
                FieldName               = "latitude",
                IsMultivalued           = false,
                Operation               = AttributeOperation.ImportExport,
                PropertyName            = "Latitude",
                AttributeNamePart       = "latitude",
                NullValueRepresentation = NullValueRepresentation.DoubleZero,
                CastForExport           = value =>
                {
                    if (value == null)
                    {
                        return(null);
                    }

                    return(double.Parse(value.ToString()));
                },
                CastForImport = value => ((double?)value)?.ToString("R")
            };

            AdapterSubfield longitude = new AdapterSubfield
            {
                AttributeType           = AttributeType.String,
                FieldName               = "longitude",
                IsMultivalued           = false,
                PropertyName            = "Longitude",
                Operation               = AttributeOperation.ImportExport,
                AttributeNamePart       = "longitude",
                NullValueRepresentation = NullValueRepresentation.DoubleZero,
                CastForExport           = value =>
                {
                    if (value == null)
                    {
                        return(null);
                    }

                    return(double.Parse(value.ToString()));
                },
                CastForImport = value => ((double?)value)?.ToString("R")
            };

            AdapterNestedType schemaItem = new AdapterNestedType
            {
                Api           = "building",
                AttributeName = "coordinates",
                Fields        = new List <AdapterSubfield>()
                {
                    latitude, longitude
                },
                FieldName     = "coordinates",
                PropertyName  = "Coordinates",
                SupportsPatch = false
            };

            type.AttributeAdapters.Add(schemaItem);

            yield return(type);
        }
コード例 #29
0
 public void OpenPasswordConnection(KeyedCollection <string, ConfigParameter> configParameters, Partition partition)
 {
     this.Configuration = new ManagementAgentParameters(configParameters);
     Logger.LogPath     = this.Configuration.PasswordOperationLogFile;
     this.SetHttpDebugMode();
 }
コード例 #30
0
        public Schema GetSchema(KeyedCollection <string, ConfigParameter> configParameters)
        {
            this.Configuration = new ManagementAgentParameters(configParameters);

            return(SchemaBuilder.GetSchema(this.Configuration).GetSchema());
        }