public ActionResult Data(Malldata Alldata) { //ここには、日付検索時にやってくる。基本は上のと同じ table = common.AzureAccess(); var loginuser = RDB.db.Users.Where(p => p.idName.Equals(User.Identity.Name)).Single(); int id = loginuser.Modules.Where(p => p.Name.Equals(Alldata.ModuleName)).Single().id; var units = RDB.db.Modules.Where(x => x.id.Equals(id)).Single().Units; TableQuery<DataEntity> query = GetQueryTakeNum(id, 1, Alldata.DateStart, Alldata.DateEnd); Malldata Alldata_tmp = GetData(query, units); TableQuery<DataEntity> query1 = new TableQuery<DataEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Take," + id), TableOperators.And, TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, common.GetTimeIndex(Alldata.DateStart)), TableOperators.And, TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThanOrEqual, common.GetTimeIndex(Alldata.DateEnd)) ) )).Take(20); Alldata.FlagBlob = new List<bool>(); foreach (var entity in table.ExecuteQuery(query1)) { if (entity.DataVal == null) { Alldata.FlagBlob.Add(false); } else { if (entity.DataVal.Equals("BlobData")) { Alldata.FlagBlob.Add(true); } else { Alldata.FlagBlob.Add(false); } } } Alldata.Type = Alldata_tmp.Type; Alldata.TypeDataId = Alldata_tmp.TypeDataId; Alldata.data = Alldata_tmp.data; Alldata.Id = id; Alldata.NumData = GetDataCount(id, Alldata.DateStart, Alldata.DateEnd); Alldata.TakeNum = 1; return View(Alldata); }
//query条件に一致するデータを取得(Azure)TypeとDataだけ Malldata GetData(TableQuery<DataEntity> query, ICollection<Unit> units) { Malldata AllData = new Malldata(); string[] Type = new string[units.Count]; int[] TypeDataId = new int[units.Count]; int[] TypeId = new int[units.Count]; int num = 0; foreach (var unit in units) { Type[num] = unit.Unit1; TypeDataId[num] = unit.TypeDataId; TypeId[num] = unit.id; num++; } AllData.Type = new List<string>(); AllData.TypeDataId = new List<int>(); AllData.data = new List<List<string>>(); AllData.Type = Type.ToList(); AllData.TypeDataId = TypeDataId.ToList(); List<string> datatmp1 = new List<string>(); string[] datatmp2 = new string[Type.LongLength + 1]; for (int i = 0; i < Type.LongLength + 1; i++) { datatmp2[i] = string.Empty; } string time = string.Empty; bool first = false; foreach (DataEntity entity in table.ExecuteQuery(query)) { if (time.Equals(entity.RowKey.Split(',')[0])) { } else { if (first) { datatmp2[0] = common.GetDateIndex(time); //データの0列目は更新時刻 datatmp1 = datatmp2.ToList(); AllData.data.Add(datatmp1); datatmp1 = new List<string>(); datatmp2 = new string[Type.LongLength + 1]; } first = true; } // RDBのunitsテーブルのidとKVSのRowKeyのRowKeyの,の後の数字が一致している時にdatatmp2に格納 // RDBにはあるがKVSには無い場合、そのデータは穴抜けのデータとなる。 for (int i = 0; i < Type.LongLength; i++) { if (units.Where(p => p.id == int.Parse(entity.RowKey.Split(',')[1])).Single().id.Equals(TypeId[i])) { datatmp2[i + 1] = entity.DataVal; } } time = entity.RowKey.Split(',')[0]; } datatmp2[0] = common.GetDateIndex(time); datatmp1 = datatmp2.ToList(); AllData.data.Add(datatmp1); return AllData; }
public ActionResult Data(string ModuleName, int takenum, string DateStart, string DateEnd) { table = common.AzureAccess(); Malldata AllData = new Malldata(); var loginuser = RDB.db.Users.Where(p => p.idName.Equals(User.Identity.Name)).Single(); var module = loginuser.Modules.Where(p => p.Name.Equals(ModuleName)).Single(); int id = module.id; var units = module.Units; // 削除中ならmoduleテーブルのTypeプロパティは"1"である(DataDeleteController参照) if (module.Type.Equals("1")) { AllData.ModuleName = ModuleName; AllData.Deleting = true; return View(AllData); } else { AllData.Deleting = false; } // データ数が0なら if (module.NumData == 0) { AllData.ModuleName = ModuleName; AllData.NumData = 0; return View(AllData); } // AllDataの中には、takenum件から20件のValueデータが入る TableQuery<DataEntity> query = GetQueryTakeNum(id, takenum, DateStart, DateEnd); AllData = GetData(query, units); //takenum件から20件のTakeデータを取得して、DataValプロパティが"BlobData"ならば、そのデータはBlobデータである。 TableQuery<DataEntity> query1 = new TableQuery<DataEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Take," + id), TableOperators.And, TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, common.GetTimeIndex(DateStart)), TableOperators.And, TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThanOrEqual, common.GetTimeIndex(DateEnd)) ) )).Take(takenum); TableQuery<DataEntity> query2 = new TableQuery<DataEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Take," + id), TableOperators.And, TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, table.ExecuteQuery(query1).LastOrDefault().RowKey) )).Take(20); AllData.FlagBlob = new List<bool>(); foreach (var entity in table.ExecuteQuery(query2)) { if (entity.DataVal == null) { AllData.FlagBlob.Add(false); } else { if (entity.DataVal.Equals("BlobData")) { AllData.FlagBlob.Add(true); } else { AllData.FlagBlob.Add(false); } } } AllData.ModuleName = ModuleName; AllData.NumData = GetDataCount(id, DateStart, DateEnd); AllData.TakeNum = takenum; AllData.Id = id; AllData.DateStart = DateStart; AllData.DateEnd = DateEnd; return View(AllData); }