Ejemplo n.º 1
0
        public static List <dynamic> GetRoutesForUser(Guid userId)
        {
            string filterStr = string.Format(@"Id in 
(select EntityRouteId from [dbo].[EntityRouteUser] 
    where SecurityUserId = @UserIdValue) OR (select COUNT(*) from [dbo].[EntityRouteUser] where EntityRoute.Id = EntityRouteId) = 0");

            var param = new Dictionary <string, object>();

            param.Add("UserIdValue", userId);
            FilterCriteriaSet filter = FilterCriteriaSet.And.Custom(filterStr, param);

            return(DynamicRepository.GetByEntity("EntityRoute", filter, OrderByCriteriaSet.Asc("Name")));
        }
Ejemplo n.º 2
0
        public ActionResult GetBudgetVersions(Guid id, bool excludecurrent)
        {
            var budgetversions = excludecurrent ?
                                 DynamicRepository.GetByEntity("BudgetVersion",
                                                               FilterCriteriaSet.And.Equal(id, "BudgetId").NotEqual(true, "IsCurrent"),
                                                               OrderByCriteriaSet.Asc("Name")) :
                                 DynamicRepository.GetByEntity("BudgetVersion",
                                                               FilterCriteriaSet.And.Equal(id, "BudgetId"),
                                                               OrderByCriteriaSet.Asc("Name"));

            return(new ContentResult
            {
                ContentType = "text/html",
                Content = DynamicEntityJSONDataSource.GetSuccessWithPlainSerializedValues("OK", budgetversions, "values")
            });
        }
Ejemplo n.º 3
0
        private XElement GenerateByStages(dynamic entityRoute, IDictionary <string, object> parameters)
        {
            var routeItems = DynamicRepository.GetByEntity("EntityRouteItem",
                                                           FilterCriteriaSet.And.Equal((Guid)entityRoute.Id, "EntityRouteId"),
                                                           OrderByCriteriaSet.Asc("Number")).ToList();

            var routeItemUsers = DynamicRepository.GetByView("EntityRouteItemSighters",
                                                             FilterCriteriaSet.And.Equal((Guid)entityRoute.Id, "EntityRouteItemId_EntityRouteId")).ToList();

            var blocks = new List <WorkflowBlock>();

            //create SimpleBlocks
            SimpleBlock draftBlock = new SimpleBlock("Draft");

            draftBlock["Initial"]   = true;
            draftBlock["AllowEdit"] = true;
            draftBlock["Actor"]     = true;
            blocks.Add(draftBlock);

            for (int i = 0; i < routeItems.Count; i++)
            {
                var routeItem = routeItems[i];
                var block     = new SimpleBlock(routeItem.Name);
                block["AllowEdit"] = routeItem.AllowEdit;
                block["Users"]     = routeItemUsers.Where(c => c.EntityRouteItemId == routeItem.Id)
                                     .Select(s => ((Guid)s.SecurityUserId).ToString("N")).ToList().ToFormattedString(";", false);
                blocks.Add(block);
            }

            if (entityRoute.AddStageForLegalEntity)
            {
                var block = new StageForLegalEntityBlock("Final regional approval");
                block["Initial"]   = false;
                block["AllowEdit"] = true;
                blocks.Add(block);
            }

            blocks.Add(new SimpleBlock("Approved"));

            //set Commands property
            for (int i = 0; i < blocks.Count - 1; i++)
            {
                var block = blocks[i];
                if (block["Initial"] is bool && (bool)block["Initial"])
                {
                    block["Commands"] = new List <SimpleCommand>()
                    {
                        new SimpleCommand()
                        {
                            Name = "StartToRoute", ToBlock = blocks[i + 1], Classifier = TransitionClassifier.Direct
                        }
                    };
                }
                else if (i < blocks.Count - 3)
                {
                    block["Commands"] = new List <SimpleCommand>()
                    {
                        new SimpleCommand()
                        {
                            Name = "WfCommandAgree", ToBlock = blocks[i + 1], Classifier = TransitionClassifier.Direct
                        },
                        new SimpleCommand()
                        {
                            Name = "WfCommandBacktoDraft", ToBlock = draftBlock, Classifier = TransitionClassifier.Reverse
                        }
                    };
                }
                else
                {
                    block["Commands"] = new List <SimpleCommand>()
                    {
                        new SimpleCommand()
                        {
                            Name = "WfCommandApproved", ToBlock = blocks[i + 1], Classifier = TransitionClassifier.Direct
                        },
                        new SimpleCommand()
                        {
                            Name = "WfCommandBacktoDraft", ToBlock = draftBlock, Classifier = TransitionClassifier.Reverse
                        }
                    };
                }
            }

            return(Converter.ToXElement(string.Empty, blocks));
        }
Ejemplo n.º 4
0
        public static List <ImpersonationInfo> GetImpersonationForUser(Guid userId)
        {
            if ((new DynamicEntityRepository()).GetEntityMetadataByEntityName("SecurityUserImpersonation") == null)
            {
                return(new List <ImpersonationInfo>());
            }

            var param = new Dictionary <string, object>();

            param.Add("CurrentDate", DateTime.Now.Date);

            var filter = FilterCriteriaSet.And.Custom("DATEADD(dd, 0, DATEDIFF(dd, 0, @CurrentDate)) >= DATEADD(dd, 0, DATEDIFF(dd, 0, DateFrom)) AND DATEADD(dd, 0, DATEDIFF(dd, 0, @CurrentDate)) <= DATEADD(dd, 0, DATEDIFF(dd, 0, DateTo))  ", param);

            filter = filter.Merge(FilterCriteriaSet.And.Equal(userId, "ImpSecurityUserId"));

            var imp = DynamicRepository.GetByEntity("SecurityUserImpersonation", filter);

            if (imp.Count == 0)
            {
                return(new List <ImpersonationInfo>());
            }

            var employee = DynamicRepository.GetByView("Employee", FilterCriteriaSet.And.In(imp.Select(c => c.SecurityUserId).ToList(), "SecurityUserId"), OrderByCriteriaSet.Asc("SecurityUserId_Name"));

            return(employee.Select(e => new ImpersonationInfo()
            {
                Id = e.SecurityUserId,
                Name = e.SecurityUserId_Name,
                Employee = e,
                DateTo = imp.Where(c => c.SecurityUserId == e.SecurityUserId).Single().DateTo
            }).ToList());
        }