public List <CORE.DAL.Entities.Comment> GetCommentChilds(List <CORE.DAL.Entities.Comment> comments) { List <CORE.DAL.Entities.Comment> childs = new List <CORE.DAL.Entities.Comment>(); List <CORE.DAL.Entities.Comment> newChilds = new List <CORE.DAL.Entities.Comment>(); using (IRSAPIClient proxy = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System)) { int workspaceId = _workspaceID; proxy.APIOptions.WorkspaceID = workspaceId; CORE.BLL.Service.RSAPIService.CommentRSAPIService cRSAPIService = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(proxy); CORE.BLL.Service.SqlService.CommentSqlService commentService = new CORE.BLL.Service.SqlService.CommentSqlService(_helper.GetDBContext(workspaceId)); foreach (CORE.DAL.Entities.Comment item in comments) { childs = commentService.GetCommentsChild(item.ArtifactId); if (!childs.Count().Equals(0)) { foreach (CORE.DAL.Entities.Comment child in childs) { CORE.DAL.Entities.Comment comment = cRSAPIService.Get(child.ArtifactId); newChilds.Add(comment); } item.CommentChilds = GetCommentChilds(newChilds); } else { item.CommentChilds = childs; } } } return(comments); }
public CORE.DAL.Entities.Comment GetCommentDataByRsapi(int commentAI) { CORE.DAL.Entities.Comment comment = new CORE.DAL.Entities.Comment(); using (IRSAPIClient proxy = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System)) { proxy.APIOptions.WorkspaceID = _workspaceID; CORE.BLL.Service.RSAPIService.CommentRSAPIService csrsapi = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(proxy); CORE.BLL.Service.SqlService.CommentSqlService cssql = new RelativityAppCore.BLL.Service.SqlService.CommentSqlService(_helper.GetDBContext(_workspaceID)); comment = csrsapi.Get(commentAI); comment.CommentChilds = cssql.GetCommentsChild(comment.ArtifactId); List <CORE.DAL.Entities.Comment> childs = new List <RelativityAppCore.DAL.Entities.Comment>(); foreach (var c in comment.CommentChilds) { childs.Add(csrsapi.Get(c.ArtifactId)); } comment.CommentChilds = childs; comment.CommentChilds = GetCommentChilds(comment.CommentChilds.ToList()); } return(comment); }
public IEnumerable <CORE.DAL.Entities.Comment> GetReplysByObjectManager(int artifactId) { List <CORE.DAL.Entities.Comment> childs = new List <CORE.DAL.Entities.Comment>(); List <CORE.DAL.Entities.Comment> newChilds = new List <CORE.DAL.Entities.Comment>(); using (IRSAPIClient proxy = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System)) { int workspaceId = _workspaceID; proxy.APIOptions.WorkspaceID = workspaceId; CORE.BLL.Service.RSAPIService.CommentRSAPIService cRSAPIService = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(proxy); CORE.BLL.Service.SqlService.CommentSqlService commentService = new CORE.BLL.Service.SqlService.CommentSqlService(_helper.GetDBContext(workspaceId)); childs = commentService.GetCommentsChild(artifactId); foreach (var child in childs) { CORE.DAL.Entities.Comment comment = getDataReplyCommentByObjectManager(child.ArtifactId, workspaceId); newChilds.Add(comment); } } return(newChilds); }
public override kCura.EventHandler.Console GetConsole(PageEvent pageEvent) { int activeWorkspaceId = this.Helper.GetActiveCaseID(); //Construct a console object to build the console appearing in the UI. kCura.EventHandler.Console returnConsole = new kCura.EventHandler.Console(); returnConsole.Items = new List <IConsoleItem>(); returnConsole.Title = CONSOLE_TITLE; string select = "<h3 style='color:#11599E'>Comments Tree</h3>"; List <string> elements = new List <string>(); elements.Add(select); using (kCura.Relativity.Client.IRSAPIClient client = this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(Relativity.API.ExecutionIdentity.System)) { client.APIOptions.WorkspaceID = this.Helper.GetActiveCaseID(); Service.SqlService.CommentSqlService commentService = new Service.SqlService.CommentSqlService(this.Helper.GetDBContext(this.Helper.GetActiveCaseID())); Service.RSAPIService.CommentRSAPIService commentRSAPIService = new Service.RSAPIService.CommentRSAPIService(client); Data.Entities.Comment comment = commentRSAPIService.Get(this.ActiveArtifact.ArtifactID); comment.CommentChilds = commentService.GetCommentsChild(comment.ArtifactId); drawCommentTree2(ref elements, (comment.CommentChilds).ToList()); returnConsole.HTMLBlocks = elements; } ConsoleHeader header = new ConsoleHeader("Console Application"); //Construct the submit job button. ConsoleButton submitJobButton = new ConsoleButton(); submitJobButton.Name = INSERT_JOB_BUTTON_NAME; submitJobButton.DisplayText = INSERT_JOB_DISPLAY_TEXT; submitJobButton.ToolTip = INSERT_JOB_TOOL_TIP; submitJobButton.RaisesPostBack = true; submitJobButton.Enabled = true; //Construct the delete job button ConsoleButton deleteJobButton = new ConsoleButton() { Name = DELETE_JOB_BUTTON_NAME, DisplayText = DELETE_JOB_DISPLAY_TEXT, ToolTip = DELETE_JOB_TOOL_TIP, RaisesPostBack = true, Enabled = true }; //Button to see the comment data ConsoleButton seeCommentButton = new ConsoleButton() { Name = "See Comment Data", DisplayText = "Commen Data", ToolTip = "Comment Data", RaisesPostBack = true, Enabled = true }; ConsoleSeparator separador = new ConsoleSeparator(); //If a job is already in the queue, change the text and disable the button. if (pageEvent == PageEvent.PreRender) { SqlParameter commentArtifactId = new SqlParameter("@commentArtifacId", System.Data.SqlDbType.Int); commentArtifactId.Value = ActiveArtifact.ArtifactID; int jobCount = this.Helper.GetDBContext(activeWorkspaceId).ExecuteSqlStatementAsScalar <Int32>(JOB_EXISTS_QUERY, new SqlParameter[] { commentArtifactId }); //Use the helper function to check if a job currently exists. Set Enabled to the opposite value. if (jobCount > 0) { submitJobButton.Enabled = false; deleteJobButton.Enabled = true; } else { submitJobButton.Enabled = true; deleteJobButton.Enabled = false; } //Get the base path to the application. String basePath = this.Application.ApplicationUrl.Substring(0, this.Application.ApplicationUrl.IndexOf("/Case/Mask/")); //Construct the path to the custom page with the current patient artifact id and current workspace. String patientProfilePageUrl = String.Format("{0}/CustomPages/{1}/Home/Index/?artifacId={2}", basePath, COMMENT_HISTORY_APPLICATION_GUID, ActiveArtifact.ArtifactID); //Create the JavaScript for the button and set the button property. String windowOpenJavaScript = String.Format("window.open('{0}', '', 'location=no,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes,width=300,height=400');", patientProfilePageUrl); seeCommentButton.OnClickEvent = windowOpenJavaScript; } //Add the buttons to the console. returnConsole.Items.Add(header); returnConsole.Items.Add(submitJobButton); returnConsole.Items.Add(deleteJobButton); returnConsole.Items.Add(seeCommentButton); returnConsole.Items.Add(separador); return(returnConsole); }
public override Response Execute() { Artifact activeArtifact = this.ActiveArtifact; int activeWorkspaceId = this.Helper.GetActiveCaseID(); string currentUser = this.Helper.GetAuthenticationManager().UserInfo.FullName; IDBContext dbcontext = this.Helper.GetDBContext(activeWorkspaceId); bool result = true; ConsoleEventHandlerComment consoleEventHandler = new ConsoleEventHandlerComment(); Response retVal = new Response() { Success = true, Message = String.Empty }; //verify if the comment has a parent if (!(ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()] == null)) { int parentCommentId = (int)ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()].Value.Value; kCura.Relativity.Client.DTOs.RDO parentComment = new kCura.Relativity.Client.DTOs.RDO(parentCommentId); using (kCura.Relativity.Client.IRSAPIClient client = this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(ExecutionIdentity.System)) { int workspaceId = this.Helper.GetActiveCaseID(); client.APIOptions.WorkspaceID = workspaceId; parentComment = client.Repositories.RDO.ReadSingle(parentCommentId); client.APIOptions.WorkspaceID = -1; kCura.Relativity.Client.DTOs.User userComment = new kCura.Relativity.Client.DTOs.User(parentComment.SystemCreatedBy.ArtifactID); userComment = client.Repositories.User.ReadSingle(parentComment.SystemCreatedBy.ArtifactID); if (ActiveArtifact.IsNew) { MailMessage email = new MailMessage(); string userEmail = userComment.EmailAddress; string author = this.Helper.GetAuthenticationManager().UserInfo.FullName; email.To.Add(new MailAddress(userEmail)); // sentEmailNew(email, author); } } } else { using (kCura.Relativity.Client.IRSAPIClient client = this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(ExecutionIdentity.System)) { string type = string.Empty; int workspaceId = this.Helper.GetActiveCaseID(); client.APIOptions.WorkspaceID = workspaceId; CORE.BLL.Service.RSAPIService.CommentRSAPIService commentRSAPIService = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(client); CORE.DAL.Entities.Comment comment = commentRSAPIService.Get(ActiveArtifact.ArtifactID); ChoiceCollection typeChoices = (ChoiceCollection)this.ActiveArtifact.Fields[COMMENT_TYPE_FIELD_GUID.ToString()].Value.Value; foreach (Choice typeC in typeChoices) { type = typeC.Name; } comment.TypeChoosed = type; auditComment(comment, ActiveArtifact.IsNew, this.Helper.GetDBContext(workspaceId)); } } try { ChoiceCollection typeChoices = (ChoiceCollection)this.ActiveArtifact.Fields[COMMENT_TYPE_FIELD_GUID.ToString()].Value.Value; foreach (Choice typeChoice in typeChoices) { if (typeChoice.Name.Equals("Error")) { result = consoleEventHandler.insertJob(dbcontext, currentUser, activeArtifact); } else { result = consoleEventHandler.deleteJob(dbcontext, activeArtifact.ArtifactID); } } } catch (Exception e) { retVal.Success = false; retVal.Message = e.Message; } return(retVal); }
public override Response Execute() { _logger = this.Helper.GetLoggerFactory().GetLogger().ForContext <PreSaveEventHandlerComment>(); Response retVal = new Response(); retVal.Success = true; retVal.Message = string.Empty; // Console.WriteLine(output); //string output = null; try { String comment = (String)this.ActiveArtifact.Fields[COMMENT_FIEL_GUID.ToString()].Value.Value; string user = (String)this.ActiveArtifact.Fields[SYSTEM_CREATED_BY_FIELD.ToString()].Value.Value; if (!(ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()] == null)) { using (kCura.Relativity.Client.IRSAPIClient client = this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(Relativity.API.ExecutionIdentity.System)) { client.APIOptions.WorkspaceID = this.Helper.GetActiveCaseID(); Service.RSAPIService.CommentRSAPIService commentRSAPIService = new Service.RSAPIService.CommentRSAPIService(client); Service.SqlService.CommentSqlService commentSqlService = new Service.SqlService.CommentSqlService(this.Helper.GetDBContext(Helper.GetActiveCaseID())); int parentCommentId = (int)this.ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()].Value.Value; Data.Entities.Comment parentComment = new Data.Entities.Comment(parentCommentId); parentComment = commentRSAPIService.Get(parentCommentId); List <Data.Entities.Comment> commentsChild = commentSqlService.GetCommentsChild(parentComment.ArtifactId); parentComment.CommentChilds = commentsChild; int user1 = parentComment.CreatedBy.ArtifactId; int user2 = this.Helper.GetAuthenticationManager().UserInfo.ArtifactID; if (commentsChild.Count.Equals(0)) { if (user1.Equals(user2)) { throw new StartConversation(); } } } } if (String.IsNullOrWhiteSpace(comment)) { _logger.LogError($"the comment field was not fill up "); throw new FieldMissingException("Comment"); } if (!ActiveArtifact.IsNew) { using (kCura.Relativity.Client.IRSAPIClient client = this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(ExecutionIdentity.System)) { client.APIOptions.WorkspaceID = this.Helper.GetActiveCaseID(); Service.RSAPIService.CommentRSAPIService commentRSAPIService = new Service.RSAPIService.CommentRSAPIService(client); Data.Entities.Comment currentComment = new Data.Entities.Comment(ActiveArtifact.ArtifactID); currentComment = commentRSAPIService.Get(ActiveArtifact.ArtifactID); int commentUserId = currentComment.CreatedBy.ArtifactId; int currentUserId = this.Helper.GetAuthenticationManager().UserInfo.ArtifactID; if (!commentUserId.Equals(currentUserId)) { throw new DontEditAnotherComment(); } } } Boolean typeSelected = false; ChoiceCollection typeField = (ChoiceCollection)this.ActiveArtifact.Fields[TYPE_FIELD_GUID.ToString()].Value.Value; foreach (Choice typeChoice in typeField) { if (typeChoice.IsSelected) { typeSelected = true; break; } } if (!typeSelected) { throw new FieldMissingException("Comment Type"); } } catch (FieldMissingException fielMissingEx) { retVal.Success = false; retVal.Message = fielMissingEx.Message; } catch (Exception e) { retVal.Success = false; retVal.Message = e.Message; } return(retVal); }
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); } }