⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 framecity.cs

📁 结构很好的三层数据访问组件。开放源码。是微软企业库数据访问的替代产品之一。
💻 CS
字号:
namespace FrameCountry
{
    using System;
    using System.IO;
    using System.Reflection;
    using System.Text;

    internal class FrameCity
    {
        private string ClassAlias = "CT";

        private string ChangeDateTimeToFillStyle(DateTime dealDateTime)
        {
            int num = ((dealDateTime.Year * 0x2710) + (dealDateTime.Month * 100)) + dealDateTime.Day;
            int num2 = ((0xf4240 + (dealDateTime.Hour * 0x2710)) + (dealDateTime.Minute * 100)) + dealDateTime.Second;
            return (num.ToString().Substring(2, 6) + num2.ToString().Substring(1, 6));
        }

        public string DealErrorInfo(string classAlias, string functionAlias, string ErrorInfo)
        {
            if (ErrorInfo.IndexOf("◇") == 0)
            {
                return (classAlias + functionAlias + "." + ErrorInfo.Substring(1, ErrorInfo.Length - 1));
            }
            return (classAlias + functionAlias + ":\n\r" + ErrorInfo);
        }

        public string GetValueData(string ValueData, string DBType, string DataType)
        {
            string s = ValueData;
            string str = DBType.ToLower();
            if (str != null)
            {
                str = string.IsInterned(str);
                if (str == "oracle")
                {
                    switch (DataType.ToLower())
                    {
                        case "string":
                            return ("'" + s + "'");

                        case "datetime":
                        {
                            DateTime time = new DateTime();
                            time = DateTime.Parse(s);
                            return ("to_date('" + time.ToString() + "','yyyy-mm-dd HH24:MI:SS')");
                        }
                        case "number":
                            return s;
                    }
                    return s;
                }
                if (str == "sqlserver")
                {
                    switch (DataType.ToLower())
                    {
                        case "string":
                            return ("'" + s + "'");

                        case "datetime":
                            return ("'" + s + "'");

                        case "number":
                            return s;
                    }
                    return s;
                }
                if (str == "db2")
                {
                    switch (DataType.ToLower())
                    {
                        case "string":
                            return ("'" + s + "'");

                        case "datetime":
                            return ("'" + s + "'");

                        case "number":
                            return s;
                    }
                    return s;
                }
                if (str != "access2000")
                {
                    return s;
                }
                switch (DataType.ToLower())
                {
                    case "string":
                        return ("'" + s + "'");

                    case "datetime":
                        return ("#" + s + "#");
                }
            }
            return s;
        }

        public bool WriteFrameShipLog(string WriteStr, ref string ErrorInfo)
        {
            string functionAlias = "03";
            bool flag = false;
            try
            {
                StreamWriter writer;
                string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
                directoryName = directoryName.Substring(6, directoryName.Length - 6);
                if (!Directory.Exists(directoryName + @"\FrameCountryLog\FrameShipLog"))
                {
                    Directory.CreateDirectory(directoryName + @"\FrameCountryLog\FrameShipLog");
                }
                string path = directoryName + @"\FrameCountryLog\FrameShipLog\FrameShipLog" + this.ChangeDateTimeToFillStyle(DateTime.Today).Substring(0, 6) + ".log";
                if (File.Exists(path))
                {
                    writer = new StreamWriter(path, true, Encoding.Default);
                }
                else
                {
                    flag = true;
                    writer = new StreamWriter(path, false, Encoding.Default);
                }
                WriteStr = WriteStr.Replace("\r", "");
                for (int i = 0; i < 9; i++)
                {
                    WriteStr = WriteStr.Replace("  ", " ");
                }
                if (flag)
                {
                    writer.Write("┏━━━━━━━━━━━ FrameCountry ━━━━━━━━━━━┓\r\n\tFrameCountry是采用.Net的开发平台,专注于数据库访问层功能的架构系统,为用户提供便捷、规范、强大的功能,提升开发效率。\r\n┣━━━━━━┫FrameShip\r\n\t记录表示层向业务层传输的XML字符串。\r\n┣━━━━━━┫Relation\r\n作者:李峥\r\n邮箱:zh.li@vip.sina.com\r\n  QQ:42270101\r\n博客:http://blog.csdn.net/lizheng82\r\n┗━━━━━━━━━━━━━ End ━━━━━━━━━━━━┛");
                    writer.Write("\n\r\n\r");
                }
                writer.Write(WriteStr);
                writer.Write("\n\r\n\r");
                writer.Close();
            }
            catch (Exception exception)
            {
                ErrorInfo = "写入日志文件错误!\n\r错误信息如下:\n\r" + exception.Message;
                ErrorInfo = this.DealErrorInfo(this.ClassAlias, functionAlias, ErrorInfo);
                return false;
            }
            return true;
        }

        public bool WriteFrameTownLog(string ConFile, string WriteStr, ref string ErrorInfo)
        {
            string functionAlias = "02";
            bool flag = false;
            try
            {
                StreamWriter writer;
                string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
                directoryName = directoryName.Substring(6, directoryName.Length - 6);
                if (!Directory.Exists(directoryName + @"\FrameCountryLog\FrameTownLog"))
                {
                    Directory.CreateDirectory(directoryName + @"\FrameCountryLog\FrameTownLog");
                }
                string path = directoryName + @"\FrameCountryLog\FrameTownLog\" + ConFile + this.ChangeDateTimeToFillStyle(DateTime.Today).Substring(0, 6) + ".log";
                if (File.Exists(path))
                {
                    writer = new StreamWriter(path, true, Encoding.Default);
                }
                else
                {
                    flag = true;
                    writer = new StreamWriter(path, false, Encoding.Default);
                }
                WriteStr = WriteStr.Replace("\r", "");
                for (int i = 0; i < 9; i++)
                {
                    WriteStr = WriteStr.Replace("  ", " ");
                }
                if (flag)
                {
                    writer.Write("┏━━━━━━━━━━━ FrameCountry ━━━━━━━━━━━┓\r\n\tFrameCountry是采用.Net的开发平台,专注于数据库访问层功能的架构系统,为用户提供便捷、规范、强大的功能,提升开发效率。\r\n┣━━━━━━┫FrameTown\r\n\t架构主执行类,接收FrameBridge对象的处理请求,完成对数据库操作,返回结果信息。\r\n┣━━━━━━┫Relation\r\n作者:李峥\r\n邮箱:zh.li@vip.sina.com\r\n  QQ:42270101\r\n博客:http://blog.csdn.net/lizheng82\r\n┗━━━━━━━━━━━━━ End ━━━━━━━━━━━━┛");
                    writer.Write("\n\r\n\r");
                }
                writer.Write(WriteStr);
                writer.Write("\n\r\n\r");
                writer.Close();
            }
            catch (Exception exception)
            {
                ErrorInfo = "写入日志文件错误!\n\r错误信息如下:\n\r" + exception.Message;
                ErrorInfo = this.DealErrorInfo(this.ClassAlias, functionAlias, ErrorInfo);
                return false;
            }
            return true;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -