Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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());
     }
 }
Beispiel #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);
        }
Beispiel #6
0
        /// <summary>
        /// 查询数据返回一个loginPerson
        /// </summary>
        public DataSet SelectDataByCondition(string queryWhere)
        {
            DataSet ds = null;

            try
            {
                ManagerOperate managerDeal = ManagerOperate.getInstance();
                LoginPerson    loginPerson = new LoginPerson();
                string         queryStr    = TableInfo.GetQueryFieldFile(loginPerson.Tables[0]);
                ds = managerDeal.SelectByCondition("manager_login_person", queryStr, queryWhere);
            }
            catch (Exception exception)
            {
                log.writeLog(this.GetType().Name, "查询数据出错!" + exception.ToString());
            }
            return(ds);
        }
Beispiel #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);
        }
Beispiel #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());
     }
 }
Beispiel #9
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);
        }
Beispiel #10
0
 public string ValidPerson(string personID, string password)
 {
     try
     {
         string         sqlWhere         = "  person_code='" + personID + "'";
         PersonLoginBll loginPersonLogic = new PersonLoginBll();
         DataSet        loginPerson      = loginPersonLogic.SelectDataByCondition(sqlWhere);
         if (loginPerson == null || loginPerson.Tables[0].Rows.Count <= 0)
         {
             return("-1");
         }
         System.Data.DataRow loginPersonRow = loginPerson.Tables[0].Rows[0];
         return((string)loginPersonRow["person_status"]);
     }
     catch (Exception exception)
     {
         log.writeLog(this.GetType().Name, "取登录人员信息出错!" + exception.ToString());
     }
     return("-1");
 }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #14
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);
        }
Beispiel #15
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);
        }
Beispiel #16
0
        protected void OnStart(object sender)
        {
            try
            {
                ReadXml     readXml     = new ReadXml();
                XmlNodeList xmlNodeList = readXml.ReadNodeListFromFile("interaction.xml", "interactions");
                string      tcpPort     = readXml.ReadAttrFromFile("interaction.xml", "interactions", "tcpport");
                string      httpPort    = readXml.ReadAttrFromFile("interaction.xml", "interactions", "httpport");

                TcpServerChannel tcp = new TcpServerChannel(int.Parse(tcpPort));
                ChannelServices.RegisterChannel(tcp, false);
                log.writeLog(this.GetType().Name, "Remoting服务正在用TCP方式监听端口(" + tcpPort + ")!");

                HttpServerChannel http = new HttpServerChannel(int.Parse(httpPort));
                ChannelServices.RegisterChannel(http, false);
                log.writeLog(this.GetType().Name, "Remoting服务正在用HTTP方式监听端口(" + httpPort + ")!");

                foreach (XmlNode xn in xmlNodeList)
                {
                    string interaction   = xn.Attributes["impl"].Value;
                    string implInterface = xn.Attributes["interface"].Value;

                    Assembly remotingAssembly = Assembly.Load("RemoteObject");

                    if (remotingAssembly == null)
                    {
                        log.writeLog(this.GetType().Name, "注册服务" + interaction + "失败");
                        continue;
                    }
                    try
                    {
                        System.Type[] types = remotingAssembly.GetTypes();
                        if (types != null)
                        {
                            for (int loop = 0; loop < types.GetLength(0); loop++)
                            {
                                Type   temp        = types[loop];
                                Type[] tInterfaces = temp.GetInterfaces();
                                if (tInterfaces != null && tInterfaces.Length > 0)
                                {
                                    for (int j = 0; j < tInterfaces.Length; j++)
                                    {
                                        string intfaceName = tInterfaces[j].Name;
                                        if (intfaceName.Equals(implInterface))
                                        {
                                            RemotingConfiguration.RegisterWellKnownServiceType(temp, implInterface, WellKnownObjectMode.SingleCall);
                                            log.writeLog(this.GetType().Name, "注册服务" + temp.Name + "成功");

                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        log.writeLog(this.GetType().Name, "注册服务" + interaction + "失败" + exception.ToString());
                    }
                }
            }
            catch (Exception exception)
            {
                log.writeLog(this.GetType().Name, "加载对象出错!" + exception.ToString());
            }
            (sender as Control).Enabled = false;
        }