private void HandleModify(BOL_REQUEST_ID oREQUEST_ID, DataRow row) { string strMsg = ""; REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out strMsg)) // If updated_at is not already modified { //update the record oREQUEST_ID.GD = string.IsNullOrEmpty(oREQUEST_ID.GD_CODE) ? 0 : 2; oREQUEST_ID.PASSWORD_EXPIRATION_DATE = oREQUEST_ID.DISABLED_FLG == "*" ? null : oREQUEST_ID.PASSWORD_EXPIRATION_DATE; oREQUEST_ID.PASSWORD_SET_DATE = oREQUEST_ID.DISABLED_FLG == "*" ? null : oREQUEST_ID.PASSWORD_SET_DATE; DAL_REQUEST_ID.Update(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out strMsg); } else { ResponseUtility.ReturnFailMessage(row); return; } //return message and MK value if (String.IsNullOrEmpty(strMsg)) //success { ResponseUtility.ReturnSuccessMessage(row, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER); } else //failed { ResponseUtility.MailSendingFail(row); } }
public async Task WhenNavigatingToTheHasSignInPage_ThenTheARedirectToYourDetailsIsReturned() { SessionService.Get(Arg.Is("TempSupportRequestId")).Returns(REQUEST_ID.ToString()); var actual = await sut.Index(); actual.Should().BeOfType <RedirectToActionResult>(); }
public MetaResponse SendMail(string CompanyCodeList) { try { string strMsg = ""; DataTable dgvList = Utility.Utility_Component.JsonToDt(CompanyCodeList); for (int i = 0; i < dgvList.Rows.Count; i++) { //cast to REQUEST_ID object BOL_REQUEST_ID oREQUEST_ID = new BOL_REQUEST_ID(); oREQUEST_ID = Cast_REQUEST_ID(dgvList.Rows[i]); REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out strMsg)) // If updated_at is not already modified { bool mailSuccess = PrepareAndSendMail(oREQUEST_ID); if (mailSuccess) { //update email sent date oREQUEST_ID.EMAIL_SEND_DATE = TEMP; DAL_REQUEST_ID.UpdateMailDate(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out strMsg); if (String.IsNullOrEmpty(strMsg)) { //success message dgvList.Rows[i]["EMAIL_SEND_DATE"] = UPDATED_AT_DATETIME; ResponseUtility.ReturnMailSuccessMessage(dgvList.Rows[i], UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER); } else { //fail message ResponseUtility.MailSendingFail(dgvList.Rows[i]); } } else { ResponseUtility.MailSendingFail(dgvList.Rows[i]); } } else { ResponseUtility.ReturnFailMessage(dgvList.Rows[i]); } } response.Status = 1; response.Data = Utility.Utility_Component.DtToJSon(dgvList, "Mail status");; timer.Stop(); response.Meta.Duration = timer.Elapsed.TotalSeconds; return(response); } catch (Exception ex) { return(ResponseUtility.GetUnexpectedResponse(response, timer, ex)); } }
public MetaResponse GDConfirmRequest(string list) { try { string msg = ""; DataTable dgvList = Utility.Utility_Component.JsonToDt(list); for (int i = 0; i < dgvList.Rows.Count; i++) { BOL_REQUEST_DETAIL oREQUEST_DETAIL = new BOL_REQUEST_DETAIL(); BOL_REQUEST_ID oREQUEST_ID = new BOL_REQUEST_ID(); //cast into objects oREQUEST_ID = Cast_REQUEST_ID(dgvList.Rows[i]); oREQUEST_DETAIL = Cast_REQUEST_DETAIL(dgvList.Rows[i]); //send mail bool mailSuccess = PrepareAndSendMail(oREQUEST_DETAIL, true, null); if (mailSuccess) { REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out msg)) { //set GD to 1 oREQUEST_ID.GD = 1; //insert the record DAL_REQUEST_ID.GDConfirmationRequestUpdate(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out msg); //return message and MK value if (String.IsNullOrEmpty(msg)) //success { ResponseUtility.ReturnSuccessMessage(dgvList.Rows[i], UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER, string.Format(Utility.Messages.Jimugo.I000ZZ016, "GD確認依頼")); } else //failed { ResponseUtility.ReturnFailMessage(dgvList.Rows[i]); } } } else { ResponseUtility.MailSendingFail(dgvList.Rows[i]); } } response.Status = 1; response.Data = Utility.Utility_Component.DtToJSon(dgvList, "GD Confirm Request");; timer.Stop(); response.Meta.Duration = timer.Elapsed.TotalSeconds; return(response); } catch (Exception ex) { return(ResponseUtility.GetUnexpectedResponse(response, timer, ex)); } }
private void HandleModify(BOL_REQUEST_DETAIL oREQUEST_DETAIL, BOL_REQUEST_ID oREQUEST_ID, DataRow row) { string msg = ""; using (TransactionScope dbTxn = new TransactionScope()) { #region UPDATE REQUEST_DETSIL REQUEST_DETAIL DAL_REQUEST_DETAIL = new REQUEST_DETAIL(con); if (!DAL_REQUEST_DETAIL.IsAlreadyUpdated(oREQUEST_DETAIL, out msg)) // If updated_at is not already modified { //insert the record DAL_REQUEST_DETAIL.UpdateUsageApplication(oREQUEST_DETAIL, CURRENT_DATETIME, CURRENT_USER, out msg); if (!string.IsNullOrEmpty(msg)) { dbTxn.Dispose(); ResponseUtility.ReturnFailMessage(row); return; } } else { dbTxn.Dispose(); ResponseUtility.ReturnFailMessage(row); return; } #endregion #region UPDATE REQUEST_ID REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out msg)) // If updated_at is not already modified { //insert the record DAL_REQUEST_ID.UpdateUsageApplication(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out msg); } else { dbTxn.Dispose(); ResponseUtility.ReturnFailMessage(row); return; } //return message and MK value if (String.IsNullOrEmpty(msg)) //success { dbTxn.Complete(); ResponseUtility.ReturnSuccessMessage(row, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER); } else //failed { dbTxn.Dispose(); ResponseUtility.ReturnFailMessage(row); } #endregion } }
public ControllerRegisterCompleteNotificationSending() { response = new MetaResponse(); DAL_REQUEST_ID = new REQUEST_ID(con); DAL_REQUEST_DETAIL = new REQUEST_DETAIL(con); DAL_REPORT_HISTORY = new REPORT_HISTORY(con); DAL_CLIENT_CERTIFICATE = new CLIENT_CERTIFICATE(con); DAL_REQ_ADDRESS = new REQ_ADDRESS(con); timer = new Stopwatch(); timer.Start(); //UPDATED_AT UPDATED_AT_DATETIME = TEMP.ToString("yyyy/MM/dd HH:mm"); CURRENT_DATETIME = TEMP.ToString("yyyyMMddHHmmss"); }
public MetaResponse GDConfirmComplete(string list) { try { string msg = ""; DataTable dgvList = Utility.Utility_Component.JsonToDt(list); for (int i = 0; i < dgvList.Rows.Count; i++) { //cast into objects BOL_REQUEST_DETAIL oREQUEST_DETAIL = new BOL_REQUEST_DETAIL(); BOL_REQUEST_ID oREQUEST_ID = new BOL_REQUEST_ID(); oREQUEST_DETAIL = Cast_REQUEST_DETAIL(dgvList.Rows[i]); oREQUEST_ID = Cast_REQUEST_ID(dgvList.Rows[i]); //get GD code By COMPANY NO BOX REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); string GD_CODE = DAL_REQUEST_ID.GetGDCode(oREQUEST_ID.COMPANY_NO_BOX.ToString(), out msg); if (string.IsNullOrEmpty(msg)) { #region Send Mail bool mailSuccess = PrepareAndSendMail(oREQUEST_DETAIL, false, GD_CODE); if (mailSuccess) //success { ResponseUtility.ReturnSuccessMessage(dgvList.Rows[i], UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER, string.Format(Utility.Messages.Jimugo.I000ZZ016, "GD確認完了")); } else //failed { ResponseUtility.MailSendingFail(dgvList.Rows[i]); } #endregion } else { ResponseUtility.ReturnFailMessage(dgvList.Rows[i]); } } response.Status = 1; response.Data = Utility.Utility_Component.DtToJSon(dgvList, "GD Confirmation Complete");; timer.Stop(); response.Meta.Duration = timer.Elapsed.TotalSeconds; return(response); } catch (Exception ex) { return(ResponseUtility.GetUnexpectedResponse(response, timer, ex)); } }
public async Task WhenTheNoDfeSignInOptionIsSelected_ThenUserIsRedirectedToYourDetailsPage() { SessionService.Get(Arg.Is("TempSupportRequestId")).Returns(REQUEST_ID.ToString()); var actual = await sut.Index(new HasSignInViewModel() { HasSignInAccount = false }); var redirectResult = actual as RedirectToActionResult; Assert.AreEqual("YourDetails", redirectResult.ControllerName); Assert.AreEqual("Index", redirectResult.ActionName); }
private void HandleDelete(BOL_REQUEST_ID oREQUEST_ID, DataRow row) { string strMsg = ""; using (TransactionScope dbTxn = new TransactionScope()) { //check if it is already registered in REQUEST_DETAIL REQUEST_DETAIL DAL_REQUEST_DETAIL = new REQUEST_DETAIL(con); REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out strMsg)) // IF updated_at is not already modified { if (!DAL_REQUEST_DETAIL.IsAlreadyUsed(oREQUEST_ID.COMPANY_NO_BOX, out strMsg)) { //delete the record DAL_REQUEST_ID.Delete(oREQUEST_ID, out strMsg); } else //Already used { dbTxn.Dispose(); ResponseUtility.ReturnFailMessage(row, string.Format(Utility.Messages.Jimugo.E000ZZ033, oREQUEST_ID.COMPANY_NO_BOX)); return; } } else { dbTxn.Dispose(); ResponseUtility.ReturnFailMessage(row); return; } //return message and MK value if (String.IsNullOrEmpty(strMsg)) //success { dbTxn.Complete(); ResponseUtility.ReturnDeleteSuccessMessage(row); } else //failed { ResponseUtility.ReturnFailMessage(row); } } }
public MetaResponse getCompanyCodeList(string COMPANY_NO_BOX, string COMPANY_NAME, string EMAIL, int OFFSET, int LIMIT) { try { string strMessage = ""; int TOTAL = 0; REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); DataTable dt = DAL_REQUEST_ID.GetCompanyCodeList(COMPANY_NO_BOX, COMPANY_NAME, EMAIL, OFFSET, LIMIT, out strMessage, out TOTAL); response.Data = Utility.Utility_Component.DtToJSon(dt, "CompnayCodeList"); if (dt.Rows.Count > 0) { response.Status = 1; } else { if (strMessage == "") { response.Status = 1; response.Message = "There is no data to display."; } else { response.Status = 0; response.Message = strMessage; } } response.Meta.Offset = OFFSET; response.Meta.Limit = LIMIT; response.Meta.Total = TOTAL; timer.Stop(); response.Meta.Duration = timer.Elapsed.TotalSeconds; return(response); } catch (Exception ex) { return(ResponseUtility.GetUnexpectedResponse(response, timer, ex)); } }
private void HandleInsert(BOL_REQUEST_ID oREQUEST_ID, string OPERATION, DataRow row) { string strMsg = ""; using (TransactionScope dbTxn = new TransactionScope()) { REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con); if (OPERATION == "I") { #region Auto Index //GET records of AUTO_INDEX TABLE AUTO_INDEX DAL_AUTO_INDEX = new AUTO_INDEX(con); DataTable result = DAL_AUTO_INDEX.GetByAutoIndexID(oREQUEST_ID.AUTO_INDEX_ID, out strMsg); //parepare AUTO_INDEX object BOL_AUTO_INDEX oAUTO_INDEX = new BOL_AUTO_INDEX(); oAUTO_INDEX = Cast_AUTO_INDEX(result.Rows[0]); oAUTO_INDEX.AUTO_INDEX++; #endregion #region Insert Record if (!DAL_AUTO_INDEX.IsAlreadyUpdated(oAUTO_INDEX, out strMsg)) // If AUTO INDEX is not already modified { //UPDATE AUTO INDEX DAL_AUTO_INDEX.Update(oAUTO_INDEX, CURRENT_DATETIME, CURRENT_USER, out strMsg); //generate COMPANY NO BOX string COMPANY_NO = "AJ-" + oAUTO_INDEX.AUTO_INDEX.ToString().PadLeft(4, '0'); int COMPANY_BOX = 1; string COMPANY_NO_BOX = COMPANY_NO + "-" + COMPANY_BOX.ToString().PadLeft(2, '0'); //assign COMPANY NO BOX oREQUEST_ID.COMPANY_NO_BOX = COMPANY_NO_BOX; oREQUEST_ID.COMPANY_NO = COMPANY_NO; oREQUEST_ID.COMPANY_BOX = COMPANY_BOX; //Update in datatable row["COMPANY_NO_BOX"] = COMPANY_NO_BOX; row["COMPANY_NO"] = COMPANY_NO; row["COMPANY_BOX"] = COMPANY_BOX; //generate hashed password oREQUEST_ID.PASSWORD_HASHED = Crypto.HashPassword(oREQUEST_ID.PASSWORD); //insert the record oREQUEST_ID.GD = string.IsNullOrEmpty(oREQUEST_ID.GD_CODE) ? 0 : 2; oREQUEST_ID.SOCIOS_USER_FLG = oREQUEST_ID.AUTO_INDEX_ID == "CNSOCIOS" ? "*" : " "; DAL_REQUEST_ID.Insert(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out strMsg); if (String.IsNullOrEmpty(strMsg)) //success { dbTxn.Complete(); ResponseUtility.ReturnSuccessMessage(row, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER); } else //failed { ResponseUtility.ReturnFailMessage(row, String.Format(Utility.Messages.Jimugo.E000ZZ028, COMPANY_NO_BOX)); } } else { ResponseUtility.ReturnFailMessage(row); return; } #endregion } else { #region Copy Record //get max company number from REQUEST_ID oREQUEST_ID.COMPANY_BOX = DAL_REQUEST_ID.GetMaxCompanyBox(oREQUEST_ID.COMPANY_NO, out strMsg); string COMPANY_NO = oREQUEST_ID.COMPANY_NO; int COMPANY_BOX = oREQUEST_ID.COMPANY_BOX; string COMPANY_NO_BOX = COMPANY_NO + "-" + COMPANY_BOX.ToString().PadLeft(2, '0'); //Update in datatable oREQUEST_ID.COMPANY_NO_BOX = COMPANY_NO_BOX; row["COMPANY_NO_BOX"] = COMPANY_NO_BOX; row["COMPANY_NO"] = COMPANY_NO; row["COMPANY_BOX"] = COMPANY_BOX; //generate hashed password oREQUEST_ID.PASSWORD_HASHED = Crypto.HashPassword(oREQUEST_ID.PASSWORD); //insert the record oREQUEST_ID.GD = string.IsNullOrEmpty(oREQUEST_ID.GD_CODE) ? 0 : 2; oREQUEST_ID.SOCIOS_USER_FLG = oREQUEST_ID.AUTO_INDEX_ID == "CNSOCIOS" ? "*" : " "; DAL_REQUEST_ID.Insert(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out strMsg); if (String.IsNullOrEmpty(strMsg)) //success { dbTxn.Complete(); ResponseUtility.ReturnSuccessMessage(row, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER); } else //failed { ResponseUtility.ReturnFailMessage(row, String.Format(Utility.Messages.Jimugo.E000ZZ028, COMPANY_NO_BOX)); } #endregion } } }
/// <summary> /// 线程工作函数 /// </summary> private void _threadProc() { while (!bRun) { //标记最后扫描时间,交付上级判断 RunningMark = DateTime.Now; //尚未运行的策略,直接丢弃队列中新的行情 while (_marketQueue.Count > 0) { DeQueueInfo(); } //标记线程状态为正在空转 Status = 1; Thread.Sleep(10); } if (DBAccessLayer.DBEnable) { DBAccessLayer.UpdateStrategyStatusRecord(StrategyInstanceID, 1); } while (!breaklabel) { /**** * 循环工作: * 1. 更新行情信息 * 2. 计算中间参数 * 3. 判断运行条件 * 4. 生成交易列表 * ****/ //标记最后扫描时间,交付上级判断 RunningMark = DateTime.Now; if (Status == 1) { if (DBAccessLayer.DBEnable) { DBAccessLayer.UpdateStrategyStatusRecord(StrategyInstanceID, 2); } } if (bRun) { //标记线程状态为正在运行 Status = 2; Thread.Sleep(1); //策略实例运算 List <managedMarketInforStruct> infos = new List <managedMarketInforStruct>(); List <MarketData> dataList = new List <MarketData>(); while (_marketQueue.Count > 0) { MarketData d = (MarketData)DeQueueInfo(); if (d == null) { Thread.Sleep(10); continue; } dataList.Add(d); } foreach (MarketData data in dataList) { managedMarketInforStruct info = new managedMarketInforStruct(); info.dAskPrice = new double[10]; info.dAskVol = new double[10]; info.dBidPrice = new double[10]; info.dBidVol = new double[10]; if (data.AskPrice != null) { for (int i = 0; i < data.AskPrice.Count(); i++) { info.dAskPrice[i] = Convert.ToDouble(data.AskPrice[i]) / 10000; info.dAskVol[i] = Convert.ToDouble(data.AskVol[i]); info.dBidPrice[i] = Convert.ToDouble(data.BidPrice[i]) / 10000; info.dBidVol[i] = Convert.ToDouble(data.BidVol[i]); } } managedsecurityindex index = new managedsecurityindex(); index.cSecurity_code = data.Code; info.msecurity = index; info.security_name = data.Code; info.nTime = data.Time / 1000; info.nStatus = data.Status; info.nPreClose = Convert.ToDouble(data.PreClose) / 10000; info.dLastPrice = Convert.ToDouble(data.Match) / 10000; info.dHighLimited = Convert.ToDouble(data.HighLimited) / 10000; info.dLowLimited = Convert.ToDouble(data.LowLimited) / 10000; info.exchangeID = data.WindCode.Split('.')[1]; if (data.Status == 68) { info.bstoped = true; } switch (data.IOPV) { case 0: { index.cSecuritytype = 115; break; } case 1: { index.cSecuritytype = 102; break; } case 2: { index.cSecuritytype = 105; break; } } info.LastUpdateTime = Int32.Parse(DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0')); //MarketDelayCalculation.cal(data.Time, 3); if (data.Status == 68 || data.Status == 66) { info.bstoped = true; } else { info.bstoped = false; } info.nInfotLag = info.LastUpdateTime - info.nTime; infos.Add(info); } if (infos.Count > 0) { if (Type == "OPEN") { DateTime d1 = DateTime.Now; m_strategy_open.updateSecurityInfo(infos.ToArray(), infos.Count); d1 = DateTime.Now; m_strategy_open.calculateSimTradeStrikeAndDelta(); } else { m_strategy_close.updateSecurityInfo(infos.ToArray(), infos.Count); m_strategy_close.calculateSimTradeStrikeAndDelta(); } } else { continue; } } if (bRun && bAllow) { bool _reached = false; if (Type == "OPEN") { _reached = m_strategy_open.isOpenPointReached(); } else { _reached = m_strategy_close.isOpenPointReached(); } // _reached = true; //测试使用,注意删除 // 生成交易列表 if (_reached) { List <managedTraderorderstruct> ol = (Type == "OPEN") ? m_strategy_open.getTradeList().ToList() : m_strategy_close.getTradeList().ToList(); //交易列表送往交易线程下单(下单的线程,股票和期货是分开的) List <TradeOrderStruct> orderli = new List <TradeOrderStruct>(); foreach (managedTraderorderstruct item in ol) { TradeOrderStruct order = new TradeOrderStruct(); order.cExhcnageID = item.cExchangeID; order.cSecurityCode = item.cSecurity_code; order.SecurityName = item.cSecurity_code; order.nSecurityAmount = item.nSecurity_amount; order.dOrderPrice = item.dOrderprice; order.cTradeDirection = item.cTraderdirection.ToString(); order.cOffsetFlag = item.cOffsetFlag.ToString(); order.cOrderPriceType = item.cOrderPriceType.ToString(); order.cSecurityType = item.cSecuritytype.ToString(); order.cOrderLevel = item.cOrderlevel.ToString(); order.cOrderexecutedetail = item.cOrderexecutedetail.ToString(); order.belongStrategy = StrategyInstanceID; order.OrderRef = REQUEST_ID.ApplyNewID(); order.cUser = User; orderli.Add(order); UserRequestMap.GetInstance().AddOrUpdate(order.OrderRef, User, (key, oldvalue) => oldvalue = User); } if (DBAccessLayer.DBEnable == true) { string json = Json.Encode(orderli); DBAccessLayer.InsertORDERLIST(StrategyInstanceID, json); } //提交风控模块 //下单到交易预处理模块 queue_prd_trade.GetQueue().Enqueue((object)orderli); if (DBAccessLayer.DBEnable) { //写入数据库,策略状态为已下单 DBAccessLayer.UpdateStrategyStatusRecord(StrategyInstanceID, 3); DBAccessLayer.UpdateSGOPENStatus(StrategyInstanceID, 3); } // 列表只会生成一次 breaklabel = true; } } //获取中间显示参数 //gettaderargs getshowstatus if (Type == "OPEN") { string status = m_strategy_open.getshowstatus(); List <String> statusLi = status.Split(' ').ToList(); status = string.Empty; foreach (string i in statusLi) { if (i.Trim() != string.Empty) { status += (i + "&"); } } PushStrategyInfo.Instance.UpdateStrategyInfo(StrategyInstanceID, status); } else { string status = m_strategy_close.getshowstatus(); List <string> statusLi = status.Split(' ').ToList(); status = string.Empty; foreach (string i in statusLi) { if (i.Trim() != string.Empty) { status += (i + "&"); } } PushStrategyInfo.Instance.UpdateStrategyInfo(StrategyInstanceID, status); } Thread.Sleep(1); } }