Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        URL = new Url();
        URL.GetUrl();
        //创建临时文件夹
        Directory.CreateDirectory(URL.Temp_path);
        Bar = GetComponent <Transform>();

        //获取服务器version文件
        Sd = new DownLoad(URL.Server_version, URL.Download_version, true);
        Sd.StartDownload();
        CompareVersion();
    }
Exemplo n.º 2
0
        // GET: admin/DownLoads/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DownLoad downLoad = db.DownLoads.Find(id);

            if (downLoad == null)
            {
                return(HttpNotFound());
            }
            return(View(downLoad));
        }
        public ActionResult DownloadSysDetail(DownLoad download)
        {
            int result = 0;

            if (download != null && download.ID > 0)
            {
                //修改
                result = downloadSer.UpdateDownLoad(download);
            }
            else
            {
                //添加
                result = downloadSer.AddDownLoad(download);
            }
            return(Json(new { retCode = result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DownloadSysDetail(int id)
        {
            DownLoad download = downloadSer.GetDownLoadDetail(id);

            if (download == null)
            {
                download = new DownLoad();
            }
            //lookuplist
            List <WebLookup>             looklist      = webCommSer.GetLookupList("DownLoad_type");
            IEnumerable <SelectListItem> IEnumlooklist = looklist.Select(com => new SelectListItem {
                Value = com.Code.ToString(), Text = com.Description
            });

            ViewBag.looklist = IEnumlooklist;
            //firsttype
            List <DownLoadType> DownLoadTypelist = new List <DownLoadType>();

            if (download.LookupCode != 0)
            {
                DownLoadTypelist         = downloadSer.GetDownLoadTypeOne(download.LookupCode);
                ViewBag.DownLoadTypelist = DownLoadTypelist.Select(com => new SelectListItem {
                    Value = com.id.ToString(), Text = com.name
                });
            }
            else
            {
                ViewBag.DownLoadTypelist = DownLoadTypelist;
            }
            //secondtype
            List <DownLoadType> DownLoadTypeTowlist = new List <DownLoadType>();

            if (download.firstID != 0)
            {
                DownLoadTypeTowlist         = downloadSer.GetDownLoadTypeTwo(download.firstID);
                ViewBag.DownLoadTypeTowlist = DownLoadTypeTowlist.Select(com => new SelectListItem {
                    Value = com.id.ToString(), Text = com.name
                });
            }
            else
            {
                ViewBag.DownLoadTypeTowlist = DownLoadTypeTowlist;
            }

            return(View(download));
        }
Exemplo n.º 5
0
 public int DeleteDownLoad(int id)
 {
     using (AIYunNetContext context = new AIYunNetContext())
     {
         DownLoad originalDownLoad = context.DownLoad.Find(id);
         if (originalDownLoad != null)
         {
             originalDownLoad.IsDelete = true;
             originalDownLoad.DeleteOn = DateTime.Now;
             context.SaveChanges();
             return(1);
         }
         else
         {
             return(0);
         }
     }
 }
Exemplo n.º 6
0
        public ActionResult Show(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DownLoad downLoad = db.DownLoads.Find(id);

            if (downLoad == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Title = downLoad.Title;
            ViewBag.Date  = downLoad.DateTime;
            //ViewBag.Introduction = downLoad.;
            ViewBag.Content = downLoad.Content;
            return(View());
        }
Exemplo n.º 7
0
        //Read Syuyaku info from oracle and output an excel file
        private void B_SYKDOWNLOAD_Click(object sender, EventArgs e)
        {
            if (GrdCheck() != 0 && StatusCheck(new string[] { "未処理", "集荷表", "集約" }) == true)
            {
                object Area = CB_AREA.SelectedValue;

                bool MNR = CH_MNR.Checked;
                bool SNK = CH_SNK.Checked;
                bool TYU = CH_TYU.Checked;
                bool CYU = CH_CYU.Checked;
                bool APU = CH_APU.Checked;

                bool Status1 = radioButton1.Checked;
                bool Status2 = radioButton3.Checked;
                bool Status3 = radioButton2.Checked;
                bool Status4 = radioButton4.Checked;
                bool Status5 = radioButton5.Checked;
                bool Status6 = radioButton6.Checked;
                bool Status7 = radioButton7.Checked;

                string SyukaBi1 = E_SYUKABI1.Value.ToString();
                string SyukaBi2 = E_SYUKABI2.Value.ToString();
                string Exlsrd1  = E_EXLSRD1.Value.ToString();
                string Exlsrd2  = E_EXLSRD2.Value.ToString();
                string Unchin1  = E_UNCHIN1.Value.ToString();
                string Unchin2  = E_UNCHIN2.Value.ToString();

                string OrderNO   = E_ORDERNO.Text;
                string HaisoBnNO = E_HAISOBNNO.Text;

                bool ZanKa = CH_ZANKA.Checked;


                DataGridView gr = GR_LIST;
                DownLoad     dl = new DownLoad();
                DataTable    ds = new DataTable();
                //検索
                ds = dl.SearchParameter(MNR, SNK, TYU, CYU, APU, Status1, Status2, Status3, Status4, Status5, Status6, Status7, SyukaBi1, SyukaBi2, Exlsrd1,
                                        Exlsrd2, Unchin1, Unchin2, OrderNO, HaisoBnNO, ZanKa, Area, !E_SYUKABI1.Checked, !E_SYUKABI2.Checked, !E_EXLSRD1.Checked, !E_EXLSRD2.Checked, !E_UNCHIN1.Checked, !E_UNCHIN2.Checked);
                //excel出力
                dl.SyuYakuDL(gr, ds);
            }
        }
Exemplo n.º 8
0
        public void Go_DowndLoad(object p)
        {
            if (Down_list_Selete == null)
            {
                return;
            }
            if (DownInfo[Down_list_Selete.ID].State == "下载")
            {
                return;
            }
            DownLoad    d    = new DownLoad();
            string      name = DownInfo[Down_list_Selete.ID].filename;
            Information inf  = d.RSerialization(name);

            if (inf.filename == null)
            {
                MessageBox.Show("文件不存在!");
                int i = Down_list_Selete.ID;
                DownInfo.RemoveAt(Down_list_Selete.ID);
                for (; i < DownInfo.Count; i++)
                {
                    DownInfo[i].ID = i;
                }
                Serialization(@"./config/ImportDownLoadInfo", DownInfo);
                return;
            }
            d.ContinuousDownLoad(inf);
            DownInfo[Down_list_Selete.ID].ID    = Down_d.Count;
            DownInfo[Down_list_Selete.ID].State = "下载";
            Down_d.Add(d);
            for (int i = 0; i < Down_d.Count; i++)
            {
                Down_d[i].Maxseepd = Limit_DownLoad_Speed;
                Down_d[i].Sum      = Down_d.Count;
            }
            Task <int> task = _client.DownloadRequestAsync(Down_list_Selete.Hash, d.Port);

            task.ContinueWith(T =>
            {
            });
            Serialization(@"./config/ImportDownLoadInfo", DownInfo);
        }
Exemplo n.º 9
0
        public ActionResult Edit([Bind(Include = "Id,Photo,Title,Content,IsTop,Clicks,DateTime")] DownLoad downLoad, HttpPostedFileBase Photo)
        {
            if (ModelState.IsValid)
            {
                if (Photo != null)
                {
                    if (Photo.ContentType.IndexOf("image", System.StringComparison.Ordinal) == -1)
                    {
                        ViewBag.message = "檔案類型錯誤";
                        return(View());
                    }

                    downLoad.Photo = Utility.SaveUpImage(Photo);
                    Utility.GenerateThumbnailImage(downLoad.Photo, Photo.InputStream, Server.MapPath("~/UpFile/Images"), "s", 167, 115);
                }
                db.Entry(downLoad).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(downLoad));
        }
Exemplo n.º 10
0
        public ActionResult DownLoadDetail(int id = 0)
        {
            DownLoad        model = DownSer.GetDownLoadDetail(id);
            List <DownLoad> list  = DownSer.GetDownLoadList(model.firstID);

            ViewBag.list = list;
            if (model.userid != 0)
            {
                if (model.usertype == "WebCompanyUser")
                {
                    WebCompany webCompany = webComSer.GetWebCompanyByUserID(model.userid);
                    ViewBag.webCompany = webCompany;
                }
                else if (model.usertype == "WebUser")
                {
                    WebPeople webpeople = WebPeoSer.GetWebPeopleByUserID(model.userid);
                    ViewBag.webpeople = webpeople;
                }
            }
            return(View(model));
        }
Exemplo n.º 11
0
        public void ProcessRequest(HttpContext context)
        {
            string fileName = context.Server.HtmlDecode(context.Request.QueryString["fileFullName"]);

            try
            {
                var speed = 0;
                Int32.TryParse(ConfigurationManager.AppSettings["DownloadSpeed"], out speed);

                if (File.Exists(fileName))
                {
                    DownLoad.DownloadFile(context, fileName, speed * 1024);
                }
                else
                {
                    context.Response.Write("<script  language='javascript'>window.alert('待下载的文件被移动或删除!');window.close(); </script>");
                }
            }
            catch (Exception)
            {
                context.Response.Write("<script  language='javascript'>window.alert('下载文件时发生异常!');window.close(); </script>");
            }
        }
 private void setInfo()
 {
     if (id > 0)
     {
         using (BLLDownLoad bll = new BLLDownLoad())
         {
             DownLoad dwinfor = bll.GetSingle(id);
             if (dwinfor != null)
             {
                 if (dwinfor.IsEnglish == 1)
                 {
                     rbtnIsChinese.Checked = true;
                 }
                 else if (dwinfor.IsEnglish == 2)
                 {
                     rbtnIsEnglish.Checked = true;
                 }
                 txtDLName.Text    = dwinfor.DLName;
                 txtRemarks.Text   = dwinfor.Remarks;
                 lblDLAddress.Text = dwinfor.DLAddress;
             }
         }
     }
 }
Exemplo n.º 13
0
        private void GetVideo(object obj)
        {
            RevMessageEvent e     = (RevMessageEvent)obj;
            string          fname = "";

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                IDbCommand command = conn.CreateCommand();
                if (e.message != null && (e.message.IndexOf("毕加猪") > -1 || e.message.IndexOf("bjz") > -1))
                {
                    command.CommandText = "SELECT * FROM JokerList WHERE joker LIKE 'QVideo-%' ORDER BY RANDOM() limit 1";
                }
                else
                {
                    command.CommandText = "SELECT * FROM JokerList  ORDER BY RANDOM() limit 1";
                }

                string      id     = "";
                IDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    id = reader["joker"].ToString();
                }
                reader.Close();
                string DownUrl = "";
                if (id != "")
                {
                    OnLog("获取ID:" + id);
                    if (!File.Exists(Robot.path + @"JokerNetease\" + id + ".mp4"))
                    {
                        WebClient web = new WebClient();
                        web.Encoding = Encoding.UTF8;

                        if (id.Length > 7 && id.Substring(0, 7) == "QVideo-")
                        {
                            string vid       = id.Replace("QVideo-", "");
                            string VideoInfp = web.DownloadString("https://h5wx.video.qq.com/getinfo?callback=j&platform=11001&charge=0&otype=json&ehost=https%3A%2F%2Fview.inews.qq.com&sphls=0&sb=1&nocache=0&_rnd=1613111258363&guid=1613111258363&appVer=V2.0Build9496&vids=" + vid + "&defaultfmt=auto&&_qv_rmt=VEZfwXxMA12593l4u=&_qv_rmt2=48nK/4IM1535169lQ=&sdtfrom=v3110&_=1613111256247&jsonpCallback=j");
                            VideoInfp = VideoInfp.Substring(2);
                            VideoInfp = VideoInfp.Substring(0, VideoInfp.Length - 1);
                            VideoInfo v = JsonHelper.DeserializeObject <VideoInfo>(VideoInfp);
                            if (v.msg == null)
                            {
                                vi[] vData = v.vl.vi;
                                foreach (vi vv in vData)
                                {
                                    string fvkey  = vv.fvkey;
                                    int    br     = vv.br;
                                    string ti     = vv.ti;
                                    string DownUi = vv.ul.ui[0].url;
                                    DownUrl = DownUi + vv.fn + "?vkey=" + fvkey + "&br=" + br + "&platform=2&fmt=auto&level=0&sdtfrom=v3110&guid=1613111258363";
                                }
                            }
                            else
                            {
                                OnLog("获取地址失败:" + VideoInfp);
                                return;
                            }
                        }
                        else
                        {
                            web.Headers.Add("referer: https://c.m.163.com/news/v/" + id + ".html?spss=newsapp");
                            string data = web.DownloadString("https://gw.m.163.com/nc-gateway/api/v1/video/detail/" + id);
                            DownUrl = new Regex(@"""mp4Hd_url""\:""(?<URI>.+?)""", RegexOptions.IgnoreCase | RegexOptions.Multiline).Match(data).Groups["URI"].ToString();
                            if (DownUrl == "")
                            {
                                DownUrl = new Regex(@"""mp4_url""\:""(?<URI>.+?)""", RegexOptions.IgnoreCase | RegexOptions.Multiline).Match(data).Groups["URI"].ToString();
                            }
                        }



                        if (DownUrl != "")
                        {
                            if (e.message_type == "private")
                            {
                                Friend.Send(e.user_id, "获取地址成功,正在下载视频");
                            }
                            OnLog("获取地址成功:" + DownUrl);
                            DownLoad down = new DownLoad(DownUrl, Robot.path + @"JokerNetease\" + id + ".mp4");
                            if (down.errorCode == 0)
                            {
                                if (e.message_type == "private")
                                {
                                    Friend.Send(e.user_id, "下载文件成功,用时:" + down.Time + "秒,等待发送");
                                }
                                OnLog("下载文件成功,用时:" + down.Time + "秒");
                                fname = Robot.path + @"JokerNetease\" + id + ".mp4";
                            }
                            else
                            {
                                if (e.message_type == "private")
                                {
                                    Friend.Send(e.user_id, "下载文件失败:" + down.errorMessage);
                                }
                                OnLog("下载文件失败:" + down.errorMessage);
                            }
                        }
                        else
                        {
                            OnLog("获取地址失败:" + DownUrl);
                        }
                    }
                    else
                    {
                        if (e.message_type == "private")
                        {
                            Friend.Send(e.user_id, "获取文件成功,等待发送");
                        }
                        OnLog("获取文件成功,等待发送");
                        fname = Robot.path + @"JokerNetease\" + id + ".mp4";
                    }
                }
                else
                {
                    OnLog("获取ID:" + command.CommandText);
                }
            }
            catch (Exception ex)
            {
                OnLog(ex.Message);
            }


            string Video = fname;

            if (Video != "")
            {
                if (e.message_type == "private")
                {
                    Friend.Send(e.user_id, "[CQ:video,file=file:///" + Video + "]");
                }
                if (e.message_type == "group" && e.group_id > 0)
                {
                    Cluster.Send(e.group_id, "[CQ:video,file=file:///" + Video + "]");
                }
            }
            else
            {
                OnLog("获取视频失败");
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (BLLDownLoad bll = new BLLDownLoad())
            {
                DownLoad obj = new DownLoad();

                if (id > 0)
                {
                    obj    = bll.GetSingle(id);
                    obj.ID = id;
                }
                obj.DLName    = txtDLName.Text.Trim().ToString();
                obj.DLAddTime = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                obj.Remarks   = txtRemarks.Text.ToString();
                if (Session["admin"] != null)
                {
                    AdminUser adminuser = GetAdminUser();
                    if (adminuser != null)
                    {
                        obj.DLAddName = adminuser.TrueName.ToString();
                    }
                }

                if (rbtnIsChinese.Checked == true)
                {
                    obj.IsEnglish = 1;
                }
                else if (rbtnIsEnglish.Checked == true)
                {
                    obj.IsEnglish = 2;
                }
                else
                {
                    ShowMsg("请选择语言类别!");
                    return;
                }


                #region   产品图片(前台产品图片来源于此)
                try
                {
                    if (this.UploadDLAddress.HasFile)
                    {
                        string extName = Path.GetExtension(UploadDLAddress.FileName);
                        string virFileFullName;
                        string fileName;
                        WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName);
                        if (UploadDLAddress.PostedFile.ContentLength < 5000000)//文件小于5M
                        {
                            UploadDLAddress.SaveAs(StringPlus.MapPath(virFileFullName));
                        }
                        else
                        {
                            ShowMsg("文件大小不能超过5M!");
                            return;
                        }
                        if (IsAllowedExtension(StringPlus.MapPath(virFileFullName)))
                        {
                            if (id > 0)
                            {//新增时无需删除
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).DLAddress)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).DLAddress));
                                }
                            }
                            obj.DLAddress = virFileFullName;
                        }
                        else
                        {
                            if (File.Exists(StringPlus.MapPath(virFileFullName)))
                            {
                                File.Delete(StringPlus.MapPath(virFileFullName));
                            }
                            ShowMsg("此文件类型不可以上传");
                            return;
                        }
                    }
                    else
                    {
                        obj.DLAddress = lblDLAddress.Text;
                    }
                }
                catch (DevNetException ex)
                {
                    ExceptionManager.ShowErrorMsg(this, ex);
                    return;
                }
                #endregion

                bll.Save(obj);

                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "cpDownLoadList.aspx");
                }
            }
        }
Exemplo n.º 15
0
 //成员
 protected string GetEditUrlf(object ID)
 {
     return(DownLoad.GetShowReference("AwardMember.aspx?id=" + ID, "成员"));
 }
Exemplo n.º 16
0
        private void CreatDowndLoadThread(object p)
        {
            FileInfoDataList SeleteInfo1 = (FileInfoDataList)p;

            if (SeleteInfo1 == null)
            {
                return;
            }
            #region MyRegion
            //if (SeleteInfo1.Hash.Length < 36)
            //{
            //    MessageBox.Show("根目录不能下载");
            //    return;
            //}
            #endregion

            if (SeleteInfo1.IsFolder == true)
            {
                MessageBox.Show("根目录不能下载");
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (ThreadStart) delegate
            {
                DownLoad d = new DownLoad();
                LoadInfo l = new LoadInfo();
                //l.name = @"DriverGenius2012";
                //l.type = "文件夹";
                d.RootDirectory = CurrentDownloadPath + @"\";
                l.name          = SeleteInfo1.Name;
                if (SeleteInfo1.Size == null)
                {
                    l.size = 0;
                }
                else
                {
                    l.size = (long)SeleteInfo1.Size;
                }
                l.type          = SeleteInfo1.Type;
                DownListInfo sm = d.CreatDownLoad(l);
                if (sm == null)
                {
                    return;
                }
                sm.ID    = d.ID = DownInfo.Count;
                sm.State = "下载";
                sm.Hash  = SeleteInfo.Hash;
                DownInfo.Add(sm);
                Down_d.Add(d);
                for (int i = 0; i < Down_d.Count; i++)
                {
                    Down_d[i].Maxseepd = Limit_DownLoad_Speed;
                    Down_d[i].Sum      = Down_d.Count;
                }
                d.Percentage += Refresh;
                //if (ShowSharefile == null)
                {
                    Task <int> task = _client.DownloadRequestAsync(SeleteInfo.Hash, d.Port);
                    task.ContinueWith(T =>
                    {
                    });
                }
                //else ShowSharefile.SendDirectoryName(@":\" + Directory + @"\" + l.name);
                Serialization(@"./config/ImportDownLoadInfo", DownInfo);
            });
        }
Exemplo n.º 17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/javascript";
            try
            {
                Stopwatch watch = new Stopwatch();
                watch.Start();
                string multiDownRptParams = context.Server.HtmlDecode(context.Request.QueryString["multiDownRptParams"]);
                var    rptIdArray         = multiDownRptParams.Split('@');
                var    fileUrlArray       = new List <string>();
                foreach (var rptId in rptIdArray)
                {
                    string json = MultiDelReport.HttpGet(context, rptId);
                    if (json == "[]" || json == null || json == "null" || json == string.Empty)
                    {
                        continue;
                    }
                    IList <ReportInfo> jsonArray = JsonConvert.DeserializeObject <IList <ReportInfo> >(json);
                    var data       = jsonArray[0];
                    var Status     = data.status;
                    var downRptUrl = string.Empty;
                    if (Status == "0")
                    {
                        downRptUrl = data.UnconfirmedUrl;
                    }
                    else
                    {
                        downRptUrl = data.ConfirmedUrl;
                    }
                    if (File.Exists(downRptUrl))
                    {
                        fileUrlArray.Add(downRptUrl);
                    }
                }
                //剔除重复的元素
                fileUrlArray = fileUrlArray.Distinct().ToList();
                if (!fileUrlArray.Any())
                {
                    context.Response.ContentType = "text/html";
                    context.Response.Write("<script  language='javascript'>window.alert('待下载的文件被移动或删除!');window.close(); </script>");
                }
                else
                {
                    Stopwatch watch2 = new Stopwatch();
                    watch2.Start();
                    string rootPath       = Path.GetTempPath();
                    string zipFileName    = "report_" + (DateTime.Now.Ticks / 10000);
                    string tempDirectory  = rootPath + "\\" + zipFileName; //压缩目录
                    string zipFullName    = tempDirectory + ".zip";        //压缩文件全名
                    string downloadAsName = "监测报表.zip";

                    if (Directory.Exists(tempDirectory))
                    {
                        Directory.Delete(tempDirectory, true);
                    }
                    Directory.CreateDirectory(tempDirectory);
                    foreach (var fileName in fileUrlArray)
                    {
                        var zipFileFullName = tempDirectory + "\\" + new FileInfo(fileName).Name;
                        if (File.Exists(fileName))
                        {
                            File.Copy(fileName, zipFileFullName);
                        }
                    }
                    watch2.Stop();
                    string time2 = watch2.ElapsedMilliseconds.ToString();
                    logger.Debug(string.Format("拷贝文件..总耗时..{0} 毫秒\r\n", time2));
                    Stopwatch watch3 = new Stopwatch();
                    watch3.Start();
                    CreateZip(tempDirectory, zipFullName);
                    watch3.Stop();
                    string time3 = watch3.ElapsedMilliseconds.ToString();
                    logger.Debug(string.Format("压缩文件..总耗时..{0} 毫秒\r\n", time3));
                    var tempPathDir = new DirectoryInfo(tempDirectory);
                    tempPathDir.Delete(true);
                    Stopwatch watch4 = new Stopwatch();
                    watch4.Start();
                    //var speed = 1*1024*1024; //1M
                    var speed = 0;
                    Int32.TryParse(ConfigurationManager.AppSettings["MultiDownloadSpeed"], out speed);
                    DownLoad.DownloadFile(context, zipFullName, speed * 1024 * 1024, downloadAsName);
                    watch4.Stop();
                    string time4 = watch4.ElapsedMilliseconds.ToString();
                    logger.Debug(string.Format("下载文件..总耗时..{0} 毫秒\r\n", time4));
                    watch.Stop();
                    string time = watch.ElapsedMilliseconds.ToString();
                    logger.Debug(string.Format("批量下载..总耗时..{0} 毫秒\r\n", time));
                    //删除临时文件
                    var zipFile = new FileInfo(zipFullName);
                    zipFile.Delete();
                }
            }
            catch (Exception)
            {
                context.Response.ContentType = "text/html";
                context.Response.Write("<script  language='javascript'>window.alert('下载文件时发生异常!');window.history.go(-2);window.opener.location.reload(); " + "</ " + "script>");
            }
        }
Exemplo n.º 18
0
 //下载
 protected string GetEditUrl(object ID)
 {
     return(DownLoad.GetShowReference("Operate.aspx?id=" + ID, "操作"));
 }
Exemplo n.º 19
0
 //成果名称
 protected string GetEditUrla(object ID)
 {
     return(DownLoad.GetShowReference("AchievementName.aspx?id=" + ID, "成果名称"));
 }
Exemplo n.º 20
0
 //获奖人
 protected string GetEditUrlp(object ID)
 {
     return(DownLoad.GetShowReference("AwardPeople.aspx?id=" + ID, "获奖人"));
 }
Exemplo n.º 21
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SyncView);

            Window.AddFlags(WindowManagerFlags.KeepScreenOn);

            settings = Common.GetSettings();

            files = new Dictionary <string, DLFile>();

            files.Add("App", new DLFile()
            {
                path = Path.Combine(Common.DatabaseFileDir(), settings.packageName), isNew = false
            });

            files.Add("Prs", new DLFile()
            {
                path = Path.Combine(Common.DatabaseFileDir(), "presents.xml.gz"), isNew = false
            });
//			filePath = Path.Combine(Common.DatabaseFileDir(), settings.packageName);

            vrsnAppCurr = PackageManager.GetPackageInfo(PackageName, PackageInfoFlags.Activities).VersionName;
//			vrsnPrsCurr = settings.vrsnOfPresents;

            client = new WebClient();

            client.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => {
                if (File.Exists(files["Prs"].path))
                {
                    string fileText = File.ReadAllText(files["Prs"].path);
                    vrsnPrsCurr = UploadFiles.GetMd5Hash(fileText);
                }
                else
                {
                    vrsnPrsCurr = "";
                };
                try {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(e.Result);
                    files["App"].vrsnNew = doc.GetElementById("versionApp").InnerText;
                    files["Prs"].vrsnNew = doc.GetElementById("versionPrs").InnerText;
                    files["App"].isNew   = !bool.Equals(vrsnAppCurr, files["App"].vrsnNew);
                    files["Prs"].isNew   = !bool.Equals(vrsnPrsCurr, files["Prs"].vrsnNew);

                    if ((files["App"].isNew) || (files["Prs"].isNew))
                    {
                        RunOnUiThread(() => CheckLoadPackage());
                    }
                } catch (Exception exc) {
                    RunOnUiThread(() => Toast.MakeText(this, exc.Message, ToastLength.Long).Show());
                }
            };

            client.DownloadDataCompleted += (object sender, DownloadDataCompletedEventArgs e) => {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                ;
                try {
                    File.WriteAllBytes(filePath, e.Result);
                    RunOnUiThread(() => txtProgress.Text = "Загрузка окончена");
                    RunOnUiThread(() => Toast.MakeText(this, "ALL", ToastLength.Short).Show());
                    RunOnUiThread(() => pB.Visibility = ViewStates.Gone);
                    RunOnUiThread(() => CheckLoadPackage());
                } catch (Exception exc) {
                    RunOnUiThread(() => Toast.MakeText(this, exc.Message, ToastLength.Long).Show());
                }
            };

            client.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) => {
                if (pB.Visibility == ViewStates.Visible)
                {
                    RunOnUiThread(() => pB.Activated = true);
                    RunOnUiThread(() => pB.Max       = (int)e.TotalBytesToReceive);
                    RunOnUiThread(() => pB.Progress  = (int)e.BytesReceived);
                }
            };

            pB            = FindViewById <ProgressBar> (Resource.Id.StatusProgress);
            pB.Visibility = ViewStates.Gone;

            txtVersion      = FindViewById <TextView> (Resource.Id.txtVersion);
            txtVersion.Text = "Текущая версия программы: " + PackageManager.GetPackageInfo(PackageName, PackageInfoFlags.Activities).VersionName;

            btnUpdateApp            = FindViewById <Button> (Resource.Id.btnUpdateApp);
            btnUpdateApp.Visibility = ViewStates.Gone;

            btnDownLoadPresents            = FindViewById <Button> (Resource.Id.btnDownLoadPresents);
            btnDownLoadPresents.Visibility = ViewStates.Gone;
            btnDownLoadPresents.Click     += (object sender, EventArgs e) => {
                pB.Visibility = ViewStates.Visible;
                if (DownLoad.HasConnection(this) && !client.IsBusy)
                {
                    filePath = files ["Prs"].path;
                    client.DownloadDataAsync(new Uri(settings.dlSite + "presents.xml.gz"));
                    files ["Prs"].isNew            = false;
                    btnDownLoadPresents.Visibility = ViewStates.Gone;
                }
                else
                {
                    btnDownLoadPresents.Text = "Подождите окончания другой загрузки...";
                }
            };


            txtProgress               = FindViewById <TextView> (Resource.Id.txtProgress);
            txtProgress.Text          = "Идет сверка информации с сервером...";
            btnUploadFiles            = FindViewById <Button> (Resource.Id.btnUploadFiles);
            btnUploadFiles.Visibility = ViewStates.Gone;

            btnUploadFiles.Click += (object sender, EventArgs e) => {
                var t = new Thread(() => {
                    string loadResult = "";
                    RunOnUiThread(() => pB.Visibility    = ViewStates.Visible);
                    RunOnUiThread(() => pB.Activated     = true);
                    RunOnUiThread(() => pB.Max           = 5);
                    RunOnUiThread(() => pB.Progress      = 0);
                    RunOnUiThread(() => txtProgress.Text = "Идет синхронизация с сервером...");
                    loadResult = UploadFiles.LoadFile("Settings");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 1);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    loadResult = UploadFiles.LoadFile("DoctorDB");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 2);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    //RunOnUiThread(() => txtProgress.Text = "load HospitalDB");
                    loadResult = UploadFiles.LoadFile("HospitalDB");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 3);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    //RunOnUiThread(() => txtProgress.Text = "load Demonstration");
                    loadResult = UploadFiles.LoadFile("Demonstration");
                    Console.WriteLine(loadResult);
                    RunOnUiThread(() => pB.Progress = 4);
                    //RunOnUiThread(() => txtProgress.Text = loadResult);
                    Thread.Sleep(1000);
                    if (loadResult.Contains("FILE SAVED"))
                    {
                        string reportString = UploadFiles.DownLoadReport();

                        DemonstrationManager.CurrentDemonstrationToArchive();

                        var serializer = new XmlSerializer(typeof(List <Report>));
                        using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(reportString))) {
                            List <Report> dlReport  = (List <Report>)serializer.Deserialize(stream);
                            List <Report> curReport = (List <Report>)ReportManager.GetReports();
                            if (curReport.Count == 0)
                            {
                                curReport = dlReport;
                            }
                            else
                            {
                                for (int dl = 0; dl < dlReport.Count; dl++)
                                {
                                    var report = curReport.Find(r => r.doctorID == dlReport[dl].doctorID);
                                    if (report == null)
                                    {
                                        curReport.Add(dlReport[dl]);
                                    }
                                    else
                                    {
                                        for (int i = 0; i < dlReport[dl].rItems.Count; i++)
                                        {
                                            var rItem = report.rItems.Find(ri => ri.weekNum == dlReport[dl].rItems[i].weekNum);
                                            if (rItem == null)
                                            {
                                                report.rItems.Add(dlReport[dl].rItems[i]);
                                            }
                                            else
                                            {
                                                rItem.visitCount = rItem.visitCount + dlReport[dl].rItems[i].visitCount;
                                            }
                                        }
                                    }
                                }
                            }
                            if (ReportManager.SaveReports(curReport))
                            {
                                Console.WriteLine("Report saved...");
                                //RunOnUiThread(() => txtProgress.Text = "Report saved...");
                            }
                            else
                            {
                                Console.WriteLine("Report not saved...");
                                //RunOnUiThread(() => txtProgress.Text = "Report not saved...");
                            }
                        }
                    }
                    RunOnUiThread(() => pB.Progress = 5);
                    Thread.Sleep(2500);
                    Console.WriteLine("Uploading finished...");
                    RunOnUiThread(() => pB.Visibility             = ViewStates.Gone);
                    RunOnUiThread(() => txtProgress.Visibility    = ViewStates.Visible);
                    RunOnUiThread(() => txtProgress.Text          = "Синхронизация успешно завершена.");
                    RunOnUiThread(() => btnUploadFiles.Visibility = ViewStates.Invisible);
                }
                                   );
                t.Start();
                //RunOnUiThread(() => pB.Activated = true);
                //RunOnUiThread(() => pB.Max = (int)e.TotalBytesToReceive);
                //RunOnUiThread(() => pB.Progress = (int)e.BytesReceived);
                //txtProgress.Text = "load DoctorDB";
                //txtProgress.Text = UploadFiles.LoadFile("DoctorDB");//Toast.MakeText(this, "Toast within progress dialog.", ToastLength.Long).Show());
                //txtProgress.Text = "load HospitalDB";
                //txtProgress.Text = UploadFiles.LoadFile("HospitalDB");
                //Console.WriteLine ("Uploading finished...");
            };
        }