Exemple #1
0
    /// <summary>
    /// 'V' 버튼을 눌렀을때 발생
    /// </summary>
    public void OnOk()
    {
        Dialog dialog = GameResources.Dialog;

        switch (status)
        {
        case PlaceStatus.Default:
            if (Check())
            {
                dialog.ShowUnitPlacerCheck();
                status = PlaceStatus.Check;
            }
            break;

        case PlaceStatus.Check:
            dialog.Hide();
            status = PlaceStatus.Default;
            Place();
            break;

        case PlaceStatus.Fail:
            dialog.Hide();
            status = PlaceStatus.Default;
            break;
        }
    }
        public static MatrixConvertionResult ToPlaceStatuses(this string[,] sourceMatrix)
        {
            var rowCount    = sourceMatrix.GetLength(0);
            var columnCount = sourceMatrix.GetLength(1);
            var destMatrix  = new PlaceStatus[rowCount, columnCount];
            var result      = new MatrixConvertionResult();

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    var parsingResult = Enum.TryParse(sourceMatrix[i, j], out destMatrix[i, j]);
                    if (!parsingResult)
                    {
                        if (sourceMatrix[i, j] == "null")
                        {
                            destMatrix[i, j] = PlaceStatus.Null;
                        }
                        else
                        {
                            ConsoleLogger.WriteError($"Can't be parsed element of map {sourceMatrix[i,j]}");
                            return(new MatrixConvertionResult()
                            {
                                Matrix = destMatrix
                            });
                        }
                    }
                }
            }

            return(new MatrixConvertionResult()
            {
                Matrix = destMatrix, IsSucceed = true
            });
        }
Exemple #3
0
        /// <summary>
        /// Creates a new place iBeacon with or without a child
        /// </summary>
        /// <param name="status">Desired place status</param>
        /// <param name="isAssignIbeacon">Whether iBeacon device should be assigned to the new place(s) (optional)</param>
        /// <param name="isAddChild">Whether child place should be added or not (optional)</param>
        /// <returns>(<see cref="Place"/>) New parent place object</returns>
        public static Place CreateNewPlaceIbeacon(
            PlaceStatus status,
            bool isAssignIbeacon = false,
            bool isAddChild      = false)
        {
            var bodyObject = new Place
            {
                DeviceTypeId = (int)PlaceType.Ibeacon,
                Id           = null,
                PlaceModules = new List <PlaceModule>
                {
                    new PlaceModule
                    {
                        ModuleId      = (int)PlaceType.Ibeacon,
                        Configuration = JsonConvert.SerializeObject(
                            new Configuration
                        {
                            apps = new List <string>()
                        })
                    }
                },
                ChildPlaces = new List <ChildPlace>(),
                DirectItems = new List <DirectItem>(),
                Title       = $"Auto test {ActionManager.RandomNumber}",
                Schedule    = new Schedule
                {
                    ScheduleApps = new List <ScheduleApp>()
                },
                TimeZoneId = 8,
                Radius     = 5,
                Status     = (int)status
            };

            if (isAssignIbeacon)
            {
                var ibeacon = GetIbeacon() ?? CreateIbeacon();
                bodyObject.Device = ibeacon;
            }

            var response    = RestController.HttpRequestJson(string.Format(UriCxm.PlacesById, "null"), Method.POST, bodyObject);
            var parentPlace = JsonConvert.DeserializeObject <Place>(response.Content);

            if (isAddChild)
            {
                var childPlace = bodyObject;
                childPlace.Title    = $"Auto test {ActionManager.RandomNumber}";
                childPlace.ParentId = parentPlace.Id;
                RestController.HttpRequestJson(string.Format(UriCxm.PlacesById, childPlace.Id), Method.POST, childPlace);
            }

            if (status == PlaceStatus.Deleted)
            {
                RestController.HttpRequestJson(string.Format(UriCxm.PlacesById, parentPlace.Id), Method.DELETE);
            }

            parentPlace = GetById(parentPlace.Id);

            return(parentPlace);
        }
Exemple #4
0
 public PlaceEventArgs(Guid accountId, Guid tranId, PlaceStatus status, TransactionError error, string errorDetail)
 {
     this.AccountId     = accountId;
     this.TransactionId = tranId;
     this.Status        = status;
     this.Error         = error;
     this.ErrorDetail   = string.Format("ErrorCode = {0}, detail = {1}", error, errorDetail);
 }
Exemple #5
0
        /// <summary>
        /// Update the object.
        /// </summary>
        private void Update()
        {
            PlaceStatus placeStatus    = player.GetPlaceStatus();
            Color       crosshairColor = Color.black;

            switch (placeStatus)
            {
            case PlaceStatus.Able: crosshairColor = Color.green; break;

            case PlaceStatus.Out: crosshairColor = Color.red; break;

            case PlaceStatus.Range: crosshairColor = Color.black; break;

            case PlaceStatus.Rotate: crosshairColor = Color.yellow; break;
            }

            crosshair.color = crosshairColor;
        }
Exemple #6
0
    /// <summary>
    /// 'X' 버튼을 눌렀을때 발생
    /// </summary>
    public void OnCancel()
    {
        Dialog dialog = GameResources.Dialog;

        switch (status)
        {
        case PlaceStatus.Default:
            break;

        case PlaceStatus.Check:
            dialog.Hide();
            status = PlaceStatus.Default;
            break;

        case PlaceStatus.Fail:
            dialog.Hide();
            break;
        }
    }
        private bool CheckPlace(NativeActivityContext context)
        {
            // если нужно перевычитать место
            if (ReloadPlace.Get(context))
            {
                var manager = IoC.Instance.Resolve <IBaseManager <Place> >();

                var placeCode = PlaceObject.Get(context).GetKey();
                var tmp       = manager.Get(placeCode);
                if (tmp == null)
                {
                    ErrorMessage.Set(context, string.Format("{0}Место с кодом {1} не существует", Environment.NewLine, placeCode));
                    return(false);
                }
                PlaceObject.Set(context, tmp);
            }

            var te    = TEObject.Get(context);
            var place = PlaceObject.Get(context);
            // проверим статус места
            var placeStatus = place.StatusCode_R;

            if (!placeStatus.Equals(PlaceStatus.Get(context)))
            {
                ErrorMessage.Set(context, "Не верный статус места: " + placeStatus);
                return(false);
            }

            var placeCapacity = Convert.ToInt32(place.PlaceCapacity);

            if (placeCapacity < Convert.ToInt32(PlaceCapacity.Get(context)))
            {
                ErrorMessage.Set(context, "Остаточная вместимость места < " + placeCapacity);
                return(false);
            }

            // если нужно проверить, что тип ТЕ привязан к классу места
            if (CheckTEType2PlaceClass.Get(context))
            {
                var filter = string.Format("(tetypecode_r='{0}' and placeclasscode_r='{1}')", te.TETypeCode, place.PlaceClassCode);
                var mgr    = IoC.Instance.Resolve <IBaseManager <TEType2PlaceClass> >();
                var teTypeToPlaceClassCheck = mgr.GetFiltered(filter);
                if (!teTypeToPlaceClassCheck.Any())
                {
                    ErrorMessage.Set(context, string.Format("Тип ТЕ ({0}) данного ТЕ не привязан к классу ({1}) выбранного места", te.TETypeCode, place.PlaceClassCode));
                    return(false);
                }
            }

            // если нужно проверить, что вес ТЕ соответстует разрешенному весу места
            if (CheckTEWeightWithPlaceWeight.Get(context))
            {
                if (te.TEWeight > place.PlaceWeight)
                {
                    ErrorMessage.Set(context, string.Format("Вес ТЕ ({0}) больше допустимой нагрузки на место ({1})", te.TEWeight, place.PlaceWeight));
                    return(false);
                }
            }

            // если нужно проверить, что совокупный вес тех ТЕ, которые уже стоят на местах одной группы мест с нашим местом назначения
            // (а так же перемещаются туда по другим ЗНТ), и вес перемещаемой ТЕ не превышают максимальный вес на группу мест
            if (CheckAllTEWeightWithPlaceGroupWeight.Get(context))
            {
                var placeGroupCode = place.PlaceGroupCode;
                var filter         = string.Format("tecode in (select te.tecode from wmste te inner join wmsplace pl on te.tecurrentplace = pl.placecode inner join wmstransporttask tt on tt.ttaskstartplace = pl.placecode or tt.ttaskcurrentplace = pl.placecode or tt.ttasknextplace = pl.placecode or tt.ttaskfinishplace = pl.placecode where pl.placegroupcode = '{0}')", placeGroupCode);
                var mgr            = IoC.Instance.Resolve <IBaseManager <TE> >();
                var teList         = mgr.GetFiltered(filter);
                var sum            = teList.Sum(o => o.TEWeight);
                if ((sum + te.TEWeight) > place.PlaceWeightGroup)
                {
                    ErrorMessage.Set(context, string.Format("Превышение максимального веса на группу ({2}). Вес уже размещенных ТЕ={0}, текущей ТЕ={1}", sum, te.TEWeight, place.PlaceWeightGroup));
                    return(false);
                }
            }

            // если нужно проверить, что ТЕ можно поместить на место по габаритам
            if (CheckTESizeWithPlaceSize.Get(context))
            {
                // по высоте
                if (te.TEHeight > place.PlaceHeight)
                {
                    ErrorMessage.Set(context, string.Format("Высота ТЕ ({0}) превышает высоту места ({1})", te.TEHeight, place.PlaceHeight));
                    return(false);
                }

                var max1 = te.TEWidth > te.TELength ? te.TEWidth : te.TELength;
                var min1 = te.TEWidth < te.TELength ? te.TEWidth : te.TELength;
                var max2 = place.PlaceWidth > place.PlaceLength ? place.PlaceWidth : place.PlaceLength;
                var min2 = place.PlaceWidth < place.PlaceLength ? place.PlaceWidth : place.PlaceLength;
                if (max1 > max2 || min1 > min2)
                {
                    ErrorMessage.Set(context, string.Format("Размеры ТЕ ({0}x{1}) превышают размеры места ({2}x{3}) по ширине или длине", min1, max1, min2, max2));
                    return(false);
                }
            }

            return(true);
        }
Exemple #8
0
        /// <summary>
        /// Returns place object if place with specified parameters exists
        /// </summary>
        /// <param name="type">Place device type</param>
        /// <param name="status">Place status</param>
        /// <param name="hasDeviceAssigned">Should place have iBeacon assigned or not (optional)</param>
        /// <param name="hasChildren">Is place has children (optional)</param>
        /// <param name="hasParent">Is place has parent (optional)</param>
        /// <returns>(<see cref="Place"/>) Place object or null if not found</returns>
        public static Place GetPlace(
            PlaceType type,
            PlaceStatus status,
            bool hasDeviceAssigned,
            bool?hasChildren = false,
            bool?hasParent   = null)
        {
            var response = RestController.HttpRequestJson(UriCxm.Places, Method.GET);
            var places   = JsonConvert.DeserializeObject <Place[]>(response.Content);

            if (status != (int)PlaceStatus.Deleted)
            {
                places = places
                         .AsParallel()
                         .Where(x => x.Status != (int)PlaceStatus.Deleted)
                         .ToArray();
            }

            if (type != PlaceType.Any && places.Length > 0)
            {
                places = places
                         .AsParallel()
                         .Where(x => x.DeviceTypeId == (type != 0 ? (int?)type : null))
                         .ToArray();
            }

            if (status != PlaceStatus.Any && places.Length > 0)
            {
                places = places
                         .AsParallel()
                         .Where(x => x.Status == (int)status)
                         .ToArray();
            }

            if (hasDeviceAssigned && places.Length > 0)
            {
                places = places
                         .AsParallel()
                         .Where(x => x.Device != null)
                         .ToArray();
            }

            if (hasChildren != null && places.Length > 0)
            {
                if ((bool)hasChildren)
                {
                    places =
                        (from t1 in places.AsParallel()
                         join t2 in places.AsParallel()
                         on t1.ParentId equals t2.Id
                         select t1)
                        .ToArray();
                }
            }

            if (hasParent != null && places.Length > 0)
            {
                if ((bool)hasParent)
                {
                    places = places
                             .AsParallel()
                             .Where(x => x.ParentId != null)
                             .ToArray();
                }
                else
                {
                    places = places
                             .AsParallel()
                             .Where(x => x.ParentId == null)
                             .ToArray();
                }
            }

            var result = places?.AsParallel().AsOrdered().OrderBy(x => x.Id).LastOrDefault();

            if (result != null)
            {
                result = GetById(result.Id);
            }

            return(result);
        }
Exemple #9
0
 public PlaceEventArgs(Guid accountId, Guid tranId, PlaceStatus status)
     : this(accountId, tranId, status, TransactionError.OK, string.Empty)
 {
 }