Exemple #1
0
 /// <summary>
 /// 獲取客戶資料
 /// </summary>
 /// <param name="model"></param>
 /// <param name="bizCustomerSet"></param>
 /// <param name="customerSet"></param>
 private void GetCustomerInfo(ACCFTT model, BizCustomerRepository bizCustRepo, CustomerRepository custRepo, CustUserRepository custUserRepo, out BizCustomerSet bizCustomerSet, out CustomerSet customerSet, out CustUserSet custUserSet)
 {
     bizCustomerSet = bizCustRepo.QueryData(new object[] { model.KEYNO });
     customerSet    = custRepo.QueryData(new object[] { model.IDCODE.TrimStart('0') });
     custUserSet    = custUserRepo.QueryData(new object[] { $"{model.IDCODE.TrimStart('0')},admin" });
 }
Exemple #2
0
        /// <summary>
        /// 導入商戶資料
        /// </summary>
        /// <param name="modelSources"></param>
        void IImportData.CreateData(IList modelSources)
        {
            List <ACCFTT> srcs = modelSources as List <ACCFTT>;

            if (null == srcs)
            {
                return;
            }
            using BizCustomerRepository bizCustRepo = new BizCustomerRepository(DataAccess)
                  {
                      Message = Message, User = SystemOperator.SysOperator
                  };
            using CustomerRepository custRepo = new CustomerRepository(DataAccess)
                  {
                      Message = Message, User = SystemOperator.SysOperator
                  };
            using CustUserRepository custUserRepo = new CustUserRepository(DataAccess)
                  {
                      Message = Message, User = SystemOperator.SysOperator
                  };
            foreach (ACCFTT model in srcs)
            {
                Message.Prefix = $"第{model.Id}行:";
                switch (model.APPLYSTAT.ToInt32())
                {
                case 0:
                {
                    DataAccess.Database.BeginTransaction();
                    try
                    {
                        GetCustomerInfo(model, bizCustRepo, custRepo, custUserRepo, out BizCustomerSet bizCustomerSet, out CustomerSet customerSet, out CustUserSet custUserSet);
                        if (customerSet is null)
                        {
                            custRepo.Create(BizACCFTT.SetCustomer(model, customerSet));
                        }
                        else
                        {
                            custRepo.Update(null, BizACCFTT.SetCustomer(model, customerSet));
                        }
                        custRepo.CommitData(FuncAction.Create);
                        if (bizCustomerSet is null)
                        {
                            bizCustRepo.Create(BizACCFTT.SetBizCustomer(model, bizCustomerSet));
                        }
                        else
                        {
                            bizCustRepo.Update(null, BizACCFTT.SetBizCustomer(model, bizCustomerSet));
                        }
                        bizCustRepo.CommitData(FuncAction.Create);
                        if (custUserSet is null)
                        {
                            custUserRepo.Create(BizACCFTT.AddAdminAccount(model));
                            custUserRepo.CommitData(FuncAction.Create);
                        }
                        DataAccess.Database.CommitTransaction();
                    }
                    catch
                    {
                        DataAccess.Database.RollbackTransaction();
                        throw;
                    }
                }
                break;

                case 1:
                case 9:
                    UnableBizCustomer(model.KEYNO);
                    break;
                }
            }
        }