예제 #1
0
        public static IPersonRepository GetRepositoryByType(string DataSourceType)
        {
            IPersonRepository result = null;

            switch (DataSourceType)
            {
            case "Service":
                var service = new Service.Service();
                result = service;
                break;

            case "CSV":
                var csv = new CSV.CSV();
                result = csv;
                break;

            case "SQL":
                var sql = new SQL.SQL();
                result = sql;
                break;

            default:
                throw new ArgumentException();
            }
            return(result);
        }
예제 #2
0
        public static void ParseThroughDictionary()
        {
            const string pathname =
                @"C:\Users\jaleh\Desktop\Predict Versions\PredictTheFuture0.1\The_Cleaners\The_Cleaners\dictionary.txt";

            var lines      = File.ReadAllLines(pathname);
            var connection = new SQL.SQL("server=localhost;user=root;database=db1;port=3306;password=L0adingg...");

            foreach (string line in lines)
            {
            }
        }
예제 #3
0
        public void getData <T>()
        {
            try
            {
                int           _count = 0;
                int           _page  = 1;
                string        _columns;
                StringBuilder _sb = new StringBuilder();

                List <JSONKeyValue <T> > _list = AppConfig.GetValues <T>(string.Format("data,{0}", this._item), string.Concat(this._database, ".json"));
                string[] _JSONPath             = new string[_list.Count];
                string[] _fields = new string[_list.Count];

                foreach (JSONKeyValue <T> _obj in _list)
                {
                    _sb.Append(_obj._key).Append(",");
                    _fields[_count]   = _obj._key;
                    _JSONPath[_count] = _obj._value.ToString();
                    _count++;
                }

                _count   = 0;
                _columns = _sb.ToString();

                Console.WriteLine(string.Format("writing {0} from {1} to database.........", this._item, this._database));

                do
                {
                    cJSON getData = new cJSON(AppConfig.GetString("url_domain", "", "config", string.Concat(this._database, ".json")),
                                              String.Format(AppConfig.GetString(this._item, "", "Config,request_url", string.Concat(this._database, ".json")), _page.ToString()),
                                              AppConfig.GetString("username", "", "config", string.Concat(this._database, ".json")), AppConfig.GetString("password", "", "config", string.Concat(this._database, ".json")));
                    DataTable dtOrganizations = getData.GetDataTable(_JSONPath, _fields);
                    if (dtOrganizations == null)
                    {
                        break;
                    }
                    _count = dtOrganizations.Rows.Count;
                    if (AppConfig.GetBool("multiThreading") == true)
                    {
                        foreach (DataRow drOrganizations in dtOrganizations.Rows)
                        {
                            int          _columnIndex = HelperClass.ColumnIndex(drOrganizations, "id");
                            objSQL       _params      = new objSQL(drOrganizations, string.Format("Select {1}imported,lastupdate,s3_flag from dbo.{2} where Id = {0}", drOrganizations[_columnIndex].ToString(), _columns, this._item), _fields);
                            WaitCallback wi           = new WaitCallback(new SQL.SQL()._work);
                            _th.add2queue(ref wi, _params);
                        }
                        while (_th.activeThreads() > curThreads)
                        {
                        }
                    }
                    else
                    {
                        foreach (DataRow drOrganizations in dtOrganizations.Rows)
                        {
                            int     _columnIndex = HelperClass.ColumnIndex(drOrganizations, "id");
                            objSQL  _params      = new objSQL(drOrganizations, string.Format("Select {1}imported,lastupdate,s3_flag from dbo.{2} where Id = {0}", drOrganizations[_columnIndex].ToString(), _columns, this._item), _fields);
                            SQL.SQL wi           = new SQL.SQL();
                            wi._work(_params);
                        }
                    }
                    _page++;
                } while (_count != 0);
            }
            catch (Exception ex)
            {
                string err = string.Format("{0}: {1}", MethodBase.GetCurrentMethod().Name, ex.ToString());
                Nlogger.Error(err);
            }
        }