private static async Task <AppVersionModel> retrieveVersion(IServiceProvider sp, AppKey appKey)
        {
            AppVersionModel appVersion;
            var             hostEnv = sp.GetService <IHostEnvironment>();

            if (hostEnv.IsProduction())
            {
                var hubApi = sp.GetService <HubAppApi>();
                appVersion = await hubApi.AppRegistration.GetVersion.Invoke(new GetVersionRequest
                {
                    AppKey     = appKey,
                    VersionKey = AppVersionKey.Current
                });
            }
            else
            {
                appVersion = new AppVersionModel
                {
                    VersionKey = AppVersionKey.Current.Value,
                    Major      = 1,
                    Minor      = 0,
                    Patch      = 0
                };
            }
            return(appVersion);
        }
        public void Output(AppVersionModel versionModel, string outputPath)
        {
            var version     = new Version(versionModel.Major, versionModel.Minor, versionModel.Patch);
            var nextVersion = new Version(versionModel.Major, versionModel.Minor, versionModel.Patch + 1);
            var output      = new VersionToolOutput
            {
                VersionKey       = versionModel.VersionKey,
                VersionType      = versionModel.VersionType.DisplayText,
                VersionNumber    = version.ToString(3),
                DevVersionNumber = nextVersion.ToString(3)
            };

            new XtiProcessData().Output(output);
            if (!string.IsNullOrWhiteSpace(outputPath))
            {
                var dirPath = Path.GetDirectoryName(outputPath);
                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }
                using var writer = new StreamWriter(outputPath, false);
                writer.WriteLine
                (
                    JsonSerializer.Serialize
                    (
                        new VersionRecord
                {
                    Key     = versionModel.VersionKey,
                    Type    = versionModel.VersionType.DisplayText,
                    Version = versionModel.Version().ToString()
                }
                    )
                );
            }
        }
        public AppVersionModel GetVersion()
        {
            AppVersionModel appVersionModel = new AppVersionModel();
            GlobalSetting   globalSettings  = AppVersionRepository.GetAll().SingleOrDefault();

            AutoMapper.Mapper.Map(globalSettings, appVersionModel);
            return(appVersionModel);
        }
Beispiel #4
0
        public JsonResult GetAppVersion(string AppOS)
        {
            JsonresultModel ResultModel = new JsonresultModel();
            AppVersionModel AppVersion  = new AppVersionModel();


            try
            {
                if (AppOS == "IOS")
                {
                    //iphone
                    AppVersion.AppOS    = "IOS";
                    AppVersion.Version  = ConfigurationManager.AppSettings["IOS_Version"];
                    AppVersion.Download = ConfigurationManager.AppSettings["IOS_Download"];
                    ResultModel.Result  = "1";
                    ResultModel.Query   = AppVersion;
                }
                else if (AppOS == "Android")
                {
                    //android
                    AppVersion.AppOS = "Android";



                    AppVersion.Version  = GeneralModelFactory.getAPKVersion(Server.MapPath("/files/app.apk"));
                    AppVersion.Download = ConfigurationManager.AppSettings["Android_Download"];


                    ResultModel.Result = "1";
                    ResultModel.Query  = AppVersion;
                }
                else
                {
                    ResultModel.Result   = "0";
                    ResultModel.ErrorMsg = "查無AppOS";
                    return(Json(ResultModel, JsonRequestBehavior.AllowGet));
                }
            }
            catch
            {
                ResultModel.Result   = "0";
                ResultModel.ErrorMsg = "系統發生錯誤";
                return(Json(ResultModel, JsonRequestBehavior.AllowGet));
            }

            return(Json(ResultModel, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        /// <summary>
        /// 检查更新
        /// </summary>
        /// <param name="currentVersion"></param>
        /// <param name="os">操作系统</param>
        /// <returns></returns>
        public AppVersionModel CheckUpdate(string currentVersion, string os)
        {
            AppVersionModel verData = new AppVersionModel();

            if (os == OSOptions.android.ToString())
            {
                bool flag = GlobalProvider.IsVersionUpdate("1.0.2", currentVersion);
                if (flag)
                {
                    verData.serverVersion = "1.0.2";
                    verData.updateType    = 1;
                    verData.updateTip     = "测试更新";
                    verData.updateUrl     = "http://www.baidu.com";
                }
            }
            return(verData);
        }
        public async Task <AppVersionModel[]> Versions()
        {
            var versions = new AppVersionModel[] { };

            if (File.Exists(path))
            {
                using (var reader = new StreamReader(path))
                {
                    var serialized = await reader.ReadToEndAsync();

                    if (!string.IsNullOrWhiteSpace(serialized))
                    {
                        var jsonOptions = new JsonSerializerOptions();
                        versions = JsonSerializer.Deserialize <AppVersionModel[]>(serialized, jsonOptions);
                    }
                }
            }
            return(versions);
        }
Beispiel #7
0
        /// <summary>
        /// 检查更新
        /// </summary>
        /// <param name="currentVersion"></param>
        /// <param name="os">操作系统</param>
        /// <returns></returns>
        public AppVersionModel CheckUpdate(string currentVersion, string os)
        {
            AppVersionModel verData = new AppVersionModel();

            if (os == OSOptions.android.ToString())
            {
                var newVersion = ConfigLogic.GetValue("AppVersion");

                bool flag = GlobalProvider.IsVersionUpdate(newVersion, currentVersion);
                if (flag)
                {
                    verData.serverVersion = newVersion;
                    verData.updateType    = Convert.ToInt32(ConfigLogic.GetValue("EnableAppCoerceUpdate")) == 1 ? 2 : 1;
                    verData.updateTip     = ConfigLogic.GetValue("AppUpateContent");
                    verData.updateUrl     = ConfigLogic.GetValue("AppUpateUrl");
                }
            }
            return(verData);
        }