Exemplo n.º 1
0
        public HttpResponseMessage Get(EnvironmentEnum environment, PlatformEnum platform, string application = "ALL")
        {
            log.DebugFormat("GetAllForPlatform: {0}", platform.ToString());

            HttpResponseMessage response;

            try
            {
                var validationResult = VerifyProperties(platform, environment);

                if (validationResult.Errors.Count > 0)
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, validationResult);
                    return(response);
                }

                var features = _jsonTogglerService.GetAllFeatureTogglesForPlatformAndApplication(platform, application);

                var ftResults = new List <FeatureToggleResult>();
                foreach (var feature in features)
                {
                    var ftResult = new FeatureToggleResult();
                    ftResult.Name         = feature.Name;
                    ftResult.IsEnabled    = feature.Platform.Has <PlatformEnum>(platform) && feature.Environment.Has <EnvironmentEnum>(environment);
                    ftResult.FilterValues = feature.FilterValues;
                    ftResult.CommandType  = feature.CommandType.HasValue ? (int)feature.CommandType.Value : 0;
                    ftResult.Command      = feature.Command;

                    if (feature.SubFeatureToggles != null && feature.SubFeatureToggles.Count > 0)
                    {
                        var subFeatures = new List <SubFeatureToggleResult>();
                        foreach (var subFeature in feature.SubFeatureToggles)
                        {
                            var subft = new SubFeatureToggleResult();

                            subft.Name         = subFeature.Name;
                            subft.IsEnabled    = subFeature.Platform.Has <PlatformEnum>(platform) && subFeature.Environment.Has <EnvironmentEnum>(environment);
                            subft.FilterValues = subFeature.FilterValues;
                            subft.CommandType  = subFeature.CommandType.HasValue ? (int)subFeature.CommandType.Value : 0;
                            subft.Command      = subFeature.Command;

                            subFeatures.Add(subft);
                        }

                        ftResult.SubFeatures = subFeatures;
                    }

                    ftResults.Add(ftResult);
                }

                response = Request.CreateResponse(HttpStatusCode.OK, ftResults);
            }
            catch (Exception ex)
            {
                log.Error("Error occurred", ex);
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(response);
        }
        public HttpResponseMessage Get(EnvironmentEnum environment, PlatformEnum platform, string application = "ALL")
        {
            log.DebugFormat("GetAllForPlatform: {0}", platform.ToString());

            HttpResponseMessage response;

            try
            {
                var validationResult = VerifyProperties(platform, environment);

                if (validationResult.Errors.Count > 0)
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, validationResult);
                    return(response);
                }

                var features = _jsonTogglerService.GetAllFeatureTogglesForPlatformAndApplication(platform, application);

                response = Request.CreateResponse(HttpStatusCode.OK, features);
            }
            catch (Exception ex)
            {
                log.Error("Error occurred", ex);
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(response);
        }
Exemplo n.º 3
0
    private void Start()
    {
        Client = new UdpClient(Port);

        ReceiveThread = new Thread(
            new ThreadStart(ReceiveData));
        ReceiveThread.IsBackground = true;
        ReceiveThread.Start();

        PlatformStr = Platform.ToString();
        LocationStr = MessageTypeEnum.Location.ToString();
        RotationStr = MessageTypeEnum.Rotation.ToString();

        SenderIP  = new IPEndPoint(IPAddress.Broadcast, Port);
        ReciverIP = new IPEndPoint(IPAddress.Any, 0);
        Platform  = PlatformEnum.PC;
    }
        /// <summary>
        /// Get Platform Relative Root Path
        /// </summary>
        public static string GetPlatformRelativeRootPath() {
            PlatformEnum currentPlatform = PlatformEnum.Unknown;
#if UNITY_ANDROID
            currentPlatform = PlatformEnum.Android;
#elif UNITY_IOS
            currentPlatform = PlatformEnum.IOS;
#elif UNITY_STANDALONE_WIN
            currentPlatform = PlatformEnum.Windows;
#elif UNITY_STANDALONE_LINUX
            currentPlatform = PlatformEnum.Linux;
#elif UNITY_STANDALONE_OSX
            currentPlatform = PlatformEnum.Mac;
#else
            currentPlatform = PlatformEnum.Unknown;
#endif
            return DirectoryConst.CACHE_ROOT + currentPlatform.ToString() + CharConst.STR_SLASH;
        }
Exemplo n.º 5
0
 public override string ToString()
 {
     return
         // Required elements
         ("Location: " + _location.ToString() + Environment.NewLine
          + "Datetimestamp: " + Helpers.DateTimeStampString(_dateTimeStamp) + Environment.NewLine
          + "Platform: " + _platform.ToString() + Environment.NewLine
          + "Provider: " + _provider + Environment.NewLine
          + "IsMockProvider: " + _isFromMockProvider.ToString() + Environment.NewLine
          // Potentially null / missing elements
          + (_altitude.HasValue ? "Altitude: " + Helpers.ConvertToFeetString(_altitude) + " ft" + Environment.NewLine : "")
          + (_buildingFloor.HasValue ? "BuildingFloor: " + _buildingFloor.ToString() + Environment.NewLine : "")
          + (_speed.HasValue ? "Speed: " + Helpers.ConvertToMilesPerHourString(_speed) + " mph" + Environment.NewLine : "")
          + (_bearing.HasValue ? "Bearing: " + Math.Round(_bearing.Value, 1).ToString() + " degrees East of North" + Environment.NewLine : "")
          + (_horizontalAccuracy.HasValue ? "HorizontalAccuracy: " + Helpers.ConvertToFeetString(_horizontalAccuracy) + " ft" + Environment.NewLine : "")
          + (_verticalAccuracy.HasValue ? "VerticalAccuracy: " + Helpers.ConvertToFeetString(_verticalAccuracy) + " ft" + Environment.NewLine : ""));
 }
        /// <summary>
        /// 创建客户数据
        /// </summary>
        /// <param name="name"></param>
        /// <param name="email"></param>
        /// <param name="amount"></param>
        /// <param name="buyOn"></param>
        /// <param name="platform"></param>
        /// <returns></returns>
        public static int CreateBuyer(string name, string email, double amount, DateTime buyOn, PlatformEnum platform, ISession NSession)
        {

            IList<OrderBuyerType> list = NSession.CreateQuery(" from OrderBuyerType where BuyerName=:p and Platform=:p2").SetString("p", name).SetString("p2", platform.ToString()).List<OrderBuyerType>();
            OrderBuyerType buyer = new OrderBuyerType();
            if (list.Count > 0)
            {
                buyer = list[0];
                buyer.BuyCount += 1;
                buyer.BuyAmount += amount;
                buyer.ListBuyOn = buyOn;
            }
            else
            {
                buyer = new OrderBuyerType();
                buyer.BuyerName = name;
                buyer.BuyerEmail = email;
                buyer.FristBuyOn = buyOn;
                buyer.BuyCount = 1;
                buyer.BuyAmount = amount;
                buyer.ListBuyOn = buyOn;
                buyer.Platform = platform.ToString();
            }
            NSession.SaveOrUpdate(buyer);
            NSession.Flush();
            return buyer.Id;
        }