Beispiel #1
0
 public void copy(ref LINK_Agenda cpy)
 {
     fk_schedule     = cpy.fk_schedule;
     fk_empresa      = cpy.fk_empresa;
     en_atividade    = cpy.en_atividade;
     st_emp_afiliada = cpy.st_emp_afiliada;
 }
Beispiel #2
0
        public override bool authenticate( )
        {
            if (base.authenticate() == false)
            {
                return(false);
            }

            Registry("authenticate ins_agenda ");

            /// USER [ authenticate ]

            emp = new T_Empresa(this);
            l_a = new LINK_Agenda(this);

            input_st_empresa = input_st_empresa.PadLeft(6, '0');

            if (!emp.select_rows_empresa(input_st_empresa))
            {
                PublishError("Código inválido de empresa");
                return(false);
            }

            if (!emp.fetch())
            {
                return(false);
            }

            if (input_en_atividade != TipoAtividade.FechMensal)
            {
                PublishError("Código inválido de atividade");
                return(false);
            }
            else
            {
                if (input_en_tipo_schedule != Scheduler.Monthly)
                {
                    PublishError("Esta atividade permite somente agendamento mensal");
                    return(false);
                }
            }

            if (l_a.select_rows_emp_ativ(emp.get_identity(), input_en_atividade))
            {
                while (l_a.fetch())
                {
                    if (l_a.get_st_emp_afiliada().ToUpper().Trim() == input_st_afiliada.ToUpper().Trim())
                    {
                        PublishError("Atividade previamente agendada");
                        return(false);
                    }
                }
            }

            /// USER [ authenticate ] END

            Registry("authenticate done ins_agenda ");

            return(true);
        }
Beispiel #3
0
        public override bool authenticate( )
        {
            if (base.authenticate() == false)
            {
                return(false);
            }

            Registry("authenticate del_agenda ");

            /// USER [ authenticate ]

            LINK_Agenda la = new LINK_Agenda(this);

            if (!la.selectIdentity(input_fk_agenda))
            {
                PublishError("Agenda não encontrada");
                return(false);
            }

            I_Scheduler sch = new I_Scheduler(this);

            if (!sch.selectIdentity(la.get_fk_schedule()))
            {
                return(false);
            }

            if (!sch.delete())
            {
                return(false);
            }

            if (!la.delete())
            {
                return(false);
            }

            /// USER [ authenticate ] END

            Registry("authenticate done del_agenda ");

            return(true);
        }
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_agenda ");

            /// USER [ execute ]

            LINK_Agenda l_a = new LINK_Agenda(this);

            // ## Busca todos os registros de agendamento

            if (l_a.selectAll())
            {
                StringBuilder sb = new StringBuilder();

                T_Empresa   emp = new T_Empresa(this);
                I_Scheduler sch = new I_Scheduler(this);

                ApplicationUtil var_util = new ApplicationUtil();

                while (l_a.fetch())
                {
                    // ## Cria container de dados

                    DadosAgenda da = new DadosAgenda();

                    // ## Valida links para outras tabelas

                    if (!emp.selectIdentity(l_a.get_fk_empresa()))
                    {
                        continue;
                    }

                    if (!sch.selectIdentity(l_a.get_fk_schedule()))
                    {
                        continue;
                    }

                    var_util.indexCSV(sch.get_st_job(), ';');

                    string aff = "";
                    string job = var_util.getCSV(0);

                    if (sch.get_st_job().IndexOf("afiliada") > 0)
                    {
                        if (job == "schedule_fech_mensal")
                        {
                            aff = " - " + var_util.getCSV(4);
                        }
                    }

                    // ## Copia dados

                    da.set_fk_agenda(l_a.get_identity());
                    da.set_st_empresa(emp.get_st_empresa() + aff);
                    da.set_st_nome_empresa(emp.get_st_fantasia());
                    da.set_en_atividade(l_a.get_en_atividade());
                    da.set_dt_ultima(sch.get_dt_last());

                    // ## Formata

                    switch (sch.get_tg_type())
                    {
                        #region - Monthly -

                    case Scheduler.Monthly:
                    {
                        da.set_st_info("Mensal, Dia " +
                                       sch.get_nu_monthly_day() +
                                       ", Hora " +
                                       sch.get_st_monthly_hhmm().Substring(0, 2) +
                                       ":" +
                                       sch.get_st_monthly_hhmm().Substring(2, 2));

                        break;
                    }

                        #endregion

                        #region - Weekly -

                    case Scheduler.Weekly:
                    {
                        string dia = "";

                        switch (sch.get_st_weekly_dow())
                        {
                        case "0": dia = "Domingo";      break;

                        case "1": dia = "Segunda";      break;

                        case "2": dia = "Terça";                break;

                        case "3": dia = "Quarta";       break;

                        case "4": dia = "Quinta";       break;

                        case "5": dia = "Sexta";                break;

                        case "6": dia = "Sábado";       break;
                        }

                        da.set_st_info("Semanal, Dia " +
                                       dia +
                                       ", Hora " +
                                       sch.get_st_weekly_hhmm().Substring(0, 2) +
                                       ":" +
                                       sch.get_st_weekly_hhmm().Substring(2, 2));

                        break;
                    }

                        #endregion

                        #region - Daily -

                    case Scheduler.Daily:
                    {
                        da.set_st_info("Diariamente " +
                                       sch.get_st_daily_hhmm().Substring(0, 2) +
                                       ":" +
                                       sch.get_st_daily_hhmm().Substring(2, 2));

                        break;
                    }

                        #endregion
                    }

                    // ## Guarda em memória

                    DataPortable mem_rtc = da as DataPortable;

                    sb.Append(MemorySave(ref mem_rtc));
                    sb.Append(",");
                }

                // ## Guarda todos os identificadores em um bloco

                string list_ids = sb.ToString().TrimEnd(',');

                DataPortable dp = new DataPortable();

                dp.setValue("ids", list_ids);

                // ## Envia para client a identificação do bloco

                output_st_csv = MemorySave(ref dp);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_agenda ");

            return(true);
        }
Beispiel #5
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute ins_agenda ");

            /// USER [ execute ]

            I_Scheduler schel = new I_Scheduler(this);

            if (input_en_atividade == TipoAtividade.FechMensal)
            {
                string job = "schedule_fech_mensal;empresa;" +
                             input_st_empresa + ";afiliada;" +
                             input_st_afiliada;

                schel.set_st_job(job);
            }

            schel.set_tg_type(input_en_tipo_schedule);
            schel.set_dt_specific(GetDataBaseTime());
            schel.set_tg_status(Context.OPEN);

            switch (input_en_tipo_schedule)
            {
            case Scheduler.Daily:
            {
                schel.set_st_daily_hhmm(input_st_horario);

                schel.set_dt_last(GetDataBaseTime(DateTime.Now.AddDays(1)));
                schel.set_dt_prev(GetDataBaseTime(DateTime.Now.AddDays(1)));

                break;
            }

            case Scheduler.Weekly:
            {
                schel.set_st_weekly_dow(input_st_aux);
                schel.set_st_weekly_hhmm(input_st_horario);

                schel.set_dt_last(GetDataBaseTime(DateTime.Now.AddDays(7)));
                schel.set_dt_prev(GetDataBaseTime(DateTime.Now.AddDays(7)));

                break;
            }

            case Scheduler.Monthly:
            {
                schel.set_nu_monthly_day(input_st_aux);
                schel.set_st_monthly_hhmm(input_st_horario);

                schel.set_dt_last(GetDataBaseTime(DateTime.Now.AddMonths(1)));
                schel.set_dt_prev(GetDataBaseTime(DateTime.Now.AddMonths(1)));

                break;
            }
            }

            if (!schel.create_I_Scheduler())
            {
                return(false);
            }

            l_a = new LINK_Agenda(this);

            l_a.set_en_atividade(input_en_atividade);
            l_a.set_fk_schedule(schel.get_identity());
            l_a.set_fk_empresa(emp.get_identity());
            l_a.set_st_emp_afiliada(input_st_afiliada);

            if (!l_a.create_LINK_Agenda())
            {
                return(false);
            }

            PublishNote("Agendamento criado com sucesso");

            /// USER [ execute ] END

            Registry("execute done ins_agenda ");

            return(true);
        }