public ActionResult UploadFile(HttpPostedFileBase file, Templates objtemplates) { if (file == null || file.ContentLength == 0) { ModelState.AddModelError("", "Please select file or your file is empty"); } else if (file.ContentLength > 0) { string[] AllowedFileExtensions = new string[] { ".xlsx", ".csv" }; if (!AllowedFileExtensions.Contains(System.IO.Path.GetExtension(file.FileName))) { ModelState.AddModelError("", "Please Select file of type: " + string.Join(", ", AllowedFileExtensions)); } else { var fileExt = Path.GetExtension(file.FileName); var fileName = Path.GetFileName(file.FileName) + DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss") + fileExt; string directory = Server.MapPath("~/Content/Upload/"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var path = Path.Combine(directory, fileName); file.SaveAs(path); DALProperty prop = new DALProperty(); prop.ParseExcel(path, objtemplates.Type.ToString()); ViewBag.Message = "File has been uploaded successfully. You can proceed by selecting the required site from Top Navigation."; return(View("Index")); } } return(View("Index")); }
// Load All Objects from Database public List <ObjectData> GetObjects() { List <ObjectData> objects = new List <ObjectData>(); DALProperty property = new DALProperty(); DataSet ds = property.getObjects(); objects = (from tmp in ds.Tables[0].AsEnumerable() select new ObjectData { SiteID = tmp.Field <int?>("SiteID") == null ? 0 : tmp.Field <int>("SiteID"), ObjectID = tmp.Field <int>("ObjectID"), ObjName = tmp.Field <string>("ObjName"), ObjType = tmp.Field <string>("ObjType"), ObjSubType = tmp.Field <string>("ObjSubType"), Obj_Ref_1 = tmp.Field <string>("Obj_Ref_1"), Obj_Ref_2 = tmp.Field <string>("Obj_Ref_2"), Obj_Ref_3 = tmp.Field <string>("Obj_Ref_3"), Obj_Ref_4 = tmp.Field <string>("Obj_Ref_4"), Obj_Ref_5 = tmp.Field <string>("Obj_Ref_5"), Obj_Ref_6 = tmp.Field <string>("Obj_Ref_6"), Obj_Ref_7 = tmp.Field <string>("Obj_Ref_7"), Obj_Ref_8 = tmp.Field <string>("Obj_Ref_8"), Obj_Ref_9 = tmp.Field <string>("Obj_Ref_9"), Obj_Ref_10 = tmp.Field <string>("Obj_Ref_10"), }).ToList(); return(objects); }
public List<Site> GetSite() { List<Site> sites = new List<Site>(); DALProperty property = new DALProperty(); DataSet ds = property.getSite(); sites = (from tmp in ds.Tables[0].AsEnumerable() select new Site { SiteID = tmp.Field<int>("SiteID"), SiteCode = tmp.Field<int>("SiteCode"), SiteName = tmp.Field<string>("SiteName") }).ToList(); return sites; }
public List<MenuTree> GetTreeData() { List<MenuTree> objects = new List<MenuTree>(); DALProperty property = new DALProperty(); DataSet ds = property.getObjects(); objects = (from tmp in ds.Tables[0].AsEnumerable() select new MenuTree { ObjType = tmp.Field<string>("ObjType"), ObjSubType = tmp.Field<string>("ObjSubType"), ObjName = tmp.Field<string>("ObjName"), }).ToList(); return objects; }
public List <MenuTree> GetTreeData() { List <MenuTree> objects = new List <MenuTree>(); DALProperty property = new DALProperty(); DataSet ds = property.getObjects(); objects = (from tmp in ds.Tables[0].AsEnumerable() select new MenuTree { ObjType = tmp.Field <string>("ObjType"), ObjSubType = tmp.Field <string>("ObjSubType"), ObjName = tmp.Field <string>("ObjName"), }).ToList(); return(objects); }
public List <Site> GetSite() { List <Site> sites = new List <Site>(); DALProperty property = new DALProperty(); DataSet ds = property.getSite(); sites = (from tmp in ds.Tables[0].AsEnumerable() select new Site { SiteID = tmp.Field <int>("SiteID"), SiteCode = tmp.Field <int>("SiteCode"), SiteName = tmp.Field <string>("SiteName") }).ToList(); return(sites); }
// Load All Objects from Database public List<ObjectData> GetObjects() { List<ObjectData> objects = new List<ObjectData>(); DALProperty property = new DALProperty(); DataSet ds = property.getObjects(); objects = (from tmp in ds.Tables[0].AsEnumerable() select new ObjectData { SiteID = tmp.Field<int?>("SiteID") == null ? 0 : tmp.Field<int>("SiteID"), ObjectID = tmp.Field<int>("ObjectID"), ObjName = tmp.Field<string>("ObjName"), ObjType = tmp.Field<string>("ObjType"), ObjSubType = tmp.Field<string>("ObjSubType"), Obj_Ref_1 = tmp.Field<string>("Obj_Ref_1"), Obj_Ref_2 = tmp.Field<string>("Obj_Ref_2"), Obj_Ref_3 = tmp.Field<string>("Obj_Ref_3"), Obj_Ref_4 = tmp.Field<string>("Obj_Ref_4"), Obj_Ref_5 = tmp.Field<string>("Obj_Ref_5"), Obj_Ref_6 = tmp.Field<string>("Obj_Ref_6"), Obj_Ref_7 = tmp.Field<string>("Obj_Ref_7"), Obj_Ref_8 = tmp.Field<string>("Obj_Ref_8"), Obj_Ref_9 = tmp.Field<string>("Obj_Ref_9"), Obj_Ref_10 = tmp.Field<string>("Obj_Ref_10"), }).ToList(); return objects; }