Exemple #1
0
        private void Predecessor_JobTaskCompleted(JobTask sender, JobTaskResult jobTaskResult)
        {
            if (this.State == JobTaskState.PENDING)
            {
                this.State = JobTaskState.IN_PROGRESS;
                UpdateTask();
            }

            if (this.Asset == null)
            {
                try
                {
                    var type = jobTaskResult.ResultType;

                    var ride = type.GetProperty("Asset");
                    if (ride.PropertyType != typeof(AssetModel))
                    {
                        throw new InvalidCastException("Type Verification Asset field failed");
                    }

                    Asset = ride.GetValue(jobTaskResult, null) as AssetModel;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemple #2
0
        private void Predecessor_JobTaskCompleted(JobTask sender, JobTaskResult jobTaskResult)
        {
            if (this.State == JobTaskState.PENDING)
            {
                this.State = JobTaskState.IN_PROGRESS;
                UpdateTask();
            }

            // Making sure result only propagates if this doesn't have an asset assigned yet
            if (this.Asset == null)
            {
                try
                {
                    var type = jobTaskResult.ResultType;

                    VerifyPropertyTypesFromResult(type);

                    var asset = type.GetProperty("Asset");
                    Asset = asset.GetValue(jobTaskResult, null) as AssetModel;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemple #3
0
        private void DeleteMessageOnServer(string hostname, int port, bool useSsl, PoolEntity pool, List <CommunicationPoolEntity> mailList,
                                           List <string> mailMsgIds, JobTaskResult taskResult)
        {
            if (mailList != null && mailList.Count > 0)
            {
                Task.Factory.StartNew(() => Parallel.ForEach(mailList,
                                                             new ParallelOptions {
                    MaxDegreeOfParallelism = WebConfig.GetTotalCountToProcess()
                },
                                                             x =>
                {
                    lock (sync)
                    {
                        Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Mail On Server").Add("Subject", x.Subject)
                                    .Add("SenderAddress", x.SenderAddress).Add("MessageNumber", x.MessageNumber).ToInputLogString());

                        try
                        {
                            string decryptedstring = StringCipher.Decrypt(pool.Password, Constants.PassPhrase);
                            this.DeleteMail(hostname, port, useSsl, pool.Email, decryptedstring, mailMsgIds);
                            Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Mail On Server").ToSuccessLogString());
                        }
                        catch (Exception ex)
                        {
                            Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Mail On Server").Add("Error Message", ex.Message).ToFailLogString());
                            Logger.Error("Exception occur:\n", ex);

                            _commPoolDataAccess = new CommPoolDataAccess(_context);
                            if (_commPoolDataAccess.DeleteMailContent(x, taskResult))
                            {
                                Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Communication Pool").Add("JobId", x.JobId).Add("SRId", x.SRId).ToSuccessLogString());
                            }
                            else
                            {
                                Logger.Info(_logMsg.Clear().SetPrefixMsg("Delete Communication Pool").Add("JobId", x.JobId).Add("SRId", x.SRId).ToFailLogString());
                            }
                        }
                    }
                })).Wait();

                // Override status response
                if (taskResult.NumFailedDelete > 0)
                {
                    taskResult.StatusResponse.Status      = Constants.StatusResponse.Failed;
                    taskResult.StatusResponse.Description = "Unable to delete emails";
                }
            }
        }
Exemple #4
0
        private void Predecessor_JobTaskCompleted(JobTask sender, JobTaskResult jobTaskResult)
        {
            if (this.State == JobTaskState.PENDING)
            {
                this.State = JobTaskState.IN_PROGRESS;
                UpdateTask();
            }

            try
            {
                var type = jobTaskResult.ResultType;

                VerifyPropertyTypesFromResult(type);

                var asset = type.GetProperty("Asset");
                Asset = asset.GetValue(jobTaskResult, null) as AssetModel;
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #5
0
        private void Predecessor_JobTaskCompleted(JobTask sender, JobTaskResult jobTaskResult)
        {
            if (this.State == JobTaskState.PENDING)
            {
                this.State = JobTaskState.IN_PROGRESS;
                UpdateTask();
            }

            try
            {
                var type = jobTaskResult.ResultType;

                var ride = type.GetProperty("Asset");
                if (ride.PropertyType != typeof(AssetModel))
                    throw new InvalidCastException("Type Verification Asset field failed");

                Asset = ride.GetValue(jobTaskResult, null) as AssetModel;
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #6
0
        public JobTaskResult AddMailContent(string hostname, int port, bool useSsl, PoolEntity pool)
        {
            JobTaskResult taskResult = new JobTaskResult();

            taskResult.StatusResponse = new StatusResponse();
            taskResult.Username       = pool.Email;

            try
            {
                if (string.IsNullOrWhiteSpace(pool.Password))
                {
                    throw new CustomException("Password is required");
                }

                int           refNumOfSR    = 0;
                int           refNumOfFax   = 0;
                int           refNumOfWeb   = 0;
                int           refNumOfEmail = 0;
                List <string> mailMsgIds    = null;

                _commPoolDataAccess = new CommPoolDataAccess(_context);
                List <CommunicationPoolEntity> mailList = this.FetchAllMessages(hostname, port, useSsl, pool);

                Logger.Info(_logMsg.Clear().SetPrefixMsg("Add Mail Content").Add("Username", pool.Email).Add("MailList Size", mailList.Count).ToInputLogString());

                taskResult.TotalEmailRead = mailList.Count;
                bool success = _commPoolDataAccess.AddMailContent(mailList, ref refNumOfSR, ref refNumOfFax, ref refNumOfWeb, ref refNumOfEmail);
                taskResult.NumOfSR         = refNumOfSR;
                taskResult.NumOfFax        = refNumOfFax;
                taskResult.NumOfKKWebSite  = refNumOfWeb;
                taskResult.NumOfEmail      = refNumOfEmail;
                taskResult.NumFailedDelete = mailList.Count(x => x.IsDeleted == false);

                if (success)
                {
                    if (mailList.Any(x => x.IsDeleted))
                    {
                        mailMsgIds = mailList.Where(x => x.IsDeleted).Select(x => x.UID).ToList();

                        #region "Delete mail list from user's mailboxes"

                        this.DeleteMessageOnServer(hostname, port, useSsl, pool, mailList, mailMsgIds, taskResult);

                        #endregion
                    }

                    if (taskResult.NumFailedDelete == 0)
                    {
                        taskResult.StatusResponse.Status      = Constants.StatusResponse.Success;
                        taskResult.StatusResponse.Description = string.Empty;
                    }
                    else
                    {
                        taskResult.StatusResponse.Status      = Constants.StatusResponse.Failed;
                        taskResult.StatusResponse.Description = "Unable to delete emails";
                    }

                    Logger.Info(_logMsg.Clear().SetPrefixMsg("Add Mail Content").ToSuccessLogString());
                }
                else
                {
                    taskResult.StatusResponse.Status      = Constants.StatusResponse.Failed;
                    taskResult.StatusResponse.Description = "Failed to save data";
                    Logger.Info(_logMsg.Clear().SetPrefixMsg("Add Mail Content").Add("Error Message", taskResult.StatusResponse.Description).ToFailLogString());
                }

                return(taskResult);
            }
            catch (CustomException cex)
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Add Mail Content").Add("Error Message", cex.Message).ToFailLogString());
                Logger.Error("Exception occur:\n", cex);
                taskResult.StatusResponse.Status      = Constants.StatusResponse.Failed;
                taskResult.StatusResponse.Description = cex.Message;
            }
            catch (Exception ex)
            {
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Add Mail Content").Add("Error Message", ex.Message).ToFailLogString());
                Logger.Error("Exception occur:\n", ex);
                taskResult.StatusResponse.Status      = Constants.StatusResponse.Failed;
                taskResult.StatusResponse.Description = ex.Message;
            }

            return(taskResult);
        }
Exemple #7
0
 public JobActionFeed(JobTaskResult jobTaskResult)
 {
     this.jobTaskResult = jobTaskResult;
 }
Exemple #8
0
 private void _terminalTask_JobTaskCompleted(JobTask sender, JobTaskResult result)
 {
     CompleteJob();
 }
Exemple #9
0
 protected void EnsureCorrelationIsValid(TTask task, JobTaskResult result)
 {
     Ensure.That(result.CorrelationId)
     .WithMessage("The CorrelationId on the task result does not match the CorrelationId of the source task.")
     .Is(task.CorrelationId);
 }
Exemple #10
0
 private void _terminalTask_JobTaskCompleted(JobTask sender, JobTaskResult result)
 {
     CompleteJob();
 }