Ejemplo n.º 1
0
    /// <summary>
    /// HttpResponse.AddHeader 方法--将一个 HTTP 头添加到输出流。
    /// public void AddHeader( string name, string value )
    /// name                              要添加 value 的 HTTP 头名称。
    /// value                             要添加到头中的字符串。
    /// Response.Clear() 方法:           清除缓冲区流中的所有内容输出
    /// HttpRequest.ContentType    属性: 获取或设置传入请求的 MIME 内容类型
    /// HttpResponse.BinaryWrite() 方法: 将一个二进制字符串写入 HTTP 输出流。
    /// HttpResponse.Flush()       方法: 向客户端发送当前所有缓冲的输出
    /// HttpResponse.WriteFile()   方法: 将指定的文件直接写入 HTTP 响应输出流。
    /// HttpResponse.End()         方法: 将当前所有缓冲的输出发送到客户端,停止该页的执行,
    ///                                   并引发 EndRequest 事件。
    /// </summary>
    /// <param name="fileName"></param> 客户端保存的文件名
    /// <param name="filePath"></param> 服务端文件路径
    private void down_load_file()
    {
        string _fileName = RequestClass.GetString("fileName");
        int    _type     = RequestClass.GetInt("T", 0);
        string _Doc      = string.Empty;

        if (_type == 1)
        {
            _Doc = WebConfig.GetAppSettingString("DownFile");
        }
        else if (_type == 2)
        {
            _Doc = "plupload\\VINFile\\";
        }
        string _url = HttpContext.Current.Request.PhysicalApplicationPath
                      + "\\" + _Doc
                      + "\\" + _fileName;

        //以字符流的形式下载文件   File.OpenWrite("d:\\excel.csv")
        //FileStream fs = new FileStream(filePath, FileMode.Open);
        FileStream fs = File.OpenRead(_url);

        byte[] bytes = new byte[(int)fs.Length];
        fs.Read(bytes, 0, bytes.Length);
        fs.Close();
        Response.ContentType = "application/-excel";
        //通知浏览器下载文件而不是打开
        Response.AddHeader("Content-Disposition", "attachment;filename="
                           + HttpUtility.UrlEncode(_fileName, System.Text.Encoding.UTF8));
        Response.BinaryWrite(bytes);
        Response.Flush();
        Response.End();
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 退出登录并返回指定页面,指定页面清除Cookie
        /// </summary>
        /// <param name="Sessionname">Sessionname</param>
        /// <param name="Url">清除Session后返回的指定页面,清除Cookie</param>
        public static void LoginOut(string Sessionname, string Url)
        {
            HttpContext.Current.Session[Sessionname] = null;

            if ("" == Url)
            {
                Url = WebConfig.GetAppSettingString("LoginOutUrl");
            }
            HttpContext.Current.Response.Redirect(Url);
        }
Ejemplo n.º 3
0
    private void EventHandle_CLICK_V1001_02(xml x)
    {
        string Title = "宝马7系现金优惠18万 购车送大礼包";
        //string Title = string.Empty;
        string Description = "宝马7系现金优惠18万 购车送大礼包:";
        string PicUrl      = WebConfig.GetAppSettingString("Wechat_Web_Default_Image_Url");
        //string PicUrl = string.Empty;
        string url    = WebConfig.GetAppSettingString("Wechat_Web_Url") + "upload/1410101043493425.html";
        string senCon = wechatHandle.SendPassive_image_text(x.FromUserName, x.ToUserName, Title, Description, PicUrl, url);

        _http.Response.Write(senCon);
        CRMTree.BLL.BL_Wechat.SendCustom_News(x.FromUserName, 51);
    }
Ejemplo n.º 4
0
 /// <summary>
 /// 退出登录
 /// </summary>
 /// <param name="AllowEmailNonActivated">如果为false退出登录并返回指定页面,指定页面清除Cookie,true直接清除Cookie跟Session</param>
 /// <param name="Sessionname">Sessionname</param>
 /// <param name="Url">清除Session后返回的指定页面,清除Cookie</param>
 public static void LoginOut(bool AllowEmailNonActivated, string Sessionname, string Url)
 {
     if (!AllowEmailNonActivated)
     {
         LoginOut(Sessionname, Url);
     }
     HttpContext.Current.Session[Sessionname] = null;
     //Security.ClearCookies();
     if ("" == Url)
     {
         Url = WebConfig.GetAppSettingString("LoginOutUrl");
     }
     HttpContext.Current.Response.Redirect(Url);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 写入日志文件
        /// </summary>
        /// <param name="input"></param>
        /// <param name="fileid"></param>
        /// <param name="clientid"></param>
        public static void WriteLogFile(string input)
        {
            string path = WebConfig.GetAppSettingString("CSIFilePath");
            //指定日志文件的目录
            string fname       = path + "\\UploadFiles\\UploadLogs\\System\\logfile-" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            string strSavePath = path + "\\UploadFiles\\UploadLogs\\System";

            if (!System.IO.Directory.Exists(strSavePath))
            {
                System.IO.Directory.CreateDirectory(strSavePath);
            }
            FileInfo finfo = new FileInfo(fname);

            if (finfo.Exists && finfo.Length > 222048)
            {
                finfo.Delete();
                FileStream   fs     = new FileStream(fname, FileMode.Create);
                StreamWriter writer = new StreamWriter(fs);
                writer.WriteLine("----------");
                writer.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                writer.WriteLine(input);
                writer.WriteLine("----------");
                writer.Flush();
                writer.Close();
                fs.Close();
            }
            else
            {
                using (FileStream fs = finfo.OpenWrite())
                {
                    StreamWriter w = new StreamWriter(fs);
                    w.BaseStream.Seek(0, SeekOrigin.End);
                    w.WriteLine("----------");
                    w.WriteLine("{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    w.WriteLine(input);
                    w.WriteLine("----------");
                    w.Flush();
                    w.Close();
                }
            }
        }