Exemplo n.º 1
0
            public void OnPlatformDefault(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.Create("\ud83d\ude80");
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(63, layout.label0.HeightRequest);
            }
        /// <summary>
        /// Sends push notifications with message and badge count to the user device specified with device token.
        /// </summary>
        /// <param name="nType">An integer containing specifying notification type.</param>
        /// <param name="dp">An integer containing specifying device platform.</param>
        /// <param name="dToken">A string containing the device token of the user device to whom message has to be delivered.</param>
        /// <param name="data">A dictionary having notification data.</param>
        public void SendNotification(short nType, short dp, string dToken, Dictionary <string, string> data)
        {
            NotificationType notificationType = (NotificationType)nType;
            DevicePlatform   devicePlatform   = (DevicePlatform)dp;

            if (Enum.IsDefined(typeof(NotificationType), nType) && Enum.IsDefined(typeof(DevicePlatform), dp) && !NeeoUtility.IsNullOrEmpty(dToken))
            {
                try
                {
                    NotificationManager notificationManager = new NotificationManager();
                    notificationManager.SendNotification(notificationType, devicePlatform, dToken, data);
                }
                catch (ApplicationException appExp)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "notificationType:" + notificationType + ", devicePlatform:" + devicePlatform + ", deviceToken:" + dToken + ", data:" + JsonConvert.SerializeObject(data) + ", error:" + appExp.Message);
                    NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)Convert.ToInt32(appExp.Message));
                }
                catch (Exception exp)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "notificationType:" + notificationType + ", devicePlatform:" + devicePlatform + ", deviceToken:" + dToken + ", data:" + JsonConvert.SerializeObject(data) + ", error:" + exp.Message, exp);
                    NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.ServerInternalError);
                }
            }
            else
            {
                NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments);
            }
        }
Exemplo n.º 3
0
 public HUDControlConfig(DevicePlatform platform,
                         DeviceType deviceType,
                         Enum bundleId,
                         string prefabName,
                         int appLayerId) : base(platform, deviceType, bundleId, prefabName, appLayerId)
 {
 }
Exemplo n.º 4
0
        /// <summary>
        /// Sends messages to the users who are not blocked.
        /// </summary>
        /// <remarks>It manipulates the user requests whether it is resending activation code request or not, block or unblock the user based on maximum allowed request in 24 hrs and then sends sms to the users who are not blocked.</remarks>
        /// <param name="phoneNumber">A string containing the user's phone number.</param>
        /// <param name="devicePlatform">An enum specifying the device platform.</param>
        /// <param name="activationCode">A string containing activation code to be sent.</param>
        /// <param name="isResend">A bool if true specifying that the request is for resending activation code; otherwise false.</param>
        /// <param name="isRegenerated">A bool if true specifying that the request is for sending regenerated activation code; otherwise false.</param>
        /// <returns>An integer if 0 = sms has not been sent, -1 = sms has been successfully sent or number of remaining minutes to unblock user = user is blocked based on blocking policy. </returns>
        public static int SendActivationCodeToUnBlockedUser(string phoneNumber, DevicePlatform devicePlatform, string activationCode, bool isResend, bool isRegenerated)
        {
            int smsSendingResult = (int)SmsSendingStatus.SendingFailed;

            if (devicePlatform == DevicePlatform.iOS || devicePlatform == DevicePlatform.Android)
            {
                if (isResend == true)
                {
                    SmsManager.SendSms(phoneNumber, activationCode, isRegenerated);
                    smsSendingResult = (int)SmsSendingStatus.Sent;
                    return(smsSendingResult);
                }
                else
                {
                    DbManager dbManager = new DbManager();
                    if (dbManager.StartTransaction())
                    {
                        try
                        {
                            int userBlockedState = dbManager.GetUserBlockedState(phoneNumber);
                            switch ((UserState)userBlockedState)
                            {
                            case UserState.NotBlocked:
                                SmsManager.SendSms(phoneNumber, activationCode, isRegenerated);
                                smsSendingResult = (int)SmsSendingStatus.Sent;
                                break;

                            default:
                                smsSendingResult = userBlockedState;
                                break;
                            }

                            dbManager.CommitTransaction();
                            return(smsSendingResult);
                        }
                        catch (ApplicationException appExp)
                        {
                            dbManager.RollbackTransaction();
                            throw;
                        }
                        catch (Exception exp)
                        {
                            dbManager.RollbackTransaction();
                            LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.Message, exp);
                            throw new ApplicationException(CustomHttpStatusCode.UnknownError.ToString("D"));
                        }
                    }
                    else
                    {
                        throw new ApplicationException(CustomHttpStatusCode.TransactionFailure.ToString("D"));
                        return(smsSendingResult);
                    }
                }
            }
            else
            {
                // handling for secondary devices.
                return(smsSendingResult);
            }
        }
Exemplo n.º 5
0
        /*
         * Private.
         */

        private void UpdateDeviceInfo()
        {
            CurrentDevicePlatform = GetCurrentDevicePlatform();
            CurrentDeviceType     = DeviceUtil.GetDeviceType(CurrentDevicePlatform);

            Log.Debug((p, t) => $"Platform: {p} DeviceType: {t}", CurrentDevicePlatform, CurrentDeviceType);
        }
Exemplo n.º 6
0
        public void SendNotification(string deviceToken, string notificationMsg, int platform, int bageCount)
        {
            DevicePlatform type = (DevicePlatform)platform;

            if (type == DevicePlatform.iOS)
            {
                try
                {
                    //var appleCertificate = File.ReadAllBytes("E:\\APNSDistCertificate.p12");
                    //_push.RegisterAppleService(new ApplePushChannelSettings(true,appleCertificate, "PowerfulP1234"));
                    _push.QueueNotification(new AppleNotification(deviceToken)
                                            .WithAlert(notificationMsg)
                                            .WithBadge(bageCount)
                                            .WithSound("default"));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else if (type == DevicePlatform.Android)
            {
                _push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(deviceToken)
                                        .WithJson("{\"alert\":\"" + notificationMsg + "\",\"badge\":" + bageCount + ",\"sound\":\"sound.caf\"}"));
            }
        }
Exemplo n.º 7
0
        private BuildTargetGroup GetBuildTargetGroup(DevicePlatform devicePlatform)
        {
            switch (devicePlatform)
            {
            case DevicePlatform.Windows:
            case DevicePlatform.Mac:
            case DevicePlatform.Linux:
                return(BuildTargetGroup.Standalone);

            case DevicePlatform.Android:
                return(BuildTargetGroup.Android);

            case DevicePlatform.iOS:
                return(BuildTargetGroup.iOS);

            case DevicePlatform.WebGL:
                return(BuildTargetGroup.WebGL);

            case DevicePlatform.WindowsUniversal:
                return(BuildTargetGroup.WSA);

            case DevicePlatform.XboxOne:
                return(BuildTargetGroup.XboxOne);

            default:
                Debug.LogErrorFormat("Found Unknown DevicePlatform \"{0}\" to update defines for.", devicePlatform);
                return(BuildTargetGroup.Unknown);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <param name="devicePlatform"></param>
        /// <param name="activationCode"></param>
        /// <returns></returns>
        public static int SendActivationCode(string phoneNumber, DevicePlatform devicePlatform, string activationCode)
        {
            int smsSendingResult = (int)SmsSendingStatus.SendingFailed;

            if (Enum.IsDefined(typeof(DevicePlatform), devicePlatform))
            {
                var dbManager = new DbManager();
                if (dbManager.StartTransaction())
                {
                    try
                    {
                        var userAttemptsDetails = dbManager.GetUserAttemptsCount(phoneNumber, activationCode);
                        switch ((UserState)userAttemptsDetails["blockedState"])
                        {
                        case UserState.NotBlocked:
                            if (userAttemptsDetails["attemptsCount"] % 2 == 0 && Convert.ToBoolean(ConfigurationManager.AppSettings[NeeoConstants.SecondarySMSApiEnabled]))
                            {
                                PowerfulPal.Sms.SmsManager.GetInstance().Twilio.SendSms(new[] { NeeoUtility.FormatAsIntlPhoneNumber(phoneNumber) }, NeeoUtility.GetActivationMessage(activationCode));
                                smsSendingResult = (int)SmsSendingStatus.Sent;
                            }
                            else
                            {
                                PowerfulPal.Sms.SmsManager.GetInstance().SendSms(new[] { NeeoUtility.FormatAsIntlPhoneNumber(phoneNumber) }, NeeoUtility.GetActivationMessage(activationCode));
                                smsSendingResult = (int)SmsSendingStatus.Sent;
                            }
                            break;

                        default:
                            smsSendingResult = userAttemptsDetails["blockedState"];
                            break;
                        }

                        dbManager.CommitTransaction();
                        return(smsSendingResult);
                    }
                    catch (ApplicationException appExp)
                    {
                        dbManager.RollbackTransaction();
                        throw;
                    }
                    catch (Exception exp)
                    {
                        dbManager.RollbackTransaction();
                        LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.Message, exp);
                        throw new ApplicationException(CustomHttpStatusCode.UnknownError.ToString("D"));
                    }
                }
                else
                {
                    throw new ApplicationException(CustomHttpStatusCode.TransactionFailure.ToString("D"));
                    return(smsSendingResult);
                }
            }
            else
            {
                // handling for secondary devices.
                return(smsSendingResult);
            }
        }
Exemplo n.º 9
0
        public static async Task <bool> AppNeedsUpdate(int currentVersion, DevicePlatform devicePlatform)
        {
            // var url = devicePlatform == DevicePlatform.Android ? GoogleAppId : AppleAppId;

            var content = await DataAccess.WebAPI.Get("https://docs.google.com/spreadsheets/d/e/2PACX-1vS4BqQ3tUSShsGYHjWLZcbsNwROaf1fV1cLTz4m4feBiTI-FfVj4_tBpUAY-qP0jYcQGj8HCzSnq_p1/pub?gid=0&single=true&output=csv" +
                                                      $"&localhash={Guid.NewGuid().ToString("N")}");

            if (string.IsNullOrWhiteSpace(content))
            {
                return(false);
            }
            var lines = content.Split("\r\n".ToCharArray());

            if (lines.Count() < 2)
            {
                return(false);
            }
            var lastLine = lines.Last();
            var versions = lastLine.Split(',');

            if (versions.Count() < 2)
            {
                return(false);
            }
            if (devicePlatform == DevicePlatform.Android && int.TryParse(versions[0].Replace(".", ""), out int droidVersion))
            {
                var result = droidVersion > currentVersion;
                return(result);
            }
            else if (devicePlatform == DevicePlatform.iOS && int.TryParse(versions[1].Replace(".", ""), out int iosVersion))
            {
                var result = iosVersion > currentVersion;
                return(result);
            }
            return(false);

            /*
             * string pattern;
             * if (devicePlatform == DevicePlatform.Android)
             * {
             *  pattern = "Current Version</div><span class=\"htlgb\"><div class=\"IQ1z0d\"><span class=\"htlgb\">(?<version>\\d*.{0,1}\\d*.{0,1}\\d*)</span>";
             * }
             * else
             * {
             *  pattern = "versionString\":\"(?<version>\\d.{0,1}\\d.{0,1}\\d)\",\"releaseDate\":";
             * }
             * var match = Regex.Match(content, pattern);
             * if (match.Success)
             * {
             *  var ver = match.Groups["version"]?.ToString().Replace(".", "");
             *  var result = int.TryParse(ver, out int digitVer) && digitVer > currentVersion;
             *  return result;
             * }
             *
             * return false;
             */
        }
Exemplo n.º 10
0
        /// <summary>
        /// 检查版本更新
        /// </summary>
        /// <param name="version">客户端版本</param>
        /// <param name="clientType">设备类型</param>
        /// <param name="customerSourceId">客户来源Id</param>
        /// <param name="appName">App编码</param>
        /// <returns></returns>
        public CheckerResDto CheckVersion(ApiVersion version, DevicePlatform clientType, byte customerSourceId,
                                          string appName)
        {
            long versionCode = GetDefaultVersionCode(version.FullVersion, clientType);
            //客户端版本
            string clientSourceKey = string.Format(RedisKeyConst.Installationpackage_ClientSourceKey,
                                                   GetDefaultVersionCode(version.FullVersion, clientType),
                                                   (int)clientType, customerSourceId, appName);

            var resDto = CacheHelper.GetCache <CheckerResDto>(clientSourceKey);

            if (resDto == null)
            {
                var sourceVersion = GetSourceVersion(clientType, customerSourceId, appName, versionCode);

                if (sourceVersion != null)
                {
                    resDto = new CheckerResDto()
                    {
                        Status  = sourceVersion.UpdateType,
                        Content = string.Empty,
                        Downurl = string.Empty
                    };

                    if ((sourceVersion.UpdateType == (int)ClientUpdateStatus.Optional ||
                         sourceVersion.UpdateType == (int)ClientUpdateStatus.Force) && sourceVersion.UpdateToVersionCode > 0)
                    {
                        var updateToSourceVersion = GetSourceVersion(clientType, customerSourceId, appName,
                                                                     sourceVersion.UpdateToVersionCode);
                        if (updateToSourceVersion != null)
                        {
                            resDto.Content = string.IsNullOrWhiteSpace(updateToSourceVersion.ClientVersionDesc)
                                ? ""
                                : updateToSourceVersion.ClientVersionDesc;
                            resDto.Downurl = string.IsNullOrWhiteSpace(updateToSourceVersion.UpdateLink)
                                ? ""
                                : updateToSourceVersion.UpdateLink;
                        }
                    }

                    //CacheHelper.WriteCache(clientSourceKey, resDto, 1440);
                    CacheHelper.AddCache(clientSourceKey, resDto, 1440);
                }
                else
                {
                    resDto = new CheckerResDto()
                    {
                        Status  = (int)ClientUpdateStatus.None,
                        Content = "",
                        Downurl = ""
                    };
                }
            }

            return(resDto);
        }
Exemplo n.º 11
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     // WPF doesn't show ToolbarItems for pages in modal stack
     // so we use NavigationBehavior.SetApplicationRoot and pop TestCases page from modal stack to make this test case visible with toolbar items
     if (DeviceInfo.Platform == DevicePlatform.Create("WPF"))
     {
         Navigation.PopModalAsync();
     }
 }
Exemplo n.º 12
0
        protected UIControlConfiguration(DevicePlatform platform, DeviceType deviceType, Enum bundleId, string prefabName, int appLayerId)
        {
            DevicePlatform = platform;
            DeviceType     = deviceType;

            this.bundleId   = bundleId;
            this.prefabName = prefabName;
            this.appLayerId = appLayerId;

            bindings = new List <UIControlBinding>();
        }
Exemplo n.º 13
0
        public Target(string id, string name, DevicePlatform platform)
        {
            this.Name = name;
            this.ID = id;
            this.Platform = platform;

            // We want the name to be friendly
            if (Name == String.Empty) {
                Name = ID.Replace ('_', ' ');
            }
        }
Exemplo n.º 14
0
 private long GetDefaultVersionCode(long fullVersion, DevicePlatform clientType)
 {
     if ((clientType == DevicePlatform.Android) && (fullVersion >= 540431955284459520))
     {
         return(108227128545247242);
     }
     if ((clientType == DevicePlatform.Ios) && (fullVersion >= 216876491030396828))
     {
         return(216876491030396828);
     }
     return(fullVersion);
 }
Exemplo n.º 15
0
                protected override IEnumerable <string>?GetPlatformFileType(DevicePlatform _)
                {
                    var platform = DeviceInfo2.Platform;

                    foreach (var fileType in fileTypes)
                    {
                        if (fileType.Key.HasFlag(platform))
                        {
                            return(fileType.Value);
                        }
                    }
                    return(null);
                }
Exemplo n.º 16
0
        public static MobileDeviceType ToMobileDeviceType(this DevicePlatform platform)
        {
            if (platform == DevicePlatform.Android)
            {
                return(MobileDeviceType.Android);
            }

            if (platform == DevicePlatform.iOS)
            {
                return(MobileDeviceType.IOS);
            }

            return(MobileDeviceType.Unknown);
        }
Exemplo n.º 17
0
        public void OnPlatformExtension(string markup, string platform, int expected)
        {
            mockDeviceInfo.Platform = DevicePlatform.Create(platform);

            var actual = (new MarkupExtensionParser()).ParseExpression(ref markup, new Internals.XamlServiceProvider(null, null)
            {
                IXamlTypeResolver   = typeResolver,
                IProvideValueTarget = new MockValueProvider("foo", new object())
                {
                    TargetProperty = GetType().GetProperty(nameof(FontSize))
                }
            });

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 18
0
 private static void UserQuarterlyStatistics(DevicePlatform devicePlatform, DateTime creationDate, CountryStatistics countryStats)
 {
     if (creationDate >= countryStats.RecentHistory.QuarterlyCounts.LowerBoundDate && creationDate <= countryStats.RecentHistory.QuarterlyCounts.UpperBoundDate)
     {
         if (devicePlatform == DevicePlatform.Android)
         {
             countryStats.Android.RecentHistory.QuarterlyCounts.TotalCount += 1;
             countryStats.RecentHistory.QuarterlyCounts.TotalCount         += 1;
         }
         else if (devicePlatform == DevicePlatform.iOS)
         {
             countryStats.Ios.RecentHistory.QuarterlyCounts.TotalCount += 1;
             countryStats.RecentHistory.QuarterlyCounts.TotalCount     += 1;
         }
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// 获取最新的升级版本信息
        /// </summary>
        /// <param name="clientType">客户端类型</param>
        /// <param name="customerSourceId">安装来源</param>
        /// <param name="appServerCode">app编码</param>
        /// <returns></returns>
        public ClientSourceVersion GetLastSourceVersion(DevicePlatform clientType, byte customerSourceId,
                                                        string appServerCode)
        {
            string sql = @"SELECT TOP 1 * FROM dbo.ClientSourceVersion 
WHERE [ClientSource]=@ClientSource AND [ClientType]=@ClientType AND [ServerCode]=@ServerCode
ORDER BY VersionCode DESC";

            var param = new[]
            {
                new SqlParameter("@ClientSource", customerSourceId),
                new SqlParameter("@ClientType", (int)clientType),
                new SqlParameter("@ServerCode", appServerCode),
            };

            return(Util.ReaderToModel <ClientSourceVersion>(sql, param));
        }
Exemplo n.º 20
0
        public Process InstallToDevice(
			DevicePlatform platform,
			Action<string> output,
			Action<string> errors,
			Action<int, Process> exited)
        {
            string device;
            switch (platform) {
                case DevicePlatform.iOS: device = "ios"; break;
                case DevicePlatform.Android: device = "android"; break;
                default: throw new ArgumentOutOfRangeException ("platform");
            }
            var p = StartProcess ("install " + device, output, errors, exited);
            p.StandardInput.Close();
            return p;
        }
Exemplo n.º 21
0
            public void OnPlatform2Syntax(bool useCompiledXaml)
            {
                mockDeviceInfo.Platform = DevicePlatform.Android;
                var layout = new OnPlatform(useCompiledXaml);

                Assert.AreEqual(42, layout.label0.HeightRequest);

                mockDeviceInfo.Platform = DevicePlatform.iOS;
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(21, layout.label0.HeightRequest);


                mockDeviceInfo.Platform = DevicePlatform.Create("FooBar");
                layout = new OnPlatform(useCompiledXaml);
                Assert.AreEqual(42, layout.label0.HeightRequest);
            }
        /// <summary>
        /// Save user device token
        /// </summary>
        public async Task RegisterUserAsync(string userId, string userToken, DevicePlatform platform)
        {
            var isDuplicate = _db.UserDeviceTokens.Any(ur => ur.UserId == userId &&
                                                       ur.Token == userToken);

            if (!isDuplicate)
            {
                _db.UserDeviceTokens.Add(new UserDeviceToken
                {
                    UserId   = userId,
                    Token    = userToken,
                    Platform = platform
                });

                await _db.SaveChangesAsync();
            }
        }
Exemplo n.º 23
0
            DevicePlatform SetUpPlatform(string platform)
            {
                var p = DevicePlatform.Create(platform);

                mockDeviceInfo.Platform = p;
                if (p == DevicePlatform.iOS)
                {
                    DependencyService.Register <INativeValueConverterService, MockIosPlatformValueConverterService>();
                    DependencyService.Register <INativeBindingService, MockIosPlatformBindingService>();
                }
                else if (p == DevicePlatform.Android)
                {
                    DependencyService.Register <INativeValueConverterService, MockAndroidPlatformValueConverterService>();
                    DependencyService.Register <INativeBindingService, MockAndroidPlatformBindingService>();
                }

                return(p);
            }
Exemplo n.º 24
0
        public static void Add(this ImageList.ImageCollection ic,
			DevicePlatform p, Image i)
        {
            ic.Add (GetString (p), i);
        }
Exemplo n.º 25
0
 public Target(string id, DevicePlatform platform)
     : this(id, string.Empty, platform)
 {
 }