public JObject LoadManual(int?id) { JObject obManual = new JObject(); // Product id 있는 지 확인 if (id == null) { obManual.Add("result", "id 값이 null입니다."); return(obManual); } Product product = db.Products.Find(id); IEnumerable <XAppComponent> xAppComponents = db2.XAppComponents.Where(e => e.AppCategory == "LIB" && e.ComponentIdx == product.ComponentIdx); JArray arrFile = new JArray(); foreach (XAppComponent xAppComponent in xAppComponents) { var xLibraries = db2.XLibraries.Where(e => e.LibIdx == xAppComponent.AppIdx); if (xLibraries.Count() == 0) { continue; } XLibrary xlib = xLibraries.First(); var xResource = db2.XResources.Where(e => e.AppIdx == xlib.LibIdx && e.AppCategory == "LIB" && e.IsUrl == 0 && e.FileCategory == "MNL" && e.SubCategory == "IST"); // X_Resource의 subCategory에 "IST"가 들어가있지 않으면 못불러옴 (ERP2에서 수정해야 함) if (xResource.Count() == 0) { continue; } XResource xRes = xResource.First(); var xFileRepoes = db2.XFileRepositories.Where(e => e.AppIdx == xRes.ResIdx && e.AppCategory == "RES"); if (xFileRepoes.Count() == 0) { continue; } XFileRepository xFileRepo = xFileRepoes.First(); var xFiles = db2.XFiles.Where(e => e.FileIdx == xFileRepo.FileIdx); if (xFiles.Count() == 0) { continue; } XFile xFile = xFiles.First(); JObject obFile = new JObject(); obFile.Add("AppIdx", xAppComponent.AppIdx); obFile.Add("FileName", xFile.FileName); obFile.Add("Code", xRes.Code); obFile.Add("Date", xRes.MDate); obFile.Add("Edition", xRes.FileVersion); obFile.Add("ChangeDate", string.Format("{0:yyyy/MM/dd HH:mm:ss}", xRes.EDate)); obFile.Add("ChangeUser", xRes.EUser); arrFile.Add(obFile); } obManual.Add("Manuals", arrFile); obManual.Add("Result", "Success"); return(obManual); }
// Search public JArray LoadProducts(string search, string category) { string txt = category ?? ""; if (txt.ToUpper() == "MODELS" || txt.ToUpper() == "MANUALS") { txt = "GOODS"; } else if (txt.ToUpper() == "ALL") { txt = ""; } var products = db.Products.Include(e => e.Equipment).AsNoTracking() .Where(e => e.Completion.Contains(txt) && (e.Equipment.Name.Contains(search ?? "") || e.Model.Contains(search ?? ""))); int x = products.Count() - 50; if (x > 0) { products = products.OrderBy(e => e.Id).Skip(x); } JArray arrProduct = new JArray(); foreach (Product product in products) { // Category가 Manual이면, Manual이 있는 지 확인하고 없으면 continue if (txt.ToUpper() == "MANUALS") { var xComponents = db2.XComponents.Where(e => e.Model == product.Model && e.CompTechGroupIdx != null); if (xComponents.Count() != 1) { continue; } int componentIdx = xComponents.First().ComponentIdx; var xAppComponents = db2.XAppComponents.Where(e => e.ComponentIdx == componentIdx && e.AppCategory == "LIB"); foreach (XAppComponent xAppComponent in xAppComponents) { var xLibraries = db2.XLibraries.Where(e => e.LibIdx == xAppComponent.AppIdx); if (xLibraries.Count() == 0) { continue; } XLibrary xlib = xLibraries.First(); var xResource = db2.XResources.Where(e => e.AppIdx == xlib.LibIdx && e.AppCategory == "LIB" && e.IsUrl == 0 && e.FileCategory == "MNL" && e.SubCategory == "IST"); if (xResource.Count() == 0) { continue; } XResource xRes = xResource.First(); var xFileRepoes = db2.XFileRepositories.Where(e => e.AppIdx == xRes.ResIdx && e.AppCategory == "RES"); if (xFileRepoes.Count() == 0) { continue; } XFileRepository xFileRepo = xFileRepoes.First(); var xFiles = db2.XFiles.Where(e => e.FileIdx == xFileRepo.FileIdx); if (xFiles.Count() == 0) { continue; } } } JObject item = new JObject(); item.Add("ProductId", product.Id); item.Add("ProductModel", product.Model); item.Add("Title", product.Title); item.Add("Completion", product.Completion); item.Add("Mass", product.Mass); arrProduct.Add(item); } return(arrProduct); }