示例#1
0
        /// <summary>
        /// 得到某个Node
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public XmlNode ReadNodeFromNodeListByNodeAttr(XmlNodeList nodeList, string attrName, string attrValue)
        {
            try
            {
                foreach (XmlNode xn in  nodeList)
                {
                    if (attrName == "")
                    {
                        return(null);
                    }

                    string factAttr = NodeAtt(xn, attrName);
                    if (factAttr != "")
                    {
                        if (factAttr.Equals(attrValue))
                        {
                            return(xn);
                        }
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取xml出错" + exception.ToString());
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// 读取某个文件某个路径下的某个属性值
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string ReadAttrFromFile(string fileName, string path, string name)
        {
            string XMLFileName = System.AppDomain.CurrentDomain.BaseDirectory + @"config\" + fileName;

            try
            {
                XmlDocument xd = new System.Xml.XmlDocument();
                xd.Load(XMLFileName);

                foreach (XmlNode xn in xd.SelectNodes(path))
                {
                    if (name == "")
                    {
                        return("");
                    }
                    string attrName = NodeAtt(xn, name);
                    if (attrName != "")
                    {
                        return(attrName);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取!" + fileName + "出错" + exception.ToString());
            }
            return(null);
        }
示例#3
0
        /// <summary>
        /// 得到某个Node
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public XmlNode ReadNodeFromNodeListByNodeName(XmlNodeList nodeList, string nodeName)
        {
            try
            {
                foreach (XmlNode xn in  nodeList)
                {
                    if (nodeName == "")
                    {
                        return(xn);
                    }

                    if (nodeName.Equals(xn.Name))
                    {
                        return(xn);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取xml出错" + exception.ToString());
            }
            return(null);
        }
示例#4
0
 public void UpdateBySql(string sqlUpdate)
 {
     try
     {
         System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(sqlUpdate, managerDB.OpenApp());
                command.CommandType             = System.Data.CommandType.Text;
         command.ExecuteNonQuery();
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "更新数据出错!" + exception.ToString());
     }
 }
示例#5
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            try
            {
                FilterContext = filterContext;
                Log           = AppLogFactory.Create <ActionTrackerAttribute>();
                Log.Trace("Executing {0}.{1}", ControllerName, ActionName);
                Watch = Stopwatch.StartNew();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
示例#6
0
        public object ScalarBySql(string sql)
        {
            object dr = null;

            try
            {
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(sql, managerDB.OpenApp());
                       dr = command.ExecuteScalar();
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "查询数据出错!" + exception.ToString());
            }
            return(dr);
        }
示例#7
0
        /// <summary>
        /// 根据条件(传入的DataSet)查询数据
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public DataSet SelectByCondition(String table, string where)
        {
            DataSet ds = new DataSet();

            try
            {
                string querySql = table + where;
                System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(querySql, managerDB.OpenApp());

                adapter.Fill(ds, table);
            }
            catch (System.Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "查询数据表" + table + "出错!" + exception.ToString());
            }
            return(ds);
        }
示例#8
0
 public void UpdateByProcedure(string procedureName, System.Data.OleDb.OleDbParameter[] sqlParameter)
 {
     try
     {
         System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(procedureName, managerDB.OpenApp());
               command.CommandType = System.Data.CommandType.StoredProcedure;
         for (int i = 0; i < sqlParameter.Length; i++)
         {
             command.Parameters.Add(sqlParameter[i]);
         }
         command.ExecuteNonQuery();
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "执行存储过程出错!" + exception.ToString());
     }
 }
        protected void Application_Start()
        {
            //var target = LogManagement.GetAsyncDbWrapperTarget();
            //target.OverflowAction = AsyncTargetWrapperOverflowAction.Grow;

            var log = AppLogFactory.Create <MvcApplication>();

            log.Info("Application starting");

            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
            AutoMapping.CreateMaps();

            log.Info("Application started");
        }
示例#10
0
        /// <summary>
        /// 取得数据库连接
        /// </summary>
        override public System.Data.OleDb.OleDbConnection OpenApp()
        {
            string connectStr = null;

            try
            {
                if (connect == null)
                {
                    connectStr = "Provider=MSDAORA;User ID=" + this.ServerApplicationUserID + ";Data Source=" + this.ServerApplicationDB + ";Password="******"连接SqlServer数据库失败!连接字符串:" + connectStr + exception.ToString());
            }
            return(connect);
        }
示例#11
0
        /// <summary>
        /// 得到NodeList
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public XmlNodeList ReadNodeListFromFile(string fileName, string path)
        {
            string XMLFileName = System.AppDomain.CurrentDomain.BaseDirectory + @"config\" + fileName;

            try
            {
                XmlDocument xd = new System.Xml.XmlDocument();
                xd.Load(XMLFileName);

                System.Xml.XmlNode     nodeFirst = xd.SelectSingleNode(path);
                System.Xml.XmlNodeList nodeList  = nodeFirst.ChildNodes;
                return(nodeList);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取!" + fileName + "出错" + exception.ToString());
            }
            return(null);
        }
示例#12
0
 /// <summary>
 /// 得到某个Node下所有的NodeList
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="path"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public XmlNodeList ReadNodeListFromNode(XmlNode node)
 {
     try
     {
         if (node.HasChildNodes == false)
         {
             return(null);
         }
         else
         {
             return(node.ChildNodes);
         }
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "根据Node得NodeList出错!" + exception.ToString());
     }
     return(null);
 }
示例#13
0
 public System.Data.OleDb.OleDbDataReader SelectByProcedure(string procedureName, System.Data.SqlClient.SqlParameter[] sqlParameter)
 {
     System.Data.OleDb.OleDbDataReader dr = null;
     try
     {
         System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(procedureName, managerDB.OpenApp());
               command.CommandType = System.Data.CommandType.StoredProcedure;
         for (int i = 0; i < sqlParameter.Length; i++)
         {
             command.Parameters.Add(sqlParameter[i]);
         }
         dr = command.ExecuteReader();
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "执行存储过程" + procedureName + "查询数据出错!" + exception.ToString());
     }
     return(dr);
 }
        public void OnException(ExceptionContext exceptionContext)
        {
            if (exceptionContext.ExceptionHandled)
            {
                return;
            }

            if (ConfigurationManager.AppSettings["enableErrorPages"] == "false")
            {
                AppLogFactory.Create <AppErrorHandlerAttribute>().Error(
                    "Unexpected error. enableErrorPages is false, skipping detailed error gathering. Error was: {0}",
                    exceptionContext.Exception.ToString());
                return;
            }

            Ensure.That(Reporter, "Reporter").IsNotNull();
            Reporter.ReportException(exceptionContext);

            SetErrorViewResult(exceptionContext);
        }
示例#15
0
        /// <summary>
        /// 取得数据库连接
        /// </summary>
        override public System.Data.OleDb.OleDbConnection OpenApp()
        {
            string connectStr = null;

            try
            {
                if (connect == null)
                {
                    connectStr  = "Provider=SQLOLEDB.1;Persist Security Info=True;";
                    connectStr += "Data Source=" + this.DbServer + "; Initial Catalog=" + this.ServerApplicationDB;
                    connectStr += ";User ID=" + this.ServerApplicationUserID + "; Password="******"连接SqlServer数据库失败!连接字符串:" + connectStr + exception.ToString());
            }
            return(connect);
        }
示例#16
0
        /// <summary>
        /// 读取某个节点下的某个属性值
        /// </summary>
        /// <param name="node"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string ReadAttrFromPath(XmlNode node, string path, string name)
        {
            if (node.HasChildNodes == false)
            {
                string attrName = NodeAtt(node, name);
                if (attrName != "")
                {
                    return(attrName);
                }
                else
                {
                    return("");
                }
            }


            try
            {
                foreach (XmlNode xn in node.SelectNodes(path))
                {
                    if (name == "")
                    {
                        return("");
                    }
                    string attrName = NodeAtt(xn, name);
                    if (attrName != "")
                    {
                        return(attrName);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取!" + path + "出错" + exception.ToString());
            }
            return(null);
        }