private credential convertToDomainObject(CredentialDto credentialModel) { credential credential = null; if (credentialModel is AmazonCredentialDto) { credential = Mapper.Map <AmazonCredentialDto, amazoncredential>(credentialModel as AmazonCredentialDto); } else if (credentialModel is eBayCredentialDto) { credential = Mapper.Map <eBayCredentialDto, ebaycredential>(credentialModel as eBayCredentialDto); } else if (credentialModel is ShipStationCredentialDto) { credential = Mapper.Map <ShipStationCredentialDto, shipstationcredential>(credentialModel as ShipStationCredentialDto); } else if (credentialModel is BigCommerceCredentialDto) { credential = Mapper.Map <BigCommerceCredentialDto, bigcommercecredential>(credentialModel as BigCommerceCredentialDto); } else { throw new InvalidCastException(string.Format("Unknown credential type \'{0}\' for casting!", credentialModel.MarketplaceType)); } return(credential); }
private CredentialDto convertToModel(credential credential) { CredentialDto model = null; if (credential is amazoncredential) { model = Mapper.Map <amazoncredential, AmazonCredentialDto>(credential as amazoncredential); } else if (credential is ebaycredential) { model = Mapper.Map <ebaycredential, eBayCredentialDto>(credential as ebaycredential); } else if (credential is shipstationcredential) { model = Mapper.Map <shipstationcredential, ShipStationCredentialDto>(credential as shipstationcredential); } else if (credential is bigcommercecredential) { model = Mapper.Map <bigcommercecredential, BigCommerceCredentialDto>(credential as bigcommercecredential); } else { throw new InvalidCastException(string.Format("Unknown credential type \'{0}\' for casting!", credential.MarketplaceType)); } return(model); }
public ActionResult AddUser(string Name, string Email, string NE) //public ActionResult Inscription(InfoInscription info) { InfoInscription info = new InfoInscription(); info.Nom = Name; info.Email = Email; info.Education = NE; var username = GenererUsername(info); var pwd = GenererPwd(info); Email email = new Email(info, username, pwd); bool status = sendMail(email); if (status) { niveauEducationDataClassesDataContext db = new niveauEducationDataClassesDataContext(); Inscription eleve = new Inscription { nom = Name, email = Email, education = NE }; db.Inscriptions.InsertOnSubmit(eleve); db.SubmitChanges(); credential cr = new credential { username = username, password = pwd, email = Email, firsttime = 1 }; db.credentials.InsertOnSubmit(cr); db.SubmitChanges(); } return(View("inscription")); }
private void GetInfo(HttpContext context) { string sUserId = context.Request["UserId"]; if (string.IsNullOrEmpty(sUserId)) { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 5, "Chưa nhập đủ thông tin")); return; } if (sUserId.Trim().Length != 12 && sUserId.Trim().Length != 14) { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 6, "Số thuê bao phải là 12 hoặc 14 ký tự")); return; } if (!Utility.isOnlyNumber(sUserId)) { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 7, "Số hợp đồng phải là kiểu số")); return; } WSClient client = new WSClient(); var cred = new credential { clientId = Config.ClientIdSmartLink }; var result = client.getVoucherPaymentInfo(cred, sUserId); if (result.returnCode != "") { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", result.returnCode, result.returnCodeDescription)); return; } else { CustomerGateInfo info = XMLReader.ReadInfo(result.responseData); if (info != null) { string sVoucher = ""; if (info.vouchers != null && info.vouchers.Count > 0) { foreach (voucher voucher in info.vouchers) { if (sVoucher == "") { sVoucher += string.Format("{{\"vouchervalue\":\"{0}\",\"duration\":\"{1}\",\"vouchername\":\"{2}\",\"durationuomaltcode\":\"{3}\",\"voucherdesc\":\"{4}\"}}", voucher.vouchervalue, voucher.duration, voucher.vouchername, voucher.durationuomaltcode, voucher.voucherdesc); } else { sVoucher += "," + string.Format("{{\"vouchervalue\":\"{0}\",\"duration\":\"{1}\",\"vouchername\":\"{2}\",\"durationuomaltcode\":\"{3}\",\"voucherdesc\":\"{4}\"}}", voucher.vouchervalue, voucher.duration, voucher.vouchername, voucher.durationuomaltcode, voucher.voucherdesc); } } } context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\",\"subnum\":\"{2}\",\"contactname\":\"{3}\",\"contactaddress\":\"{4}\"," + "\"contactphone\":\"{5}\",\"contactemail\":\"{6}\",\"servicename\":\"{7}\",\"substatusname\":\"{8}\"," + "\"expirationdate\":\"{9}\",\"vouchers\":[{10}] }}", 0, "load thông tin ok", info.subnum, info.contactname, info.contactaddress, info.contactphone, info.contactemail, info.servicename, info.substatusname, info.expirationdate, sVoucher)); context.Session[Config.GetSessionUser] = info; } else { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 8, "Không tìm thấy thông tin khách hàng")); } } }
public municipality Save() { _munit.name = this.textBoxDictMunitName.Text.Trim(); _munit.@operator = this.textBoxDictOperator.Text.Trim(); _munit.remark = this.textBoxDictRemark.Text.Trim(); if (_munit.municipality_id == 0) Repo.Add(_munit); Repo.SaveChanges(); var cred = Repo.GetCredentialSync(_munit.municipality_id, LoginType.Municipality); if (cred == null) { cred = new credential { ref_id = _munit.municipality_id, login_type = (int) LoginType.Municipality }; Repo.Add(cred); } cred.login = this.textBoxDictLogin.Text.Trim(); cred.passwd = this.textBoxDictPassword.Text.Trim(); Repo.SaveChanges(); this.labelError.Text = string.Empty; return _munit; }
private Credential convertToModel(credential credential) { Credential model = null; if (credential is amazoncredential) { var item = credential as amazoncredential; model = new AmazonCredential { AccessKeyId = item.AccessKeyId, AssociateId = item.AssociateId, CompanyId = item.CompanyId, Id = item.Id, IsDefault = item.IsDefault, IsEnabled = item.IsEnabled, MarketplaceId = item.MarketplaceId, MarketplaceType = item.MarketplaceType, MerchantId = item.MerchantId, Mode = item.Mode, Name = item.Name, SearchAccessKeyId = item.SearchAccessKeyId, SearchSecretKey = item.SearchSecretKey, SecretKey = item.SecretKey, ServiceEndPoint = item.ServiceEndPoint }; } else if (credential is ebaycredential) { var item = credential as ebaycredential; model = new eBayCredential { ApplicationId = item.ApplicationId, DeveloperId = item.DeveloperId, CertificationId = item.CertificationId, UserToken = item.UserToken, CompanyId = item.CompanyId, Id = item.Id, IsDefault = item.IsDefault, IsEnabled = item.IsEnabled, MarketplaceId = item.MarketplaceId, MarketplaceType = item.MarketplaceType, Mode = item.Mode, Name = item.Name, ServiceEndPoint = item.ServiceEndPoint }; } else if (credential is bigcommercecredential) { var item = credential as bigcommercecredential; model = new BigCommerceCredential { Username = item.Username, ApiKey = item.ApiKey, CompanyId = item.CompanyId, Id = item.Id, IsDefault = item.IsDefault, IsEnabled = item.IsEnabled, MarketplaceId = item.MarketplaceId, MarketplaceType = item.MarketplaceType, Mode = item.Mode, Name = item.Name, ServiceEndPoint = item.ServiceEndPoint }; } else { throw new InvalidCastException(string.Format("Unknown credential type \'{0}\' for casting!", credential.MarketplaceType)); } return(model); }
public Credentials(credential cred) { CredId = cred.credentials_id; this.LoginType = (LoginType) cred.login_type; }
private void GateFTP(HttpContext context, string UserId, string CardSerials, string CardPin, string sType) { GateCardInfo info = new GateCardInfo() { UserId = UserId, CardId = CardPin, SerialsId = CardSerials, CreateDate = DateTime.Now, ServiceID = sType }; try { AuthenSoapHeader authen = new AuthenSoapHeader(); authen.UserName = Config.UserServicesGate; authen.Password = Config.PassServicesGate; WsGateCardSoapClient client = new WsGateCardSoapClient(); var result = client.CardInputSandbox(authen, sType, CardSerials, CardPin); if (result.ErrorCode == "00") { //Giao dịch GateCard thành công info.ResultId = result.ErrorCode; info.Msg = result.ErrorMessage; info.Amount = int.Parse(result.Amount); info.TransId = result.TransId; SubmitVoucherInfo sbInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdFPT, UserId = UserId, Amount = info.Amount, CreateDate = DateTime.Now, TransId = info.TransId }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdFPT }; var wsResult = wsclient.submitVoucher(cred, UserId, result.Amount, info.TransId); sbInfo.returnCode = wsResult.returnCode; sbInfo.returnCodeDescription = wsResult.returnCodeDescription; sbInfo.responseData = wsResult.responseData; sbInfo.signature = wsResult.signature; if (sbInfo.returnCode == "") { string sDate = ReadResultVocher(sbInfo.responseData); context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 0, sDate)); return; } else { context.Response.Write(string.Format("{{\"error\":\"{0}\",\"msg\":\"{1}\"}}", sbInfo.returnCode, sbInfo.returnCodeDescription)); return; } } catch (Exception e) { //log error context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", e.GetHashCode(), e.Message)); sbInfo.returnCode = e.GetHashCode().ToString(); sbInfo.returnCodeDescription = e.Message; return; } finally { SubmitVoucherData.instance.Add(sbInfo); } } else { info.ResultId = result.ErrorCode; info.Msg = result.ErrorMessage; context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", result.ErrorCode, result.ErrorMessage)); } } catch (Exception e) { //log error context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", e.GetHashCode(), e.Message)); //if (info.ResultId == "") //{ // info.ResultId = e.GetHashCode().ToString(); // info.Msg = e.Message; //} return; } finally { GateCardData.instance.Add(info); } }
public edu Save() { _edu.municipality = (municipality)comboBoxMunit.SelectedItem; _edu.edu_kind = (edu_kind) comboBoxEduKind.SelectedItem; _edu.fullname = this.textBoxDictEduName.Text.Trim(); _edu.name = this.textBoxDictEduShortName.Text.Trim(); if (string.IsNullOrEmpty(this.textBoxDictEduNumber.Text)) _edu.edu_number = null; else _edu.edu_number = Convert.ToInt32(this.textBoxDictEduNumber.Text); _edu.@operator = this.textBoxDictEduOperator.Text.Trim(); _edu.accreditation_date = DateTime.MinValue; _edu.accreditation_end_date = DateTime.MinValue; _edu.license_date = DateTime.MinValue; _edu.license_end_date = DateTime.MinValue; if (_edu.edu_id == 0) { Repo.Add(_edu); Repo.SaveChanges(); } var cred = Repo.GetCredential(_edu.edu_id, LoginType.Edu).Result; if (cred == null) { cred = new credential { ref_id = _edu.edu_id, login_type = (int)LoginType.Edu, alias = string.Empty }; Repo.Add(cred); } cred.login = this.textBoxDictLogin.Text.Trim(); cred.passwd = this.textBoxDictPassword.Text.Trim(); Repo.SaveChanges(); this.labelError.Text = string.Empty; return _edu; }
/** * CallService * Parms were already read. Now call the service proxy classes * */ void CallService() { string simpleGenKey = null; string structGenKey = null; // Instantiate the service, and create the service url Console.WriteLine(); Console.WriteLine(" CLIENT>> creates the client proxy : use input url."); Console.WriteLine(); PLMKeyManagementClient genKeySvc = new PLMKeyManagementClient("IPLMKeyManagement", _url); try { Console.WriteLine(" CLIENT>> call the first web method of the PLMKey service."); Console.WriteLine(" CLIENT>> ======================================================.\n"); string contextURI = "CAATEST:" + _companyName + ":" + _productName; string validityURI = "CAATEST:" + _validityInMn; Console.WriteLine(" CLIENT>> input data:"); Console.WriteLine("\tadminKey =\"" + _adminKey + "\""); Console.WriteLine("\tuserName =\"" + _userName + "\""); Console.WriteLine("\tuserPwd =\"" + _pwdName + "\""); Console.WriteLine("\tcontextURI =\"" + contextURI + "\""); Console.WriteLine("\tvalidityURI=\"" + validityURI + "\""); Console.WriteLine(" CLIENT>> call the generatePLMKeyFromSimpleContext.\n"); simpleGenKey = genKeySvc.generatePLMKeyFromSimpleContext(_adminKey, _userName, _pwdName, contextURI, validityURI); Console.WriteLine(" CLIENT>> key generated from simple context =\"{0}\"\n\n", simpleGenKey); } catch (Exception e) { Console.WriteLine(">>>PLMKey SERVICE EXCEPTION (SIMPLE CONTEXT METHOD) <<<\n" + e); } try { Console.WriteLine(" CLIENT>> Test the 2nd web method of the PLMKey service. "); Console.WriteLine(" CLIENT>> ======================================================.\n"); // create the credentialset object and fill it with the right credential values: // (given that the credentials name and type are know by the client) // authentication : <user> <password> // applicative : <company> <product> // validity : <validityMinutes> CredentialSet csInstance = new CredentialSet(); csInstance.id = "CAATEST"; // a) the authentication credentials. credential userCred = new credential(); userCred.name = "user"; userCred.Value = _userName; credential pwdCred = new credential(); pwdCred.name = "password"; pwdCred.Value = _pwdName; pwdCred.ispassword = true; // add the credentials to the credential set authentication part. csInstance.authentication = new credential[2]; csInstance.authentication[0] = userCred; csInstance.authentication[1] = pwdCred; //b) the applicative credentials credential companyCred = new credential(); companyCred.name = "company"; companyCred.Value = _companyName; credential productCred = new credential(); productCred.name = "product"; productCred.Value = _productName; csInstance.applicative = new credential[2]; csInstance.applicative[0] = companyCred; csInstance.applicative[1] = productCred; //c) the validity credentials credential validCred = new credential(); validCred.name = "validityMinutes"; validCred.Value = _validityInMn.ToString(); csInstance.validity = new credential[1]; csInstance.validity[0] = validCred; structGenKey = genKeySvc.generatePLMKeyFromStructuredContext(_adminKey, csInstance); Console.WriteLine(" CLIENT>> key generated from structured context =\"{0}\"\n\n", structGenKey); } catch (Exception e) { Console.WriteLine(">>>PLMKey SERVICE EXCEPTION (STRUCTURED CONTEXT METHOD) <<<\n" + e); } string keysToRevoke = null; if (simpleGenKey != null) { keysToRevoke = simpleGenKey; } if (structGenKey != null) { if (keysToRevoke == null) { keysToRevoke = structGenKey; } else { keysToRevoke += " "; keysToRevoke += structGenKey; } } try { Console.WriteLine(" CLIENT>> Test revocation web method of the PLMKey service. "); Console.WriteLine(" CLIENT>> ======================================================.\n"); genKeySvc.revokePLMKeys(_adminKey, keysToRevoke); Console.WriteLine(" CLIENT>> revocation of keys =\"{0}\" is done", keysToRevoke); } catch (Exception e) { Console.WriteLine(">>>PLMKey SERVICE EXCEPTION (KEY REVOCATION METHOD) <<<\n" + e); } }
protected void Page_Load(object sender, EventArgs e) { string sTranId = Request.QueryString["vpc_MerchTxnRef"]; if (string.IsNullOrEmpty(sTranId)) { Response.Redirect("/SmartLink/", true); } //Check info Smartlink Hashtable hash = new Hashtable(); foreach (String key in Request.QueryString.AllKeys) { if (key.StartsWith("vpc_")) { hash.Add(key, Request.QueryString[key]); } } bool isEmptysecureSecret; bool isValidsecureHash = SmartLinkHelper.checkSum(hash, out isEmptysecureSecret); if (isEmptysecureSecret) { Response.Redirect("/SmartLink/", true); } if (!isValidsecureHash) { Response.Redirect("/SmartLink/", true); } //check info AV CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserSmartlink, sTranId)); if (oCache == null) { Response.Redirect("/SmartLink/", true); } string sDerection = ""; SmartlinkQueryInfo oQueryInfo = new SmartlinkQueryInfo() { CreateDate = DateTime.Now }; try { string sStatus = SmartLinkHelper.GetQuery(sTranId, ref oQueryInfo);//chư thấy trả về if (!string.IsNullOrEmpty(sStatus)) { String[] arr = sStatus.Split('&'); foreach (String item in arr) { String[] temp = item.Split('='); if ("vpc_DRExists".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_DRExists = temp[1]; } if ("vpc_FoundMultipleDRs".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_FoundMultipleDRs = temp[1]; } if ("vpc_Message".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_Message = temp[1]; } if ("vpc_SecureHash".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_SecureHash = temp[1]; } if ("vpc_TxnResponseCode".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_TxnResponseCode = temp[1]; } } //giao dịch thành công if (oQueryInfo.vpc_TxnResponseCode == "0") { //submit voucher SubmitVoucherInfo oSVInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdSmartLink, UserId = oCache.User.subnum, Amount = int.Parse(oCache.Voucher.vouchervalue), CreateDate = DateTime.Now, TransId = sTranId }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdSmartLink }; var wsResult = wsclient.submitVoucher(cred, oSVInfo.UserId, oSVInfo.Amount.ToString(), oSVInfo.TransId); oSVInfo.returnCode = wsResult.returnCode; oSVInfo.returnCodeDescription = wsResult.returnCodeDescription; string sResultDate = XMLReader.ReadResultVocher(wsResult.responseData);//dt oSVInfo.responseData = sResultDate; oSVInfo.signature = wsResult.signature; if (oSVInfo.returnCode == "") { Session[Config.GetSessionsResultDate] = sResultDate;//ss sDerection = "/SmartLink/#" + sTranId + "|T"; } else { //Session[Config.GetSessionsResultFail] = wsResult.returnCodeDescription;//ss Session[Config.GetSessionsResultFail] = "Giao dịch không thành công"; sDerection = "/SmartLink/#" + sTranId + "|F|Y"; } } catch (Exception ex) { //log error Session[Config.GetSessionsResultFail] = ex.Message; oSVInfo.returnCode = ex.GetHashCode().ToString(); oSVInfo.returnCodeDescription = ex.Message; sDerection = "/SmartLink/#" + sTranId + "|F|Y"; } finally { SubmitVoucherData.instance.Add(oSVInfo); //Response.Redirect(sDerection); } } else { //Session[Config.GetSessionsResultFail] = SmartLinkHelper.getResponseDescription(oQueryInfo.vpc_TxnResponseCode??""); Session[Config.GetSessionsResultFail] = "Giao dịch không thành công"; sDerection = "/SmartLink/#" + sTranId + "|F"; } } else { sDerection = "/SmartLink/#" + sTranId + "|F"; } } catch (Exception ex) { oQueryInfo.vpc_TxnResponseCode = ex.GetHashCode().ToString(); oQueryInfo.vpc_Message = ex.Message; sDerection = "/SmartLink/#" + sTranId + "|F"; } finally { CacheProvider.Remove(string.Format(KeyCache.KeyUserSmartlink, sTranId)); SmartlinkQueryData.instance.Add(oQueryInfo); if (sDerection != "") { Response.Redirect(sDerection); } } }
protected void Page_Load(object sender, EventArgs e) { string Good_Code = Request.QueryString["code"]; if (string.IsNullOrEmpty(Good_Code)) { Response.Redirect("/Banknet/", true); } CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserBanknet, Good_Code)); if (oCache == null) { Response.Redirect("/Banknet/", true); } string sRedirection = "/Banknet/"; SubmitVoucherInfo oSVInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdBanknet, UserId = oCache.User.subnum, Amount = int.Parse(oCache.Voucher.vouchervalue), CreateDate = DateTime.Now, TransId = Good_Code }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdBanknet }; var wsResult = wsclient.submitVoucher(cred, oSVInfo.UserId, oSVInfo.Amount.ToString(), oSVInfo.TransId); oSVInfo.returnCode = wsResult.returnCode; oSVInfo.returnCodeDescription = wsResult.returnCodeDescription; string sResultDate = XMLReader.ReadResultVocher(wsResult.responseData);//dt oSVInfo.responseData = sResultDate; oSVInfo.signature = wsResult.signature; if (oSVInfo.returnCode == "") { Session[Config.GetSessionsResultDate] = sResultDate;//ss //confirm ThreadStart newThread = delegate { Confirm(oCache.Merchant_trans_id, oCache.sTrans_Id); }; Thread myThread = new Thread(newThread); myThread.Start(); sRedirection = "/Banknet/#" + Good_Code + "|T"; } else { Session[Config.GetSessionsResultFail] = wsResult.returnCodeDescription;//ss sRedirection = "/Banknet/#" + Good_Code + "|F|Y"; } } catch (Exception ex) { //log error Session[Config.GetSessionsResultFail] = ex.Message; oSVInfo.returnCode = ex.GetHashCode().ToString(); oSVInfo.returnCodeDescription = ex.Message; sRedirection = "/Banknet/#" + Good_Code + "|F|Y"; } finally { SubmitVoucherData.instance.Add(oSVInfo); Response.Redirect(sRedirection); } }