public IHttpActionResult UpgradeIos(string accessToken, int channel, int platform, string ver) { Logger.WriterLogger("Common.UpgradeIos, Params: " + string.Format("accessToken={0}&channel={1}&platform={2}&ver={3}", accessToken, channel, platform, ver), LoggerType.Info); decimal resultver = Util.ConvertVer(ver) * 1.00m / 100; AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetLatestAppVersionRecordOrderById("ios"); if (appVersionRecordInfo != null) { IosVersionResult result = new IosVersionResult(); result.VerName = appVersionRecordInfo.Version.ToString("0.00").Replace(".", ""); result.Descript = appVersionRecordInfo.Description; //result.IsForceUpgrade = appVersionRecordInfo.IsForcibleUpgrade; result.IsForceUpgrade = APPHelper.IsForcibleUpgradeByPreviousVersion(resultver, "ios"); return(base.JsonActionResult(new StandardResult <IosVersionResult>() { code = 0, msg = "", data = result })); } else { return(base.JsonActionResult(new StandardResult <string>() { code = 1, msg = "未获取到ios版本信息", data = null })); } }
private void LoadNewVersion() { AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetLatestAppVersionRecordOrderById("ios"); if (appVersionRecordInfo != null) { this.txtVersion.Text = appVersionRecordInfo.Version.ToString("0.00"); this.txtDescription.Text = appVersionRecordInfo.Description; this.txtUpgradeUrl.Text = appVersionRecordInfo.UpgradeUrl; this.ChkisForceUpgrade.Checked = appVersionRecordInfo.IsForcibleUpgrade; } }
private AppAndroidVersionResult GetAndroidLatestVersion() { AppAndroidVersionResult result = new AppAndroidVersionResult(); AppVersionRecordInfo appVersion = APPHelper.GetLatestAppVersionRecordOrderById("android"); if (appVersion != null) { result = new AppAndroidVersionResult(); result.appname = appVersion.AppName; result.apkname = appVersion.AppPackageName; result.verName = appVersion.VersionName; result.verCode = (int)appVersion.Version; result.url = Util.AppendImageHost(appVersion.UpgradeUrl); result.infoUrl = Util.AppendImageHost(appVersion.UpgradeInfoUrl); // 打开文件 ///Storage/data/app/android/haimylife_v10.1.txt result.info = ""; result.IsForcibleUpgrade = appVersion.IsForcibleUpgrade; result.info = appVersion.Description; //string upgradeInfoPath = HostingEnvironment.MapPath(appVersion.UpgradeInfoUrl); //if (File.Exists(upgradeInfoPath)) //{ // try // { // using (var fs = new FileStream(upgradeInfoPath, FileMode.Open, FileAccess.Read)) // { // int len = (int)fs.Length; // byte[] bytes = new byte[len]; // int r = fs.Read(bytes, 0, bytes.Length); // result.info = System.Text.Encoding.UTF8.GetString(bytes); // } // } // catch(Exception ex) // { // Logger.WriterLogger(ex.Message); // } //} } return(result); }
/// <summary> /// 保存版本信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveVersion_Click(object sender, System.EventArgs e) { if (string.IsNullOrWhiteSpace(this.txtDescription.Text)) { this.ShowMsg("版本描述不能为空", false); return; } if (string.IsNullOrWhiteSpace(this.txtUpgradeUrl.Text)) { this.ShowMsg("链接地址不能为空", false); return; } decimal num = 0.00m; if (!decimal.TryParse(this.txtVersion.Text, out num)) { this.ShowMsg("版本号格式不对,必须为实数", false); return; } if (this.Id > 0) { //修改版本有上传文件才进行数据包存储操作 if (this.fileUpload.HasFile) { if (this.fileUpload.PostedFile.ContentLength == 0 || (this.fileUpload.PostedFile.ContentType != "application/x-zip-compressed" && this.fileUpload.PostedFile.ContentType != "application/zip" && this.fileUpload.PostedFile.ContentType != "application/octet-stream")) { this.ShowMsg("请上传正确的数据包文件", false); return; } string savedPath = this.Page.Request.MapPath("~/storage/data/app/android"); string fileName = System.IO.Path.GetFileName(this.fileUpload.PostedFile.FileName); string fullFileName = System.IO.Path.Combine(savedPath, fileName); this.fileUpload.PostedFile.SaveAs(fullFileName); System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(savedPath); using (ZipFile zipFile = ZipFile.Read(System.IO.Path.Combine(directoryInfo.FullName, fileName))) { foreach (ZipEntry current in zipFile) { current.Extract(directoryInfo.FullName, ExtractExistingFileAction.OverwriteSilently); } } System.IO.File.Delete(fullFileName); } AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetAppVersionById(this.Id); appVersionRecordInfo.Version = num; appVersionRecordInfo.Description = this.txtDescription.Text; appVersionRecordInfo.UpgradeUrl = this.txtUpgradeUrl.Text.Trim(); appVersionRecordInfo.IsForcibleUpgrade = this.ChkisForceUpgrade.Checked; appVersionRecordInfo.Device = "android"; if (APPHelper.UpdateAppVersionRecord(appVersionRecordInfo)) { this.ShowMsg("保存成功!", true); } else { this.ShowMsg("保存失败!", true); } } else { if (!this.fileUpload.HasFile) { this.ShowMsg("请先选择一个数据包文件", false); return; } if (this.fileUpload.PostedFile.ContentLength == 0 || (this.fileUpload.PostedFile.ContentType != "application/x-zip-compressed" && this.fileUpload.PostedFile.ContentType != "application/zip" && this.fileUpload.PostedFile.ContentType != "application/octet-stream")) { this.ShowMsg("请上传正确的数据包文件", false); return; } string savedPath = this.Page.Request.MapPath("~/storage/data/app/android"); string fileName = System.IO.Path.GetFileName(this.fileUpload.PostedFile.FileName); string fullFileName = System.IO.Path.Combine(savedPath, fileName); this.fileUpload.PostedFile.SaveAs(fullFileName); System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(savedPath); using (ZipFile zipFile = ZipFile.Read(System.IO.Path.Combine(directoryInfo.FullName, fileName))) { foreach (ZipEntry current in zipFile) { current.Extract(directoryInfo.FullName, ExtractExistingFileAction.OverwriteSilently); } } System.IO.File.Delete(fullFileName); AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetLatestAppVersionRecordOrderById("android"); if (appVersionRecordInfo != null) { if (appVersionRecordInfo.Version >= num) { this.ShowMsg("版本号必须大于之前的版本", false); return; } } AppVersionRecordInfo newappVersionRecordInfo = new AppVersionRecordInfo(); newappVersionRecordInfo.Version = num; newappVersionRecordInfo.IsForcibleUpgrade = this.ChkisForceUpgrade.Checked; newappVersionRecordInfo.Description = this.txtDescription.Text.Trim(); newappVersionRecordInfo.UpgradeUrl = this.txtUpgradeUrl.Text.Trim(); newappVersionRecordInfo.Device = "android"; if (APPHelper.AddAppVersionRecord(newappVersionRecordInfo)) { this.ShowMsg("保存成功!", true); } else { this.ShowMsg("保存失败!", true); } } }
/// <summary> /// 保存版本信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveVersion_Click(object sender, System.EventArgs e) { AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetLatestAppVersionRecordOrderById("ios"); decimal num = 0.00m; if (!decimal.TryParse(this.txtVersion.Text, out num)) { this.ShowMsg("版本号格式不对,必须为实数", false); return; } //if (appVersionRecordInfo != null) //{ // if (appVersionRecordInfo.Version >= num) // { // this.ShowMsg("版本号必须大于当前版本", false); // return; // } //} if (string.IsNullOrWhiteSpace(this.txtDescription.Text)) { this.ShowMsg("版本描述不能为空", false); return; } if (string.IsNullOrWhiteSpace(this.txtUpgradeUrl.Text)) { this.ShowMsg("链接地址不能为空", false); return; } if (appVersionRecordInfo == null) { AppVersionRecordInfo newappVersionRecordInfo = new AppVersionRecordInfo(); newappVersionRecordInfo.Version = num; newappVersionRecordInfo.IsForcibleUpgrade = this.ChkisForceUpgrade.Checked; newappVersionRecordInfo.Description = this.txtDescription.Text.Trim(); newappVersionRecordInfo.UpgradeUrl = this.txtUpgradeUrl.Text.Trim(); newappVersionRecordInfo.Device = "ios"; if (APPHelper.AddAppVersionRecord(newappVersionRecordInfo)) { this.ShowMsg("保存成功!", true); } else { this.ShowMsg("保存失败!", true); } } else { appVersionRecordInfo.Version = num; appVersionRecordInfo.Description = this.txtDescription.Text.Trim(); appVersionRecordInfo.UpgradeUrl = this.txtUpgradeUrl.Text.Trim(); appVersionRecordInfo.IsForcibleUpgrade = this.ChkisForceUpgrade.Checked; appVersionRecordInfo.Device = "ios"; if (APPHelper.UpdateAppVersionRecord(appVersionRecordInfo)) { this.ShowMsg("保存成功!", true); } else { this.ShowMsg("保存失败!", true); } } }