示例#1
0
 public SessionOrchestrationPolicy(
     WorkFlowType workFlowType,
     SyncStateMachine syncStateMachine)
 {
     m_workFlowType     = workFlowType;
     m_syncStateMachine = syncStateMachine;
 }
示例#2
0
        /// <summary>
        /// 更新数据
        /// </summary>
        public async Task UpdateWorkFlowTypeAsync(WorkFlowType entity)
        {
            _repository.Update(entity);
            await _unitOfWork.CommitAsync();

            _memoryCache.Remove(entity.Id);
        }
示例#3
0
        internal void Initialize(string testProjectName)
        {
            WorkFlowType = new WorkFlowType();
            WorkFlowType.DirectionOfFlow = DirectionOfFlow.Unidirectional;
            WorkFlowType.Frequency       = Frequency.ContinuousManual;
            WorkFlowType.SyncContext     = SyncContext.Unidirectional;
            IsLeftToRightWorkflow        = true;

            m_testProjectName = testProjectName;
        }
        private bool IsSessionUniDirectional(RuntimeEntityModel context, RTSessionGroup rtSessionGroup)
        {
            var sessionGroupConfigQuery =
                (from sg in context.RTSessionGroupConfigSet
                 where sg.SessionGroup.GroupUniqueId.Equals(rtSessionGroup.GroupUniqueId)
                 orderby sg.Id descending
                 select sg).First();

            WorkFlowType workFlowType = new WorkFlowType(sessionGroupConfigQuery.WorkFlowType);

            return(workFlowType.DirectionOfFlow == DirectionOfFlow.Unidirectional);
        }
示例#5
0
        public async Task <IActionResult> UpdateWorkFlowType([FromBody] WorkFlowType entity)
        {
            var result = _service.HaveRepeatName(entity.Id, entity.Name);

            if (result)
            {
                ModelState.AddModelError("Name", ErrorMessages.WorkFlow_Type_E001);
                return(BadRequest(ModelState));
            }

            await _service.UpdateWorkFlowTypeAsync(entity);

            return(Ok());
        }
示例#6
0
        /// <summary>
        /// 获取工作流程
        /// </summary>
        /// <param name="workStatus">流程编号</param>
        /// <returns></returns>
        public static WorkFlowType GetWorkFlowId(int workStatus, int companyTypeId)
        {
            WorkFlowType           result   = null;
            SpecialAuditWFTemplate template = null;

            try
            {
                template = XmlDeSerialize <SpecialAuditWFTemplate>(SpecialAuditWF_ConfigFile);
                result   = (from d in template.WorkFlowTypes where d.WorkStatus == workStatus && d.CompanyId == companyTypeId select d).FirstOrDefault();
            }
            catch {}

            return(result);
        }
示例#7
0
        /// <summary>
        /// Convert WorkFlowType to string
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            WorkFlowType workFlowType = value as WorkFlowType;
            string       name         = m_workFlowScenarios.FirstOrDefault(x => x.Value.Frequency == workFlowType.Frequency && x.Value.DirectionOfFlow == workFlowType.DirectionOfFlow && x.Value.SyncContext == workFlowType.SyncContext).Key;

            if (name != null)
            {
                return(name);
            }
            else
            {
                m_workFlowScenarios[CustomString] = workFlowType;
                return(CustomString);
            }
        }
示例#8
0
        static WorkFlowTypeConverter()
        {
            m_workFlowScenarios = new Dictionary <string, WorkFlowType>();

            m_workFlowScenarios["One-way migration"]                 = new WorkFlowType();
            m_workFlowScenarios["One-way migration"].Frequency       = Frequency.ContinuousManual;
            m_workFlowScenarios["One-way migration"].DirectionOfFlow = DirectionOfFlow.Unidirectional;
            m_workFlowScenarios["One-way migration"].SyncContext     = SyncContext.Disabled;

            m_workFlowScenarios["Two-way sync"]                 = new WorkFlowType();
            m_workFlowScenarios["Two-way sync"].Frequency       = Frequency.ContinuousAutomatic;
            m_workFlowScenarios["Two-way sync"].DirectionOfFlow = DirectionOfFlow.Bidirectional;
            m_workFlowScenarios["Two-way sync"].SyncContext     = SyncContext.Disabled;

            m_workFlowScenarios[CustomString] = new WorkFlowType();
        }
示例#9
0
        internal SessionWorker(
            Guid sessionId,
            ManualResetEvent sessionEvent,
            AnalysisEngine analysisEngine,
            MigrationEngine migrationEngine,
            LinkEngine linkEngine,
            Guid leftMigrationSourceId,
            Guid rightMigrationSourceId,
            WorkFlowType workFlowType,
            int secondsSyncWaitInterval,
            string threadName)
        {
            SessionId              = sessionId;
            Event                  = sessionEvent;
            AnalysisEngine         = analysisEngine;
            MigrationEngine        = migrationEngine;
            LinkEngine             = linkEngine;
            LeftMigrationSourceid  = leftMigrationSourceId;
            RightMigrationSourceid = rightMigrationSourceId;
            WorkFlowType           = workFlowType;
            m_threadName           = threadName;

            SqlSyncStateManager manager = SqlSyncStateManager.GetInstance();

            m_syncStateManager = manager;
            m_syncCommandQueue = manager;

            m_syncStateMachine = new SyncStateMachine(PipelineState.Default, new SyncStateTransitionAlgorithm(),
                                                      OwnerType.Session, sessionId, m_syncStateManager);
            m_orchPolicy = new SessionOrchestrationPolicy(WorkFlowType, m_syncStateMachine);

            try
            {
                checked
                {
                    MilliSecondsSyncWaitInterval = secondsSyncWaitInterval * 1000;
                }
            }
            catch (OverflowException)
            {
                MilliSecondsSyncWaitInterval = int.MaxValue;
                TraceManager.TraceInformation(
                    "The speicified interval of {0} minutes is too long for the system to handle. The interval is now changed to {1} minutes.",
                    secondsSyncWaitInterval / 60,
                    (int)(MilliSecondsSyncWaitInterval / 1000 / 60));
            }
        }
示例#10
0
        public SessionViewModel(Guid sessionUniqueId, RTSessionConfig recentSessionConfig)
        {
            OneWaySessions = new Dictionary <Guid, OneWaySessionViewModel>();

            SessionUniqueId       = sessionUniqueId;
            m_recentSessionConfig = recentSessionConfig;

            recentSessionConfig.SessionGroupConfigReference.Load();
            recentSessionConfig.LeftSourceConfigReference.Load();
            recentSessionConfig.LeftSourceConfig.MigrationSourceReference.Load();
            recentSessionConfig.RightSourceConfigReference.Load();
            recentSessionConfig.RightSourceConfig.MigrationSourceReference.Load();

            OneWaySessions[recentSessionConfig.LeftSourceConfig.MigrationSource.UniqueId] = new OneWaySessionViewModel(recentSessionConfig, recentSessionConfig.LeftSourceConfig.MigrationSource, recentSessionConfig.RightSourceConfig.MigrationSource);
            WorkFlowType workFlowType = new WorkFlowType(recentSessionConfig.SessionGroupConfig.WorkFlowType);

            if (workFlowType.DirectionOfFlow == DirectionOfFlow.Bidirectional)
            {
                OneWaySessions[recentSessionConfig.RightSourceConfig.MigrationSource.UniqueId] = new OneWaySessionViewModel(recentSessionConfig, recentSessionConfig.RightSourceConfig.MigrationSource, recentSessionConfig.LeftSourceConfig.MigrationSource);
            }
        }
示例#11
0
        /// <summary>
        /// Get Document. For more information visit <see cref="http://docapi.d4sign.com.br/#send-signer">D4Sign API REST</see>
        /// </summary>
        /// <returns></returns>
        public async Task <MessageResult> SendDocumentToSign(string documentKey, string message, SkipEmailType skipEmail, WorkFlowType workFlow)
        {
            if (string.IsNullOrEmpty(documentKey))
            {
                throw new ArgumentNullException("documentKey", "Document key is null or empty.");
            }

            var data = new DocumentToSignResquest
            {
                Message   = message,
                SkipEmail = skipEmail.GetHashCode(),
                Workflow  = workFlow.GetHashCode()
            };

            return(await SendAsync <MessageResult>(HttpMethod.Post, string.Format("documents/{0}/sendtosigner", documentKey, data)));
        }
示例#12
0
        private void CreateStatus(string description, string color, bool IsCompleted, bool IsDefault, WorkFlowType WorkFlowType)
        {
            Status status = ObjectSpace.CreateObject <Status>();

            status.Description  = description;
            status.Color        = System.Drawing.ColorTranslator.FromHtml(color);
            status.IsCompleted  = IsCompleted;
            status.IsDefault    = IsDefault;
            status.WorkFlowType = WorkFlowType;
            status.Save();
            status.Session.CommitTransaction();
        }
示例#13
0
 private static bool IsBidirectionalWorkFlowType(WorkFlowType workFlowType)
 {
     return(workFlowType.DirectionOfFlow == DirectionOfFlow.Bidirectional);
 }
示例#14
0
 private static bool IsRightToLeftContextSyncNeeded(WorkFlowType workFlowType)
 {
     return(workFlowType.SyncContext == SyncContext.Bidirectional);
 }
示例#15
0
        private void ProcessPipeline(WorkFlowType workFlowType)
        {
            bool bidirection = IsBidirectionalWorkFlowType(workFlowType);
            bool leftToRightContextSyncNeeded = IsLeftToRightContextSyncNeeded(workFlowType);
            bool rightToLeftContextSyncNeeded = IsRightToLeftContextSyncNeeded(workFlowType);

            do
            {
                // always notifying the listeners the pipeline is (re)starting
                SessionControlResume(this, new SessionControlEventArgs());

                try
                {
                    #region ----- LEFT TO RIGHT -----
                    OneDirectionProcessPipeline(true, LeftMigrationSourceid, RightMigrationSourceid, leftToRightContextSyncNeeded, bidirection);
                    #endregion

                    TraceManager.TraceInformation("");

                    #region ----- RIGHT TO LEFT -----
                    if (bidirection)
                    {
                        OneDirectionProcessPipeline(false, RightMigrationSourceid, LeftMigrationSourceid, rightToLeftContextSyncNeeded, bidirection);
                    }
                    else
                    {
                        CleanupDeltaTable(RightMigrationSourceid);
                    }
                    #endregion

                    #region ----- The current round-trip is stopping -----
                    if (m_syncStateMachine.TryTransit(PipelineSyncCommand.STOP_CURRENT_TRIP))
                    {
                        m_syncStateMachine.CommandTransitFinished(PipelineSyncCommand.STOP_CURRENT_TRIP);
                    }
                    #endregion
                }
                catch (SessionOrchestrationPolicy.StopSessionException)
                {
                    TraceManager.TraceInformation("{0}: Session aborted!", m_thread.Name);
                    return;
                }
                catch (SessionOrchestrationPolicy.StopSingleTripException)
                {
                    // When Stop is requested, we continue and let the policy to decide
                    // whether it should start another round trip or not
                    TraceManager.TraceInformation("{0}: Session stopped!", m_thread.Name);
                    continue;
                }
                catch (Exception)
                {
                    throw;
                }

                switch (workFlowType.Frequency)
                {
                case Frequency.ContinuousAutomatic:
                    TraceManager.TraceInformation("{0}: Sync is done!", m_thread.Name);
                    TraceManager.TraceInformation("{0}: Waiting {1} seconds before next synchronization",
                                                  m_thread.Name,
                                                  MilliSecondsSyncWaitInterval / 1000);
                    break;

                case Frequency.ContinuousManual:
                case Frequency.OneTime:
                    TraceManager.TraceInformation("{0}: Migration is done!", m_thread.Name);
                    MigrationSessionCompleted();
                    break;

                default:
                    throw new ArgumentException("m_orchPolicy.WorkFlowType.Frequency");
                }
            } while (m_orchPolicy.TryStartNextRoundTrip(MilliSecondsSyncWaitInterval));
        }
示例#16
0
        internal void Initialize(string testProjectName)
        {
            if (MigrationTestType == MigrationTestType.OneWay)
            {
                WorkFlowType = new WorkFlowType()
                {
                    DirectionOfFlow = DirectionOfFlow.Unidirectional,
                    Frequency       = Frequency.ContinuousManual,
                    SyncContext     = SyncContext.Disabled,
                };
            }
            else
            {
                WorkFlowType = new WorkFlowType()
                {
                    DirectionOfFlow = DirectionOfFlow.Bidirectional,
                    Frequency       = Frequency.ContinuousManual,
                    SyncContext     = SyncContext.Disabled,
                };
            }

            foreach (TestProject p in TestProjectList.TestProject)
            {
                if (testProjectName.Equals(p.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    TestProject = p;
                    Trace.TraceInformation("Using Configuration File '{0}' for test project {1}", TestProject.ConfigurationFile, testProjectName);
                    break;
                }
            }

            foreach (EndPoint e in EndPointList)
            {
                if (String.Equals(e.ID, TestProject.LeftEndPointID, StringComparison.OrdinalIgnoreCase))
                {
                    LeftEndPoint = e;
                }
                if (String.Equals(e.ID, TestProject.RightEndPointID, StringComparison.OrdinalIgnoreCase))
                {
                    RightEndPoint = e;
                }
            }

            if (TestProject == null)
            {
                throw new Exception(String.Format("Test Project {0} is not defined in MigrationTestEnvironment", testProjectName));
            }

            if (LeftEndPoint == null)
            {
                throw new Exception(String.Format("Test Project {0} has an undefined Left EndPoint in MigrationTestEnvironment", TestProject.Name));
            }

            if (RightEndPoint == null)
            {
                throw new Exception(String.Format("Test Project {0} has an undefined Right EndPoint in MigrationTestEnvironment", TestProject.Name));
            }

            if (LeftEndPoint == RightEndPoint)
            {
                throw new Exception(String.Format("Test Project {0} has the same endpoint '{1}' defined for both ends in MigrationTestEnvironment", TestProject.Name, LeftEndPoint.ID));
            }

            LeftEndPoint.Initialize();
            RightEndPoint.Initialize();

            // Friendly names must be unique since we use them as ServerIdentifiers so append text to make it clear which side is which
            LeftEndPoint.FriendlyName   += " (Left,";
            RightEndPoint.FriendlyName  += " (Right,";
            TargetEndPoint.FriendlyName += "Target)";
            SourceEndPoint.FriendlyName += "Source)";

            Trace.TraceInformation("------ MigrationTestEnvironment details ------");
            Trace.TraceInformation("MigrationType: {0}", MigrationTestType);
            Trace.TraceInformation("ConfigurationFile: {0}", ConfigurationFile);
            Trace.TraceInformation(LeftEndPoint.ToString());
            Trace.TraceInformation(RightEndPoint.ToString());
            Trace.TraceInformation("----------------------------------------------");
        }
示例#17
0
        /// <summary>
        /// 添加数据
        /// </summary>
        public async Task AddWorkFlowTypeAsync(WorkFlowType entity)
        {
            await _repository.InsertAsync(entity);

            await _unitOfWork.CommitAsync();
        }