public JsonResult _GetProductsInfo(MarketplaceFeed model) { // get the products's ASINs var infoFeeds = _productService.GetProductInfoFeeds(model); // create the file to save the list of product's ASIN var fileFullPath = string.Format("{0}\\Products_ASINS_{1:yyyyMMdd_HHmmss}.txt", _systemJobsRoot, DateTime.Now); // write the asins to the file using (var streamWriter = new StreamWriter(fileFullPath)) { var writer = new CsvHelper.CsvWriter(streamWriter); foreach (var info in infoFeeds) { writer.WriteField(info.EisSKU); writer.WriteField(info.ASIN); writer.WriteField(info.UPC); writer.NextRecord(); } } // create new job for the Amazon Get Info for the asins var systemJob = new SystemJobDto { JobType = JobType.AmazonGetInfo, Parameters = fileFullPath, SubmittedBy = User.Identity.Name }; _systemJobService.CreateSystemJob(systemJob); return(Json(new { Success = "Amazon Get Info has been passed to EIS System Jobs for execution." }, JsonRequestBehavior.AllowGet)); }
public ActionResult DownloadBulkeBaySuggestedCategoriesResult(int jobId) { // get the system job details var systemJob = new SystemJobDto(); do { // let's sleep a while to give time the system job for eBay bull categories try { Thread.Sleep(1000); } catch { } // get the job info systemJob = _systemJobService.GetSystemJob(jobId); // send out the file result if the system job is done if (systemJob.Status == JobStatus.Completed) { var fileInfo = new FileInfo(systemJob.ParametersOut); Response.Clear(); Response.ContentType = "text/csv"; Response.AddHeader("Content-Length", fileInfo.Length.ToString()); Response.AddHeader("Content-disposition", string.Format("attachment; filename=\"{0}\"", fileInfo.Name)); Response.TransmitFile(fileInfo.FullName); Response.Flush(); Response.End(); } } while (systemJob.Status != JobStatus.Completed || systemJob.Status != JobStatus.Failed); return(null); }
public JsonResult _DeleteProducts(MarketplaceFeed model) { try { // get product's EIS SKU var productEisSkus = _productService.GetProductsEisSku(model); var fileFullPath = string.Format("{0}\\BulkDeleteProducts_{1:yyyyMMdd_HHmmss}.txt", _systemJobsRoot, DateTime.Now); using (var streamWriter = new StreamWriter(fileFullPath)) { var writer = new CsvHelper.CsvWriter(streamWriter); foreach (var eisSku in productEisSkus) { writer.WriteField(eisSku); writer.NextRecord(); } } // create new job for the Amazon Get Info for the asins var systemJob = new SystemJobDto { JobType = JobType.BulkDeleteProduct, Parameters = fileFullPath, SubmittedBy = User.Identity.Name }; _systemJobService.CreateSystemJob(systemJob); return(Json("Bulk deletion of products has been passed to EIS System Jobs for execution.", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = "Error in deleting products! - Message: " + EisHelper.GetExceptionMessage(ex) }, JsonRequestBehavior.AllowGet)); } }
public ActionResult UploadFileAsync(JobType jobType, bool isCreate = false, bool isAutoLink = false, bool isCreateEisSKU = false, bool hasHeaderFile = true, string supportiveParameters = null) { var file = Request.Files[0]; var fileFullPath = string.Format("{0}\\{2:yyyy}{2:MM}{2:dd}{2:HH}{2:mm}_{1}", ConfigurationManager.AppSettings["FilePath"].ToString(), file.FileName, DateTime.UtcNow); // save the file to the file path file.SaveAs(fileFullPath); // creat jobs to process the uploading product file var systemJob = new SystemJobDto { JobType = jobType, Parameters = fileFullPath, IsAddNewItem = isCreate, HasPostAction_1 = isAutoLink, // this flag is for add link to EIS products with vendor products via UPC code HasPostAction_2 = isCreateEisSKU, // this flag for adding link to EIS products and create EIS product it doesn't exist HasHeader = hasHeaderFile, SubmittedBy = User.Identity.Name, SupportiveParameters = supportiveParameters }; _jobService.CreateSystemJob(systemJob); return(Json(new { isUploaded = true, message = "The file has been successfuly uploaded and passed to EIS System Job service for execution." }, "text/html")); }
public SystemJobDto GetSystemJob(int id) { var result = new SystemJobDto(); using (var context = new EisInventoryContext()) { var systemJob = context.systemjobs.FirstOrDefault(x => x.Id == id); result = Mapper.Map <SystemJobDto>(systemJob); } return(result); }
public int CreateSystemJob(SystemJobDto model) { // create system job object var systemJob = Mapper.Map <systemjob>(model); using (var context = new EisInventoryContext()) { systemJob.Created = DateTime.UtcNow; context.systemjobs.Add(systemJob); context.SaveChanges(); } return(systemJob.Id); }
public JsonResult _SubmiteBayProductReListing(MarketplaceFeed model) { try { // get the eBay products for the relisting var productItems = _productService.GeteBayItemFeeds(model).ToList(); var fileFullPath = string.Format("{0}\\eBayProductReListing_{1:yyyyMMdd_HHmmss}.csv", _systemJobsRoot, DateTime.Now); using (var streamWriter = new StreamWriter(fileFullPath)) { var writer = new CsvHelper.CsvWriter(streamWriter); foreach (var item in productItems) { writer.WriteField(item.EisSKU); writer.WriteField(item.ItemId); writer.NextRecord(); } } // create new job for eBay suggested categories var systemJob = new SystemJobDto { JobType = JobType.eBayProductsReListing, Parameters = fileFullPath, SupportiveParameters = model.Mode, SubmittedBy = User.Identity.Name }; var jobId = _systemJobService.CreateSystemJob(systemJob); return(Json(new { Success = "eBay Product ReListing has been passed to EIS System Jobs for execution.", JobId = jobId }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = "Error in submitting eBay product relisting! - Message: " + EisHelper.GetExceptionMessage(ex) }, JsonRequestBehavior.AllowGet)); } }
public JsonResult _GeteBayBulkSuggestedCategories(MarketplaceFeed model) { try { // get the product feed for bul eBay suggested categories var productKeywordFeeds = _productService.GeteBaySuggestedCategoryFeed(model); var fileFullPath = string.Format("{0}\\BulkeBaySuggestedCategories_{1:yyyyMMdd_HHmmss}.csv", _systemJobsRoot, DateTime.Now); using (var streamWriter = new StreamWriter(fileFullPath)) { var writer = new CsvHelper.CsvWriter(streamWriter); foreach (var item in productKeywordFeeds) { writer.WriteField(item.EisSKU); writer.WriteField(item.Keyword); writer.NextRecord(); } } // create new job for eBay suggested categories var systemJob = new SystemJobDto { JobType = JobType.BulkeBaySuggestedCategories, Parameters = fileFullPath, SubmittedBy = User.Identity.Name }; var jobId = _systemJobService.CreateSystemJob(systemJob); return(Json(new { Success = "Bulk eBay get suggested categories has been passed to EIS System Jobs for execution.", JobId = jobId }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Error = "Error in getting bulk eBay suggested categories! - Message: " + EisHelper.GetExceptionMessage(ex) }, JsonRequestBehavior.AllowGet)); } }