Example #1
0
        /// <summary>
        /// 处理公司档案信息
        /// </summary>
        /// <param name="type">档案相关信息类别</param>
        /// <param name="Info">档案信息内容</param>
        /// <param name="ID">档案信息编号</param>
        /// <param name="MineCode">煤矿编号</param>
        /// <returns></returns>
        public void TransCompanyData(string type, string Info, string ID, string MineCode)
        {
            TransCompanyModel Trans           = new TransCompanyModel(type, Info, ID, MineCode);
            string            ResponseMessage = string.Empty;

            if (type.IndexOf("AddQYZZ") >= 0 | type.IndexOf("AlterQYZZ") >= 0 | type.IndexOf("AddQYTZ") >= 0
                | type.IndexOf("AlterQYTZ") >= 0 | type.IndexOf("AddXGZL") >= 0 | type.IndexOf("AlterXGZL") >= 0)
            {
                byte[] ReadFileResult = GetFileContent();
                if (ReadFileResult == null)
                {
                    ResponseMessage = "{ error:'没有选择要上传的文件,请选择!', msg:'请选择要上传的文件'}";
                }
                else
                {
                    Trans.FileContent = ReadFileResult;
                    string ReturnMessage = Trans.GetJson;
                    switch (ReturnMessage)
                    {
                    case "True":
                        ResponseMessage = "{ error:'', msg:'恭喜,数据保存成功!'}";
                        break;

                    case "False":
                        ResponseMessage = "{ error:'数据保存失败!', msg:'数据保存失败,数据不允许重复或网络故障!'}";
                        break;
                    }
                }
            }
            else
            {
                ResponseMessage = Trans.GetJson;
            }
            Response.Write(ResponseMessage);
            Response.End();
        }
Example #2
0
        public void DownloadFile(string type, string ID)
        {
            TransCompanyModel transModel = new TransCompanyModel(type, "", ID, "");
            DataTable         dt         = transModel.DownloadFile();

            Response.Buffer      = true;
            Response.ContentType = "application/octet-stream";

            byte[] readfilecontent = (byte[])dt.Rows[0]["filecontent"];

            Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(dt.Rows[0]["filename"].ToString(), System.Text.Encoding.UTF8));

            Response.BinaryWrite(readfilecontent);
            Response.Flush();
            Response.End();

            //Response.OutputStream.Write(readfilecontent, 0, readfilecontent.Length);
            //Response.OutputStream.Flush();
            //Response.OutputStream.Close();
            //Response.Flush();
            //Response.End();

            //Response.OutputStream(dt.Rows[0]["filecontent"], 0, dt.Rows[0]["filecontent"]);
        }