public bool insertJob(IDBContext dbContext, string currentUser, DTOs.RDO rdo) { bool result = true; DateTime date = DateTime.Now; string INSERT_JOB_QUERY = $@"IF NOT EXISTS(SELECT TOP 1 * FROM [EDDSDBO].commentJob where comment_artifactid = @commentArtifactId) BEGIN insert into [EDDSDBO].commentJob (cojob_comment, cojob_createdBy, comment_artifactId, cojob_createdOn) Values (@comment, @user, @commentArtifactId, @createdOn ) END"; System.Data.SqlClient.SqlParameter comment = new System.Data.SqlClient.SqlParameter("@comment", System.Data.SqlDbType.VarChar); comment.Value = rdo.Fields[0].Value; System.Data.SqlClient.SqlParameter user = new System.Data.SqlClient.SqlParameter("@user", System.Data.SqlDbType.VarChar); user.Value = currentUser; System.Data.SqlClient.SqlParameter commentArtifactId = new System.Data.SqlClient.SqlParameter("@commentArtifactId", System.Data.SqlDbType.Int); commentArtifactId.Value = rdo.ArtifactID; System.Data.SqlClient.SqlParameter createdOn = new System.Data.SqlClient.SqlParameter("@createdOn", System.Data.SqlDbType.DateTime); createdOn.Value = DateTime.Now; try { dbContext.ExecuteNonQuerySQLStatement(INSERT_JOB_QUERY, new System.Data.SqlClient.SqlParameter[] { commentArtifactId, comment, user, createdOn }); result = true; } catch (Exception e) { System.Console.WriteLine($"There was a problem in a Query: {e.Message}"); result = false; } return(result); }
private void CreateFileValidationResult(bool isMissing, string fileType) { try { var fvResult = new DTOs.RDO(); fvResult.ArtifactTypeGuids.Add(new Guid(MainApp.Helper.Constant.OBJECT_TYPE_FILE_VALIDATIOM_RESULT_GUID)); DTOs.FieldValueList <DTOs.Document> docObjects = new DTOs.FieldValueList <DTOs.Document>(); var doc = new DTOs.Document(ArtifactID); docObjects.Add(doc); fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_NAME), DateTime.UtcNow.ToString("MM-dd-yyyy HH:mm:ss"))); fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_DOCUMENT), docObjects)); fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_VALIDATION_DATE), DateTime.UtcNow)); fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_EXIST), isMissing)); fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_TYPE), fileType)); DTOs.WriteResultSet <DTOs.RDO> writeResults = Connection.Repositories.RDO.Create(fvResult); if (!writeResults.Success) { throw new Exception(string.Format("An error occurred in result creation: {0}", writeResults.Results[0].Message)); } } catch (Exception ex) { throw ex; } }
public override Response PreMassOperation() { ConsoleEventHandlerComment console = new ConsoleEventHandlerComment(); kCura.EventHandler.Response retVal = new kCura.EventHandler.Response(); retVal.Success = true; retVal.Message = "Successful Pre Execute Operation method"; IDBContext dbContext = this.Helper.GetDBContext(this.Helper.GetActiveCaseID()); string sqlText = $" SELECT * FROM [Comment] WHERE ArtifactID IN (SELECT ARTIFACTID from[RESOURCE].[{ this.MassActionTableName}]) "; System.Data.DataRowCollection results = dbContext.ExecuteSqlStatementAsDataTable(sqlText).Rows; foreach (System.Data.DataRow row in results) { DTOs.RDO comme = new DTOs.RDO((int)row.ItemArray[0]); comme.ArtifactTypeGuids.Add(new Guid(ARTIFACT_TYPE)); comme.Fields.Add(new DTOs.FieldValue(new Guid(COMMENT_FIELD_GUID.ToString()), row.ItemArray[1])); console.insertJob(dbContext, this.Helper.GetAuthenticationManager().UserInfo.FullName, comme); DTOs.Choice choice = new DTOs.Choice(ERROR_TYPE_FIELD_GUID); comme.Fields.Add(new DTOs.FieldValue(TYPE_FIELD_GUID, choice)); using (kCura.Relativity.Client.IRSAPIClient client = this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(Relativity.API.ExecutionIdentity.System)) { client.APIOptions.WorkspaceID = this.Helper.GetActiveCaseID(); client.Repositories.RDO.UpdateSingle(comme); } } return(retVal); }
public Comment Get(int artifactId) { Comment comment = new Comment(); try { DTOs.RDO commentDTO = new DTOs.RDO(artifactId); commentDTO.Fields = DTOs.FieldValue.AllFields; commentDTO.ArtifactTypeGuids.Add(new Guid(comment.ARTIFACT_TYPE)); commentDTO = client.Repositories.RDO.ReadSingle(artifactId); comment.ArtifactId = commentDTO.ArtifactID; comment.Name = commentDTO.TextIdentifier; Entities.Artifact user = new Entities.Artifact(commentDTO.SystemCreatedBy.ArtifactID); user.Name = commentDTO.SystemCreatedBy.FullName; comment.CreatedBy = user; Entities.Artifact lastUser = new Entities.Artifact(commentDTO.SystemLastModifiedBy.ArtifactID); lastUser.Name = commentDTO.SystemCreatedBy.FullName; comment.LastModifiedBy = lastUser; comment.CreatedOn = commentDTO.SystemCreatedOn.ToString(); comment.LastModifiedOn = commentDTO.SystemLastModifiedOn.ToString(); comment.imageBase64 = (string)commentDTO[new Guid(comment.COMMENT_THUMBNAIL_FIELD)].Value; } catch (Exception) { throw; } return(comment); }
public bool Update(int artifactId, Comment artifact) { DTOs.RDO commentToUpdate = client.Repositories.RDO.ReadSingle(artifactId); commentToUpdate.Fields.Add(new DTOs.FieldValue() { Name = "Comment", Value = artifact.Name }); try { client.Repositories.RDO.UpdateSingle(commentToUpdate); return(true); } catch (Exception) { throw; } }
public int Create(Comment artifact) { int result = 0; DTOs.RDO comment = new DTOs.RDO(); comment.ArtifactTypeGuids.Add(new Guid(artifact.ARTIFACT_TYPE)); comment.Fields.Add(new DTOs.FieldValue(new Guid(artifact.COMMENT), artifact.Name)); comment.Fields.Add(new DTOs.FieldValue(new Guid(artifact.SINGLE_CHOICE_FIELD), new Guid(artifact.TypeChoosed))); try { result = client.Repositories.RDO.CreateSingle(comment); } catch (Exception) { throw; } return(result); }
public override void Execute() { int contador = 0; //Get the current Agent artifactID Int32 agentArtifactID = this.AgentID; //Get a dbContext for the EDDS database IDBContext eddsDBContext = this.Helper.GetDBContext(-1); List <int> worksapcesID = new List <int>(); Comment comment = new Comment(); try { using (IRSAPIClient proxy = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System)) { RelativityAppCore.BLL.Service.RSAPIService.CommentRSAPIService commentRSAPIService = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(proxy); IDBContext DBContext = this.Helper.GetDBContext(-1); DataRowCollection data = DBContext.ExecuteSqlStatementAsDataTable(Queries.GetWorkspacesWithApp).Rows; RaiseMessage("Find for the workspaces with the application", 1); foreach (var item in data[0].ItemArray) { worksapcesID.Add((int)item); } foreach (var item in worksapcesID) { proxy.APIOptions.WorkspaceID = item; DTOs.Query <DTOs.RDO> query = new DTOs.Query <DTOs.RDO>(); DTOs.QueryResultSet <DTOs.RDO> results = new DTOs.QueryResultSet <DTOs.RDO>(); query.ArtifactTypeGuid = new Guid(comment.ARTIFACT_TYPE); query.Fields = DTOs.FieldValue.AllFields; // query.Condition = new BooleanCondition(new Guid(guidSet), BooleanConditionEnum.EqualTo, false); try { results = proxy.Repositories.RDO.Query(query); foreach (var c in results.Results) { RaiseMessage($"verifying if the comment: {c.Artifact.ArtifactID} already has the thumnails", 1); DTOs.RDO commentDto = new DTOs.RDO(c.Artifact.ArtifactID); commentDto.ArtifactTypeGuids.Add(new Guid(comment.ARTIFACT_TYPE)); commentDto.Fields = DTOs.FieldValue.AllFields; commentDto.Fields.Add(new DTOs.FieldValue(new Guid(guidSet))); commentDto = proxy.Repositories.RDO.ReadSingle(c.Artifact.ArtifactID); //bool fieldValue = (bool)commentDto[new Guid(guidSet)].Value; string image = (string)commentDto[new Guid(Image_guid_field)].Value; if (!string.IsNullOrEmpty(image)) { RaiseMessage($"Creating Thumbnails for the comment {c.Artifact.ArtifactID}", 1); string thumbnail = getImage(c.Artifact.ArtifactID, this.Helper.GetDBContext(proxy.APIOptions.WorkspaceID)); commentDto.Fields.Add(new DTOs.FieldValue(new Guid(thumbnailsImage), thumbnail)); commentDto.Fields.Add(new DTOs.FieldValue(new Guid(guidSet), true)); proxy.Repositories.RDO.UpdateSingle(commentDto); } else { contador = contador + 1; commentDto.Fields.Add(new DTOs.FieldValue(new Guid(guidSet), false)); proxy.Repositories.RDO.UpdateSingle(commentDto); } } } catch (Exception) { throw; } } } RaiseMessage($"There are {contador} comments without thumbnail", 1); } catch (System.Exception ex) { //Your Agent caught an exception this.RaiseError(ex.Message, ex.Message); } }