Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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());
     }
 }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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());
     }
 }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
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);
 }
Exemple #11
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);
 }
        /// <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);
        }
Exemple #13
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);
        }