Пример #1
0
        private void CreateXML(XmlDocument XD, string Path)
        {
            CommonFunc ComX = new CommonFunc();

            ComX.SaveXmlWithUTF8NotBOM(XD, Path);
            if (ComX != null)
            {
                ComX = null;
            }
        }
Пример #2
0
        /// <summary>
        /// 文件签名
        /// </summary>
        /// <param name="strPath"></param>
        /// <param name="strEBDID"></param>
        public void GenerateSignatureFile(string strPath, string strEBDID)
        {
            if (SingletonInfo.GetInstance().m_UsbPwsSupport != "1")
            {
                return;
            }

            string sSignFileName = "\\EBDB_" + strEBDID + ".xml";

            using (FileStream SignFs = new FileStream(strPath + sSignFileName, FileMode.Open))
            {
                StreamReader signsr  = new StreamReader(SignFs, Encoding.UTF8);
                string       xmlsign = signsr.ReadToEnd();
                signsr.Close();
                responseXML signrp     = new responseXML();
                XmlDocument xmlSignDoc = new XmlDocument();
                try
                {
                    //对文件进行签名
                    int    nDeviceHandle = (int)phDeviceHandle;
                    byte[] pucSignature  = Encoding.UTF8.GetBytes(xmlsign);

                    string strSignture     = "";
                    string strpucCounter   = "";
                    string strpucSignCerSn = "";
                    string nReturn         = usb.Platform_CalculateSingature_String(nDeviceHandle, 1, pucSignature, pucSignature.Length, ref strSignture);
                    //生成签名文件
                    string xmlSIGNFileName = "\\EBDS_EBDB_" + strEBDID + ".xml";
                    xmlSignDoc = signrp.SignResponse(strEBDID, strpucCounter, strpucSignCerSn, nReturn);
                    CommonFunc cm = new CommonFunc();
                    cm.SaveXmlWithUTF8NotBOM(xmlSignDoc, strPath + xmlSIGNFileName);
                    if (cm != null)
                    {
                        cm = null;
                    }
                }
                catch (Exception ex)
                {
                    Log.Instance.LogWrite("签名文件错误:" + ex.Message);
                }
            }
        }