public ActionResult FileUpload(HttpPostedFileBase Upload) { dbDataTable ddt = new dbDataTable(); DataTable FileRecord = ddt.Tb_AV_Workorder(); try { if (Upload != null && Upload.ContentLength > 0) { if (Upload.FileName.EndsWith(".csv") || Upload.FileName.EndsWith(".CSV")) { Stream stream = Upload.InputStream; using (CsvReader csvReader = new CsvReader(new StreamReader(stream), true)) { FileRecord.Load(csvReader); } WorkOrderDL wdl = new WorkOrderDL(); wdl.Insert("MarketSites", FileRecord, ViewBag.UserId, null); TempData["msg_success"] = "Save successfully."; } else { TempData["msg_error"] = "Select .csv File"; } } else { TempData["msg_error"] = "No file selected"; } } catch (Exception ex) { TempData["msg_error"] = ex.Message; } return(RedirectToAction("New")); }
public bool Insert(string filter, Workorder wo, List <Workorder> wolst, Int64 UserId, string IMEI) { try { dbDataTable ddt = new dbDataTable(); DataTable wodt = ddt.Tb_AV_Workorder(); if (wolst != null) { #region Add Rows for (int i = 0; i < wolst.Count; i++) { DataRow row = wodt.NewRow(); row["clusterCode"] = wolst[i].clusterId; //wo.clusterCode; row["Region"] = wo.Region; row["Market"] = wo.Market; row["Client"] = wo.Client; row["siteCode"] = wo.siteCode; row["siteLatitude"] = wo.siteLatitude; row["siteLongitude"] = wo.siteLongitude; row["Description"] = wo.Description; row["sectorCode"] = wolst[i].sectorCode; row["networkMode"] = wolst[i].networkMode; //wolst[i].networkMode; row["Scope"] = wo.Scope; row["Band"] = wolst[i].Band; row["Carrier"] = wolst[i].Carrier; row["Antenna"] = wolst[i].Antenna; row["BeamWidth"] = wolst[i].BeamWidth; row["VerticalBeamWidth"] = wolst[i].VerticalBeamWidth; row["Azimuth"] = wolst[i].Azimuth; row["PCI"] = wolst[i].PCI; row["ReceivedOn"] = wo.ReceivedOn; row["BandWidth"] = wolst[i].BandWidth; row["CellId"] = wolst[i].CellId; row["RFHeight"] = wolst[i].RFHeight; row["MTilt"] = wolst[i].MTilt; row["ETilt"] = null; row["SiteName"] = wo.SiteName; row["SiteTypeId"] = wo.SiteTypeId; row["SiteClassId"] = wo.SiteClassId; row["SiteAddress"] = wo.SiteAddress; //project row["ProjectId"] = wo.ProjectId; row["MRBTS"] = wolst[i].MRBTS; row["RevisionId"] = wo.RevisionId; row["RedriveCount"] = wo.RedriveCount; row["SiteId"] = wo.SiteId; row["SectorLatitude"] = wolst[i].SectorLatitude; row["SectorLongitude"] = wolst[i].SectorLongitude; row["SectorId"] = wolst[i].SectorId; ///cluster custom row["SiteClusterId"] = wolst[i].SiteClusterId; row["ClusterName"] = ""; row["CellFilePath"] = ""; ///TSS row["SiteSurveyId"] = wolst[i].SiteSurveyId; row["SurveyId"] = wolst[i].SurveyId; wodt.Rows.Add(row); } #endregion } wod.Insert(filter, wodt, UserId, IMEI); return(true); } catch (Exception ex) { throw; } }