コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }