public void GetFullImport()
        {
            using (SQLManagementAgent ma = new SQLManagementAgent())
            {
                Configuration.Schema = ma.DefaultSchemaXml.XmlDeserializeFromString <SchemaConfiguration>();
                Schema schema = ma.GetSchemaDetached();

                ma.Schema     = schema;
                ma.ImportType = OperationType.Full;

                OpenImportConnectionRunStep dummyOpenImportRunStep = new OpenImportConnectionRunStep();

                // fake runstep data
                ma.ImportType = OperationType.Full;
                ma.CustomData = "";
                ma.PageSize   = 100;

                System.Collections.ObjectModel.KeyedCollection <string, ConfigParameter> configParams = null;
                ma.OpenImportConnectionDetached(configParams, schema, null);

                GetImportEntriesRunStep rs = new GetImportEntriesRunStep();

                GetImportEntriesResults rest = new GetImportEntriesResults();
                rest.MoreToImport = true;
                while (rest.MoreToImport)
                {
                    rest = ma.GetImportEntriesDetached(rs);
                }

                CloseImportConnectionRunStep dummyCloseImportRunStep = null;
                ma.CloseImportConnectionDetached(dummyCloseImportRunStep);
            }
        }
Exemple #2
0
        public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            // The schema types are required for serialization, so save them into a local variable for use in CloseImportConnection
            this.operationSchema = types;

            this.importRunStepParameters = importRunStep;

            if (this.importRunStepParameters.ImportType == OperationType.Delta)
            {
                // Load the items from the queue
                CSEntryChangeQueue.LoadQueue(this.filename);
            }

            return(new OpenImportConnectionResults());
        }
Exemple #3
0
        //
        // Import
        //
        // OpenImportConnection
        public OpenImportConnectionResults OpenImportConnection(
            KeyedCollection <string, ConfigParameter> _configParameters,
            Schema _types,
            OpenImportConnectionRunStep _importRunStep)
        {
            utils.Logger(TraceEventType.Information,
                         ConstDefinition.ID0400_START_OPENIMPORTCONNECTION,
                         ConstDefinition.MSG0400_START_OPENIMPORTCONNECTION);
            try
            {
                // Get OperationType
                operationType = _importRunStep.ImportType;
#if DEBUG
                switch (operationType)
                {
                case OperationType.Full:
                    utils.Logger(TraceEventType.Verbose, ConstDefinition.ID0450_VERBOSE_OPENIMPORTCONNECTION, "OperationType : Full");
                    break;

                case OperationType.Delta:
                    utils.Logger(TraceEventType.Verbose, ConstDefinition.ID0450_VERBOSE_OPENIMPORTCONNECTION, "OperationType : Delta");
                    break;

                case OperationType.FullObject:
                    utils.Logger(TraceEventType.Verbose, ConstDefinition.ID0450_VERBOSE_OPENIMPORTCONNECTION, "OperationType : FullObject");
                    break;

                default:
                    utils.Logger(TraceEventType.Verbose, ConstDefinition.ID0450_VERBOSE_OPENIMPORTCONNECTION, "OperationType : Other");
                    break;
                }
#endif
                resource_uri = _configParameters[ConstDefinition.CFG_RESOURCE_URI].Value.ToString();
                auth_token   = _configParameters[ConstDefinition.CFG_AUTH_TOKEN].Value.ToString();
                return(new OpenImportConnectionResults());
            }
            catch (Exception ex)
            {
                utils.Logger(TraceEventType.Error,
                             ConstDefinition.ID0499_ERROR_OPENIMPORTCONNECTION,
                             ex.Message);
                throw new ExtensibleExtensionException(ConstDefinition.MSG0499_ERROR_OPENIMPORTCONNECTION + ex.Message);
            }
        }
        /// <summary>
        /// Used to configure the import session and is called once at the beginning of the import.
        /// </summary>
        /// <param name="configParameters">A collection of <see cref="ConfigParameter"/> objects.</param>
        /// <param name="types">Contains a <see cref="Schema"/> that defines the management agent's schema</param>
        /// <param name="importRunStep">Contains an <see cref="OpenImportConnectionRunStep"/> object.</param>
        /// <returns></returns>
        public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters,
                                                                Schema types, OpenImportConnectionRunStep importRunStep)
        {
            InitializeConnector(configParameters);

            _setupCustomerIdsEnumerator = true;
            _setupUsersEnumerators      = true;

            // This dictionary will contain a complete list of all customer identifiers that are processed. These
            // identifiers will be used to obtain the users that belong to the customers that were processed.
            _customersInfo = new Dictionary <string, string>();
            // Obtain the collection of customer broken out by page size. This is required because the synchronization
            // will only import a set size of entries at once. The page size is controlled by the ImportDefaultPageSize
            // and ImportMaxPageSize properties.
            _customers = _operations.Customers.Query(QueryFactory.Instance.BuildIndexedQuery(ImportDefaultPageSize));
            // Create a customer enumerator which will be used to traverse the pages of customers.
            _customersEnumerator = _operations.Enumerators.Customers.Create(_customers);

            return(new OpenImportConnectionResults());
        }
Exemple #5
0
        public OpenImportConnectionResults OpenImportConnection(
            KeyedCollection <string, ConfigParameter> configParameters, Schema types,
            OpenImportConnectionRunStep importRunStep)
        {
            _schemaTypes   = types;
            _objectSources = GetRepositoryContainers(configParameters);

            _setImportPageSize = importRunStep.PageSize > 0 ? importRunStep.PageSize : ImportDefaultPageSize;

            var importResults = new OpenImportConnectionResults();

            _objectImportsDictionary = new Dictionary <IObjectSource <IExternalObject>, List <IExternalObject> >();

            foreach (IObjectSource <IExternalObject> repoContainer in _objectSources)
            {
                List <IExternalObject> allExternalObjects = repoContainer.GetAll();
                _objectImportsDictionary.Add(repoContainer, allExternalObjects);
            }

            return(importResults);
        }
        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 OpenImportConnectionResults OpenImportConnection(System.Collections.ObjectModel.KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
 {
     throw new NotImplementedException();
 }
        public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            try
            {
                this.GetMAConfig(configParameters);

                this.OpenRSAConnection();

                m_importPageSize = importRunStep.PageSize;

                rsaResult = this.ImportUsers();

                return(new OpenImportConnectionResults());
            }
            catch (Exception ex)
            {
                EmailError(ex);
                throw ex;
            }
        }
Exemple #9
0
        public OpenImportConnectionResults OpenImportConnection(System.Collections.ObjectModel.KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep openImportRunStep)
        {
            Tracer.Enter("openimportconnection");
            try
            {
                Tracer.TraceInformation("getting-schema");
                try
                {
                    foreach (SchemaType type in types.Types)
                    {
                        foreach (SchemaAttribute attr in type.AnchorAttributes)
                        {
                            //Tracer.TraceInformation("{0}-anchor-attribute {1} [{2}]", type.Name, attr.Name, attr.DataType);
                            objectTypeAnchorAttributeNames.Add(type.Name, attr.Name);
                        }
                        foreach (SchemaAttribute attr in type.Attributes)
                        {
                            //Tracer.TraceInformation("{0}-attribute {1} [{2}]", type.Name, attr.Name, attr.DataType);
                        }
                    }
                    InitializeSchemaVariables(types);
                }
                catch (Exception ex)
                {
                    Tracer.TraceError("getting-schema", ex);
                }
                finally
                {
                    Tracer.TraceInformation("got-schema");
                }

                InitializeConfigParameters(configParameters);

                //SetupImpersonationToken();

                OpenRunspace();

                Tracer.TraceInformation("resetting-pipeline-results-and-counters");
                importResults = new List <PSObject>();
                pageToken     = "";

                OpenImportConnectionResults oicr = new OpenImportConnectionResults();
                ImportRunStepPageSize = openImportRunStep.PageSize;
                Tracer.TraceInformation("openimportrunstep-pagesize '{0}'", ImportRunStepPageSize);

                oicr.CustomData = openImportRunStep.ImportType == OperationType.Full ? "" : openImportRunStep.CustomData;
                Tracer.TraceInformation("openimportrunstep-customdata '{0}'", oicr.CustomData);

                importOperationType = openImportRunStep.ImportType;
                Tracer.TraceInformation("openimportrunstep-importtype '{0}'", importOperationType);

                return(oicr);
            }
            catch (Exception ex)
            {
                Tracer.TraceError("openimportconnection", ex);
                throw;
            }
            finally
            {
                Tracer.Exit("openimportconnection");
            }
        }
Exemple #10
0
        /// <summary>
        /// Configures the import session at the beginning of an import
        /// </summary>
        /// <param name="configParameters">The configuration parameters supplied to this management agent</param>
        /// <param name="types">The schema types that apply to this import run</param>
        /// <param name="importRunStep">The definition of the current run step</param>
        /// <returns>Results of the import setup</returns>
        public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            try
            {
                this.suppliedConfigParameters = configParameters;
                Logger.LogPath = this.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting Import");
                Logger.WriteLine("Import data from sync engine: " + importRunStep.CustomData);

                this.client = new AcmaSyncServiceClient();
                this.client.Open();

                ImportStartRequest request = new ImportStartRequest();
                request.ImportType = importRunStep.ImportType;
                request.PageSize   = 0;
                request.Schema     = types;

                this.importResponse = this.client.ImportStart(request);

                this.importPageSize = importRunStep.PageSize;

                return(new OpenImportConnectionResults());
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
                throw;
            }
        }
Exemple #11
0
        public OpenImportConnectionResults OpenImportConnectionDetached(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            Tracer.Enter(nameof(OpenImportConnectionDetached));
            OpenImportConnectionResults result = new OpenImportConnectionResults();

            try
            {
                if (importRunStep != null) // only use when attached to FIM
                {
                    InitializeConfigParameters(configParameters);
                    ImportType = importRunStep.ImportType;
                    CustomData = ImportType == OperationType.Delta ? importRunStep.CustomData : null;
                    PageSize   = importRunStep.PageSize;
                }
                Tracer.TraceInformation("import-type {0}", ImportType);
                Tracer.TraceInformation("customdata {0}", CustomData);
                Tracer.TraceInformation("pagesize {0}", PageSize);

                Schema = types;

                importCsEntryQueue = new List <CSEntryChange>();

                methods.OpenConnection();

                if (Configuration.RunBeforeImport)
                {
                    List <SqlParameter> parameters = new List <SqlParameter>();
                    parameters.Add(new SqlParameter("importtype", ImportType.ToString()));
                    parameters.Add(new SqlParameter("customdata", CustomData));
                    methods.RunStoredProcedure(Configuration.ImportCommandBefore, parameters);
                    parameters.Clear();
                    parameters = null;
                }
            }
            catch (Exception ex)
            {
                Tracer.TraceError(nameof(OpenImportConnectionDetached), ex);
                throw;
            }
            finally
            {
                Tracer.Exit(nameof(OpenImportConnectionDetached));
            }
            return(result);
        }
 public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
 {
     this.imUrl = configParameters["imUrl"].Value;
     this.webServiceUsername = configParameters["webServiceUsername"].Value;
     this.webServicePassword = configParameters["webServicePassword"].Value;
     this.enableLogging      = configParameters["enableLogging"].Value;
     this.loggingLevel       = configParameters["loggingLevel"].Value;
     return(new OpenImportConnectionResults());
 }
Exemple #13
0
        public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            OpenImportConnectionResults openImportConnectionResults = new OpenImportConnectionResults();

            _lastRunTimeStamp    = openImportConnectionResults.CustomData = importRunStep.CustomData;
            _currentRuntimeStamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
            _currentPageSize     = importRunStep.PageSize;
            try
            {
                _lastRunTimeStamp = openImportConnectionResults.CustomData = importRunStep.CustomData;
                _peopleDiscovery  = new RESTHandler(configParameters[_API_KEY].Value,
                                                    configParameters[_BASE_URI].Value,
                                                    configParameters[_LANG].Value,
                                                    configParameters[_NOPAGESRTN].Value);
                _personDiscoveryList = _peopleDiscovery.ReadObjects();
                _moviesList          = new List <MovieDiscoveryJsonTypes.Result>();
                _objectCount         = 0;
                _personCount         = 0;
                _skipPeople          = false;
            }
            catch (Exception ex)
            {
                LogEvent(ex.ToString());
                throw new ExtensibleExtensionException(ex.ToString());
            }
            return(openImportConnectionResults);
        }
        /// <summary>
        /// Configures the import session at the beginning of an import
        /// </summary>
        /// <param name="configParameters">The configuration parameters supplied to this management agent</param>
        /// <param name="types">The schema types that apply to this import run</param>
        /// <param name="importRunStep">The definition of the current run step</param>
        /// <returns>Results of the import setup</returns>
        OpenImportConnectionResults IMAExtensible2CallImport.OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting Import");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                SshConnection.OpenSshConnection(ManagementAgent.MAParameters);
                OperationBase operation;
                this.ImportType     = importRunStep.ImportType;
                this.schemaTypes    = types.Types;
                this.importPageSize = importRunStep.PageSize;

                if (importRunStep.ImportType == OperationType.Delta)
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportDeltaStartOperation);
                }
                else
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportFullStartOperation);
                }

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform import start operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Import start operation failed", ex);
                    }
                }

                this.importEnumerator = CSEntryImport.GetObjects(this.schemaTypes, importRunStep.ImportType).GetEnumerator();
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open import connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open import connection operation", ex);
            }

            OpenImportConnectionResults results = new OpenImportConnectionResults();

            return(new OpenImportConnectionResults());
        }
Exemple #15
0
        public OpenImportConnectionResults OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            Logging.SetupLogger(configParameters);

            this.importContext = new ImportContext()
            {
                RunStep          = importRunStep,
                ImportItems      = new BlockingCollection <CSEntryChange>(),
                ConfigParameters = configParameters,
                Types            = types
            };

            try
            {
                logger.Info("Starting {0} import", this.importContext.InDelta ? "delta" : "full");

                this.importContext.ConnectionContext = InterfaceManager.GetProviderOrDefault <IConnectionContextProvider>()?.GetConnectionContext(configParameters, ConnectionContextOperationType.Import);

                if (!string.IsNullOrEmpty(importRunStep.CustomData))
                {
                    try
                    {
                        this.importContext.IncomingWatermark = JsonConvert.DeserializeObject <WatermarkKeyedCollection>(importRunStep.CustomData);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex, "Could not deserialize watermark");
                    }
                }

                this.importContext.Timer.Start();

                this.StartCreatingCSEntryChanges(this.importContext);
            }
            catch (Exception ex)
            {
                logger.Error(ex.UnwrapIfSingleAggregateException());
                throw;
            }

            return(new OpenImportConnectionResults());
        }
Exemple #16
0
 OpenImportConnectionResults IMAExtensible2CallImport.OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
 {
     return(OpenImportConnectionDetached(configParameters, types, importRunStep));
 }