/// <summary> /// Initializes Job BEO /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="bootParameters">Boot parameters</param> /// <param name="createdBy">Job created by</param> /// <returns>Job Business Entity</returns> protected override SaveSearchResultsJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { LogMessage(Constants.InitializationStartMessage, false, LogCategory.Job, null); LogMessage(Constants.InitializationStartMessage, GetType(), Constants.InitializeMethodFullName, EventLogEntryType.Information, jobId, jobRunId); _taskBatchSize = GetMaximumDocumentChunkSize(); //Constructing Search Results property Beo from passed boot paramter _searchResultsProperty = (SearchResultsPropertiesBEO) XmlUtility.DeserializeObject(bootParameters, typeof(SearchResultsPropertiesBEO)); //Initialize the JobBEO object _jobBeo.JobName = _searchResultsProperty.SearchResultsName; _jobBeo.JobDescription = _searchResultsProperty.SearchResultsDescription; _jobBeo.SearchQueryId = _searchResultsProperty.SearchResultsId; _userEntityOfJobOwner = UserBO.GetUserUsingGuid(createdBy); _jobBeo.JobScheduleCreatedBy = (_userEntityOfJobOwner.DomainName.Equals("N/A")) ? _userEntityOfJobOwner.UserId : _userEntityOfJobOwner.DomainName + "\\" + _userEntityOfJobOwner.UserId; _jobBeo.JobTypeName = Constants.JobTypeName; _jobBeo.JobId = jobId; _jobBeo.JobRunId = jobRunId; _jobBeo.DocumentQuery = _searchResultsProperty.DocumentQuery; return(_jobBeo); }
/// <summary> /// Mock Session : Windows job doesn't /// </summary> private void MockSession() { #region Mock _webContext = new MockWebOperationContext(); var userProp = new UserBusinessEntity { UserGUID = _mCreatedBy }; //Mock HttpContext & HttpSession : Calling from Worker so doesn't contain HttpContext. var mockContext = new Mock <HttpContextBase>(); var mockSession = new Mock <HttpSessionStateBase>(); if (_mUserProp != null) { userProp = _mUserProp; } else { _mUserProp = UserBO.AuthenticateUsingUserGuid(_mCreatedBy); userProp = _mUserProp; } var userSession = new UserSessionBEO(); SetUserSession(userProp, userSession); mockSession.Setup(ctx => ctx["UserDetails"]).Returns(userProp); mockSession.Setup(ctx => ctx["UserSessionInfo"]).Returns(userSession); mockSession.Setup(ctx => ctx.SessionID).Returns(Guid.NewGuid().ToString()); mockContext.Setup(ctx => ctx.Session).Returns(mockSession.Object); EVHttpContext.CurrentContext = mockContext.Object; #endregion }
/// <summary> /// method to set the context and pass the user object to search services /// </summary> /// <param name="adminSession"></param> /// <param name="currUser"></param> /// <param name="toggle"></param> private void SetContext(UserSessionBEO adminSession, UserBusinessEntity currUser, bool toggle) { var mockContext = new Mock <HttpContextBase>(); var mockSession = new Mock <HttpSessionStateBase>(); if (toggle) { var currentSessionUser = new UserSessionBEO { UserGUID = currUser.UserGUID, UserId = currUser.UserId, DomainName = currUser.DomainName, Timezone = currUser.Timezone, IsSuperAdmin = currUser.IsSuperAdmin }; mockSession.Setup(ctx => ctx[Constants.UserSessionInfo]).Returns(currentSessionUser); } else { mockSession.Setup(ctx => ctx[Constants.UserSessionInfo]).Returns(adminSession); } mockSession.Setup(ctx => ctx.SessionID).Returns(Guid.NewGuid().ToString()); mockContext.Setup(ctx => ctx.Session).Returns(mockSession.Object); EVHttpContext.CurrentContext = mockContext.Object; }
/// <summary> /// This is the overridden Initialize() method. /// </summary> /// <param name="jobId">Job Identifier.</param> /// <param name="jobRunId">Job Run Identifier.</param> /// <param name="bootParameters">Boot Parameters.</param> /// <param name="createdBy">Created By Guid</param> /// <returns>jobParameters</returns> protected override BaseJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { m_UserBusinessEntity = null; try { EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Start, EventLogEntryType.Information); //Create Folders for Temporary Storage this.CreateFoldersForTemperoryStorage(); //Clean Source Directory this.CleanSharedSpaceForSourceDirectory(); //Clean Zip Files this.CleanZipFilesInSharedSpace(); //filling properties of the job parameter this.m_Job.JobId = jobId; this.m_Job.JobRunId = jobRunId; this.m_Job.JobName = Constants.EmailJob; this.m_UserBusinessEntity = UserBO.GetUserUsingGuid(createdBy); this.m_Job.JobScheduleCreatedBy = (this.m_UserBusinessEntity.DomainName.Equals(Constants.NotApplicable)) ? this.m_UserBusinessEntity.UserId : this.m_UserBusinessEntity.DomainName + Constants.PathSeperator + this.m_UserBusinessEntity.UserId; this.m_Job.JobTypeName = Constants.EmailDocuments; // Default settings this.m_Job.StatusBrokerType = BrokerType.Database; this.m_Job.CommitIntervalBrokerType = BrokerType.ConfigFile; this.m_Job.CommitIntervalSettingType = SettingType.CommonSetting; if (bootParameters != null) { this.m_Job.BootParameters = bootParameters; } else { DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed); throw new EVException().AddDbgMsg("{0}:{1}:{2}", jobId, Constants.EmailJobInitialisation, Constants.XmlNotWellFormed).AddResMsg(ErrorCodes.XmlStringNotWellFormed); } EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Success, EventLogEntryType.Information); } catch (EVException ex) { //Send Email Failure notification SendEmailBO.SendNotification(jobId.ToString(CultureInfo.InvariantCulture), false); DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed); EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.ToUserString(), EventLogEntryType.Information); this.JobLogInfo.AddParameters(Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.ToUserString()); EVJobException jobException = new EVJobException(ErrorCodes.ProblemInJobInitialization, ex, this.JobLogInfo); throw (jobException); } catch (Exception ex) { //Send Email Failure notification SendEmailBO.SendNotification(jobId.ToString(CultureInfo.InvariantCulture), false); //Update Delivery Status to Failed DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed); //Handle exception in initialize EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.Message, EventLogEntryType.Information); this.JobLogInfo.AddParameters(Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.Message); EVJobException jobException = new EVJobException(ErrorCodes.ProblemInJobInitialization, ex, this.JobLogInfo); throw (jobException); } return(m_Job); }
/// <summary> /// Sets the usersession object using the UserBusinessEntity details /// </summary> /// <param name="userProp"></param> /// <param name="userSession"></param> private static void SetUserSession(UserBusinessEntity userProp, UserSessionBEO userSession) { userSession.UserId = userProp.UserId; userSession.UserGUID = userProp.UserGUID; userSession.DomainName = userProp.DomainName; userSession.IsSuperAdmin = userProp.IsSuperAdmin; userSession.LastPasswordChangedDate = userProp.LastPasswordChangedDate; userSession.PasswordExpiryDays = userProp.PasswordExpiryDays; userSession.Timezone = userProp.Timezone; }
private void SetUserSession(string createdByGuid, UserBusinessEntity userProp, UserSessionBEO userSession) { userSession.UserId = userProp.UserId; userSession.UserGUID = createdByGuid; userSession.DomainName = userProp.DomainName; userSession.IsSuperAdmin = userProp.IsSuperAdmin; userSession.LastPasswordChangedDate = userProp.LastPasswordChangedDate; userSession.PasswordExpiryDays = userProp.PasswordExpiryDays; userSession.Timezone = userProp.Timezone; }
private void SetUserSession(string createdByGuid, UserBusinessEntity userProp, UserSessionBEO userSession) { userSession.UserId = userProp.UserId; userSession.UserGUID = createdByGuid; userSession.DomainName = userProp.DomainName; userSession.IsSuperAdmin = userProp.IsSuperAdmin; userSession.LastPasswordChangedDate = userProp.LastPasswordChangedDate; userSession.PasswordExpiryDays = userProp.PasswordExpiryDays; userSession.Timezone = userProp.Timezone; userSession.FirstName = userProp.FirstName; userSession.LastName = userProp.LastName; }
//Key : Newly generated Id during overlay //Value : Id generated earlier(during Append) #endregion #region OverDrive protected override void BeginWork() { base.BeginWork(); _jobParameter = GetImportBEO(BootParameters); if (_jobParameter != null && !string.IsNullOrEmpty(_jobParameter.CreatedBy)) { //Get User Information , Its needed for search _userInfo = UserBO.AuthenticateUsingUserGuid(_jobParameter.CreatedBy); _userInfo.CreatedBy = _jobParameter.CreatedBy; _isIncludeNativeFile = (_jobParameter != null && _jobParameter.IsImportNativeFiles); } }
/// <summary> /// This is the overridden Initialize() method. /// </summary> /// <param name="jobId">Job Identifier.</param> /// <param name="jobRunId">Job Run Identifier.</param> /// <param name="bootParameters">Boot Parameters.</param> /// <param name="createdBy">string</param> /// <returns>jobParameters</returns> protected override BaseJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { try { EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeStart, EventLogEntryType.Information); //Create Folders for Temporary storage this.CreateFoldersForTemperoryStorage(); //Clean shared Space this.CleanSharedSpace(); //filling properties of the job parameter this.m_Job.JobId = jobId; this.m_Job.JobRunId = jobRunId; this.m_Job.JobName = Constants.PrintJobName; this.m_UserBusinessEntity = UserBO.GetUserUsingGuid(createdBy); this.m_Job.JobScheduleCreatedBy = (this.m_UserBusinessEntity.DomainName.Equals(Constants.NA)) ? this.m_UserBusinessEntity.UserId : this.m_UserBusinessEntity.DomainName.ConcatStrings(new List <string> { Constants.PathSeperator, this.m_UserBusinessEntity.UserId }); this.m_Job.JobTypeName = Constants.PrintJobTypeName; // Default settings this.m_Job.StatusBrokerType = BrokerType.Database; this.m_Job.CommitIntervalBrokerType = BrokerType.ConfigFile; this.m_Job.CommitIntervalSettingType = SettingType.CommonSetting; if (bootParameters != null) { this.m_Job.BootParameters = bootParameters; //Update the delivery status to "running" state DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Running); EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeSuccess, EventLogEntryType.Information); } else { DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed); EvLog.WriteEntry(jobId + Constants.Colon + Constants.PrintJobInitialisation, Constants.JobXmlNotWellFormed, EventLogEntryType.Information); throw new EVException().AddResMsg(ErrorCodes.XmlStringNotWellFormed); } } catch (EVException ex) { DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed); EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeFailed + " : " + ex.ToUserString() + ":" + ex.InnerException + ":" + ex.StackTrace, EventLogEntryType.Information); LogException(this.JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization); } catch (Exception ex) { DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed); //Handle exception in initialize EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeFailed + " : " + ex.Message, EventLogEntryType.Information); LogException(this.JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization); } return(m_Job); }
/// <summary> /// Sets the user session object using the UserBusinessEntity details. /// </summary> /// <param name="createdByGuid">Created by User Guid.</param> /// <param name="userProp">User Properties.</param> /// <param name="userSession">User Session.</param> private static void SetUserSession(string createdByGuid, UserBusinessEntity userProp, UserSessionBEO userSession) { userSession.UserId = userProp.UserId; userSession.UserGUID = createdByGuid; userSession.DomainName = userProp.DomainName; userSession.IsSuperAdmin = userProp.IsSuperAdmin; userSession.LastPasswordChangedDate = userProp.LastPasswordChangedDate; userSession.PasswordExpiryDays = userProp.PasswordExpiryDays; userSession.Timezone = userProp.Timezone; if (userProp.Organizations.Any()) { userSession.Organizations.AddRange(userProp.Organizations); } }
/// <summary> /// Initializes Job BEO /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="bootParameters">Boot parameters</param> /// <param name="createdBy">Job created by</param> /// <returns>Job Business Entity</returns> protected override BaseJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { BaseJobBEO jobBeo = new BaseJobBEO(); try { EvLog.WriteEntry(Constants.JobTypeName + " - " + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Start, EventLogEntryType.Information); //Initialize the JobBEO object jobBeo.JobId = jobId; jobBeo.JobRunId = jobRunId; jobBeo.JobName = Constants.JobTypeName + " " + DateTime.UtcNow; //fetch UserEntity UserBusinessEntity userBusinessEntity = UserBO.GetUserUsingGuid(createdBy); jobBeo.JobScheduleCreatedBy = (userBusinessEntity.DomainName.Equals("N/A")) ? userBusinessEntity.UserId : userBusinessEntity.DomainName + "\\" + userBusinessEntity.UserId; userBusinessEntity = null; jobBeo.JobTypeName = Constants.JobTypeName; // Default settings jobBeo.StatusBrokerType = BrokerType.Database; jobBeo.CommitIntervalBrokerType = BrokerType.ConfigFile; jobBeo.CommitIntervalSettingType = SettingType.CommonSetting; if (bootParameters != null) { jobBeo.BootParameters = bootParameters; } else { throw new EVException().AddDbgMsg("{0}:{1}:{2}", jobId, Constants.Event_Job_Initialize_Start, Constants.XmlNotWellFormed). AddResMsg(ErrorCodes.XmlStringNotWellFormed); } Tracer.Info("{0} - {1}:{2}", Constants.JobTypeName, jobId, Constants.Event_Job_Initialize_Success); } catch (EVJobException ex) { _isJobFailed = true; ex.AddDbgMsg("{0}:{1}", Constants.JobTypeName, MethodInfo.GetCurrentMethod().Name); throw; } catch (Exception ex) { _isJobFailed = true; ex.AddDbgMsg("{0}:{1}", Constants.JobTypeName, MethodInfo.GetCurrentMethod().Name); JobLogInfo.AddParameters("Problem in" + Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name); EVJobException jobException = new EVJobException(ErrorCodes.InitializeError, ex, JobLogInfo); throw (jobException); } return(jobBeo); }
private IWebOperationContext EstablishSession(string createdBy) { var userProp = new UserBusinessEntity { UserGUID = createdBy }; //Mock HttpContext & HttpSession : Calling from Worker so doesn't contain HttpContext. var mockContext = new Mock<HttpContextBase>(); var mockSession = new Mock<HttpSessionStateBase>(); userProp = UserBO.AuthenticateUsingUserGuid(createdBy); var userSession = new UserSessionBEO(); SetUserSession(createdBy, userProp, userSession); mockSession.Setup(ctx => ctx["UserDetails"]).Returns(userProp); mockSession.Setup(ctx => ctx["UserSessionInfo"]).Returns(userSession); mockSession.Setup(ctx => ctx.SessionID).Returns(Guid.NewGuid().ToString()); mockContext.Setup(ctx => ctx.Session).Returns(mockSession.Object); EVHttpContext.CurrentContext = mockContext.Object; return new MockWebOperationContext().Object; }
private IWebOperationContext EstablishSession(string createdBy) { var userProp = new UserBusinessEntity { UserGUID = createdBy }; //Mock HttpContext & HttpSession : Calling from Worker so doesn't contain HttpContext. var mockContext = new Mock <HttpContextBase>(); var mockSession = new Mock <HttpSessionStateBase>(); userProp = UserBO.AuthenticateUsingUserGuid(createdBy); var userSession = new UserSessionBEO(); SetUserSession(createdBy, userProp, userSession); mockSession.Setup(ctx => ctx["UserDetails"]).Returns(userProp); mockSession.Setup(ctx => ctx["UserSessionInfo"]).Returns(userSession); mockSession.Setup(ctx => ctx.SessionID).Returns(Guid.NewGuid().ToString()); mockContext.Setup(ctx => ctx.Session).Returns(mockSession.Object); EVHttpContext.CurrentContext = mockContext.Object; return(new MockWebOperationContext().Object); }
/// <summary> /// Initializes Job BEO /// </summary> /// <param name="jobId">Alert Job Identifier</param> /// <param name="jobRunId">Alert Job Run Identifier</param> /// <param name="bootParameters">Boot parameters</param> /// <param name="createdByGuid">Alert Job created by Guid</param> /// <returns>Alert Job Business Entity</returns> protected override SearchAlertsJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdByGuid) { try { // Set Job level properties to Alert Job business entity object. m_SearchAlertsJobBeo.JobId = jobId; m_SearchAlertsJobBeo.JobRunId = jobRunId; m_SearchAlertsJobBeo.JobTypeName = Constants.LOG_SOURCE; m_SearchAlertsJobBeo.BootParameters = bootParameters; m_SearchAlertsJobBeo.JobName = Constants.LOG_SOURCE; m_UserBusinessEntity = UserBO.GetUserUsingGuid(createdByGuid); m_SearchAlertsJobBeo.JobScheduleCreatedBy = (m_UserBusinessEntity.DomainName.Equals(Constants.NA)) ? m_UserBusinessEntity.UserId : m_UserBusinessEntity.DomainName + Constants.BackSlash + m_UserBusinessEntity.UserId; // job start time need to be reduced by an offset to calculate start time // That's because at the beginning, Scheduler increments the start time by an offset for next run. var jobStartTimeoffsetFinal = Constants.INTEGER_INITIALIZE_VALUE; var jobStartTimeoffset = ApplicationConfigurationManager.GetValue(Constants.JOB_START_TIME_OFFSET); Int32.TryParse(jobStartTimeoffset, out jobStartTimeoffsetFinal); m_SearchAlertsJobBeo.JobScheduleNextRunDate = m_Helper.GetSearchAlertJobRunStartTime(m_SearchAlertsJobBeo.JobId).AddHours(jobStartTimeoffsetFinal); } catch (EVException ex) { HandleEVException(ex, MethodBase.GetCurrentMethod().Name, null); var jobException = new EVJobException(ex.GetErrorCode(), ex, JobLogInfo); throw (jobException); } catch (Exception ex) { // Handle exception in initialize LogMessage(ex.Message, MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error, null); var jobException = new EVJobException(ErrorCodes.ProblemInJobInitialization, ex, JobLogInfo); throw (jobException); } // return Alert Job Business Entity return(m_SearchAlertsJobBeo); }
/// <summary> /// Initializes Job BEO /// </summary> /// <param name="jobId">Create ReviewSet Job Identifier</param> /// <param name="jobRunId">Create ReviewSet Run Identifier</param> /// <param name="bootParameters">Boot parameters</param> /// <param name="createdBy">Create Reviewset created by</param> /// <returns>Create Reviewset Job Business Entity</returns> protected override MergeReviewSetJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { MergeReviewSetJobBEO mergeReviewSetJobBeo = null; try { //Message that job has been initialized. EvLog.WriteEntry(jobId + Constants.InitMessage, Constants.JobStartMessage, EventLogEntryType.Information); //Populate the the UpdateReviewSetJobBEO from the boot Parameters mergeReviewSetJobBeo = GetUpdateRsJobBeo(bootParameters); if (mergeReviewSetJobBeo != null) { mergeReviewSetJobBeo.JobId = jobId; mergeReviewSetJobBeo.JobRunId = jobRunId; _userGuid = createdBy; UserBusinessEntity userBusinessEntity = UserBO.GetUserUsingGuid(createdBy); mergeReviewSetJobBeo.JobScheduleCreatedBy = userBusinessEntity.UserId; mergeReviewSetJobBeo.JobTypeName = Constants.JobName; mergeReviewSetJobBeo.JobName = Constants.JobName + DateTime.Now.ToString(CultureInfo.InvariantCulture); } EvLog.WriteEntry(jobId + Constants.InitMessage, Constants.JobEndMessage, EventLogEntryType.Information); } catch (EVException ex) { HandleEVException(); LogException(JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization); } catch (Exception ex) { //Handle exception in intialize EvLog.WriteEntry(jobId + Constants.JobError, ex.Message, EventLogEntryType.Error); LogException(JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization); } //return merge reviewset Job Business Entity return(mergeReviewSetJobBeo); }
protected override void BeginWork() { try { base.BeginWork(); _jobParams = GetImportBEO(BootParameters); if (_jobParams != null && !string.IsNullOrEmpty(_jobParams.CreatedBy)) { //Get User Information , Its needed for search _userInfo = UserBO.AuthenticateUsingUserGuid(_jobParams.CreatedBy); _userInfo.CreatedBy = _jobParams.CreatedBy; _isIncludeNativeFile = (_jobParams.IsImportNative); } //Law import batch size for documents _batchSize = GetMessageBatchSize(); } catch (Exception ex) { ReportToDirector(ex.ToUserString()); ex.Trace().Swallow(); } }
/// <summary> /// Bulk search for entire batch document /// </summary> public List <DocumentDetail> BulkSearch(List <DocumentDetail> docDetailsList, UserBusinessEntity userInfo, out List <JobWorkerLog <OverlaySearchLogInfo> > overlayLogList) { var documentDetailList = new List <DocumentDetail>(); var logList = new List <JobWorkerLog <OverlaySearchLogInfo> >(); var overlayUniqueThreadString = string.Empty; var searchQueryText = new StringBuilder(); var outputFields = new List <Field>(); var docCount = 0; #region Construct Bulk Query foreach (var doc in docDetailsList) { if (docCount == 0) { outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field { FieldName = field.FieldName })); } docCount++; var overlayMatchingField = doc.OverlayMatchingField.Where(f => !string.IsNullOrEmpty(f.FieldValue)).ToList(); if (!overlayMatchingField.Any()) { continue; } searchQueryText.Append(ConstructSearchQuery(overlayMatchingField.ToList())); if (docCount != docDetailsList.Count) { searchQueryText.Append(Constants.SearchORCondition); } } var strSearchQueryText = searchQueryText.ToString(); //To remove last OR Operator( " OR ") which added in search query. var searchOrOperatorLastIndex = searchQueryText.ToString().LastIndexOf(Constants.SearchORCondition); if (searchOrOperatorLastIndex != -1) { if ((searchQueryText.ToString().Length - searchOrOperatorLastIndex) == Constants.SearchORCondition.Length) { strSearchQueryText = searchQueryText.ToString().Substring(0, searchOrOperatorLastIndex); } } #endregion #region Bulk Search ReviewerSearchResults bulkSearchresult; using (var transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { var searchHelper = new OverlaySearchHelper(); bulkSearchresult = searchHelper.Search(strSearchQueryText, m_JobParameter.CollectionId, m_JobParameter.DatasetId, m_JobParameter.MatterId, m_Dataset.Matter.MatterDBName, m_JobParameter.CreatedBy, userInfo, outputFields); } #endregion #region Construct Document From Search // DEBUG //docDetailsList.ForEach(docDetail => Parallel.ForEach(docDetailsList, docDetail => { JobWorkerLog <OverlaySearchLogInfo> overlayLog = null; string threadConstraint; var docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments, out threadConstraint, out overlayLog); lock (documentDetailList) { if (docs != null) { documentDetailList.AddRange(docs); } if (overlayLog != null) { logList.Add(overlayLog); } if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty) { overlayUniqueThreadString = threadConstraint; } } }); overlayLogList = logList; #endregion #region Find and Purify Duplicate match document RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList); #endregion return(documentDetailList); }
/// <summary> /// Bulk search for entire batch document /// </summary> public List<DocumentDetail> BulkSearch(List<DocumentDetail> docDetailsList, UserBusinessEntity userInfo, out List<JobWorkerLog<OverlaySearchLogInfo>> overlayLogList) { var documentDetailList = new List<DocumentDetail>(); var logList = new List<JobWorkerLog<OverlaySearchLogInfo>>(); var overlayUniqueThreadString = string.Empty; var searchQueryText = new StringBuilder(); var outputFields = new List<Field>(); var docCount = 0; #region Construct Bulk Query foreach (var doc in docDetailsList) { if (docCount == 0) { outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field {FieldName = field.FieldName})); } docCount++; var overlayMatchingField = doc.OverlayMatchingField.Where(f => !string.IsNullOrEmpty(f.FieldValue)).ToList(); if (!overlayMatchingField.Any()) continue; searchQueryText.Append(ConstructSearchQuery(overlayMatchingField.ToList())); if (docCount != docDetailsList.Count) searchQueryText.Append(Constants.SearchORCondition); } var strSearchQueryText = searchQueryText.ToString(); //To remove last OR Operator( " OR ") which added in search query. var searchOrOperatorLastIndex = searchQueryText.ToString().LastIndexOf(Constants.SearchORCondition); if (searchOrOperatorLastIndex != -1) { if ((searchQueryText.ToString().Length - searchOrOperatorLastIndex) == Constants.SearchORCondition.Length) { strSearchQueryText = searchQueryText.ToString().Substring(0, searchOrOperatorLastIndex); } } #endregion #region Bulk Search ReviewerSearchResults bulkSearchresult; using (var transScope = new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { var searchHelper = new OverlaySearchHelper(); bulkSearchresult = searchHelper.Search(strSearchQueryText, m_JobParameter.CollectionId, m_JobParameter.DatasetId, m_JobParameter.MatterId, m_Dataset.Matter.MatterDBName, m_JobParameter.CreatedBy, userInfo, outputFields); } #endregion #region Construct Document From Search // DEBUG //docDetailsList.ForEach(docDetail => Parallel.ForEach(docDetailsList, docDetail => { JobWorkerLog<OverlaySearchLogInfo> overlayLog = null; string threadConstraint; var docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments, out threadConstraint, out overlayLog); lock (documentDetailList) { if (docs != null) documentDetailList.AddRange(docs); if (overlayLog != null) logList.Add(overlayLog); if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty) overlayUniqueThreadString = threadConstraint; } }); overlayLogList = logList; #endregion #region Find and Purify Duplicate match document RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList); #endregion return documentDetailList; }
/// <summary> /// This method is used to construct the notification message and send the notification for the alert /// </summary> /// <param name="task"></param> /// <param name="originalQuery"></param> /// <param name="searchBizEntityObj"></param> private void ConstructNotificationMessage(SearchAlertsTaskBEO task, string originalQuery, DocumentQueryEntity searchBizEntityObj) { /* send notification only if * - All result count between prev alert and current alert is changed * - All result count is same but new results found for current alert * - if alert is running for the first time * - if the prev query and current query is not same */ if ((m_LastResultCount != m_AllResultCount) || ((m_LastResultCount == m_AllResultCount) && m_NewResultCount > 0) || (m_AlertLastRunTimestamp.Equals(DateTime.MinValue) || m_AlertLastRunTimestamp.Equals(Constants.MSSQL2005_MINDATE)) || (!String.IsNullOrEmpty(m_PrevSearchQuery) && (!m_PrevSearchQuery.Equals(originalQuery)))) { var dataSetName = (searchBizEntityObj != null && searchBizEntityObj.QueryObject.DatasetId > 0) ? FolderBO.GetFolderDetails(searchBizEntityObj.QueryObject.DatasetId.ToString()).FolderName : String.Empty; var reviewSetName = (searchBizEntityObj != null && searchBizEntityObj.QueryObject.MatterId > 0 && !String.IsNullOrEmpty(searchBizEntityObj.QueryObject.ReviewsetId)) ? ReviewSetBO.GetReviewSetDetails(searchBizEntityObj.QueryObject.MatterId.ToString(), searchBizEntityObj.QueryObject.ReviewsetId).ReviewSetName : String.Empty; // Send notification var alertMessage = Constants.ALERT_NOTIFICATION_MESSAGE; // modify the notification message if this needs to be sent as part of manual alert if (m_ManualAlertNextRunDate != DateTime.MinValue) { alertMessage += Constants.MANUAL_ALERT_MESSAGE; } if (string.IsNullOrEmpty(reviewSetName)) { alertMessage = m_AllResultCount + alertMessage + Constants.Hyphen + HttpUtility.HtmlDecode(task.SearchAlert.Name) + Constants.FOR + Constants.DATASET + HttpUtility.HtmlDecode(dataSetName); } else { alertMessage = m_AllResultCount + alertMessage + Constants.Hyphen + HttpUtility.HtmlDecode(task.SearchAlert.Name) + Constants.FOR + Constants.DATASET + HttpUtility.HtmlDecode(dataSetName) + Constants.INREVIEWSET + HttpUtility.HtmlDecode(reviewSetName); } if ((((m_LastResultCount == m_AllResultCount) && m_NewResultCount > 0) || ((m_LastResultCount > m_AllResultCount) && m_NewResultCount == 0)) && (m_AlertLastRunTimestamp != DateTime.MinValue)) { alertMessage += Constants.SEARCH_ALERT_RESULTS_CHANGED; } // this is required to get the details of the person who actually created the alert if (!string.IsNullOrEmpty(task.SearchAlert.CreatedBy)) { m_UserBusinessEntity = UserBO.GetUserUsingGuid(task.SearchAlert.CreatedBy); } var messageBuilder = new StringBuilder(); messageBuilder.Append(Constants.Table); messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(HttpUtility.HtmlEncode(alertMessage)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(Constants.MessageSearchQuery); messageBuilder.Append(HttpUtility.HtmlDecode(originalQuery)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(Constants.MessageDatasetName); messageBuilder.Append(HttpUtility.HtmlDecode(dataSetName)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); if (!(string.IsNullOrEmpty(reviewSetName))) { messageBuilder.Append(Constants.Row); messageBuilder.Append(Constants.Column); messageBuilder.Append(Constants.MessageReviewsetName); messageBuilder.Append(HttpUtility.HtmlDecode(reviewSetName)); messageBuilder.Append(Constants.CloseColumn); messageBuilder.Append(Constants.CloseRow); } messageBuilder.Append(Constants.CloseTable); SendNotification(task.SearchAlert, alertMessage, messageBuilder.ToString()); } }
public async Task <IActionResult> Register(RegisterViewModel model, byte[] AvatarImage = null, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var roleAdmin = new IdentityRole("Admin"); var roleuser = new IdentityRole("User"); // User claim for write task data user.Claims.Add(new IdentityUserClaim <string> { ClaimType = "Task", ClaimValue = "Write" }); var roleExists = _rolesManager.RoleExistsAsync(roleAdmin.Name).Result; if (!roleExists) { var resulRoles = await _rolesManager.CreateAsync(roleAdmin); if (resulRoles.Succeeded) { roleExists = _rolesManager.RoleExistsAsync(roleuser.Name).Result; resulRoles = await _rolesManager.CreateAsync(roleuser); } } var roleid = await _rolesManager.FindByNameAsync(roleAdmin.Name); user.Roles.Add(new IdentityUserRole <string> { RoleId = roleid.Id, UserId = user.Id }); var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { var businessEntity = new BusinessEntity(model.Name, model.Email, true); var userSetting = new UserSetting("", model.Name, "", "", businessEntity, user) { AvatarImage = AvatarImage, UserSettingId = user.Id }; var userBusinessEntity = new UserBusinessEntity(businessEntity, userSetting); _userBusinessEntityService.Add(userBusinessEntity); //_userSettingService.Add(userSetting); if (_pipelineService.Count() <= 0) { var pipeline = new Pipeline("Pipeline") { BusinessEntity = businessEntity, UserSettingId = user.Id }; List <Stage> stage = new List <Stage>(); List <TaskGroup> taskGroup = new List <TaskGroup>(); stage.Add(new Stage() { BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 1, Name = "Cliente potencial" }); stage.Add(new Stage() { BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 2, Name = "Contatado" }); stage.Add(new Stage() { BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 3, Name = "Demo Agendada" }); stage.Add(new Stage() { BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 4, Name = "Proposta Feita" }); stage.Add(new Stage() { BusinessEntity = businessEntity, Pipeline = pipeline, OrderStage = 5, Name = "Negociações começadas" }); taskGroup.Add(new TaskGroup() { BusinessEntity = businessEntity, Name = "Ligação" }); taskGroup.Add(new TaskGroup() { BusinessEntity = businessEntity, Name = "Reunião" }); taskGroup.Add(new TaskGroup() { BusinessEntity = businessEntity, Name = "Email" }); taskGroup.Add(new TaskGroup() { BusinessEntity = businessEntity, Name = "Almoço" }); taskGroup.Add(new TaskGroup() { BusinessEntity = businessEntity, Name = "Tarefa" }); taskGroup.Add(new TaskGroup() { BusinessEntity = businessEntity, Name = "Apresentação" }); _pipelineService.Add(pipeline); stage.ForEach(a => _stageService.Add(a)); taskGroup.ForEach(a => _taskGroupService.Add(a)); } // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=532713 // Send an email with this link var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Action(nameof(ConfirmEmail), "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme); await _emailSender.SendEmailAsync(model.Email, "Confirm your account", $"<p>Por favor, confirme seu email clicando neste link : <a href='{callbackUrl}'>link</a>" + "</p>"); //await _signInManager.SignInAsync(user, isPersistent: false); _logger.LogInformation(3, "User created a new account with password."); return(RedirectToLocal(returnUrl)); //return RedirectToAction("Setup","Home", new { user = user }); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
/// <summary> /// Initializes Job BEO /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="bootParameters">Boot parameters</param> /// <param name="createdBy">Job created by</param> /// <returns>Job Business Entity</returns> protected override CompareSavedSearchResultsJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { try { LogMessage(Constants.InitializationStartMessage, GetType(), Constants.InitializeMethodFullName, EventLogEntryType.Information, jobId, jobRunId); //using job framework Logging LogMessage(Constants.InitializationStartMessage, false, LogCategory.Job, null); try { // Set level of logging _fileType = (ApplicationConfigurationManager.GetValue(Constants.RequiredFileType)); _encodingType = (ApplicationConfigurationManager.GetValue(Constants.RequiredEncoding)); _xslFilePathForComparisonReport = (CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.XslFilePathForComparisonReport)); LogMessage(Constants.InitializationDoneForConfigurableItemMessage, false, LogCategory.Job, null); LogMessage(Constants.InitializationDoneForConfigurableItemMessage, GetType(), Constants.InitializeMethodFullName, EventLogEntryType.Information, jobId, jobRunId); } catch { _isJobFailed = true; LogMessage(Constants.InitializationDoneForConfigurableItemErrorMessage, true, LogCategory.Job, null); LogMessage(Constants.InitializationDoneForConfigurableItemErrorMessage, GetType(), Constants.InitializeMethodFullName, EventLogEntryType.Information, jobId, jobRunId); } //Constructing Search Results property Beo from passed boot paramter _searchResultsProperty = (SearchResultsPropertiesDataContract) XmlUtility.DeserializeObject(bootParameters, typeof(SearchResultsPropertiesDataContract)); //Initialize the JobBEO object _jobBeo.JobName = string.Format("Compare Job - {0} at {1}", _searchResultsProperty.SearchResultsName, DateTime.UtcNow.ConvertToUserTime()); _jobBeo.JobDescription = _searchResultsProperty.SearchResultsDescription; _jobBeo.FileType = _fileType; _jobBeo.JobTypeName = Constants.JobTypeName; _jobBeo.JobId = jobId; _jobBeo.JobRunId = jobRunId; // Obtain User BEO of job owner -> will be used for audit log purpose _userEntityOfJobOwner = UserBO.GetUserUsingGuid(createdBy); _jobBeo.JobScheduleCreatedBy = (_userEntityOfJobOwner.DomainName.Equals("N/A")) ? _userEntityOfJobOwner.UserId : _userEntityOfJobOwner.DomainName + "\\" + _userEntityOfJobOwner.UserId; } catch (EVException ex) { _isJobFailed = true; WriteToEventViewer(ex, GetType(), MethodBase.GetCurrentMethod().Name, jobId, jobRunId); HandleJobException(null, ErrorCodes.ProblemInJobInitialization); } catch (Exception ex) { _isJobFailed = true; // Handle exception in initialize LogMessage(ex, GetType(), MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error, jobId, jobRunId); HandleJobException(ex, ErrorCodes.ProblemInJobInitialization); } return(_jobBeo); }
/// <summary> /// Sets the usersession object using the UserBusinessEntity details /// </summary> /// <param name="userProp"></param> /// <param name="userSession"></param> private static void SetUserSession(UserBusinessEntity userProp, UserSessionBEO userSession) { userSession.UserId = userProp.UserId; userSession.UserGUID = userProp.UserGUID; userSession.DomainName = userProp.DomainName; userSession.IsSuperAdmin = userProp.IsSuperAdmin; userSession.LastPasswordChangedDate = userProp.LastPasswordChangedDate; userSession.PasswordExpiryDays = userProp.PasswordExpiryDays; userSession.Timezone = userProp.Timezone; userSession.FirstName = userProp.FirstName; userSession.LastName = userProp.LastName; }
/// <summary> /// Print the document /// </summary> /// <param name="jobId"></param> /// <param name="request"></param> /// <param name="document"></param> /// <param name="separatorSheet"></param> /// <param name="errorCode"></param> /// <returns></returns> private bool PrintDocumentSet(string jobId, BulkPrintServiceRequestBEO request, DocumentResult document, string separatorSheet, out string errorCode) { var toReturn = false; var title = string.Empty; var fieldValue = string.Empty; var binaryType = NativeSetBinaryType; var sb = new StringBuilder(string.Empty); //Get the binary types for the images switch (request.BulkPrintOptions.ImageType.ImageType) { case DocumentImageTypeBEO.Native: binaryType = NativeSetBinaryType; break; case DocumentImageTypeBEO.ImageSet: binaryType = ImageSetBinaryType; break; case DocumentImageTypeBEO.ProductionSet: binaryType = ProductionSetBinaryType; break; } //Get the document binary var documentData = DocumentBO.GetDocumentBinaryData(long.Parse(request.DataSet.MatterId), request.BulkPrintOptions.ImageType. ImageIdentifier.CollectionId, document.DocumentID, binaryType, string.Empty); #region Assertion documentData.ShouldNotBe(null); documentData.DocumentBinary.ShouldNotBe(null); #endregion var isFileExists = documentData.DocumentBinary.FileList.Count > 0; errorCode = string.Empty; foreach (var fileInfo in documentData.DocumentBinary.FileList) { if (!File.Exists(fileInfo.Path)) { isFileExists = false; break; } } m_UserDetails = UserBO.GetUserUsingGuid(request.RequestedBy.UserId); userContext = CreateUserContext(request.RequestedBy.UserId); EVHttpContext.CurrentContext = userContext; //Construct Query string if (!isFileExists) { errorCode = "Bulk print Invalid file"; toReturn = true; } else { fieldValue = document.DocumentControlNumber; if (document.Fields != null && document.Fields.Any()) { fieldValue = document.DocumentControlNumber; title = Constants.TitleNotAvailable; foreach (var field in document.Fields) { if (field == null) { continue; } if (field.DataTypeId == Constants.TitleFieldType) { title = !string.IsNullOrEmpty(field.Value) ? fieldValue.Trim() : title; } if (String.IsNullOrEmpty(field.Name)) { continue; } if (field.Name.Equals(_mBootParameters.FieldName)) { fieldValue = !string.IsNullOrEmpty(field.Value) ? field.Value.Trim() : fieldValue; } } } var specialChars = new List <string> { "<", ">", ":", "\"", "\\", "|", "?", "*", "." }; if (specialChars.Exists(x => fieldValue.Contains(x))) { // Log documents with special characters or empty values... toReturn = false; errorCode = "Special characters in the field value and hence cannot be printed"; } else { ConstructQueryString(jobId, document, title, separatorSheet, sb, documentData, fieldValue); try { toReturn = CreatePostWebRequestForCreatingPdf(jobId, sb.ToString()); } catch (WebException webException) { webException.Trace().Swallow(); } catch (Exception ex) { ex.Trace().Swallow(); errorCode = "Error in Conversion and hence cannot be printed"; } } } return(toReturn); }
/// <summary> /// Sets the user session object using the UserBusinessEntity details. /// </summary> /// <param name="createdByGuid">Created by User Guid.</param> /// <param name="userProp">User Properties.</param> /// <param name="userSession">User Session.</param> private static void SetUserSession(string createdByGuid, UserBusinessEntity userProp, UserSessionBEO userSession) { userSession.UserId = userProp.UserId; userSession.UserGUID = createdByGuid; userSession.DomainName = userProp.DomainName; userSession.IsSuperAdmin = userProp.IsSuperAdmin; userSession.LastPasswordChangedDate = userProp.LastPasswordChangedDate; userSession.PasswordExpiryDays = userProp.PasswordExpiryDays; userSession.Timezone = userProp.Timezone; if (userProp.Organizations.Any()) userSession.Organizations.AddRange(userProp.Organizations); }
/// <summary> /// Print the document /// </summary> /// <param name="jobId"></param> /// <param name="request"></param> /// <param name="document"></param> /// <param name="separatorSheet"></param> /// <param name="errorCode"></param> /// <returns></returns> private bool PrintDocumentSet(string jobId, BulkPrintServiceRequestBEO request, DocumentResult document, string separatorSheet, out string errorCode) { var toReturn = false; var title = string.Empty; var fieldValue = string.Empty; var binaryType = NativeSetBinaryType; var sb = new StringBuilder(string.Empty); //Get the binary types for the images switch (request.BulkPrintOptions.ImageType.ImageType) { case DocumentImageTypeBEO.Native: binaryType = NativeSetBinaryType; break; case DocumentImageTypeBEO.ImageSet: binaryType = ImageSetBinaryType; break; case DocumentImageTypeBEO.ProductionSet: binaryType = ProductionSetBinaryType; break; } //Get the document binary var documentData = DocumentBO.GetDocumentBinaryData(long.Parse(request.DataSet.MatterId), request.BulkPrintOptions.ImageType. ImageIdentifier.CollectionId, document.DocumentID, binaryType, string.Empty); #region Assertion documentData.ShouldNotBe(null); documentData.DocumentBinary.ShouldNotBe(null); #endregion var isFileExists = documentData.DocumentBinary.FileList.Count > 0; errorCode = string.Empty; foreach (var fileInfo in documentData.DocumentBinary.FileList) { if (!File.Exists(fileInfo.Path)) { isFileExists = false; break; } } m_UserDetails = UserBO.GetUserUsingGuid(request.RequestedBy.UserId); userContext = CreateUserContext(request.RequestedBy.UserId); EVHttpContext.CurrentContext = userContext; //Construct Query string if (!isFileExists) { errorCode = "Bulk print Invalid file"; toReturn = true; } else { fieldValue = document.DocumentControlNumber; if (document.Fields != null && document.Fields.Any()) { fieldValue = document.DocumentControlNumber; title = Constants.TitleNotAvailable; foreach (var field in document.Fields) { if (field == null) continue; if (field.DataTypeId == Constants.TitleFieldType) title = !string.IsNullOrEmpty(field.Value) ? fieldValue.Trim() : title; if (String.IsNullOrEmpty(field.Name)) continue; if (field.Name.Equals(_mBootParameters.FieldName)) fieldValue = !string.IsNullOrEmpty(field.Value) ? field.Value.Trim() : fieldValue; } } var specialChars = new List<string> {"<", ">", ":", "\"", "\\", "|", "?", "*", "."}; if (specialChars.Exists(x => fieldValue.Contains(x))) { // Log documents with special characters or empty values... toReturn = false; errorCode = "Special characters in the field value and hence cannot be printed"; } else { ConstructQueryString(jobId, document, title, separatorSheet, sb, documentData, fieldValue); try { toReturn = CreatePostWebRequestForCreatingPdf(jobId, sb.ToString()); } catch (WebException webException) { webException.Trace().Swallow(); } catch (Exception ex) { ex.Trace().Swallow(); errorCode = "Error in Conversion and hence cannot be printed"; } } } return toReturn; }
/// <summary> /// Bulk search for entire batch document /// </summary> public List <DocumentDetail> BulkSearch(List <DocumentDetail> docDetailsList, UserBusinessEntity userInfo, out List <JobWorkerLog <OverlaySearchLogInfo> > overlayLogList, out Dictionary <string, string> overlayDocumentIdPair) { var documentDetailList = new List <DocumentDetail>(); var logList = new List <JobWorkerLog <OverlaySearchLogInfo> >(); var overlayUniqueThreadString = string.Empty; overlayDocumentIdPair = new Dictionary <string, string>(); var searchQueryText = new StringBuilder(); var docCount = 0; var outputFields = new List <Field>(); #region Construct Bulk Query foreach (var doc in docDetailsList) { if (docCount == 0) { outputFields.AddRange(doc.OverlayMatchingField.Select(field => new Field { FieldName = field.FieldName })); } docCount++; searchQueryText.Append(ConstructSearchQuery(doc.OverlayMatchingField)); if (docCount != docDetailsList.Count) { searchQueryText.Append(" OR "); } } #endregion #region Bulk Search ReviewerSearchResults bulkSearchresult; using (new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress)) { var searchHelper = new OverlaySearchHelper(); bulkSearchresult = searchHelper.Search(searchQueryText.ToString(), _jobParams.CollectionId, _jobParams.DatasetId, _jobParams.MatterId, _datasetBEO.Matter.MatterDBName, _jobParams.CreatedBy, userInfo, outputFields); } #endregion #region Construct Document From Search foreach (var docDetail in docDetailsList) { JobWorkerLog <OverlaySearchLogInfo> overlayLog; string threadConstraint; var docs = ConstructDocumentFromSearch(docDetail, bulkSearchresult.ResultDocuments, out threadConstraint, out overlayLog); if (docs != null) { documentDetailList.AddRange(docs); } if (overlayLog != null) { logList.Add(overlayLog); } if (threadConstraint != string.Empty && overlayUniqueThreadString == string.Empty) { overlayUniqueThreadString = threadConstraint; } } overlayLogList = logList; #endregion overlayDocumentIdPair = AddKeyValues(overlayDocumentIdPair, _overlayNewAndOldDocumentIdPairs); #region Find and Purify Duplicate match document RemoveDuplicateUpdateDocument(documentDetailList, overlayLogList); #endregion return(documentDetailList); }
public async Task <IActionResult> Register(RegisterViewModel model, bool continueAdd, byte[] AvatarImage = null) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var roleAdmin = new IdentityRole("Admin"); var roleuser = new IdentityRole("User"); var roleExists = _rolesManager.RoleExistsAsync(roleAdmin.Name).Result; if (!roleExists) { var resulRoles = await _rolesManager.CreateAsync(roleAdmin); if (resulRoles.Succeeded) { roleExists = _rolesManager.RoleExistsAsync(roleuser.Name).Result; resulRoles = await _rolesManager.CreateAsync(roleuser); } } var roleid = await _rolesManager.FindByNameAsync(roleAdmin.Name); // User claim for write task data user.Claims.Add(new IdentityUserClaim <string> { ClaimType = "Task", ClaimValue = "Write" }); user.Roles.Add(new IdentityUserRole <string> { RoleId = roleid.Id, UserId = user.Id }); var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { var businessEntityId = _currentUser.GetCurrentBusinessEntityId(); var userSetting = new UserSetting("", model.Name, "", "", null, user) { AvatarImage = AvatarImage, BusinessEntityId = businessEntityId, UserSettingId = user.Id }; _userSettingService.Add(userSetting); var userBusinessEntity = new UserBusinessEntity() { BusinessEntityId = businessEntityId, UserSettingId = user.Id }; _userBusinessEntityService.Add(userBusinessEntity); return(RedirectToAction(continueAdd ? "Add" : "List")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
/// <summary> /// Mock Session : Windows job doesn't /// </summary> private void MockSession() { #region Mock new MockWebOperationContext(); UserBusinessEntity userProp; //Mock HttpContext & HttpSession : Calling from Worker so doesn't contain HttpContext. var mockContext = new Mock<HttpContextBase>(); var mockSession = new Mock<HttpSessionStateBase>(); if (_mUserProp != null) userProp = _mUserProp; else { _mUserProp = UserBO.AuthenticateUsingUserGuid(_mCreatedBy); userProp = _mUserProp; } var userSession = new UserSessionBEO(); SetUserSession(userProp, userSession); mockSession.Setup(ctx => ctx["UserDetails"]).Returns(userProp); mockSession.Setup(ctx => ctx["UserSessionInfo"]).Returns(userSession); mockSession.Setup(ctx => ctx.SessionID).Returns(Guid.NewGuid().ToString()); mockContext.Setup(ctx => ctx.Session).Returns(mockSession.Object); EVHttpContext.CurrentContext = mockContext.Object; #endregion }