Exemplo n.º 1
0
        public virtual int DoRecive(string strData, UInt32 nUserFlag, string strForm, string strTo, Object objCallback)
        {
            int nRet = 0;

            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(strData);
            }
            catch (Exception e)
            {
                // 输出误信息,以便于调试
                string strMsg = e.ToString();
                System.Diagnostics.Debug.WriteLine(strMsg);
                string strRet = String.Format("<Return  strMsg=\"{0}\"/>", e.ToString());
                CShareDll.SendData(strRet, nUserFlag, strTo, strForm, 100);
                PostLog(strMsg);

                return(nRet);
            }
            nRet = DoRecive(xmlDoc.DocumentElement, strForm, objCallback);

            return(nRet);
        }
Exemplo n.º 2
0
        public ErrCode SendString(string strSend, UInt32 nUserFlag, string strFrom, string strTo)
        {
            ErrCode retCode = ErrCode.EC_OK;

            retCode = CShareDll.SendData(strSend, nUserFlag, strFrom, strTo, 1000);
            return(retCode);
        }
Exemplo n.º 3
0
        // 等待服务端返回XmlElement
        public XmlElement WaitXmlElement(out string strFrom, out UInt32 nUserFlag, UInt32 nWaitTimeout)
        {
            XmlElement retXmlElement = null;
            ErrCode    retCode       = ErrCode.EC_OK;
            string     strRecve      = string.Empty;

            retCode = CShareDll.WaitData(out strRecve, out nUserFlag, out strFrom, ModuleName, nWaitTimeout);
            if (retCode != ErrCode.EC_OK)
            {
                //string strMsg = String.Format("等待消息超时,WaitData(ReciveModuleName=\"{0}\",nTimeout={1})",ModuleName,nWaitTimeout); ;
                //PostLog(strMsg, LogType.LT_TRACE);
                return(retXmlElement);
            }
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(strRecve);
            retXmlElement = xmlDoc.DocumentElement;
            return(retXmlElement);
        }
Exemplo n.º 4
0
        //------------------------------------------

        public virtual ErrCode Init(object objCallback)
        {
            ErrCode retCode = ErrCode.EC_OK;

            if (IsInit)
            {
                return(retCode);
            }
            //-----------------------------------
            IntPtr intPtr = IntPtr.Zero;
            //GCHandle gcHandle = GCHandle.Alloc(this, GCHandleType.Pinned);
            //intPtr = gcHandle.AddrOfPinnedObject();
            object obj = IntPtr.Zero;

            retCode = CShareDll.RegisterService(ModuleName, new ReceiveCallback(OnRecive), objCallback);//

            string strMsg;

            strMsg = String.Format("{0}=CBaseModule.Init({1})", retCode, objCallback.ToString());
            if (retCode != ErrCode.EC_OK)
            {
                PostLog(strMsg);
            }
            if (retCode == ErrCode.EC_OK)
            {
                IsInit = true;
            }
            //--------------
            string strFileName;
            string strDir = System.AppDomain.CurrentDomain.BaseDirectory;

            strFileName = String.Format("{0}Config\\RdCalcQuant.xml", strDir);
            try
            {
                m_xmlConfig.Load(strFileName);
            }
            catch (Exception e)
            {
                strMsg = e.ToString();
                PostLog(strMsg);
            }
            return(retCode);
        }