public string[] GetIssuerName(string issuerID, HK_IssuerCodeMap issuerCodeMap)
        {
            string[] arr = { "", "" };
            foreach (Trans tran in issuerCodeMap.Map)
            {
                if (issuerID == tran.Code)
                {
                    arr[0] = tran.ShortName;
                    arr[1] = tran.FullName;

                    break;
                }
                else
                {
                    continue;
                }
            }
            if (arr[0] == string.Empty || arr[1] == string.Empty)
            {
                ErrorMsg += "\n There's no issuer for ";
                ErrorMsg += issuerID;
            }
            return(arr);
        }
        public string GetIDNLongNameForWarrant(RicInfo ricObj, bool isIndex, bool isStock, bool isCall, bool isHKD, HK_IssuerCodeMap issuerCodeMap)
        {
            string idnLongName = "";

            //For Index
            if (isIndex)
            {
                if (ricObj.Underlying == "HSI")
                {
                    idnLongName = "HANG SENG@";
                }
                if (ricObj.Underlying == "HSCEI")
                {
                    idnLongName = "HANG SENG C E I@";
                }
                if (ricObj.Underlying == "DJI")
                {
                    idnLongName = "DJ INDU AVERAGE@";
                }

                idnLongName += GetIssuerName(ricObj.Issuer, issuerCodeMap)[0];
                idnLongName += " ";
                DateTime maturittDateTime = DateTime.ParseExact(ricObj.MaturityDate, "dd-MM-yyyy", null);
                idnLongName += maturittDateTime.ToString("MMMyy", new CultureInfo("en-US")).ToUpper() + " ";



                //Attach Strike Price from Strike Level
                //For HKD
                if (isHKD)
                {
                    idnLongName += ricObj.StrikeLevel.Substring(4);
                }
                else
                {
                    idnLongName += ricObj.StrikeLevel;
                }

                idnLongName += " ";
                //For Call
                if (isCall)
                {
                    idnLongName += "C";
                }
                //For Put
                else
                {
                    idnLongName += "P";
                }

                if (isIndex)
                {
                    idnLongName += "IW";
                }
                else
                {
                    idnLongName += "WT";
                }
            }
            //For Stock
            if (isStock)
            {
                idnLongName  = ricObj.UnderlyingNameForStock + "@";
                idnLongName += GetIssuerName(ricObj.Issuer, issuerCodeMap)[0];
                DateTime maturittDateTime = DateTime.ParseExact(ricObj.MaturityDate, "dd-MM-yyyy", null);
                idnLongName += maturittDateTime.ToString("MMMyy", new CultureInfo("en-US")).ToUpper() + " ";
                //Attach Strike Price from Strike Level
                //For HKD
                if (isHKD)
                {
                    idnLongName += ricObj.StrikeLevel.Substring(4);
                }
                else
                {
                    idnLongName += ricObj.StrikeLevel;
                }

                idnLongName += " ";
                //For Call
                if (isCall)
                {
                    idnLongName += "C";
                }
                //For Put
                else
                {
                    idnLongName += "P";
                }

                if (isIndex)
                {
                    idnLongName += "IW";
                }
                else
                {
                    idnLongName += "WT";
                }
            }

            return(idnLongName);
        }
        public HKRicTemplate(RicInfo ricInfo, FMType fmType)
        {
            bool isIndex     = false;
            bool isCall      = false;
            bool isHKD       = false;
            bool isStock     = false;
            bool isOil       = false;
            bool isCommodity = false;

            if (ricInfo.Underlying == "HSI" || ricInfo.Underlying == "HSCEI" || ricInfo.Underlying == "DJI")
            {
                isIndex = true;
            }

            if (Char.IsDigit(ricInfo.Underlying, 0))
            {
                isStock = true;
            }
            //appear new underlying then query in db and change underlying value
            //if ((!isIndex) && (!isStock))
            //{
            //    HKUnderlyingInfo underlyingInfo = HKUnderlyingManager.SelectUnderlyingInfoByUnderlying(ricInfo.Underlying);

            //    if (underlyingInfo != null)
            //    {
            //        ricInfo.Underlying = underlyingInfo.UnderlyingRic;

            //        if (ricInfo.Underlying == "HSI" || ricInfo.Underlying == "HSCEI" || ricInfo.Underlying == "DJI")
            //            isIndex = true;

            //        if (Char.IsDigit(ricInfo.Underlying, 0))
            //            isStock = true;
            //    }
            //}

            if (ricInfo.Name.Contains("OIL"))
            {
                isOil = true;
            }

            if (ricInfo.BullBear.ToLower().Contains("call"))
            {
                isCall = true;
            }
            if (ricInfo.Name.Contains("GOLD") || ricInfo.Name.Contains("SILVER"))
            {
                isCommodity = true;
            }
            if (Char.IsLetter(ricInfo.StrikeLevel, 0))
            {
                isHKD = true;
            }

            issuerCodeObj = ConfigUtil.ReadConfig(issuerCodeMapPath, typeof(HK_IssuerCodeMap)) as HK_IssuerCodeMap;
            DateTime effectiveDate = DateTime.ParseExact(ricInfo.ListingDate, "dd-MM-yyyy", null);

            EffectiveDate     = effectiveDate.ToString("dd-MMM-yy");
            UnderLyingRic     = ricInfo.Code + ".HK";
            CompositeChainRic = "0#" + ricInfo.Code + ".HK";
            BrokerPageRic     = ricInfo.Code + "bk.HK";
            MiscInfoPageRic   = ricInfo.Code + "MI.HK";
            DisplayName       = ricInfo.Name;
            OfficicalCode     = ricInfo.Code;
            ExchangeSymbol    = ricInfo.Code;
            Currency          = "HKD";
            RecordType        = "097";
            SpareUbytes8      = "WRNT";
            #region For CBBC only
            //For CBBC only
            if (fmType == FMType.Cbbc)
            {
                IdnLongName         = GetIDNLongName(ricInfo);
                UnderlyingChainRic1 = "0#CBBC.HK";
                UnderlyingChainRic2 = "0#WARRANTS.HK";
                GNTX20_10           = "CBBC/" + ricInfo.BullBear;
                GNTX20_10           = GNTX20_10.ToUpper();
                Row80_13            = "Callable " + ricInfo.BullBear + " Contracts";
                WarrantType         = "Callable " + ricInfo.BullBear + " Contracts";
                RdmCur = "344";
                if (ricInfo.BullBear.ToLower().Contains("bear"))
                {
                    GVFlag = "P";
                }
                if (ricInfo.BullBear.ToLower().Contains("bull"))
                {
                    GVFlag = "C";
                }
                if (Char.IsLetter(ricInfo.StrikeLevel, 0))
                {
                    CallLevel = ricInfo.CallLevel.Substring(4);
                }
                else
                {
                    CallLevel = ricInfo.CallLevel;
                }
                if (Char.IsLetter(ricInfo.Underlying, 0))
                {
                    GNTX20_12 = "IDX~~~~~~<" + ricInfo.Code + "MI.HK>";
                    IssTpFlg  = "I";
                    if (ricInfo.Underlying == "HSCEI")
                    {
                        GNTX20_6   = "<.HSCE";
                        LongLink14 = ".HSCE|HKD|1  <-- TQR INSERT DAILY";
                    }
                    else if (ricInfo.Underlying == "HSI")
                    {
                        LongLink14 = ".HSI|HKD|1  <-- TQR INSERT DAILY";
                        GNTX20_6   = "<." + ricInfo.Underlying + ">";
                    }

                    else if (ricInfo.Underlying == "DJI")
                    {
                        LongLink14 = ".DJI|USD|1  <-- TQR INSERT DAILY";
                        GNTX20_6   = "<." + ricInfo.Underlying + ">";
                    }
                    else
                    {
                        GNTX20_6   = "<." + ricInfo.Underlying + ">";
                        LongLink14 = "Index not equal HSI,HSCEI or DJI";
                    }
                }
                else
                {
                    GNTX20_12  = "HKD~~~~~~<" + ricInfo.Code + "MI.HK>";
                    IssTpFlg   = "S";
                    GNTX20_6   = "<" + ricInfo.Underlying + ".HK>";
                    LongLink14 = ricInfo.Underlying.Substring(1) + ".HK";
                }
            }
            #endregion

            #region For Warrant only
            else
            {
                GNTX20_10   = "EU/" + ricInfo.BullBear;
                GNTX20_10   = GNTX20_10.ToUpper();
                Row80_13    = "Equity Warrant";
                IdnLongName = GetIDNLongNameForWarrant(ricInfo, isIndex, isStock, isCall, isHKD, issuerCodeObj);
                if (isCall)
                {
                    GVFlag = "C";
                }
                else
                {
                    GVFlag = "P";
                }
                if (isStock)
                {
                    UnderlyingChainRic1 = "0#" + ricInfo.Underlying.Substring(1) + "W.HK";
                    ChainRic1           = "0#CWRTS.HK";
                    WarrantType         = "Equity Warrant";
                    GNTX20_6            = "<" + ricInfo.Underlying.Substring(1) + ".HK>";
                    GNTX20_12           = "HKD~~~~~~<" + ricInfo.Code + "MI.HK>";
                    IssTpFlg            = "S";
                    RdmCur     = "344";
                    LongLink14 = ricInfo.Underlying.Substring(1) + ".HK";
                }

                else if (isIndex)
                {
                    ChainRic1 = "";
                    Row80_13  = "Index Warrant";
                    GNTX20_12 = "IDX~~~~~~<" + ricInfo.Code + "MI.HK>";
                    RdmCur    = "344";
                    if (ricInfo.Underlying == "HSCEI")
                    {
                        UnderlyingChainRic1 = "0#.HSCEW.HK";
                        WarrantType         = "Hang Seng China Enterprises Index Warrant";
                        GNTX20_6            = "<.HSCE>";
                        LongLink14          = ".HSCE|HKD|1  <-- TQR INSERT DAILY";
                    }
                    else if (ricInfo.Underlying == "HSI")
                    {
                        WarrantType         = "Hang Seng Index Warrant";
                        UnderlyingChainRic1 = "0#." + ricInfo.Underlying + "W.HK";
                        GNTX20_6            = "<." + ricInfo.Underlying + ">";
                        LongLink14          = ".HSI|HKD|1  <-- TQR INSERT DAILY";
                    }
                    else
                    {
                        if (ricInfo.Underlying == "DJI")
                        {
                            LongLink14 = ".DJI|USD|1  <-- TQR INSERT DAILY";
                        }
                        else
                        {
                            LongLink14 = "Index not equal HSI,HSCEI or DJI";
                        }
                        UnderlyingChainRic1 = "0#." + ricInfo.Underlying + "W.HK";
                        WarrantType         = "DJ Industrial Average Index Warrant";
                    }
                    IssTpFlg = "I";
                }
                else if (isOil)
                {
                    ChainRic1   = "0#OWRTS.HK";
                    WarrantType = "Oil Warrant";
                    Row80_13    = "Future Warrant";
                    RdmCur      = "840";
                }
                else if (isCommodity)
                {
                    Row80_13            = "Commodity Warrant";
                    UnderlyingChainRic1 = string.Empty;
                    ChainRic1           = "0#OWRTS.HK";
                    WarrantType         = "Miscellaneous Warrant";
                    RdmCur = "840";
                }
                else
                {
                    //isCurrency = true;
                    if (ricInfo.Name.Contains("YEN"))
                    {
                        RdmCur = "392";
                    }
                    UnderlyingChainRic1 = string.Empty;
                    ChainRic1           = "0#OWRTS.HK";
                    WarrantType         = "Miscellaneous Warrant";
                    Row80_13            = "Currency Warrant";
                    IssTpFlg            = "F";
                    RdmCur     = string.Empty;
                    LongLink14 = string.Empty;
                }
            }
            #endregion

            ChainRic2 = "0#WARRANTS.HK";

            MiscInfoPageChainRic = "0#MI.HK";
            LotSize = ricInfo.BoardLot;
            //ColDsplyNmll
            ColDsplyNmll = GetColDsplyNmllInfo(ricInfo);
            BcastRef     = "n/a";
            WntRation    = (1.0 / System.Convert.ToDouble(ricInfo.EntitlementRatio)).ToString();

            if (Char.IsLetter(ricInfo.StrikeLevel, 0))
            {
                StrikPrc = ricInfo.StrikeLevel.Substring(4);
            }
            else
            {
                StrikPrc = ricInfo.StrikeLevel;
            }

            DateTime maturDate = DateTime.ParseExact(ricInfo.MaturityDate, "dd-MM-yyyy", null);
            MaturDate = maturDate.ToString("dd-MMM-yy");

            LongLink3   = "t" + ricInfo.Code + ".HK";
            SpareSnum13 = "1";
            GNTX20_3    = "[HK-\"WARRAN*\"]";
            GNTX20_7    = "********************";

            GNTX20_11  = ricInfo.TotalIssueSize;
            CouponRate = "n/a";
            IssuePrice = ricInfo.IssuerPrice;
            BondType   = "WARRANTS";
            Leg1Str    = string.Empty;
            Leg2Str    = string.Empty;
            GNTXT24_1  = string.Empty;
            GNTXT24_2  = string.Empty;

            NewOrgList          = string.Empty;
            PrimaryList         = string.Empty;
            OrgnizationName1    = string.Empty;
            GeographyEntity     = string.Empty;
            OrgnizationType     = string.Empty;
            AliasPre            = string.Empty;
            AliasGen            = string.Empty;
            IssueClassification = string.Empty;
            MSCICode            = string.Empty;
            BusinessActivity    = string.Empty;
            ExistingOrgList     = string.Empty;
            PrimaryList         = string.Empty;
            OrgnizationName2    = GetIssuerName(ricInfo.Issuer, issuerCodeObj)[1];
            IssueClassification = "WNT";
            //For WRT_CNR
            Gearing = ricInfo.Gear;
            Premium = ricInfo.Premium;
            DateTime announcementData = DateTime.ParseExact(ricInfo.LauntchDate, "dd-MM-yyyy", null);
            AnnouncementDate = announcementData.ToString("dd-MMM-yy");
            PaymentDate      = DateTime.ParseExact(ricInfo.ClearingCommencementDate, "dd-MM-yyyy", null).ToString("dd-MMM-yy");
        }