public override Response ValidateLayout()
        {
            Response retVal = new Response()
            {
                Success = true,
                Message = "Success all comment jobs were inserted"
            };

            string comment = (string)this.LayoutMask.Fields[COMMENT_FIELD_GUID.ToString()].Value.Value;

            if (!string.IsNullOrEmpty(comment))
            {
                retVal.Success = false;
                retVal.Message = "This mass edit operation requires that you leave the comment field blank";
                return(retVal);
            }

            ChoiceCollection choices = (ChoiceCollection)this.LayoutMask.Fields[TYPE_FIELD_GUID.ToString()].Value.Value;

            foreach (Choice choice in choices)
            {
                if (!choice.Name.Equals("Error"))
                {
                    retVal.Success = false;
                    retVal.Message = "This mass edit operation requires that type selected is Error";
                    return(retVal);
                }
            }


            return(retVal);
        }
        private void LoadVariables()
        {
            SelectedObjectType            = string.Empty;
            SvcManager                    = Helper.GetServicesManager();
            Logger                        = GetLoggerAsync().Result;
            WorkspaceArtifactId           = Helper.GetActiveCaseID();
            IdentityCurrentUser           = ExecutionIdentity.CurrentUser;
            IdentitySystem                = ExecutionIdentity.System;
            CurrentArtifactId             = ActiveArtifact.ArtifactID;
            CurrentUserArtifactId         = Helper.GetAuthenticationManager().UserInfo.ArtifactID;
            DbContextEdds                 = Helper.GetDBContext(-1);
            DbContext                     = Helper.GetDBContext(WorkspaceArtifactId);
            ImportManagerResultsTableName = $"{Constant.Names.TablePrefix}Import_Manager_Results_{Guid.NewGuid()}";
            ColObjectType                 = (ChoiceCollection)ActiveArtifact.Fields[GetArtifactIdByGuid(Constant.Guids.Field.ImportUtilityJob.ObjectType)].Value.Value;

            //Set the selected Object Type from the record
            foreach (Choice objectType in ColObjectType)
            {
                if (!objectType.IsSelected)
                {
                    continue;
                }
                SelectedObjectType = objectType.Name;
                break;
            }

            ImportUtilityJob = new ImportConsoleJob(SvcManager, DbContextEdds, DbContext, IdentityCurrentUser, IdentitySystem, ArtifactQueries, SqlQueryHelper, Logger, WorkspaceArtifactId, CurrentArtifactId, CurrentUserArtifactId, string.Empty, SelectedObjectType, ImportManagerResultsTableName);
        }
Пример #3
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public RuleWorld()
 {
     // Set values for current rule:
     // HeaderCollection, choices to make and
     Headers = new HeaderCollection();
     Choices = new ChoiceCollection();
     //Conclusions = new ConclusionCollection();
 }
Пример #4
0
        public override Response Execute()
        {
            var response = new Response()
            {
                Success = true,
                Message = string.Empty
            };

            var statusFieldGuid = GetArtifactIdByGuid(Constant.Guids.Field.MarkupUtilityImportJob.Status);

            if (ActiveArtifact.IsNew)
            {
                //Update the Status field
                ActiveArtifact.Fields[statusFieldGuid].Value.Value = Constant.Status.Job.NEW;

                //Update the Job Type field
                var jobTypeFieldGuid        = GetArtifactIdByGuid(Constant.Guids.Field.MarkupUtilityImportJob.JobType);
                var jobTypeChoiceImportGuid = GetArtifactIdByGuid(Constant.Guids.Choices.ImportJobType.Import);
                var collection = new ChoiceCollection {
                    new Choice(jobTypeChoiceImportGuid, "")
                };
                var cfv = (ChoiceFieldValue)ActiveArtifact.Fields[jobTypeFieldGuid].Value;
                cfv.Choices = collection;
            }
            else
            {
                var status        = ActiveArtifact.Fields[statusFieldGuid].Value.Value;
                var statusArray   = new[] { Constant.Status.Job.NEW, Constant.Status.Job.ERROR, Constant.Status.Job.VALIDATION_FAILED };
                var jobInProgress = Array.IndexOf(statusArray, status) > -1;

                if (!jobInProgress)
                {
                    return(response);
                }
                var currentWorkspaceArtifactId = Helper.GetActiveCaseID();
                var artifactId = ActiveArtifact.ArtifactID;

                using (var proxy = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
                {
                    proxy.APIOptions.WorkspaceID = currentWorkspaceArtifactId;
                    var importJob          = proxy.Repositories.RDO.ReadSingle(artifactId);
                    var value              = importJob[Constant.Guids.Field.MarkupUtilityImportJob.RedactionFile].ValueAsSingleObject;
                    var oldRedactionFileId = value.ArtifactID;
                    var redactionFileGuid  = GetArtifactIdByGuid(Constant.Guids.Field.MarkupUtilityImportJob.RedactionFile);
                    var newRedactionFileId = ActiveArtifact.Fields[redactionFileGuid].Value.Value;

                    if (newRedactionFileId.Equals(oldRedactionFileId))
                    {
                        return(response);
                    }
                    response.Message = "Unable to change Import Redaction File for completed jobs or jobs in progress";
                    response.Success = false;
                }
            }

            return(response);
        }
Пример #5
0
        /// <summary>
        /// Updates the available choices.
        /// </summary>
        private void UpdateChoices()
        {
            if (AllowSpecify && (ChoiceCollection.Count > 0))
            {
                ChoiceCollection.RemoveAt(ChoiceCollection.Count - 1);
            }

            if (AllowSpecify)
            {
                var specifyChoice = new Choice(ChoiceSpecify, string.Empty, true);
                ChoiceCollection.Add(specifyChoice);

                if (SelectedChoice == null)
                {
                    SelectedChoice = specifyChoice;
                }
            }

            Resources["ChoiceCollection"] = ChoiceCollection;
        }
Пример #6
0
        private void LoadVariables()
        {
            SelectedObjectType  = string.Empty;
            SvcManager          = Helper.GetServicesManager();
            Logger              = GetLoggerAsync().Result;
            WorkspaceArtifactId = Helper.GetActiveCaseID();
            IdentityCurrentUser = ExecutionIdentity.CurrentUser;
            IdentitySystem      = ExecutionIdentity.System;
            CurrentArtifactId   = ActiveArtifact.ArtifactID;
            DbContextEdds       = Helper.GetDBContext(-1);
            DbContext           = Helper.GetDBContext(WorkspaceArtifactId);
            ColObjectType       = (ChoiceCollection)ActiveArtifact.Fields[Constant.Guids.Field.ExportUtilityJob.ObjectType.ToString()].Value.Value;

            var priority = ActiveArtifact.Fields[Constant.Guids.Field.ExportUtilityJob.Priority.ToString()];

            if (priority.Value?.Value != null)
            {
                Priority = (int)priority.Value.Value;
            }
            else
            {
                Priority = 0;
            }

            //Set the selected Object Type from the record
            foreach (Choice objectType in ColObjectType)
            {
                if (!objectType.IsSelected)
                {
                    continue;
                }
                SelectedObjectType = objectType.Name;
                break;
            }

            ExportUtilityJob = new ExportConsoleJob(SvcManager, DbContextEdds, DbContext, IdentityCurrentUser, IdentitySystem, ArtifactQueries, SqlQueryHelper, Logger, WorkspaceArtifactId, CurrentArtifactId, string.Empty, SelectedObjectType, Priority);
        }
Пример #7
0
    public override Response Execute()
    {
        Response response = new Response
        {
            Success = true,
            Message = String.Empty
        };

        try
        {
            // Fixed-Length Text--------------------------------------------------------------------
            // Get
            string name = (string)ActiveArtifact.Fields["Name"].Value.Value;
            // Set
            ActiveArtifact.Fields["Name"].Value.Value = "Andrew Zipper";

            // Date--------------------------------------------------------------------------------
            // Get
            DateTime startDate =
                (DateTime)ActiveArtifact.Fields["Employment Start Date"].Value.Value;
            // Set
            DateTime newStartDate = new DateTime(1999, 12, 31);
            ActiveArtifact.Fields["Employment Start Date"].Value.Value = newStartDate;

            // Whole Number-------------------------------------------------------------------------
            // Get
            int employmentDuration =
                (int)ActiveArtifact.Fields["Employment Duration in Years"].Value.Value;
            // Set
            ActiveArtifact.Fields["Employment Duration in Years"].Value.Value =
                DateTime.Today.Year - newStartDate.Year;

            // Yes/No-------------------------------------------------------------------------------
            // Get
            bool isSeniorManagement =
                (bool)ActiveArtifact.Fields["Is Part of Senior Management?"].Value.Value;
            // Set
            ActiveArtifact.Fields["Is Part of Senior Management?"].Value.Value = false;

            // Single Choice------------------------------------------------------------------------
            // Get
            kCura.EventHandler.ChoiceCollection interestLevel =
                (ChoiceCollection)ActiveArtifact.Fields["Interest Level"].Value.Value;
            // Set
            // Even though it is just a single choice, we have to wrap it in a ChoiceCollection object
            kCura.EventHandler.ChoiceCollection newInterestLevel = new ChoiceCollection();
            kCura.EventHandler.Choice           lowChoice        = new Choice(1147813, "Low");
            newInterestLevel.Add(lowChoice);
            ActiveArtifact.Fields["Interest Level"].Value.Value = newInterestLevel;

            // Multiple Choice----------------------------------------------------------------------
            // Get
            kCura.EventHandler.ChoiceCollection tags =
                (ChoiceCollection)ActiveArtifact.Fields["Tags"].Value.Value;
            // Set
            kCura.EventHandler.ChoiceCollection newSetOfTags = new ChoiceCollection
            {
                new Choice(1147817, "Executive"),
                new Choice(1147818, "Person of Interest")
            };
            ActiveArtifact.Fields["Tags"].Value.Value = newSetOfTags;

            // Currency-----------------------------------------------------------------------------
            // Get
            decimal lastKnownIncome =
                (decimal)ActiveArtifact.Fields["Last Known Income Amount"].Value.Value;
            // Set
            ActiveArtifact.Fields["Last Known Income Amount"].Value.Value = new decimal(1700000.00);

            // Decimal------------------------------------------------------------------------------
            // Get
            decimal percentOwnership =
                (decimal)ActiveArtifact.Fields["Percent Ownership"].Value.Value;
            // Set
            ActiveArtifact.Fields["Percent Ownership"].Value.Value = new decimal(25.00);

            // User---------------------------------------------------------------------------------
            // Get
            if (!ActiveArtifact.Fields["Current User"].Value.IsNull)
            {
                int currentUserId =
                    (int)ActiveArtifact.Fields["Current User"].Value.Value;
            }
            // Set
            int newUserId = 1026092;
            ActiveArtifact.Fields["Current User"].Value.Value = newUserId;

            // File---------------------------------------------------------------------------------
            // Get
            kCura.EventHandler.FileFieldValue currentFile =
                (FileFieldValue)ActiveArtifact.Fields["Current File"].Value;
            // to read the file as a stream:
            if (!currentFile.IsNull)
            {
                using (Stream stream = currentFile.FileValue.FileStream)
                {
                    // read the file
                }
            }
            // Set
            if (!currentFile.IsNull)
            {
                using (System.IO.MemoryStream memStream = new MemoryStream())
                {
                    byte[] byteArray = System.Text.Encoding.UTF8.GetBytes("This is a test text file.");
                    memStream.Write(byteArray, 0, byteArray.Length);
                    FileValue fileValue = new kCura.EventHandler.FileValue("TestFile.txt", memStream);
                    ActiveArtifact.Fields["Current File"].Value.Value = fileValue;
                }
            }

            // Long Text----------------------------------------------------------------------------
            // Get
            string currentFileText = (string)ActiveArtifact.Fields["Description"].Value.Value;
            // Set
            ActiveArtifact.Fields["Description"].Value.Value =
                "This custodian has an abnormally large number of documents.";

            // Single Object------------------------------------------------------------------------
            // Get - returns the Artifact ID of the associated object
            int parentCustodian =
                (int)ActiveArtifact.Fields["Parent Custodian"].Value.Value;
            // Set
            int newParentCustodianId = 1147821;
            ActiveArtifact.Fields["Parent Custodian"].Value.Value = newParentCustodianId;

            // Multiple Object----------------------------------------------------------------------
            // Get - returns an array of the Artifact IDs of the associated objects
            int[] associatedDocs = (int[])ActiveArtifact.Fields["Documents"].Value.Value;
            // Set
            int   newArraySize = associatedDocs.Length + 1;
            int[] newDocs      = new int[newArraySize];
            newDocs[0] = 1039364; // specify Artifact ID of document we want to include
            associatedDocs.CopyTo(newDocs, 1);
            ActiveArtifact.Fields["Documents"].Value.Value = newDocs;
        }

        catch (InvalidCastException ice)
        {
            response.Message = $"Invalid cast occured: {ice.Message}";
            response.Success = false;
        }

        catch (Exception ex)
        {
            //Change the response Success property to false to let the user know an error occurred
            response.Success = false;
            response.Message = ex.ToString();
        }

        return(response);
    }
Пример #8
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);
        }
        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);
        }