private void Stat(List <DwNumber> numbers, string dbName, string dmName, string[] numberTypes, bool isReset) { Dictionary <string, Dictionary <string, int> > numberTypeLastSpanDict = new Dictionary <string, Dictionary <string, int> >(100000); List <DwSpan> entities = new List <DwSpan>(numbers.Count); IDwSpanDAO spanDao = DAOFactory.Create <IDwSpanDAO>(dbName, ConfigHelper.GetDwSpanTableName(dmName)); if (isReset) { spanDao.Truncate(); } long lastP = spanDao.SelectLatestPeroid(string.Empty); foreach (DwNumber number in numbers) { Dictionary <string, int> pSpanDict = GetSpanDict(numberTypeLastSpanDict, dmName, numberTypes, number); if (number.P > lastP) { entities.Add(this.CreateSpan(number, pSpanDict)); } } string[] columnNames = numberTypes.Select(x => x + "Spans").Union(new string[] { "P" }).ToArray(); spanDao.Insert(entities, SqlInsertMethod.SqlBulkCopy, columnNames); Console.WriteLine("{0} {1} Finished", dbName, dmName); }
private void AddSpan(DwNumber number) { string[] dmNames = DimensionNumberTypeBiz.Instance.GetEnabledDimensions("PL35"); List <BatchEntity <DwSpan> > batchEntities = new List <BatchEntity <DwSpan> >(dmNames.Length); foreach (string dmName in dmNames) { string[] numberTypes = DimensionNumberTypeBiz.Instance.GetNumberTypes("PL35", dmName); Dictionary <string, int> spanDict = this.DataAccessor.SelectSpansByNumberTypes(number, dmName, numberTypes); DwSpan dwSpan = new DwSpan() { P = number.P }; foreach (string key in spanDict.Keys) { string propertyName = string.Format("{0}Spans", key); dwSpan[propertyName] = spanDict[key]; } string destTableName = ConfigHelper.GetDwSpanTableName(dmName); string[] columnNames = numberTypes.Select(x => x + "Spans").Union(new string[] { "P" }).ToArray(); BatchEntity <DwSpan> batchEntity = new BatchEntity <DwSpan>(dwSpan, destTableName, columnNames); batchEntities.Add(batchEntity); } IDwSpanDAO spanDao = DAOFactory.Create <IDwSpanDAO>(this._currentDbName, string.Empty); spanDao.Insert(batchEntities); }