Esempio n. 1
0
        public ChangesSet LoadChanges(int importId)
        {
            var bl     = new ImportBL(_context);
            var result = bl.GetChanges(importId, CurrentUserId);

            return(result);
        }
        public HttpResponseMessage Import_SKU_Inventory_Update()
        {
            string path = HttpContext.Current.Server.MapPath("~/ImportFiles/ItemData/");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            HttpPostedFile postedFile = HttpContext.Current.Request.Files[0];
            string         fileName   = HttpContext.Current.Request.Form["fileName"];
            string         ImportedBy = HttpContext.Current.Request.Form["ImportedBy"];

            if (fileName.Contains(".xlsx"))
            {
                fileName = fileName.Replace(" ", "_").Replace(".xls", "");
                fileName = fileName + "$" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss") + ".xlsx";
            }
            //Save the File.
            postedFile.SaveAs(path + fileName);

            //insert to table
            ImportBL bl = new ImportBL();

            bl.Import_SKU_Inventory_Update(path + fileName, "Sheet1", ImportedBy);

            //Send OK Response to Client.
            return(Request.CreateResponse(HttpStatusCode.OK, fileName));
        }
Esempio n. 3
0
        public ActionResult Import(HttpPostedFileBase file, string source)
        {
            string path = ImportBL.ImportImage(file, source);

            file.SaveAs(Server.MapPath(path));
            ViewBag.path = path;
            return(PartialView("_PartialImageName"));
        }
Esempio n. 4
0
        public async Task <IActionResult> StartImport()
        {
            var bl       = new ImportBL(_context);
            var settings = _context.UserSettings.Where(x => x.UserId == CurrentUserId && x.Active).FirstOrDefault();
            await bl.Import(settings);

            return(Ok());
        }
Esempio n. 5
0
 public void DeleteImport(Guid id)
 {
     try
     {
         var importBL = new ImportBL();
         importBL.DeleteImport(id);
     }
     catch (Exception)
     {
     }
 }
Esempio n. 6
0
 public async Task TestBotAuthorization()
 {
     var bl       = new ImportBL(_context);
     var settings = new UserSettings()
     {
         UserId         = Guid.NewGuid().ToString(),
         BotPassword    = "******",
         BotUserName    = "******",
         TargetUsername = "******"
     };
     await bl.Import(settings);
 }
Esempio n. 7
0
 public List <Import> GetImportsByDate(string date)
 {
     try
     {
         var importBL = new ImportBL();
         return(importBL.GetImportsByDate(date));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 8
0
 public object ImportPaging([FromBody()] Paging pagingDate, int pageNumber)
 {
     try
     {
         var importBL = new ImportBL();
         return(importBL.GetImportsPaging(pageNumber, pagingDate.FromDate, pagingDate.ToDate));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 9
0
        public Import GetImportByID(Guid id)
        {
            try
            {
                var importBL = new ImportBL();
                return(importBL.GetImportByID(id));
            }

            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 10
0
 public List <Import> GetImportStatistical(int type, int value)
 {
     try
     {
         var           importBL = new ImportBL();
         List <Import> imps;
         imps = importBL.GetImportStatistical(type, value);
         return(imps);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 11
0
        public ActionResult ImportCrew()
        {
            ImportBL imBl = new ImportBL();
            TemporaryCrewViewModel crewImportVM = new TemporaryCrewViewModel();

            if (Session["Role"].ToString() == "SupportUser" || Session["Role"].ToString() == "ShipAdmin")
            {
                crewImportVM = imBl.GetAllTemporaryCrews();

                return(View(crewImportVM));
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
Esempio n. 12
0
        public void SaveImport([FromBody] Import import, int mode)
        {
            try
            {
                var importBL = new ImportBL();
                if (mode == 1)
                {
                    importBL.SaveImport(import);
                }
                else
                {
                    importBL.EditImport(import);
                }
            }

            catch (Exception)
            {
            }
        }
Esempio n. 13
0
        public ActionResult ImportCrewList(object crews)
        {
            ImportBL  importBl       = new ImportBL();
            var       jsonString     = Newtonsoft.Json.JsonConvert.SerializeObject(crews);
            DataTable dt             = JsonStringToDataTable(jsonString);
            string    FailureMessage = "";
            int       FailureCount   = 0;
            int       SuccessCount   = 0;

            string s = importBl.ImportCrewList(dt, ref FailureMessage, ref FailureCount, ref SuccessCount);

            if (FailureMessage != "" || FailureCount != 0 || SuccessCount != 0)
            {
                return(RedirectToAction("LogForUserExcel", "LogForUserExcel"));
            }
            else
            {
                return(Json("File Uploaded Successfully!"));
            }
        }
        public IHttpActionResult ItemImportLog_Select([FromBody] ItemImportLogModel itmImportModel)
        {
            ImportBL bl = new ImportBL();

            return(Ok(bl.ItemImportLog_Select(itmImportModel)));
        }
Esempio n. 15
0
        public ActionResult Index(HttpPostedFileBase postedFile)
        {
            object   dtData       = new object();
            ImportBL crewImportBL = new ImportBL();
            int      i            = 0;

            if (postedFile != null)
            {
                //string path = Server.MapPath("~/Uploads/");
                string path = Server.MapPath(ConfigurationManager.AppSettings["CrewUploadPath"].ToString());
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string fileName = string.Empty;
                fileName = Path.GetFileName(postedFile.FileName);

                if (System.IO.File.Exists(path + fileName))
                {
                    System.IO.File.Delete(path + fileName);
                }

                postedFile.SaveAs(path + Path.GetFileName(postedFile.FileName));
                ViewBag.Message = "File uploaded successfully.";

                string filePath = path + fileName;

                // read file
                using (var stream = System.IO.File.Open(filePath, FileMode.Open, FileAccess.Read))
                {
                    // Auto-detect format, supports:
                    //  - Binary Excel files (2.0-2003 format; *.xls)
                    //  - OpenXml Excel files (2007 format; *.xlsx)
                    using (var reader = ExcelReaderFactory.CreateReader(stream))
                    {
                        // 2. Use the AsDataSet extension method
                        var dataSet = reader.AsDataSet(new ExcelDataSetConfiguration()
                        {
                            // Gets or sets a callback to determine which row is the header row.
                            // Only called when UseHeaderRow = true.
                            ConfigureDataTable = _ => new ExcelDataTableConfiguration
                            {
                                UseHeaderRow = false,// Use first row is ColumnName here :D
                                FilterRow    = rowHeader => rowHeader.Depth >= 2
                            }
                        });

                        if (dataSet.Tables.Count > 0)
                        {
                            dtData = dataSet.Tables[0];
                            // Do Something
                        }
                        // The result of each spreadsheet is in result.Tables
                    }
                    i = crewImportBL.ImportCrew(dtData, ConfigurationManager.AppSettings["ShipNumber"]);
                }
            }
            if (i > 0)
            {
                return(RedirectToAction("ImportCrew", "Import"));
            }
            else
            {
                return(View());
            }
        }