コード例 #1
0
ファイル: MainAdapter.cs プロジェクト: zaharPonimash/dbqf
        public MainAdapter(
            Project project, DbServiceFactory serviceFactory, IFieldPathFactory pathFactory,
            PresetView preset, StandardView standard, AdvancedView advanced,
            RetrieveFieldsView fields)
            : base(project)
        {
            ServiceFactory = serviceFactory;
            PathFactory    = pathFactory;

            Preset   = preset;
            Standard = standard;
            Advanced = advanced;
            _views.Add("Preset", preset.Adapter);
            _views.Add("Standard", standard.Adapter);
            _views.Add("Advanced", advanced.Adapter);

            RetrieveFields = fields;

            Preset.Adapter.Search   += Adapter_Search;
            Standard.Adapter.Search += Adapter_Search;
            Advanced.Adapter.Search += Adapter_Search;

            SelectedSubjectChanged += delegate { RefreshPaths(); };

            var refresh = new EventHandler((s, e) =>
            {
                RefreshPaths();
                _dbService = ServiceFactory.CreateAsync(Project.CurrentConnection);
            });

            Project.CurrentConnectionChanged += refresh;
            Result = new BindingSource();
            refresh(this, EventArgs.Empty);
        }
コード例 #2
0
        public IActionResult Index([FromQuery] string access_token, [FromBody] WebHookRequest request)
        {
            var token = ConfigHelper.GetString("PaymentFileLoaded.access_token");

            if (token.ToLowerInvariant() != access_token.ToLowerInvariant())
            {
                return(BadRequest());
            }

            try
            {
                Logger.Info(request.ToString());
                var dao = DbServiceFactory.GetCurrent();
                if (dao == null)
                {
                    throw new NullReferenceException("Can not get database connection");
                }

                var customExporter = new CustomDistributeAndExportPayment();
                customExporter.Process(request.fileId, request.siteName);

                Logger.Info("Execute successful.");
                return(Ok("successful"));
            }
            catch (Exception ex)
            {
                Logger.Info("Execute failed.");
                Logger.Error(ex);
                throw;
            }
        }
コード例 #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            services.AddSingleton <IDockerService>(s => new DockerService());

            services.AddSingleton(s => DbServiceFactory.CreateFromEnvironmentVariables(s.GetRequiredService <IConfiguration>()));
            services.AddSingleton(s => s.GetRequiredService <IDbService>().Stacks);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: wjire/Wjire.CodeBuilder
        /// <summary>
        /// 切换数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBox_one_dataBase_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox_one_dataBase.SelectedIndex < 0)
            {
                return;
            }
            textBox_dbName.Text = comboBox_one_dataBase.Text;
            ConnectionInfo info = GetCurrentConnectionInfo();

            _dbService = DbServiceFactory.CreateDbService(info);
            GetTableNames();
        }
コード例 #5
0
ファイル: ShellBase.cs プロジェクト: zaharPonimash/dbqf
        public ShellBase(Project project, DbServiceFactory serviceFactory, ListCacher cacher, IList <IInitialiser> initialisers)
        {
            Project        = project;
            ServiceFactory = serviceFactory;
            Cacher         = cacher;
            OnConnectionChanged();

            foreach (var i in initialisers)
            {
                i.Initialise();
            }
        }
コード例 #6
0
ファイル: Shell.cs プロジェクト: zaharPonimash/dbqf
        public Shell(Project project, IControlFactory <Control> controlFactory, DbServiceFactory serviceFactory, ListCacher cacher, IList <IInitialiser> initialisers)
            : base(project, serviceFactory, cacher, initialisers)
        {
            // initialise last saved connection with this project
            var connectionLookup = Settings.Default.SavedConnections;

            if (connectionLookup.ContainsKey(Project.Id))
            {
                Project.CurrentConnection = Project.Connections.Find(c => c.Identifier == connectionLookup[Project.Id]);
            }

            ControlFactory = controlFactory;
            ControlFactory.ListRequested += ControlFactory_ListRequested;
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: wjire/Wjire.CodeBuilder
        /// <summary>
        /// 连接到数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void button_one_conn_Click(object sender, EventArgs e)
        {
            comboBox_one_dataBase.Items.Clear();
            comboBox_one_dataBase.Text = string.Empty;
            Clear();
            ConnectionInfo info = GetCurrentConnectionInfo();

            _dbService = DbServiceFactory.CreateDbService(info);
            List <string> dbList = await _dbService.GetAllDataBase();

            BindDataBase(dbList);
            GetTableNames();
            AddConnectionInfoToComboBox(info);
            AddConnectionInfoToCache(info);
            SaveConnectionInfoToResource();
        }
コード例 #8
0
        public void GetVendorsAndSendEmail()
        {
            var dao = DbServiceFactory.GetCurrent();

            if (dao == null)
            {
                throw new Exception("Can not get data connection");
            }
            var list = dao.ProcForListObject <VendorData>("[custom].usp_s_GetAllVendorWithPaymentMethod").ToList();

            LOGGER.Info($"Total {list.Count} vendors");
            if (list.Any())
            {
                StringBuilder builder = GenerateReportFileContent(list);
                SendEmail(builder);
            }
        }
コード例 #9
0
ファイル: Startup.cs プロジェクト: weedkiller/Triceratops
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSignalR();

            services
            .AddControllersWithViews(o =>
            {
                o.Filters.Add(new TimedRequestAttribute());
            })
            .AddJsonOptions(o => JsonHelper.UpdateSerialiserOptions(o.JsonSerializerOptions));

            ConfigureDocker(services);

            services.AddSingleton(s => DbServiceFactory.CreateFromEnvironmentVariables());
            services.AddSingleton(s => s.GetRequiredService <IDbService>().Servers);
            services.AddSingleton(s => s.GetRequiredService <IDbService>().Containers);

            services.AddSingleton <IServerService>(s => new ServerService(
                                                       s.GetRequiredService <IDbService>(),
                                                       s.GetRequiredService <ITriceratopsDockerClient>()
                                                       ));
        }
コード例 #10
0
        public MainWindowAdapter(
            Project project, DbServiceFactory serviceFactory, IFieldPathFactory pathFactory,
            PresetView preset, StandardView standard, AdvancedView advanced,
            RetrieveFieldsView fields)
            : base(project)
        {
            _appWidth       = Properties.Settings.Default.AppWidth;
            _appHeight      = Properties.Settings.Default.AppHeight;
            _appWindowState = Properties.Settings.Default.AppWindowState;
            _viewColumnSize = new GridLength(Properties.Settings.Default.ViewColumnSize);

            Preset         = preset;
            Standard       = standard;
            Advanced       = advanced;
            RetrieveFields = fields;
            _views.Add("Preset", preset.Adapter);
            _views.Add("Standard", standard.Adapter);
            _views.Add("Advanced", advanced.Adapter);

            Preset.Adapter.Search   += Adapter_Search;
            Standard.Adapter.Search += Adapter_Search;
            Advanced.Adapter.Search += Adapter_Search;

            ProjectAdapter = new ProjectAdapter(project);
            PathFactory    = pathFactory;
            ServiceFactory = serviceFactory;

            CurrentView             = Preset.Adapter;
            SelectedSubjectChanged += delegate { RefreshPaths(); };
            var refresh = new EventHandler((s, e) =>
            {
                RefreshPaths();
                OnPropertyChanged("ApplicationTitle");
                _dbService = ServiceFactory.CreateAsync(Project.CurrentConnection);
            });

            ProjectAdapter.Project.CurrentConnectionChanged += refresh;
            refresh(this, EventArgs.Empty);
        }
コード例 #11
0
        public bool ProcessCreateVendors(out string errors)
        {
            errors = string.Empty;
            var vendors = this._paymentDatas.Select(vendorSelector);
            var dt      = vendors.ToDataTable();
            var dao     = DbServiceFactory.GetCurrent();

            if (dao == null)
            {
                throw new Exception("Can not get customer data connection");
            }
            IDictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@PaymentConversionVendorAddressesTvp"] = dt;
            object oResult = dao.ProcForScalar("dbo.usp_i_CreateVendorFromPaymentFile", parameters);

            if (oResult != null && !AppHelper.IsNumeric(oResult))
            {
                errors = AppHelper.ToString(oResult);
                return(false);
            }
            return(true);
        }
        public void Process(int fileId, string siteName)
        {
            try
            {
                Logger.Info("begin CustomDistributeAndExportPayment process");
                var dao        = DbServiceFactory.GetCurrent();
                var parameters = new Dictionary <string, object>();
                parameters.Add("@I_vFileId", fileId);
                var list = dao.ProcForListObject <PaymentData>("[custom].usp_s_GetPaymentByFileID", parameters).ToList();

                var grouped = list.GroupBy(s => new
                {
                    TransactionId     = s.TransactionId,
                    PaymentNumber     = s.PaymentNumber,
                    PaymentMethod     = s.PaymentMethod,
                    PaymentDate       = s.PaymentDate,
                    PaymentAmount     = s.PaymentAmount,
                    VendorID          = s.VendorID,
                    VendorName        = s.VendorName,
                    PayeeAddressLine1 = s.PayeeAddressLine1,
                    PayeeAddressLine2 = s.PayeeAddressLine2,
                    PayeeAddressLine3 = s.PayeeAddressLine3,
                    PayeeAddressLine4 = s.PayeeAddressLine4,
                    PaymentBatchId    = s.PaymentBatchId,
                }).Select(s => new Payment
                {
                    Details = s.ToList(),
                    Header  = new PaymentHeader
                    {
                        TransactionId     = s.Key.TransactionId,
                        PaymentNumber     = s.Key.PaymentNumber,
                        PaymentMethod     = s.Key.PaymentMethod,
                        PaymentDate       = s.Key.PaymentDate,
                        PaymentAmount     = s.Key.PaymentAmount,
                        VendorID          = s.Key.VendorID,
                        VendorName        = s.Key.VendorName,
                        PayeeAddressLine1 = s.Key.PayeeAddressLine1,
                        PayeeAddressLine2 = s.Key.PayeeAddressLine2,
                        PayeeAddressLine3 = s.Key.PayeeAddressLine3,
                        PayeeAddressLine4 = s.Key.PayeeAddressLine4,
                        PaymentBatchId    = s.Key.PaymentBatchId,
                    }
                }).OrderBy(s => s.Header.VendorName);
                if (list.Any())
                {
                    var batchId             = list.First(s => s.PaymentBatchId.HasValue).PaymentBatchId;
                    var exportTime          = DateTime.Now.ToString("yyyyMMddHHmmss");
                    var checkFileOutputName = $"CHECK_{exportTime}_{batchId}.txt";
                    var eftFileOutputName   = $"EFT_{exportTime}_{batchId}.txt";
                    //gennerate check file
                    var checkPaymentList = grouped.Where(s => s.Header.PaymentMethod == 0).ToList();
                    Logger.Info($"check payment count: {checkPaymentList.Count})");

                    StringBuilder checkFileContent = GenerateCheckFileContent(checkPaymentList);

                    //gennerate eft file
                    var eftPaymentList = grouped.Where(s => s.Header.PaymentMethod != 0).ToList();

                    Logger.Info("eft payment count: " + eftPaymentList.Count);
                    StringBuilder eftFileContent = GenerateEftFileContent(eftPaymentList);

                    //upload to blob
                    if (checkFileContent.Length > 0)
                    {
                        UploadFileToBlobStorage(checkFileOutputName, checkFileContent, siteName);
                        //send msb
                        SendMessageToMsgBus(checkFileOutputName, siteName);
                    }
                    else
                    {
                        Logger.Info("No file is exported because there is no CHECK payment records");
                    }

                    if (eftFileContent.Length > 0)
                    {
                        UploadFileToBlobStorage(eftFileOutputName, eftFileContent, siteName);
                        SendMessageToMsgBus(eftFileOutputName, siteName);
                    }
                    else
                    {
                        Logger.Info("No file is exported because there is no EFT payment records");
                    }

                    //delete CHECK
                    if (checkPaymentList.Any())
                    {
                        parameters = new Dictionary <string, object>();
                        parameters.Add("@I_vBatchId", batchId);
                        Logger.Info($"call [custom].[usp_d_DeleteCheckPaymentFromBatch] with batchId = {batchId}");
                        dao.ProcForScalar("[custom].[usp_d_DeleteCheckPaymentFromBatch]", parameters);
                    }
                }
                else
                {
                    Logger.Info("No batch created with file: " + fileId);
                }
                Logger.Info("end CustomDistributeAndExportPayment process");
            }
            catch (Exception e)
            {
                Logger.Error("error:", e);
            }
        }