/// <summary>
        /// From informations create a FmInfo object
        /// </summary>
        /// <param name="results"></param>
        /// <returns></returns>
        private FmInfo InfosToFm(List <string> results)
        {
            FmInfo fm = new FmInfo();
            Dictionary <string, string> infos = new Dictionary <string, string>();

            char[] stringSeparators = new char[] { ':' };

            foreach (string entry in results)
            {
                string[] parts = entry.Split(stringSeparators, StringSplitOptions.None);
                if (parts.Length == 2)
                {
                    infos.Add(parts[0].Trim(), parts[1].Trim());
                }
            }

            fm.Isin          = infos["國際編碼"];
            fm.MatureDate    = ConvertDate(infos["到期日期"]);
            fm.EffectiveDate = ConvertDate(infos["發行日期"]);
            fm.ChineseName   = infos["債券簡稱"];
            fm.Strikes       = infos["最新轉(交)換價格"];
            fm.Shares        = infos["實際發行總額"];
            fm.Ric           = infos["債券代碼"];
            string[] nameParts = infos["債券英文名稱"].Split(fm.Ric.Substring(4).ToCharArray());
            fm.EnglishName = nameParts[0];
            string url      = "http://mops.twse.com.tw/mops/web/ajax_t05st03";
            string postData = String.Format("encodeURIComponent=1&step=1&firstin=1&off=1&keyword4={0}&code1=&TYPEK2=&checkbtn=1&queryName=co_id&TYPEK=all&co_id={1}", fm.Ric.Substring(0, 4), fm.Ric.Substring(0, 4));
            var    htc      = WebClientUtil.GetHtmlDocument(url, 300000, postData);

            string fullHtml = htc.DocumentNode.InnerText;

            if (fullHtml.Contains("(上市公司)"))
            {
                fm.Type = ".TW";
            }
            else
            {
                fm.Type = ".TWO";
            }
            return(fm);
        }
        /// <summary>
        /// Generates Fm from website informations
        /// </summary>
        /// <param name="ric"></param>
        private Dictionary <string, string> GenerateFm(string ric)
        {
            try
            {
                FmInfo res   = GetInfos(ric);
                var    fm    = new Fm();
                var    infos = new Dictionary <string, string>
                {
                    { "ric", res.Ric },
                    { "name", res.EnglishName },
                    { "displayname", GetGatsDisplayName(res.Ric, res.Type) },
                    { "chinesename", res.ChineseName },
                    { "units", String.Format("{0:n0}", Convert.ToInt64(res.Shares.Replace("元", "").Replace(",", "")) / 100) },
                    { "maturedate", res.MatureDate.ToString("ddMMMyy").ToUpper() },
                    { "effectivedate", res.EffectiveDate.ToString("ddMMMyy").ToUpper() },
                    { "effectivedateidn", res.EffectiveDate.ToString("dd/MM/yyyy") },
                    { "isin", res.Isin },
                    { "abbrev", res.EnglishName.ToUpper() },
                    { "strike", res.Strikes.Replace("元", "") },
                    { "type", res.Type }
                };
                fm.AddProp(infos);
                string filename = String.Format("{0}{1}_{2}.txt", configObj.WorkingDir, res.Ric, DateTime.Now.ToString("ddMM"));
                fm.GenerateAndSave("TwTemplate", filename);
                //TaskResultList.Add(new TaskResultEntry("result file" + res.Ric + " FM", "", filename));
                AddResult("result file", filename, "");
                //add "=== End of Proforma ===" in the file end
                AddWordInTheEnd(filename);

                //BCU.txt
                string fileNameBCU = Path.Combine(configObj.WorkingDir, "BCU.txt");
                GeneratorBCUFile(res, fileNameBCU);
                return(infos);
            }
            catch (Exception ex)
            {
                Logger.Log("Fm generation failed for this ric, error: " + ex.Message, Logger.LogType.Warning);
                return(null);
            }
        }
        private void GeneratorBCUFile(FmInfo res, string fileName)
        {
            string content = string.Empty;
            string bcuType = string.Empty;

            if (res.Type.Equals(".TWO"))
            {
                bcuType = string.Format("OTCTWS_EQ_{0}_REL", res.Ric);
            }
            else if (res.Type.Equals(".TW"))
            {
                bcuType = string.Format("TAIW_EQ_{0}_REL", res.Ric);
            }
            else
            {
                LogMessage(string.Format("res.Type:{0} is not .TWO or .TW, so bcuType==empty.", res.Type));
            }

            content = "Ric\tBCU\r\n" + res.Ric + "\t" + bcuType;
            System.IO.File.WriteAllText(fileName, content);
            AddResult("result file", fileName, "");
        }