示例#1
0
 public void SetDestinationPoint(CellBase point)
 {
     if (DestinationPoint != null && CellBase.CompareStates(DestinationPoint.GetState(), CellBase.State.DestinationPoint))
     {
         DestinationPoint.SetFree();
     }
     DestinationPoint = point;
 }
示例#2
0
        public Ride CreateNewRide(Address startPoint, Address destinationPoint, Money income,
                                  int customerId, CustomerDetails customerDetails)
        {
            var start       = new DestinationPoint(PointStatus.OnTheWay, startPoint);
            var destination = new DestinationPoint(PointStatus.NotStarted, destinationPoint, start);

            var driversIncome = new Money(income.Currency, income.Amount * DriverIncomeFromSingleRidePercent);

            return(new Ride(RideStatus.OnTheWayToCustomer, driversIncome, customerId, customerDetails, start, destination));
        }
示例#3
0
    private void Start()
    {
        _audioManager           = GameObject.Find("AudioManager").GetComponent <AudioManager>();
        _destinationPoint       = GameObject.Find("DeathPoint").transform;
        _destinationPointScript = _destinationPoint.GetComponent <DestinationPoint>();
        _spriteManager          = GameObject.Find("SpriteManager").GetComponent <SpriteManager>();
        _player = GameObject.Find("Player").GetComponent <Animator>();
        _spriteManager.InitSprite(gameObject);

        _splashOnDeath = GameObject.Find("OnDeath").GetComponent <SplashOnDeath>();
    }
示例#4
0
        public NavigationComponent(NavMeshAgent agent, IEnumerable <DestinationPoint> destinationPoints,
                                   Transform mainTransform, Transform syncTransform, HealthController healthController,
                                   WinLoseController winLoseController, GameObject hitEffect, IInstantiator instantiator)
        {
            _agent             = agent;
            _mainTransform     = mainTransform;
            _syncTransform     = syncTransform;
            _healthController  = healthController;
            _winLoseController = winLoseController;
            _hitEffect         = hitEffect;
            _instantiator      = instantiator;

            var random = new System.Random();

            _destination = destinationPoints.OrderBy(x => random.Next()).First();
            mainTransform.LookAt(_destination.transform.position);
        }
示例#5
0
        public async Task <DestinationPoint> UpdateDestinationPointCustomFormat(DestinationPoint destinationPoint)
        {
            try
            {
                var previousDestinationPoint = await _dbContext.DestinationPoints
                                               .Include(o => o.ReferencedSourcePoint)
                                               .Include(o => o.ReferencedSourcePoint.Catalog)
                                               .Include(o => o.DestinationPointCustomFormats).ThenInclude(x => x.CustomFormat).FirstAsync(o => o.Id == destinationPoint.Id);

                if (previousDestinationPoint != null)
                {
                    previousDestinationPoint.DecimalPlace = destinationPoint.DecimalPlace;
                    // Remove old format
                    var oldFormats = previousDestinationPoint.DestinationPointCustomFormats.Where(x => x.DestinationPointId == destinationPoint.Id).ToList();

                    foreach (var item in oldFormats)
                    {
                        previousDestinationPoint.DestinationPointCustomFormats.Remove(item);
                    }

                    // Add new format
                    var newFormat = new DestinationPointCustomFormats()
                    {
                        DestinationPointId = destinationPoint.Id, CustomFormatId = destinationPoint.DestinationPointCustomFormats.FirstOrDefault().CustomFormatId
                    };
                    previousDestinationPoint.DestinationPointCustomFormats.Add(newFormat);

                    await _dbContext.SaveChangesAsync();

                    await _dbContext.Entry(previousDestinationPoint.ReferencedSourcePoint).ReloadAsync();

                    previousDestinationPoint.ReferencedSourcePoint.PublishedHistories = (await _dbContext.PublishedHistories.Where(o => o.SourcePointId == previousDestinationPoint.ReferencedSourcePoint.Id).ToArrayAsync())
                                                                                        .OrderByDescending(p => p.PublishedDate).ToArray();
                    previousDestinationPoint.ReferencedSourcePoint.SerializeCatalog = true;
                    previousDestinationPoint.ReferencedSourcePoint.Catalog.SerializeSourcePoints = false;
                    previousDestinationPoint.DestinationPointCustomFormats.FirstOrDefault().CustomFormat = await _dbContext.CustomFormats.FirstOrDefaultAsync(x => x.Id == destinationPoint.DestinationPointCustomFormats.FirstOrDefault().CustomFormatId);

                    await _logService.WriteLog(new LogEntity()
                    {
                        LogId      = "30002",
                        Action     = Constant.ACTIONTYPE_EDIT,
                        PointType  = Constant.POINTTYPE_DESTINATIONPOINT,
                        ActionType = ActionTypeEnum.AuditLog,
                        Message    = $"Edit destination point."
                    });
                }

                return(previousDestinationPoint);
            }
            catch (ApplicationException ex)
            {
                throw ex.InnerException;
            }
            catch (Exception ex)
            {
                var logEntity = new LogEntity()
                {
                    LogId      = "20003",
                    Action     = Constant.ACTIONTYPE_ADD,
                    ActionType = ActionTypeEnum.ErrorLog,
                    PointType  = Constant.POINTTYPE_DESTINATIONPOINT,
                    Message    = ".Net Error",
                    Detail     = ex.ToString()
                };
                logEntity.Subject = $"{logEntity.LogId} - {logEntity.Action} - {logEntity.PointType} - Error";
                await _logService.WriteLog(logEntity);

                throw ex;
            }
        }
示例#6
0
        public async Task <DestinationPoint> AddDestinationPoint(string fileName, string documentId, DestinationPoint destinationPoint)
        {
            try
            {
                var  destinationCatalog    = _dbContext.DestinationCatalogs.FirstOrDefault(o => o.DocumentId == documentId);
                bool addDestinationCatalog = (destinationCatalog == null);
                if (addDestinationCatalog)
                {
                    try
                    {
                        destinationCatalog = new DestinationCatalog()
                        {
                            Name = fileName, DocumentId = documentId
                        };
                        _dbContext.DestinationCatalogs.Add(destinationCatalog);
                    }
                    catch (Exception ex)
                    {
                        var entity = new LogEntity()
                        {
                            LogId      = "40002",
                            Action     = Constant.ACTIONTYPE_ADD,
                            ActionType = ActionTypeEnum.ErrorLog,
                            PointType  = Constant.POINTYTPE_DESTINATIONCATALOG,
                            Message    = ".Net Error",
                        };
                        entity.Subject = $"{entity.LogId} - {entity.Action} - {entity.PointType} - Error";
                        await _logService.WriteLog(entity);

                        throw new ApplicationException("Add Source Catalog failed", ex);
                    }
                }

                destinationPoint.Created = DateTime.Now.ToUniversalTime().ToPSTDateTime();
                destinationPoint.Creator = _userProfileService.GetCurrentUser().Username;

                destinationCatalog.DestinationPoints.Add(destinationPoint);

                _dbContext.SourcePoints.Attach(destinationPoint.ReferencedSourcePoint);
                _dbContext.DestinationPoints.Add(destinationPoint);

                await _dbContext.Entry(destinationPoint.ReferencedSourcePoint).ReloadAsync();

                // Add recent files
                var recentFile = new RecentFile();
                recentFile.User      = _userProfileService.GetCurrentUser().Username;
                recentFile.Date      = DateTime.Now.ToUniversalTime().ToPSTDateTime();
                recentFile.CatalogId = (await _dbContext.SourcePoints.FirstOrDefaultAsync(o => o.Id == destinationPoint.ReferencedSourcePoint.Id)).CatalogId;
                _dbContext.RecentFiles.Add(recentFile);

                await _dbContext.SaveChangesAsync();

                if (addDestinationCatalog)
                {
                    await _logService.WriteLog(new LogEntity()
                    {
                        LogId      = "40001",
                        Action     = Constant.ACTIONTYPE_ADD,
                        PointType  = Constant.POINTYTPE_DESTINATIONCATALOG,
                        ActionType = ActionTypeEnum.AuditLog,
                        Message    = $"Add destination catalog {destinationCatalog.Name}."
                    });
                }
                await _logService.WriteLog(new LogEntity()
                {
                    LogId      = "20001",
                    Action     = Constant.ACTIONTYPE_ADD,
                    PointType  = Constant.POINTTYPE_DESTINATIONPOINT,
                    ActionType = ActionTypeEnum.AuditLog,
                    Message    = $"Create destination point value: {destinationPoint.ReferencedSourcePoint.Value} in the word file named:{destinationCatalog.FileName} by {_userProfileService.GetCurrentUser().Username}"
                });

                destinationPoint = await _dbContext.DestinationPoints
                                   .Include(o => o.ReferencedSourcePoint)
                                   .Include(o => o.ReferencedSourcePoint.Catalog)
                                   .Include(o => o.DestinationPointCustomFormats).ThenInclude(x => x.CustomFormat).FirstAsync(o => o.Id == destinationPoint.Id);

                destinationPoint.ReferencedSourcePoint.PublishedHistories            = (await _dbContext.PublishedHistories.Where(o => o.SourcePointId == destinationPoint.ReferencedSourcePoint.Id).ToArrayAsync()).OrderByDescending(p => p.PublishedDate).ToArray();
                destinationPoint.ReferencedSourcePoint.SerializeCatalog              = true;
                destinationPoint.ReferencedSourcePoint.Catalog.SerializeSourcePoints = false;
                destinationPoint.DestinationPointCustomFormats = destinationPoint.DestinationPointCustomFormats;

                await _logService.WriteLog(new LogEntity()
                {
                    LogId      = "30002",
                    Action     = Constant.ACTIONTYPE_GET,
                    PointType  = Constant.POINTTYPE_SOURCECATALOGLIST,
                    ActionType = ActionTypeEnum.AuditLog,
                    Message    = $"Get source catalogs."
                });

                return(destinationPoint);
            }
            catch (ApplicationException ex)
            {
                throw ex.InnerException;
            }
            catch (Exception ex)
            {
                var logEntity = new LogEntity()
                {
                    LogId      = "20003",
                    Action     = Constant.ACTIONTYPE_ADD,
                    ActionType = ActionTypeEnum.ErrorLog,
                    PointType  = Constant.POINTTYPE_DESTINATIONPOINT,
                    Message    = ".Net Error",
                    Detail     = ex.ToString()
                };
                logEntity.Subject = $"{logEntity.LogId} - {logEntity.Action} - {logEntity.PointType} - Error";
                await _logService.WriteLog(logEntity);

                throw ex;
            }
        }
        public async Task CloneFiles(IEnumerable <CloneForm> files)
        {
            try
            {
                var filesWillClone     = files.Where(o => o.Clone);
                var clonedSourcePoints = new Dictionary <Guid, SourcePoint>();
                foreach (var item in filesWillClone)
                {
                    if (item.IsExcel)
                    {
                        var catalog = await _dbContext.SourceCatalogs.Where(o => o.DocumentId.Equals(item.DocumentId, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefaultAsync();

                        if (catalog != null)
                        {
                            var sourcePoints = await _dbContext.SourcePoints.Where(o => o.Status == SourcePointStatus.Created && o.CatalogId == catalog.Id)
                                               .Include(o => o.DestinationPoints)
                                               .ToArrayAsync();

                            var sourcePointIds     = sourcePoints.Select(point => point.Id).ToArray();
                            var publishedHistories = await(from pb in _dbContext.PublishedHistories
                                                           where sourcePointIds.Contains(pb.SourcePointId)
                                                           select pb).ToArrayAsync();

                            #region Add new source catalog

                            SourceCatalog newSourceCatalog = new SourceCatalog()
                            {
                                Name = item.DestinationFileUrl, DocumentId = item.DestinationFileDocumentId, IsDeleted = false
                            };
                            _dbContext.SourceCatalogs.Add(newSourceCatalog);

                            #endregion

                            #region Add new source point

                            foreach (var sourcePoint in sourcePoints)
                            {
                                var lastPublishedValue = publishedHistories.Where(o => o.SourcePointId == sourcePoint.Id).OrderByDescending(o => o.PublishedDate).FirstOrDefault().Value;
                                var newSourcePoint     = new SourcePoint()
                                {
                                    Name         = sourcePoint.Name,
                                    RangeId      = sourcePoint.RangeId,
                                    Position     = sourcePoint.Position,
                                    Value        = sourcePoint.Value,
                                    Created      = DateTime.Now.ToUniversalTime().ToPSTDateTime(),
                                    Creator      = _userProfileService.GetCurrentUser().Username,
                                    Status       = SourcePointStatus.Created,
                                    NamePosition = sourcePoint.NamePosition,
                                    NameRangeId  = sourcePoint.NameRangeId,
                                    SourceType   = sourcePoint.SourceType
                                };

                                _dbContext.PublishedHistories.Add(new PublishedHistory()
                                {
                                    Name          = sourcePoint.Name,
                                    Position      = sourcePoint.Position,
                                    Value         = "Cloned",
                                    PublishedUser = _userProfileService.GetCurrentUser().Username,
                                    PublishedDate = DateTime.Now.ToUniversalTime().ToPSTDateTime(),
                                    SourcePointId = newSourcePoint.Id
                                });

                                _dbContext.PublishedHistories.Add(new PublishedHistory()
                                {
                                    Name          = sourcePoint.Name,
                                    Position      = sourcePoint.Position,
                                    Value         = lastPublishedValue,
                                    PublishedUser = _userProfileService.GetCurrentUser().Username,
                                    PublishedDate = DateTime.Now.AddSeconds(1).ToUniversalTime().ToPSTDateTime(),
                                    SourcePointId = newSourcePoint.Id
                                });

                                newSourceCatalog.SourcePoints.Add(newSourcePoint);

                                clonedSourcePoints.Add(sourcePoint.Id, newSourcePoint);
                            }

                            #endregion
                        }
                    }
                }

                foreach (var item in filesWillClone)
                {
                    if (item.IsWord)
                    {
                        var catalog = await _dbContext.DestinationCatalogs.Where(o => o.DocumentId.Equals(item.DocumentId, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefaultAsync();

                        if (catalog != null)
                        {
                            var destinationPoints = await _dbContext.DestinationPoints.Where(o => o.CatalogId == catalog.Id)
                                                    .Include(o => o.CustomFormats)
                                                    .Include(o => o.ReferencedSourcePoint)
                                                    .Include(o => o.ReferencedSourcePoint.Catalog).ToArrayAsync();

                            var sourcePointDocumentIds = destinationPoints.Select(o => o.ReferencedSourcePoint.Catalog.DocumentId);
                            var clonedExcelDocumentIds = files.Where(o => o.Clone && o.IsExcel).Select(o => o.DocumentId);
                            if (sourcePointDocumentIds.Any(o => clonedExcelDocumentIds.Any(p => p.Equals(o, StringComparison.CurrentCultureIgnoreCase))))
                            {
                                #region Add new destination catalog

                                DestinationCatalog newDestinationCatalog = new DestinationCatalog()
                                {
                                    Name = item.DestinationFileUrl, DocumentId = item.DestinationFileDocumentId, IsDeleted = false
                                };
                                _dbContext.DestinationCatalogs.Add(newDestinationCatalog);

                                #endregion

                                #region Add new destination point

                                foreach (var destinationPoint in destinationPoints)
                                {
                                    var referencedSourcePoint = clonedSourcePoints.FirstOrDefault(o => o.Key == destinationPoint.ReferencedSourcePoint.Id).Value;
                                    if (referencedSourcePoint != null)
                                    {
                                        DestinationPoint newDestinationPoint = new DestinationPoint()
                                        {
                                            RangeId         = destinationPoint.RangeId,
                                            Created         = DateTime.Now.ToUniversalTime().ToPSTDateTime(),
                                            Creator         = _userProfileService.GetCurrentUser().Username,
                                            DecimalPlace    = destinationPoint.DecimalPlace,
                                            DestinationType = destinationPoint.DestinationType
                                        };

                                        var newCustomFormatIds = destinationPoint.CustomFormats.Select(o => o.Id);
                                        var newCustomFormats   = _dbContext.CustomFormats.Where(o => newCustomFormatIds.Contains(o.Id));
                                        foreach (var format in newCustomFormats)
                                        {
                                            newDestinationPoint.CustomFormats.Add(format);
                                        }

                                        newDestinationCatalog.DestinationPoints.Add(newDestinationPoint);

                                        newDestinationPoint.ReferencedSourcePoint = referencedSourcePoint;
                                        _dbContext.DestinationPoints.Add(newDestinationPoint);
                                    }
                                }

                                #endregion
                            }
                        }
                    }
                }

                await _dbContext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                var entity = new LogEntity()
                {
                    LogId      = "50001",
                    Action     = Constant.ACTIONTYPE_CLONE,
                    ActionType = ActionTypeEnum.ErrorLog,
                    PointType  = Constant.POINTTYPE_CLONE,
                    Message    = ".Net Error",
                };
                entity.Subject = $"{entity.LogId} - {entity.Action} - {entity.PointType} - Error";
                await _logService.WriteLog(entity);

                throw new ApplicationException("Clone folder failed", ex);
            }
        }
        private static ICollection <DestinationPoint> OrderStopsInternal(ICollection <DestinationPoint> stops,
                                                                         ICollection <DestinationPoint> orderedStops, DestinationPoint currentStop)
        {
            if (orderedStops.Count == stops.Count)
            {
                return(orderedStops);
            }

            orderedStops.Add(currentStop);

            var nextStop = stops.SingleOrDefault(x => x.PreviousPoint == currentStop);

            return(OrderStopsInternal(stops, orderedStops, nextStop));
        }
示例#9
0
        /// <summary>
        /// Update the custom format of destination point.
        /// </summary>
        /// <param name="destinationPoint"></param>
        /// <returns></returns>
        public async Task <DestinationPoint> UpdateDestinationPointCustomFormatAsync(DestinationPoint destinationPoint)
        {
            try
            {
                var previousDestinationPoint = await _dbContext.DestinationPoints
                                               .Include(o => o.ReferencedSourcePoint)
                                               .Include(o => o.ReferencedSourcePoint.Catalog)
                                               .Include(o => o.ReferencedSourcePoint.PublishedHistories)
                                               .Include(o => o.CustomFormats).FirstAsync(o => o.Id == destinationPoint.Id);

                if (previousDestinationPoint != null)
                {
                    previousDestinationPoint.DecimalPlace = destinationPoint.DecimalPlace;
                    var newFormatIds = destinationPoint.CustomFormats != null?destinationPoint.CustomFormats.Select(c => c.Id).ToArray() : new int[]
                    {
                    };
                    var newFormats      = _dbContext.CustomFormats.Where(o => newFormatIds.Contains(o.Id));
                    var deletingFormats = previousDestinationPoint.CustomFormats.Except(newFormats, new Comparer <CustomFormat>((x, y) => x.Id == y.Id)).ToList();
                    var addingFormats   = newFormats.AsEnumerable().Except(previousDestinationPoint.CustomFormats, new Comparer <CustomFormat>((x, y) => x.Id == y.Id));

                    foreach (var item in deletingFormats)
                    {
                        previousDestinationPoint.CustomFormats.Remove(item);
                    }

                    foreach (var item in addingFormats)
                    {
                        if (_dbContext.Entry(item).State == EntityState.Detached)
                        {
                            _dbContext.CustomFormats.Attach(item);
                        }
                        previousDestinationPoint.CustomFormats.Add(item);
                    }

                    await _dbContext.SaveChangesAsync();

                    await _dbContext.Entry(previousDestinationPoint.ReferencedSourcePoint).ReloadAsync();

                    foreach (var customFormatItem in previousDestinationPoint.CustomFormats)
                    {
                        await _dbContext.Entry(customFormatItem).ReloadAsync();
                    }

                    previousDestinationPoint.ReferencedSourcePoint.PublishedHistories            = previousDestinationPoint.ReferencedSourcePoint.PublishedHistories.OrderByDescending(p => p.PublishedDate).ToArray();
                    previousDestinationPoint.ReferencedSourcePoint.SerializeCatalog              = true;
                    previousDestinationPoint.ReferencedSourcePoint.Catalog.SerializeSourcePoints = false;
                    previousDestinationPoint.CustomFormats = previousDestinationPoint.CustomFormats.OrderBy(c => c.GroupOrderBy).ToArray();

                    await _logService.WriteLogAsync(new LogEntity()
                    {
                        LogId      = "30002",
                        Action     = Constant.ACTIONTYPE_EDIT,
                        PointType  = Constant.POINTTYPE_DESTINATIONPOINT,
                        ActionType = ActionTypeEnum.AuditLog,
                        Message    = $"Edit destination point."
                    });
                }

                return(previousDestinationPoint);
            }
            catch (ApplicationException ex)
            {
                throw ex.InnerException;
            }
            catch (Exception ex)
            {
                var logEntity = new LogEntity()
                {
                    LogId      = "20003",
                    Action     = Constant.ACTIONTYPE_ADD,
                    ActionType = ActionTypeEnum.ErrorLog,
                    PointType  = Constant.POINTTYPE_DESTINATIONPOINT,
                    Message    = ".Net Error",
                    Detail     = ex.ToString()
                };
                logEntity.Subject = $"{logEntity.LogId} - {logEntity.Action} - {logEntity.PointType} - Error";
                await _logService.WriteLogAsync(logEntity);

                throw ex;
            }
        }
示例#10
0
    public void StartGame()
    {
        OnGameReset?.Invoke();
        _character.SetStartPosition(StartPoint);

        IList <ICell> FinalPath = Map.Instance.FindPathOnMap(StartPoint, DestinationPoint);

        if (FinalPath != null)
        {
            UIManager.Instance.WriteResultInfo(FinalPath.Count + " Distance cells\n" + StartPoint.GetPosition() + " Start position\n" + DestinationPoint.GetPosition() + " Destination position");

            _character.GotToTarget(FinalPath);

            foreach (var item in FinalPath)
            {
                if (item != DestinationPoint)
                {
                    item.SetPartOfPath();
                }
            }
        }
    }
示例#11
0
 private void UpdateDestinationPointForNoChoiceExit()
 {
     StartCoroutine(LiberaPosto(DestinationPoint));
     DestinationPoint = Destination.GetComponent <GridSystem>().GetRandomPoint();
     DestinationPoint.GetComponent <DestinationPoint>().Occupa();
 }
示例#12
0
 public DestinationPoint CreateDestinationPoint(Address address, DestinationPoint previousPoint = null)
 => new DestinationPoint(PointStatus.OnTheWay, address, previousPoint);