示例#1
0
 static void Main(string[] args)
 {
     Uri address = new Uri("http://localhost/WcfServices/CalculatorService");
     ServiceProxyFactory<ICalculator> factory = new ServiceProxyFactory<ICalculator>(address);
     ICalculator proxy = factory.CreateChannel();
     Console.WriteLine("x + y = {2} when x = {0} and y = {1}", 1, 2, proxy.Add(1, 2));
     Console.WriteLine("x - y = {2} when x = {0} and y = {1}", 1, 2, proxy.Subtract(1, 2));
     Console.WriteLine("x * y = {2} when x = {0} and y = {1}", 1, 2, proxy.Multiply(1, 2));
     Console.WriteLine("x / y = {2} when x = {0} and y = {1}", 1, 2, proxy.Divide(1, 2));
 }
示例#2
0
        /// <summary>
        /// This is the main entry point for your service replica.
        /// This method executes when this replica of your service becomes primary and has write status.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            var proxyFactory  = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory());
            var proxyFactory2 = new ServiceProxyFactory(c => new CorrelatingFabricTransportServiceRemotingClientFactory <ISampleService>());
            var proxyFactory3 = new ActorProxyFactory();

            //ISampleService service = proxyFactory2.CreateServiceProxy<ISampleService>(
            //   new Uri("fabric:/LogMagic.FabricTestApp2/LogMagic.FabricTestApp.StatelessSimulator"));

            ISampleService service = CorrelatingProxyFactory.CreateServiceProxy <ISampleService>(
                new Uri("fabric:/LogMagic.FabricTestApp2/LogMagic.FabricTestApp.StatelessSimulator"),
                raiseSummary: RaiseSummary,
                remoteServiceName: "StatelessSimulator");

            IActorSimulator actor = CorrelatingProxyFactory.CreateActorProxy <IActorSimulator>(ActorId.CreateRandom());

            //actor = proxyFactory3.CreateActorProxy<IActorSimulator>(ActorId.CreateRandom());

            using (L.Context("param1", "value1"))
            {
                try
                {
                    string hey = await service.PingSuccessAsync("hey");

                    await actor.SetCountAsync(5, cancellationToken);

                    int count = await actor.GetCountAsync(cancellationToken);

                    hey = await service.PingFailureAsync("fail");
                }
                catch (Exception ex)
                {
                    ex = null;
                }
            }
        }
示例#3
0
        private static void QueryAtors()
        {
            var fabricClient  = new FabricClient();
            var serviceUri    = new Uri("fabric:/ActorCustomDataContractSerialization/MyActorService");
            var partitionList = fabricClient.QueryManager.GetPartitionListAsync(serviceUri).GetAwaiter().GetResult();

            foreach (var partition in partitionList)
            {
                ContinuationToken continuationToken = null;
                var queriedActorCount         = 0;
                var queriedActiveActorCount   = 0;
                var queriedInactiveActorCount = 0;


                var proxyFactory = new ServiceProxyFactory((c) =>
                {
                    return(new FabricTransportServiceRemotingClientFactory(
                               serializationProvider: new CustomDataContractProvider()));
                });

                do
                {
                    var partitionKey      = new ServicePartitionKey(((Int64RangePartitionInformation)partition.PartitionInformation).LowKey);
                    var actorServiceProxy = proxyFactory.CreateServiceProxy <IActorService>(serviceUri, partitionKey);
                    var queryResult       = actorServiceProxy.GetActorsAsync(continuationToken, CancellationToken.None)
                                            .GetAwaiter().GetResult();
                    queriedActorCount         += queryResult.Items.Count();
                    queriedActiveActorCount   += queryResult.Items.Count(actor => actor.IsActive);
                    queriedInactiveActorCount += queryResult.Items.Count(actor => !actor.IsActive);
                    continuationToken          = queryResult.ContinuationToken;
                } while (continuationToken != null);


                Console.WriteLine($"Partition Id: {partition.PartitionInformation.Id},  Total: {queriedActorCount}, Active: {queriedActiveActorCount}, Inactive {queriedInactiveActorCount}");
            }
        }
        private void ImportAccountTitle()
        {
            try
            {
                ClearStatusMessage();

                ImportSetting importSetting = null;
                // 取込設定取得
                var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.AccountTitle);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;

                var definition = new AccountTitleFileDefinition(new DataExpression(ApplicationControl));

                definition.AccountTitleCodeField.ValidateAdditional = (val, param) =>
                {
                    var reports = new List <WorkingReport>();
                    if (((ImportMethod)param) != ImportMethod.Replace)
                    {
                        return(reports);
                    }

                    MasterDatasResult categoryResult      = null;
                    MasterDatasResult customerResult      = null;
                    MasterDatasResult debitBillingResult  = null;
                    MasterDatasResult creditBillingResult = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var accountTitle    = factory.Create <AccountTitleMasterClient>();
                        var codes           = val.Values.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).Distinct().ToArray();
                        categoryResult      = accountTitle.GetImportItemsForCategory(SessionKey, CompanyId, codes);
                        customerResult      = accountTitle.GetImportItemsForCustomerDiscount(SessionKey, CompanyId, codes);
                        debitBillingResult  = accountTitle.GetImportItemsForDebitBilling(SessionKey, CompanyId, codes);
                        creditBillingResult = accountTitle.GetImportItemsForCreditBilling(SessionKey, CompanyId, codes);
                    });

                    foreach (MasterData ca in categoryResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.AccountTitleCodeField.FieldIndex,
                            FieldName = definition.AccountTitleCodeField.FieldName,
                            Message   = $"区分マスターに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。",
                        });
                    }

                    foreach (MasterData ca in customerResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.AccountTitleCodeField.FieldIndex,
                            FieldName = definition.AccountTitleCodeField.FieldName,
                            Message   = $"得意先マスター歩引設定に存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。",
                        });
                    }

                    foreach (MasterData ca in debitBillingResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.AccountTitleCodeField.FieldIndex,
                            FieldName = definition.AccountTitleCodeField.FieldName,
                            Message   = $"請求データに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。",
                        });
                    }

                    foreach (MasterData ca in creditBillingResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.AccountTitleCodeField.FieldIndex,
                            FieldName = definition.AccountTitleCodeField.FieldName,
                            Message   = $"請求データに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。",
                        });
                    }
                    return(reports);
                };

                var importer = definition.CreateImporter(m => m.Code);
                importer.UserId      = Login.UserId;
                importer.UserCode    = Login.UserCode;
                importer.CompanyId   = CompanyId;
                importer.CompanyCode = Login.CompanyCode;
                importer.LoadAsync   = async() => await LoadGridAsync();

                importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork);

                System.Action clear = () =>
                {
                    AccountTitleList.Clear();
                    var loadTask = LoadGridAsync();
                    ProgressDialog.Start(ParentForm, loadTask, false, SessionKey);
                    AccountTitleList.AddRange(loadTask.Result);
                    grdAccountTitleMaster.DataSource = new BindingSource(AccountTitleList, null);
                };
                var importResult = DoImport(importer, importSetting, clear);
                if (!importResult)
                {
                    return;
                }
                txtCode.Clear();
                txtName.Clear();
                txtContraAccountCode.Clear();
                txtContraAccountName.Clear();
                txtContraAccountSubCode.Clear();
                AccountTitleId     = 0;
                txtCode.Enabled    = true;
                this.ActiveControl = txtCode;
                BaseContext.SetFunction03Enabled(false);
                Modified = false;
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }
示例#5
0
 private async Task GetColumnNameSettingAsync()
 => await ServiceProxyFactory.DoAsync(async (ColumnNameSettingMasterService.ColumnNameSettingMasterClient client) =>
 {
     var results       = await client.GetItemsAsync(SessionKey, CompanyId);
     ColumnNameSetting = results.ColumnNames;
 });
示例#6
0
 private async Task <CountResult> DeleteLevelSettingAsync(int level)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.DeleteReminderLevelSettingAsync(SessionKey, CompanyId, level);
     return(result);
 });
示例#7
0
 private async Task <int> GetMaxLevelAsync()
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.GetMaxReminderLevelAsync(SessionKey, CompanyId);
     return(result.MaxReminderLevel);
 });
示例#8
0
 private async Task <bool> ExistTemplateAtLevelAsync(int templateId)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.ExistTemplateAtReminderLevelAsync(SessionKey, templateId);
     return(result.Exist);
 });
示例#9
0
 private async Task <ReminderTemplateSetting> GetTemplateSettingByCodeAsync(string Code)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.GetReminderTemplateSettingByCodeAsync(SessionKey, CompanyId, Code);
     return(result.ReminderTemplateSetting);
 });
示例#10
0
 private async Task ReminderExist()
 => await ServiceProxyFactory.DoAsync(async (ReminderServiceClient client) =>
 {
     var result          = await client.ExistAsync(SessionKey, CompanyId);
     IsExistReminderData = result.Exist;
 });
示例#11
0
        private async Task <bool> ValidateDeleteStaffId()
        {
            Action <string, string[]> errorHandler = (id, args) =>
            {
                ProgressDialog.Start(ParentForm, LoadStaffGrid(), false, SessionKey);
                ShowWarningDialog(id, args);
            };

            var loginUserValid = false;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var client     = factory.Create <LoginUserMasterClient>();
                var result     = await client.ExitStaffAsync(SessionKey, StaffId);
                loginUserValid = (result.Count == 0);
                if (!loginUserValid)
                {
                    errorHandler.Invoke(MsgWngDeleteConstraint, new string[] { "ログインユーザマスター", lblStaffCode.Text });
                }
            });

            if (!loginUserValid)
            {
                return(false);
            }

            var customerMasterValid = false;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service         = factory.Create <CustomerMasterClient>();
                var result          = await service.ExistStaffAsync(SessionKey, StaffId);
                customerMasterValid = !result.Exist;
                if (!customerMasterValid)
                {
                    errorHandler.Invoke(MsgWngDeleteConstraint, new string[] { "得意先マスター", lblStaffCode.Text });
                }
            });

            if (!customerMasterValid)
            {
                return(false);
            }

            var billingDataValid = false;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service      = factory.Create <BillingServiceClient>();
                var result       = await service.ExistStaffAsync(SessionKey, StaffId);
                billingDataValid = !result.Exist;
                if (!billingDataValid)
                {
                    errorHandler.Invoke(MsgWngDeleteConstraint, new string[] { "請求データ", lblStaffCode.Text });
                }
            });

            if (!billingDataValid)
            {
                return(false);
            }

            return(true);
        }
示例#12
0
 /// <summary> CurrencyIdで取得したデータを設定</summary>
 private async Task SetDataWithCurrencyId()
 {
     if (PaymentAgencyFlag)
     {
         await ServiceProxyFactory.LifeTime(async factory =>
         {
             var service = factory.Create <PaymentAgencyFeeMasterClient>();
             PaymentAgencyFeesResult result = await service.GetAsync(SessionKey, CustomerId, CurrencyId);
             {
                 if (result.ProcessResult.Result)
                 {
                     AgencyCheckList = result.PaymentAgencyFees.ToList();
                     List <PaymentAgencyFee> paymentFeeList = new List <PaymentAgencyFee>(result.PaymentAgencyFees);
                     if (paymentFeeList.Count > 0)
                     {
                         paymentFeeList.ForEach(f => f.NewFee = f.Fee);
                         Invoke(new System.Action(() =>
                         {
                             paymentFeeList.Add(new PaymentAgencyFee {
                             });
                             grid.DataSource            = new BindingSource(paymentFeeList, null);
                             grid.CurrentCellBorderLine = new Line(LineStyle.None, Color.Empty);
                             grid.CurrentRowBorderLine  = new Line(LineStyle.None, Color.Empty);
                         }));
                     }
                     else
                     {
                         grid.Rows.Clear();
                         Invoke(new System.Action(() =>
                         {
                             paymentFeeList.Add(new PaymentAgencyFee {
                             });
                             grid.DataSource            = new BindingSource(paymentFeeList, null);
                             grid.CurrentCellBorderLine = new Line(LineStyle.None, Color.Empty);
                             grid.CurrentRowBorderLine  = new Line(LineStyle.None, Color.Empty);
                             grid.CurrentCell.Selected  = false;
                         }));
                     }
                     Modified = false;
                 }
             }
         });
     }
     else
     {
         await ServiceProxyFactory.LifeTime(async factory =>
         {
             var service = factory.Create <CustomerFeeMasterClient>();
             CustomerFeeResult result = await service.GetAsync(SessionKey, CustomerId, CurrencyId);
             {
                 if (result.ProcessResult.Result)
                 {
                     CustomerCheckList = result.CustomerFee.ToList();
                     List <CustomerFee> customerFees = new List <CustomerFee>(result.CustomerFee);
                     if (customerFees.Count > 0)
                     {
                         customerFees.ForEach(f => f.NewFee = f.Fee);
                         Invoke(new System.Action(() =>
                         {
                             customerFees.Add(new CustomerFee {
                             });
                             grid.DataSource            = new BindingSource(customerFees, null);
                             grid.CurrentCellBorderLine = new Line(LineStyle.None, Color.Empty);
                             grid.CurrentRowBorderLine  = new Line(LineStyle.None, Color.Empty);
                         }));
                     }
                     else
                     {
                         grid.Rows.Clear();
                         Invoke(new System.Action(() =>
                         {
                             customerFees.Add(new CustomerFee {
                             });
                             grid.DataSource            = new BindingSource(customerFees, null);
                             grid.CurrentCellBorderLine = new Line(LineStyle.None, Color.Empty);
                             grid.CurrentRowBorderLine  = new Line(LineStyle.None, Color.Empty);
                             grid.CurrentCell.Selected  = false;
                         }));
                     }
                     Modified = false;
                 }
             }
         });
     }
 }
示例#13
0
        private void Export()
        {
            ClearStatusMessage();

            try
            {
                var loadTask = GetHolidayCalendarAsync();
                ProgressDialog.Start(ParentForm, loadTask, false, SessionKey);
                var list = loadTask.Result;

                if (!list.Any())
                {
                    ShowWarningDialog(MsgWngNoExportData);
                    return;
                }

                string serverPath = null;
                ServiceProxyFactory.LifeTime(factory =>
                {
                    var service = factory.Create <GeneralSettingMasterClient>();
                    var task    = service.GetByCodeAsync(SessionKey, CompanyId, "サーバパス");
                    ProgressDialog.Start(ParentForm, task, false, SessionKey);

                    if (task.Result.ProcessResult.Result)
                    {
                        serverPath = task.Result.GeneralSetting?.Value;
                    }
                });

                if (!Directory.Exists(serverPath))
                {
                    serverPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                }

                var filePath = string.Empty;
                var fileName = $"カレンダーマスター{DateTime.Today:yyyyMMdd}.csv";
                if (!ShowSaveExportFileDialog(serverPath, fileName, out filePath))
                {
                    return;
                }

                var definition = new HolidayCalendarFileDefinition(new DataExpression(ApplicationControl));
                var exporter   = definition.CreateExporter();
                exporter.UserId      = Login.UserId;
                exporter.UserCode    = Login.UserCode;
                exporter.CompanyId   = CompanyId;
                exporter.CompanyCode = Login.CompanyCode;

                ProgressDialog.Start(ParentForm, (cancel, progress) =>
                {
                    return(exporter.ExportAsync(filePath, list, cancel, progress));
                }, true, SessionKey);

                if (exporter.Exception != null)
                {
                    NLogHandler.WriteErrorLog(this, exporter.Exception, SessionKey);
                    ShowWarningDialog(MsgErrExportError);
                    return;
                }

                DispStatusMessage(MsgInfFinishExport);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                DispStatusMessage(MsgErrExportError);
            }
        }
示例#14
0
        private void Import()
        {
            ClearStatusMessage();
            try
            {
                ImportSetting importSetting = null;
                var           task          = Util.GetMasterImportSettingAsync(Login, ImportFileType.SectionWithLoginUser);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;
                var definition = new SectionWithLoginUserFileDefinition(new DataExpression(ApplicationControl));
                definition.SectionCodeField.GetModelsByCode = val =>
                {
                    Dictionary <string, Section> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var section           = factory.Create <SectionMasterClient>();
                        SectionsResult result = section.GetByCode(SessionKey, CompanyId, val);

                        if (result.ProcessResult.Result)
                        {
                            product = result.Sections
                                      .ToDictionary(c => c.Code);
                        }
                    });
                    return(product ?? new Dictionary <string, Section>());
                };

                definition.LoginUserCodeField.GetModelsByCode = val =>
                {
                    Dictionary <string, LoginUser> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var loginUser   = factory.Create <LoginUserMasterClient>();
                        UsersResult res = loginUser.GetByCode(SessionKey, CompanyId, val);

                        if (res.ProcessResult.Result)
                        {
                            product = res.Users
                                      .ToDictionary(c => c.Code);
                        }
                    });
                    return(product ?? new Dictionary <string, LoginUser>());
                };

                var importer = definition.CreateImporter(m => new { m.LoginUserId, m.SectionId });
                importer.UserId      = Login.UserId;
                importer.UserCode    = Login.UserCode;
                importer.CompanyId   = CompanyId;
                importer.CompanyCode = Login.CompanyCode;
                importer.LoadAsync   = async() => await SectionWithLoginUserData();

                importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork);

                var importResult = DoImport(importer, importSetting);
                if (!importResult)
                {
                    return;
                }
                ClearFromTo();
                BeforeParentSearch();
                txtLoginUserCode.Clear();
                lblLoginUserNames.Clear();
                grdLoginUserModify.DataSource = null;
                grdLoginUserOrigin.DataSource = null;
                txtLoginUserCode.Focus();
                Modified = false;
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }
示例#15
0
 private async Task <bool> SaveAsync(List <int> ids)
 => await ServiceProxyFactory.DoAsync(async (EBFileSettingMasterClient client) => {
     var result = await client.UpdateIsUseableAsync(SessionKey, CompanyId, Login.UserId, ids.ToArray());
     return(result?.ProcessResult.Result ?? false);
 });
示例#16
0
        private void ExportData()
        {
            ClearStatusMessage();

            List <Currency> list       = null;
            string          serverPath = null;

            try
            {
                var loadTask = LoadListAsync();
                var pathTask = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service = factory.Create <GeneralSettingMasterClient>();
                    var result  = await service.GetByCodeAsync(
                        SessionKey, CompanyId, "サーバパス");

                    if (result.ProcessResult.Result)
                    {
                        serverPath = result.GeneralSetting?.Value;
                    }

                    if (!Directory.Exists(serverPath))
                    {
                        serverPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    }
                });
                ProgressDialog.Start(ParentForm, Task.WhenAll(loadTask, pathTask), false, SessionKey);

                list = loadTask.Result;

                if (!list.Any())
                {
                    ShowWarningDialog(MsgWngNoExportData);
                    return;
                }

                var filePath = string.Empty;
                var fileName = $"通貨マスター{DateTime.Today:yyyyMMdd}.csv";
                if (!ShowSaveExportFileDialog(serverPath, fileName, out filePath))
                {
                    return;
                }

                var definition = new CurrencyFileDefinition(new DataExpression(ApplicationControl));
                definition.CurrencyToleranceField.Format = value => value.ToString("G29");

                var exporter = definition.CreateExporter();
                exporter.UserId      = Login.UserId;
                exporter.UserCode    = Login.UserCode;
                exporter.CompanyId   = CompanyId;
                exporter.CompanyCode = Login.CompanyCode;

                ProgressDialog.Start(ParentForm, (cancel, progress) =>
                {
                    return(exporter.ExportAsync(filePath, list, cancel, progress));
                }, true, SessionKey);

                if (exporter.Exception != null)
                {
                    NLogHandler.WriteErrorLog(this, exporter.Exception, SessionKey);
                    ShowWarningDialog(MsgErrExportError);
                    return;
                }

                DispStatusMessage(MsgInfFinishExport);
                Settings.SavePath <Receipt>(Login, filePath);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                DispStatusMessage(MsgErrExportError);
            }
        }
示例#17
0
        private void Import()
        {
            ClearStatusMessage();
            try
            {
                ImportSetting importSetting = null;
                var           task          = Util.GetMasterImportSettingAsync(Login, ImportFileType.Staff);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;
                if (importSetting == null)
                {
                    return;
                }

                var definition = new StaffFileDefinition(new DataExpression(ApplicationControl));

                definition.MailField.Required = UseDistribution;

                definition.DepartmentIdField.GetModelsByCode = val =>
                {
                    Dictionary <string, Department> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var departmentMaster     = factory.Create <DepartmentMasterClient>();
                        DepartmentsResult result = departmentMaster.GetByCode(SessionKey, CompanyId, val);

                        if (result.ProcessResult.Result)
                        {
                            product = result.Departments.ToDictionary(c => c.Code);
                        }
                    });
                    return(product ?? new Dictionary <string, Department>());
                };

                //その他
                definition.StaffCodeField.ValidateAdditional = (val, param) =>
                {
                    var reports = new List <WorkingReport>();
                    if (((ImportMethod)param) != ImportMethod.Replace)
                    {
                        return(reports);
                    }

                    var codes = val.Values.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).Distinct().ToArray();
                    MasterDatasResult resultlogin = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var staffMaster = factory.Create <StaffMasterClient>();
                        resultlogin     = staffMaster.GetImportItemsLoginUser(SessionKey, CompanyId, codes);
                    });

                    foreach (MasterData ca in resultlogin.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.StaffCodeField.FieldIndex,
                            FieldName = definition.StaffCodeField.FieldName,
                            Message   = $"ログインユーザーマスターに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。",
                        });
                    }

                    MasterDatasResult resultcustomer = null;
                    MasterDatasResult resultbilling  = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var staffMaster = factory.Create <StaffMasterClient>();
                        resultcustomer  = staffMaster.GetImportItemsCustomer(SessionKey, CompanyId, codes);
                        resultbilling   = staffMaster.GetImportItemsBilling(SessionKey, CompanyId, codes);
                    });
                    foreach (MasterData ca in resultcustomer.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.StaffCodeField.FieldIndex,
                            FieldName = definition.StaffCodeField.FieldName,
                            Message   = $"得意先マスターに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。",
                        });
                    }
                    foreach (MasterData ca in resultbilling.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.StaffCodeField.FieldIndex,
                            FieldName = definition.StaffCodeField.FieldName,
                            Message   = $"請求データに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。",
                        });
                    }

                    return(reports);
                };
                var importer = definition.CreateImporter(m => m.Code);
                importer.UserId      = Login.UserId;
                importer.UserCode    = Login.UserCode;
                importer.CompanyId   = CompanyId;
                importer.CompanyCode = Login.CompanyCode;
                importer.LoadAsync   = async() => await LoadListAsync();

                importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork);

                var importResult = DoImport(importer, importSetting, Clear);
                if (!importResult)
                {
                    return;
                }
                StaffProgress.Clear();
                Task <List <Staff> > loadTask = LoadListAsync();
                ProgressDialog.Start(ParentForm, loadTask, false, SessionKey);
                StaffProgress.AddRange(loadTask.Result);
                grdStaff.DataSource = new BindingSource(StaffProgress, null);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }
示例#18
0
 private async Task GetCommonSettingAsync()
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result    = await client.GetReminderCommonSettingAsync(SessionKey, CompanyId);
     CommonSetting = result.ReminderCommonSetting ?? new ReminderCommonSetting();
 });
示例#19
0
        /// <summary>
        /// This is the entry point of the service host process.
        /// </summary>
        private static void Main()
        {
            try
            {
                // The ServiceManifest.XML file defines one or more service type names.
                // Registering a service maps a service type name to a .NET type.
                // When Service Fabric creates an instance of this service type,
                // an instance of the class is created in this host process.

                // Start with the trusty old container builder.
                var builder = new ContainerBuilder();

                // Register any regular dependencies.


                var config = new ESFA.DC.Logging.ApplicationLoggerSettings();
                config.LoggerOutput = ESFA.DC.Logging.Enums.LogOutputDestination.SqlServer;
                builder.RegisterType <ESFA.DC.Logging.SeriLogging.SeriLogger>().As <ESFA.DC.Logging.ILogger>()
                .WithParameter(new TypedParameter(typeof(ESFA.DC.Logging.ApplicationLoggerSettings), config))
                .InstancePerLifetimeScope();

                //get the config values and register in container
                var fundingActorOptions =
                    ConfigurationHelper.GetSectionValues <ActorOptions>("FundingActorsSection");
                builder.RegisterInstance(fundingActorOptions).As <ActorOptions>().SingleInstance();

                var dataServiceOptions =
                    ConfigurationHelper.GetSectionValues <DataServiceOptions>("DataServiceSection");
                builder.RegisterInstance(dataServiceOptions).As <DataServiceOptions>().SingleInstance();

                builder.RegisterInstance(new ActorsHelper()).As <IActorsHelper>();


                //store proxy factory in container
                var serviceProxyFactory = new ServiceProxyFactory(
                    (c) => new FabricTransportServiceRemotingClientFactory(
                        remotingSettings: FabricTransportRemotingSettings.LoadFrom("DataTransportSettings"),
                        remotingCallbackMessageHandler: null, servicePartitionResolver: null, exceptionHandlers: null,
                        traceId: null,
                        serializationProvider: new ServiceRemotingJsonSerializationProvider()));

                builder.RegisterInstance(serviceProxyFactory).As <ServiceProxyFactory>().SingleInstance();

                builder.RegisterType <FundingCalcManager>().As <IFundingCalcManager>().InstancePerLifetimeScope();


                // Register the Autofac magic for Service Fabric support.
                builder.RegisterServiceFabricSupport();
                // Register the stateless service.
                builder.RegisterStatelessService <FundingCalcService>("DCT.ILR.FundingCalcServiceType");

                builder.Register(c =>
                {
                    var ctx = c.Resolve <StatelessServiceContext>();
                    return(ctx.CodePackageActivationContext.ApplicationName);
                }).Named <string>("ApplicationName");

                //ServiceRuntime.RegisterServiceAsync("DCT.ILR.VadationServiceStatefulType",
                //    context => new VadationServiceStateful(context)).GetAwaiter().GetResult();

                //ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(VadationServiceStateful).Name);

                using (var container = builder.Build())
                {
                    using (var childlifetime = container.BeginLifetimeScope())
                    {
                        var s = childlifetime.Resolve <IFundingCalcManager>();
                    }

                    //var logger = container.Resolve<ESFA.DC.Logging.ILogger>();
                    ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(FundingCalcService).Name);

                    // Prevents this host process from terminating so services keep running.
                    Thread.Sleep(Timeout.Infinite);
                }
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
示例#20
0
 private async Task <CountResult> DeleteTemplateSettingAsync(int templateId)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.DeleteReminderTemplateSettingAsync(SessionKey, templateId);
     return(result);
 });
示例#21
0
 private async Task <bool> SaveAsync(WebApiSetting setting)
 => ((await ServiceProxyFactory.DoAsync(async(WebApiSettingMasterClient client)
                                        => await client.SaveAsync(SessionKey, setting)))
     ?.ProcessResult.Result ?? false);
示例#22
0
 private async Task <ReminderLevelSettingResult> GetLevelSettingByLevelAsync(int level)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.GetReminderLevelSettingByLevelAsync(SessionKey, CompanyId, level);
     return(result);
 });
示例#23
0
 private async Task <bool> DeleteAsync()
 => ((await ServiceProxyFactory.DoAsync(async(WebApiSettingMasterClient client)
                                        => await client.DeleteAsync(SessionKey, CompanyId, WebApiType.PcaDX)))
     ?.ProcessResult.Result ?? false);
示例#24
0
 private async Task <ReminderLevelSettingResult> SaveLevelSettingAsync(ReminderLevelSetting levelSetting)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.SaveReminderLevelSettingAsync(SessionKey, levelSetting);
     return(result);
 });
示例#25
0
 public StudentsController()
 {
     _actorProxyFactory   = new ActorProxyFactory();
     _serviceProxyFactory = new ServiceProxyFactory();
     _actorServiceUri     = new Uri($@"{FabricRuntime.GetActivationContext().ApplicationName}/{"StudentActorService"}");
 }
示例#26
0
 private async Task GetSummarySettingsAsync()
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var results        = await client.GetReminderSummarySettingsAsync(SessionKey, CompanyId);
     SummarySettingList = results.ReminderSummarySettings;
 });
示例#27
0
        private void Save()
        {
            CurrencyResult  result       = null;
            List <Currency> currencyList = null;

            try
            {
                // 入力項目チェック
                if (!ValidateInput())
                {
                    return;
                }

                if (!ShowConfirmDialog(MsgQstConfirmSave))
                {
                    DispStatusMessage(MsgInfProcessCanceled);
                    return;
                }

                ClearStatusMessage();

                Currency currency = CurrencyInfo();

                var task = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service = factory.Create <CurrencyMasterClient>();

                    result = await service.SaveAsync(SessionKey, currency);
                    if (result.ProcessResult.Result)
                    {
                        currencyList = await LoadListAsync();
                    }
                });
                ProgressDialog.Start(ParentForm, task, false, SessionKey);

                if (result.ProcessResult.Result)
                {
                    if (result.Currency != null)
                    {
                        Clear();
                        DispStatusMessage(MsgInfSaveSuccess);
                    }
                    else
                    {
                        ShowWarningDialog(MsgErrSaveError);
                    }

                    CurrencyList.Clear();
                    CurrencyList.AddRange(currencyList);
                }

                if (currencyList != null)
                {
                    grdCurrencyMaster.DataSource = new BindingSource(CurrencyList, null);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
示例#28
0
 private async Task <ReminderSummarySettingsResult> SaveSummarySettingAsync(List <ReminderSummarySetting> summarySettings)
 => await ServiceProxyFactory.DoAsync(async (ReminderSettingServiceClient client) =>
 {
     var result = await client.SaveReminderSummarySettingAsync(SessionKey, summarySettings.ToArray());
     return(result);
 });
示例#29
0
        private void Import()
        {
            ClearStatusMessage();
            try
            {
                ImportSetting importSetting = null;
                var           task          = Util.GetMasterImportSettingAsync(Login, ImportFileType.Currency);

                // 取込設定取得
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;

                var definition = new CurrencyFileDefinition(new DataExpression(ApplicationControl));

                //その他
                definition.CurrencyCodeField.ValidateAdditional = (val, param) =>
                {
                    var reports = new List <WorkingReport>();
                    if (((ImportMethod)param) != ImportMethod.Replace)
                    {
                        return(reports);
                    }

                    MasterDatasResult billResult    = null;
                    MasterDatasResult receiptResult = null;
                    MasterDatasResult nettingResult = null;

                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var currencyMaster = factory.Create <CurrencyMasterClient>();
                        var codes          = val.Values.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).Distinct().ToArray();

                        billResult    = currencyMaster.GetImportItemsBilling(SessionKey, CompanyId, codes);
                        receiptResult = currencyMaster.GetImportItemsReceipt(SessionKey, CompanyId, codes);
                        nettingResult = currencyMaster.GetImportItemsNetting(SessionKey, CompanyId, codes);
                    });

                    foreach (MasterData ca in billResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.CurrencyCodeField.FieldIndex,
                            FieldName = definition.CurrencyCodeField.FieldName,
                            Message   = $"請求データに存在する{ca.Code}が存在しないため、インポートできません。",
                        });
                    }

                    foreach (var ca in receiptResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.CurrencyCodeField.FieldIndex,
                            FieldName = definition.CurrencyCodeField.FieldName,
                            Message   = $"入金データに存在する{ca.Code}が存在しないため、インポートできません。",
                        });
                    }

                    foreach (var ca in nettingResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code)))
                    {
                        reports.Add(new WorkingReport
                        {
                            LineNo    = null,
                            FieldNo   = definition.CurrencyCodeField.FieldIndex,
                            FieldName = definition.CurrencyCodeField.FieldName,
                            Message   = $"入金予定相殺データに存在する{ca.Code}が存在しないため、インポートできません。",
                        });
                    }

                    return(reports);
                };

                definition.CurrencyToleranceField.ValidateAdditional = (val, param) =>
                {
                    var reports = new List <WorkingReport>();
                    foreach (var pair in val)
                    {
                        if (pair.Value.Precision < 0)
                        {
                            continue;
                        }
                        var significant = (pair.Value.Tolerance * Amount.Pow10(pair.Value.Precision));

                        if (Math.Floor(significant) != significant)
                        {
                            reports.Add(new WorkingReport
                            {
                                LineNo    = pair.Key,
                                FieldNo   = definition.CurrencyToleranceField.FieldIndex,
                                FieldName = definition.CurrencyToleranceField.FieldName,
                                Message   = $"手数料誤差金額は小数点以下{pair.Value.Precision}桁までとなるよう入力してください。",
                            });
                        }
                    }
                    return(reports);
                };

                var importer = definition.CreateImporter(m => m.Code);
                importer.UserId      = Login.UserId;
                importer.UserCode    = Login.UserCode;
                importer.CompanyId   = Login.CompanyId;
                importer.CompanyCode = Login.CompanyCode;
                importer.LoadAsync   = async() => await LoadListAsync();

                importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork);

                var importResult = DoImport(importer, importSetting, Clear);
                if (!importResult)
                {
                    return;
                }
                CurrencyList.Clear();
                var loadListTask = LoadListAsync();
                ProgressDialog.Start(ParentForm, loadListTask, false, SessionKey);
                CurrencyList.AddRange(loadListTask.Result);
                grdCurrencyMaster.DataSource = new BindingSource(CurrencyList, null);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }
示例#30
0
        private void ExportAccountTitle()
        {
            try
            {
                ClearStatusMessage();
                List <AccountTitle> list = null;
                var listTask             = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var accountTitleMaster     = factory.Create <AccountTitleMasterClient>();
                    AccountTitlesResult result = await accountTitleMaster.GetItemsAsync(
                        SessionKey, new AccountTitleSearch {
                        CompanyId = CompanyId
                    });

                    if (result.ProcessResult.Result)
                    {
                        list = result.AccountTitles;
                    }
                });

                var pathTask = Util.GetGeneralSettingServerPathAsync(Login);
                ProgressDialog.Start(ParentForm, Task.WhenAll(listTask, pathTask), false, SessionKey);
                var serverPath = pathTask.Result;

                if (!list.Any())
                {
                    ShowWarningDialog(MsgWngNoExportData);
                    return;
                }

                if (!Directory.Exists(serverPath))
                {
                    serverPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                }

                var filePath = string.Empty;
                var fileName = $"科目マスター{DateTime.Today:yyyyMMdd}.csv";
                if (!ShowSaveExportFileDialog(serverPath, fileName, out filePath))
                {
                    return;
                }

                var definition = new AccountTitleFileDefinition(new DataExpression(ApplicationControl));
                var exporter   = definition.CreateExporter();
                exporter.UserId      = Login.UserId;
                exporter.UserCode    = Login.UserCode;
                exporter.CompanyId   = CompanyId;
                exporter.CompanyCode = Login.CompanyCode;

                ProgressDialog.Start(ParentForm, (cancel, progress) =>
                {
                    return(exporter.ExportAsync(filePath, list, cancel, progress));
                }, true, SessionKey);

                if (exporter.Exception != null)
                {
                    NLogHandler.WriteErrorLog(this, exporter.Exception, SessionKey);
                    ShowWarningDialog(MsgErrExportError);
                    return;
                }

                DispStatusMessage(MsgInfFinishExport);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                DispStatusMessage(MsgErrExportError);
            }
        }
示例#31
0
        private void DeleteCurrency()
        {
            var         currencyCode = txtCurrencyCode.Text;
            ExistResult resultBill   = null;
            ExistResult resultRec    = null;
            ExistResult resultNet    = null;

            //MessageInfo msg = null;
            System.Action messaging = null;
            var           checkTask = ServiceProxyFactory.LifeTime(async factory =>
            {
                var serviceBill    = factory.Create <BillingServiceClient>();
                var serviceRec     = factory.Create <ReceiptServiceClient>();
                var serviceNetting = factory.Create <NettingServiceClient>();

                resultBill = await serviceBill.ExistCurrencyAsync(SessionKey, CurrencyID);
                if (resultBill.Exist)
                {
                    messaging = () => ShowWarningDialog(MsgWngDeleteConstraint, "請求テーブル", "通貨コード");
                    return;
                }
                resultRec = await serviceRec.ExistCurrencyAsync(SessionKey, CurrencyID);
                if (resultRec.Exist)
                {
                    messaging = () => ShowWarningDialog(MsgWngDeleteConstraint, "入金テーブル", "通貨コード");
                    return;
                }
                resultNet = await serviceNetting.ExistCurrencyAsync(SessionKey, CurrencyID);
                if (resultNet.Exist)
                {
                    messaging = () => ShowWarningDialog(MsgWngDeleteConstraint, "入金予定相殺テーブル", "通貨コード");
                    return;
                }
            });

            ProgressDialog.Start(ParentForm, checkTask, false, SessionKey);

            if (messaging != null)
            {
                messaging.Invoke();
                return;
            }

            // Show Confirm
            if (!ShowConfirmDialog(MsgQstConfirmDelete))
            {
                DispStatusMessage(MsgInfProcessCanceled);
                return;
            }

            CountResult deleteResult = null;

            CurrentCurrency = CurrencyList.Find(b => (b.Code == currencyCode));

            var task = ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <CurrencyMasterClient>();

                deleteResult = await service.DeleteAsync(SessionKey, CurrentCurrency.Id);
            });

            ProgressDialog.Start(ParentForm, task, false, SessionKey);

            if (deleteResult.Count > 0)
            {
                CurrencyList.Remove(CurrentCurrency);
                grdCurrencyMaster.DataSource = new BindingSource(CurrencyList, null);
                Clear();
                DispStatusMessage(MsgInfDeleteSuccess);
            }
            else
            {
                ShowWarningDialog(MsgErrDeleteError);
            }
        }