public string BSESIPorderEntryParam(int UserID, string ClientCode, OnlineMFOrderVo onlinemforderVo, int CustomerId, string DematAcctype, out char msgType, out IDictionary <string, string> sipOrderIds) { DemoBSEMFOrderEntry.MFOrderEntryClient webOrderEntryClient = new DemoBSEMFOrderEntry.MFOrderEntryClient(); BSEMFSIPOdererVo bseMFSIPOdererVo = new BSEMFSIPOdererVo(); msgType = 'F'; string message = string.Empty; int systematicId = 0; int rmsId = 0; sipOrderIds = null; try { string orderEntryresponse = string.Empty; string PurchaseType = string.Empty; string purchase = string.Empty; OnlineMFOrderDao OnlineMFOrderDao = new OnlineMFOrderDao(); string bseuserID = string.Empty; string bsepass = string.Empty; bool result = false; string bseMemberId = string.Empty; DataSet ds = OnlineMFOrderDao.GetAPICredentials("BSE", 1021); if (ds != null && ds.Tables[0].Rows.Count > 0) { bseuserID = ds.Tables[0].Rows[0]["AEAC_Username"].ToString(); bsepass = ds.Tables[0].Rows[0]["AEAC_Password"].ToString(); bseMemberId = ds.Tables[0].Rows[0]["AEAC_MemberId"].ToString(); } string passkey = "E234586789D12"; string password = webOrderEntryClient.getPassword(bseuserID, bsepass, passkey); string[] bsePassArray = password.Split('|'); if (bsePassArray[0].ToString() == "100") { if (onlinemforderVo.DividendType != "0" && onlinemforderVo.DividendType != "") { onlinemforderVo.BSESchemeCode = OnlineMFOrderDao.BSESchemeCode(onlinemforderVo.SchemePlanCode, onlinemforderVo.DividendType); } if (DematAcctype == "CDSL" || DematAcctype == "") { DematAcctype = "C"; } else if (DematAcctype == "NSDL") { DematAcctype = "N"; } bseMFSIPOdererVo.Password = bsePassArray[1]; if (onlinemforderVo.IsCancelled != "True" && onlinemforderVo.IsCancelled == null) { bseMFSIPOdererVo.Transactioncode = "NEW"; } else { bseMFSIPOdererVo.Transactioncode = "CXL"; systematicId = onlinemforderVo.SystematicId; } bseMFSIPOdererVo.BSEOrderId = 0; bseMFSIPOdererVo.BSEUserId = bseuserID; bseMFSIPOdererVo.MemberId = bseMemberId; bseMFSIPOdererVo.ClientCode = ClientCode; bseMFSIPOdererVo.SchemeCode = onlinemforderVo.BSESchemeCode; //bseMFSIPOdererVo.InternalReferenceNo = transCode; bseMFSIPOdererVo.TransMode = "D"; bseMFSIPOdererVo.DPTransactionMode = DematAcctype; bseMFSIPOdererVo.StartDate = String.Format("{0:d}", onlinemforderVo.StartDate); bseMFSIPOdererVo.FrequenceType = GetBSESIPFrequencyCode(onlinemforderVo.FrequencyCode); bseMFSIPOdererVo.FrequenceAllowed = "1"; bseMFSIPOdererVo.InstallmentAmount = Convert.ToInt16(onlinemforderVo.Amount).ToString(); bseMFSIPOdererVo.NoOfInstallments = onlinemforderVo.TotalInstallments.ToString(); bseMFSIPOdererVo.Remarks = string.Empty; bseMFSIPOdererVo.FolioNo = string.Empty;// As its demat SIP bseMFSIPOdererVo.FirstOrderFlag = "Y"; bseMFSIPOdererVo.SubBRCode = string.Empty; bseMFSIPOdererVo.EUIN = "E116327"; bseMFSIPOdererVo.EUINDeclarationFlag = "Y"; bseMFSIPOdererVo.DPC = "Y"; bseMFSIPOdererVo.REGID = onlinemforderVo.IsCancelled == "True" ? onlinemforderVo.BSEREGID.ToString(): string.Empty; bseMFSIPOdererVo.IPAddress = string.Empty; bseMFSIPOdererVo.Password = bsePassArray[1]; bseMFSIPOdererVo.PassKey = passkey; bseMFSIPOdererVo.Param1 = string.Empty; bseMFSIPOdererVo.Param2 = string.Empty; bseMFSIPOdererVo.Param3 = string.Empty; bseMFSIPOdererVo.MandateId = onlinemforderVo.MandateId.ToString(); Random ran = new Random(); int transCode = OnlineMFOrderDao.BSEMFSIPorderResponseParam(bseMFSIPOdererVo, rmsId, UserID); bseMFSIPOdererVo.UniqueReferanceNumber = transCode.ToString() + ran.Next().ToString(); bseMFSIPOdererVo.InternalReferenceNo = transCode.ToString(); if (onlinemforderVo.ModeTypeCode == "BXSIP") { orderEntryresponse = webOrderEntryClient.xsipOrderEntryParam(bseMFSIPOdererVo.Transactioncode, bseMFSIPOdererVo.UniqueReferanceNumber, bseMFSIPOdererVo.SchemeCode, bseMFSIPOdererVo.MemberId, bseMFSIPOdererVo.ClientCode, bseMFSIPOdererVo.BSEUserId , bseMFSIPOdererVo.InternalReferenceNo, bseMFSIPOdererVo.TransMode, bseMFSIPOdererVo.DPTransactionMode , bseMFSIPOdererVo.StartDate, bseMFSIPOdererVo.FrequenceType, bseMFSIPOdererVo.FrequenceAllowed, bseMFSIPOdererVo.InstallmentAmount , bseMFSIPOdererVo.NoOfInstallments, bseMFSIPOdererVo.Remarks, bseMFSIPOdererVo.FolioNo, bseMFSIPOdererVo.FirstOrderFlag , bseMFSIPOdererVo.SubBRCode, bseMFSIPOdererVo.MandateId, bseMFSIPOdererVo.SubBRCode, bseMFSIPOdererVo.EUIN, bseMFSIPOdererVo.EUINDeclarationFlag, bseMFSIPOdererVo.DPC, bseMFSIPOdererVo.REGID , bseMFSIPOdererVo.IPAddress, bseMFSIPOdererVo.Password, bseMFSIPOdererVo.PassKey, bseMFSIPOdererVo.Param1, bseMFSIPOdererVo.Param2, bseMFSIPOdererVo.Param3); } else if (onlinemforderVo.ModeTypeCode == "BSSIP") { orderEntryresponse = webOrderEntryClient.sipOrderEntryParam(bseMFSIPOdererVo.Transactioncode, bseMFSIPOdererVo.UniqueReferanceNumber, bseMFSIPOdererVo.SchemeCode, bseMFSIPOdererVo.MemberId, bseMFSIPOdererVo.ClientCode, bseMFSIPOdererVo.BSEUserId, bseMFSIPOdererVo.InternalReferenceNo, bseMFSIPOdererVo.TransMode, bseMFSIPOdererVo.DPTransactionMode, bseMFSIPOdererVo.StartDate, bseMFSIPOdererVo.FrequenceType, bseMFSIPOdererVo.FrequenceAllowed, bseMFSIPOdererVo.InstallmentAmount, bseMFSIPOdererVo.NoOfInstallments, bseMFSIPOdererVo.Remarks, bseMFSIPOdererVo.FolioNo, bseMFSIPOdererVo.FirstOrderFlag, bseMFSIPOdererVo.SubBRCode, bseMFSIPOdererVo.EUIN, bseMFSIPOdererVo.EUINDeclarationFlag, bseMFSIPOdererVo.DPC, bseMFSIPOdererVo.REGID, bseMFSIPOdererVo.IPAddress, bseMFSIPOdererVo.Password, bseMFSIPOdererVo.PassKey, bseMFSIPOdererVo.Param1, bseMFSIPOdererVo.Param2, bseMFSIPOdererVo.Param3); } string[] bseorderEntryresponseArray = orderEntryresponse.Split('|'); Int64 bseSIPId = 0; Int64.TryParse(bseorderEntryresponseArray[5], out bseSIPId); OnlineMFOrderDao.BSEMFSIPorderResponseParam(transCode, UserID, bseSIPId, bseMemberId, ClientCode, bseorderEntryresponseArray[6], bseorderEntryresponseArray[7], rmsId, bseMFSIPOdererVo.UniqueReferanceNumber); if (bseorderEntryresponseArray[7] == "0") { if (onlinemforderVo.ModeTypeCode == "BXSIP" && onlinemforderVo.IsCancelled != "True") { OnlineMFOrderDao.UpdateSystematicStep(onlinemforderVo.SystematicId, "IP", UserID); systematicId = onlinemforderVo.SystematicId; } else if (onlinemforderVo.ModeTypeCode == "BSSIP" && onlinemforderVo.IsCancelled != "True") { sipOrderIds = CreateOrderMFSipDetails(onlinemforderVo, UserID); systematicId = Convert.ToInt32(sipOrderIds["SIPId"].ToString()); } result = OnlineMFOrderDao.BSESIPRequestUpdate(systematicId, transCode); msgType = 'S'; } else if (bseorderEntryresponseArray[7] != "0" && onlinemforderVo.ModeTypeCode == "BXSIP") { OnlineMFOrderDao.UpdateSystematicStep(onlinemforderVo.SystematicId, "RJ", UserID); } message = bseorderEntryresponseArray[6]; //} //else //{ // message = "No response from RMS"; //} } else { message = "Unable to process the order as Exchange is not available for Now."; } } catch (Exception ex) { message = "Unable to process the order as Exchange is not available for Now." + ex.Message; } finally { webOrderEntryClient.Close(); } return(message); }
public string BSEorderEntryParam(int UserID, string ClientCode, OnlineMFOrderVo onlinemforderVo, int CustomerId, string DematAcctype, out char msgType) { DemoBSEMFOrderEntry.MFOrderEntryClient webOrderEntryClient = new DemoBSEMFOrderEntry.MFOrderEntryClient(); List <int> orderIds = new List <int>(); msgType = 'F'; string message = string.Empty; bool isRMSDebited = false; int rmsId = 0; try { string PurchaseType = string.Empty; string purchase = string.Empty; OnlineMFOrderDao OnlineMFOrderDao = new OnlineMFOrderDao(); string bseuserID = string.Empty; string bsepass = string.Empty; string bseMemberId = string.Empty; DataSet ds = OnlineMFOrderDao.GetAPICredentials("BSE", 1021); if (ds != null && ds.Tables[0].Rows.Count > 0) { bseuserID = ds.Tables[0].Rows[0]["AEAC_Username"].ToString(); bsepass = ds.Tables[0].Rows[0]["AEAC_Password"].ToString(); bseMemberId = ds.Tables[0].Rows[0]["AEAC_MemberId"].ToString(); } string passkey = "E234586789D12"; string password = webOrderEntryClient.getPassword(bseuserID, bsepass, passkey); string[] bsePassArray = password.Split('|'); if (bsePassArray[0].ToString() == "100") { if (onlinemforderVo.DividendType != "0" && onlinemforderVo.DividendType != "") { onlinemforderVo.BSESchemeCode = OnlineMFOrderDao.BSESchemeCode(onlinemforderVo.SchemePlanCode, onlinemforderVo.DividendType); } string allRedeem = "N"; string DPCFlag = "Y"; string Amount = string.Empty; string Unit = string.Empty; if (DematAcctype == "CDSL" || DematAcctype == "") { DematAcctype = "C"; } else if (DematAcctype == "NSDL") { DematAcctype = "N"; } if (onlinemforderVo.TransactionType == "BUY") { Amount = onlinemforderVo.Amount.ToString(); PurchaseType = "FRESH"; purchase = "P"; } else if (onlinemforderVo.TransactionType == "ABY") { Amount = onlinemforderVo.Amount.ToString(); PurchaseType = "ADDITIONAL"; purchase = "P"; } else if (onlinemforderVo.TransactionType == "SEL") { if (onlinemforderVo.IsAllUnits) { allRedeem = "Y"; } else { Unit = onlinemforderVo.Redeemunits.ToString(); } PurchaseType = "FRESH"; purchase = "R"; DPCFlag = "N"; } if (onlinemforderVo.TransactionType != "SEL") { isRMSDebited = DebitOrCreditRMSUserAccountBalance(UserID, ClientCode, -onlinemforderVo.Amount, rmsId, out rmsId); } else if (onlinemforderVo.TransactionType == "SEL") { isRMSDebited = true; } if (isRMSDebited) { int transCode = OnlineMFOrderDao.BSEorderEntryParam("NEW", UserID, ClientCode, onlinemforderVo.BSESchemeCode, purchase, PurchaseType, DematAcctype, Amount, Unit, allRedeem, "", "Y", "", "", "E116327", "Y", "N", DPCFlag, "", rmsId); string uniqueRefNo; Random ran = new Random(); uniqueRefNo = transCode.ToString() + ran.Next().ToString(); string orderEntryresponse = webOrderEntryClient.orderEntryParam("NEW", uniqueRefNo, "", bseuserID, bseMemberId, ClientCode, onlinemforderVo.BSESchemeCode, purchase, PurchaseType, DematAcctype, Amount, Unit, allRedeem, "", "", "Y", "", "", "E116327", "Y", "N", DPCFlag, "", bsePassArray[1], passkey, "", "", ""); string[] bseorderEntryresponseArray = orderEntryresponse.Split('|'); OnlineMFOrderDao.BSEorderResponseParam(transCode, UserID, Convert.ToInt64(bseorderEntryresponseArray[2]), ClientCode, bseorderEntryresponseArray[6], bseorderEntryresponseArray[7], rmsId, uniqueRefNo); if (Convert.ToInt32(bseorderEntryresponseArray[7]) == 1) { if (onlinemforderVo.TransactionType != "SEL") { DebitOrCreditRMSUserAccountBalance(UserID, ClientCode, onlinemforderVo.Amount, rmsId, out rmsId); } message = "Order cannot be processed." + bseorderEntryresponseArray[6]; } else if ((Convert.ToInt32(bseorderEntryresponseArray[7]) == 0)) { orderIds = CreateCustomerOnlineMFOrderDetails(onlinemforderVo, UserID, CustomerId); bool result = OnlineMFOrderDao.BSERequestOrderIdUpdate(orderIds[0], transCode, rmsId); message = "Order placed successfully with Exchange. Order reference no is " + orderIds[0].ToString(); msgType = 'S'; } } else { message = "No response from RMS"; } } else { message = "Unable to process the order as Exchange is not available for Now."; } } catch (Exception ex) { if (isRMSDebited && onlinemforderVo.TransactionType != "SEL") { DebitOrCreditRMSUserAccountBalance(UserID, ClientCode, onlinemforderVo.Amount, rmsId, out rmsId); } message = "Unable to process the order as Exchange is not available for Now." + ex.Message; } finally { webOrderEntryClient.Close(); } return(message); }