예제 #1
0
        // Populate the page with entity data
        private void PopulatePage()
        {
            int userId = 0;

            try
            {
                userId = Security.GetCurrentUserId();
            }
            catch
            {
                Security.RedirectToHomePage();
            }
            List <BatchDto> batches = BatchService.GetBatches(userId);

            BatchGridView.DataSource = null;
            BatchGridView.DataBind();
            hiddenDiv.Visible = false;

            if (batches.Count > 0)
            {
                BatchGridView.DataSource = batches;
                BatchGridView.DataBind();
            }
            else
            {
                hiddenDiv.Visible = true;
            }
        }
예제 #2
0
        public void Test_000_batch_close()
        {
            BatchSummary summary = BatchService.CloseBatch(BatchCloseType.Forced);

            Assert.IsNotNull(summary);
            Assert.IsTrue(summary.IsBalanced);
        }
예제 #3
0
 public SubmitController(HostProxyService hostProxyService, BatchService batchService, IJson json, ILogger <SubmitController> logger)
 {
     _hostProxyService = hostProxyService;
     _batchService     = batchService;
     _json             = json;
     _logger           = logger;
 }
예제 #4
0
        //GET:/export/saveText
        public FileResult saveText()
        {
            string appendix, content = "";

            try
            {
                int uID = int.Parse(Request.Params.Get("UID"));

                BatchList record = BatchService.FindBatchRecord(uID);
                content += "站号:" + record.StationId +
                           "/t站类:" + (record.SType == 0 ? "雨量站" : "水情站") +
                           "/t传输方式:" + (record.TType == BatchList.Types.transType.Byday ? "按日传输" : "按小时传输") +
                           "/n/n返回信息:" + record.RawInfo +
                           "/n";

                foreach (var temp in record.Bdata)
                {
                    content += "/n" + temp.BatchTime + " : " + temp.BatchValue;
                }

                content += "/n/n";

                //文件后缀名。可以用不同的方法名区分,也可以作为一个参数输入。
                appendix = "txt";
            }
            catch (Exception)
            {
                return(null);
            }
            //返回结果
            byte[] data = Encoding.UTF8.GetBytes(content);
            return(File(data, "text/plain", "批量传输" + "." + appendix));
        }
예제 #5
0
 public BatchController(BatchService batchService, OrganisationService organisationService, DepartmentService departmentService, CampaignService campaignService)
 {
     this.batchService        = batchService;
     this.organisationService = organisationService;
     this.departmentService   = departmentService;
     this.campaignService     = campaignService;
 }
예제 #6
0
        // Create Batch in the database
        protected void CreateBtn_Click(object sender, EventArgs e)
        {
            BatchDto batch = null;

            try
            {
                // Create Batch Object
                batch = new BatchDto
                {
                    Batch_Ref = BatchReferenceTb.Text,
                    DecisionForestRegressionJobId = null,
                    LinearRegressionJobId         = null,
                    UserId = Int32.Parse(Security.GetQueryString())
                };
            }
            catch
            {
                Response.Redirect("CreateBatch?message=Error");
            }

            // Add to database
            if (BatchService.CreateBatch(batch))
            {
                Response.Redirect("Default?message=BatchCreateSuccess");
            }
            else
            {
                Response.Redirect("CreateBatch?message=Error");
            }
        }
예제 #7
0
        private void BatchButton_MouseUp(object sender, MouseButtonEventArgs e)
        {
            // 批次列表显示
            StackPanel  bacthPanel  = (StackPanel)sender;
            StackPanel  bacthPanel1 = (StackPanel)bacthPanel.Parent;
            StackPanel  bacthPanel2 = (StackPanel)bacthPanel1.Parent;
            StackPanel  bacthPanel3 = (StackPanel)bacthPanel2.Parent;
            ListBoxItem item        = (ListBoxItem)bacthPanel3.Parent;
            int         corpId      = Convert.ToInt32(item.Tag);
            //MessageBox.Show("==Tag==" + corpId);
            StackPanel panel  = (StackPanel)item.FindName("sp00");
            Image      Arrow2 = (Image)item.FindName("Arrow2");
            Image      Arrow1 = (Image)item.FindName("Arrow1");

            if (panel.Visibility == Visibility.Collapsed)
            {
                panel.Visibility  = Visibility.Visible;
                Arrow2.Visibility = Visibility.Visible;
                Arrow1.Visibility = Visibility.Collapsed;
                DataGrid grid = (DataGrid)item.FindName("DetailGrid");
                if (corpId != null)
                {
                    BatchService ser = new BatchService();
                    //DataTable dt = ser.queryBatchRecord(corpId);
                    grid.ItemsSource = dt.DefaultView;
                }
            }
            else
            {
                panel.Visibility  = Visibility.Collapsed;
                Arrow1.Visibility = Visibility.Visible;
                Arrow2.Visibility = Visibility.Collapsed;
            }
        }
        // Populate the page with entity data
        private void PopulatePage()
        {
            int batchId = 0;

            try
            {
                // Get object from BatchApi
                batchId = Int32.Parse(Security.GetQueryString());
                BatchDto batch = BatchService.GetBatch(batchId);

                BatchReferenceTb.Text = batch.Batch_Ref;
            }
            catch
            {
                // ERROR - User contained invalid data
                Response.Redirect("BatchDetail?Id{" + batchId + "}&message=DatabaseError");
            }

            List <BatteryDto> batteries = BatteryService.GetBatteries(batchId);

            if (batteries.Count > 0)
            {
                // If there are batteries in this batch; display the gridview
                BatteryGridView.DataSource = batteries;
                BatteryGridView.DataBind();
            }
            else
            {
                // Otherwise hide the gridview and display an alternative message
                hiddenDiv.Visible   = true;
                SubtitleDiv.Visible = false;
                DownloadDiv.Visible = false;
            }
        }
예제 #9
0
        public void Test_033_Settlement()
        {
            BatchSummary response = BatchService.CloseBatch();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
예제 #10
0
        public ActionResult saveDataBase()
        {
            helper.DBReturnCode code = helper.DBReturnCode.NOT_EXIST;
            try
            {
                int         uID       = int.Parse(Request.Params.Get("UID"));
                string      stationID = Request.Params.Get("stationID");
                bool        rtype     = Request.Params.Get("ReportType") == "Rain" ? true : false;
                bool        trans     = Request.Params.Get("TransType") == "ByDay" ? true : false;
                string      stime     = Request.Params.Get("startTime");
                string      etime     = Request.Params.Get("endTime");
                BatchList   record    = BatchService.FindBatchRecord(uID);
                List <rain> rainList  = new List <rain>();
                for (int i = 0; i < record.Bdata.Count; i++)
                {
                    rainList.Add(new rain
                    {
                        //stationid = record.Bdata[i].
                    });
                }
                //TODO:暂时搁置
                //code = DAL.RainService.SaveBatchData(record);
            }
            catch (Exception)
            {
                return(Json(helper.DBHelper.SerializeDBReturnCode(helper.DBReturnCode.BAD_REQUEST), JsonRequestBehavior.AllowGet));
            }

            string json = helper.DBHelper.SerializeDBReturnCode(code);

            return(Json(json, JsonRequestBehavior.AllowGet));
        }
예제 #11
0
        private void qualityAdd_Click(object sender, RoutedEventArgs e)
        {
            DynamicParameters d = getParameters();

            BatchService ser = new BatchService();

            if ("".Equals(hproId.Text))
            {
                BatchService ser2     = new BatchService();
                dynamic      codeData = ser2.queryEnterAndProduceCode(id);
                //获取厂商识别码与物品识别码   根据规则生成追溯码
                string zsCode = Tools.getQrcodeRule(codeData[0].ENTERPRISE_CODE, codeData[0].PRODUCE_CODE);
                d.Add("productionCode", zsCode);//追溯码生成

                //1、新增production and quality
                int productionId = ser.doAddProduction(d);//返回productionId

                //4、提示新增成功
                if (productionId > 0)
                {
                    MessageBox.Show("新增成功!");
                    this.Close();
                }
            }
            else
            {
                d.Add("productionId", hproId.Text);
                d.Add("qualityId", batch[0].QUALITY_ID);
                ser.doEditProduction(d);
                MessageBox.Show("修改成功!");
                this.Close();
            }
        }
예제 #12
0
        public void SettleBatch()
        {
            BatchSummary response = BatchService.CloseBatch();

            Assert.IsNotNull(response);
            Assert.AreEqual("SUCCESS", response.Status);
        }
예제 #13
0
        public void CloseBatch_Verify_MissingBatchId()
        {
            var transaction = creditCard.Verify()
                              .WithCurrency(CURRENCY)
                              .Execute();

            Assert.IsNotNull(transaction);
            Assert.AreEqual(SUCCESS, transaction?.ResponseCode);
            Assert.AreEqual(VERIFIED, transaction?.ResponseMessage);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("MANDATORY_DATA_MISSING", ex.ResponseCode);
                Assert.AreEqual("40223", ex.ResponseMessage);
                Assert.AreEqual($"Status Code: BadRequest - Request expects the batch_id",
                                ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
예제 #14
0
        public void CloseBatch_WithClosedBatchReference()
        {
            var transaction = creditCard.Charge(1.25m)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(transaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 1.25m);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(batchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("INVALID_BATCH_ACTION", ex.ResponseCode);
                Assert.AreEqual("40014", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - 5,No current batch", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
예제 #15
0
        public void CloseBatch_Auth_CreditCardData()
        {
            var transaction = creditTrackData.Authorize(AMOUNT)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Preauthorized);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("MANDATORY_DATA_MISSING", ex.ResponseCode);
                Assert.AreEqual("40223", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - Request expects the batch_id", ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
예제 #16
0
        public void CloseBatch_ActionNotAuthorized()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId   = APP_ID,
                AppKey  = APP_KEY,
                Channel = Channel.CardPresent
            });

            var transaction = creditTrackData
                              .Charge(AMOUNT)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            waitForGpApiReplication();

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            } catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("ACTION_NOT_AUTHORIZED", ex.ResponseCode);
                Assert.AreEqual("40212", ex.ResponseMessage);
                Assert.AreEqual("Status Code: Forbidden - Permission not enabled to execute action", ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
예제 #17
0
        public void CloseBatch_WithCardNumberDetails_DeclinedTransaction()
        {
            var card = new CreditCardData {
                Number   = "4263970000005262",
                ExpMonth = 05,
                ExpYear  = 2025,
                Cvn      = "852",
            };

            var chargeTransaction = card.Charge(1.99m)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            Assert.IsNotNull(chargeTransaction);
            Assert.AreEqual("DECLINED", chargeTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Declined), chargeTransaction?.ResponseMessage);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("INVALID_BATCH_ACTION", ex.ResponseCode);
                Assert.AreEqual("40017", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - 9,No transaction associated with batch", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
예제 #18
0
        public void CloseBatch_WithCardNumberDetails_DeclinedTransaction()
        {
            var card = new CreditCardData {
                Number      = "4263970000005262",
                ExpMonth    = expMonth,
                ExpYear     = expYear,
                Cvn         = "852",
                CardPresent = true
            };

            var chargeTransaction = card.Charge(AMOUNT)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            Assert.IsNotNull(chargeTransaction);
            Assert.AreEqual(DECLINED, chargeTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Declined), chargeTransaction?.ResponseMessage);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            Assert.IsNotNull(batchSummary);
            Assert.AreEqual(CLOSED, batchSummary?.Status);
            Assert.AreEqual(0, batchSummary?.TransactionCount);
            Assert.AreEqual(0, batchSummary?.TotalAmount);
        }
예제 #19
0
 public TransportServiceImpl(TransportDAO transportDAO, InspectionService inspectionService,
                             BatchService batchService, VehicleService vehicleService)
 {
     this.transportDAO      = transportDAO;
     this.inspectionService = inspectionService;
     this.batchService      = batchService;
     this.vehicleService    = vehicleService;
 }
예제 #20
0
 public BatchFileWebAPITests()
 {
     //configuration = new Mock<IConfiguration>();
     //iBatchService = new Mock<IBatchService>();
     //logger = new Mock<ILoggerService>();
     //batchController = new BatchController(iBatchService.Object, logger.Object, configuration.Object);
     batchService = new BatchService(batchFileDBContext.Object);
 }
예제 #21
0
 public BatchServiceTest()
 {
     _repositoryMock  = new Mock <IBatchRepository>();
     _transactionMock = new Mock <ITransactionService>();
     _categoryMock    = new Mock <ICategoryService>();
     _mapperMock      = new Mock <IMapper>();
     _loggerMock      = new Mock <ILogger <BatchService> >();
     _service         = new BatchService(_repositoryMock.Object, _transactionMock.Object, _categoryMock.Object, _mapperMock.Object, _loggerMock.Object);
 }
예제 #22
0
 public BatchController(
     BatchService gpsService,
     SequentialDataTools stools,
     AnalysisService det
     )
 {
     this._service = gpsService;
     this._stools  = stools;
     this._det     = det;
 }
        public IHttpActionResult Post(BatchManagement batch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            BatchService batchService = new BatchService();

            return(Created(batchService.AddItem(batch)));
        }
        // Upload CSV data as list of Batteries and add to the database
        protected void UploadBtn_Click(object sender, EventArgs e)
        {
            int batchId = Int32.Parse(Security.GetQueryString());

            if (BatchService.UploadFromFile(BatteryUpload))
            {
                Response.Redirect("BatchDetail.aspx?id=" + batchId + "&message=BatteriesUploadSuccess");
            }
            else
            {
                Response.Redirect("BatchDetail.aspx?id=" + batchId + "&message=Error");
            }
        }
예제 #25
0
 public MemberController(
     UserService userService,
     SignInManager <IdentityDBUser> signInManager,
     UserManager <IdentityDBUser> userManager,
     TokenService tokenService,
     BatchService batchService)
 {
     _userService   = userService;
     _signInmanager = signInManager;
     _userManager   = userManager;
     _tokenService  = tokenService;
     _batchService  = batchService;
 }
        // Soft-delete this User in the database
        protected void DeleteBtn_Click(object sender, EventArgs e)
        {
            int batchId = Int32.Parse(Security.GetQueryString());

            // Soft delete batch in Database
            if (BatchService.DeleteBatch(batchId))
            {
                Response.Redirect("Default.aspx?message=BatchDeleteSuccess");
            }
            else
            {
                Response.Redirect("BatchDetail.aspx?id=" + batchId + "&message=DeleteError");
            }
        }
        // Get User Id of the current User
        private static int GetUserId()
        {
            int userId = 0;

            try
            {
                userId = Int32.Parse(BatchService.GetUserId().ToString());
            }
            catch
            {
                Security.RedirectToHomePage();
            }

            return(userId);
        }
예제 #28
0
        public void CloseBatch()
        {
            var chargeTransaction = creditTrackData.Charge(AMOUNT)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(chargeTransaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, AMOUNT);
        }
예제 #29
0
        public void CloseBatch()
        {
            var chargeTransaction = creditCard.Charge(1.99m)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(chargeTransaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 1.99m);
        }
 public void recurring_999_CloseBatch()
 {
     try {
         var response = BatchService.CloseBatch();
         Assert.IsNotNull(response);
         //Console.WriteLine(string.Format("Batch ID: {0}", response.Id));
         //Console.WriteLine(string.Format("Sequence Number: {0}", response.SequenceNumber));
     }
     catch (GatewayException exc) {
         if (exc.ResponseMessage != "Transaction was rejected because it requires a batch to be open.")
         {
             Assert.Fail(exc.Message);
         }
     }
 }
예제 #31
0
        public void BatchService_ProcessFile_Test()
        {
            // Arrange
            Mock<IContentItemDao> contentItemDaoMock = new Mock<IContentItemDao>(MockBehavior.Strict);
            contentItemDaoMock.Setup(setup => setup.Add(It.IsAny<ContentItem>()))
                .Callback((ContentItem contentItem) => contentItem.Id = BatchServiceTest.GetNextID())
                .Returns((ContentItem contentItem) => { return contentItem; });

            Mock<ITimelineDao> timelineDaoMock = new Mock<ITimelineDao>(MockBehavior.Strict);
            timelineDaoMock.Setup(setup => setup.Add(It.IsAny<Timeline>()))
                .Callback((Timeline timeline) => { timeline.Id = 10; timeline.RootContentItemId = 100; })
                .Returns((Timeline timeline) => { return timeline; });

            BatchService target = new BatchService(contentItemDaoMock.Object, timelineDaoMock.Object);

            //// Act
            //long result = target.ProcessFile("../../../batch.txt");

            //// Assert
            //Assert.AreEqual(10, result);
            //Assert.AreEqual((long)11210, ID);
        }