internal WeixinToolkitSettings(WeixinExtraXml xml, BaseAppSetting appsetting)
        {
            fCurrent = this;

            fEngine = new MessageEngine();
            if (xml.Weixin.Normal != null)
            {
                fNormalDefault = new DefaultEngine(xml.Weixin.Normal.DefaultMessage);

                fAuthConfig = new WeixinAuthConfig();
                string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\Auth.xml");
                if (File.Exists(authFileName))
                    fAuthConfig.ReadXmlFromFile(authFileName);
            }
            else if (xml.Weixin.CorpApps != null)
            {
                fCorpDefault = new Dictionary<int, DefaultEngine>();
                foreach (var item in xml.Weixin.CorpApps)
                    fCorpDefault.Add(item.AppId, new DefaultEngine(item.DefaultMessage));

                fCorpAuthConfig = new WeixinCorpAuthConfig();
                string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\CorpAuth.xml");
                if (File.Exists(authFileName))
                    fCorpAuthConfig.ReadXmlFromFile(authFileName);
            }
            else
                TkDebug.ThrowImpossibleCode(this);

            if (xml.Weixin.MessageLog != null)
                fLog = xml.Weixin.MessageLog.CreateObject();

        }
        public void AppStarted(object application, BaseAppSetting appsetting,
            BaseGlobalVariable globalVariable)
        {
            string path = Path.Combine(appsetting.XmlPath, "weixin.xml");
            if (File.Exists(path))
            {
                WeixinExtraXml xml = new WeixinExtraXml();
                xml.ReadXmlFromFile(path);
                WeixinToolkitSettings.Current = new WeixinToolkitSettings(xml, appsetting);
            }

            RulePlugInFactory factory = globalVariable.FactoryManager.GetCodeFactory(
                RulePlugInFactory.REG_NAME).Convert<RulePlugInFactory>();

            factory.EnumableCodePlugIn(AddCodeRule);
            factory.EnumableXmlPlugIn(AddXmlRule);
        }
        public void AppStarted(object application, BaseAppSetting appsetting,
                               BaseGlobalVariable globalVariable)
        {
            string path = Path.Combine(appsetting.XmlPath, "weixin.xml");

            if (File.Exists(path))
            {
                WeixinExtraXml xml = new WeixinExtraXml();
                xml.ReadXmlFromFile(path);
                WeixinToolkitSettings.Current = new WeixinToolkitSettings(xml, appsetting);
            }

            RulePlugInFactory factory = globalVariable.FactoryManager.GetCodeFactory(
                RulePlugInFactory.REG_NAME).Convert <RulePlugInFactory>();

            factory.EnumableCodePlugIn(AddCodeRule);
            factory.EnumableXmlPlugIn(AddXmlRule);
        }
Пример #4
0
        internal WeixinToolkitSettings(WeixinExtraXml xml, BaseAppSetting appsetting)
        {
            fCurrent = this;

            fEngine = new MessageEngine();
            if (xml.Weixin.Normal != null)
            {
                fNormalDefault = new DefaultEngine(xml.Weixin.Normal.DefaultMessage);

                fAuthConfig = new WeixinAuthConfig();
                string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\Auth.xml");
                if (File.Exists(authFileName))
                {
                    fAuthConfig.ReadXmlFromFile(authFileName);
                }
            }
            else if (xml.Weixin.CorpApps != null)
            {
                fCorpDefault = new Dictionary <int, DefaultEngine>();
                foreach (var item in xml.Weixin.CorpApps)
                {
                    fCorpDefault.Add(item.AppId, new DefaultEngine(item.DefaultMessage));
                }

                fCorpAuthConfig = new WeixinCorpAuthConfig();
                string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\CorpAuth.xml");
                if (File.Exists(authFileName))
                {
                    fCorpAuthConfig.ReadXmlFromFile(authFileName);
                }
            }
            else
            {
                TkDebug.ThrowImpossibleCode(this);
            }

            if (xml.Weixin.MessageLog != null)
            {
                fLog = xml.Weixin.MessageLog.CreateObject();
            }
        }