/// <summary> /// 数据库下载 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1"></param> /// <param name="P2"></param> /// <param name="UserInfo"></param> public void DBDOWNLOAD(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { int id = Int32.Parse(P1); var sd = new SZHL_DBGLB().GetEntity(p => p.ID == id); if (sd != null) { FileInfo fi = new FileInfo(sd.Path); // 设置编码和附件格式 context.Response.Clear(); context.Response.ClearHeaders(); context.Response.Buffer = false; context.Response.ContentType = "application/octet-stream"; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Charset = ""; context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(sd.Name, Encoding.UTF8)); context.Response.AppendHeader("Content-Length", fi.Length.ToString()); context.Response.WriteFile(fi.FullName); context.Response.End(); } else { msg.ErrorMsg = "下载失败"; } }
/// <summary> /// 数据库备份还原列表 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1"></param> /// <param name="P2"></param> /// <param name="UserInfo"></param> public void GETDBBRLIST(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { string userName = UserInfo.User.UserName; string strWhere = " 1=1 and ComId=" + UserInfo.User.ComId; int DataID = -1; int.TryParse(context.Request.QueryString["ID"] ?? "-1", out DataID);//记录Id if (DataID != -1) { string strIsHasDataQX = new JH_Auth_QY_ModelB().ISHASDATAREADQX("DBGL", DataID, UserInfo); if (strIsHasDataQX == "Y") { strWhere += string.Format(" And ID = '{0}'", DataID); } } if (P1 != "") { int page = 0; int pagecount = 8; int.TryParse(context.Request.QueryString["p"] ?? "1", out page); int.TryParse(context.Request.QueryString["pagecount"] ?? "8", out pagecount);//页数 page = page == 0 ? 1 : page; int total = 0; DataTable dt = new DataTable(); switch (P1) { case "0": //手机单条数据 { //设置usercenter已读 new JH_Auth_User_CenterB().ReadMsg(UserInfo, DataID, "DBGL"); } break; case "1": //备份 { strWhere += " And Type ='" + P1 + "'"; } break; case "2": //还原 { strWhere += " And Type ='" + P1 + "'"; } break; } dt = new SZHL_DBGLB().GetDataPager(" SZHL_DBGL ", " *,case Type when '1' then '备份' when '2' then '还原' end as TypeName ", pagecount, page, " CRDate desc", strWhere, ref total); msg.Result = dt; msg.Result1 = total; } }