Ejemplo n.º 1
0
        //财付通充值返回
        public bool _99BillReturn(string merchantAcctId, string version, string language, string signType, string payType, string bankId, string orderNo, string orderTime,
                                  string orderAmount, string dealId, string bankDealId, string dealTime, string payAmount, string fee, string ext1, string ext2, string payResult, string errCode, string signMsg, string payIp, DateTime payDate)
        {
            string key = AllSettings.Current.PaySettings._99Bill_Key;
            //生成加密串。必须保持如下顺序。
            //string merchantSignMsgVal = "";
            StringBuilder merchantSignMsgValBuilder = new StringBuilder();

            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "merchantAcctId", merchantAcctId);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "version", version);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "language", language);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "signType", signType);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "payType", payType);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "bankId", bankId);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "orderId", orderNo);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "orderTime", orderTime);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "orderAmount", orderAmount);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "dealId", dealId);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "bankDealId", bankDealId);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "dealTime", dealTime);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "payAmount", payAmount);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "fee", fee);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "ext1", ext1);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "ext2", ext2);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "payResult", payResult);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "errCode", errCode);
            Pay._99Bill.appendParam(merchantSignMsgValBuilder, "key", key);

            string merchantSignMsgVal = merchantSignMsgValBuilder.ToString();

            string merchantSignMsg = Pay._99Bill.GetMD5(merchantSignMsgVal, "utf-8");

            //商家进行数据处理,并跳转会商家显示支付结果的页面
            ///首先进行签名字符串验证
            if (StringUtil.EqualsIgnoreCase(signMsg, merchantSignMsg))
            {
                switch (payResult)
                {
                case "10":
                    /*
                     * ' 商户网站逻辑处理,比方更新订单支付状态为成功
                     * ' 特别注意:只有signMsg.ToUpper() == merchantSignMsg.ToUpper(),且payResult=10,才表示支付成功!同时将订单金额与提交订单前的订单金额进行对比校验。
                     */
                    //报告给快钱处理结果,并提供将要重定向的地址。
                    int userID;
                    PayDao.Instance.UpdateUserPayItem("", orderNo, dealId, payIp, payDate, out userID);
                    if (userID > 0)
                    {
                        UserBO.Instance.TryResetUserPointsCache(userID);
                    }
                    return(true);

                default:
                    break;
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static ParameterInfo GetParameterByName(MethodInfo methodInfo, string name)
        {
            foreach (ParameterInfo parameter in methodInfo.GetParameters())
            {
                if (StringUtil.EqualsIgnoreCase(parameter.Name, name))
                {
                    return(parameter);
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
        public void Read(string configFilePath)
        {
            #region 读取配置

            if (File.Exists(configFilePath) == false)
            {
                throw new FileNotFoundException("未在bbsmax所在的根目录找到bbsmax.config配置文件", "bbsmax.config");
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(configFilePath);
            }
            catch (XmlException)
            {
                throw new Exception("配置文件 bbsmax.config 格式不正确。您是否在数据库名、数据库帐号或密码中使用了 & 或者其他特殊符号?如果是,您需要在配置文件中将其进行HTML编码。例如 & 应该写为 &");
            }
            catch
            {
                throw;
            }

            foreach (XmlNode configNode in doc.DocumentElement.ChildNodes)
            {
                if (configNode.NodeType != XmlNodeType.Comment)
                {
                    switch (configNode.Name.ToLower())
                    {
                    case "connectionstrings":

                        #region 读取连接字符串

                        foreach (XmlNode connectionNode in configNode.ChildNodes)
                        {
                            if (connectionNode.NodeType != XmlNodeType.Comment)
                            {
                                if (string.Compare(connectionNode.Name, "clear", true) == 0)
                                {
                                    ConnectionString = null;
                                    DataProviderName = null;
                                }

                                else
                                {
                                    bool isAdd    = string.Compare(connectionNode.Name, "add", true) == 0;
                                    bool isRemove = string.Compare(connectionNode.Name, "remove", true) == 0;

                                    if ((isAdd || isRemove) && connectionNode.Attributes["name"] != null)
                                    {
                                        switch (connectionNode.Attributes["name"].Value.ToLower())
                                        {
                                        case "bbsmax":
                                            if (isAdd)
                                            {
                                                ConnectionString = connectionNode.Attributes["connectionString"].Value.Trim();
                                                DataProviderName = connectionNode.Attributes["providerName"].Value.Trim();
                                            }
                                            else if (isRemove)
                                            {
                                                ConnectionString = null;
                                                DataProviderName = null;
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        break;

                        #endregion

                    case "appsettings":

                        #region 读取基本设置

                        foreach (XmlNode appSettingNode in configNode.ChildNodes)
                        {
                            if (appSettingNode.NodeType != XmlNodeType.Comment)
                            {
                                if (string.Compare(appSettingNode.Name, "clear", true) == 0)
                                {
                                    InstallDirectory = DefaultInstallDirectory;
                                    DynamicCompress  = false;
                                    StaticCompress   = false;
                                }

                                else
                                {
                                    bool isAdd    = string.Compare(appSettingNode.Name, "add", true) == 0;
                                    bool isRemove = string.Compare(appSettingNode.Name, "remove", true) == 0;

                                    if ((isAdd || isRemove) && appSettingNode.Attributes["key"] != null)
                                    {
                                        switch (appSettingNode.Attributes["key"].Value.ToLower())
                                        {
                                        case "bbsmax.installpath":

                                            if (isAdd)
                                            {
                                                InstallDirectory = appSettingNode.Attributes["value"].Value.Trim();
                                            }
                                            else if (isRemove)
                                            {
                                                InstallDirectory = null;
                                            }

                                            break;

                                        case "bbsmax.dynamiccompress":

                                            if (isAdd)
                                            {
                                                DynamicCompress = string.Compare(appSettingNode.Attributes["value"].Value.Trim(), "ON", true) == 0;
                                            }
                                            else if (isRemove)
                                            {
                                                DynamicCompress = false;
                                            }

                                            break;

                                        case "bbsmax.staticcompress":

                                            if (isAdd)
                                            {
                                                StaticCompress = string.Compare(appSettingNode.Attributes["value"].Value.Trim(), "ON", true) == 0;
                                            }
                                            else if (isRemove)
                                            {
                                                StaticCompress = false;
                                            }

                                            break;

                                        case "bbsmax.licence":

                                            if (isAdd)
                                            {
                                                Licence = appSettingNode.Attributes["value"].Value.Trim();
                                            }
                                            else if (isRemove)
                                            {
                                                Licence = null;
                                            }

                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        break;

                        #endregion

                    case "owners":

                        #region 读取创始人

                        foreach (XmlNode ownersNode in configNode.ChildNodes)
                        {
                            if (ownersNode.NodeType != XmlNodeType.Comment)
                            {
                                if (string.Compare(ownersNode.Name, "clear", true) == 0)
                                {
                                    OwnerUsernames.Clear();
                                }

                                else
                                {
                                    bool isAdd    = string.Compare(ownersNode.Name, "add", true) == 0;
                                    bool isRemove = string.Compare(ownersNode.Name, "remove", true) == 0;

                                    if ((isAdd || isRemove) && ownersNode.Attributes["username"] != null)
                                    {
                                        string username = ownersNode.Attributes["username"].Value.Trim().ToLower();

                                        if (isAdd)
                                        {
                                            OwnerUsernames.Add(username);
                                        }
                                        else if (isRemove)
                                        {
                                            OwnerUsernames.Remove(username);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        break;

                        #endregion

                    case "passportconnectionsetting":

                        #region 读取通行证客户端设置

                        bool enablePassport = false;

                        if (configNode.Attributes["enable"] != null)
                        {
                            enablePassport = StringUtil.EqualsIgnoreCase(configNode.Attributes["enable"].Value.Trim(), "true");
                            PassportClient.EnablePassport = enablePassport;
                        }

                        if (enablePassport)
                        {
                            bool serverRead    = false;
                            bool clientidRead  = false;
                            bool accesskeyRead = false;

                            if (configNode.Attributes["server"] != null)
                            {
                                PassportClient.PassportRoot = configNode.Attributes["server"].Value.Trim();

                                if (PassportClient.PassportRoot != string.Empty)
                                {
                                    serverRead = true;
                                }
                            }

                            if (serverRead == false)
                            {
                                throw new ArgumentException("通行证配置中缺少server属性");
                            }

                            if (configNode.Attributes["clientid"] != null)
                            {
                                int clientID;
                                if (int.TryParse(configNode.Attributes["clientid"].Value.Trim(), out clientID))
                                {
                                    PassportClient.ClientID = clientID;
                                    clientidRead            = true;
                                }
                            }

                            if (clientidRead == false)
                            {
                                throw new ArgumentException("通行证配置中缺少clientid属性");
                            }

                            if (configNode.Attributes["accesskey"] != null)
                            {
                                PassportClient.AccessKey = configNode.Attributes["accesskey"].Value.Trim();

                                if (PassportClient.PassportRoot != string.Empty)
                                {
                                    accesskeyRead = true;
                                }
                            }

                            if (accesskeyRead == false)
                            {
                                throw new ArgumentException("通行证配置中缺少accesskey属性");
                            }

                            if (configNode.Attributes["timeout"] != null)
                            {
                                int timeout;
                                if (int.TryParse(configNode.Attributes["timeout"].Value.Trim(), out timeout))
                                {
                                    PassportClient.PassportTimeout = timeout;
                                    clientidRead = true;
                                }
                            }
                        }

                        #endregion
                        break;

                    case "maxplugins":
                        #region 外部插件配置
                        XmlNodeList childNodes = configNode.ChildNodes;
                        int         ln         = 1;
                        foreach (XmlNode n in childNodes)
                        {
                            bool readname     = false;
                            bool readtype     = false;
                            bool readassembly = false;
                            if (n.Name.Equals("add", StringComparison.OrdinalIgnoreCase))
                            {
                                MaxPluginItem item = new MaxPluginItem();

                                if (n.Attributes["name"] != null)
                                {
                                    item.Name = n.Attributes["name"].Value.Trim();
                                    readname  = true;
                                }
                                if (n.Attributes["type"] != null)
                                {
                                    item.Type = n.Attributes["type"].Value.Trim();
                                    readtype  = true;
                                }

                                if (n.Attributes["assembly"] != null)
                                {
                                    item.Assembly = n.Attributes["assembly"].Value;
                                    readassembly  = true;
                                }

                                if (readname == false)
                                {
                                    throw new ArgumentException("外部插件配置项目第" + ln + "行缺少name属性");
                                }
                                if (readtype == false)
                                {
                                    throw new ArgumentException("外部插件配置项目第" + ln + "行缺少type属性");
                                }
                                if (readassembly == false)
                                {
                                    throw new ArgumentException("外部插件配置项目第" + ln + "行缺少readassembly属性");
                                }

                                this.MaxPlugins.Add(item.Name, item);
                            }
                            ln++;
                        }
                        #endregion
                        break;
                    }
                }
            }

            if (string.IsNullOrEmpty(ConnectionString) || string.IsNullOrEmpty(DataProviderName))
            {
                throw new Exception("配置文件 bbsmax.config 不正确,请重新上传Install.aspx、Globals.asax、bin\\MaxInstall.dll文件然后运行Install.aspx来启动安装向导");
            }

            string md5 = SecurityUtil.MD5(ConnectionString);

            SafeString = SecurityUtil.MD5(md5).Substring(0, 10);

            FileNamePart = md5.Substring(0, 6);

            LicenceExpireDate = DateTime.MinValue;

            LicencedServers = null;

            if (string.IsNullOrEmpty(Licence) == false)
            {
                string decodedInfo = SecurityUtil.DesDecode(Licence);

                if (decodedInfo == null)
                {
                    return;
                }

                string[] infos = decodedInfo.Split('|');

                if (infos.Length == 2)
                {
                    LicenceExpireDate = DateTime.Parse(infos[0]);
                    LicencedServers   = infos[1].Split(',');
                }
            }

            #endregion
        }