示例#1
0
        public void Insert()
        {
            var client   = new RestClient();
            var request  = new RestRequest(fundcode_url);
            var response = client.Get(request);
            var content  = response.Content;

            content = content.Replace("var r = ", "").Replace(";", "").Replace("\"", "");
            content = content.Substring(2, content.Length - 3);
            var arr1 = content.Split("],[");

            if (dapperHelper.Get <FundCode>(@"SELECT * FROM fund_code") == null)
            {
                foreach (var item in arr1)
                {
                    var arr2     = item.Split(',');
                    var fundCode = new FundCode
                    {
                        Code    = arr2[0],
                        PinYin  = arr2[1],
                        Name    = arr2[2],
                        Type    = arr2[3],
                        Extend1 = arr2[4]
                    };
                    dapperHelper.Insert(fundCode);
                }
                dapperHelper.CloseDbConnection();
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref = "Fund"/> class.
 /// </summary>
 /// <param name = "fundcode" >
 /// The fundcode.
 /// </param>
 public Fund(FundCode fundcode)
 {
     Record         = new DataBuilder(Source, GetArgs(fundcode))?.GetRecord();
     ID             = new Key(Record, PrimaryKey.FundId);
     Name           = new Element(Record, Field.Name);
     Code           = new Element(Record, Field.Code);
     Title          = new Element(Record, Field.Title);
     TreasurySymbol = new Element(Record, Field.TreasurySymbol);
     Data           = Record?.ToDictionary();
 }