Exemple #1
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);
                }
            }
        }
Exemple #2
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);
                }
            }
        }