Пример #1
0
    public static List <object> getJson()
    {
        JsonSerializerSettings settings = new JsonSerializerSettings();

        settings.Formatting = Formatting.Indented;
        settings.AddSqlConverters();
        List <object> tmpL = new List <object>();

        foreach (var item in Main_List)
        {
            var val = item.Value;
            if (val.Count > 0)
            {
                for (int i = 0; i < val.Count; i += STEP)
                {
                    Dictionary <string, Dictionary <string, List <object> > > _List = new Dictionary <string, Dictionary <string, List <object> > >();

                    var end = STEP;
                    if (val.Count <= i + STEP)
                    {
                        end = val.Count - i;
                    }
                    var tmpDict = new Dictionary <string, List <object> >();
                    tmpDict.Add(item.Key, item.Value.GetRange(i, end));
                    //Console.WriteLine("tmpDict Length");
                    //foreach (var term in tmpDict.Keys)
                    //{

                    //    Console.WriteLine(tmpDict[term].Count);
                    //}

                    _List.Add(city_code, tmpDict);

                    var json_item = JsonConvert.SerializeObject(_List, settings);

                    tmpL.Add(json_item);
                }
                Console.WriteLine("Item Length");
                Console.WriteLine(val.Count);

                Console.WriteLine("\n");

                //using (FileStream f = new FileStream(String.Format("./Data/Length.txt"), FileMode.Append, FileAccess.Write, FileShare.None))
                //{
                //    using (StreamWriter sw = new StreamWriter(f))
                //    {
                //        sw.Write(item.Key.ToString() + ": ");
                //        sw.WriteLine(val.Count);
                //    }
                //}
            }
            else
            {
                list_clear();
                break;
            }
        }
        return(tmpL);
    }
Пример #2
0
        public async Task ConnectAsync()
        {
            _logger.LogInformation("Connecting to SQL Server...");
            _sqlConnection = new SqlConnection(_config.SourceSqlConnectionString);
            _logger.LogInformation("Done");

            _logger.LogInformation("Connecting to Couchbase...");
            var serializerSettings = new JsonSerializerSettings();

            serializerSettings.AddSqlConverters();

            var options = new ClusterOptions
            {
                UserName   = _config.TargetUsername,
                Password   = _config.TargetPassword,
                Serializer = new DefaultSerializer(serializerSettings, serializerSettings)
            };

            _cluster = await Cluster.ConnectAsync(_config.TargetConnectionString, options);

            _logger.LogInformation("Done");
        }