コード例 #1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_processaArqBancario ");

            /// USER [ execute ]

            DataPortable csv_AllArchive = MemoryGet(input_st_id);

            ApplicationUtil var_util = new ApplicationUtil();

            string st_ids = csv_AllArchive.getValue("ids");

            Trace(st_ids);

            int total_records = var_util.indexCSV(st_ids);

            T_Faturamento fat = new T_Faturamento(this);

            for (int t = 0; t < total_records; ++t)
            {
                DataPortable port_line = MemoryGet(var_util.getCSV(t));

                string line = port_line.getValue("line");

                Trace(line);

                int pos = 0;

                //7
                //06
                //030908
                //7
                //0509629684
                //030908
                //0000000002108

                string fk        = line.Substring(pos, 25).Trim();    pos += 25;
                string cod       = line.Substring(pos, 2).Trim();    pos += 2;
                string dt_banco  = line.Substring(pos, 6).Trim();    pos += 6;
                string st_seuNum = line.Substring(pos, 10).Trim();    pos += 10;
                string st_nosNum = line.Substring(pos, 20).Trim();    pos += 20;
                string dt_venc   = line.Substring(pos, 6).Trim();    pos += 6;
                string vr_pago   = line.Substring(pos, 13).Trim();    pos += 13;

                vr_pago = vr_pago.TrimStart('0');

                Trace(line);

                fat.ExclusiveAccess();

                if (!fat.selectIdentity(fk))
                {
                    Registry("Registro " + fk + " desconhecido!");
                    fat.ReleaseExclusive();
                    continue;
                }

                fat.set_tg_retBanco(cod);

                if (cod == "00")
                {
                    fat.set_tg_situacao(TipoSitFat.PagoCC);
                }

                if (cod == "10")
                {
                    fat.set_tg_situacao(TipoSitFat.BaixaCfeInst);
                }

                if (cod == "06" ||
                    cod == "08" ||
                    cod == "15" ||
                    cod == "25")
                {
                    fat.set_tg_situacao(TipoSitFat.PagoDoc);
                }

                fat.set_dt_baixa(GetDataBaseTime(new DateTime(2000 + Convert.ToInt32(dt_banco.Substring(4, 2)),
                                                              Convert.ToInt32(dt_banco.Substring(2, 2)),
                                                              Convert.ToInt32(dt_banco.Substring(0, 2)))));

                if (!fat.synchronize_T_Faturamento())
                {
                    Registry("Registro " + fk + " não foi possível atualizar!");
                }

                fat.ReleaseExclusive();
            }

            /// USER [ execute ] END

            Registry("execute done exec_processaArqBancario ");

            return(true);
        }