Esempio n. 1
0
        public void TestWorkerAgent()
        {
            using (CacheContextScope d = NSerio.Relativity.RepositoryHelper.InitializeRepository(-1))
            {
                Batch batch = null;
                System.Data.DataTable queryResult  = null;
                System.Data.DataRow   workspaceRow = null;
                Workspace             workspace    = null;
                int workspaceArtifactId            = default(int);

                try
                {
                    var Worker = new Worker();
                    queryResult = _Repository.MasterDBContext.ExecuteSqlStatementAsDataTable(Database.Resources.RetrieveNextWorkspace);
                    if (queryResult.Rows.Count > 0)
                    {
                        workspaceRow        = queryResult.Rows[0];
                        workspaceArtifactId = (int)workspaceRow["CaseArtifactID"];

                        if (DoesWorkspaceExist(workspaceArtifactId))
                        {
                            using (IRSAPIClient proxy = Worker.Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
                            {
                                proxy.APIOptions.WorkspaceID = workspaceArtifactId;
                                try
                                {
                                    workspace = new Workspace(proxy, workspaceRow, Worker.Helper);
                                    workspace.WorkspaceDBConnection = Worker.Helper.GetDBContext(workspace.ArtifactID);
                                    batch = new Batch(BatchSize, 1, Worker.Helper, workspace, null);

                                    batch.Process();
                                }
                                catch (Exception ex)
                                {
                                    workspace.HandleError(ex);
                                    throw ex;
                                }
                            }
                        }
                        else
                        {
                            _Repository.MasterDBContext.ExecuteNonQuerySQLStatement(string.Format(Database.Resources.CleanupDeletedCaseFromManagerQueue, workspaceArtifactId));
                            _Repository.MasterDBContext.ExecuteNonQuerySQLStatement(string.Format(Database.Resources.CleanupDeletedCaseFromWorkerQueue, BatchSize, workspaceArtifactId));
                        }
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 2
0
        public void TestManagerAgent()
        {
            using (CacheContextScope d = NSerio.Relativity.RepositoryHelper.InitializeRepository(-1))
            {
                System.Data.DataTable workspaces = null;
                Workspace             workspace  = null;
                int workspaceArtifactId          = default(int);

                //try
                //{
                var Manager = new Manager();
                workspaces = _Repository.MasterDBContext.ExecuteSqlStatementAsDataTable(Database.Resources.RetrieveWorkspaces);

                if (workspaces.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow row in workspaces.Rows)
                    {
                        workspaceArtifactId = (int)row["CaseArtifactID"];

                        if (DoesWorkspaceExist(workspaceArtifactId))
                        {
                            //_Repository.WorkspaceID = workspaceArtifactId;
                            try
                            {
                                //var rc = new RSAPIClient(new Uri(c_ServerURL), new UsernamePasswordCredentials(c_RelativityUser, c_RelativityPassword));
                                //rc.APIOptions.WorkspaceID = workspaceArtifactId;
                                //rc.Login();
                                workspace                       = new Workspace(_Repository.RSAPISystem, null, null);
                                workspace.ArtifactID            = (int)row["CaseArtifactID"];
                                workspace.JobArtifactID         = (int)row["JobArtifactID"];
                                workspace.FlagFieldColumnName   = Convert.ToString(row["FlagFieldColumnName"]);
                                workspace.EDDSDBConnection      = _Repository.MasterDBContext;
                                workspace.WorkspaceDBConnection = new DBContext(new kCura.Data.RowDataGateway.Context(c_SQLServerName, string.Format("EDDS{0}", workspaceArtifactId == -1 ? string.Empty : workspaceArtifactId.ToString()), c_SQLUser, c_SQLPassword));

                                workspace.Prepare();
                            }
                            catch (Exception ex)
                            {
                                // workspace.HandleError(ex);
                                throw ex;
                            }
                        }
                        else
                        {
                            //Cleanup manager and worker queue if workspace has been deleted
                            _Repository.MasterDBContext.ExecuteNonQuerySQLStatement(string.Format(Database.Resources.CleanupDeletedCaseFromManagerQueue, workspaceArtifactId));
                            _Repository.MasterDBContext.ExecuteNonQuerySQLStatement(string.Format(Database.Resources.CleanupDeletedCaseFromWorkerQueue, BatchSize, workspaceArtifactId));
                        }
                    }
                }
            }
        }