Пример #1
0
        public ActionResult ImportWhiteLabelPOSSN()
        {
            POSBLL ab = new POSBLL();
            //导入文件
            HttpPostedFileBase file   = Request.Files["importSN"];
            DataTable          dt     = ExcelToDataTable(file);
            List <string>      snList = new List <string>();
            List <POSs>        list   = new List <POSs>();

            foreach (DataRow item in dt.Rows)
            {
                if (!item[0].ToString().StartsWith("N3000"))
                {
                    continue;
                }
                POSs pos = new POSs();
                pos.Sn           = item[0].ToString();
                pos.Status       = false;
                pos.Timestamp    = DateTime.UtcNow;
                pos.WhiteLabel   = Request.Form["WhiteLabel"];
                pos.IsWhiteLabel = true;
                pos.FirstCrypto  = Request.Form["FirstCrypto"];
                if (item[1].ToString().Equals("Open"))
                {
                    pos.IsMiningEnabled = true;
                }
                list.Add(pos);

                snList.Add(item[0].ToString());
            }
            List <POSs> listRepeat = new List <POSs>();

            if (list.Count > 0)
            {
                listRepeat = ab.Import(list, snList, UserId, UserName);
                if (listRepeat.Count > 0)
                {
                    HSSFWorkbook book  = new HSSFWorkbook();
                    ISheet       sheet = book.CreateSheet("Sheet1");
                    IRow         row1  = sheet.CreateRow(0);
                    row1.CreateCell(0, CellType.String).SetCellValue("POS SN");
                    row1.CreateCell(1, CellType.String).SetCellValue("Imported file exist duplicate POS SN numbers, please try again after delete the duplicate SN numbers");

                    for (int i = 0; i < listRepeat.Count; i++)
                    {
                        IRow row = sheet.CreateRow(i + 1);
                        row.CreateCell(0, CellType.String).SetCellValue(listRepeat[i].Sn);
                    }

                    ICellStyle cellStyle = book.CreateCellStyle();
                    Response.Charset     = System.Text.Encoding.UTF8.BodyName;
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment; filename=\"POS SN List.xls\"");
                    book.Write(Response.OutputStream);
                    Response.Flush();
                    Response.End();
                }
            }
            return(RedirectToAction("Index", new { id = Request["PageId"] }));
        }
Пример #2
0
        public SaveResult Create(POSs pos, int userId, string userName)
        {
            bool isExists = FiiiPayDB.DB.Queryable <POSs>().Where(t => t.Sn == pos.Sn).First() == null;

            if (pos != null && isExists)
            {
                pos.Timestamp = DateTime.UtcNow;
                pos.Status    = false;
                var  posId       = FiiiPayDB.POSDb.InsertReturnIdentity(pos);
                bool saveSuccess = posId > 0;
                if (saveSuccess)
                {
                    ActionLog actionLog = new ActionLog();
                    actionLog.IPAddress  = GetClientIPAddress();
                    actionLog.AccountId  = userId;
                    actionLog.CreateTime = DateTime.UtcNow;
                    actionLog.ModuleCode = typeof(POSBLL).FullName + ".Create";
                    actionLog.Username   = userName;
                    actionLog.LogContent = "Create POS " + posId;
                    new ActionLogBLL().Create(actionLog);
                }
                return(new SaveResult(saveSuccess));
            }
            return(new SaveResult(false));
        }
Пример #3
0
        public ActionResult Save(POSs oPos)
        {
            POSBLL     ab     = new POSBLL();
            SaveResult result = new SaveResult();

            result = ab.Create(oPos, UserId, UserName);
            return(Json(result.toJson()));
        }