public void ImportCompleted() { ImportService importService = new ImportService(); ImportProcess process = importService.checkStatus(); if (process.currentCount == process.partCount) { importService.FinishImport(); } else { ThreadPool.QueueUserWorkItem(o => ImportAsync()); } }
/*public ActionResult Start(string partlist = "", int partcount = 0) { ImportService importService = new ImportService(); ImportProcess currentProcess = importService.checkStatus(); if (currentProcess.endTime != null) { ThreadPool.QueueUserWorkItem(o => ImportAsync(partlist,partcount)); } ViewBag.status = currentProcess; return View(); }*/ public string StartAjax() { ImportService importService = new ImportService(); ImportProcess currentProcess = importService.checkStatus(); if (currentProcess.endTime != null) { importService.StartImport(); ThreadPool.QueueUserWorkItem(o => ImportAsync()); return "Started"; } return "Running"; }
public void ImportAsync() { ImportService importService = new ImportService(); List<int> importedparts = importService.GetImportList(); List<int> localpartlist = new List<int>(); localpartlist.AddRange(importedparts); if (importedparts.Count > 0) { AsyncManager.OutstandingOperations.Increment(localpartlist.Count); int count = AsyncManager.OutstandingOperations.Count; foreach (int partID in localpartlist) { importService.ImportImagesCompleted += (sender, e) => { bool removed = importedparts.Remove(e.partID); if (removed) { AsyncManager.OutstandingOperations.Decrement(); } count = AsyncManager.OutstandingOperations.Count; if (count == 0 && removed) { ImportCompleted(); } }; importService.ImportImagesAsync(Server, partID, Guid.NewGuid()); } } }
public string ImportImages(int partid = 0) { HttpServerUtilityBase server = Server; ImportService importservice = new ImportService(); string complete = importservice.ImportImages(server, partid); return complete; }
public ActionResult ImageImport() { ImportService importservice = new ImportService(); ImportProcess status = importservice.checkStatus(); ViewBag.status = status; CurtDevDataContext db = new CurtDevDataContext(); if (!status.isRunning()) { List<int> noimages = db.getPartsWithNoImages().Select(x => x.partID).ToList<int>(); ViewBag.noimages = noimages; List<int> missingimages = db.getPartsWithMissingImageSizes().Select(x => x.partID).ToList<int>(); ViewBag.missingimages = missingimages; } return View(); }
public string CheckStatus() { ImportService importService = new ImportService(); ImportProcess currentProcess = importService.checkStatus(); return Newtonsoft.Json.JsonConvert.SerializeObject(currentProcess); }