public ActionResponse <NewTaskRunResult> RequestNewTaskRun()
        {
            var newTaskRunResult = new NewTaskRunResult
            {
                RunRequired = true,
                //SessionId = "unique-session-id-123",
                SessionId = Guid.NewGuid().ToString(),
                DateFrom  = new DateTime(2016, 12, 1),
                DateTo    = new DateTime(2016, 12, 2)
            };

            return(new ActionResponse <NewTaskRunResult> {
                Success = true, Response = newTaskRunResult
            });
        }
예제 #2
0
        /// <summary>
        /// Perform the actual task of gathering and staging new data
        /// </summary>
        /// <param name="taskParameters"></param>
        /// <returns></returns>
        private bool PerformTask(NewTaskRunResult taskParameters)
        {
            // tell the task server that we're starting the run
            ActionResponse actionResponse = _taskServer.Starting(taskParameters.SessionId);

            if (!actionResponse.Success)
            {
                // The call to the task server failed!!!!!  Need to fall back to manually alerting someone...
                SendErrorEmail("Error", "Failed starting task! " + actionResponse.Message);
                return(false);
            }

            // Iterate through all data types we have (in appropriate order) and
            if (!StageDataFromProvider(taskParameters, _entity1Provider))
            {
                return(false);
            }

            if (!StageDataFromProvider(taskParameters, _entity2Provider))
            {
                return(false);
            }

            // When done, commit the staging server data set
            actionResponse = _stagingServer.Commit(taskParameters.SessionId);
            if (!actionResponse.Success)
            {
                AbortSession(taskParameters.SessionId, "Error committing staged data: " + actionResponse.Message);
                return(false);
            }

            actionResponse = _taskServer.Completed(taskParameters.SessionId);
            if (!actionResponse.Success)
            {
                // Completing the session on the task server failed!!!!!  Need to fall back to manually alerting someone...
                SendErrorEmail("Error", "Failed completing task! " + actionResponse.Message);
                return(false);
            }

            return(true);
        }
예제 #3
0
        private bool StageDataFromProvider(NewTaskRunResult taskParameters, IEntity2Provider dataProvider)
        {
            if (StagingDisabled)
            {
                Console.WriteLine();
                Console.WriteLine("Staging is disabled for datatype: {0}. Query results displayed below...", dataProvider.DataType.Name);
            }

            QueryResult <Entity2> queryResult = dataProvider.Query(taskParameters.DateFrom, taskParameters.DateTo);

            if (!queryResult.QuerySuccess)
            {
                // something went wrong performing the query - inform the task server and abort
                string errorMessage = string.Format("Error staging '{0}' object: {1}", dataProvider.DataType.Name, queryResult.Message);
                AbortSession(taskParameters.SessionId, errorMessage);
                return(false);
            }

            foreach (var data in queryResult.Data)
            {
                if (StagingDisabled)
                {
                    Console.WriteLine("   - {0}", dataProvider.FriendlyDisplay(data));
                }
                else
                {
                    ActionResponse response = _stagingServer.Load(taskParameters.SessionId, data);
                    if (!response.Success)
                    {
                        // something went wrong staging the data object - inform the task server and abort
                        string errorMessage = string.Format("Error staging '{0}' object: {1}", dataProvider.DataType.Name, response.Message);
                        AbortSession(taskParameters.SessionId, errorMessage);
                        return(false);
                    }
                }
            }

            return(true);
        }