Beispiel #1
0
        public override void Load()
        {
            StreamReader gfile    = new StreamReader(System.IO.Path.Combine(Application.persistentDataPath, "myCash"));
            string       loadJson = gfile.ReadToEnd();

            gfile.Close();

            load = new MainPoint();
            load = JsonUtility.FromJson <MainPoint>(loadJson);
        }
Beispiel #2
0
        public override void Save(params int[] value)
        {
            MainPoint mp = new MainPoint();

            mp.cash = value[0];
            string saveString = JsonUtility.ToJson(mp);

            StreamWriter file = new StreamWriter(System.IO.Path.Combine(Application.persistentDataPath, "myCash"));

            file.Write(saveString);
            file.Close();
        }
        private MainPoint CreateEntityMainPoint(Guid id, SysType systemType, EusMainPoint asp, bool isTest, DateTime now, string userName, Guid EntityId, MainPointType MainPointType)
        {
            var sp = new MainPoint
            {
                MainPointGuid       = Guid.NewGuid(),
                Sys                 = systemType,
                IsTest              = isTest,
                AgentCode           = asp.AgentCode,
                CityCode            = asp.CityCode,
                Address             = asp.Address ?? string.Empty,
                SalingType          = asp.SaleType == (byte)EntitySales.SaleTypes.Own,
                IsBlock             = false,
                Qaa                 = false,
                InterfaceOfArs      = 0,
                EthereumIsConnected = false,
                IsCharter           = false,
                CreatedDate         = now,
                ModifiedDate        = now,
                EusMainPointGuid    = asp.Id,
                CreatedBy           = userName,
                ModifiedBy          = userName,
                MainPointType       = MainPointType
            };

            sp.EntityExpirations.Add(new EntityExpiration
            {
                EntityExpirationGuid = id,
                ValidFrom            = now.Date,
                ValidTo      = new DateTime(2050, 1, 1),
                EntityGuid   = EntityId,
                ModifiedDate = now,
                IsActive     = true
            });

            return(sp);
        }
        private void UpdateEntityMainPointEntity(EntityEntity EntityEntity, MainPoint EntityMainPointEntity, IPrincipal principal, DateTime now)
        {
            switch (EntityEntity.Sys)
            {
            case EntitySysType.EusET:
            case EntitySysType.ElioET:
            case EntitySysType.SabreET:
            {
                var LtSystem      = EntityMainPointEntity.Sys.ToLtSystem();
                var PlacesInDb    = EntityMainPointEntity.Lts.Where(x => x.LtSystem == LtSystem).ToDictionary(x => x.LtGuid);
                var PlacesInModel = EntityEntity.EntityPlaces ?? Array.Empty <EntityPlace>();

                if (PlacesInDb.Any() && !PlacesInModel.Any())
                {
                    throw new InvalidOperationException($"Нельзя удалить все офисы на валидаторе ({EntityEntity.Id})");
                }

                if (PlacesInModel.Any())
                {
                    EntityMainPointEntity.AuthorizationDate = PlacesInModel.Min(x => x.AuthorizationDate);
                }

                foreach (var Place in PlacesInModel)
                {
                    if (PlacesInDb.TryGetValue(Place.Id, out var existed))
                    {
                        UpdateFromPlace(existed, Place);

                        PlacesInDb.Remove(Place.Id);
                    }
                    else
                    {
                        var newLt = CreateLt(Place.Id,
                                             EntityEntity.EntitySales.Agent.Code,
                                             EntityMainPointEntity.MainPointGuid,
                                             LtSystem,
                                             principal.Identity.Name,
                                             now);

                        UpdateFromPlace(newLt, Place);

                        EntityMainPointEntity.Lts.Add(newLt);
                    }
                }
                if (PlacesInDb.Any())
                {
                    _context.Lt.RemoveRange(PlacesInDb.Values);
                }


                break;
            }

            case EntitySysType.Rn:
            {
                var Rn = EntityMainPointEntity.Lts.Where(x => x.LtSystem == LtSystems.Rn && x.RnStatus && x.RnTaps.Any())
                         .GroupBy(x => new { x.AGN, x.GRP }).SingleOrDefault();

                if (EntityEntity.RnGroup == null && Rn == null)
                {
                    break;
                }

                if (EntityEntity.RnGroup == null && Rn != null)
                {
                    throw new NotFoundException($"Rn терминал у пункта продаж ({EntityEntity.Id}) не найден для обновления");
                }

                if (!principal.IsAdmin() && Rn != null)
                {
                    if (EntityEntity.RnGroup.Agn != Rn.Key.AGN ||
                        EntityEntity.RnGroup.Grp != Rn.Key.GRP)
                    {
                        throw new InvalidOperationException($"Нельзя изменить ТКП и ГРП на авторизованном валидаторе ({EntityEntity.Id})");
                    }
                }

                var tapsInDb    = Rn?.ToDictionary(x => x.LtGuid) ?? new Dictionary <Guid, Lt>();
                var tapsInModel = EntityEntity.RnTerminals ?? Array.Empty <RnTerminal>();

                if (tapsInDb.Any() && !tapsInModel.Any())
                {
                    throw new InvalidOperationException($"Нельзя удалить все ТАП на валидаторе ({EntityEntity.Id})");
                }

                if (tapsInModel.Any())
                {
                    EntityMainPointEntity.AuthorizationDate = tapsInModel.Min(x => x.AuthorizationDate);
                }

                foreach (var tap in tapsInModel)
                {
                    if (tapsInDb.TryGetValue(tap.Id, out var existed))
                    {
                        UpdateFromTap(existed, EntityEntity.RnGroup, tap);

                        tapsInDb.Remove(tap.Id);
                    }
                    else
                    {
                        var newLt = CreateLt(tap.Id,
                                             EntityEntity.EntitySales.Agent.Code,
                                             EntityMainPointEntity.MainPointGuid,
                                             LtSystems.Rn,
                                             principal.Identity.Name,
                                             now);


                        UpdateFromTap(newLt, EntityEntity.RnGroup, tap);

                        EntityMainPointEntity.Lts.Add(newLt);
                    }
                }
                if (tapsInDb.Any())
                {
                    foreach (var Lt in tapsInDb.Values)
                    {
                        Lt.ReleaseDate = now;
                        Lt.RnStatus    = false;
                    }
                }
                break;
            }

            case EntitySysType.Unknown when EntityMainPointEntity.AgentCode == "1488":
                break;

            default:
                throw new DomainException($"Reservation system for Entity ({EntityMainPointEntity.MainPointGuid}) is not recognized");
            }
#warning добавить изменение Location при аптейте связанной EusMainPoint в ETR.Test.Eus.BusinessLogic.MainPoint.UpdateMainPointHandler

            EntityMainPointEntity.Location     = (EntityPlaceLocationTypes)EntityEntity.Location;
            EntityMainPointEntity.IsOnline     = EntityEntity.Location == LocationTypes.Online;
            EntityMainPointEntity.Rto          = EntityEntity.Location == LocationTypes.Rto;
            EntityMainPointEntity.SiteAudience = (EntityPlaceSiteAudienceTypes)EntityEntity.SiteAudience;
            EntityMainPointEntity.Comment      = EntityEntity.Comment;

            //можно указывать только при создании
            //MainPoint.IsTest = cmd.IsTest;

            EntityMainPointEntity.ModifiedBy   = principal.Identity.Name;
            EntityMainPointEntity.ModifiedDate = now;
        }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     //audio = GetComponents<AudioSource>();
     instance = this;
 }