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); }
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); }
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); }
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); }
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); }
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); }
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); }
public bool DepartmentCode(ForeignKeyFieldDefinition <TModel, int, Department> def) { return(ResolveCode(def)); }
public bool CategoryCode(ForeignKeyFieldDefinition <TModel, int, Category> def) { return(ResolveCode(def)); }
public bool AccountTitleCode(ForeignKeyFieldDefinition <TModel, int, AccountTitle> def) { return(ResolveCode(def)); }
public bool OwnCompanyCode(ForeignKeyFieldDefinition <TModel, int, Company> def) { return(true); }
public bool OwnCompanyCode(ForeignKeyFieldDefinition <TModel, int, Company> def) { SetField(def.FieldIndex - 1, LoginCompanyCode); return(true); }
public bool LessThanCollectCategoryId(ForeignKeyFieldDefinition <TModel, int, Category> def) { return(ResolveId(def)); }
public bool LoginUserCodeField(ForeignKeyFieldDefinition <TModel, int, LoginUser> def) { return(ResolveCode(def)); }
public bool CustomerCodeForDiscount(ForeignKeyFieldDefinition <TModel, int, Customer> def) { return(true); }
//47 public bool GreaterThanCollectCategoryId3(ForeignKeyFieldDefinition <TModel, int, Category> def) { return(true); }
public bool SectionCode(ForeignKeyFieldDefinition <TModel, int, Section> def) { return(true); }
public bool PaymentAgencyCode(ForeignKeyFieldDefinition <TModel, int, PaymentAgency> def) { return(ResolveCode(def)); }
public bool CustomerCode(ForeignKeyFieldDefinition <TModel, int, Customer> def) { return(ResolveCode(def)); }
public bool CollectCategoryCode(ForeignKeyFieldDefinition <TModel, int, Category> def) { return(true); }
//PE0102 public bool CurrencyCode(ForeignKeyFieldDefinition <TModel, int, Currency> def) { return(ResolveCode(def)); }
public bool CurrencyCodeForFee(ForeignKeyFieldDefinition <TModel, int, Currency> def, int foreignflg) { return(true); }
public bool SectionCode(ForeignKeyFieldDefinition <TModel, int, Section> def) { return(ResolveCode(def)); }
public bool GreaterThanCollectCategoryId2(ForeignKeyFieldDefinition <TModel, int, Category> def) { return(ResolveCode(def)); }
public bool StaffCode(ForeignKeyFieldDefinition <TModel, int, Staff> def) { return(ResolveId(def)); }