コード例 #1
0
        private ComboBoxCell CreateDatabindingComboBoxCell(ComboBoxCell comboBoxCell)
        {
            CategoriesResult result         = null;
            CategorySearch   categorySearch = new CategorySearch();

            categorySearch.CompanyId    = CompanyId;
            categorySearch.CategoryType = 4;

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

                result = await service.GetItemsAsync(SessionKey, categorySearch);
            });

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

            if (result.ProcessResult.Result)
            {
                CategoryList = result.Categories;

                comboBoxCell.DataSource    = new BindingSource(CategoryList, null);
                comboBoxCell.DisplayMember = nameof(Category.Name);
                comboBoxCell.ValueMember   = nameof(Category.Id);
            }

            return(comboBoxCell);
        }
コード例 #2
0
        /// <summary> 入金区分設定 </summary>
        private async Task LoadNyuukinCategoryCombo()
        {
            CategoriesResult result = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <CategoryMasterClient>();
                result      = await service.GetByCodeAsync(SessionKey,
                                                           CompanyId, CategoryType.Receipt, new string[] { }
                                                           );
            });

            if (result.ProcessResult.Result)
            {
                CategoryList = result.Categories;
                if (CategoryList != null)
                {
                    cmbNyukinKubun.Items.Add(new ListItem("すべて", 0));
                    foreach (var category in CategoryList)
                    {
                        cmbNyukinKubun.Items.Add(new ListItem(category.Code + " : " + category.Name, category.Id));
                    }
                    cmbNyukinKubun.SelectedIndex = 0;
                }
            }
        }
コード例 #3
0
        private void Import()
        {
            ClearStatusMessage();
            try
            {
                ImportSetting importSetting = null;
                var           task          = Util.GetMasterImportSettingAsync(Login, ImportFileType.IgnoreKana);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;

                var definition = new IgnoreKanaFileDefinition(new DataExpression(ApplicationControl));
                definition.ExcludeCategoryIdField.GetModelsByCode = val =>
                {
                    CategoriesResult result = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var categoryMaster = factory.Create <CategoryMasterClient>();
                        result             = categoryMaster.GetByCode(SessionKey, CompanyId, ExcludeCategoryType, val);
                    });
                    if (result.ProcessResult.Result)
                    {
                        return(result.Categories
                               .ToDictionary(c => c.Code));
                    }
                    return(new Dictionary <string, Category>());
                };

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

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

                var importResult = DoImport(importer, importSetting);
                if (!importResult)
                {
                    return;
                }
                IgnoreKanaList.Clear();
                Task <List <IgnoreKana> > loadTask = GetListAsync();
                Clear(true, false);
                ProgressDialog.Start(ParentForm, loadTask, false, SessionKey);
                IgnoreKanaList.AddRange(loadTask.Result);

                grdExcludeKanaList.DataSource = new BindingSource(IgnoreKanaList, null);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }
コード例 #4
0
        private void txtCategoryCode_Validated(object sender, EventArgs e)
        {
            try
            {
                ClearStatusMessage();

                var categoryType = 2; // 入金区分
                var categoryCode = txtCategoryCode.Text;

                if (string.IsNullOrEmpty(categoryCode) ||
                    string.IsNullOrWhiteSpace(categoryCode))
                {
                    lblCategoryName.Clear();
                    ReceiptCategoryId = null;
                    return;
                }

                Category category = null;
                var      task     = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service             = factory.Create <CategoryMasterClient>();
                    CategoriesResult result = await service.GetByCodeAsync(
                        Login.SessionKey,
                        Login.CompanyId,
                        categoryType, new string[] { categoryCode });

                    if (result.ProcessResult.Result && result.Categories.Any())
                    {
                        category = result.Categories[0];
                    }
                });
                ProgressDialog.Start(ParentForm, task, false, SessionKey);

                if (category != null)
                {
                    txtCategoryCode.Text = category.Code;
                    lblCategoryName.Text = category.Name;
                    ReceiptCategoryId    = category.Id;
                }
                else
                {
                    txtCategoryCode.Clear();
                    lblCategoryName.Clear();
                    ReceiptCategoryId = null;
                    ShowWarningDialog(MsgWngMasterNotExist, "入金区分", categoryCode);
                    txtCategoryCode.Focus();
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
コード例 #5
0
        private static async Task <List <Category> > GetCategoryListAsync(string sessionKey, int companyId, int categoryType)
        {
            CategoriesResult result = null;

            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var client = factory.Create <CategoryMasterService.CategoryMasterClient>();
                result     = await client.GetByCodeAsync(sessionKey, companyId, categoryType, null);
            });

            if (result == null || result.ProcessResult.Result == false)
            {
                return(null);
            }

            return(result.Categories);
        }
コード例 #6
0
        private void txtExcludeCategoryCode_Validated(object sender, EventArgs e)
        {
            try
            {
                Category result = null;
                if (string.IsNullOrEmpty(txtExcludeCategoryCode.Text))
                {
                    SetCategory(null);
                    ClearStatusMessage();
                    return;
                }

                Task task = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service          = factory.Create <CategoryMasterClient>();
                    CategoriesResult res = await service.GetByCodeAsync(SessionKey, CompanyId,
                                                                        ExcludeCategoryType, new[] { txtExcludeCategoryCode.Text });

                    if (res.ProcessResult.Result)
                    {
                        result = res.Categories.FirstOrDefault();
                    }
                });
                ProgressDialog.Start(ParentForm, task, false, SessionKey);

                if (result == null)
                {
                    ShowWarningDialog(MsgWngMasterNotExist, "対象外区分", txtExcludeCategoryCode.Text);
                    txtExcludeCategoryCode.Clear();
                    lblExcludeCategoryName.Clear();
                    txtExcludeCategoryCode.Focus();
                }
                else
                {
                    ClearStatusMessage();
                    SetCategory(result);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
コード例 #7
0
        /// <summary>Set Category Items When CategoryCode Cell Leave</summary>
        /// <param name="index"> Row Index of CategoryCode Cell</param>
        private void SetCategoryItems(int index)
        {
            if (index >= 0)
            {
                string code = Convert.ToString(grdNettingInput.Rows[index]["celCategoryCode"].EditedFormattedValue);

                if (code != "")
                {
                    code = code.PadLeft(2, '0');
                    grdNettingInput.Rows[index]["celCategoryCode"].Value = code;
                }

                UseLimitDate = 0;

                CategoriesResult result = null;
                var task = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service = factory.Create <CategoryMasterClient>();
                    result      = await service.GetByCodeAsync(SessionKey, CompanyId, 2, new[] { code });
                });

                ProgressDialog.Start(ParentForm, Task.Run(() => task), false, SessionKey);
                if (result.ProcessResult.Result && result.Categories != null && result.Categories.Any())
                {
                    UseLimitDate = result.Categories[0].UseLimitDate;
                    grdNettingInput.Rows[index]["celCategoryCode"].Value     = result.Categories[0].Code;
                    grdNettingInput.Rows[index]["celCategoryCodeName"].Value = result.Categories[0].Code + ":" + result.Categories[0].Name;
                    grdNettingInput.Rows[index]["celId"].Value           = result.Categories[0].Id;
                    grdNettingInput.Rows[index]["celUseLimitDate"].Value = result.Categories[0].UseLimitDate;
                }
                else
                {
                    grdNettingInput.Rows[index]["celId"].Value               = "";
                    grdNettingInput.Rows[index]["celCategoryCode"].Value     = "";
                    grdNettingInput.Rows[index]["celCategoryCodeName"].Value = "";
                    grdNettingInput.Rows[index]["celUseLimitDate"].Value     = "";
                }
            }
            if (UseLimitDate != 1)
            {
                grdNettingInput.Rows[index]["celDueAt"].Value = null;
            }
        }
コード例 #8
0
        /// <summary> 請求区分設定 </summary>
        private async Task LoadBillingCategoryCombo()
        {
            CategoriesResult result = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <CategoryMasterClient>();
                result      = await service.GetByCodeAsync(SessionKey, CompanyId, 1, new string[] { });
            });

            if (result.ProcessResult.Result)
            {
                CategoryList = result.Categories;
                cmbSeikyuKubun.Items.Add(new ListItem("すべて", 0));
                for (int i = 0; i < CategoryList.Count(); i++)
                {
                    cmbSeikyuKubun.Items.Add(new ListItem(CategoryList[i].Code + " : " + CategoryList[i].Name, CategoryList[i].Id));
                }
                cmbSeikyuKubun.SelectedIndex = 0;
            }
        }
コード例 #9
0
ファイル: CategoriesViewModel.cs プロジェクト: sevenate/nfm
        /// <summary>
        /// Download all categories for specific user.
        /// </summary>
        /// <returns>Operation result.</returns>
        public IEnumerable <IResult> LoadAllCategories()
        {
            yield return(Show.Busy(new BusyScreen {
                Message = "Loading..."
            }));

            var request = new CategoriesResult(userId);

            yield return(request);

            Categories.Clear();
            Categories.AddRange(request.Categories);

            if (Reloaded != null)
            {
                Reloaded(this, EventArgs.Empty);
            }

            yield return(Show.NotBusy());
        }
コード例 #10
0
ファイル: CategoryGridLoader.cs プロジェクト: fwka1605/next
        public async Task <IEnumerable <Category> > SearchInfo()
        {
            List <Category> list = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service             = factory.Create <CategoryMasterClient>();
                CategoriesResult result = await service.GetItemsAsync(Application.Login.SessionKey,
                                                                      CategorySearch);

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

            if (CategorySearch.SearchPredicate != null)
            {
                list = list.Where(x => CategorySearch.SearchPredicate(x)).ToList();
            }
            return(list);
        }
コード例 #11
0
        public void getCategoryList()
        {
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = baseUrl;
            var response = httpClient.GetAsync("api/category-type/2").Result;

            if (response.IsSuccessStatusCode)
            {
                var                      result      = response.Content.ReadAsStringAsync().Result;
                JObject                  obj         = JObject.Parse(result);
                IList <JToken>           cateresults = obj["results"].Children().ToList();
                IList <CategoriesResult> cateResults = new List <CategoriesResult>();
                foreach (JToken item in cateresults)
                {
                    CategoriesResult searchResult = JsonConvert.DeserializeObject <CategoriesResult>(item.ToString());
                    cateResults.Add(searchResult);
                    Console.WriteLine(searchResult);
                }
                cateFilter.DataSource    = cateResults;
                cateFilter.DisplayMember = "name";
                cateFilter.ValueMember   = "id";
            }
        }
コード例 #12
0
        private void Import()
        {
            try
            {
                ImportSetting importSetting = null;
                var           task          = Util.GetMasterImportSettingAsync(Login, ImportFileType.BankAccount);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;

                var definition = new BankAccountFileDefinition(new DataExpression(ApplicationControl));
                definition.CategoryIdField.GetModelsByCode = val =>
                {
                    Dictionary <string, Category> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var categoryMaster      = factory.Create <CategoryMasterClient>();
                        CategoriesResult result = categoryMaster.GetByCode(
                            Login.SessionKey, Login.CompanyId, 2, val);
                        if (result.ProcessResult.Result)
                        {
                            product = result.Categories
                                      .ToDictionary(c => c.Code);
                        }
                    });
                    return(product ?? new Dictionary <string, Category>());
                };
                definition.SectionIdField.Ignored         = !UseSection;
                definition.SectionIdField.GetModelsByCode = val =>
                {
                    Dictionary <string, Section> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var sectionMaster     = factory.Create <SectionMasterClient>();
                        SectionsResult result = sectionMaster.GetByCode(
                            Login.SessionKey, Login.CompanyId, val);
                        if (result.ProcessResult.Result)
                        {
                            product = result.Sections
                                      .ToDictionary(c => c.Code);
                        }
                    });
                    return(product ?? new Dictionary <string, Section>());
                };

                var importer = definition.CreateImporter(m => new
                {
                    m.BankCode,
                    m.BranchCode,
                    m.AccountTypeId,
                    m.AccountNumber
                });
                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, ClearAll);
                if (!importResult)
                {
                    return;
                }

                BankAccountList.Clear();
                Task <List <BankAccount> > loadListTask = LoadListAsync();
                ProgressDialog.Start(ParentForm, loadListTask, false, SessionKey);
                BankAccountList.AddRange(loadListTask.Result);
                grdBankAccount.DataSource = new BindingSource(BankAccountList, null);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }
コード例 #13
0
        private void ExportCustomer(CustomerSearch customerData)
        {
            List <Customer> list       = null;
            string          serverPath = null;

            var task = ServiceProxyFactory.LifeTime(async factory =>
            {
                var service            = factory.Create <CustomerMasterClient>();
                CustomersResult result = await service.GetItemsAsync(SessionKey, CompanyId, customerData);

                if (result.ProcessResult.Result)
                {
                    list = result.Customers;
                }
            });
            Task <string> pathTask = GetServerPath();

            ProgressDialog.Start(ParentForm, Task.WhenAll(task, pathTask), false, SessionKey);
            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 CustomerFileDefinition(new DataExpression(ApplicationControl));

            definition.ExcludeInvoicePublishField.Ignored  = !UsePublishInvoice;
            definition.ExcludeReminderPublishField.Ignored = !UseReminder;
            var exporter = definition.CreateExporter();

            exporter.UserId      = Login.UserId;
            exporter.UserCode    = Login.UserCode;
            exporter.CompanyId   = CompanyId;
            exporter.CompanyCode = Login.CompanyCode;

            Func <int[], Dictionary <int, Category> > getter = ids =>
            {
                Dictionary <int, Category> product = null;
                ServiceProxyFactory.LifeTime(factory =>
                {
                    var categoryservice     = factory.Create <CategoryMasterClient>();
                    CategoriesResult result = categoryservice.Get(SessionKey, ids);
                    if (result.ProcessResult.Result)
                    {
                        product = result.Categories.ToDictionary(c => c.Id);
                    }
                });
                return(product ?? new Dictionary <int, Category>());
            };

            definition.CollectCategoryIdField.GetModelsById             = getter;
            definition.LessThanCollectCategoryIdField.GetModelsById     = getter;
            definition.GreaterThanCollectCategoryId3Field.GetModelsById = getter;
            definition.GreaterThanCollectCategoryId2Field.GetModelsById = getter;
            definition.GreaterThanCollectCategoryId1Field.GetModelsById = getter;

            NLogHandler.WriteDebug(this, "得意先マスター 出力開始");
            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;
            }

            NLogHandler.WriteDebug(this, "得意先マスター 出力終了");

            DispStatusMessage(MsgInfFinishExport);
            Settings.SavePath <Customer>(Login, filePath);
        }
コード例 #14
0
        private void OutputNewCustomer()
        {
            try
            {
                List <Customer> list = Importer.GetNewCustomers();
                if (!list.Any())
                {
                    return;
                }

                var serverPath = string.Empty;
                ProgressDialog.Start(ParentForm, Task.Run(() =>
                {
                    serverPath = Util.GetGeneralSettingServerPathAsync(Login).Result;
                }), false, SessionKey);

                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 CustomerFileDefinition(new DataExpression(ApplicationControl));
                var exporter   = definition.CreateExporter();
                exporter.UserId      = Login.UserId;
                exporter.UserCode    = Login.UserCode;
                exporter.CompanyId   = CompanyId;
                exporter.CompanyCode = Login.CompanyCode;

                Func <int[], Dictionary <int, Category> > getter = ids =>
                {
                    Dictionary <int, Category> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var categoryservice     = factory.Create <CategoryMasterClient>();
                        CategoriesResult result = categoryservice.Get(SessionKey, ids);
                        if (result.ProcessResult.Result)
                        {
                            product = result.Categories.ToDictionary(c => c.Id);
                        }
                    });
                    return(product ?? new Dictionary <int, Category>());
                };
                definition.CollectCategoryIdField.GetModelsById = getter;

                NLogHandler.WriteDebug(this, "新規得意先 出力開始");
                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;
                }

                NLogHandler.WriteDebug(this, "新規得意先 出力終了");

                DispStatusMessage(MsgInfFinishExport);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                DispStatusMessage(MsgErrExportError);
            }
        }
コード例 #15
0
 public Category(CategoriesResult categoryResult)
 {
     Label = categoryResult.Label;
     Score = categoryResult.Score;
 }