Example #1
0
        private void startCheckUp(object obj)
        {
            bool isNeedTipAllReadyLatest = (bool)obj;

            try
            {
                String     response = HttpUtil.Get(HttpUtil.URL.UpdateUrl, null);
                UpdateInfo data     = JsonConvert.DeserializeAnonymousType(response, new UpdateInfo());
                if (PkgUtil.compareVersion(data.version, EXE_VERSION) > 0)
                {
                    if (MessageBox.Show(String.Format("当前版本:{0}\n最新版本:{1}\n是否下载?", EXE_VERSION, data.version), "升级提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        SaveFileDialog dialog = new SaveFileDialog();
                        dialog.FileName = data.appUrl.Substring(data.appUrl.LastIndexOf("/") + 1);
                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            HttpDownloadFile(data.appUrl, dialog.FileName, Int32.Parse(data.size));
                        }
                    }
                }
                else
                {
                    if (isNeedTipAllReadyLatest)
                    {
                        MessageBox.Show("已经是最新版本 " + EXE_VERSION);
                    }
                }
            }
            catch (Exception e1)
            {
                showMsg(e1.Message);
            }
        }
Example #2
0
        private void dataGridViewMain_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            if (e.ColumnIndex == 3) // 上传
            {
                String locPath = mListData[e.RowIndex].locPath;
                if (String.IsNullOrEmpty(locPath))
                {
                    MessageBox.Show("请先设置本地apk路径");
                    return;
                }

                if (!File.Exists(locPath))
                {
                    MessageBox.Show("本地apk不存在,请先生成apk文件");
                    return;
                }

                String ver        = getApkVersion(locPath);
                int    compareRet = PkgUtil.compareVersion(ver, mListData[e.RowIndex].updateInfo.version);
                if (compareRet < 0)
                {
                    MessageBox.Show("当前版本小于远程服务器版本,无法上传");
                    return;
                }

                if (MessageBox.Show("远程版本:" + mListData[e.RowIndex].updateInfo.version + "\n本地版本:" + ver + "\n确认上传吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    UploadInfo info = new UploadInfo();
                    info.id      = mListData[e.RowIndex].id;
                    info.version = ver;
                    mLocFile     = locPath;
                    new Thread(new ParameterizedThreadStart(startUploadFile)).Start(info);
                }
            }
            else if (e.ColumnIndex == 4) // 下载
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter   = "apk文件| *.apk|任意文件| *.*";
                dialog.FileName = mListData[e.RowIndex].name;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    new Thread(new ParameterizedThreadStart(startDownFile)).Start(new String[] { mListData[e.RowIndex].updateInfo.appUrl, dialog.FileName, mListData[e.RowIndex].updateInfo.size }); //  (mListData[e.RowIndex].updateInfo.appUrl, dialog.FileName))
                }
            }
        }