public AddAddressViewModel(WalletService ws, PoolingService ps)
        {
            _poolingService = ps;
            _walletService  = ws;

            Task.Run(() => _walletService.GetAvailabeTickers().ContinueWith((result) =>
            {
                if (result.Exception == null)
                {
                    var tickerSelected = new TickerDTO()
                    {
                        CoinSymbol = "Auto Detect",
                        Degraded   = false
                    };
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        TickerList.Add(tickerSelected);
                        foreach (var ticker in result.Result.OrderBy(o => o.CoinSymbol).ToList())
                        {
                            TickerList.Add(ticker);
                        }
                        NotifyOfPropertyChange(() => TickerList);
                        SelectedTicker = tickerSelected;
                    });
                }
            }));
        }
Ejemplo n.º 2
0
 public MainViewModel(PoolingService ps, LoginService ls, WalletService ws,
                      AddAddressViewModel aavm, DonateViewModel dvm, AskNewCoinViewModel ancm)
 {
     _poolingService      = ps;
     _addAddressViewModel = aavm;
     _donateViewModel     = dvm;
     _askNewCoinViewModel = ancm;
     _loginService        = ls;
     _walletService       = ws;
     firstLogin           = true;
     GetVersion(() => { LoginSeed(); });
 }
Ejemplo n.º 3
0
        public ActionResult UploadCustomerData(UploadModel model)
        {
            try
            {
                ITransactionService tranSrv    = IoC.Resolve <ITransactionService>();
                EInvoiceContext     Context    = (EInvoiceContext)FXContext.Current;
                Company             currentCom = Context.CurrentCompany;
                HttpPostedFileBase  fileUpload = Request.Files["FilePath"];
                if (fileUpload == null || fileUpload.ContentLength <= 0)
                {
                    Messages.AddErrorFlashMessage("Chưa chọn file dữ liệu khách hàng.");
                    return(RedirectToAction("Upload", new { TypeTran = model.TypeTrans }));
                }

                Transaction mTran = new Transaction();
                byte[]      bf    = new byte[fileUpload.ContentLength];
                fileUpload.InputStream.Read(bf, 0, fileUpload.ContentLength);
                if (!fileUpload.FileName.ToLower().Contains(".zip") && !fileUpload.FileName.ToLower().Contains(".xls"))
                {
                    Messages.AddErrorFlashMessage("File upload phải là file .zip hoặc .xls !");
                    return(RedirectToAction("Upload", new { TypeTran = model.TypeTrans }));
                }

                mTran.Data        = bf;
                mTran.ComID       = currentCom.id;
                mTran.id          = Guid.NewGuid();
                mTran.InvPattern  = model.Pattern;
                mTran.InvSerial   = model.Serial;
                mTran.AccountName = HttpContext.User.Identity.Name;
                mTran.Status      = TranSactionStatus.NewUpload;
                mTran.TypeTrans   = model.TypeTrans;
                IPoolingService service = new PoolingService(Context);
                if (fileUpload.FileName.ToLower().Contains(".xls"))
                {
                    //xu ly doc excell và tạo xml.
                    IDataTranService dataTranSrv = currentCom.Config.Keys.Contains("IDataTranService") ? IoC.Resolve(Type.GetType(currentCom.Config["IDataTranService"])) as IDataTranService : new ExcelDefaultDataTranService();
                    string           parseError  = "";
                    string           xmlData     = dataTranSrv.ParseCustomer(mTran.Data, ref parseError);
                    //update lai du lieu data xml
                    if (null != xmlData)
                    {
                        mTran.Data = CompressFile(System.Text.Encoding.UTF8.GetBytes(xmlData));
                    }
                    else
                    {
                        mTran.Status   = TranSactionStatus.Failed;
                        mTran.Messages = parseError;
                        tranSrv.CreateNew(mTran);
                        tranSrv.CommitChanges();
                        log.Info("Upload Transaction by: " + HttpContext.User.Identity.Name);
                        Messages.AddErrorFlashMessage("Upload file khách hàng lên hệ thống không thành công, theo dõi kết quả qua mã giao dịch: " + mTran.id);
                        return(RedirectToAction("Index", new { TypeTran = model.TypeTrans }));
                    }
                }
                tranSrv.CreateNew(mTran);
                tranSrv.CommitChanges();
                log.Info("Upload Customer by: " + HttpContext.User.Identity.Name + "--Begin call webservice");
                service.importCus(mTran.id);
                Messages.AddFlashMessage("Upload file lên hệ thống thành công, theo dõi kết quả qua mã giao dịch: " + mTran.id);
                return(RedirectToAction("Index", new { TypeTran = model.TypeTrans }));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(RedirectToAction("Upload", new { TypeTran = model.TypeTrans }));
            }
        }
Ejemplo n.º 4
0
        public ActionResult UploadInvoiceCancelData(UploadModel model)
        {
            try
            {
                ITransactionService tranSrv      = IoC.Resolve <ITransactionService>();
                EInvoiceContext     Context      = (EInvoiceContext)FXContext.Current;
                Company             currentCom   = Context.CurrentCompany;
                HttpPostedFileBase  fileUpload   = Request.Files["FilePath"];
                HttpPostedFileBase  fileQDUpload = Request.Files["FileQDPath"];
                if (fileUpload == null || fileUpload.ContentLength == 0)
                {
                    Messages.AddErrorFlashMessage("Chưa chọn file dữ liệu hủy.");
                    return(RedirectToAction("Upload", new { TypeTran = model.TypeTrans }));
                }

                if (fileQDUpload == null || fileQDUpload.ContentLength == 0)
                {
                    Messages.AddErrorFlashMessage("Chưa chọn file quyết định hủy.");
                    return(RedirectToAction("Upload", model));
                }
                byte[] qdinhHuybuffer = new byte[fileQDUpload.ContentLength];
                fileQDUpload.InputStream.Read(qdinhHuybuffer, 0, fileQDUpload.ContentLength);
                if (!fileQDUpload.FileName.ToLower().Contains(".jpg") && !fileQDUpload.FileName.ToLower().Contains(".png"))
                {
                    Messages.AddErrorFlashMessage("File QĐ upload phải là file .jpg hoặc .png!");
                    return(RedirectToAction("Upload", new { TypeTran = model.TypeTrans }));
                }

                byte[] dulieuhuyBuffer = new byte[fileUpload.ContentLength];
                fileUpload.InputStream.Read(dulieuhuyBuffer, 0, fileUpload.ContentLength);
                if (!fileUpload.FileName.ToLower().Contains(".zip") && !fileUpload.FileName.ToLower().Contains(".xls"))
                {
                    Messages.AddErrorFlashMessage("File upload phải là file .zip hoặc .xls.");
                    return(RedirectToAction("Upload", new { TypeTran = model.TypeTrans }));
                }

                Transaction mTran = new Transaction();
                mTran.Data        = dulieuhuyBuffer;
                mTran.ComID       = currentCom.id;
                mTran.id          = Guid.NewGuid();
                mTran.InvPattern  = model.Pattern;
                mTran.InvSerial   = model.Serial;
                mTran.AccountName = HttpContext.User.Identity.Name;
                mTran.Status      = TranSactionStatus.NewUpload;
                mTran.TypeTrans   = model.TypeTrans;
                string fullPath = "";
                //string filePath = WebConfigurationManager.AppSettings["InvUnReleaseDecisionDir"]
                string filePath = AppDomain.CurrentDomain.BaseDirectory + WebConfigurationManager.AppSettings["InvUnReleaseDecisionDir"];
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }
                if (!filePath.EndsWith(@"\"))
                {
                    filePath += @"\";
                }
                fullPath = filePath + fileUpload.FileName;
                System.IO.File.Delete(fullPath);
                System.IO.File.WriteAllBytes(fullPath, qdinhHuybuffer);
                mTran.AttachedFile = fullPath;
                mTran.Reason       = model.ReasonDel;

                if (fileUpload.FileName.ToLower().Contains(".xls"))
                {
                    //xu ly doc excell và tạo xml.
                    IDataTranService dataTranSrv = currentCom.Config.Keys.Contains("IDataTranService") ? IoC.Resolve(Type.GetType(currentCom.Config["IDataTranService"])) as IDataTranService : new ExcelDefaultDataTranService();
                    string           parseError  = "";
                    string           xmlData     = dataTranSrv.ParseIInvoiceCancel(mTran.Data, ref parseError);
                    //update lai du lieu data xml
                    if (null != xmlData)
                    {
                        mTran.Data = CompressFile(System.Text.Encoding.UTF8.GetBytes(xmlData));
                    }
                    else
                    {
                        mTran.Status   = TranSactionStatus.Failed;
                        mTran.Messages = parseError;
                        tranSrv.CreateNew(mTran);
                        tranSrv.CommitChanges();
                        log.Info("Upload Transaction by: " + HttpContext.User.Identity.Name);
                        Messages.AddErrorFlashMessage("Upload file khách hàng lên hệ thống không thành công, theo dõi kết quả qua mã giao dịch: " + mTran.id);
                        return(RedirectToAction("Index", new { TypeTran = model.TypeTrans }));
                    }
                }

                tranSrv.CreateNew(mTran);
                tranSrv.CommitChanges();
                log.Info("Upload Transaction by: " + HttpContext.User.Identity.Name + "--Begin call webservice");
                IPoolingService service = new PoolingService(Context);
                service.cancelInv(mTran.id);
                Messages.AddFlashMessage("Upload file lên hệ thống thành công, theo dõi kết quả qua mã giao dịch: " + mTran.id);
                return(RedirectToAction("Index", new { TypeTran = model.TypeTrans }));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(RedirectToAction("Upload", new { TypeTran = model.TypeTrans }));
            }
        }