Ejemplo n.º 1
0
        public static async Task ReadOutChannels(XmlTvReader reader, StreamWriter resultsFileStream)
        {
            var channels = reader.GetChannels().Distinct().ToList();

            resultsFileStream.Write(EntityExtensions.GetHeader("Channels"));

            foreach (var channel in channels)
            {
                System.Console.WriteLine("Retrieved Channel: {0} - {1}", channel.Id, channel.DisplayName);
                resultsFileStream.Write(channel.GetChannelDetail());
            }

            var totalProgrammeCount = 0;

            resultsFileStream.Write("\r\n");
            foreach (var channel in channels)
            {
                System.Console.WriteLine("Processing Channel: {0}", channel.DisplayName);

                resultsFileStream.Write(EntityExtensions.GetHeader("Programs for " + channel.DisplayName));
                var channelProgrammeCount = await ReadOutChannelProgrammes(reader, channel, resultsFileStream);

                totalProgrammeCount += channelProgrammeCount;
                await resultsFileStream.WriteLineAsync(String.Format("Total Programmes for {1}: {0}", channelProgrammeCount, channel.DisplayName));
            }

            await resultsFileStream.WriteLineAsync(String.Format("Total Programmes: {0}", totalProgrammeCount));
        }
Ejemplo n.º 2
0
        private string[] BuildFindElements(IEnumerable <string> findFields)
        {
            if (findFields == null)
            {
                return(null);
            }

            var list       = new List <string>();
            var entity     = EntityExtensions.Create <TEntity>();
            var properties = entity.GetPropertys();

            foreach (var property in properties)
            {
                if (findFields != null && !findFields.Contains(property.Name))
                {
                    continue;
                }

                var elmentName = entity.BsonElementName(property.Name);
                if (elmentName == null)
                {
                    continue;
                }

                list.Add(elmentName);
            }
            return(list.ToArray());
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Owned <Domain.ValueObjects.Localization.LocalizedValueObject>();

            foreach (var entityType in modelBuilder.Model.GetEntityTypes())
            {
                Type TEntity     = entityType.ClrType;
                Type TPrimaryKey = TEntity.GetProperty("Id")?.PropertyType;

                if (TPrimaryKey is null)
                {
                    continue;
                }

                if (EntityExtensions.EntityIsMayHaveTenant(TEntity, TPrimaryKey))
                {
                    modelBuilder.Entity(TEntity)
                    .HasOne(TEntity, "TenantlessEntity")
                    .WithMany("TenantEntities")
                    .OnDelete(DeleteBehavior.Restrict)
                    .HasForeignKey("TenantlessEntityId")
                    .IsRequired(false);
                }

                typeof(EfCoreDbContextBase)
                .GetMethod(nameof(ApplyBaseFilters), BindingFlags.Instance | BindingFlags.NonPublic)
                .MakeGenericMethod(TEntity, TPrimaryKey)
                .Invoke(this, new object[] { modelBuilder, entityType });
            }
        }
Ejemplo n.º 4
0
    private bool DeleteEntity()
    {
        using (var ctx = new Entities())
        {
            try
            {
                var id         = btnFormButtons.EntityID;
                var dataSource = ctx.REPORTs.FirstOrDefault(u => u.ID == id);
                dataSource.DELETED = 1;

                EntityExtensions.ExecuteProcedure(new EntityConnection(ctx.Connection.ConnectionString),
                                                  "Entities.ClearReportFields", new KeyValuePair <string, object>("REPORT_ID", dataSource.ID));

                EntityExtensions.ExecuteProcedure(new EntityConnection(ctx.Connection.ConnectionString),
                                                  "Entities.ClearReportSites", new KeyValuePair <string, object>("REPORT_ID", dataSource.ID));

                Audit.Log(ctx, AuditType.Edit, this.Page.GetType().FullName,
                          string.Format("Report Marked as Deleted. ID: {0}", dataSource.ID), LoggedInUser.ID);
                ctx.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                ExceptionLog.WriteException("Delete Report", ex);
                ShowMessage(MessageType.Error, "There was an error deleting this record");
            }
        }
        return(false);
    }
Ejemplo n.º 5
0
 // Token: 0x0600009E RID: 158 RVA: 0x00012510 File Offset: 0x00010710
 public override bool OnBeforeCalloutDisplayed()
 {
     this.SpawnPoint = NOOSEHeadquarters.sPos_prota;
     EManager.limoM  = new Vehicle(Main.vPatrol1, NOOSEHeadquarters.sPos_limo, NOOSEHeadquarters.he_limo);
     EManager.fbi1M  = new Vehicle(Main.vPatrol2, NOOSEHeadquarters.sPos_fbi1, NOOSEHeadquarters.he_fbi1);
     EManager.fbi2M  = new Vehicle(Main.vPatrol3, NOOSEHeadquarters.sPos_fbi2, NOOSEHeadquarters.he_fbi2);
     Noose_HQ_To_Maze_Bank.p_limo = new Ped("S_M_M_FIBOffice_01", EManager.limoM.Position, 0f);
     Noose_HQ_To_Maze_Bank.p_limo.WarpIntoVehicle(EManager.limoM, -1);
     Noose_HQ_To_Maze_Bank.p_fbi1 = new Ped("S_M_M_FIBOffice_02", EManager.fbi1M.Position, 0f);
     Noose_HQ_To_Maze_Bank.p_fbi1.WarpIntoVehicle(EManager.fbi1M, -1);
     Noose_HQ_To_Maze_Bank.p_fbi2 = new Ped("U_M_M_JewelSec_01", EManager.fbi2M.Position, 0f);
     Noose_HQ_To_Maze_Bank.p_fbi2.WarpIntoVehicle(EManager.fbi2M, -1);
     if (!EntityExtensions.Exists(Noose_HQ_To_Maze_Bank.p_limo))
     {
         return(false);
     }
     if (!EntityExtensions.Exists(Noose_HQ_To_Maze_Bank.p_fbi1))
     {
         return(false);
     }
     if (!EntityExtensions.Exists(Noose_HQ_To_Maze_Bank.p_fbi2))
     {
         return(false);
     }
     base.ShowCalloutAreaBlipBeforeAccepting(this.SpawnPoint, 25f);
     base.AddMinimumDistanceCheck(15f, this.SpawnPoint);
     base.CalloutMessage  = "Protection : NOOSE HQ to Maze Bank";
     base.CalloutPosition = this.SpawnPoint;
     Functions.PlayScannerAudioUsingPosition("WE_HAVE CONVOY_ESCORT IN_OR_ON_POSITION", this.SpawnPoint);
     return(base.OnBeforeCalloutDisplayed());
 }
Ejemplo n.º 6
0
 public static void LineToPolyCommand()
 {
     using (var tr = new QuickTransaction()) {
         EntityExtensions.LineToPoly(tr);
         tr.Commit();
     }
 }
Ejemplo n.º 7
0
        public void OnSalvedVariationType()
        {
            try
            {
                var variationType  = this.view.VariationType;
                var variationValue = this.view.VariationValue;

                if (string.IsNullOrEmpty(variationType))
                {
                    this.view.InfoMessage = "Informe um tipo";
                    return;
                }

                if (string.IsNullOrEmpty(variationValue))
                {
                    this.view.InfoMessage = "Informe um valor";
                    return;
                }

                this.variationType.Type  = variationType.ToUpper();
                this.variationType.Value = variationValue.ToUpper();

                this.repository.Add(this.variationType);
                EntityExtensions.UpdateAllVariationsStatic(this.repository.GetAll());

                this.view.InfoMessage = "Variação salva com sucesso!";
                this.view.Dispose();
            }
            catch (Exception ex)
            {
                LOGGER.Error($"Error while salved variation type:{ex.Message}");
                this.view.ErrorMessage = $"Não foi possível salvar esta variação: {ex.Message}";
            }
        }
Ejemplo n.º 8
0
        public void Flatten_Money(decimal m)
        {
            var cash = new Money(m);
            var s    = EntityExtensions.Flatten(cash);

            s.ShouldBe(m);
        }
Ejemplo n.º 9
0
        public void Flatten_Null_Works()
        {
            EntityReference er     = null;
            var             result = EntityExtensions.Flatten(er);

            result.ShouldBe(null);
        }
Ejemplo n.º 10
0
 // Token: 0x06000068 RID: 104 RVA: 0x00008620 File Offset: 0x00006820
 public override bool OnBeforeCalloutDisplayed()
 {
     this.SpawnPoint = GalileoObservatory.sPos_prota;
     EManager.limoM  = new Vehicle(Main.vPatrol1, GalileoObservatory.sPos_limo, GalileoObservatory.he_limo);
     EManager.fbi1M  = new Vehicle(Main.vPatrol2, GalileoObservatory.sPos_fbi1, GalileoObservatory.he_fbi1);
     EManager.fbi2M  = new Vehicle(Main.vPatrol3, GalileoObservatory.sPos_fbi2, GalileoObservatory.he_fbi2);
     Observatory_to_Richards_Majestic.p_limo = new Ped("S_M_M_FIBOffice_01", EManager.limoM.Position, 0f);
     Observatory_to_Richards_Majestic.p_limo.WarpIntoVehicle(EManager.limoM, -1);
     Observatory_to_Richards_Majestic.p_fbi1 = new Ped("S_M_M_FIBOffice_02", EManager.fbi1M.Position, 0f);
     Observatory_to_Richards_Majestic.p_fbi1.WarpIntoVehicle(EManager.fbi1M, -1);
     Observatory_to_Richards_Majestic.p_fbi2 = new Ped("U_M_M_JewelSec_01", EManager.fbi2M.Position, 0f);
     Observatory_to_Richards_Majestic.p_fbi2.WarpIntoVehicle(EManager.fbi2M, -1);
     if (!EntityExtensions.Exists(Observatory_to_Richards_Majestic.p_limo))
     {
         return(false);
     }
     if (!EntityExtensions.Exists(Observatory_to_Richards_Majestic.p_fbi1))
     {
         return(false);
     }
     if (!EntityExtensions.Exists(Observatory_to_Richards_Majestic.p_fbi2))
     {
         return(false);
     }
     base.ShowCalloutAreaBlipBeforeAccepting(this.SpawnPoint, 25f);
     base.AddMinimumDistanceCheck(15f, this.SpawnPoint);
     base.CalloutMessage  = "Protection : Galileo Observatory to Richards Majestic";
     base.CalloutPosition = this.SpawnPoint;
     Functions.PlayScannerAudioUsingPosition("WE_HAVE CONVOY_ESCORT IN_OR_ON_POSITION", this.SpawnPoint);
     return(base.OnBeforeCalloutDisplayed());
 }
Ejemplo n.º 11
0
        // GET: Admin/ProductAdder
        public async Task <ActionResult> Index(StatusMessageId?status, int page = 1, string search = null, int categoryId = 0)
        {
            ViewBag.StatusMessage = status != null?EntityExtensions.HtmlStatusMessage(status) : "";

            var response = await _adminProductService.GetDataAsync(page, pageSize, categoryId, search);

            return(View(response));
        }
Ejemplo n.º 12
0
        // GET: Admin/Discount
        public async Task <ActionResult> Index(StatusMessageId?status, string search = null, int pageSize = 10, int page = 1)
        {
            ViewBag.StatusMessage = status != null?EntityExtensions.HtmlStatusMessage(status) : "";

            var response = await _adminDiscountService.GetDataAsync(search, pageSize, page);

            return(View(response));
        }
Ejemplo n.º 13
0
        public void ThrowExceptionWhenNoNPC()
        {
            BFsharp.RuleDebugger.NoNotifyPropertyChangedWarning = RuleDebuggerEntrySeverity.Exception;

            var e  = new EntityWithoutNPC();
            var ee = EntityExtensions.RegisterTypedObject(e);

            ee.CreateValidationRule(x => x.Name.Length > 3)
            .Start();
        }
Ejemplo n.º 14
0
        // GET: Admin/Category
        public async Task <ActionResult> Index(StatusMessageId?status, int page = 1, string search = null)
        {
            ViewBag.StatusMessage = status != null?EntityExtensions.HtmlStatusMessage(status) : "";

            var response = await _categoryService.GetDataAsync(page, search);

            ViewBag.SearchString = search;

            return(View(response));
        }
Ejemplo n.º 15
0
        public void Test()
        {
            var entity = new EntityWithoutCode();

            var rules = EntityExtensions.RegisterTypedObject(entity);

            rules.CreateValidationRule(e => e.Count > 0).Start();

            rules.BrokenRules.Count.ShouldEqual(1);
        }
Ejemplo n.º 16
0
    private bool CopyFromForm()
    {
        using (var ctx = new Entities())
        {
            try
            {
                var dataSource = new FIELDGROUP();

                if (btnFormButtons.EntityID.HasValue)
                {
                    var id = btnFormButtons.EntityID;
                    dataSource = ctx.FIELDGROUPs.FirstOrDefault(u => u.ID == id);
                    PopulateEntity(ref dataSource);
                    Audit.Log(ctx, AuditType.Edit, this.Page.GetType().FullName,
                              string.Format("Group Edited. ID: {0}", dataSource.ID), LoggedInUser.ID);
                }
                else
                {
                    dataSource = new FIELDGROUP {
                        CREATEDON = DateTime.Now
                    };
                    PopulateEntity(ref dataSource);
                    ctx.AddToFIELDGROUPs(dataSource);

                    Audit.Log(ctx, AuditType.Add, this.Page.GetType().FullName,
                              string.Format("Group Added: {0}", dataSource.NAME), LoggedInUser.ID);
                }

                ctx.SaveChanges();

                // delete fields
                EntityExtensions.ExecuteProcedure(new EntityConnection(ctx.Connection.ConnectionString),
                                                  "Entities.ClearGroupFields", new KeyValuePair <string, object>("GROUP_ID", dataSource.ID));

                // save fields
                foreach (var item in jsGroupFields.SelectedItems)
                {
                    var groupField = new FIELDGROUPFIELD {
                        FIELDGROUPID = dataSource.ID, FIELDID = (short)int.Parse(item.Value)
                    };
                    ctx.AddToFIELDGROUPFIELDs(groupField);
                }

                ctx.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                ExceptionLog.WriteException("Save Group", ex);
                ShowMessage(MessageType.Error, "There was an error saving this record");
            }
        }
        return(false);
    }
Ejemplo n.º 17
0
        public void Flatten_EntityReference()
        {
            var er = new EntityReference("contact", Guid.Empty);
            var s  = EntityExtensions.Flatten(er);

            s.ShouldBe(new JsonEntityReference()
            {
                entityname = "contact",
                entityguid = Guid.Empty
            });
        }
Ejemplo n.º 18
0
        public async Task <ActionResult> EditDiscount(StatusMessageId?status, int discountId)
        {
            ViewBag.StatusMessage = status != null?EntityExtensions.HtmlStatusMessage(status) : "";

            var model = await _adminDiscountService.GetDataByIDAsync(discountId);

            var list = await _adminProductService.GetAllProductAsync();

            ViewBag.ProductId = new SelectList(list.Where(item => model.Products.FirstOrDefault(r => r.ProductId == item.ProductId) == null).ToList(), "ProductId", "Name");
            return(View(model));
        }
Ejemplo n.º 19
0
        public async Task <ActionResult> EditAuthor(StatusMessageId?status, string productId)
        {
            ViewBag.StatusMessage = status != null?EntityExtensions.HtmlStatusMessage(status) : "";

            var model = await _productService.GetDataByIDAsync(productId);

            var list = await _adminAuthorService.GetAllAuthorAsync();

            ViewBag.AuthorId = new SelectList(list.Where(item => model.Authors.FirstOrDefault(r => r.AuthorId == item.AuthorId) == null).ToList(), "AuthorId", "Name");
            return(View(model));
        }
Ejemplo n.º 20
0
        public void ThrowExceptionWhenClosure()
        {
            BFsharp.RuleDebugger.ClosureWarning = RuleDebuggerEntrySeverity.Exception;

            var e  = new EntityWithoutNPC();
            var ee = EntityExtensions.RegisterTypedObject(e);

            ee.CreateValidationRule(x => x.Name.Length != Name.Length)
            .WithModeAtStartup(ValidationRuleStartupMode.None)
            .Start();
        }
Ejemplo n.º 21
0
        public Repository(IEntityMappingConfigFactory entityMappingConfigFactory, IConfiguration configuration)
            : base(configuration)
        {
            _entityMappingConfig = entityMappingConfigFactory.Create(typeof(T));
            _tableName           = _entityMappingConfig.GetTableName();

            _fields = EntityExtensions.GetFieldNames(typeof(T))
                      .Select(fieldName => _entityMappingConfig
                              .GetColumnPropretyByFieldName(fieldName))
                      .Where(field => field != null && field.IsValid())
                      .ToList();
        }
Ejemplo n.º 22
0
 public void ModifyRelated <TRelationEntity>(
     TEntity entity, ICollection <TRelationEntity> oldRelations, IEnumerable <TRelationEntity> newRelations,
     Func <TRelationEntity, TRelationEntity, bool> equalsById) where TRelationEntity : class
 {
     auditVisitor.SetAuditProperties(entity);
     EntityExtensions.UpdateCollection(
         oldRelations,
         newRelations,
         equalsById,
         e => auditVisitor.SetAuditProperties(e)
         );
 }
Ejemplo n.º 23
0
        public void ImposeEntity_Returns_Copy_Of_Original_If_ToImpose_Null(bool imposeNullValues)
        {
            var originalEntity = new Entity()
            {
                Id = Guid.NewGuid(), LogicalName = EntityName
            };

            originalEntity.Attributes.Add(FieldName, "one");
            var imposed = originalEntity.ImposeEntity(null, imposeNullValues);

            Assert.True(EntityExtensions.SameAs(imposed, originalEntity));
        }
Ejemplo n.º 24
0
        public async Task <ActionResult> DeletedOrder(StatusMessageId?status, DateTime?fromDate, DateTime?toDate, int?orderStatus, int page = 1)
        {
            ViewBag.StatusMessage = status != null?EntityExtensions.HtmlStatusMessage(status) : "";

            var response = await _adminOrderService.GetDataAsync(fromDate, toDate, orderStatus, page, OrderTypeRequest.DeletedOrder);

            ViewBag.OrderStatusList = selectsStatus(2);
            ViewBag.FromDate        = fromDate;
            ViewBag.ToDate          = toDate;

            return(View(response));
        }
Ejemplo n.º 25
0
        public static Hero ClosestToMouse(Hero source, float range = 600)
        {
            var mousePosition = Game.MousePosition;
            var enemyHeroes   = ObjectManager.GetEntities <Hero>()
                                .Where(
                x =>
                x.Team == source.GetEnemyTeam() && !x.IsIllusion && x.IsAlive && x.IsVisible &&
                EntityExtensions.Distance2D(x, mousePosition) <= range /*&& !x.IsMagicImmune()*/)
                                .OrderBy(x => x.Distance2D(mousePosition));

            return(enemyHeroes.FirstOrDefault());
        }
Ejemplo n.º 26
0
        public void ThrowIfNotAllowedToEdit_Role_Entity_ArgumentNullException()
        {
            // Arrange
            var helper = new TestHelper();
            var user   = helper.CreateForRole("role");
            var parcel = EntityHelper.CreateParcel(123);

            parcel.SetRowVersion("value");

            // Act
            // Assert
            Assert.Throws <ArgumentNullException>(() => EntityExtensions.ThrowIfNotAllowedToEdit((Parcel)null, "paramName", user, "role"));
        }
Ejemplo n.º 27
0
        public void ThrowIfNotAllowedToEdit_Permissions_Entity_ArgumentNullException()
        {
            // Arrange
            var helper = new TestHelper();
            var user   = helper.CreateForPermission(Permissions.PropertyEdit);
            var parcel = EntityHelper.CreateParcel(123);

            parcel.SetRowVersion("value");

            // Act
            // Assert
            Assert.Throws <ArgumentNullException>(() => EntityExtensions.ThrowIfNotAllowedToEdit((Parcel)null, "paramName", user, new[] { Permissions.PropertyEdit, Permissions.PropertyAdd }));
        }
Ejemplo n.º 28
0
        public static void ConfigureObjectMappings()
        {
            EntityExtensions.CreateEntityMapping <User, UserT>()
            .ForMember(x => x.Username, x => x.MapFrom(y => y.Username))
            .ForMember(x => x.Password, x => x.MapFrom(y => y.Password))
            .ForMember(x => x.EmailAddress, x => x.MapFrom(y => y.EmailAddress));
            EntityExtensions.CreateDtoMapping <UserT, User>()
            .ForMember(x => x.Username, x => x.MapFrom(y => y.Username))
            .ForMember(x => x.Password, x => x.MapFrom(y => y.Password))
            .ForMember(x => x.EmailAddress, x => x.MapFrom(y => y.EmailAddress));

            Mapper.AssertConfigurationIsValid();
        }
Ejemplo n.º 29
0
        public void ThrowIfNotAllowedToEdit_Permission_Entity_ArgumentNullException()
        {
            // Arrange
            var helper   = new TestHelper();
            var user     = helper.CreateForPermission(Permissions.PropertyEdit);
            var property = EntityHelper.CreateProperty(123);

            property.ConcurrencyControlNumber = 1;

            // Act
            // Assert
            Assert.Throws <ArgumentNullException>(() => EntityExtensions.ThrowIfNotAllowedToEdit((PimsProperty)null, "paramName", user, Permissions.PropertyEdit));
        }
Ejemplo n.º 30
0
        public async Task <AdminChartResponse> GetChartResponse()
        {
            var week   = EntityExtensions.GetWeekDate(DateTime.Now);
            var months = EntityExtensions.GetRevenue(DateTime.Now);
            var roles  = await _identityRoleRepository.GetListRoles();

            var areaLabels = new List <string>();
            var areaData   = new List <double>();
            var barLabels  = new List <string>();
            var barData    = new List <double>();
            var pieLabels  = new List <string>();
            var pieData    = new List <double>();

            foreach (var item in week)
            {
                var price = await GetDayEarning(item);

                areaLabels.Add("'" + item.Date.Day + "/" + item.Date.Month + "'");
                areaData.Add(price);
            }

            foreach (var item in months)
            {
                var price = await GetMonthEarning(item);

                barLabels.Add("'Tháng " + item.Date.Month + "'");
                barData.Add(price);
            }

            var emp = _applicationUserRepository.CountEmp();

            foreach (var item in roles)
            {
                var user = await _applicationUserRepository.GetListUserByRole(item);

                pieLabels.Add("'" + item.Name + "'");
                pieData.Add(Math.Round((double)user.Count() / emp * 100));
            }

            return(new AdminChartResponse {
                AreaChart = new AreaChart {
                    Date = areaLabels, DateEarning = areaData
                },
                BarChart = new BarChart {
                    Date = barLabels, DateEarning = barData
                },
                PieChart = new PieChart {
                    Roles = pieLabels, Percentage = pieData
                }
            });
        }