public string ConvertPayJson(string appId, string PartnerId, PayRequestInfo req) { SiteSettings siteSettings = HiContext.Current.SiteSettings; AppVersionRecordInfo latestAppVersionRecord = APPHelper.GetLatestAppVersionRecord("android"); string text = ""; if (latestAppVersionRecord == null || latestAppVersionRecord.Version.ToDecimal_MoreDot(0) > 3.3m) { text = "{"; text = text + "\"appid\":\"" + appId + "\","; text = text + "\"noncestr\":\"" + req.nonceStr + "\","; text += "\"package\":\"Sign=WXPay\","; text = text + "\"partnerid\":\"" + PartnerId + "\","; text = text + "\"prepayid\":\"" + req.prepayid + "\","; text = text + "\"timestamp\":" + req.timeStamp + ","; text = text + "\"sign\":\"" + req.paySign + "\""; return(text + "}"); } text = "{"; text = text + "\"partnerId\":\"" + PartnerId + "\","; text = text + "\"prepayId\":\"" + req.prepayid + "\","; text = text + "\"nonceStr\":\"" + req.nonceStr + "\","; text = text + "\"timeStamp\":\"" + req.timeStamp + "\","; text = text + "\"sign\":\"" + req.paySign + "\""; return(text + "}"); }
protected void Page_Load(object sender, System.EventArgs e) { btnCancel.Click += btnCancel_Click; btnSave.Click += btnSave_Click; dic = new Dictionary <string, string>(); List <AppRunImgInfo> list = APPHelper.GetAppRunImg(); if (!(list == null || list.Count == 0)) { foreach (AppRunImgInfo a in list) { dic.Add(a.phoneType, a.imgSrc); } } if (!this.Page.IsPostBack) { if (dic.ContainsKey("Android720_1280")) { Android720_1280hid.Value = Android720_1280.ImageUrl = dic["Android720_1280"]; } if (dic.ContainsKey("iOS750_1334")) { iOS750_1334hid.Value = iOS750_1334.ImageUrl = dic["iOS750_1334"]; } if (dic.ContainsKey("iOS640_960")) { iOS640_960hid.Value = iOS640_960.ImageUrl = dic["iOS640_960"]; } if (dic.ContainsKey("iOS1242_2208")) { iOS1242_2208hid.Value = iOS1242_2208.ImageUrl = dic["iOS1242_2208"]; } } }
private void btnUpoad_Click(object sender, System.EventArgs e) { 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); this.LoadVersion(); AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetLatestAppVersionRecord("android"); if (appVersionRecordInfo == null) { appVersionRecordInfo = new AppVersionRecordInfo(); appVersionRecordInfo.Device = "android"; appVersionRecordInfo.Version = 0.00m; } decimal num = 1.00m; decimal.TryParse(this.litVersion.Text, out num); if (num > appVersionRecordInfo.Version) { bool isForcibleUpgrade = false; bool.TryParse(this.hidIsForcibleUpgrade.Value, out isForcibleUpgrade); appVersionRecordInfo.AppName = this.litAppName.Text; appVersionRecordInfo.AppPackageName = this.litApkName.Text; appVersionRecordInfo.VersionName = this.litVersionName.Text; appVersionRecordInfo.Version = num; appVersionRecordInfo.IsForcibleUpgrade = isForcibleUpgrade; appVersionRecordInfo.Description = this.litDescription.Text; appVersionRecordInfo.UpgradeUrl = this.litUpgradeUrl.Text; appVersionRecordInfo.UpgradeInfoUrl = this.litUpgradeInfoUrl.Text; APPHelper.AddAppVersionRecord(appVersionRecordInfo); } this.ShowMsg("上传成功!", true); }
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 })); } }
internal void Start() { Initialize(); var ip = APPHelper.GetLocalIP(); if (ip != null) { Log("Starting VM Request listener at local IP: " + ip.ToString(), true); try { mListener = new TcpListener(ip, Definitions.mPortNumber); mListener.Start(); BeginAcceptConnection(); } catch (Exception ex) { Log("Exception: " + ex); } } else { Log("Failed to get local IP"); } }
private void installapp() { string TESTExe = mTESTExecutable; string[] results = mCommandResponse.TestCommand.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (results.Length == 2) { TESTExe = Path.Combine(mTargetDirectory, results[1]); } Log("Install path: " + TESTExe); bool result = false; if (GetOperatingSystemType() == OperatingSystemType.Windows) { result = APPHelper.installapp(mTargetDirectory, TESTExe, mCommandResponse.LicenseKey); } else { result = APPHelper.installappMac(mTargetDirectory, TESTExe, mCommandResponse.LicenseKey); } if (result == false) { Log("APP failed to install"); mCommandResultString += "APP Failed to install" + "; "; mCommandResult = false; } else { Log("Waiting for " + mWaitForAPPSeconds + " seconds to let APP start up"); Thread.Sleep(mWaitForAPPSeconds * 1000); if (GetOperatingSystemType() == OperatingSystemType.Windows) { result = APPHelper.CheckTESTIsRunning(); Log("TEST running: " + result); if (result == false) { mCommandResultString += "APP is not running" + "; "; mCommandResult = false; } else { result = Directory.Exists(mProgramDataDirDirectory); Log("TEST ProgramDataDir exists: " + result); if (result == false) { mCommandResultString += "APP Data directory was not created" + "; "; mCommandResult = false; } } } } CreateOutputJson((result == true ? 1 : 0), (result == true ? 0 : 1)); }
public string GetGoodsListJson(DbQueryResult GoodsTable, int ClientType) { AppVersionRecordInfo latestAppVersionRecord = APPHelper.GetLatestAppVersionRecord("android"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("\"list\":["); DataTable data = GoodsTable.Data; for (int i = 0; i < data.Rows.Count; i++) { stringBuilder.Append("{"); stringBuilder.Append("\"item_id\":\"" + data.Rows[i]["ProductId"] + "\","); stringBuilder.Append("\"title\":\"" + data.Rows[i]["ProductName"] + "\","); stringBuilder.Append("\"price\":\"" + data.Rows[i]["SalePrice"].ToDecimal(0).F2ToString("f2") + "\","); stringBuilder.Append("\"original_price\":\"" + data.Rows[i]["MarketPrice"].ToDecimal(0).F2ToString("f2") + "\","); stringBuilder.Append("\"create_time\":\"" + Convert.ToDateTime(data.Rows[i]["AddedDate"]).ToString("yyyy-MM-dd HH:mm:ss") + "\","); switch (ClientType) { case 2: if (latestAppVersionRecord == null || latestAppVersionRecord.Version.ToDecimal_MoreDot(0) > 3.3m) { stringBuilder.Append("\"link\":\"" + HiContext.Current.HostPath + "/productdetail.html?id=" + data.Rows[i]["ProductId"] + "\","); } else { stringBuilder.Append("\"link\":\"hishop://webShowProduct/null/" + data.Rows[i]["ProductId"] + "\","); } break; case 1: stringBuilder.Append("\"link\":\"/ProductDetails?productId=" + data.Rows[i]["ProductId"] + "\","); break; case 4: stringBuilder.Append("\"link\":\"../productdetail/productdetail?id=" + data.Rows[i]["ProductId"] + "\","); break; default: stringBuilder.Append("\"link\":\"javascript:showProductDetail(" + data.Rows[i]["ProductId"] + ")\","); break; } string empty = string.Empty; empty = ((!string.IsNullOrEmpty(data.Rows[i]["ThumbnailUrl310"].ToString())) ? data.Rows[i]["ThumbnailUrl310"].ToString() : SettingsManager.GetMasterSettings().DefaultProductImage); if ((empty.IndexOf("http") < 0 || empty.IndexOf("https") < 0) && ClientType == 4) { empty = Globals.FullPath(empty); } stringBuilder.Append("\"pic\":\"" + empty + "\","); stringBuilder.Append("\"is_compress\":0"); stringBuilder.Append("},"); } string str = stringBuilder.ToString().TrimEnd(','); return(str + "]"); }
private void LoadVersion() { AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetAppVersionById(this.Id); 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; } }
public IHttpActionResult Upgrade(string accessToken, int channel, int platform, string ver) { Logger.WriterLogger("Common.Upgrade, Params: " + string.Format("accessToken={0}&channel={1}&platform={2}&ver={3}", accessToken, channel, platform, ver), LoggerType.Info); // 保存访问信息 base.SaveVisitInfo("", channel, platform, ver); // 验证令牌 int accessTookenCode = VerifyAccessToken(accessToken); if (accessTookenCode > 0) { return(base.JsonFaultResult(new CommonException(accessTookenCode).GetMessage(), "Common.Upgrade")); } decimal resultver = Util.ConvertVer(ver) * 1.00m / 100; string device = ""; switch (platform) { case 3: device = "android"; AppAndroidVersionResult result = GetAndroidLatestVersion(); result.IsForcibleUpgrade = APPHelper.IsForcibleUpgradeByPreviousVersion(resultver, "android"); return(base.JsonActionResult(new StandardResult <AppAndroidVersionResult>() { code = 0, msg = "", data = result })); //break; case 2: device = "ios"; break; default: break; } return(base.JsonActionResult(new StandardResult <object>() { code = 0, msg = "", data = null })); }
public IHttpActionResult AppBanner(string accessToken, int channel, int platform, string ver) { Logger.WriterLogger("Site.AppBanner, Params: " + string.Format("accessToken={0}&channel={1}&platform={2}&ver={3}", accessToken, channel, platform, ver), LoggerType.Info); // 保存访问信息 base.SaveVisitInfo("", channel, platform, ver); // 验证令牌 int accessTookenCode = VerifyAccessToken(accessToken); if (accessTookenCode > 0) { return(base.JsonFaultResult(new CommonException(accessTookenCode).GetMessage(), "Site.AppBanner")); } List <AppBannerListItem> items = new List <AppBannerListItem>(); List <AppRunImgInfo> list = APPHelper.GetAppRunImg(); if (!(list == null || list.Count == 0)) { AppBannerListItem item = null; foreach (AppRunImgInfo current in list) { item = new AppBannerListItem(); item.DeviceType = current.phoneType; item.BannerUrl = Util.AppendImageHost(current.imgSrc); items.Add(item); } } StandardResult <ListResult <AppBannerListItem> > result = new StandardResult <ListResult <AppBannerListItem> >() { code = 0, msg = "", data = new ListResult <AppBannerListItem>() { TotalNumOfRecords = items.Count, Results = items } }; return(base.JsonActionResult(result)); }
/// <summary> /// 创建根节点对象 /// </summary> /// <param name="xmlFilePath">Xml文件的相对路径</param> private static XmlElement CreateRootElement(string xmlFilePath) { //定义变量,表示XML文件的绝对路径 string filePath = ""; //获取XML文件的绝对路径 filePath = APPHelper.GetPath(xmlFilePath); //创建XmlDocument对象 XmlDocument xmlDocument = new XmlDocument(); //加载XML文件 xmlDocument.Load(filePath); //返回根节点 return(xmlDocument.DocumentElement); }
internal void Start() { var ip = APPHelper.GetLocalIP(); if (ip != null) { Log("Starting StatusRequest listener at local IP: " + ip.ToString(), true); mListener = new TcpListener(APPHelper.GetLocalIP(), Definitions.mTestServerControlPortNumber); mListener.Start(); BeginAcceptConnection(); } else { Log("Failed to get local IP"); } }
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); }
private void ProcessAppInit(System.Web.HttpContext context) { string text = context.Request["VID"]; string text2 = context.Request["device"]; string text3 = context.Request["version"]; string text4 = context.Request["isFirst"]; if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2) || string.IsNullOrEmpty(text3) || string.IsNullOrEmpty(text4)) { context.Response.Write(this.GetErrorJosn(101, "缺少必填参数")); return; } decimal num; if (!decimal.TryParse(text3, out num)) { context.Response.Write(this.GetErrorJosn(102, "数字类型转换错误")); return; } if (text4.ToLower() == "true") { APPHelper.AddAppInstallRecord(new AppInstallRecordInfo { VID = text, Device = text2 }); } AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetLatestAppVersionRecord(text2); if (appVersionRecordInfo == null) { appVersionRecordInfo = new AppVersionRecordInfo(); appVersionRecordInfo.Version = num; } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("{\"result\":{"); stringBuilder.AppendFormat("\"version\":\"{0}\",", appVersionRecordInfo.Version); stringBuilder.AppendFormat("\"existNew\":\"{0}\",", (appVersionRecordInfo.Version > num).ToString().ToLower()); stringBuilder.AppendFormat("\"forcible\":\"{0}\",", APPHelper.IsForcibleUpgrade(text2, num).ToString().ToLower()); stringBuilder.AppendFormat("\"description\":\"{0}\",", appVersionRecordInfo.Description); stringBuilder.AppendFormat("\"upgradeUrl\":\"{0}\"", appVersionRecordInfo.UpgradeUrl); stringBuilder.Append("}}"); context.Response.Write(stringBuilder.ToString()); }
protected override void OnLoad(System.EventArgs e) { if (!this.Page.IsPostBack) { string userAgent = HttpContext.Current.Request.QueryString["t"] != null ? HttpContext.Current.Request.QueryString["t"].ToLower() : ""; if (string.IsNullOrEmpty(userAgent)) { userAgent = HttpContext.Current.Request.UserAgent.ToLower(); } string url = ""; if (userAgent.IndexOf("ios") != -1) { AppVersionRecordInfo appVersion = APPHelper.GetLatestAppVersionRecord("ios"); if (appVersion != null) { url = appVersion.UpgradeUrl; } } else if (userAgent.IndexOf("android") != -1) { AppVersionRecordInfo appVersion = APPHelper.GetLatestAppVersionRecord("android"); if (appVersion != null) { url = appVersion.UpgradeUrl; } } else { AppVersionRecordInfo appVersion = APPHelper.GetLatestAppVersionRecord("android"); if (appVersion != null) { url = appVersion.UpgradeUrl; } } if (!string.IsNullOrEmpty(url)) { HttpContext.Current.Response.Redirect(url); } } }
protected void rptAndroidUpgrades_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument); if (APPHelper.DelAppVersionById(id)) { this.ShowMsg("删除成功", true); this.BindData(); return; } else { this.ShowMsg("删除失败", false); return; } } }
private void BindData() { this.rptAndroidUpgrades.DataSource = APPHelper.GetAppVersionRecordList("android"); this.rptAndroidUpgrades.DataBind(); }
protected override void AttachChildControls() { if (HiContext.Current.User != null) { AppshopTemplatedRepeater appshopTemplatedRepeater = (AppshopTemplatedRepeater)this.FindControl("rptDrawList"); IList <AppLotteryDraw> list = (IList <AppLotteryDraw>)(appshopTemplatedRepeater.DataSource = APPHelper.GetAppLotteryDraw(HiContext.Current.UserId)); appshopTemplatedRepeater.DataBind(); PageTitle.AddSiteNameTitle("中奖记录"); } }
void btnSave_Click(object sender, EventArgs e) { string mapPath = Globals.MapPath("/Storage/master/app/"); string pa = "/Storage/master/app/"; string fileUuid = Guid.NewGuid().ToString().ToLower() + "_"; if (!string.IsNullOrWhiteSpace(fileUpload1.FileName)) { string filename = fileUuid + "android_720_1289."; string ext = fileUpload1.FileName.Substring(fileUpload1.FileName.LastIndexOf('.') + 1); fileUpload1.SaveAs(mapPath + filename + ext); Android720_1280.ImageUrl = pa + filename + ext; } if (!string.IsNullOrWhiteSpace(fileUpload2.FileName)) { string filename = fileUuid + "ios750_1334."; string ext = fileUpload2.FileName.Substring(fileUpload2.FileName.LastIndexOf('.') + 1); fileUpload2.SaveAs(mapPath + filename + ext); iOS750_1334.ImageUrl = pa + filename + ext; } if (!string.IsNullOrWhiteSpace(fileUpload3.FileName)) { string filename = fileUuid + "ios640_960."; string ext = fileUpload3.FileName.Substring(fileUpload3.FileName.LastIndexOf('.') + 1); fileUpload3.SaveAs(mapPath + filename + ext); iOS640_960.ImageUrl = pa + filename + ext; } if (!string.IsNullOrWhiteSpace(fileUpload4.FileName)) { string filename = fileUuid + "ios1242_2208."; string ext = fileUpload4.FileName.Substring(fileUpload4.FileName.LastIndexOf('.') + 1); fileUpload4.SaveAs(mapPath + filename + ext); iOS1242_2208.ImageUrl = pa + filename + ext; } //return; //ShowMsg(Android720_1280hid.Value,false); if (dic.ContainsKey("Android720_1280")) { dic["Android720_1280"] = Android720_1280.ImageUrl; } else { dic.Add("Android720_1280", Android720_1280.ImageUrl); } if (dic.ContainsKey("iOS750_1334")) { dic["iOS750_1334"] = iOS750_1334.ImageUrl; } else { dic.Add("iOS750_1334", iOS750_1334.ImageUrl); } if (dic.ContainsKey("iOS640_960")) { dic["iOS640_960"] = iOS640_960.ImageUrl; } else { dic.Add("iOS640_960", iOS640_960.ImageUrl); } if (dic.ContainsKey("iOS1242_2208")) { dic["iOS1242_2208"] = iOS1242_2208.ImageUrl; } else { dic.Add("iOS1242_2208", iOS1242_2208.ImageUrl); } if (APPHelper.ChangeAppRunImg(dic)) { this.ShowMsg("±£´æ³É¹¦£¡", true); string[] name = System.IO.Directory.GetFiles(mapPath); foreach (string n in name) { } //this.Response.Redirect("AppRunImg.aspx", true); } else { this.ShowMsg("±£´æʧ°Ü£¡", false); } }
protected override void AttachChildControls() { string text = ""; this.AndroidQrCode = (Image)this.FindControl("AndroidQrCode"); this.IosQrCode = (Image)this.FindControl("IosQrCode"); this.androidLink = (HtmlAnchor)this.FindControl("androidlink"); this.iosLink = (HtmlAnchor)this.FindControl("ioslink"); string text2 = ""; string text3 = ""; string text4 = ""; string str = ""; string text5 = ""; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.XmlResolver = null; AppVersionRecordInfo latestAppVersionRecord = APPHelper.GetLatestAppVersionRecord("android"); if (latestAppVersionRecord != null) { text4 = latestAppVersionRecord.Version.ToString(); text2 = latestAppVersionRecord.UpgradeUrl; } if (string.IsNullOrEmpty(text2)) { text2 = "http://" + Globals.DomainName + text + this.appBaseDir + "android/MEC1.4_android1.0.0.apk"; } if (text2.ToLower().IndexOf("http://") == -1) { text2 = "http://" + Globals.DomainName + text + text2; } text5 = this.baseDir + "AndroidDownload_" + text4 + ".png"; if (Directory.Exists(this.Page.Request.MapPath(text5))) { this.AndroidQrCode.ImageUrl = "http://" + this.baseDir + "AndroidDownload_" + text4 + ".png"; } else { this.AndroidQrCode.ImageUrl = Globals.CreateQRCode(text2, text5, false, ImageFormats.Png); } AppVersionRecordInfo latestAppVersionRecord2 = APPHelper.GetLatestAppVersionRecord("ios"); if (latestAppVersionRecord2 != null) { str = latestAppVersionRecord2.Version.ToString(); } text3 = HiContext.Current.SiteSettings.AppIOSDownLoadUrl; if (string.IsNullOrEmpty(text3)) { text3 = "https://itunes.apple.com/us/app/yi-dong-yun-shang-cheng/id880544709?mt=8"; } text5 = this.baseDir + "IosDownload_" + str + ".png"; if (Directory.Exists(this.Page.Request.MapPath(text5))) { this.IosQrCode.ImageUrl = this.baseDir + "IosDownload_" + str + ".png"; } else { this.IosQrCode.ImageUrl = Globals.CreateQRCode(text3, text5, false, ImageFormats.Png); } this.iosLink.HRef = text3; this.androidLink.HRef = text2; }
private void btnUpoad_Click(object sender, EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (this.fileUpload.FileContent.Length > 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); } else { string text2 = masterSettings.AppAndroidDownLoadUrl = Globals.StripAllTags(this.txtAndroidDownloadUrl.InnerText); if (this.fileUpload.FileContent.Length > 0) { string text3 = this.Page.Request.MapPath("~/App_Data/data/app/android"); string str = this.Page.Request.MapPath("~/storage/data/app/android"); string fileName = Path.GetFileName(this.fileUpload.PostedFile.FileName); string text4 = Path.Combine(text3, fileName); this.ClearDirectory(text3); this.fileUpload.PostedFile.SaveAs(text4); DirectoryInfo directoryInfo = new DirectoryInfo(text3); using (ZipFile zipFile = ZipFile.Read(Path.Combine(directoryInfo.FullName, fileName))) { foreach (ZipEntry item in zipFile) { item.Extract(directoryInfo.FullName, ExtractExistingFileAction.OverwriteSilently); } } if (!File.Exists(text3 + "/AndroidUpgrade.xml")) { this.ShowMsg("压缩包中不包含版本信息的xml文件,请重新打包。", false); return; } File.Copy(text3 + "/AndroidUpgrade.xml", str + "/AndroidUpgrade.xml", true); File.Delete(text3 + "/AndroidUpgrade.xml"); string[] files = Directory.GetFiles(text3, "*.apk"); if (files.Length != 0) { string[] array = files; foreach (string text5 in array) { FileInfo fileInfo = new FileInfo(text5); File.Copy(text5, str + "/" + fileInfo.Name, true); } } File.Delete(text4); this.LoadVersion(); AppVersionRecordInfo appVersionRecordInfo = APPHelper.GetLatestAppVersionRecord("android"); if (appVersionRecordInfo == null) { appVersionRecordInfo = new AppVersionRecordInfo(); appVersionRecordInfo.Device = "android"; appVersionRecordInfo.Version = "0.00"; } string text6 = this.litVersion.Text; if (APPHelper.IsExistNewVersion(text6, appVersionRecordInfo.Version)) { bool isForcibleUpgrade = false; bool.TryParse(this.hidIsForcibleUpgrade.Value, out isForcibleUpgrade); appVersionRecordInfo.Version = text6; appVersionRecordInfo.IsForcibleUpgrade = isForcibleUpgrade; appVersionRecordInfo.Description = this.litDescription.Text; appVersionRecordInfo.UpgradeUrl = this.txtAndroidDownloadUrl.InnerText; APPHelper.AddAppVersionRecord(appVersionRecordInfo); } } masterSettings.EnableAppDownload = this.ooOpen.SelectedValue; masterSettings.AppAuditAPIUrl = this.txtAppAuditAPIUrl.Text.ToNullString(); string text8 = masterSettings.AppIOSDownLoadUrl = Globals.StripAllTags(this.txtIosDownloadUrl.Text); SettingsManager.Save(masterSettings); this.ShowMsg("保存成功!", true); } }
/// <summary> /// 实例化XmlOperate对象 /// </summary> /// <param name="xmlFilePath">Xml文件的相对路径</param> public XmlOperate(string xmlFilePath) { //获取XML文件的绝对路径 this._XMLPath = _filePath = APPHelper.GetPath(xmlFilePath); }
private void SyncTime() { // Do not sync time if this is a MAC if (GetOperatingSystemType() == OperatingSystemType.Mac) { APPHelper.SetTimeMac(); return; } int attempt = 0; ServiceController serviceController = new ServiceController("w32time"); if (serviceController.Status != ServiceControllerStatus.Running) { serviceController.Start(); } Log("w32time service is running"); SendHeartBeat(); while (attempt < 25) { try { Process processTime = new Process(); processTime.StartInfo.FileName = "C:\\Windows\\System32\\w32tm.exe"; processTime.StartInfo.Arguments = "/resync /force"; processTime.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; processTime.StartInfo.UseShellExecute = false; processTime.StartInfo.RedirectStandardOutput = true; processTime.Start(); string output = processTime.StandardOutput.ReadToEnd(); processTime.WaitForExit(); Log("Synced time with server: " + output); SendLogMessage("MSG: " + output); if (output.ToLower().Contains("the command completed successfully.") == true) { // Due to the possible time change, the timer may be out of sync, so start a new one. StartHeartbeatTimer(); return; } Log("Retrying time sync in 10 sec."); } catch (Exception ex) { Log("Unable to sync time: " + ex); } Thread.Sleep(10000); attempt++; SendHeartBeat(); } throw new Exception("MSG: Could not sync time."); }
/// <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); } } }
protected override void AttachChildControls() { string text = ""; this.loadPanel = (HtmlGenericControl)this.FindControl("loadPanel"); this.sharePanel = (HtmlGenericControl)this.FindControl("sharePanel"); this.androidLink = (HtmlAnchor)this.FindControl("androidlink"); this.iosLink = (HtmlAnchor)this.FindControl("ioslink"); string text2 = HttpContext.Current.Request.UserAgent; if (string.IsNullOrEmpty(text2)) { text2 = ""; } if (text2.ToLower().IndexOf("micromessenger") > -1) { this.loadPanel.Visible = false; this.sharePanel.Visible = true; } else { this.loadPanel.Visible = true; this.sharePanel.Visible = false; } string text3 = ""; string text4 = ""; string text5 = ""; string text6 = ""; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.XmlResolver = null; AppVersionRecordInfo latestAppVersionRecord = APPHelper.GetLatestAppVersionRecord("android"); if (latestAppVersionRecord != null) { text5 = latestAppVersionRecord.Version.ToString(); text3 = latestAppVersionRecord.UpgradeUrl; } if (string.IsNullOrEmpty(text3)) { text3 = "http://" + Globals.DomainName + text + this.appBaseDir + "android/MEC1.4_android1.0.0.apk"; } if (text3.ToLower().IndexOf("http://") == -1) { text3 = "http://" + Globals.DomainName + text + text3; } AppVersionRecordInfo latestAppVersionRecord2 = APPHelper.GetLatestAppVersionRecord("ios"); if (latestAppVersionRecord2 != null) { text6 = latestAppVersionRecord2.Version.ToString(); } text4 = HiContext.Current.SiteSettings.AppIOSDownLoadUrl; if (string.IsNullOrEmpty(text4)) { text4 = "https://itunes.apple.com/us/app/yi-dong-yun-shang-cheng/id880544709?mt=8"; } this.iosLink.HRef = text4; this.androidLink.HRef = text3; PageTitle.AddSiteNameTitle("APP下载页面"); }
/// <summary> /// 实例化XmlHelper对象 /// </summary> /// <param name="xmlFilePath">Xml文件的相对路径</param> public XmlHelper(string xmlFilePath) { //获取XML文件的绝对路径 _filePath = APPHelper.GetPath(xmlFilePath); }
/// <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); } } }
private void BindData() { this.rptIosUpgrades.DataSource = APPHelper.GetAppVersionRecordList("ios"); this.rptIosUpgrades.DataBind(); }