Ejemplo n.º 1
0
        public void UpdateData(string Phone)
        {
            try
            {
                var token    = RSAHelper.Encrypt("ceshi").Replace("+", "%2B");
                var postData = string.Format("Token={0}&Phone={1}", token, Phone);

                var msg = WebClientHelper.WebClientRequset(postData, "api/Updater/UpgradePrograms");
                var obj = msg.FromJson <UpgradeProgramsModel>();

                if (obj.StatusCode == 200)
                {
                    //升级下来的名字
                    //  string filename = System.IO.Path.Combine(Application.StartupPath, "易考星升级包.zip");
                    //下载下来的是一个压缩包数据流//
                    System.IO.FileStream fs = new System.IO.FileStream(SqlDataRepertory.DB_Name, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                    fs.Write(Convert.FromBase64String(obj.Data.File), 0, Convert.FromBase64String(obj.Data.File).Length);
                    fs.Flush();
                    fs.Close();
                    textViewTips.Text = "升级成功";
                }
                else
                {
                    textViewTips.Text = "升级失败,请检查网络连接";
                }
            }
            catch (Exception ex)
            {
                textViewTips.Text = "升级失败" + ex.Message;
            }
        }
Ejemplo n.º 2
0
        public void BackUpData(string Phone)
        {
            try
            {
                var token = RSAHelper.Encrypt("ceshi").Replace("+", "%2B");
                //  var filePath = Path.Combine(Application.StartupPath, BackUpFileName);
                System.IO.FileStream fs = new System.IO.FileStream(SqlDataRepertory.DB_Name, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                Byte[] byteFile         = new byte[fs.Length];
                fs.Read(byteFile, 0, Convert.ToInt32(fs.Length));
                fs.Close();

                var postData = string.Format("Token={0}&Phone={1} &UploadFile={2}&&FileName={3}", token, Phone, Convert.ToBase64String(byteFile).Replace("+", "%2B"), SqlDataRepertory.DB_Name.Split('/')[SqlDataRepertory.DB_Name.Split('/').Length - 1]);
                var msg      = WebClientHelper.WebClientRequset(postData, "api/AndroidUpdater/BackupPrograms");
                var obj      = msg.FromJson <UpgradeProgramsModel>();
                //地图
                if (obj.StatusCode == 200)
                {
                    Toast.MakeText(this, "备份成功", ToastLength.Long);
                    textViewTips.Text = "备份成功";
                }
                else
                {
                    textViewTips.Text = "备份失败,请检查网络连接";
                }
            }
            catch (Exception ex)
            {
                textViewTips.Text = "备份失败" + ex.Message;
            }
        }