예제 #1
0
        public static string getHead(string nodeNo, string channel)
        {
            ini    myIni  = new ini(filename);
            string areaNo = myIni.ReadValue(nodeNo, "areaNo").ToString();
            string instNo = myIni.ReadValue(nodeNo, "instNo").ToString();
            string teller = myIni.ReadValue(nodeNo, "teller").ToString();
            string term   = myIni.ReadValue(nodeNo, "term").ToString();

            switch (channel)
            {
            case "N":
                teller = "9999";
                break;

            case "M":
                teller = "9994";
                break;

            case "W":
                teller = "9993";
                break;

            default:
                break;
            }

            return(areaNo + instNo + teller + term);
        }
예제 #2
0
파일: JNKY.cs 프로젝트: lmj823/dianpiao
        private static XmlHelper setCommPara(string jydm, string nodeNo)
        {
            string    path = System.Windows.Forms.Application.StartupPath + "\\files\\" + jydm + ".xml";
            XmlHelper xher = new XmlHelper(path, true);

            ini myini = new ini(filename);

            /* head */
            xher.UpdateContent(@"/union/head/transTime", DateTime.Now.ToString("yyyyMMddHHmmss"));
            xher.UpdateContent(@"/union/head/userInfo", DateTime.Now.ToString("yyyyMMddHHmmss"));

            xher.UpdateContent(@"/union/head/sysID", myini.ReadValue(nodeNo, "sysID").ToString());
            xher.UpdateContent(@"/union/head/appID", myini.ReadValue(nodeNo, "appID").ToString());
            xher.UpdateContent(@"/union/head/clientIPAddr", myini.ReadValue(nodeNo, "clientIPAddr").ToString());
            xher.UpdateContent(@"/union/head/transFlag", myini.ReadValue(nodeNo, "transFlag").ToString());

            /* body */
            xher.UpdateContent(@"/union/body/mode", myini.ReadValue(nodeNo, "mode").ToString());
            xher.UpdateContent(@"/union/body/keyName", myini.ReadValue(nodeNo, "keyName").ToString());
            xher.UpdateContent(@"/union/body/format", myini.ReadValue(nodeNo, "format").ToString());

            return(xher);
        }
예제 #3
0
        public static string getSmsBankNo(string nodeNo)
        {
            ini myIni = new ini(filename);

            return(myIni.ReadValue(nodeNo, "smsBankNo").ToString());
        }
예제 #4
0
        public static string getKaBin(string nodeNo)
        {
            ini myIni = new ini(filename);

            return(myIni.ReadValue(nodeNo, "kaBin").ToString());
        }
예제 #5
0
        public static string getBankName(string nodeNo)
        {
            ini myIni = new ini(filename);

            return(myIni.ReadValue(nodeNo, "name").ToString());
        }
예제 #6
0
        public static string getHostPort(string nodeNo)
        {
            ini myIni = new ini(filename);

            return(myIni.ReadValue(nodeNo, "hostPort").ToString());
        }
예제 #7
0
        public static string getTeller(string nodeNo)
        {
            ini myIni = new ini(filename);

            return(myIni.ReadValue(nodeNo, "teller").ToString());
        }
예제 #8
0
파일: JNKY.cs 프로젝트: lmj823/dianpiao
        private static string SendData(string s, string nodeNo)
        {
            string recv = "error";

            byte[] body = Encoding.GetEncoding("GBK").GetBytes(s);

            byte[] head = new byte[2];
            head[0] = Convert.ToByte(body.Length >> 8);
            head[1] = Convert.ToByte(body.Length % 256);
            TcpClient sendTcp = new TcpClient();
            //string Restr = "";
            ini        myini       = new ini(filename);
            int        apphostport = Convert.ToInt32(myini.ReadValue(nodeNo, "hostPort").ToString());
            IPAddress  ip          = IPAddress.Parse(myini.ReadValue(nodeNo, "hostIP").ToString());
            IPEndPoint ipe         = new IPEndPoint(ip, apphostport);

            sendTcp.SendBufferSize = 10240;
            sendTcp.SendTimeout    = 10 * 1000;

            try
            {
                sendTcp.Connect(ip, apphostport);
            }
            catch (Exception ex)
            {
                sendTcp.Close();
                LogWrite.WriteLog("原因:" + ex.Message, "[加密机]连接服务器失败", nodeNo);
                return(recv);
            }
            NetworkStream ns = sendTcp.GetStream();

            ns.WriteTimeout = 10 * 1000;
            ns.ReadTimeout  = 10 * 1000;
            try
            {
                if (ns.CanWrite)
                {
                    ns.Write(head, 0, head.Length);
                    ns.Write(body, 0, body.Length);
                    //LogWrite.WriteLog(s, "[加密机]发送数据:", nodeNo);
                    if (ns.CanRead)
                    {
                        byte[] len = new byte[2];
                        ns.Read(len, 0, 2);
                        int    L       = len[0] * 256 + len[1];
                        byte[] recbuff = new byte[L];

                        int index = 0;
                        while (index < L)
                        {
                            int cout = ns.Read(recbuff, index, L - index);
                            if (cout <= 0)
                            {
                                break;
                            }
                            index += cout;
                        }

                        recv = Encoding.GetEncoding("gbk").GetString(recbuff);
                        //LogWrite.WriteLog(recv, "[加密机]接收数据:", nodeNo);
                    }
                }
                else
                {
                    LogWrite.WriteLog("连接不可用", "[加密机]发数据失败:", nodeNo);
                }
            }
            catch (Exception ex)
            {
                LogWrite.WriteLog(ex.Message, "[加密机]通讯故障,原因:", nodeNo);
            }
            finally
            {
                ns.Close();
                sendTcp.Close();
            }
            return(recv);
        }