Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <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);
                }
            }
        }
Beispiel #3
0
        /// <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);
                }
            }
        }
        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);
            }
        }