コード例 #1
0
        private static void Main(string[] args)
        {
            var _currentUser = "";

            _roles = new List <string> {
                "Admin"
            };
            _investorNotificate = new InvestorNotification();
            _adminNotificate    = new AdminNotification();
            _userNotificationl  = new UserNotification();
            _currentProject     = new GreenField();
            var _unitsOfWork = new UnitsOfWorkContainer(_currentProject,
                                                        new MongoRepository("mongodb://178.124.129.147/", "Projects"),
                                                        _userNotificationl,
                                                        _adminNotificate,
                                                        _investorNotificate,
                                                        _currentUser, _roles);

            if (_currentProject.WorkflowState == null)
            {
                _currentProject.WorkflowState = new Workflow
                {
                    CurrentState = ProjectWorkflow.State.Open
                };
            }
            //_workflow = new ProjectWorkflowWrapper(new ProjectWorkflow(_currentProject.WorkflowState.CurrentState), _unitsOfWork);
            //_workflow.IsMoveablde(ProjectWorkflow.Trigger.FillInformation);
            var builder = new AttributeStateMachineBuilder();
            var context = new ProjectStateContext();

            context.AdminNotification    = _adminNotificate;
            context.CurrentProject       = _currentProject;
            context.InvestorNotification = _investorNotificate;
            context.Repository           = _repository;
            context.Roles            = _roles;
            context.UserName         = _currentUser;
            context.UserNotification = _userNotificationl;
            var statemachine = builder
                               .BuilStateMachine <ProjectWorkflow.State, ProjectWorkflow.Trigger>(
                "test",
                context,
                _currentProject.WorkflowState.CurrentState);

            Console.Write(statemachine.CanFire(ProjectWorkflow.Trigger.FillInformation));
        }
コード例 #2
0
        public UnitsOfWorkContainer(Project currentProject,
                                    IRepository repository,
                                    IUserNotification userNotification,
                                    IAdminNotification adminNotification,
                                    IInvestorNotification investorNotification,
                                    string userName,
                                    IEnumerable <string> roles)
        {
            _currentProject       = currentProject;
            _repository           = repository;
            _userNotification     = userNotification;
            _adminNotification    = adminNotification;
            _investorNotification = investorNotification;
            _userName             = userName;
            _roles = roles;

            OpenUoW = new OpenUoW(_currentProject,
                                  _repository,
                                  _userNotification,
                                  _adminNotification,
                                  _investorNotification,
                                  _userName,
                                  _roles);
            OnMapUoW = new OnMapUoW(_currentProject,
                                    _repository,
                                    _userNotification,
                                    _adminNotification,
                                    _investorNotification,
                                    _userName,
                                    _roles);
            InvestorApproveUoW = new InvestorApproveUoW(_currentProject,
                                                        _repository,
                                                        _userNotification,
                                                        _adminNotification,
                                                        _investorNotification,
                                                        _userName,
                                                        _roles);

            WaitIspolcomUoW = new WaitIspolcomUoW(_currentProject,
                                                  _repository,
                                                  _userNotification,
                                                  _adminNotification,
                                                  _investorNotification,
                                                  _userName,
                                                  _roles);
            WaitInvolvedUoW = new WaitInvolvedUoW(_currentProject,
                                                  _repository,
                                                  _userNotification,
                                                  _adminNotification,
                                                  _investorNotification,
                                                  _userName,
                                                  _roles);
            WaitComissionUoW = new WaitComissionUoW(_currentProject,
                                                    _repository,
                                                    _userNotification,
                                                    _adminNotification,
                                                    _investorNotification,
                                                    _userName,
                                                    _roles);
            RealizationUoW = new RealizationUoW(_currentProject,
                                                _repository,
                                                _userNotification,
                                                _adminNotification,
                                                _investorNotification,
                                                _userName,
                                                _roles);
            PlanCreatingUoW = new PlanCreatingUoW(_currentProject,
                                                  _repository,
                                                  _userNotification,
                                                  _adminNotification,
                                                  _investorNotification,
                                                  _userName,
                                                  _roles);
            OnIspolcomUoW = new OnIspolcomUoW(_currentProject,
                                              _repository,
                                              _userNotification,
                                              _adminNotification,
                                              _investorNotification,
                                              _userName,
                                              _roles);
            OnComissionUoW = new OnComissionUoW(_currentProject,
                                                _repository,
                                                _userNotification,
                                                _adminNotification,
                                                _investorNotification,
                                                _userName,
                                                _roles);
            MinEconomyUoW = new MinEconomyUoW(_currentProject,
                                              _repository,
                                              _userNotification,
                                              _adminNotification,
                                              _investorNotification,
                                              _userName,
                                              _roles);
            IspolcomFixesUoW = new IspolcomFixesUoW(_currentProject,
                                                    _repository,
                                                    _userNotification,
                                                    _adminNotification,
                                                    _investorNotification,
                                                    _userName,
                                                    _roles);
            InvolvedorganizationsUoW = new InvolvedOrganizationsUoW(_currentProject,
                                                                    _repository,
                                                                    _userNotification,
                                                                    _adminNotification,
                                                                    _investorNotification,
                                                                    _userName,
                                                                    _roles);
            DocumentSendingUoW = new DocumentSendingUoW(_currentProject,
                                                        _repository,
                                                        _userNotification,
                                                        _adminNotification,
                                                        _investorNotification,
                                                        _userName,
                                                        _roles);
            ComissionFixesUoW = new ComissionFixesUoW(_currentProject,
                                                      _repository,
                                                      _userNotification,
                                                      _adminNotification,
                                                      _investorNotification,
                                                      _userName,
                                                      _roles);
            DoneUoW = new DoneUoW(_currentProject,
                                  _repository,
                                  _userNotification,
                                  _adminNotification,
                                  _investorNotification,
                                  _userName,
                                  _roles);

            var dict = new Dictionary <Type, IState>();

            dict.Add(OnMapUoW.GetType(), OnMapUoW);
            AttributeStateMachineBuilder.InitializeStates(dict);
        }