示例#1
0
        public WaitPanel(ref CountdownEvent countdown)
        {
            InitializeComponent();

            _countdown            = countdown;
            progress_wait.Maximum = countdown.InitialCount;
            progress_wait.Value   = countdown.InitialCount - countdown.CurrentCount;
            _thread = new Thread(() => {
                while (_countdown.CurrentCount > 0)
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        progress_wait.Value = _countdown.InitialCount - _countdown.CurrentCount;
                        label_count.Text    = $@"{_countdown.InitialCount - _countdown.CurrentCount}/{_countdown.InitialCount}";
                    }));
                    Thread.Sleep(10);
                }
                Invoke(new MethodInvoker(() =>
                {
                    progress_wait.Value = _countdown.InitialCount - _countdown.CurrentCount;
                    label_count.Text    = $@"{_countdown.InitialCount - _countdown.CurrentCount}/{_countdown.InitialCount}";
                }));
                Thread.Sleep(1000);
                Invoke(new MethodInvoker(() =>
                {
                    ScanForm scanForm = (ScanForm)Parent.Parent;
                    scanForm.EnableStart();
                    Dispose();
                }));
            });
        }
示例#2
0
        static void Main()
        {
            CultureInfo customCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();

            customCulture.NumberFormat.NumberDecimalSeparator = ".";
            Thread.CurrentThread.CurrentCulture = customCulture;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppConfig.refresh();

            using (Login login = new Login())
            {
                Application.Run(login);

                if (login.exit)
                {
                    return;
                }
            }

            using (ScanForm baseForm = new ScanForm()){
                Application.Run(baseForm);
            }
        }
示例#3
0
        public CollectionBuilder AddScanForm(string keyBase, ScanForm form)
        {
            if (!string.IsNullOrEmpty(form.Id))
            {
                return(Add("[id]".ToKvp(keyBase, form.Id)));
            }

            return(AddRequired("[tracking_codes]".ToKvp(keyBase, string.Join(",", form.TrackingCodes)))
                   .AddAddress(keyBase + "[from_address]", form.Address));
        }
示例#4
0
        public void TestScanFormList()
        {
            ScanFormList scanFormList = ScanForm.List();

            Assert.AreNotEqual(0, scanFormList.scanForms.Count);

            ScanFormList nextScanFormList = scanFormList.Next();

            Assert.AreNotEqual(scanFormList.scanForms[0].id, nextScanFormList.scanForms[0].id);
        }
示例#5
0
        private void scanfilebtn_Click(object sender, EventArgs e)
        {
            MainC c = (MainC)Forms.GetControl("main");

            if (c.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ScanForm frm = new ScanForm(ScanType.File, c.openFileDialog1.FileName);
                frm.Show();
            }
            else
            {
            }
        }
示例#6
0
        private void zonescan_Click(object sender, EventArgs e)
        {
            MainC c = (MainC)Forms.GetControl("main");

            if (c.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                ScanForm frm = new ScanForm(ScanType.Zone, c.folderBrowserDialog1.SelectedPath);
                frm.Show();
            }
            else
            {
            }
        }
示例#7
0
        public ActionResult Scan(ScanForm command, IScannerManager scannerManager)
        {
            var scanResult = new ScanCommand(command, scannerManager).Execute(_markerAsync);

            if (scanResult.Validate())
            {
                return new ActionResult {
                           Content = scanResult.Content, ContentType = "text/json"
                }
            }
            ;

            throw new Exception(scanResult.Error);
        }
        public void TestScanFormList()
        {
            Dictionary <string, object> dict = new Dictionary <string, object>()
            {
                { "page_size", 1 }
            };
            ScanFormList scanFormList = ScanForm.List(dict);

            Assert.AreNotEqual(null, scanFormList.scanForms[0].batch_id);
            Assert.AreNotEqual(0, scanFormList.scanForms.Count);
            ScanFormList nextScanFormList = scanFormList.Next();

            Assert.AreNotEqual(scanFormList.scanForms[0].id, nextScanFormList.scanForms[0].id);
        }
示例#9
0
        public ScanForm BindScanForm()
        {
            var command = new ScanForm
            {
                FileName          = TryGet("Form.FileName"),
                FileCounter       = TryGet("Form.FileCounter"),
                CompressionFormat = new CompressionFormat(TryGet("Form.CompressionFormat")),
                ColorMode         = TryGetInt("Form.ColorMode", 0),
                DPI                 = TryGetFloat("Form.Dpi", 150f),
                Source              = TryGetInt("Form.Source", 0),
                IsPackage           = TryGet("isPackage"),
                SaveAs              = TryGetInt("Form.SaveAs", 0),
                Format              = new FormatPage(TryGet("Form.Format")),
                DocumentHandlingCap = TryGetNullableInt("Form.ScanFeed", null)
            };

            return(command);
        }
示例#10
0
        public void TestScanFormCreateAndRetrieve()
        {
            // XXX: This is not repeatable. Need a new shipment id each time.
            List <Shipment> shipments = new List <Shipment>()
            {
                new Shipment()
                {
                    id = "shp_1b84b4a90660417bba7a2cda5152f681"
                }
            };

            ScanForm scanForm = ScanForm.Create(shipments);

            Assert.IsNotNull(scanForm.id);

            ScanForm otherScanForm = ScanForm.Retrieve(scanForm.id);

            Assert.AreEqual(scanForm.id, otherScanForm.id);
        }
示例#11
0
        protected void AppendVariable(string name, ScanForm value, bool alwaysinclude, ref string output)
        {
            string body = null;

            if (value != null)
            {
                if (string.IsNullOrWhiteSpace(value.id))
                {
                    AppendVariable(name + "[address]", value.address, false, ref body);
                    AppendVariable(name + "[batch_id]", value.batch_id, false, ref body);
                    AppendVariable(name + "[form_file_type]", value.form_file_type, false, ref body);
                    AppendVariable(name + "[form_url]", value.form_url, false, ref body);
                    AppendVariable(name + "[message]", value.message, false, ref body);
                    AppendVariable(name + "[status]", value.status, false, ref body);
                    if (value.tracking_codes != null && value.tracking_codes.Length > 0)
                    {
                        for (var i = 0; i < value.tracking_codes.Length; i++)
                        {
                            AppendVariable(name + "[tracking_codes][" + i + "]", value.tracking_codes[i], false, ref body);
                        }
                    }
                }
                else
                {
                    AppendVariable(name + "[id]", value.id, false, ref body);
                }
            }
            else if (alwaysinclude)
            {
                body = name + "=";
            }
            if (body != null)
            {
                if (output != null && output.Length > 0)
                {
                    output += "&";
                }
                output += body;
            }
        }
示例#12
0
        void EventsManager_ScanFile(string file)
        {
            ScanForm frm = new ScanForm(ScanType.File, file);

            frm.Show();
        }
示例#13
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            ScanForm frm = new ScanForm(ScanType.IDP, null);

            frm.Show();
        }
示例#14
0
        private void btni_ScanQRCode_Click(object sender, EventArgs e)
        {
            ScanForm sf = new ScanForm(this);

            sf.ShowDialog();
        }
示例#15
0
 public ScanCommand(ScanForm command, IScannerManager scannerManager)
 {
     _command        = command;
     _scannerManager = scannerManager;
     _log            = LogManager.GetLogger(typeof(ScanCommand));
 }
示例#16
0
        public CallResult <string> Closeout(IUnitOfWork db,
                                            IShipmentApi shipmentApi,
                                            IFileMaker pdfMaker,
                                            string outputDirectory,
                                            bool isSample,
                                            long?by)
        {
            _log.Info("Begin Closeout");
            var toCloseoutShippings = db.OrderShippingInfos.GetAllAsDto()
                                      .Where(sh => sh.ShipmentProviderType == (int)ShipmentProviderType.DhlECom &&
                                             !sh.ScanFormId.HasValue &&
                                             !sh.CancelLabelRequested &&
                                             !sh.LabelCanceled &&
                                             !String.IsNullOrEmpty(sh.StampsTxId))
                                      .ToList();

            var toCloseoutMails = db.MailLabelInfos.GetAllAsDto()
                                  .Where(m => m.ShipmentProviderType == (int)ShipmentProviderType.DhlECom &&
                                         !m.ScanFormId.HasValue &&
                                         !m.CancelLabelRequested &&
                                         !m.LabelCanceled &&
                                         !String.IsNullOrEmpty(m.StampsTxId))
                                  .ToList();

            //var shippingWithEmptyPackageIds = toCloseoutShippings.Where(sh => String.IsNullOrEmpty(sh.StampsTxId)).ToList();
            //if (shippingWithEmptyPackageIds.Any())
            //    return CallResult<string>.Fail("The following orders have has empty Package Id: "
            //        + String.Join(", ", shippingWithEmptyPackageIds.Select(sh => sh.OrderAmazonId).ToList()), null);

            //var mailingWithEmptyPackageIds = toCloseoutMails.Where(sh => String.IsNullOrEmpty(sh.StampsTxId)).ToList();
            //if (mailingWithEmptyPackageIds.Any())
            //    return CallResult<string>.Fail("The following orders have has empty Package Id: "
            //        + String.Join(", ", mailingWithEmptyPackageIds.Select(sh => sh.OrderAmazonId).ToList()), null);


            var closeoutIds = toCloseoutShippings.Select(sh => sh.StampsTxId).ToList();

            closeoutIds.AddRange(toCloseoutMails.Select(m => m.StampsTxId).ToList());

            _log.Info("Request closeout for Ids: " + String.Join(", ", closeoutIds));

            CallResult <IList <ScanFormInfo> > result = null;

            if (isSample)
            {
                result = CallResult <IList <ScanFormInfo> > .Success(new List <ScanFormInfo>()
                {
                    new ScanFormInfo()
                    {
                        ScanFormId   = "Test1",
                        ScanFormPath = "~/Closeouts/closeout_1_7027750.pdf"
                    }
                });
            }
            else
            {
                result = shipmentApi.GetScanForm(closeoutIds, null, DateTime.UtcNow);
            }
            _log.Info("Result: " + result.IsSuccess);

            if (result.IsSuccess)
            {
                var forms = result.Data;

                long?lastFormId = null;
                foreach (var form in forms)
                {
                    var dbForm = new ScanForm()
                    {
                        FormId     = form.ScanFormId,
                        FileName   = form.ScanFormPath,
                        CreateDate = _time.GetAppNowTime(),
                        CreatedBy  = by,
                    };
                    db.ScanForms.Add(dbForm);
                    db.Commit();
                    lastFormId = dbForm.Id;
                }

                var pdfFileName = pdfMaker.CreateFileWithLabels(new List <PrintLabelInfo>(),
                                                                forms.Select(s => outputDirectory + s.ScanFormPath.Trim(new[] { '~' })).ToList(),
                                                                null,
                                                                outputDirectory);

                var printPack = new LabelPrintPack()
                {
                    FileName   = pdfFileName,
                    CreateDate = _time.GetAppNowTime(),
                };
                db.LabelPrintPacks.Add(printPack);
                db.Commit();

                _log.Info("Begin update shipments");
                var fromDate          = _time.GetAppNowTime().AddDays(-30);
                var shipmentsToUpdate = db.OrderShippingInfos.GetAll().Where(sh => sh.CreateDate > fromDate &&
                                                                             closeoutIds.Contains(sh.StampsTxId))
                                        .ToList();
                var mailingsToUpdate = db.MailLabelInfos.GetAll().Where(sh => sh.CreateDate > fromDate &&
                                                                        closeoutIds.Contains(sh.StampsTxId))
                                       .ToList();

                foreach (var shipment in shipmentsToUpdate)
                {
                    shipment.ScanFormId = lastFormId;
                }
                db.Commit();
                foreach (var mailing in mailingsToUpdate)
                {
                    mailing.ScanFormId = lastFormId;
                }
                db.Commit();
                _log.Info("End update shipments");

                var url = Models.UrlHelper.GetPrintLabelPathById(printPack.Id);

                return(CallResult <string> .Success(url));
            }
            else
            {
                return(CallResult <string> .Fail(result.Message, null));
            }
        }
        public void TestScanFormCreateAndRetrieve()
        {
            ScanForm scanForm = ScanForm.Retrieve(null, "sf_e35ae7fc59bb4482ae32efc663267104");

            Assert.AreEqual("sf_e35ae7fc59bb4482ae32efc663267104", scanForm.id);
        }
示例#18
0
        public CallResult <string> Closeout(IUnitOfWork db,
                                            IShipmentApi shipmentApi,
                                            IList <DropShipperApi> externalApis,
                                            IFileMaker pdfMaker,
                                            string outputDirectory,
                                            bool isSample,
                                            long?by)
        {
            _log.Info("Begin Closeout");
            var toCloseoutShippings = db.OrderShippingInfos.GetAllAsDto()
                                      .Where(sh => sh.ShipmentProviderType == (int)ShipmentProviderType.IBC &&
                                             !sh.ScanFormId.HasValue &&
                                             !sh.CancelLabelRequested &&
                                             !sh.LabelCanceled &&
                                             !String.IsNullOrEmpty(sh.StampsTxId))
                                      .ToList();

            var toCloseoutMails = db.MailLabelInfos.GetAllAsDto()
                                  .Where(m => m.ShipmentProviderType == (int)ShipmentProviderType.IBC &&
                                         !m.ScanFormId.HasValue &&
                                         !m.CancelLabelRequested &&
                                         !m.LabelCanceled &&
                                         !String.IsNullOrEmpty(m.StampsTxId))
                                  .ToList();

            var closeoutIds = toCloseoutShippings.Select(sh => sh.StampsTxId).ToList();

            closeoutIds.AddRange(toCloseoutMails.Select(m => m.StampsTxId).ToList());

            foreach (var extApi in externalApis)
            {
                var extInfo = extApi.GetIBCOrdersToClose();
                if (!extInfo.IsFail)
                {
                    var mbgCloseoutShippingIds = extInfo.Data.ToCloseoutIds;
                    _log.Info("External API " + extApi.Market + "-" + extApi.MarketplaceId + " closeout ids: " + String.Join(", ", mbgCloseoutShippingIds));
                    closeoutIds.AddRange(mbgCloseoutShippingIds);
                }
                else
                {
                    _log.Info("No communication with " + extApi.Market + "-" + extApi.MarketplaceId + ". Details: " + extInfo.Message);
                    //return CallResult<string>.Fail("No communication with " + extApi.Market + "-" + extApi.MarketplaceId + ". Details: " + extInfo.Message, null);
                }
            }

            _log.Info("Request closeout for Ids: " + String.Join(", ", closeoutIds));

            CallResult <IList <ScanFormInfo> > result = null;

            if (isSample)
            {
                result = CallResult <IList <ScanFormInfo> > .Success(new List <ScanFormInfo>()
                {
                    new ScanFormInfo()
                    {
                        ScanFormId   = "Test1",
                        ScanFormPath = "~/Closeouts/closeout_1_7027750.pdf"
                    }
                });
            }
            else
            {
                result = shipmentApi.GetScanForm(closeoutIds, null, DateTime.UtcNow);
            }
            _log.Info("Result: " + result.IsSuccess);

            if (result.IsSuccess)
            {
                var form = result.Data.FirstOrDefault();

                long?lastFormId = null;
                var  dbForm     = new ScanForm()
                {
                    FormId     = form.ScanFormId,
                    FileName   = form.ScanFormPath,
                    CreateDate = _time.GetAppNowTime(),
                    CreatedBy  = by,
                };
                db.ScanForms.Add(dbForm);
                db.Commit();
                lastFormId = dbForm.Id;

                _log.Info("Begin update shipments");
                var fromDate          = _time.GetAppNowTime().AddDays(-30);
                var shipmentsToUpdate = db.OrderShippingInfos.GetAll().Where(sh => sh.CreateDate > fromDate &&
                                                                             closeoutIds.Contains(sh.StampsTxId))
                                        .ToList();
                var mailingsToUpdate = db.MailLabelInfos.GetAll().Where(sh => sh.CreateDate > fromDate &&
                                                                        closeoutIds.Contains(sh.StampsTxId))
                                       .ToList();

                foreach (var shipment in shipmentsToUpdate)
                {
                    shipment.ScanFormId = lastFormId;
                }
                db.Commit();
                foreach (var mailing in mailingsToUpdate)
                {
                    mailing.ScanFormId = lastFormId;
                }
                db.Commit();
                _log.Info("End update shipments");

                _log.Info("Form: " + (form.CloseoutIds != null ? String.Join(",", form.CloseoutIds) : "null"));

                foreach (var extApi in externalApis)
                {
                    _log.Info("Begin update " + extApi.Market + "-" + extApi.MarketplaceId + " shipments");
                    var closeResult = extApi.CloseIBCOrders(form);
                    _log.Info("Close result: isSuccess: " + closeResult.IsSuccess + ", message: " + closeResult.Message);
                    _log.Info("End update shipments");
                }

                return(CallResult <string> .Success(""));
            }
            else
            {
                return(CallResult <string> .Fail(result.Message, null));
            }
        }
示例#19
0
        private void btni_scan_Click(object sender, EventArgs e)
        {
            ScanForm Sf = new ScanForm(this);

            Sf.ShowDialog();
        }
示例#20
0
        private void quickscanbtn_Click(object sender, EventArgs e)
        {
            ScanForm frm = new ScanForm(ScanType.Quick, @"C:\");

            frm.Show();
        }