protected virtual void UpdateSql(OpenMarketOperation data) { String seprator = ""; string quot = ""; StringBuilder sqlCol = new StringBuilder(); for (int i = 0; i < data._dataTypes.Count; i++) { if (sqlCol.Length > 0) { seprator = ","; } if (data._dataTypes[i] == "FLOAT" || data._dataTypes[i] == "INT" || data._values[i] == "null") { quot = ""; } else { quot = "'"; } sqlCol.Append(seprator + data._colNames[i] + "=" + quot); sqlCol.Append(data._values[i].ToString().Trim() + quot); } sqlCol.Append(seprator + "MODIFYDATE="); sqlCol.Append("to_date('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')"); int idx = data.getColIdx("issueDate"); string sql = "update " + data._tabName + " set " + sqlCol.ToString() + " where RIC='" + data._ric + "' and issuedate='" + data._values[idx] + "'"; data._bulkSqlStatments.Append(sql); }
public virtual void Init(OpenMarketOperation data, QueueMessageFromRFA message) { string ignoreMessage = ""; bool isIgnore = IgnoreSql(data, ref ignoreMessage); if (isIgnore) { message.OperationType = "Ignore"; message.ReturnMessage = ignoreMessage; return; } int idx = data.getColIdx("issueDate"); bool isExist = OracleHelper.Exists("select count(*) from " + data._tabName + " where ric='" + data._ric + "' and issuedate='" + data._values[idx] + "'"); if (isExist) { UpdateSql(data); OracleHelper.ExecuteSql(data._bulkSqlStatments.ToString()); message.OperationType = "Update"; } else { InsertSql(data); OracleHelper.ExecuteSql(data._bulkSqlStatments.ToString()); message.OperationType = "Insert"; } message.ExecSql = data._bulkSqlStatments.ToString(); message.ReturnMessage = " <span style=\"color:green;\">Success!</span>"; }
protected override bool IgnoreSql(OpenMarketOperation data, ref string ignoreMessage) { var issueRate = float.Parse(data._values[data.getColIdx("issueRate")]); var issueVolume = float.Parse(data._values[data.getColIdx("issueVolume")]); if (issueVolume == 0 && issueRate == 0) { ignoreMessage = " <span style=\"background:yellow;\">issueVolume = 0 && issueRate = 0</span> "; return(true); } return(false); }
protected override bool IgnoreSql(OpenMarketOperation data, ref string ignoreMessage) { if (!data._ric.Contains("SLO")) { return(true); } var issueVolume = float.Parse(data._values[data.getColIdx("IssueVolume")]); var yield = float.Parse(data._values[data.getColIdx("Yield")]); if (issueVolume != 0 || yield != 0) { return(false); } ignoreMessage = " <span style=\"background:yellow;\"> issueVolume = 0 && yield = 0</span>"; return(true); }
protected override bool IgnoreSql(OpenMarketOperation data, ref string ignoreMessage) { if (!data._ric.Contains("MLF")) { return(true); } var issueVolume = float.Parse(data._values[data.getColIdx("IssueVolume")]); var yield = float.Parse(data._values[data.getColIdx("Yield")]); var residualVolume = float.Parse(data._values[data.getColIdx("ResidualVolume")]); if (issueVolume == 0 && yield == 0 && residualVolume == 0) { ignoreMessage = " <span style=\"color:yellow;\"> issueVolume = 0 && yield = 0 && residualVolume = 0</span>"; return(true); } return(false); }
private void ExecuteSqlByRicType(string rictype, OpenMarketOperation operation) { QueueMessageFromRFA message = new QueueMessageFromRFA { Ric = operation._ric, RicType = rictype }; switch (rictype) { case "CFXS/NEWISSUE": NewListBond nb = new NewListBond(); nb.Init(operation, message); break; case "CNREPO/PBOC": OpenMarketCNREPO cn = new OpenMarketCNREPO(); cn.Init(operation, message); break; case "MLF/PBOC": OpenMarketMLF mlf = new OpenMarketMLF(); mlf.Init(operation, message); break; case "SLF/PBOC": OpenMarketSLF slf = new OpenMarketSLF(); slf.Init(operation, message); break; case "SLO/PBOC": OpenMarketSLO slo = new OpenMarketSLO(); slo.Init(operation, message); break; } _queueMessageFromRfas.Add(message); _rfaLog.Append("\n <span style=\"background:" + (_responseRic == _requestRic ? "auto" : "yellow") + ";\">Response ric is <b>" + _responseRic + "</b></span> and " + message.OperationType + message.ReturnMessage + " \n"); if (message.OperationType != "Ignore") { _rfaLog.Append("Execute sql:" + message.ExecSql + " ; \n"); } }
private void ExecuteSqlByRicType(string rictype, OpenMarketOperation operation) { QueueMessageFromRFA message = new QueueMessageFromRFA { Ric = operation._ric, RicType = rictype }; NewListBond nb = new NewListBond(); nb.Init(operation, message); _queueMessageFromRfas.Add(message); _rfaLog.Append("\n <span style=\"background:" + (_responseRic == _requestRic ? "auto" : "yellow") + ";\">Response ric is <b>" + _responseRic + "</b></span> and " + message.OperationType + message.ReturnMessage + " \n"); if (message.OperationType != "Ignore") { _rfaLog.Append("Execute sql:" + message.ExecSql + " ; \n"); } }
protected override void InsertSql(OpenMarketOperation data) { string seprator = ""; string quot = ""; StringBuilder sqlColNames = new StringBuilder(); StringBuilder sqlValues = new StringBuilder(); for (int i = 0; i < data._dataTypes.Count; i++) { if (sqlColNames.Length > 0) { seprator = ","; } if (data._dataTypes[i] == "FLOAT" || data._dataTypes[i] == "INT" || data._values[i] == "null") { quot = ""; } else { quot = "'"; } sqlColNames.Append(seprator + data._colNames[i]); if (data._colNames[i] == "issueAmount" || data._colNames[i] == "accumulatedVolumn") { sqlValues.Append(seprator + quot + "10000*" + data._values[i].ToString().Trim() + quot); } else { sqlValues.Append(seprator + quot + data._values[i].ToString().Trim() + quot); } } sqlColNames.Append(seprator + "CREDATE"); sqlValues.Append(seprator + "to_date('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')"); string sql = "INSERT INTO " + data._tabName + "(RIC," + sqlColNames + ")" + " VALUES('" + data._ric + "', " + sqlValues + ")"; data._bulkSqlStatments.Append(sql); data._values.Clear(); data.setRic(null); }
private void ProcessMarketPrice(RespMsg respMsg) { Console.WriteLine("<- Received Market Price " + respMsg.RespType.ToString()); // ========================================================================== // Display AttribInfo if ((respMsg.HintMask & RespMsg.HintMaskFlag.AttribInfo) != 0) { if ((respMsg.AttribInfo.HintMask & AttribInfo.HintMaskFlag.ServiceName) != 0) { Console.WriteLine("Service name: " + respMsg.AttribInfo.ServiceName.ToString()); } if ((respMsg.AttribInfo.HintMask & AttribInfo.HintMaskFlag.Name) != 0) { Console.WriteLine("Symbol name: " + respMsg.AttribInfo.Name.ToString()); } } // ========================================================================== // Decode Payload if ((respMsg.HintMask & RespMsg.HintMaskFlag.Payload) != 0) { _responseRic = respMsg.AttribInfo.Name.ToString(); Data payload = respMsg.Payload; if (payload.DataType == DataEnum.FieldList) { FieldList fieldList = payload as FieldList; //Console.WriteLine("FieldList's entry count: " + fieldList.StandardDataCount); var currentRicType = _rics.Where(re => re.Ric == respMsg.AttribInfo.Name.ToString()).Select(re => re.Rictype).First(); OpenMarketOperation bs = new OpenMarketOperation(_fids.Where(re => re.Rictype == currentRicType).Select(re => re.TabName).First()); bs.setRic(respMsg.AttribInfo.Name.ToString()); if (fieldList != null) { foreach (FieldEntry fieldEntry in fieldList) { var fieldId = fieldEntry.FieldID; try { RDMFidDef fidDef = _rdmFieldDictionary.GetFidDef(fieldId); Data dataEntry = fieldEntry.GetData(fidDef.OMMType); if (dataEntry.DataType == DataEnum.DataBuffer) { if (!_currentFids.Contains(fidDef.Name.ToString())) { continue; } DataBuffer dataBuffer = dataEntry as DataBuffer; //Console.Write("\tFieldEntry: {0,-10} {1,-8}\t", fidDef.Name, "(" + fieldId + ")"); if (dataBuffer != null) { string fidValue = dataBuffer.GetAsString().ToString(); //Console.WriteLine(fidValue); var fid = _fids.First(re => re.Rictype == currentRicType && re.FidName == fidDef.Name); string colName = fid.ColName; if (fid.ColName.ToUpper() == "BONDLOCALNAME") { RMTESConverter conv = new RMTESConverter(); conv.SetBuffer(dataBuffer.GetBuffer()); // For refresh msg display fidValue = ToSimplifiedChinese(conv.ToString()); } if (colName != null) { bs.getColIdx(colName); } bs.appendColNames(fid.ColName, fid.ColType); if (fid.ColType == "DATE") { fidValue = string.IsNullOrEmpty(fidValue) ? "null" : fidValue.Replace(' ', '-'); } else if (fid.ColType == "FLOAT") { fidValue = string.IsNullOrEmpty(fidValue) ? "0" : float.Parse(fidValue).ToString(CultureInfo.InvariantCulture); } else if (fid.ColType == "INT") { fidValue = string.IsNullOrEmpty(fidValue) ? "0" : Convert.ToInt32(fidValue).ToString(); } bs.appendValues(fidValue); } } if (_responseRic == _requestRic) { CtrlBreakHandler.SetTerminated(true); } } catch (InvalidUsageException) { } } } ExecuteSqlByRicType(currentRicType, bs); } } }
protected virtual bool IgnoreSql(OpenMarketOperation data, ref string ignoreMessage) { return(false); }