Esempio n. 1
0
        public void ActualizarDescripcionFiltros()
        {
            var descripcionFiltros = (Areas.Any(f => f.ID >= 0 && f.IsChecked) ?
                                      string.Join(", ", Areas.Where(f => f.ID >= 0 && f.IsChecked).Select(f => f.Nombre)) : "Todas");

            if (this.Areas.Count == 1)
            {
                descripcionFiltros = this.Areas[0].Nombre;
                this.Areas.FirstOrDefault().IsChecked = true;
                AreaEneable = false;
            }
            else
            {
                AreaEneable = true;
            }

            DescripcionFiltroAreas = (descripcionFiltros.Length > 68 ? descripcionFiltros.Substring(0, 66) + "..." : descripcionFiltros);

            descripcionFiltros = (Profesionales.Any(f => f.ID >= 0 && f.IsChecked) ?
                                  string.Join(", ", Profesionales.Where(f => f.ID >= 0 && f.IsChecked).Select(f => f.Nombre)) : "Todos");
            if (this.Profesionales.Count == 1)
            {
                descripcionFiltros = this.Profesionales[0].Nombre;
                this.Profesionales.FirstOrDefault().IsChecked = true;
                ProfesionalEneable = false;
            }
            else
            {
                ProfesionalEneable = true;
            }

            DescripcionFiltroProfesionales = (descripcionFiltros.Length > 68 ? descripcionFiltros.Substring(0, 66) + "..." : descripcionFiltros);
        }
Esempio n. 2
0
        public override void Render(IRenderContext rc)
        {
            if (rc == null)
            {
                throw new ArgumentNullException(nameof(rc));
            }

            if (!Areas.Any() || Areas.All(a => !a.Any()))
            {
                return;
            }

            VerifyAxes();

            OxyRect clippingRect = GetClippingRect();

            rc.SetClip(clippingRect);

            // Transform all points to screen coordinates
            foreach (IEnumerable <DataPoint> area in Areas)
            {
                int n0   = area.Count();
                var pts0 = new ScreenPoint[n0];
                TransformToScreenCoordinates(n0, pts0, area);

                rc.DrawClippedPolygon(clippingRect, pts0, 1, GetSelectableFillColor(Fill), Color, StrokeThickness);
            }

            rc.ResetClip();
        }
Esempio n. 3
0
        /// <summary>
        /// Criando regras iniciais e de testes
        /// </summary>
        private void Seed_Security()
        {
            if (!Groups.Any())
            {
                var groups = new Group[]
                {
                    new Group {
                        Name = "Security"
                    },
                    new Group {
                        Name = "Management"
                    },
                    new Group {
                        Name = "Configuration"
                    },
                    new Group {
                        Name = "Sales"
                    },
                    new Group {
                        Name = "Operation"
                    }
                };

                Groups.AddRange(groups);

                foreach (var enterprise in Enterprises)
                {
                    var name = enterprise.Name.EndsWith('s')
                        ? enterprise.Name + "\'s"
                        : enterprise.Name;

                    var group = new Group
                    {
                        Name       = $"{name} User",
                        Enterprise = enterprise
                    };

                    Groups.Add(group);
                }

                SaveChanges();
            }

            if (IsTest)
            {
                if (!Users.Any())
                {
                    {
                        var enterprise = Enterprises
                                         .Single(e => e.Name == "Enterprise Test");

                        var email = $"user@{enterprise.Name}.com".Replace(" ", "").ToLower();

                        var user = new User
                        {
                            Name       = "User",
                            PublicId   = CryptoHelper.Guid("U$1"),
                            PrivateId  = CryptoHelper.Guid("U$1"),
                            Email      = email,
                            Password   = CryptoHelper.Guid("user2019"),
                            Enterprise = enterprise
                        };

                        Users.Add(user);
                    }

                    foreach (var group in Groups
                             .Where(e => e.EnterpriseId == null))
                    {
                        foreach (var enterprise in Enterprises)
                        {
                            var email = $"{group.Name}@{enterprise.Name}.com".Replace(" ", "").ToLower();

                            var user = new User
                            {
                                Name       = group.Name,
                                PublicId   = CryptoHelper.Guid(group.Name + "#" + enterprise.Name),
                                PrivateId  = CryptoHelper.Guid(group.Name + "$" + enterprise.Name),
                                Email      = email,
                                Password   = CryptoHelper.Guid(group.Name.ToLower()),
                                Enterprise = enterprise
                            };

                            Users.Add(user);

                            var userGroup = new UserGroup
                            {
                                User  = user,
                                Group = group
                            };

                            UserGroups.AddRange(userGroup);
                        }
                    }

                    SaveChanges();
                }
            }

            if (!Areas.Any())
            {
                var areas = new Area[]
                {
                    new Area {
                        Id   = (int)AreaEnum.User,
                        Name = "User"
                    },
                    new Area {
                        Id   = (int)AreaEnum.Group,
                        Name = "Group"
                    },
                    new Area {
                        Id   = (int)AreaEnum.Customer,
                        Name = "Customer"
                    }
                };

                Areas.AddRange(areas);

                SaveChanges();
            }

            if (IsTest)
            {
                if (!AreaAccess.Any())
                {
                    // Sales tem acesso de leitura e escrita no CRM

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Customer);

                        var group = Groups
                                    .First(e => e.Name == "Sales");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = false,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Management tem acesso completo ao CRM

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Customer);

                        var group = Groups
                                    .First(e => e.Name == "Management");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = true,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Operation só pode consultar o CRM

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Customer);

                        var group = Groups
                                    .First(e => e.Name == "Operation");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = false,
                            CanDelete = false,
                            CanModify = false,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Segurança pode criar novos grupos

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.Group);

                        var group = Groups
                                    .First(e => e.Name == "Security");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = true,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    // Segurança pode criar novos usuários

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.User);

                        var group = Groups
                                    .First(e => e.Name == "Security");

                        var areaAccess = new AreaAccess
                        {
                            Area      = area,
                            Group     = group,
                            CanCreate = true,
                            CanDelete = true,
                            CanModify = true,
                            CanRead   = true
                        };

                        AreaAccess.Add(areaAccess);
                    }

                    SaveChanges();
                }
            }

            if (!Policies.Any())
            {
                var area = Areas
                           .Find((int)AreaEnum.User);

                var policies = new Policy[]
                {
                    new Policy {
                        Id   = (int)PolicyEnum.User_ChangePassword,
                        Area = area,
                        Name = "Change Password"
                    },
                    new Policy {
                        Id   = (int)PolicyEnum.User_ChangeEmail,
                        Area = area,
                        Name = "Change Email"
                    }
                };

                Policies.AddRange(policies);

                SaveChanges();
            }

            if (IsTest)
            {
                if (!PolicyAccess.Any())
                {
                    // Segurança tem acesso às políticas de segurança

                    {
                        var area = Areas
                                   .Find((int)AreaEnum.User);

                        var group = Groups
                                    .First(e => e.Name == "Security");

                        foreach (var policy in Policies
                                 .Where(e => e.AreaId == area.Id))
                        {
                            var policyAccess = new PolicyAccess
                            {
                                Group  = group,
                                Policy = policy
                            };

                            PolicyAccess.AddRange(policyAccess);
                        }
                    }

                    SaveChanges();
                }
            }
        }