private void CompareDifference_Click(object sender, EventArgs e) { List <AlertMsg> AlertDifference = new List <AlertMsg>(); AlertMsg csvAlert = new AlertMsg(); VariedAlertUid alertId = new VariedAlertUid(); foreach (AlertMsg alert in AlertDescription_Csv) { csvAlert = GetAlertDescription(alert.Uid); if (csvAlert == null) { // Uid not in sql VariationList.Add(new VariedAlertUid(alert.Category, alert.Uid, Difference.UidNotInSql)); } else { if (csvAlert.Description_EN != alert.Description_EN)// || csvAlert.Description_ZH != alert.Description_ZH) { // Description not match VariationList.Add(new VariedAlertUid(alert.Category, alert.Uid, Difference.DescriptionNotMatch)); } if (csvAlert.ErrorCode != alert.ErrorCode) { // Error Code not match VariationList.Add(new VariedAlertUid(alert.Category, alert.Uid, Difference.ErrorCodeNotMatch)); } } } ShowDifference(); }
private string QueryFromCsv(string fileName) { string result = ""; AlertMsg alert = new AlertMsg(); System.IO.StreamReader csvFile = new System.IO.StreamReader(fileName); while ((line = csvFile.ReadLine()) != null) { System.Console.WriteLine(line); try { alert = ParseTxtToAlertMsg(line); if (!AlertDescription_Csv.Contains(alert)) { AlertDescription_Csv.Add(alert); } } catch (Exception ex) { } } csvFile.Close(); return(result); }
public ActionResult Product() { var alertMsg = new AlertMsg(); WxPayLog.Info(this.GetType().ToString(), "page load"); WxPayJsApi jsApiPay = new WxPayJsApi(Request); try { //调用【网页授权获取用户信息】接口获取用户的openid和access_token var url = jsApiPay.GetOpenidAndAccessToken(); if (url != null) { return(Redirect(url)); } //获取收货地址js函数入口参数 var wxEditAddrParam = jsApiPay.GetEditAddressParameters(); TempData["openid"] = jsApiPay.openid; alertMsg.IsSuccess = true; ViewBag.WxEditAddrParam = wxEditAddrParam; } catch (Exception ex) { alertMsg.Message = $"页面加载出错,请重试,错误信息:{ex.Message}"; } return(View(alertMsg)); }
private AlertMsg ParseTxtToAlertMsg(string targetString) { AlertMsg ret = new AlertMsg(); try { char[] charsToTrim = { '\"' }; string[] words = targetString.Split(','); ret.Name = words[0]; ret.Severity = Convert.ToInt16(words[1] == "Critical" ? 2 : words[1] == "Major" ? 1 : 0); ret.Category = words[2]; ret.ErrorCode = words[3].Trim(charsToTrim); ret.Uid = words[4]; ret.Description_EN = words[5].Trim(charsToTrim); ret.Description_ZH = words[6].Trim(charsToTrim); ret.IsSelfTestable = words[7] == "1" ? true : false; } catch (Exception ex) { Console.WriteLine(ex); } return(ret); }
public ActionResult JsApiPay(string openid, string total_fee) { WxPayLog.Info(this.GetType().ToString(), "JsApiPayPage load"); //检测是否给当前页面传递了相关参数 if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(total_fee)) { WxPayLog.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit..."); return(View(new AlertMsg("页面传参出错, 请返回重试"))); } var alertMsg = new AlertMsg(); //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数 WxPayJsApi jsApiPay = new WxPayJsApi(Request); jsApiPay.openid = openid; jsApiPay.total_fee = int.Parse(total_fee); //JSAPI支付预处理 try { WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(); var wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数 WxPayLog.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam); //在页面上显示订单信息 alertMsg.IsSuccess = true; alertMsg.Message = ("订单详情:" + unifiedOrderResult.ToPrintStr()); ViewBag.WxJsApiParam = wxJsApiParam; } catch (Exception ex) { alertMsg.Message = $"下单失败,请返回重试,错误信息:{ex.Message}"; } return(View(alertMsg)); }
public ActionResult RefundQueryPage(string refund_id, string out_refund_no, string transaction_id, string out_trade_no) { if (string.IsNullOrEmpty(refund_id) && string.IsNullOrEmpty(out_refund_no) && string.IsNullOrEmpty(transaction_id) && string.IsNullOrEmpty(out_trade_no)) { return(Json(new AlertMsg("微信订单号、商户订单号、商户退款单号、微信退款单号选填至少一个,微信退款单号优先!"))); } var alertMsg = new AlertMsg(); //调用退款查询接口,如果内部出现异常则在页面上显示异常原因 try { string result = WxPayApiBiz.RefundQuery(refund_id, out_refund_no, transaction_id, out_trade_no); alertMsg.IsSuccess = true; alertMsg.Message = result; } catch (WxPayException ex) { alertMsg.Message = ex.Message; } catch (Exception ex) { alertMsg.Message = ex.Message; } return(Json(alertMsg)); }
public ActionResult OrderQueryPage(string transaction_id, string out_trade_no) { if (string.IsNullOrEmpty(transaction_id) && string.IsNullOrEmpty(out_trade_no)) { return(Json(new AlertMsg("微信订单号和商户订单号至少填写一个,微信订单号优先!"))); } var alertMsg = new AlertMsg(); //调用订单查询接口,如果内部出现异常则在页面上显示异常原因 try { string result = WxPayApiBiz.OrderQuery(transaction_id, out_trade_no);//调用订单查询业务逻辑 alertMsg.IsSuccess = true; alertMsg.Message = result; } catch (WxPayException ex) { alertMsg.Message = ex.Message; } catch (Exception ex) { alertMsg.Message = ex.Message; } return(Json(alertMsg)); }
public void TestxsiNill_SDOObjectXML() { LearnerPersonal lp = new LearnerPersonal(); // Add a null UPN SifString str = new SifString(null); lp.SetField(LearnerDTD.LEARNERPERSONAL_UPN, str); // Add a null AlertMsg AlertMsg msg = new AlertMsg(AlertMsgType.DISCIPLINE, null); lp.AlertMsgList = new AlertMsgList(msg); msg.SetField(CommonDTD.ALERTMSG, new SifString(null)); // Write the object to a file Console.WriteLine("Writing to file..."); using (Stream fos = File.Open("SifWriterTest.Temp.xml", FileMode.Create, FileAccess.Write)) { SifWriter writer = new SifWriter(fos); lp.SetChanged(true); writer.Write(lp); writer.Flush(); fos.Close(); } // Parse the object from the file Console.WriteLine("Parsing from file..."); SifParser p = SifParser.NewInstance(); using (Stream fis = File.OpenRead("SifWriterTest.Temp.xml")) { lp = (LearnerPersonal)p.Parse(fis, null); } SimpleField upn = lp.GetField(LearnerDTD.LEARNERPERSONAL_UPN); Assert.IsNotNull(upn); SifString rawValue = (SifString)upn.SifValue; Assert.IsNotNull(rawValue); Assert.IsNull(rawValue.Value); Assert.IsNull(upn.Value); AlertMsgList alertMsgs = lp.AlertMsgList; Assert.IsNotNull(alertMsgs); Assert.IsTrue(alertMsgs.Count == 1); msg = (AlertMsg)alertMsgs.GetChildList()[0]; Assert.IsNull(msg.Value); SifSimpleType msgValue = msg.SifValue; Assert.IsNotNull(msgValue); Assert.IsNull(msgValue.RawValue); }
public ActionResult RefundPage(string transaction_id, string out_trade_no, string total_fee, string refund_fee) { var alertMsg = new AlertMsg(true); if (string.IsNullOrEmpty(transaction_id) && string.IsNullOrEmpty(out_trade_no)) { alertMsg.IsSuccess = false; alertMsg.Message += "微信订单号和商户订单号至少填一个!\n"; } if (string.IsNullOrEmpty(total_fee)) { alertMsg.IsSuccess = false; alertMsg.Message += "订单总金额必填!\n"; } if (string.IsNullOrEmpty(refund_fee)) { alertMsg.IsSuccess = false; alertMsg.Message += "退款金额必填!\n"; } if (!alertMsg.IsSuccess) { return(Json(alertMsg)); } //调用订单退款接口,如果内部出现异常则在页面上显示异常原因 try { string result = WxPayApiBiz.Refund(transaction_id, out_trade_no, total_fee, refund_fee); alertMsg.Message = result; } catch (WxPayException ex) { alertMsg.IsSuccess = false; alertMsg.Message = ex.Message; } catch (Exception ex) { alertMsg.IsSuccess = false; alertMsg.Message = ex.Message; } return(Json(alertMsg)); }
public ActionResult MicroPayPage(string auth_code, string body, string fee) { var alertMsg = new AlertMsg(true); if (string.IsNullOrEmpty(auth_code)) { alertMsg.IsSuccess = false; alertMsg.Message += "请输入授权码!\n"; } if (string.IsNullOrEmpty(body)) { alertMsg.IsSuccess = false; alertMsg.Message += "请输入商品描述!\n"; } if (string.IsNullOrEmpty(fee)) { alertMsg.IsSuccess = false; alertMsg.Message += "请输入商品总金额!\n"; } if (!alertMsg.IsSuccess) { return(Json(alertMsg)); } //调用刷卡支付,如果内部出现异常则在页面上显示异常原因 try { alertMsg.Message = WxPayApiBiz.MicroPay(body, fee, auth_code); } catch (WxPayException ex) { alertMsg.IsSuccess = false; alertMsg.Message = ex.ToString(); } catch (Exception ex) { alertMsg.IsSuccess = false; alertMsg.Message = ex.ToString(); } return(Json(alertMsg)); }
private AlertMsg GetAlertDescription(string uid) { AlertMsg ret = new AlertMsg(); var fileName = filePath_Db.Text; if (!File.Exists(fileName)) { //CatLog.Warn("sqlite file missing, path: " + EngModeConstants.LocalDbPath); return(ret); } using (SQLiteConnection sqliteConn = new SQLiteConnection("Data source=" + fileName)) { sqliteConn.Open(); using (var sqliteCommand = sqliteConn.CreateCommand()) { sqliteCommand.CommandText = "SELECT * FROM vmalertinfo WHERE \"UID\" = '" + uid + "'"; try { using (SQLiteDataReader sqlite_datareader = sqliteCommand.ExecuteReader()) { sqlite_datareader.Read(); ret.Uid = sqlite_datareader["UID"].ToString(); ret.Severity = Convert.ToInt32(sqlite_datareader["Severity"]); ret.Category = sqlite_datareader["Category"].ToString(); ret.ErrorCode = sqlite_datareader["Error Code"].ToString(); ret.Description_EN = sqlite_datareader["EN Description"].ToString(); ret.Description_ZH = sqlite_datareader["ZH-TW Description"].ToString(); ret.IsSelfTestable = sqlite_datareader["IsSelfTestable"].ToString() == "1" ? true : false; } } catch (Exception) { //CatLog.WarnException(sqliteCommand.CommandText, ex); } } } return(ret); }
public ActionResult DownloadBillPage(string bill_type, DateTime?bill_date) { var dateStr = (bill_date.HasValue ? bill_date.Value : DateTime.Now).ToString("yyyyMMdd"); var alertMsg = new AlertMsg(); //调用下载对账单接口,如果内部出现异常则在页面上显示异常原因 try { string result = WxPayApiBiz.DownloadBill(dateStr, bill_type); alertMsg.IsSuccess = true; alertMsg.Message = result; } catch (WxPayException ex) { alertMsg.Message = ex.Message; } catch (Exception ex) { alertMsg.Message = ex.Message; } return(Json(alertMsg)); }
public static IEnumerable <AlertMsg> GetAlertMsg(string hn, CacheConnection con) { List <AlertMsg> alertMsgs = new List <AlertMsg>(); var query = QueryString.GetAlertMsg(hn); try { using (var cmd = new CacheCommand(query.Item1, con)) { foreach (KeyValuePair <string, string> pair in query.Item2) { cmd.AddInputParameters(new { key = pair.Value }); } using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { AlertMsg result = new AlertMsg() { ALERTCAT_Code = reader["ALERTCAT_Code"].ToString(), ALERTCAT_Desc = reader["ALERTCAT_Desc"].ToString(), ALM_Message = reader["ALM_Message"].ToString(), ALM_Status = reader["ALM_Status"].ToString() }; alertMsgs.Add(result); } } } } catch (Exception e) { Console.WriteLine(e); throw; } return(alertMsgs); }
/// <summary> /// Updates the screen alert with a new line of message. /// </summary> /// <param name="msg">Message to be written.</param> /// <param name="isError">If it's an error message.</param> public void UpdateScreenAlert(string msg, bool isError) { Task.Run(() => { var alertString = ++_alertCounter + ": " + msg + '\n'; AlertMsg += alertString; if (isError) { AlertColor = Brushes.Red; } else { AlertColor = Brushes.LightGreen; } lock (_alertLock) { Thread.Sleep(3500); AlertMsg = AlertMsg.Replace(alertString, ""); _alertCounter--; } }); }