示例#1
0
        public ActionResult NewFiles()
        {
            Response res  = new Response();
            var      wolt = TempData["clusters"] as List <Workorder>;
            var      wo   = TempData["SiteCluster"].ToString();
            var      wo2  = wo.Split(',');

            try
            {
                HttpFileCollectionBase files = HttpContext.Request.Files;
                var wolst = HttpContext.Request["mydata"];
                for (int i = 0; i < files.Count; i++)
                {
                    #region File Save

                    string             Path = "/Content/AirViewLogs/" + wo2[2] + "/" + wolt[i].clusterId;
                    HttpPostedFileBase file = HttpContext.Request.Files[i] as HttpPostedFileBase;
                    if (!Directory.Exists(HttpContext.Server.MapPath("~" + Path)))
                    {
                        // if it doesn't exist, create
                        System.IO.Directory.CreateDirectory(HttpContext.Server.MapPath("~" + Path));
                    }
                    string fname = HttpContext.Server.MapPath("~" + Path + "/" + wolt[i].clusterName + "_" + wolt[i].networkmodename);
                    HttpContext.Request.Files[i].SaveAs(fname + ".csv");



                    #endregion



                    #region site count
                    List <CSVParser> values = System.IO.File.ReadAllLines(fname + ".csv")
                                              .Skip(1)
                                              .Select(v => CSVParser.FromCsv(v)).Distinct()
                                              .ToList();
                    List <string> a = new List <string>();
                    foreach (var item in values)
                    {
                        a.Add(item.siteCode);
                    }
                    //  a = new List<string>();
                    //// Int64 SiteCount = 0;
                    // Stream stream = files[i].InputStream;
                    // DataTable sitesTable = new DataTable();
                    // using (CsvReader csvReader =
                    //     new CsvReader(new StreamReader(stream), true))
                    // {
                    //     sitesTable.Load(csvReader);
                    // }
                    // DataView view = new DataView(sitesTable);
                    // DataTable tblsectors = view.ToTable(true, new string[] { "clusterCode", "siteCode" });
                    // if (tblsectors.Rows.Count > 0)
                    // {
                    //     for (int j = 0; j < tblsectors.Rows.Count; j++)
                    //     {
                    //         DataRow crow = tblsectors.Rows[j];
                    //         string abc = crow["siteCode"].ToString();
                    //         a.Add(abc);
                    //     }
                    //     a = a.Distinct().ToList();
                    // }
                    WorkOrderBL wb = new WorkOrderBL();
                    wb.Insert("InsertSiteCount", a.Distinct().ToList().Count, Path + "/" + wolt[i].clusterName + "_" + wolt[i].networkmodename + ".csv");

                    #endregion
                }
                res.Status  = "success";
                res.Message = "save successfully";
            }
            catch (Exception ex)
            {
                res.Status  = "danger";
                res.Message = ex.Message;
            }



            return(RedirectToAction("New"));
        }
示例#2
0
        public ActionResult New(Workorder wo, List <Workorder> wolst, List <AV_TSSCheckList> tss, long SiteTypeIds = 0, long SiteClassIds = 0, long ProjectIds = 0, string Clonetype = "")
        {
            Response res = new Response();

            try
            {
                if (Clonetype == "Clone")
                {
                    wo.SiteTypeId  = SiteTypeIds.ToString();
                    wo.SiteClassId = SiteClassIds;
                    wo.ProjectId   = ProjectIds;
                }

                if (wo.SiteId != 0)
                {
                    wo.SiteTypeId  = SiteTypeIds.ToString();
                    wo.SiteClassId = SiteClassIds;
                    wo.ProjectId   = ProjectIds;
                }
                ClientsBL ub           = new ClientsBL();
                var       ClientPrefix = ub.ToList("AllRecords").Where(x => x.ClientId == Convert.ToDecimal(wo.Client)).FirstOrDefault().ClientPrefix;
                wolst[0].ClientPrefix = ClientPrefix;
                Common.SelectedList sl = new Common.SelectedList();
                var obj = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId));// sl.Scopes();

                TempData["clusters"]    = wolst;
                TempData["SiteCluster"] = wo.siteCode + "," + wo.clusterCode + "," + ClientPrefix;
                foreach (var df in obj)
                {
                    if (wo.Scope == df.Value && df.Text == "TSS" || wo.Scope == df.Value && df.Text == "CLS")
                    {
                        foreach (var item in wolst)
                        {
                            item.VerticalBeamWidth = "0";
                            item.RFHeight          = 0;
                            item.MTilt             = 0;
                            item.ETilt             = 0;
                            item.BandWidth         = "0";
                            item.SectorLatitude    = 0;
                            item.SectorLongitude   = 0;
                            item.CellId            = "0";
                            item.MRBTS             = "0";
                        }
                    }
                }
                WorkOrderBL wb = new WorkOrderBL();
                if (wolst.Count > 0 && wolst[0].clusterId != null)
                {
                    var fname = wo.siteCode + "," + wo.clusterCode;
                    if (wo.SiteId == 0)
                    {
                        wb.Insert("NewWorkOrder", wo, wolst, ViewBag.UserId, null, fname);
                    }
                    else
                    {
                        wb.ChangeFolderName(wo, wolst);
                        wb.Insert("Edit_Work_Order", wo, wolst, ViewBag.UserId, null, fname);
                    }
                }
                else
                {
                    if (wo.SiteId == 0)
                    {
                        wb.Insert("NewWorkOrder", wo, wolst, ViewBag.UserId, null);
                    }
                    else
                    {
                        wb.ChangeFolderName(wo, wolst);
                        wb.Insert("Edit_Work_Order", wo, wolst, ViewBag.UserId, null);
                    }
                }
                res.Status  = "success";
                res.Message = "save successfully";
            }
            catch (Exception ex)
            {
                res.Status  = "danger";
                res.Message = ex.Message;
            }
            return(Json(new { response = res }, JsonRequestBehavior.AllowGet));
        }