Beispiel #1
0
        public bool LoginUserCodeField(ForeignKeyFieldDefinition <TModel, int, LoginUser> def)
        {
            IEnumerable <WorkingReport> reports = def.ValidateAdditional?.Invoke(Models, Params);

            if (reports != null && reports.Any())
            {
                Reports.AddRange(reports);
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        private bool ResolveCode <TForeign>(ForeignKeyFieldDefinition <TModel, int, TForeign> def)
        {
            if (def.GetModelsById == null)
            {
                return(true);
            }
            if (!IdResolutionQueue.ContainsKey(def.FieldIndex))
            {
                return(true);
            }

            var queueOfField = IdResolutionQueue[def.FieldIndex]; // 対象の列に対応するIdマッピング待ちモデル
            var keyCodes     = def.GetModelsById(queueOfField.Keys.ToArray());

            def.ForeignModels = keyCodes.Values.ToList();
            var result = true;

            foreach (var queueById in queueOfField) // <id, List<lineNo>>
            {
                var id = queueById.Key;
                if (keyCodes.ContainsKey(id))   // DB有無チェック
                {
                    var foreign = keyCodes[id]; // キーに対応するコード
                    foreach (var lineNo in queueById.Value)
                    {
                        // TODO : コードのタイプに合わせてpadding
                        SetField(lineNo, def.FieldIndex - 1, def.GetForeignCode(foreign));
                    }
                }
                else
                {
                    foreach (var lineNo in queueById.Value)
                    {
                        Reports.Add(new WorkingReport
                        {
                            LineNo    = lineNo,
                            FieldNo   = def.FieldIndex,
                            FieldName = def.FieldName,
                            Value     = id.ToString(),
                            Message   = $"存在しないため、エクスポートできません。",
                        });
                        result = false;
                    }
                }
            }

            return(result);
        }
Beispiel #3
0
        private bool ResolveId <TValue, TForeign>(ForeignKeyFieldDefinition <TModel, TValue, TForeign> def)
            where TValue : struct, IComparable <TValue>
        {
            if (def.GetModelsByCode == null ||
                CodeResolutionQueue == null ||
                !CodeResolutionQueue.ContainsKey(def.FieldIndex))
            {
                return(true);
            }

            var queueOfField = CodeResolutionQueue[def.FieldIndex]; // 対象の列に対応するIdマッピング待ちモデル
            var codeKeys     = def.GetModelsByCode(queueOfField.Keys.ToArray());

            def.ForeignModels = codeKeys.Values.ToList();
            bool result = true;

            foreach (var queueByCode in queueOfField) // <code, List<lineNo>>
            {
                var code = queueByCode.Key;
                if (codeKeys.ContainsKey(code))   // DB有無チェック
                {
                    var foreign = codeKeys[code]; // コードに対応するキー
                    foreach (var lineNo in queueByCode.Value.Where(l => Models.ContainsKey(l)))
                    {
                        def.SetValue(Models[lineNo], def.GetForeignKey(foreign));
                    }
                }
                else
                {
                    foreach (var lineNo in queueByCode.Value)
                    {
                        Reports.Add(new WorkingReport
                        {
                            LineNo    = lineNo,
                            FieldNo   = def.FieldIndex,
                            FieldName = def.FieldName,
                            Value     = code,
                            Message   = $"存在しないため、インポートできません。",
                        });
                        result = false;
                    }
                }
            }

            return(result);
        }
Beispiel #4
0
 public bool GreaterThanCollectCategoryId1(ForeignKeyFieldDefinition <TModel, int, Category> def)
 {
     if (def.ModelHasCode)
     {
         string code = def.GetCode(Model);
         SetField(def.FieldIndex - 1, code);
     }
     else
     {
         var nullable = def as NullableForeignKeyFieldDefinition <TModel, int, Category>;
         if (!def.IsNullable ||
             nullable.GetNullableValue(Model) != null)
         {
             int id = def.GetValue(Model);
             IdResolutionQueue = StoreId(IdResolutionQueue, def, id);
         }
     }
     return(true);
 }
Beispiel #5
0
 public bool CurrencyCodeForFee(ForeignKeyFieldDefinition <TModel, int, Currency> def, int foreignflg)
 {
     if (def.ModelHasCode)
     {
         string code = def.GetCode(Model);
         SetField(def.FieldIndex - 1, code);
     }
     else
     {
         var nullable = def as NullableForeignKeyFieldDefinition <TModel, int, Currency>;
         if (!def.IsNullable ||
             nullable.GetNullableValue(Model) != null)
         {
             int id = def.GetValue(Model);
             IdResolutionQueue = StoreId(IdResolutionQueue, def, id);
         }
     }
     return(true);
 }
Beispiel #6
0
 public bool PaymentAgencyCode(ForeignKeyFieldDefinition <TModel, int, PaymentAgency> def)
 {
     if (def.ModelHasCode)
     {
         string code = def.GetCode(Model);
         //  FieldValues[def.FieldNumber - 1] = $"{code}".PadLeft(2, '0');
         SetField(def.FieldIndex - 1, code?.PadLeft(2, '0'));
     }
     else
     {
         var nullable = def as NullableForeignKeyFieldDefinition <TModel, int, PaymentAgency>;
         if (!def.IsNullable ||
             nullable.GetNullableValue(Model) != null)
         {
             int id = def.GetValue(Model);
             IdResolutionQueue = StoreId(IdResolutionQueue, def, id);
         }
     }
     return(true);
 }
Beispiel #7
0
 public bool CustomerCodeForDiscount(ForeignKeyFieldDefinition <TModel, int, Customer> def)
 {
     if (def.ModelHasCode)
     {
         string code = def.GetCode(Model);
         if (DataExpression.CustomerCodeFormatString == "9")
         {
             code = code?.PadLeft(DataExpression.CustomerCodeLength, '0');
         }
         SetField(def.FieldIndex - 1, code);
     }
     else
     {
         var nullable = def as NullableForeignKeyFieldDefinition <TModel, int, Customer>;
         if (!def.IsNullable ||
             nullable.GetNullableValue(Model) != null)
         {
             int id = def.GetValue(Model);
             IdResolutionQueue = StoreId(IdResolutionQueue, def, id);
         }
     }
     return(true);
 }
Beispiel #8
0
 public bool DepartmentCode(ForeignKeyFieldDefinition <TModel, int, Department> def)
 {
     return(ResolveCode(def));
 }
Beispiel #9
0
 public bool CategoryCode(ForeignKeyFieldDefinition <TModel, int, Category> def)
 {
     return(ResolveCode(def));
 }
Beispiel #10
0
 public bool AccountTitleCode(ForeignKeyFieldDefinition <TModel, int, AccountTitle> def)
 {
     return(ResolveCode(def));
 }
Beispiel #11
0
 public bool OwnCompanyCode(ForeignKeyFieldDefinition <TModel, int, Company> def)
 {
     return(true);
 }
Beispiel #12
0
 public bool OwnCompanyCode(ForeignKeyFieldDefinition <TModel, int, Company> def)
 {
     SetField(def.FieldIndex - 1, LoginCompanyCode);
     return(true);
 }
Beispiel #13
0
 public bool LessThanCollectCategoryId(ForeignKeyFieldDefinition <TModel, int, Category> def)
 {
     return(ResolveId(def));
 }
Beispiel #14
0
 public bool LoginUserCodeField(ForeignKeyFieldDefinition <TModel, int, LoginUser> def)
 {
     return(ResolveCode(def));
 }
Beispiel #15
0
 public bool CustomerCodeForDiscount(ForeignKeyFieldDefinition <TModel, int, Customer> def)
 {
     return(true);
 }
Beispiel #16
0
 //47
 public bool GreaterThanCollectCategoryId3(ForeignKeyFieldDefinition <TModel, int, Category> def)
 {
     return(true);
 }
Beispiel #17
0
 public bool SectionCode(ForeignKeyFieldDefinition <TModel, int, Section> def)
 {
     return(true);
 }
Beispiel #18
0
 public bool PaymentAgencyCode(ForeignKeyFieldDefinition <TModel, int, PaymentAgency> def)
 {
     return(ResolveCode(def));
 }
Beispiel #19
0
 public bool CustomerCode(ForeignKeyFieldDefinition <TModel, int, Customer> def)
 {
     return(ResolveCode(def));
 }
Beispiel #20
0
 public bool CollectCategoryCode(ForeignKeyFieldDefinition <TModel, int, Category> def)
 {
     return(true);
 }
Beispiel #21
0
 //PE0102
 public bool CurrencyCode(ForeignKeyFieldDefinition <TModel, int, Currency> def)
 {
     return(ResolveCode(def));
 }
Beispiel #22
0
 public bool CurrencyCodeForFee(ForeignKeyFieldDefinition <TModel, int, Currency> def, int foreignflg)
 {
     return(true);
 }
Beispiel #23
0
 public bool SectionCode(ForeignKeyFieldDefinition <TModel, int, Section> def)
 {
     return(ResolveCode(def));
 }
Beispiel #24
0
 public bool GreaterThanCollectCategoryId2(ForeignKeyFieldDefinition <TModel, int, Category> def)
 {
     return(ResolveCode(def));
 }
Beispiel #25
0
 public bool StaffCode(ForeignKeyFieldDefinition <TModel, int, Staff> def)
 {
     return(ResolveId(def));
 }