zoukankan      html  css  js  c++  java
  • ashx获取Oracle数据库图片

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using DbLib.db;
    using System.Data;
    using DbLib.Common;
    using FrameWork.Modal;
    using FrameWork;
    using System.IO;
    using Newtonsoft.Json;
    using System.Text.RegularExpressions;
    using System.Data.OracleClient;
    namespace website.handler
    {
        /// <summary>
        /// htbsicon 的摘要说明
        /// </summary>
        public class htbsicon : IHttpHandler
        {
            public class File_info
            {
                public string name;
                public int type;
                public string path;
            }
    
            public void ProcessRequest(HttpContext context)
           
            {
              
                context.Response.ContentType = "text/plain";
                StreamReader s = null;
                try
                {
               
                        string port = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();//获取端口
                        string UrlGetlist = "http://localhost:" + port + "/handler/DBhandler/OperationDBHandler.ashx?funcName=SEL"; //查询方法
                        string requst = Common.HttpPost(UrlGetlist, "&tablename=htbsmap&id=0");  //返回数据
                        WebCommon.OutPutString(requst);
                        requst = ConvertJsonString(requst);
                        return;
                      
                       
                }
                catch
                {
                  
                }
                finally
                {
                    if (s != null)
                    {
                        s.Close();
                    }
                }
            }
     private string ConvertJsonString(string str)
            {
                //格式化json字符串
                JsonSerializer serializer = new JsonSerializer();
                TextReader tr = new StringReader(str);
                JsonTextReader jtr = new JsonTextReader(tr);
                object obj = serializer.Deserialize(jtr);
                if (obj != null)
                {
                    StringWriter textWriter = new StringWriter();
                    JsonTextWriter jsonWriter = new JsonTextWriter(textWriter)
                    {
                        Formatting = Formatting.Indented,
                        Indentation = 4,
                        IndentChar = ' '
                    };
                    serializer.Serialize(jsonWriter, obj);
                    return textWriter.ToString();
                }
                else
                {
                    return str;
                }
            }
    
            public void Digui(string path, List<File_info> list)
            {
                string[] filelist = Directory.GetFiles(path);
                Regex reg = new Regex("_.*");
                for (int n = 0; n < filelist.Length; n++)
                {
                    File_info f = new File_info();
                    int index = filelist[n].LastIndexOf('\');
                    int index3 = filelist[n].LastIndexOf("_");
                    int index2 = filelist[n].IndexOf("\images");
                    if (index != -1)
                    {
    
                        f.name = System.IO.Path.GetFileNameWithoutExtension(filelist[n]);
                        f.name = reg.Replace(f.name, "");
                        f.path = filelist[n].Substring(index2 + 1).Replace("\", "/");
                        list.Add(f);
                    }
                }
                string[] dirlist = Directory.GetDirectories(path);
                for (int n = 0; n < dirlist.Length; n++)
                {
                    DirectoryInfo d = new DirectoryInfo(dirlist[n]);
    
                    File_info f = new File_info() { name = d.Name, type = 1 };
                    list.Add(f);
                    Digui(dirlist[n], list);
                }
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
  • 相关阅读:
    1104 Sum of Number Segments (20 分)(数学问题)
    1092 To Buy or Not to Buy (20 分)(hash散列)
    1082 Read Number in Chinese (25 分)(字符串处理)【背】
    1105 Spiral Matrix (25 分)(模拟)
    初识网络安全及搭建网站(内网)
    HTML5开发者需要了解的技巧和工具汇总(转)
    native+web开发模式之web前端经验分享
    移动平台3G手机网站前端开发布局技巧汇总(转)
    Asp.net 中图片存储数据库以及页面读取显示通用方法详解附源码下载
    使用H3Viewer来查看VS2010的帮助文档
  • 原文地址:https://www.cnblogs.com/maoye520/p/9790265.html
Copyright © 2011-2022 走看看