public JsonResult GetClientInfo(string card) { LCManager.Infrastructure.Request.GetClientInfoRequest clientInfoRequest = new LCManager.Infrastructure.Request.GetClientInfoRequest(); if (!string.IsNullOrEmpty(card)) { try { clientInfoRequest.Card = Convert.ToInt64(card); } catch { } } else { return(Json(new LCManager.Infrastructure.Response.GetClientInfoResponse { ErrorCode = 10, Message = "Не указана карта клиента" })); } try { clientInfoRequest.Operator = Convert.ToInt16(JwtProps.GetOperator()); } catch { } HttpResponseMessage response = HttpClientService.PostAsync("api/values/ClientInfo", clientInfoRequest).Result; if (response.IsSuccessStatusCode) { LCManager.Infrastructure.Response.GetClientInfoResponse clientInfoResponse = response.Content.ReadAsAsync <LCManager.Infrastructure.Response.GetClientInfoResponse>().Result; if (clientInfoResponse.ErrorCode == 0) { CardInfoResponse response2 = new CardInfoResponse(); CardStatisticsRequest request2 = new CardStatisticsRequest { Card = clientInfoResponse.Card }; HttpResponseMessage responseMessage2 = HttpClientService.PostAsync("api/card/GetCard", request2).Result; if (responseMessage2.IsSuccessStatusCode) { response2 = responseMessage2.Content.ReadAsAsync <CardInfoResponse>().Result; if (response2.ErrorCode == 0) { return(Json(new { data1 = clientInfoResponse, data2 = response2 })); } } return(Json(new DefaultResponse { ErrorCode = 11, Message = "Ошибка запроса к ClientInfo" })); } } return(Json(new DefaultResponse { ErrorCode = 11, Message = "Ошибка запроса к ClientInfo" })); }
public static void performTest(String method) { bool print = true; ResCode res_code = new ResCode(); SignResponse resp = null; writeToFile("\nTESTING: " + method); switch (method) { case string t when t == "SignPDF_NOPIN": resp = client.SignPDF_NOPIN(certID, File.ReadAllBytes(fnTestPDF), 1, 0, 0, 150, 150, File.ReadAllBytes(fnSig), ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedPDF, resp.SignedBytes); } break; case string t when t == "SignPDF_NOPIN_FIELD": print = false; writeToFile("* " + method + " method was not defined"); break; case string t when t == "SignPDF_PIN_FilePath": print = false; //String path = Path.GetFullPath(fnTest); //String path = fnTest; //String path = "/etc/hosts"; //String path = "C:\\Windows\\System32\\cmd.exe"; String path = "C:\\inetpub\\wwwroot\\iisstart.htm"; //String path = "signed.pdf"; //String path = "C:\\test.pdf"; res_code = client.SignPDF_PIN_FilePath(certID, path, "aaa.pdf", 1, 0, 0, 150, 150, pinCode, File.ReadAllBytes(fnSig), "").Result; writeToFile("Not testing 'SignPDF_PIN_FilePath' functionality as it takes input file paths that are located on the server side."); break; case string t when t == "SignPDF_PIN": resp = client.SignPDF_PIN(certID, File.ReadAllBytes(fnTestPDF), 1, 0, 0, 150, 150, pinCode, File.ReadAllBytes(fnSig), ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedPDF, resp.SignedBytes); } break; case string t when t == "SignPDF_SetImage": resp = client.SignPDF_SetImage(File.ReadAllBytes(fnTestPDF), 1, 0, 0, 150, 150, File.ReadAllBytes(fnSig), ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnPosted, resp.SignedBytes); } break; case string t when t == "Get_PDFSigners": print = false; String[] strRes = client.Get_PDFSigners(File.ReadAllBytes(fnSignedPDF), ""); writeToFile("Exspected strRes is: " + "NOT NULL"); writeToFile("strRes is: " + String.Join("", strRes)); writeToFile("TEST " + (strRes != null ? "PASSED" : "FAILED")); break; case string t when t == "VerifyPDF": MultiSignValidationResponse msvRes = client.VerifyPDF(File.ReadAllBytes(fnSignedPDF)); res_code = msvRes.OperationResult; break; case string t when t == "SignPDF_PIN_Placeholder": resp = client.SignPDF_PIN_Placeholder(certID, File.ReadAllBytes(fnTestPDF), pinCode, "dip", 150, 150, File.ReadAllBytes(fnSig), ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedPDFPlaceholder, resp.SignedBytes); } break; case string t when t == "EncryptPDF_UserOwnerPasswords": resp = client.EncryptPDF_UserOwnerPasswords(File.ReadAllBytes(fnTestPDF), "tony1", "tony"); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedPDFEncrypted, resp.SignedBytes); } break; case string t when t == "SignCMS_PIN": resp = client.SignCMS_PIN(certID, digest, pinCode, CTInterfaces.CTDigestAlg.SHA1, "", ""); if (resp.SignedBytes != null) { dygestedContent = resp.SignedBytes; } res_code = resp.Result; break; case string t when t == "SignCMS_NOPIN": print = false; writeToFile("* " + method + " method was not defined"); break; case string t when t == "SignRAW_PIN": resp = client.SignRAW_PIN(certID, CTInterfaces.CTDigestAlg.SHA1, digest, pinCode, ""); res_code = resp.Result; break; case string t when t == "VerifyCMS": if (dygestedContent != null) { resp = client.VerifyCMS(digest, dygestedContent); res_code = resp.Result; } else { res_code = ResCode.NO_PERM_TOKEN_PROVIDED; } break; case string t when t == "SignXml_PIN": resp = client.SignXml_PIN(certID, File.ReadAllBytes(fnTestXml), pinCode, ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedXml, resp.SignedBytes); } else { writeToFile("Error: " + res_code); } break; case string t when t == "SignForeclosure": resp = client.SignForeclosure(certID, pinCode, File.ReadAllBytes(fnTestXml), ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedXmlForeclosure, resp.SignedBytes); } break; case string t when t == "AddIdNumberToIkul": resp = client.AddIdNumberToIkul(File.ReadAllBytes(fnTestXml), idNumber, ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedXmlIdNumber, resp.SignedBytes); } break; case string t when t == "AddSigningTime": resp = client.AddSigningTime(File.ReadAllBytes(fnTestXml), date, ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedXmlSigningTime, resp.SignedBytes); } break; case string t when t == "SetCred_Absolute": try { res_code = client.SetCred_Absolute(certID, pinCode, new DateTime(2050, 1, 1), "", ""); } catch (Exception e) { print = false; writeToFile("EXCEPRION: " + e.ToString()); } break; case string t when t == "SetCred_Sliding": try { res_code = client.SetCred_Sliding(certID, pinCode, new TimeSpan(13, 0, 0), "", ""); }catch (Exception e) { print = false; writeToFile("EXCEPRION: " + e.ToString()); } break; case string t when t == "Cred_Verify": res_code = client.Cred_Verify(certID, pinCode, ""); break; case string t when t == "Cred_IsAvailable": print = false; bool boolRes = client.Cred_IsAvailable(certID, "", ""); writeToFile("Exspected Result is: " + true); writeToFile("Result is: " + boolRes.ToString()); writeToFile("TEST " + (boolRes == true ? "PASSED" : "FAILED")); break; case string t when t == "Cred_Remove": print = false; writeToFile("* " + method + " method was not defined"); break; case string t when t == "GetVersion": String version = client.GetVersion().ToString(); if (IsValidVersion(version)) { res_code = ResCode.SUCCESS; writeToFile("Version is: " + client.GetVersion().ToString()); } else { res_code = ResCode.NO_PERM_TOKEN_PROVIDED; } break; case string t when t == "GetCardInfo": CardInfoResponse info = client.GetCardInfo(certID, pinCode, ""); res_code = info.Result; break; case string t when t == "SignWord_PIN": resp = client.SignWord_PIN(certID, File.ReadAllBytes(fnTestWord), pinCode, "", ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedWord, resp.SignedBytes); } break; case string t when t == "SignExcel_PIN": resp = client.SignExcel_PIN(certID, File.ReadAllBytes(fnTestExcel), pinCode, "", ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedExcel, resp.SignedBytes); } break; case string t when t == "SignTiff_PIN": resp = client.SignTiff_PIN(certID, File.ReadAllBytes(fnTestTiff), pinCode, 150, 150, File.ReadAllBytes(fnSig), "", ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedTiff, resp.SignedBytes); } break; case string t when t == "VerifyTiff": MultiSignValidationResponse msvResTiff = client.VerifyTiff(File.ReadAllBytes(fnSignedTiff)); res_code = msvResTiff.OperationResult; break; case string t when t == "SignWord_NOPIN": print = false; writeToFile("* " + method + " method was not defined"); break; case string t when t == "SignExcel_NOPIN": print = false; writeToFile("* " + method + " method was not defined"); break; case string t when t == "SignTiff_NOPIN": print = false; writeToFile("* " + method + " method was not defined"); break; case string t when t == "SignMeches_PIN": resp = client.SignMeches_PIN(certID, File.ReadAllBytes(fnTestPDF), "", "pdf", pinCode, ""); res_code = resp.Result; if (resp.SignedBytes != null) { saveFile(fnSignedPDFMech, resp.SignedBytes); } break; } if (print) { writeToFile("Exspected ResCode is: " + ResCode.SUCCESS.ToString()); writeToFile("ResCode is: " + res_code.ToString()); writeToFile("TEST " + (res_code == ResCode.SUCCESS ? "PASSED" : "FAILED")); } }
/// <summary> /// Получает базовую инфу по карте ПЛ (статус, тип, оператор, баланс, кол-во покупок, сумма покупок, кол-во начисленных бонусов, кол-во списанных бонусов /// </summary> /// <param name="request"></param> /// <returns></returns> public CardInfoResponse GetCard(CardStatisticsRequest request) { CardInfoResponse response = new CardInfoResponse(); try { _cnn.Open(); var cmd = _cnn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "CardGet"; if (request.Card > 0) { cmd.Parameters.AddWithValue("@number", request.Card); } //cmd.Parameters.Add("@status", SqlDbType.NVarChar, 20); //cmd.Parameters["@status"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@virtual", SqlDbType.Bit, 100); //cmd.Parameters["@virtual"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@name", SqlDbType.NVarChar, 20); //cmd.Parameters["@name"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@fullbalance", SqlDbType.Decimal); //cmd.Parameters["@fullbalance"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@balance", SqlDbType.Decimal); //cmd.Parameters["@balance"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@purchases", SqlDbType.Int); //cmd.Parameters["@purchases"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@purchasesum", SqlDbType.Decimal); //cmd.Parameters["@purchasesum"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@charged", SqlDbType.Decimal); //cmd.Parameters["@charged"].Direction = ParameterDirection.Output; //cmd.Parameters.Add("@redeemed", SqlDbType.Decimal); //cmd.Parameters["@redeemed"].Direction = ParameterDirection.Output; cmd.Parameters.Add("@errormessage", SqlDbType.NVarChar, 100); cmd.Parameters["@errormessage"].Direction = ParameterDirection.Output; cmd.Parameters.Add("@result", SqlDbType.Int); cmd.Parameters["@result"].Direction = ParameterDirection.ReturnValue; var reader = cmd.ExecuteReader(); while (reader.Read()) { if (!reader.IsDBNull(0)) { response.Status = reader.GetString(0); } if (!reader.IsDBNull(1)) { response.Type = reader.GetBoolean(1); } if (!reader.IsDBNull(2)) { response.OperatorName = reader.GetString(2); } if (!reader.IsDBNull(3)) { response.FullBalance = reader.GetDecimal(3); } if (!reader.IsDBNull(4)) { response.Balance = reader.GetDecimal(4); } if (!reader.IsDBNull(5)) { response.Purchases = reader.GetInt16(5); } if (!reader.IsDBNull(6)) { response.PurchaseSum = reader.GetDecimal(6); } if (!reader.IsDBNull(7)) { response.Charged = reader.GetDecimal(7); } if (!reader.IsDBNull(8)) { response.Redeemed = reader.GetDecimal(8); } //if (!reader.IsDBNull(14)) //{ // if (reader.GetBoolean(14) == false) // { // returnValue.Gender = -1; // } // else // { // returnValue.Gender = 1; // } //} } //try { response.Status = Convert.ToString(cmd.Parameters["@status"].Value); } catch { } //try { response.OperatorName = Convert.ToString(cmd.Parameters["@name"].Value); } catch { } //try { response.Type = Convert.ToString(cmd.Parameters["@virtual"].Value); } catch { } //try { response.FullBalance = Convert.ToDecimal(cmd.Parameters["@fullbalance"].Value); } catch { } //try { response.Balance = Convert.ToDecimal(cmd.Parameters["@balance"].Value); } catch { } //try { response.Purchases = Convert.ToInt32(cmd.Parameters["@purchases"].Value); } catch { } //try { response.PurchaseSum = Convert.ToDecimal(cmd.Parameters["@purchasesum"].Value); } catch { } //try { response.Charged = Convert.ToDecimal(cmd.Parameters["@charged"].Value); } catch { } //try { response.Redeemed = Convert.ToDecimal(cmd.Parameters["@redeemed"].Value); } catch { } response.ErrorCode = Convert.ToInt32(cmd.Parameters["@result"].Value); response.Message = Convert.ToString(cmd.Parameters["@errormessage"].Value); } catch (Exception e) { response.ErrorCode = 10; response.Message = e.Message; } finally { _cnn.Close(); } return(response); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="okMessage"></param> /// <returns></returns> private ExecuteResult <CardInfoResponse> GetInfo(GetCardInfoRequest request, string okMessage) { if (request == null || request.AuthUser == null) { return(new ExecuteResult <CardInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" }); } var entities = _cardRepository.GetListForUserId(request.AuthUser.Id, CardType.YintaiMemberCard, DataStatus.Normal).ToList(); if (entities.Count == 0) { return(new ExecuteResult <CardInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "你还没有绑定会员卡,请您先绑定" }); } if (entities.Count > 1) { return(new ExecuteResult <CardInfoResponse>(null) { StatusCode = StatusCode.InternalServerError, Message = "服务器开小差了,请您等等再试" }); } var entity = entities[0]; var pointResult = _groupCardService.GetPoint(new GroupCardPointRequest { CardNo = entity.CardNo }); var cardProfile = JsonExtension.FromJson_ <CardProfile>(entity.CardProfile); if (pointResult.Success) { var response = new CardInfoResponse { Point = pointResult.Point, CardLvl = cardProfile.Lvl, CardNo = entity.CardNo, CardType = cardProfile.Type, User_Id = entity.User_Id, LastDate = DateTime.Now, Id = entity.Id }; var result = new ExecuteResult <CardInfoResponse>(response); if (!String.IsNullOrEmpty(okMessage)) { result.Message = okMessage; } return(result); } return(new ExecuteResult <CardInfoResponse>(null) { StatusCode = StatusCode.InternalServerError, Message = String.Concat("查询积分失败,", pointResult.Desc) }); }