private static List <DTOs.Result <DTOs.BatchSet> > GetSourceBatches(IRSAPIClient proxy)
        {
            DTOs.Query <DTOs.BatchSet> query = new DTOs.Query <DTOs.BatchSet>();
            query.Fields = DTOs.FieldValue.AllFields;

            DTOs.QueryResultSet <DTOs.BatchSet> resultSet = new DTOs.QueryResultSet <DTOs.BatchSet>();
            try
            {
                resultSet = proxy.Repositories.BatchSet.Query(query, 0);
            }
            catch (Exception ex)
            {
                _logger.LogError("Exception when querying for batches: {message}", ex);
                return(null);
            }

            if (resultSet.Success)
            {
                if (resultSet.Results.Count > 0)
                {
                    _logger.LogInformation("{0} batch sets found in {1}", resultSet.Results.Count, proxy.APIOptions.WorkspaceID);
                    return(resultSet.Results);
                }
                else
                {
                    _logger.LogWarning("Query was successful but no batches exist.");
                    return(null);
                }
            }
            else
            {
                _logger.LogError("Unsuccessful query for batches: {message}", resultSet.Results[0].Message);
                return(null);
            }
        }
        public override Response Execute()
        {
            Response retVal = new Response()
            {
                Success = true,
                Message = String.Empty
            };

            _logger = Helper.GetLoggerFactory().GetLogger().ForContext <WorkspaceCreate>();

            try
            {
                int currentWorkspaceID = Helper.GetActiveCaseID();

                IDBContext workspaceDBContext = Helper.GetDBContext(currentWorkspaceID);

                int templateWorkspaceID = GetTemplateCase(workspaceDBContext);

                using (IRSAPIClient proxy = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
                {
                    proxy.APIOptions.WorkspaceID = templateWorkspaceID;

                    List <DTOs.Result <DTOs.BatchSet> > source = GetSourceBatches(proxy);

                    if (source != null)
                    {
                        if (source.Count < 1)
                        {
                            _logger.LogInformation("Template workspace has no batch sets; exiting.");
                        }
                        else
                        {
                            _logger.LogInformation("Starting creation of {number} batches", source.Count);
                            proxy.APIOptions.WorkspaceID = currentWorkspaceID;

                            CreateBatches(source, proxy);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                retVal.Success = false;
                retVal.Message = ex.ToString();
            }

            return(retVal);
        }
Exemple #3
0
        public override Response Execute()
        {
            IAPILog logger = Helper.GetLoggerFactory().GetLogger();

            logger.LogVerbose("Log information throughout execution.");

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            Response retVal = new Response();

            retVal.Success = true;
            retVal.Message = string.Empty;
            try
            {
                Int32 currentWorkspaceArtifactID = this.Helper.GetActiveCaseID();

                using (IRSAPIClient proxy = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
                {
                    proxy.APIOptions.WorkspaceID = currentWorkspaceArtifactID;
                    //Add code for working with RSAPIClient
                    int fieldMatchCount = QueryForArticleTitleField(proxy, currentWorkspaceArtifactID);
                    if (fieldMatchCount < 1)
                    {
                        int createSuccess = CreateDocumentFieldArticleTitle(proxy, currentWorkspaceArtifactID);
                        if (createSuccess <= 0)
                        {
                            retVal.Success = false;
                            retVal.Message = "Failed to create the field!";
                            logger.LogInformation("Failed to create");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                retVal.Success = false;
                retVal.Message = ex.ToString();
            }

            return(retVal);
        }
Exemple #4
0
 public void LogInformation(string message)
 {
     _logger.LogInformation(message);
 }