示例#1
0
        static void LogOffendingAssets(Group group, GroupRelations relations, LoggerAction log)
        {
            var  stringBuilder  = new StringBuilder();
            bool entitiesLogged = LogOffendingNameEntityClass(stringBuilder, relations.Zones, false);

            entitiesLogged = LogOffendingNameEntityClass(stringBuilder, relations.Devices, entitiesLogged);
            entitiesLogged = LogOffendingNameEntityClass(stringBuilder, relations.Users, entitiesLogged);
            entitiesLogged = LogOffendingNameEntityClass(stringBuilder, relations.Drivers.ConvertAll(GetDriver), entitiesLogged);
            entitiesLogged = LogOffendingNameEntityClass(stringBuilder, relations.Rules, entitiesLogged);
            LogOffendingCustomReportSchedules(group, stringBuilder, relations.CustomReportSchedules, entitiesLogged);
            if (stringBuilder.Length > 0)
            {
                log(stringBuilder.ToString());
            }
        }
示例#2
0
 /// <summary>
 ///     支付回调通知处理
 /// </summary>
 /// <param name="dic"></param>
 /// <returns></returns>
 public bool PayNotifyHandler(Dictionary <string, string> dic)
 {
     try
     {
         var alipaySignPublicKey = _alipaySettings.AlipaySignPublicKey;
         var charset             = _alipaySettings.CharSet;
         var signtype            = _alipaySettings.SignType;
         var flag = AlipaySignature.RSACheckV1(dic, alipaySignPublicKey, charset, signtype, false);
         return(flag);
     }
     catch (Exception e)
     {
         LoggerAction?.Invoke("Error", e.Message);
         return(false);
     }
 }
示例#3
0
        /// <summary>
        ///     APP支付
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <WeChatMiniPayOutput> WeChatMiniPay(WeChatMiniPayInput input)
        {
            var allinpayDefaultClient = new AllinpayDefaultClient(_allinpaySettings.CusId, _allinpaySettings.AppId, _allinpaySettings.AppKey);
            var response = allinpayDefaultClient.WeChatMiniPay(input);

            if (response.RetCode == "FAIL")
            {
                LoggerAction?.Invoke("Error", "通联支付请求参数错误");
                throw new Exception("通联支付请求参数错误,请检查!");
            }

            return(Task.FromResult(new WeChatMiniPayOutput
            {
                Response = response
            }));
        }
 /// <summary>
 ///     支付回调通知处理
 /// </summary>
 /// <param name="dic"></param>
 /// <returns></returns>
 public bool PayNotifyHandler(Dictionary <string, string> dic)
 {
     try
     {
         var allinpayKey = _allinpaySettings.AppKey;
         if (!dic.ContainsKey("sign"))//如果不包含sign,则不进行处理
         {
             LoggerAction?.Invoke("Error", "sign is null");
             return(false);
         }
         return(AllinpayUtil.ValidSign(dic, allinpayKey));
     }
     catch (Exception e)
     {
         LoggerAction?.Invoke("Error", e.Message);
         return(false);
     }
 }
        /// <summary>
        ///     JSAPI支付
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <JsApiPayOutput> WeChatJsApiPay(JsApiPayInput input)
        {
            var allinpayDefaultClient = new AllinpayDefaultClient(_allinpaySettings);
            var response = allinpayDefaultClient.WeChatJsApiPay(input);

            if (response.RetCode == "FAIL")
            {
                LoggerAction?.Invoke("Error", "通联支付请求参数错误(FAIL):" + _allinpaySettings);
                LoggerAction?.Invoke("Error", "input:" + input);
                LoggerAction?.Invoke("Error", "RetMsg:" + response.RetMsg + "    ErrMsg:" + response.ErrMsg);
                throw new Exception("通联支付请求参数错误,请检查!");
            }

            return(Task.FromResult(new JsApiPayOutput
            {
                Response = response
            }));
        }
        /// <summary>
        ///     支付回调
        /// </summary>
        /// <param name="dic"></param>
        /// <returns></returns>
        public bool PayNotifyHandler(Dictionary <string, string> dic)
        {
            try
            {
                var sArray = new SortedDictionary <string, string>();
                foreach (var item in dic)
                {
                    sArray.Add(item.Key, item.Value);
                }

                var aliNotify    = new NotifyHelper();
                var verifyResult = aliNotify.Verify(sArray, dic["notify_id"], dic["sign"], _alipaySettings);

                return(verifyResult);
            }
            catch (Exception e)
            {
                LoggerAction?.Invoke("Error", e.Message);
                return(false);
            }
        }
示例#7
0
        /// <summary>
        ///     Wap支付
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <WapPayOutput> WapPay(WapPayInput input)
        {
            var client = GetClient();

            var request = new AlipayTradeWapPayRequest();
            var model   = new AlipayTradeWapPayModel
            {
                Body = input.Body,
                DisablePayChannels = input.DisablePayChannels,
                EnablePayChannels  = input.EnablePayChannels,
                //ExtendParams = input.ex
                GoodsType      = input.GoodsType,
                OutTradeNo     = input.TradeNo ?? Guid.NewGuid().ToString("N"),
                PassbackParams = WebUtility.UrlEncode(input.PassbackParams),
                ProductCode    = "QUICK_WAP_WAY",
                PromoParams    = input.PromoParams,
                //SpecifiedChannel
                StoreId        = input.StoreId,
                Subject        = input.Subject,
                TimeoutExpress = input.TimeoutExpress,
                TotalAmount    = input.TotalAmount.ToString(CultureInfo.InvariantCulture),
                QuitUrl        = input.QuitUrl
            };

            request.SetBizModel(model);
            request.SetNotifyUrl(input.NotifyUrl ?? alipaySettings.Notify);
            var response = client.pageExecute(request);

            if (response.IsError)
            {
                LoggerAction?.Invoke("Error", "支付宝支付请求参数错误:" + JsonConvert.SerializeObject(model));
                throw new AlipayExcetion("支付宝支付请求参数错误,请检查!");
            }

            return(Task.FromResult(new WapPayOutput
            {
                Body = response.Body
            }));
        }
示例#8
0
 private DefaultAopClient GetClient()
 {
     try
     {
         var client =
             new DefaultAopClient(
                 alipaySettings.Gatewayurl,
                 alipaySettings.AppId,
                 alipaySettings.PrivateKey,
                 "json",
                 "1.0",
                 alipaySettings.SignType,
                 alipaySettings.AlipayPublicKey,
                 alipaySettings.CharSet,
                 alipaySettings.IsKeyFromFile);
         return(client);
     }
     catch (Exception ex)
     {
         LoggerAction?.Invoke("Error", "支付宝配置错误:");
         throw new AlipayExcetion("支付宝配置错误,请检查!", ex);
     }
 }
示例#9
0
 public static void Log(LoggerAction akcija, string userName)
 {
     try
     {
         using (FileStream fs = File.Open(datoteka, FileMode.Append, FileAccess.Write))
             using (StreamWriter sw = new StreamWriter(fs))
             {
                 if (akcija == LoggerAction.Prijava)
                 {
                     string vrstica = String.Format("[{0}] Uporabnik {1} se je prijavil v aplikacijo Denarna Posojila.", DateTime.Now, userName);
                     sw.WriteLine(vrstica);
                 }
                 else if (akcija == LoggerAction.Odjava)
                 {
                     string vrstica = String.Format("[{0}] Uporabnik {1} se je odjavil iz aplikacije Denarna Posojila.", DateTime.Now, userName);
                     sw.WriteLine(vrstica);
                 }
             }
     }
     catch
     {
         MessageBox.Show("Napaka pri beleženju!", "Beleženje", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#10
0
 /// <summary>
 /// Вывести сообщение об объектах согласно типа действия
 /// </summary>
 public void LogByObjects <TValue>(LoggerLevel loggerLevel, LoggerAction loggerAction, MethodBase methodBase, IEnumerable <TValue> parameters) =>
 LogByObjects(loggerLevel, loggerAction, methodBase, parameters, String.Empty);
示例#11
0
 /// <summary>
 /// Вывести сообщение об объекте согласно типа действия метода
 /// </summary>
 public void LogByObjectMethod(LoggerLevel loggerLevel, LoggerAction loggerAction, MethodBase methodBase, string parameter) =>
 LogByObjects(loggerLevel, loggerAction, ReflectionInfo.GetTypeNameFromMethodBase(methodBase), methodBase,
              new List <string>()
 {
     parameter
 }, String.Empty);
示例#12
0
 /// <summary>
 /// Вывести сообщение об объекте согласно типа действия
 /// </summary>
 public void LogByObject <TValue>(LoggerLevel loggerLevel, LoggerAction loggerAction,
                                  MethodBase methodBase, TValue parameter, string parentValue) =>
 LogByObjects(loggerLevel, loggerAction, methodBase, new List <TValue>()
 {
     parameter
 }, parentValue);
示例#13
0
 /// <summary>
 /// Вывести сообщение об объектах согласно типа действия
 /// </summary>
 public void LogByObject(LoggerLevel loggerLevel, LoggerAction loggerAction, string objectName, MethodBase methodBase, string parameters) =>
 LogByObjects(loggerLevel, loggerAction, objectName, methodBase, new List <string>()
 {
     parameters
 }, String.Empty);
示例#14
0
 /// <summary>
 /// Вывести сообщение об объекте согласно типа действия
 /// </summary>
 public void LogByObject(LoggerLevel loggerLevel, LoggerAction loggerAction, MethodBase methodBase, string parameter) =>
 LogByObject(loggerLevel, loggerAction, methodBase, parameter, String.Empty);
示例#15
0
 /// <summary>
 /// Вывести сообщение об объекте согласно типа действия
 /// </summary>
 public void LogByObject <TValue>(LoggerLevel loggerLevel, LoggerAction loggerAction, MethodBase methodBase) =>
 LogByObject(loggerLevel, loggerAction, methodBase, Enumerable.Empty <TValue>(), String.Empty);
示例#16
0
        public static void GroupImportedHandler(object sender, EntityImportedEventArgs <GroupWithLoggingData> e, LoggerAction log, bool isVerboseMode, bool flush)
        {
            bool isOutputRequired = true;

            switch (e.Status)
            {
            case EntityImportStatus.Added:
            case EntityImportStatus.Updated:
            case EntityImportStatus.MovedExisting:
            case EntityImportStatus.MovedUpdated:
            case EntityImportStatus.Existing:
                isOutputRequired = isVerboseMode;
                break;
            }
            if (isOutputRequired)
            {
                log($"Imported with status {e.Status} <{e.Entity.Group.Name}> <{e.Entity.Group.Reference}> {(e.Status == EntityImportStatus.MovedExisting || e.Status == EntityImportStatus.MovedUpdated ? $"from <{e.Entity.NameOfParentInDB}> <{e.Entity.SreferenceOfParentInDB}> to" : "child of")} <{e.Entity.Group.Parent.Name}> <{e.Entity.Group.Parent.Reference}>.{(e.Exception == null ? "" : $" {(EntityImportStatus.Failed == e.Status ? "exception: " : "")}{e.Exception.Message}")}");
                if (e.Status == EntityImportStatus.CannotDeleteNotEmpty)
                {
                    LogOffendingAssets(e.Entity.Group, e.Entity.Relations, log);
                }
                if (flush)
                {
                    Console.Out.Flush();
                }
            }
        }
        /// <inheritdoc />
        /// <summary>
        ///     网站支付
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <PayOutput> Pay(PayInput input)
        {
            //把请求参数打包成数组
            var sParaTemp = new SortedDictionary <string, string>
            {
                { "service", "create_forex_trade" },
                { "partner", _alipaySettings.Partner },
                { "_input_charset", _alipaySettings.CharSet.ToUpper() },
                { "sign_type", _alipaySettings.SignType },
                { "notify_url", input.NotifyUrl ?? _alipaySettings.Notify },
                { "return_url", input.ReturnUrl ?? _alipaySettings.ReturnUrl },
                { "currency", input.Currency ?? _alipaySettings.Currency },
                { "out_trade_no", input.TradeNo ?? Guid.NewGuid().ToString("N") },
                { "subject", input.Subject },
                { "product_code", "NEW_OVERSEAS_SELLER" },
            };

            if (!string.IsNullOrWhiteSpace(input.Body))
            {
                //商品信息,不支持特殊字符。格式:[{"goods_name":"名称1","quantity":"数量1"},{"goods_name":"名称2","quantity":"数量2"}]。
                if (!input.Body.StartsWith("["))
                {
                    input.Body = JsonConvert.SerializeObject(new List <object>()
                    {
                        new
                        {
                            goods_name = input.Body,
                            quantity   = 1
                        }
                    });
                }
                sParaTemp.Add("body", input.Body);
            }
            if (input.RmbFee > 0)
            {
                sParaTemp.Add("rmb_fee", input.RmbFee.ToString());
            }
            else
            {
                sParaTemp.Add("total_fee", input.TotalFee.ToString());
            }

            if (!string.IsNullOrWhiteSpace(input.TimeoutRule))
            {
                sParaTemp.Add("timeout_rule", input.TimeoutRule);
            }

            if (!string.IsNullOrWhiteSpace(input.AuthToken))
            {
                sParaTemp.Add("auth_token", input.AuthToken);
            }

            if (!string.IsNullOrWhiteSpace(input.Supplier))
            {
                sParaTemp.Add("supplier", input.Supplier);
            }

            if (!string.IsNullOrWhiteSpace(input.SecondaryMerchantId))
            {
                sParaTemp.Add("secondary_merchant_id", input.SecondaryMerchantId);
            }

            if (!string.IsNullOrWhiteSpace(input.SecondaryMerchantName))
            {
                sParaTemp.Add("secondary_merchant_name", input.SecondaryMerchantName);
            }

            if (!string.IsNullOrWhiteSpace(input.SecondaryMerchantIndustry))
            {
                sParaTemp.Add("secondary_merchant_industry", input.SecondaryMerchantIndustry);
            }

            if (input.OrderGmtCreate.HasValue)
            {
                sParaTemp.Add("order_gmt_create", input.OrderGmtCreate.Value.ToString("yyyy-MM-dd hh:mm:ss"));
            }

            if (input.OrderValidTime.HasValue && input.OrderValidTime > 0)
            {
                sParaTemp.Add("order_valid_time", input.OrderValidTime.Value.ToString());
            }

            #region 设置分账信息
            if (input.SplitFundInfo != null && input.SplitFundInfo.Count > 0)
            {
                foreach (var splitFundInfoDto in input.SplitFundInfo)
                {
                    if (input.RmbFee > 0)
                    {
                        splitFundInfoDto.Currency = "CNY";
                    }
                    else
                    {
                        splitFundInfoDto.Currency = input.Currency ?? _alipaySettings.Currency;
                    }
                }
                //分账信息
                sParaTemp.Add("split_fund_info", Newtonsoft.Json.JsonConvert.SerializeObject(input.SplitFundInfo));
            }
            else if (_alipaySettings.SplitFundInfo != null && _alipaySettings.SplitFundInfo.Count > 0)
            {
                input.SplitFundInfo = new List <SplitFundInfoDto>();
                foreach (var splitFundInfo in _alipaySettings.SplitFundInfo)
                {
                    var splitFundInfoDto = new SplitFundInfoDto()
                    {
                        Desc    = splitFundInfo.Desc,
                        TransIn = splitFundInfo.TransIn
                    };
                    if (input.RmbFee > 0)
                    {
                        splitFundInfoDto.Currency = "CNY";
                    }
                    else
                    {
                        splitFundInfoDto.Currency = input.Currency ?? _alipaySettings.Currency;
                    }

                    if (splitFundInfo.AmountRate > 0)
                    {
                        var amount = input.TotalFee > 0 ? input.TotalFee : input.RmbFee;
                        //日元取整数,其他的保留两位小数
                        splitFundInfoDto.Amount = splitFundInfoDto.Currency == "JPY" ? decimal.Floor(splitFundInfo.AmountRate * amount) : decimal.Round(splitFundInfo.AmountRate * amount, 2);
                    }
                }
                //分账信息
                sParaTemp.Add("split_fund_info", Newtonsoft.Json.JsonConvert.SerializeObject(input.SplitFundInfo));
            }
            #endregion

            //过滤签名参数数组
            sParaTemp.FilterPara();
            var dic = sParaTemp.BuildRequestPara(_alipaySettings);
            LoggerAction?.Invoke("Debug", "支付参数:" + JsonConvert.SerializeObject(dic));
            var html = dic.GetHtmlSubmitForm(_alipaySettings.Gatewayurl, _alipaySettings.CharSet);
            return(Task.FromResult(new PayOutput
            {
                FormHtml = html,
                Parameters = dic
            }));
        }
示例#18
0
 /// <summary>
 /// Вывести сообщение об объектах согласно типа действия
 /// </summary>
 public void LogByObjects <TValue>(LoggerLevel loggerLevel, LoggerAction loggerAction, MethodBase methodBase,
                                   IEnumerable <TValue> parameters, string parentValue) =>
 LogByObjects(loggerLevel, loggerAction, ReflectionInfo.GetTypeName(typeof(TValue)), methodBase,
              parameters?.Select(parameter => parameter.ToString()), parentValue);
示例#19
0
        // must be Company Group or decendent, a group with its sReference must be present in the database
        public static void RowParsedHandler(object sender, RowParsedEventArgs <Group> e, LoggerAction log, bool isVerboseMode, bool flush)
        {
            if (isVerboseMode || e.Exception != null)
            {
                log($"Parsed Row: {e.Row}" + (e.Exception == null ? $" OK, {e.ImportedItem.Parent.Name},{e.ImportedItem.Parent.Reference},{e.ImportedItem.Name},{e.ImportedItem.Reference}" : ", exception: " + e.Exception.Message));
                if (flush)
                {
                    Console.Out.Flush();
                }
            }

            // Terminate is decided by ImportGroupParser and is transparent to RowParser
            if (e.Exception?.Message.Contains("Terminate") == true)
            {
                throw e.Exception;
            }
        }
示例#20
0
 /// <summary>
 /// Вывести сообщение об объектах согласно типа действия
 /// </summary>
 public void LogByObjects(LoggerLevel loggerLevel, LoggerAction loggerAction, string typeName,
                          MethodBase methodBase, IEnumerable <string> parameters, string parentValue) =>
 LogByLevel(loggerLevel, $"{loggerAction} {FormatTypeName(typeName)} by {GetReflectionName(methodBase)}{GetParentClassMessage(parentValue)}".
            Map(message => FormatMessageParameters(message, parameters)));
示例#21
0
 public static void GroupRelationsPopulationFailureHandler(object sender, EntityImportedEventArgs <NameEntity> e, LoggerAction log, bool flush)
 {
     log($"Failed to populate {e.Entity.GetType()} with Id {e.Entity.Id}. Exception: {e.Exception.Message}");
     if (flush)
     {
         Console.Out.Flush();
     }
 }