private void IndexAllGetData(long start, long stop, DateTime lastIndexed)
        {
            try
            {
                var convertedData = GetDataFromDb(start, stop, lastIndexed);

                FactoryIndexer <T> .Index(convertedData);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                throw;
            }
        }
Esempio n. 2
0
        private void IndexAllGetData(long start, long step, string idColumn, string tenantIdColumn, string lastModifiedColumn, DateTime lastIndexed)
        {
            List <Wrapper> data;

            var dataQuery = new SqlQuery(Wrapper.Table + " " + Alias)
                            .Select(Wrapper.GetColumnNames(Alias))
                            .Where(Exp.Between(idColumn, start, start + step));

            if (!string.IsNullOrEmpty(tenantIdColumn))
            {
                dataQuery.InnerJoin("tenants_tenants t", Exp.EqColumns(tenantIdColumn, "t.id"))
                .Where("t.status", (int)TenantStatus.Active);
            }

            foreach (var con in Wrapper.GetConditions(Alias))
            {
                dataQuery.Where(con.Key, con.Value);
            }

            AddJoins(Wrapper, dataQuery, Alias);

            if (!DateTime.MinValue.Equals(lastIndexed))
            {
                dataQuery.Where(Exp.Gt(lastModifiedColumn, lastIndexed));
            }

            using (var db = new DbManager("default", 1800000))
            {
                db.ExecuteNonQuery("SET SESSION group_concat_max_len = 4294967295;");
                data = db.ExecuteList(dataQuery).ConvertAll(Wrapper.GetDataConverter());
            }

            try
            {
                FactoryIndexer <T> .Index(data.Cast <T>().ToList());
            }
            catch (Exception e)
            {
                Logger.Error(e);
                throw;
            }
        }