예제 #1
0
        public IActionResult ChangeDeal(PipelineViewModel data, int PipelineId, int StageId)
        {
            var _data = _dealServices.Find(data.Deal.DealId);

            if (HasTaskRequired(_data.DealId))
            {
                return(RedirectToAction("Pipeline", new { msg = "Existem tarefas a serem finalizadas antes de movimentar este negócio" }));
            }



            _data.PipelineId = PipelineId;
            _data.StageId    = StageId;

            try
            {
                _dealServices.Update(_data);
                AddNewStage(_data.DealId, _data.StageId);
            }
            catch (Exception e)
            {
                return(RedirectToAction("Pipeline", new { msg = e.InnerException.Message }));
            }



            return(RedirectToAction("Pipeline"));
        }
예제 #2
0
        public void CanAddInput()
        {
            var posMock = new Mock <IGetPosition>();

            posMock.Setup(p => p.GetElementSize(It.IsAny <IViewAware>())).Returns(new Size(4, 4));
            posMock.Setup(p => p.ViewLoaded(It.IsAny <IViewAware>())).Returns(Observable.Never <Unit>());

            PipelineViewModel vm = MainViewModelTest.GetInstance(
                container => container.ComposeExportedValue <IGetPosition>(posMock.Object)
                ).PipelineViewModel;

            var node0 = new NodeViewModel(new BlurNode(), vm);

            vm.Nodes.Add(node0);
            vm.Parent.Model.Graph.AddNode(node0.Model);
            var node1 = new NodeViewModel(new WeightedAveragedMergeNode(), vm);

            vm.Nodes.Add(node1);
            vm.Parent.Model.Graph.AddNode(node1.Model);

            Assert.Equal(0, node1.Model.Inputs.Count);
            Assert.Equal(1, node1.Inputs.Count());

            vm.InOutputMouseDown(node0.Outputs.First());
            vm.InOutputMouseUp(node1.Inputs.Last());

            Assert.Equal(1, node1.Model.Inputs.Count);
            Assert.Equal(2, node1.Inputs.Count());
            Assert.Equal(node1.Inputs.First(), vm.Edges.Single().StartViewModel);
        }
        public async Task <IActionResult> AddAsync(PipelineViewModel pipeline)
        {
            if (ModelState.IsValid)
            {
                await _pipelineService.CreateAsync(pipeline, GetCurrentUserId());

                return(RedirectToAction("Index"));
            }
            return(View(pipeline));
        }
        public static void ProcessPagingOptions(PipelineListState pipelineListState, PipelineViewModel pipelineViewModel)
        {
            if (pipelineViewModel.PageCount % 10 == 0)
            {
                pipelineViewModel.PageGroups = (pipelineViewModel.PageCount / 10);
            }
            else
            {
                pipelineViewModel.PageGroups = (pipelineViewModel.PageCount / 10) + 1;
            }

            pipelineViewModel.PageGroups = ( int )pipelineViewModel.PageGroups;
            if (pipelineViewModel.PageCount % 10 != 0)
            {
                pipelineViewModel.LastPageItems = pipelineViewModel.PageCount % 10;
            }
            else
            {
                pipelineViewModel.LastPageItems = 10;
            }

            pipelineViewModel.CurrentPage = pipelineListState.CurrentPage;

            if (pipelineViewModel.CurrentPage % 10 != 0)
            {
                pipelineViewModel.StartPage = ( int )(pipelineViewModel.CurrentPage / 10) * 10 + 1;
                if ((( int )((pipelineViewModel.CurrentPage) / 10) + 1) == pipelineViewModel.PageGroups)
                {
                    pipelineViewModel.EndPage      = ( int )(pipelineViewModel.CurrentPage / 10) * 10 + pipelineViewModel.LastPageItems;
                    pipelineViewModel.LastPageDots = true;
                }
                else
                {
                    pipelineViewModel.EndPage      = ( int )(pipelineViewModel.CurrentPage / 10) * 10 + 10;
                    pipelineViewModel.LastPageDots = false;
                }
            }
            else
            {
                pipelineViewModel.StartPage = ( int )((pipelineViewModel.CurrentPage - 1) / 10) * 10 + 1;
                if ((( int )((pipelineViewModel.CurrentPage - 1) / 10) + 1) == pipelineViewModel.PageGroups)
                {
                    pipelineViewModel.EndPage      = ( int )(pipelineViewModel.CurrentPage / 10) * 10;
                    pipelineViewModel.LastPageDots = true;
                }
                else
                {
                    pipelineViewModel.EndPage      = ( int )((pipelineViewModel.CurrentPage - 1) / 10) * 10 + 10;
                    pipelineViewModel.LastPageDots = false;
                }
            }
        }
예제 #5
0
        public void GlobalTest10()
        {
            MainViewModel     mvm = MainViewModelTest.GetInstance();
            PipelineViewModel pvm = mvm.PipelineViewModel;

            // Step 1: The user clicks "New" to create a new pipeline
            mvm.Clear();
            Assert.Empty(mvm.Model.Graph.Nodes);
            var mock = new Mock <IDragEventInfo>();

            // Step 2: Create each type of node once by drag-and-drop
            VideoInputNode    vin = (VideoInputNode)AddNode <VideoInputNode>(pvm, mock, new Point(10, 30));
            AdditiveMergeNode amn = (AdditiveMergeNode)AddNode <AdditiveMergeNode>(pvm, mock, new Point(30, 30));
            BlurNode          bn  = (BlurNode)AddNode <BlurNode>(pvm, mock, new Point(50, 30));
            BrightnessContrastSaturationNode bcsn =
                (BrightnessContrastSaturationNode)AddNode <BrightnessContrastSaturationNode>(pvm, mock, new Point(70, 30));
            ColorInputNode            cin   = (ColorInputNode)AddNode <ColorInputNode>(pvm, mock, new Point(10, 50));
            DelayNode                 dln   = (DelayNode)AddNode <DelayNode>(pvm, mock, new Point(90, 30));
            DiagramNode               dgn   = (DiagramNode)AddNode <DiagramNode>(pvm, mock, new Point(110, 30));
            DifferenceNode            dfn   = (DifferenceNode)AddNode <DifferenceNode>(pvm, mock, new Point(30, 50));
            HistogramNode             hn    = (HistogramNode)AddNode <HistogramNode>(pvm, mock, new Point(50, 50));
            ImageInputNode            imin  = (ImageInputNode)AddNode <ImageInputNode>(pvm, mock, new Point(70, 50));
            InverterNode              invn  = (InverterNode)AddNode <InverterNode>(pvm, mock, new Point(90, 50));
            NoiseInputNode            nin   = (NoiseInputNode)AddNode <NoiseInputNode>(pvm, mock, new Point(110, 50));
            OverlayNode               on    = (OverlayNode)AddNode <OverlayNode>(pvm, mock, new Point(10, 70));
            RgbSplitNode              rgbsn = (RgbSplitNode)AddNode <RgbSplitNode>(pvm, mock, new Point(30, 70));
            WeightedAveragedMergeNode wamn  =
                (WeightedAveragedMergeNode)AddNode <WeightedAveragedMergeNode>(pvm, mock, new Point(50, 70));

            // Step 3: Create the edges
            mvm.Model.Graph.AddEdge(vin.Outputs[0], bn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], bn.Inputs[0].Source);
            amn.Inputs.Add(new Node.Input());
            mvm.Model.Graph.AddEdge(vin.Outputs[0], amn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], amn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(bn.Outputs[0], dln.Inputs[0]);
            Assert.Equal(bn.Outputs[0], dln.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(dln.Outputs[0], dfn.Inputs[0]);
            Assert.Equal(dln.Outputs[0], dfn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(imin.Outputs[0], dfn.Inputs[1]);
            Assert.Equal(imin.Outputs[0], dfn.Inputs[1].Source);
            mvm.Model.Graph.AddEdge(dfn.Outputs[0], invn.Inputs[0]);
            Assert.Equal(dfn.Outputs[0], invn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(invn.Outputs[0], on.Inputs[0]);
            Assert.Equal(invn.Outputs[0], on.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(vin.Outputs[0], on.Inputs[1]);
            Assert.Equal(vin.Outputs[0], on.Inputs[1].Source);
            mvm.Model.Graph.AddEdge(vin.Outputs[0], rgbsn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], rgbsn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(rgbsn.Outputs[2], hn.Inputs[0]);
            Assert.Equal(rgbsn.Outputs[2], hn.Inputs[0].Source);
        }
예제 #6
0
        public IActionResult Create(int id)
        {
            var pvm     = new PipelineViewModel();
            var catalog = _catalogRepository.GetById(id);

            pvm.Catalog = catalog;
            var jpl = new Pipeline();

            jpl.CatalogId = id;
            pvm.Pipeline  = jpl;

            return(View(pvm));
        }
예제 #7
0
        public IActionResult Create(PipelineViewModel pvm)
        {
            var cat = _catalogRepository.GetById(pvm.Catalog.CatalogId);

            var pl1 = pvm.Pipeline;

            pl1.Catalog = cat;

            if (pl1.JenkinsWebAPI != null)
            {
                pl1.JenkinsWebAPI = pl1.JenkinsWebAPI.Trim().ToString();
            }

            if (pl1.JenkinsWebAPI != null)
            {
                if (pl1.JenkinsWebAPI.Length > 0 && pl1.JenkinsWebAPI.Substring(pl1.JenkinsWebAPI.Length - 1) != "/")
                {
                    pl1.JenkinsWebAPI += "/";
                }
            }

            if (pl1.JenkinsWebAPI != null)
            {
                if (pl1.JenkinsWebAPI.Length > 0 && pl1.JenkinsWebAPI.Substring(pl1.JenkinsWebAPI.Length - 4) != "job/")
                {
                    pl1.JenkinsWebAPI += "job/";
                }
            }

            if (pl1.ServiceNowWebAPI != null)
            {
                pl1.ServiceNowWebAPI = pl1.ServiceNowWebAPI.Trim().ToString();
            }

            if (pl1.ServiceNowWebAPI != null)
            {
                if (pl1.ServiceNowWebAPI.Length > 0 && pl1.ServiceNowWebAPI.Substring(pl1.ServiceNowWebAPI.Length - 1) != "/")
                {
                    pl1.ServiceNowWebAPI += "/";
                }
            }

            _pipelineRepository.Create(pl1);

            return(RedirectToRoute(new
            {
                controller = "Catalog",
                action = "View",
                id = cat.CatalogId
            }));
        }
예제 #8
0
        public void CanRemoveNode()
        {
            PipelineViewModel vm = MainViewModelTest.GetInstance().PipelineViewModel;

            var node0 = new NodeViewModel(new BlurNode(), vm);

            vm.Nodes.Add(node0);
            vm.Parent.Model.Graph.AddNode(node0.Model);

            Assert.PropertyChanged(vm, "Edges", node0.RemoveNode);

            Assert.DoesNotContain(node0, vm.Nodes);
            Assert.DoesNotContain(node0.Model, vm.Parent.Model.Graph.Nodes);
        }
예제 #9
0
        public void Execute()
        {
            PipelineListState pipelineListState = _httpContext.Session["PipelineListState"] != null ?
                                                  (PipelineListState)_httpContext.Session["PipelineListState"] :
                                                  new PipelineListState();

            if (!InputParameters.ContainsKey("BorroweStatusFilter"))
            {
                throw new ArgumentException("BorroweStatusFilter was expected!");
            }

            pipelineListState.BorrowerStatusFilter = InputParameters["BorroweStatusFilter"].ToString() == "0" ? null : InputParameters["BorroweStatusFilter"].ToString();

            UserAccount user = _httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name ?
                               user = (UserAccount)_httpContext.Session[SessionHelper.UserData] :
                                      UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            // on date filter change, reset page number
            pipelineListState.CurrentPage = 1;
            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }
            PipelineViewModel pipelineViewModel = PipelineDataHelper.RetrievePipelineViewModel(pipelineListState,
                                                                                               _httpContext.Session["UserAccountIds"] != null
                                                              ? (List <int>)_httpContext.Session["UserAccountIds"]
                                                              : new List <int> {
            }, user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId,
                                                                                               CommonHelper.GetSearchValue(_httpContext));


            _viewName  = "Queues/_pipeline";
            _viewModel = pipelineViewModel;

            /* Persist new state */
            _httpContext.Session["PipelineViewModel"] = pipelineViewModel.ToXml();
            _httpContext.Session["PipelineListState"] = pipelineListState;
        }
예제 #10
0
        public IActionResult Post([FromBody] PipelineViewModel value)
        {
            var             _id             = Guid.Parse(userManager.GetUserId(User));
            Profile         profile         = dataCenterContext.Profiles.Where(x => x.Id == _id).First();
            Algorithm       algorithm       = dataCenterContext.Algorithms.Find(Guid.Parse(value.AlgorithmId));
            CompleteDataSet completeDataSet = dataCenterContext.CompleteDataSets.Find(Guid.Parse(value.DataSetId));
            Pipeline        pipeline        = new Pipeline
            {
                Algorithm          = algorithm,
                Id                 = Guid.NewGuid(),
                Name               = value.Name,
                Description        = value.Description,
                NumberOfContainers = value.NumberOfContainers,
                GetCompleteDataSet = completeDataSet
            };
            List <PipelineParameter> parameters = new List <PipelineParameter>();

            foreach (var parameter in value.Parameters)
            {
                AlgorithmParameters algorithmParameter = dataCenterContext.AlgorithmParameters.Find(Guid.Parse(parameter.Id));
                parameters.Add(new PipelineParameter
                {
                    Id                 = Guid.NewGuid(),
                    Pipeline           = pipeline,
                    Value              = parameter.Value,
                    AlgorithmParameter = algorithmParameter
                });
            }
            pipeline.PipelineParameters = parameters;
            ProfilePipeline profilePipeline = new ProfilePipeline
            {
                Pipeline = pipeline,
                Profile  = profile
            };

            dataCenterContext.ProfilePipeline.Add(profilePipeline);
            dataCenterContext.SaveChanges();

            RabbitMqService rabbitMqService = new RabbitMqService();

            rabbitMqService.SendMessage(pipeline.Id + "~" + algorithm.MasterImage);
            for (int i = 0; i < pipeline.NumberOfContainers - 1; i++)
            {
                rabbitMqService.SendMessage(pipeline.Id + "~" + algorithm.SlaveImage);
            }

            return(Ok());
        }
예제 #11
0
        public ViewManager(IServiceManager serviceManager)
        {
            this.serviceManager            = serviceManager;
            serviceManager.OnStatusChange += Update;

            notifyIcon = new NotifyIcon(new Container())
            {
                ContextMenuStrip = new ContextMenuStrip(),
                Icon             = AppIcon,
                Text             = AppText,
                Visible          = true,
            };

            notifyIcon.ContextMenuStrip.Opening += ContextMenuStrip_Opening;
            notifyIcon.DoubleClick += (sender, e) => ShowPipelineView();
            notifyIcon.MouseUp     += NotifyIcon_MouseUp;

            pipelineViewModel = new PipelineViewModel(serviceManager);
        }
예제 #12
0
파일: NodeViewModel.cs 프로젝트: Kha/YUV.KA
		public NodeViewModel(Node model, PipelineViewModel parent)
		{
			fake = new InOutputViewModel(model: null, parent: this);
			Model = model;
			NodeType = new NodeType { Type = model.GetType() };
			Parent = parent;
			ZIndex = 0;

			inputs = Model.Inputs.Select(i => new InOutputViewModel(i, this)).ToList();
			Outputs = Model.Outputs.Select(i => new InOutputViewModel(i, this)).ToList();

			if (Model.Outputs is INotifyCollectionChanged)
				((INotifyCollectionChanged)Model.Outputs).CollectionChanged += delegate
				{
					Outputs = Model.Outputs.Select(i => new InOutputViewModel(i, this)).ToList();
					NotifyOfPropertyChange(() => Outputs);
					NotifyOfPropertyChange(() => HasOutputs);
					Parent.NotifyOfPropertyChange(() => Parent.Edges);
				};
		}
예제 #13
0
        private Node AddNode <T>(PipelineViewModel pvm, Mock <IDragEventInfo> mock, Point p)
        {
            mock.Setup(e => e.GetData <NodeType>()).Returns(new NodeType {
                Type = typeof(T)
            });
            mock.Setup(e => e.GetPosition(pvm)).Returns(new Point(50, 70));
            mock.SetupProperty(e => e.Effects, DragDropEffects.Copy);

            pvm.CheckClearance(mock.Object);
            Assert.Equal(DragDropEffects.Copy, mock.Object.Effects);

            pvm.Drop(mock.Object);

            var node = pvm.Nodes.Last().Model;

            Assert.True(node is T);
            Assert.Equal(50, node.X);
            Assert.Equal(70, node.Y);

            return(node);
        }
예제 #14
0
        public void PipelineViewModel_ShouldFormTheWebsiteUrlCorrectly_IndependentlyOfTrailingSlashes(string baseUri, string result)
        {
            // Arrange
            GocdTray.App.Properties.Settings.Default.GocdWebUri = baseUri;
            var pipelineViewModel = new PipelineViewModel(new ServiceManager());

            // Act
            var pipeline = new Pipeline {
                Name = "Pipeline", PipelineInstances = { new PipelineInstance()
                                                         {
                                                             Label = "23", Stages =   { new Stage()
                                                                                        {
                                                                                            Name = "Stage", Run = 3
                                                                                        } }
                                                         } }
            };
            var websiteUrl = pipelineViewModel.GetPipelineUrl(pipeline);

            // Assert
            Assert.That(websiteUrl, Is.EqualTo(result));
        }
        public async Task <IActionResult> EditAsync(PipelineViewModel pipeline)
        {
            if (ModelState.IsValid)
            {
                //we have no guarantee that pipeline.UserId was not spoofed
                var pipelineForAuth = await _pipelineService.GetAsync(pipeline.Id);

                if (pipelineForAuth == null)
                {
                    return(new NotFoundResult());
                }
                if (!await CheckPermissionAsync(pipelineForAuth))
                {
                    return(new ChallengeResult());
                }

                await _pipelineService.UpdateAsync(pipeline);

                return(RedirectToAction("Show", new { id = pipeline.Id }));
            }
            return(View(pipeline));
        }
        public static void ApplyClassCollection(PipelineViewModel pipelineViewModel)
        {
            if (pipelineViewModel.PipelineItems != null)
            {
                // Business rule
                foreach (var pipelineItem in pipelineViewModel.PipelineItems)
                {
                    foreach (var item in pipelineItem.PipelineViewItems)
                    {
                        if (item.LockExpiration < DateTime.Now && item.LockExpiration != DateTime.MinValue && (item.LockStatus == -1 || ( LockStatus )item.LockStatus != LockStatus.LockRequested))
                        {
                            item.ClassCollection = "pipelinetablelistduedate";
                        }
                        else
                        {
                            item.ClassCollection = "pipelinetablelist";
                        }

                        if (item.ExceptionItemMaxWeight != -1)
                        {
                            item.ExceptionClassCollection = item.ExceptionItemMaxWeight < 300
                                ? "exceptionIcon exceptionIcon0"
                                : "exceptionIcon exceptionIcon1";
                        }

                        if (item == pipelineItem.PipelineViewItems.First())
                        {
                            item.ClassCollection = item.ClassCollection + " first last";
                        }

                        if (item == pipelineItem.PipelineViewItems.Last())
                        {
                            item.ClassCollection = item.ClassCollection + " last";
                        }
                    }
                }
            }
        }
예제 #17
0
        public void CanDropNode()
        {
            PipelineViewModel vm = MainViewModelTest.GetInstance().PipelineViewModel;

            var mock = new Mock <IDragEventInfo>();

            mock.Setup(e => e.GetData <NodeType>()).Returns(new NodeType {
                Type = typeof(BlurNode)
            });
            mock.Setup(e => e.GetPosition(vm)).Returns(new Point(42, 21));
            mock.SetupProperty(e => e.Effects, DragDropEffects.Copy);

            vm.CheckClearance(mock.Object);
            Assert.Equal(DragDropEffects.Copy, mock.Object.Effects);

            vm.Drop(mock.Object);

            var node = vm.Nodes.Single().Model;

            Assert.True(node is BlurNode);
            Assert.Equal(42, node.X);
            Assert.Equal(21, node.Y);
        }
예제 #18
0
        public ActionResult List()
        {
            List <ListPipeline> listPipeline = new List <ListPipeline>();
            var pipelineRespone           = _pipelineService.GetPipeline();
            List <PipelineModel> pipeline = new List <PipelineModel>();
            List <long>          listId   = new List <long>();

            if (!string.IsNullOrEmpty(pipelineRespone))
            {
                var result = JsonConvert.DeserializeObject <HrmResultModel <PipelineModel> >(pipelineRespone);
                if (!CheckPermission(result))
                {
                    //return to Access Denied
                }
                else
                {
                    pipeline = result.Results;
                    listId   = pipeline.Select(x => x.Id).Distinct().ToList();
                }
            }
            if (listId.Count() > 0)
            {
                listId.Sort();
                for (int i = 0; i < listId.Count(); i++)
                {
                    listPipeline.Add(new ListPipeline()
                    {
                        ListPipelineModel = pipeline.Where(x => x.Id == listId[i]).ToList()
                    });
                }
            }
            PipelineViewModel pipelineView = new PipelineViewModel();

            pipelineView.PipelineView = listPipeline;
            return(View(pipelineView));
        }
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            /* State retrieval */
            PipelineViewModel pipelineViewModel = null;

            if (_httpContext.Session[SessionHelper.PipelineViewModel] != null)
            {
                pipelineViewModel = new PipelineViewModel().FromXml(_httpContext.Session["PipelineViewModel"].ToString());
            }
            else
            {
                pipelineViewModel = new PipelineViewModel();
            }

            PipelineListState pipelineListState = null;

            if (_httpContext.Session[SessionHelper.PipelineListState] != null)
            {
                pipelineListState = ( PipelineListState )_httpContext.Session["PipelineListState"];
            }
            else
            {
                pipelineListState = new PipelineListState();
            }

            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name)
            {
                user = ( UserAccount )_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);
            }

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            /* parameter processing */
            PipelineAttribute newSortColumn;

            if (!InputParameters.ContainsKey("Column"))
            {
                throw new ArgumentException("Column value was expected!");
            }
            else
            {
                newSortColumn = ( PipelineAttribute )Enum.Parse(typeof(PipelineAttribute), InputParameters["Column"].ToString());
            }

            // switch direction
            if (pipelineListState.SortColumn == newSortColumn && pipelineListState.SortDirection == "ASC")
            {
                pipelineListState.SortDirection = "DESC";
            }
            else
            {
                pipelineListState.SortDirection = "ASC";
            }

            pipelineListState.SortColumn  = newSortColumn;
            pipelineListState.CurrentPage = 1;

            /* Command processing */
            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }
            var pipelineViewData = PipelineDataHelper.RetrievePipelineViewModel(pipelineListState,
                                                                                _httpContext.Session["UserAccountIds"] !=
                                                                                null
                                                                                    ? (List <int>)
                                                                                _httpContext.Session[
                                                                                    "UserAccountIds"]
                                                                                    : new List <int> {
            },
                                                                                user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue);


            if (pipelineViewModel != null)
            {
                pipelineViewModel.PipelineItems = pipelineViewData.PipelineItems;
                pipelineViewModel.PageCount     = pipelineViewData.PageCount;
                pipelineViewModel.TotalItems    = pipelineViewData.TotalItems;

                PipelineGridHelper.ProcessPagingOptions(pipelineListState, pipelineViewModel);
            }


            _viewName  = "Queues/_pipeline";
            _viewModel = pipelineViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.PipelineViewModel] = pipelineViewModel.ToXml();
            _httpContext.Session[SessionHelper.PipelineListState] = pipelineListState;
        }
예제 #20
0
        public ActionResult SavePipeline(AddPipelineViewModel data)
        {
            if (data.Pipeline != null)
            {
                var validations = ValidationHelper.Validation(data.Pipeline, "Pipeline");
                if (validations.Count > 0)
                {
                    return(Json(new { Result = validations, Invalid = true }, JsonRequestBehavior.AllowGet));
                }
            }
            data.Pipeline.CreatedBy = CurrentUser.UserId;
            data.Pipeline.UpdatedBy = CurrentUser.UserId;
            foreach (var item in data.PipelineStep)
            {
                if (item.ListStringPipelineRule != null)
                {
                    item.PipelineRule = string.Join(",", item.ListStringPipelineRule);
                }
            }
            if (data.Pipeline != null)
            {
                var validations = ValidationHelper.Validation(data, "data");
                if (validations.Count > 0)
                {
                    return(Json(new { Result = validations, Invalid = true }, JsonRequestBehavior.AllowGet));
                }
            }
            bool isSuccess          = false;
            var  responeseResources = string.Empty;
            var  pipelineEntity     = MapperHelper.Map <PipelineModel, PipelineEntity>(data.Pipeline);
            var  pipelineStepTity   = MapperHelper.MapList <PipelineStepModel, PipelineStepType>(data.PipelineStep);
            var  result             = _pipelineService.SavePipeline(pipelineEntity, pipelineStepTity);

            if (result != null)
            {
                var response = JsonConvert.DeserializeObject <HrmResultModel <bool> >(result);
                if (!CheckPermission(response))
                {
                    //return to Access Denied
                }
                else
                {
                    if (response.Success == true)
                    {
                        List <ListPipeline> listPipeline = new List <ListPipeline>();
                        var pipelineRespone           = _pipelineService.GetPipeline();
                        List <PipelineModel> pipeline = new List <PipelineModel>();
                        List <long>          listId   = new List <long>();

                        if (pipelineRespone != null)
                        {
                            var resultPipeline = JsonConvert.DeserializeObject <HrmResultModel <PipelineModel> >(pipelineRespone);
                            if (!CheckPermission(resultPipeline))
                            {
                                //return to Access Denied
                            }
                            else
                            {
                                pipeline = resultPipeline.Results;
                                listId   = pipeline.Select(x => x.Id).Distinct().ToList();
                            }
                        }
                        if (listId.Count() > 0)
                        {
                            listId.Sort();
                            for (int i = 0; i < listId.Count(); i++)
                            {
                                listPipeline.Add(new ListPipeline()
                                {
                                    ListPipelineModel = pipeline.Where(x => x.Id == listId[i]).ToList()
                                });
                            }
                        }
                        PipelineViewModel pipelineView = new PipelineViewModel();
                        pipelineView.PipelineView = listPipeline;
                        return(PartialView(UrlHelpers.TemplateAdmin("Pipeline", "_Pipeline.cshtml"), pipelineView));
                    }
                    else
                    {
                        if (data.Pipeline.Id != 0)
                        {
                            responeseResources = _localizationService.GetResources("Message.Update.UnSuccessful");
                        }
                        else
                        {
                            responeseResources = _localizationService.GetResources("Message.Create.UnSuccessfu");
                        }
                    }
                }
            }

            return(Json(new { isSuccess, responeseResources }, JsonRequestBehavior.AllowGet));
        }
        public static PipelineViewModel RetrievePipelineViewModel(PipelineListState pipelineListState, List <int> userAccountIds, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (pipelineListState == null)
            {
                pipelineListState = new PipelineListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <int>();
            }

            string isOnLineUser = pipelineListState.BorrowerStatusFilter == null ? null :
                                  pipelineListState.BorrowerStatusFilter == BorrowerStatusType.Offline.GetStringValue() ? "0" : "1";

            PipelineViewData pipelineViewData = LoanServiceFacade.RetrievePipelineItemsView(userAccountIds,
                                                                                            pipelineListState.CurrentPage,
                                                                                            pipelineListState.SortColumn.GetStringValue(),
                                                                                            pipelineListState.SortDirection,
                                                                                            userAccountId,
                                                                                            searchTerm,
                                                                                            pipelineListState.ActivityTypeFilter,
                                                                                            pipelineListState.BoundDate,
                                                                                            pipelineListState.LoanPurposeFilter,
                                                                                            isOnLineUser,
                                                                                            companyId,
                                                                                            channelId,
                                                                                            divisionId,
                                                                                            branchId
                                                                                            );

            if (pipelineViewData == null)
            {
                pipelineViewData = new PipelineViewData {
                    PipelineItems = new List <PipelineViewItem>(), TotalItems = 0, TotalPages = 0
                };
            }
            // Set paging numbers
            else if (userAccountIds.Any())
            {
                pipelineViewData.TotalItems = pipelineViewData.TotalItems;
                pipelineViewData.TotalPages = pipelineViewData.TotalItems / 10;
                if ((pipelineViewData.TotalItems % 10) != 0)
                {
                    pipelineViewData.TotalPages++;
                }
            }
            for (int i = 0; i < pipelineViewData.PipelineItems.Count(); i++)
            {
                if (pipelineViewData.PipelineItems[i].PipelineViewItems.Count > 0)
                {
                    DataForShortProductDescription data =
                        LoanServiceFacade.RetrieveDataForShortProductDescription(pipelineViewData.PipelineItems[i].PipelineViewItems[0].LoanId);

                    pipelineViewData.PipelineItems[i].PipelineViewItems[0].ProgramName = LoanHelper.FormatShortProductDescription(pipelineViewData.PipelineItems[i].PipelineViewItems[0].IsHarp,
                                                                                                                                  EnumHelper.GetStringValue((AmortizationType)data.AmortizationType),
                                                                                                                                  data.LoanTerm,
                                                                                                                                  data.FixedRateTerm,
                                                                                                                                  EnumHelper.GetStringValue((MortgageType)data.MortgageType));
                }
            }
            PipelineViewModel pipelineViewModel = new PipelineViewModel
            {
                ActivityTypeList   = CommonHelper.RetrieveActivityListForQueueFilter(),
                LoanPurposeList    = new List <LoanTransactionType>(Enum.GetValues(typeof(LoanTransactionType)).Cast <LoanTransactionType>().Skip(1)),
                BorrowerStatusList = new List <BorrowerStatusType>(Enum.GetValues(typeof(BorrowerStatusType)).Cast <BorrowerStatusType>().Skip(1)),
                PipelineItems      = pipelineViewData.PipelineItems,
                PageCount          = pipelineViewData.TotalPages,
                TotalItems         = pipelineViewData.TotalItems
            };

            PipelineGridHelper.ProcessPagingOptions(pipelineListState, pipelineViewModel);
            PipelineGridHelper.ApplyClassCollection(pipelineViewModel);

            return(pipelineViewModel);
        }
예제 #22
0
        public void CanDragEdge()
        {
            var posMock = new Mock <IGetPosition>();

            posMock.Setup(p => p.GetElementSize(It.IsAny <IViewAware>())).Returns(new Size(4, 4));
            posMock.Setup(p => p.ViewLoaded(It.IsAny <IViewAware>())).Returns(Observable.Never <Unit>());

            PipelineViewModel vm = MainViewModelTest.GetInstance(
                container => container.ComposeExportedValue <IGetPosition>(posMock.Object)
                ).PipelineViewModel;

            var node0 = new NodeViewModel(new BlurNode(), vm);

            vm.Nodes.Add(node0);
            vm.Parent.Model.Graph.AddNode(node0.Model);
            var node1 = new NodeViewModel(new BlurNode(), vm);

            vm.Nodes.Add(node1);
            vm.Parent.Model.Graph.AddNode(node1.Model);

            posMock.Setup(p => p.GetElementPosition(node0.Outputs.Single(), vm)).Returns(new Point(10, 10));
            posMock.Setup(p => p.GetElementPosition(node0.Inputs.Single(), vm)).Returns(new Point(30, 10));
            posMock.Setup(p => p.GetElementPosition(node1.Inputs.Single(), vm)).Returns(new Point(40, 10));

            // Start edge from node0 output

            Assert.PropertyChanged(vm, "DraggedEdge",
                                   () => vm.InOutputMouseDown(node0.Outputs.First())
                                   );

            var edge = vm.DraggedEdge;

            Assert.Equal(new Point(12, 12), edge.StartPoint);
            Assert.Equal(new Point(12, 12), edge.EndPoint);
            Assert.Equal(EdgeStatus.Indeterminate, edge.Status);

            // Move node0

            posMock.Setup(p => p.GetElementPosition(node0.Outputs.Single(), vm)).Returns(new Point(20, 10));
            Assert.PropertyChanged(edge, "Geometry",
                                   () => node0.Position = new Point(-1, -1) // Trigger ViewPositionChanged
                                   );
            Assert.Equal(new Point(22, 12), edge.StartPoint);
            Assert.Equal(new Point(22, 12), edge.EndPoint);

            // Drag edge

            var mouseMock = new Mock <IMouseEventInfo>();

            mouseMock.Setup(m => m.GetPosition(vm)).Returns(new Point(50, 50));
            mouseMock.SetupGet(m => m.LeftButton).Returns(MouseButtonState.Pressed);
            vm.MouseMove(mouseMock.Object);

            Assert.Equal(EdgeStatus.Indeterminate, edge.Status);
            Assert.Equal(new Point(50, 50), edge.EndPoint);

            // Drag edge over node0 input

            var e = new RoutedEventArgs(Mouse.MouseMoveEvent);

            vm.InOutputMouseMove(node0.Inputs.Single(), e);

            Assert.Equal(new Point(32, 12), edge.EndPoint);
            Assert.Equal(EdgeStatus.Invalid, edge.Status);

            // Drag edge over node1 input

            vm.InOutputMouseMove(node1.Inputs.Single(), e);

            Assert.Equal(new Point(42, 12), edge.EndPoint);
            Assert.Equal(EdgeStatus.Valid, edge.Status);

            // Drop edge on node1 input

            vm.InOutputMouseUp(node1.Inputs.Single());

            Assert.Equal(new Point(42, 12), vm.Edges.Single().StartPoint);
            Assert.Equal(new Point(22, 12), vm.Edges.Single().EndPoint);
            Assert.NotNull(vm.Edges.Single().Geometry);
        }
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            PipelineListState pipelineListState = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.PipelineListState] != null))
            {
                pipelineListState = ( PipelineListState )_httpContext.Session["PipelineListState"];
            }
            else
            {
                pipelineListState = new PipelineListState();
            }


            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session["FilterViewModel"] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session["FilterViewModel"].ToString());
                userFilterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.Pipeline;
            }
            else
            {
                // possible state retrieval?
                userFilterViewModel = new FilterViewModel();
                userFilterViewModel.FilterContext = Helpers.Enums.FilterContextEnum.Pipeline;
            }

            Boolean refresh = InputParameters != null && InputParameters.ContainsKey("Refresh") && InputParameters["Refresh"].ToString().Trim() == "true";

            // reset Page Number to 1st on Tab change
            if (!refresh)
            {
                pipelineListState.CurrentPage = 1;
            }

            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null)
            {
                user = ( UserAccount )_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                throw new InvalidOperationException("UserData is null");
            }

            PipelineViewModel pipelineViewModel = new PipelineViewModel();

            pipelineViewModel = PipelineDataHelper.RetrievePipelineViewModel(pipelineListState,
                                                                             _httpContext.Session["UserAccountIds"] != null
                                                              ? (List <int>)_httpContext.Session["UserAccountIds"]
                                                              : new List <int> {
            }, user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue);


            _viewName  = "Queues/_pipeline";
            _viewModel = pipelineViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.PipelineViewModel] = pipelineViewModel.ToXml();
            _httpContext.Session[SessionHelper.PipelineListState] = pipelineListState;
            _httpContext.Session[SessionHelper.FilterViewModel]   = userFilterViewModel.ToXml();
            _httpContext.Session[SessionHelper.CurrentTab]        = LoanCenterTab.Pipeline;
        }
예제 #24
0
        public IActionResult AddDeal(PipelineViewModel data, int PipelineId, int StageId, string ContactIds, string CompanyIds, int id)
        {
            var newCompany = new Company();
            var newContact = new Contact();

            if (!string.IsNullOrEmpty(ContactIds))
            {
                var com = ContactIds.Split(',');
                if (ContactIds.IndexOf("Create New", StringComparison.OrdinalIgnoreCase) > 0)
                {
                    newContact.FirstName = com[1];
                    try
                    {
                        _contactServices.Add(newContact);
                    }
                    catch
                    {
                        ;
                    }
                }
                else
                {
                    try
                    {
                        int key = Convert.ToInt32(com[0]);
                        newContact        = _contactServices.Find(key);
                        data.Deal.Contact = newContact;
                    }
                    catch (Exception)
                    {
                        ;
                    }
                }
            }
            else
            {
                newContact = null;
            }

            if (!string.IsNullOrEmpty(CompanyIds))
            {
                var com = CompanyIds.Split(',');
                if (CompanyIds.IndexOf("Create New", StringComparison.OrdinalIgnoreCase) > 0)
                {
                    newCompany.FirstName = com[1];
                    try
                    {
                        if (newContact != null)
                        {
                            newCompany.Contacts.Add(newContact);
                        }
                        _companyServices.Add(newCompany);
                    }
                    catch
                    {
                        ;
                    }
                }
                else
                {
                    try
                    {
                        int key = Convert.ToInt32(com[0]);
                        newCompany        = _companyServices.Find(key);
                        data.Deal.Company = newCompany;
                    }
                    catch (Exception)
                    {
                        ;
                    }
                }
            }
            else
            {
                newCompany = null;
            }


            data.Deal.Name          = (string.IsNullOrEmpty(data.Deal.Name) ? "New Deal" : data.Deal.Name);
            data.Deal.UserSettingId = _currentUser.Id();
            data.Deal.PipelineId    = PipelineId;
            data.Deal.StageId       = StageId;

            if (newCompany != null)
            {
                newCompany.FirstName = string.IsNullOrEmpty(newCompany.FirstName) ? data.Deal.Name : newCompany.FirstName;
                data.Deal.Company    = newCompany;
            }

            if (newContact != null)
            {
                data.Deal.Contact = newContact;
            }

            data.Deal.Win        = false;
            data.Deal.Lost       = false;
            data.Deal.Deleted    = false;
            data.Deal.VisibleAll = true;


            try
            {
                _dealServices.Add(data.Deal);
                AddNewStage(data.Deal.DealId, data.Deal.StageId);
            }
            catch (Exception e)
            {
                return(RedirectToAction("Pipeline", new { id = data.Deal.PipelineId, msg = e.InnerException.Message }));
            }



            return(RedirectToAction("Pipeline", new { id = data.Deal.PipelineId }));
        }
예제 #25
0
        public IActionResult Pipeline(int?id, string msg, string search)
        {
            ViewData["Msg"]    = msg;
            ViewData["search"] = search;

            if (!id.HasValue)
            {
                id = _accessor.HttpContext.Session.GetInt32("User.Settings.CurrentePipelineId");

                if (!id.HasValue)
                {
                    try
                    {
                        id = _pipelineServices.Get(p => p.Active == true).PipelineId;
                    }
                    catch (Exception)
                    {
                        return(RedirectToAction("Setup", "Home"));
                    }

                    _accessor.HttpContext.Session.SetInt32("User.Settings.CurrentePipelineId", id.Value);
                }
            }
            else
            {
                _accessor.HttpContext.Session.SetInt32("User.Settings.CurrentePipelineId", id.Value);
            }


            var pipeline = new Pipeline();

            ViewData["PipelineId"] = new SelectList(_pipelineServices.GetAll(p => p.Active == true), "PipelineId", "Name", id);

            if (id.HasValue)
            {
                pipeline = _pipelineServices.Find(id);
            }

            if ((pipeline == null))
            {
                return(NotFound());
            }

            var stages = _stageServices.Query(a => a.PipelineId == pipeline.PipelineId && a.Active == true).Include(p => p.Goals);
            var deals  = _dealServices.Query(p => p.PipelineId == pipeline.PipelineId && p.Win == false && p.Lost == false && p.Deleted == false);
            var goals  = _goalServices.Query(p => p.PipelineId == pipeline.PipelineId && p.Deleted == false && p.Active == true);

            if (!string.IsNullOrEmpty(search))
            {
                deals = deals.Where(a =>
                                    a.Name.Contains(search) ||
                                    a.Company.FirstName.Contains(search) ||
                                    a.Contact.FirstName.Contains(search)
                                    );
            }
            ;


            //var tasks = _taskServices.Query(p => p.DealId  != null && p.Deleted == false && p.Done == false);
            //deals.Include(a => a.Tasks);

            var data = new PipelineViewModel()
            {
                Pipeline = pipeline, Deal = new Deal(), Deals = deals.Include(a => a.Tasks), Stages = stages, Goals = goals
            };

            return(View(data));
        }
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            /* State retrieval */

            PipelineListState pipelineListState;

            if (_httpContext.Session[SessionHelper.PipelineListState] != null)
            {
                pipelineListState = ( PipelineListState )_httpContext.Session[SessionHelper.PipelineListState];
            }
            else
            {
                pipelineListState = new PipelineListState();
            }

            UserAccount user;

            if (_httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name)
            {
                user = ( UserAccount )_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);
            }

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            /* parameter processing */
            if (!InputParameters.ContainsKey("DateFilter"))
            {
                throw new ArgumentException("DateFilter value was expected!");
            }

            var newDateFilterValue = ( GridDateFilter )Enum.Parse(typeof(GridDateFilter), InputParameters["DateFilter"].ToString());

            pipelineListState.BoundDate = newDateFilterValue;

            // on date filter change, reset page number
            pipelineListState.CurrentPage = 1;

            /* Command processing */
            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }
            PipelineViewModel pipelineViewModel = PipelineDataHelper.RetrievePipelineViewModel(pipelineListState,
                                                                                               _httpContext.Session[SessionHelper.UserAccountIds] != null
                                                                                                    ? (List <int>)_httpContext.Session[SessionHelper.UserAccountIds]
                                                                                                    : new List <int> {
            }, user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue);

            _viewName  = "Queues/_pipeline";
            _viewModel = pipelineViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.PipelineViewModel] = pipelineViewModel.ToXml();
            _httpContext.Session[SessionHelper.PipelineListState] = pipelineListState;
        }
예제 #27
0
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            /* State retrieval */

            PipelineListState pipelineListState = null;

            if (_httpContext.Session["PipelineListState"] != null)
            {
                pipelineListState = ( PipelineListState )_httpContext.Session["PipelineListState"];
            }
            else
            {
                pipelineListState = new PipelineListState();
            }

            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name)
            {
                user = (UserAccount)_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);
            }

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            /* parameter processing */
            Int32 newPageNumber = 0;

            if (!InputParameters.ContainsKey("Page"))
            {
                throw new ArgumentException("Page number was expected!");
            }
            else
            {
                newPageNumber = Convert.ToInt32(InputParameters["Page"]);
            }

            pipelineListState.CurrentPage = newPageNumber;

            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }
            PipelineViewModel pipelineViewModel = PipelineDataHelper.RetrievePipelineViewModel(pipelineListState,
                                                                                               _httpContext.Session["UserAccountIds"] != null
                                                                                                    ? (List <int>)_httpContext.Session["UserAccountIds"]
                                                                                                    : new List <int> {
            }, user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId,
                                                                                               searchValue);



            //ContactViewModelHelper.PopulateProspectStatuses( contactViewModel );

            _viewName  = "Queues/_pipeline";
            _viewModel = pipelineViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.PipelineViewModel] = pipelineViewModel.ToXml();
            _httpContext.Session[SessionHelper.PipelineListState] = pipelineListState;
        }