public void LicenseRequest_Can_Seperate_DataRowHeader()
        {
            IAS.DAL.Interfaces.IIASPersonEntities ctx = DAL.DALFactory.GetPersonContext();

            String groupNo = "130923142524097";

            String fileName = "test.csv";

            String[] rowDatas            = _header.Split(',');
            DateTime dateNow             = DateTime.Now;
            String   licenseTypeCode     = GetDataField(rowDatas, 3);
            AG_IAS_APPROVE_DOC_TYPE comp = ctx.AG_IAS_APPROVE_DOC_TYPE.Where(w => w.APPROVE_DOC_TYPE == licenseTypeCode && w.ITEM_VALUE == "Y").FirstOrDefault();

            LicenseFileHeader header = new LicenseFileHeader()
            {
                IMPORT_ID         = Convert.ToInt64(groupNo.Trim()),
                IMPORT_DATETIME   = dateNow,
                FILE_NAME         = fileName,
                PETTITION_TYPE    = _petitionTypeCode,
                LICENSE_TYPE_CODE = GetDataField(rowDatas, 3),
                COMP_CODE         = GetDataField(rowDatas, 1),
                COMP_NAME         = GetDataField(rowDatas, 2),
                LICENSE_TYPE      = GetDataField(rowDatas, 3),
                SEND_DATE         = LicenseFileHelper.PhaseToDate(GetDataField(rowDatas, 4)),
                TOTAL_AGENT       = LicenseFileHelper.PhaseToAmount(GetDataField(rowDatas, 5)),
                TOTAL_FEE         = LicenseFileHelper.PhaseToMoney(GetDataField(rowDatas, 6)),
                ERR_MSG           = "",
                APPROVE_COMPCODE  = comp == null ? null : comp.APPROVER
            };

            Assert.AreEqual(header.IMPORT_ID, 130923142524097);
            Assert.AreEqual(header.IMPORT_DATETIME, dateNow);
            Assert.AreEqual(header.PETTITION_TYPE, _petitionTypeCode);
            Assert.AreEqual(header.LICENSE_TYPE_CODE, "01");
            Assert.AreEqual(header.COMP_CODE, "1023");
            Assert.AreEqual(header.COMP_NAME, "บริษัท ไอเอ็นจีประกันชีวิต จำกัด");
            Assert.AreEqual(header.LICENSE_TYPE, "01");
            Assert.AreEqual(header.SEND_DATE, new DateTime(Convert.ToInt32(2555 - 543), 8, 8));
            Assert.AreEqual(header.TOTAL_AGENT, 10);
            Assert.AreEqual(header.TOTAL_FEE, 3000m);
            Assert.AreEqual(header.ERR_MSG, "");
            Assert.AreEqual(header.APPROVE_COMPCODE, "111");
        }
Пример #2
0
        private static LicenseFileHeader CreateLicenseFileHeader(IAS.DAL.Interfaces.IIASPersonEntities ctx, LicenseFileHeader header, String lineData, CompressFileDetail compress, string approveCom)
        {
            String[] rowDatas        = lineData.Split(',');
            String   licenseTypeCode = GetDataField(rowDatas, 3);


            // AG_IAS_APPROVE_DOC_TYPE comp = ctx.AG_IAS_APPROVE_DOC_TYPE.Where(w => w.APPROVE_DOC_TYPE == licenseTypeCode && w.ITEM_VALUE == "Y").FirstOrDefault();



            header.IMPORT_DATETIME   = DateTime.Now;
            header.LICENSE_TYPE_CODE = licenseTypeCode;
            header.COMP_CODE         = GetDataField(rowDatas, 1);
            header.COMP_NAME         = GetDataField(rowDatas, 2);
            header.LICENSE_TYPE      = licenseTypeCode;
            header.SEND_DATE         = LicenseFileHelper.PhaseToDate(GetDataField(rowDatas, 4));
            header.TOTAL_AGENT       = LicenseFileHelper.PhaseToAmount(GetDataField(rowDatas, 5));
            header.TOTAL_FEE         = LicenseFileHelper.PhaseToMoney(GetDataField(rowDatas, 6));
            header.ERR_MSG           = "";

            if (string.IsNullOrEmpty(approveCom))
            {
                approveCom = null;
            }

            header.APPROVE_COMPCODE = approveCom == null ? null : approveCom;

            AG_IAS_PETITION_TYPE_R petitionType = ctx.AG_IAS_PETITION_TYPE_R.SingleOrDefault(a => a.PETITION_TYPE_CODE == header.PettitionTypeCodeRequest);

            header.PetitionTypeR = petitionType;


            AG_IAS_LICENSE_TYPE_R licenseType = ctx.AG_IAS_LICENSE_TYPE_R.SingleOrDefault(a => a.LICENSE_TYPE_CODE == header.LicenseTypeCodeRequest);

            header.LicenseTypeR = licenseType;

            header.CompressFileDetail = compress;
            return(header);
        }
        public void LicenseHelper_Can_PhaseToDate()
        {
            DateTime date = LicenseFileHelper.PhaseToDate("08/08/2555");

            Assert.AreEqual(date, new DateTime(Convert.ToInt32(2555 - 543), 8, 8));
        }