Exemplo n.º 1
0
        public ActionResult gerarExcel()
        {
            List <int> ids = UtilRequest.getListInt("ids");

            List <MacroConta> lista = this.OMacroContaBL.listar("", true).Where(x => ids.Contains(x.id)).ToList();

            if (lista.Count > 0)
            {
                var listaExcel = lista.Select(x => new {
                    x.id,
                    x.descricao,
                    dtCadastro = UtilDate.toDisplay(x.dtCadastro.ToString()),
                    status     = x.ativo == true ? "Ativo" : "Desativado"
                }).ToList();

                var OGrid = new GridView();
                OGrid.DataSource = listaExcel;
                OGrid.DataBind();

                OGrid.HeaderRow.Cells[0].Text = "ID";
                OGrid.HeaderRow.Cells[1].Text = "Macro Conta";
                OGrid.HeaderRow.Cells[2].Text = "Data de Cadastro";
                OGrid.HeaderRow.Cells[3].Text = "Status";

                UTIL.Excel.UtilExcel OExcel = new UTIL.Excel.UtilExcel();
                OExcel.downloadExcel(Response, OGrid, String.Concat("Lista de Macro Contas - ", DateTime.Now.ToShortDateString().Replace("/", "-"), ".xls"));
            }

            return(null);
        }
Exemplo n.º 2
0
 public string ToSQLInsertString()
 {
     return(uniqueID.ToString() + ", '" + name + "', '" + sex + "', '" +
            UtilDate.ToSql(dateBorn) + "', " + race + ", " + countryID + ", '" +
            description + "', '" + future1 + "', '', " +           //future1, future2
            serverUniqueID);
 }
Exemplo n.º 3
0
    //when client selects in it's DB, there's only a row with uniqueID: 1
    //if confiable is read on client, it will be also checked on server
    public static ServerEvaluator SelectEvaluator(int myUniqueID)
    {
        Sqlite.Open();
        dbcmd.CommandText = "SELECT * FROM " + Constants.ServerEvaluatorTable + " WHERE uniqueID == " + myUniqueID;
        LogB.SQL(dbcmd.CommandText.ToString());

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        ServerEvaluator myEval = new ServerEvaluator();

        //will return a -1 on uniqueID to know that evaluator data is not in the database
        myEval.UniqueID = -1;

        while (reader.Read())
        {
            myEval.UniqueID    = Convert.ToInt32(reader[0].ToString());
            myEval.Code        = reader[1].ToString();
            myEval.Name        = reader[2].ToString();
            myEval.Email       = reader[3].ToString();
            myEval.DateBorn    = UtilDate.FromSql(reader[4].ToString());
            myEval.CountryID   = Convert.ToInt32(reader[5].ToString());
            myEval.Chronometer = reader[6].ToString();
            myEval.Device      = reader[7].ToString();
            myEval.Comments    = reader[8].ToString();
            myEval.Confiable   = Util.IntToBool(Convert.ToInt32(reader[9].ToString()));
        }

        reader.Close();
        Sqlite.Close();
        return(myEval);
    }
Exemplo n.º 4
0
        public HttpResponseMessage getLogFileList()
        {
            try
            {
                List <FileLog> fileEntries = new List <FileLog>();
                log4net.Appender.IAppender[] logAppenders = log.Logger.Repository.GetAppenders();

                foreach (log4net.Appender.IAppender s in logAppenders)
                {
                    string   filePath = ((log4net.Appender.FileAppender)s).File;
                    DateTime oTime    = System.IO.File.GetLastWriteTime(filePath);

                    FileLog oFileLog = new FileLog();
                    oFileLog.fileName       = Path.GetFileName(filePath);
                    oFileLog.dateLastUpdate = UtilDate.CurrentTimeMillis(oTime);

                    fileEntries.Add(oFileLog);
                }
                log.Debug("getlogfilelist - metodo eseguito con successo");
                return(Request.CreateResponse(HttpStatusCode.OK, fileEntries));
            }
            catch (Exception ex)
            {
                log.Error("getlogfilelist - errore nell'esecuzione ", ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemplo n.º 5
0
    //used on Sqlite main convertPersonAndPersonSessionTo77()
    public ArrayList SelectAllPersons()
    {
        dbcmd.CommandText = "SELECT * FROM " + Constants.PersonOldTable + " ORDER BY uniqueID";
        LogB.SQL(dbcmd.CommandText.ToString());
        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        ArrayList myArray = new ArrayList(1);

        while (reader.Read())
        {
            PersonOld p = new PersonOld(
                Convert.ToInt32(reader[0].ToString()),                               //uniqueID
                reader[1].ToString(),                                                //name
                reader[2].ToString(),                                                //sex
                UtilDate.FromSql(reader[3].ToString()),                              //dateBorn
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //height
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())), //weight

                Convert.ToInt32(reader[6].ToString()),                               //sportID
                Convert.ToInt32(reader[7].ToString()),                               //speciallityID
                Convert.ToInt32(reader[8].ToString()),                               //practice
                reader[9].ToString(),                                                //description
                Convert.ToInt32(reader[10].ToString()),                              //race
                Convert.ToInt32(reader[11].ToString()),                              //countryID
                Convert.ToInt32(reader[12].ToString())                               //serverUniqueID
                );
            myArray.Add(p);
        }
        reader.Close();
        return(myArray);
    }
Exemplo n.º 6
0
    //can be "Constants.PersonOldTable" or "Constants.ConvertTempTable"
    //temp is used to modify table between different database versions if needed
    public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string sex, DateTime dateBorn, double height, double weight, int sportID, int speciallityID, int practice, string description, int race, int countryID, int serverUniqueID)
    {
        if (!dbconOpened)
        {
            dbcon.Open();
        }

        if (uniqueID == "-1")
        {
            uniqueID = "NULL";
        }

        string myString = "INSERT INTO " + tableName +
                          " (uniqueID, name, sex, dateBorn, height, weight,  sportID, speciallityID, practice, description, race, countryID, serverUniqueID) VALUES (" + uniqueID + ", '" +
                          name + "', '" + sex + "', '" + UtilDate.ToSql(dateBorn) + "', " +
                          Util.ConvertToPoint(height) + ", " + "-1" + ", " + //"-1" is weight because it's defined in personSesionWeight for allow change between sessions
                          sportID + ", " + speciallityID + ", " + practice + ", '" + description + "', " +
                          race + ", " + countryID + ", " + serverUniqueID + ")";

        dbcmd.CommandText = myString;
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();
        int myReturn = -10000;         //dbcon.LastInsertRowId;

        if (!dbconOpened)
        {
            dbcon.Close();
        }

        return(myReturn);
    }
        //Construtor
        public AssociadoCargoFormValidator()
        {
            RuleFor(x => x.AssociadoCargo.idAssociado)
            .NotEmpty().WithMessage("Informe a qual associado será vinculado o cargo.");

            RuleFor(x => x.AssociadoCargo.idCargo)
            .GreaterThan(0).WithMessage("Informe qual é o cargo.");

            RuleFor(x => x.AssociadoCargo.inicioGestao)
            .NotEmpty().WithMessage("Informe o início da gestão em que o cargo foi/será exercido.");

            RuleFor(x => x.AssociadoCargo.fimGestao)
            .NotEmpty().WithMessage("Informe o fim da gestão em que o cargo foi/será exercido.");

            When(x => !String.IsNullOrEmpty(x.AssociadoCargo.inicioGestao), () => {
                RuleFor(x => UtilDate.cast(x.AssociadoCargo.inicioGestao))
                .GreaterThan(new DateTime(1920, 1, 1)).WithMessage("Informe uma data válida para o ínicio da gestão.");

                RuleFor(x => UtilDate.cast(x.AssociadoCargo.inicioGestao))
                .LessThan(x => UtilDate.cast(x.AssociadoCargo.fimGestao)).WithMessage("A data de início da gestão deve ser inferior ao fim.");
            });

            When(x => (!String.IsNullOrEmpty(x.AssociadoCargo.inicioGestao) && !String.IsNullOrEmpty(x.AssociadoCargo.fimGestao)), () => {
                RuleFor(x => x.AssociadoCargo.idCargo)
                .Must((x, idCargo) => !this.existe(x)).WithMessage("Já há um registro cadastrado com essas informações.");
            });
        }
Exemplo n.º 8
0
    public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string place, DateTime date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments, int serverUniqueID)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        if (uniqueID == "-1")
        {
            uniqueID = "NULL";
        }

        dbcmd.CommandText = "INSERT INTO " + tableName + " (uniqueID, name, place, date, personsSportID, personsSpeciallityID, personsPractice, comments, serverUniqueID)" +
                            " VALUES (" + uniqueID + ", \""
                            + name + "\", \"" + place + "\", \"" + UtilDate.ToSql(date) + "\", " +
                            personsSportID + ", " + personsSpeciallityID + ", " +
                            personsPractice + ", \"" + comments + "\", " +
                            serverUniqueID + ")";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        string myString = @"select last_insert_rowid()";

        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

        if (!dbconOpened)
        {
            Sqlite.Close();
        }

        return(myLast);
    }
Exemplo n.º 9
0
        public HttpResponseMessage insertNewTask([FromBody] Effort effort)
        {
            try
            {
                using (var unitOfWork = new UnitOfWork(new FoolStaffContext()))
                {
                    Effort oEffort = new Effort();
                    oEffort.Titolo        = effort.Titolo;
                    oEffort.Descrizione   = effort.Descrizione;
                    oEffort.Priorita      = effort.Priorita;
                    oEffort.DataCreazione = UtilDate.CurrentTimeMillis();
                    oEffort.Stato         = "OPEN";

                    unitOfWork.Efforts.Add(oEffort);
                    unitOfWork.Complete();

                    var entity = unitOfWork.Efforts.Find(t => t.Stato == "OPEN").OrderByDescending(t => t.Priorita).ToList();
                    log.Debug("insertNewTask - task inserito correttamente");
                    return(Request.CreateResponse(HttpStatusCode.OK, entity));
                }
            }
            catch (Exception ex)
            {
                log.Error("insertNewTask - errore nell'inserimento del task ", ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemplo n.º 10
0
    //public static int InsertPing(ServerPing ping)
    public static int InsertPing(bool dbconOpened, int evaluatorID, string cjVersion, string osVersion, string ip, DateTime date)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        string uniqueID = "NULL";

        string myString = "INSERT INTO " + Constants.ServerPingTable +
                          " (uniqueID, evaluatorID, cjVersion, osVersion, IP, date) VALUES (" +
                          uniqueID + ", " + evaluatorID + ", \"" +
                          cjVersion + "\", \"" + osVersion + "\", \"" +
                          ip + "\", \"" + UtilDate.ToSql(date) + "\")";

        dbcmd.CommandText = myString;

        LogB.SQL(dbcmd.CommandText.ToString());

        dbcmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        myString          = @"select last_insert_rowid()";
        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

        if (!dbconOpened)
        {
            Sqlite.Close();
        }

        return(myLast);
    }
Exemplo n.º 11
0
    public static void UpdateEvaluator(bool dbconOpened, int uniqueID, string code, string name, string email, DateTime dateBorn,
                                       int countryID, string chronometer, string device, string comments, bool confiable)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }
        dbcmd.CommandText = "UPDATE " + Constants.ServerEvaluatorTable + " " +
                            " SET code = \"" + code +
                            "\" , name = \"" + name +
                            "\" , email = \"" + email +
                            "\" , dateBorn = \"" + UtilDate.ToSql(dateBorn) +
                            "\" , countryID = " + countryID +
                            ", chronometer = \"" + chronometer +
                            "\", device = \"" + device +
                            "\", comments = \"" + comments +
                            //"\", confiable = " + Util.BoolToInt(confiable) + //security: update cannot change confiable
                            "\" WHERE uniqueID == " + uniqueID;
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
    }
Exemplo n.º 12
0
        public HttpResponseMessage closeTask([FromBody] int idEffort)
        {
            try
            {
                using (var unitOfWork = new UnitOfWork(new FoolStaffContext()))
                {
                    var entityTask = unitOfWork.Efforts.SingleOrDefault(t => t.Id == idEffort);

                    if (entityTask != null)
                    {
                        entityTask.DataChiusura = UtilDate.CurrentTimeMillis();
                        entityTask.Stato        = "CLOSED";
                        unitOfWork.Complete();
                    }
                    var entity = unitOfWork.Efforts.Find(t => t.Stato == "OPEN").OrderByDescending(t => t.Priorita).ToList();
                    log.Debug("closeTask - Task id [" + entityTask.Id + "] chiuso correttamente");
                    return(Request.CreateResponse(HttpStatusCode.OK, entity));
                }
            }
            catch (Exception ex)
            {
                log.Error("closeTask - errore nella chiusura al task ", ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemplo n.º 13
0
        public ActionResult gerarExcel()
        {
            var ids = UtilRequest.getListInt("ids");
            var listaEstoqueEntrada = this.OEstoqueEntradaBL.listarPorId(ids).ToList();

            if (listaEstoqueEntrada.Count > 0)
            {
                var listaExcel = listaEstoqueEntrada.Select(x => new {
                    x.id,
                    x.ProdutoEstoque.dtMovimentacao,
                    fornecedor = x.Fornecedor.Pessoa.nome,
                    produto    = x.ProdutoEstoque.Produto.nome,
                    quantidade = x.ProdutoEstoque.qtdMovimentada,
                    dtCadastro = UtilDate.toDisplay(x.dtCadastro.ToString()),
                    status     = (x.ativo == "S") ? "Sim" : "Não",
                }).ToList();

                var OGrid = new GridView();
                OGrid.DataSource = listaExcel;
                OGrid.DataBind();

                OGrid.HeaderRow.Cells[0].Text = "ID";
                OGrid.HeaderRow.Cells[1].Text = "Data Entrada";
                OGrid.HeaderRow.Cells[2].Text = "Fornecedor";
                OGrid.HeaderRow.Cells[3].Text = "Produto";
                OGrid.HeaderRow.Cells[4].Text = "Quantidade";
                OGrid.HeaderRow.Cells[5].Text = "Data de Cadastro";
                OGrid.HeaderRow.Cells[6].Text = "Ativo";

                UTIL.Excel.UtilExcel OExcel = new UTIL.Excel.UtilExcel();
                OExcel.downloadExcel(Response, OGrid, String.Concat("Lista de Entrada do Estoque - ", DateTime.Now.ToShortDateString().Replace("/", "-"), ".xls"));
            }

            return(null);
        }
Exemplo n.º 14
0
        private List <Message> GetMessagesRelated(Message data)
        {
            var filterBuilder = Builders <Message> .Filter;
            var finalFilter   = filterBuilder.Eq(x => x.Sender, data.Sender) |
                                filterBuilder.Eq(x => x.Receiver, data.Sender);

            var messages = _repository.GetList(finalFilter);

            return(messages.Where(x => (UtilDate.GetMothFromDate(x.Date) - UtilDate.GetMothFromDate(data.Date)) <= MessageValidation.HALFYEAF)
                   .Where(x => x.Subject
                          .ToUpper()
                          .Replace("REFERENTE: ", string.Empty)
                          .Equals(data.Subject
                                  .ToUpper()
                                  .Replace("REFERENTE: ", string.Empty)) ||
                          x.Subject
                          .ToUpper()
                          .Replace("RESPONDENDO: ", string.Empty)
                          .Equals(data.Subject
                                  .ToUpper()
                                  .Replace("RESPONDENDO: ", string.Empty)) ||
                          x.Subject
                          .ToUpper()
                          .Replace("COMPLEMENTANDO: ", string.Empty)
                          .Equals(data.Subject
                                  .ToUpper()
                                  .Replace("COMPLEMENTANDO: ", string.Empty)))
                   .ToList());
        }
Exemplo n.º 15
0
    /* OLD STUFF */

    /*
     * don't do more like this, use Sqlite.convertTables()
     */
    //change DB from 0.55 to 0.56
    protected internal static void convertTableAddingSportStuff()
    {
        ArrayList myArray = new ArrayList(2);

        //1st create a temp table
        //createTable(Constants.ConvertTempTable);
        SqliteSessionOld sqliteSessionObject = new SqliteSessionOld();

        sqliteSessionObject.createTable(Constants.ConvertTempTable);

        //2nd copy all data from session table to temp table
        dbcmd.CommandText = "SELECT * " +
                            "FROM " + Constants.SessionTable + " ORDER BY uniqueID";
        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        while (reader.Read())
        {
            Session mySession = new Session(reader[0].ToString(), reader[1].ToString(),
                                            reader[2].ToString(), UtilDate.FromSql(reader[3].ToString()),
                                            1,                    //sport undefined
                                            -1,                   //speciallity undefined
                                            -1,                   //practice level undefined
                                            reader[4].ToString(), //comments
                                            Constants.ServerUndefinedID
                                            );
            myArray.Add(mySession);
        }
        reader.Close();

        foreach (Session mySession in myArray)
        {
            InsertOld(true, Constants.ConvertTempTable,
                      mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date),
                      mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);
        }

        //3rd drop table sessions
        Sqlite.dropTable(Constants.SessionTable);

        //4d create table persons (now with sport related stuff
        //createTable(Constants.SessionTable);
        sqliteSessionObject.createTable(Constants.SessionTable);

        //5th insert data in sessions (with sport related stuff)
        foreach (Session mySession in myArray)
        {
            InsertOld(true, Constants.SessionTable,
                      mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date),
                      mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);
        }


        //6th drop temp table
        Sqlite.dropTable(Constants.ConvertTempTable);
    }
Exemplo n.º 16
0
    //used by the stats selector of sessions
    //also by PersonsRecuperateFromOtherSessionWindowBox (src/gui/person.cs)
    public static string[] SelectAllSessionsSimple(bool commentsDisable, int sessionIdDisable)
    {
        string selectString = " uniqueID, name, place, date, comments ";

        if (commentsDisable)
        {
            selectString = " uniqueID, name, place, date ";
        }

        Sqlite.Open();
        //dbcmd.CommandText = "SELECT * FROM session ORDER BY uniqueID";
        dbcmd.CommandText = "SELECT " + selectString + " FROM " + Constants.SessionTable + " " +
                            " WHERE uniqueID != " + sessionIdDisable + " ORDER BY uniqueID";

        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        ArrayList myArray = new ArrayList(2);

        int count = new int();

        count = 0;

        while (reader.Read())
        {
            if (commentsDisable)
            {
                myArray.Add(reader[0].ToString() + ":" + reader[1].ToString() + ":" +
                            reader[2].ToString() + ":" + UtilDate.FromSql(reader[3].ToString()).ToShortDateString());
            }
            else
            {
                myArray.Add(reader[0].ToString() + ":" + reader[1].ToString() + ":" +
                            reader[2].ToString() + ":" + UtilDate.FromSql(reader[3].ToString()).ToShortDateString() + ":" +
                            reader[4].ToString());
            }
            count++;
        }

        reader.Close();

        //close database connection
        Sqlite.Close();

        string [] mySessions = new string[count];
        count = 0;
        foreach (string line in myArray)
        {
            mySessions [count++] = line;
        }

        return(mySessions);
    }
Exemplo n.º 17
0
 //used to select a session at Sqlite.convertTables
 public Session(string [] myString)
 {
     this.uniqueID             = Convert.ToInt32(myString[0]);
     this.name                 = myString[1];
     this.place                = myString[2];
     this.date                 = UtilDate.FromSql(myString[3]);
     this.personsSportID       = Convert.ToInt32(myString[4]);
     this.personsSpeciallityID = Convert.ToInt32(myString[5]);
     this.personsPractice      = Convert.ToInt32(myString[6]);
     this.comments             = myString[7];
     this.serverUniqueID       = Convert.ToInt32(myString[8]);
 }
Exemplo n.º 18
0
    //force sensor
    public void UpdateForceSensorTare(double tare)
    {
        if (tare == -1)
        {
            return;
        }

        //change preferences object and SqlitePreferences
        DateTime dt = DateTime.Now;

        forceSensorTareDateTime = UtilDate.ToFile(dt);
        SqlitePreferences.Update(SqlitePreferences.ForceSensorTareDateTimeStr, forceSensorTareDateTime, false);

        forceSensorTare = tare;
        SqlitePreferences.Update(SqlitePreferences.ForceSensorTareStr, Util.ConvertToPoint(tare), false);
    }
Exemplo n.º 19
0
 //used to select a person at Sqlite.convertTables
 public PersonOld(string [] myString)
 {
     this.uniqueID       = Convert.ToInt32(myString[0]);
     this.name           = myString[1];
     this.sex            = myString[2];
     this.dateBorn       = UtilDate.FromSql(myString[3]);
     this.height         = Convert.ToDouble(Util.ChangeDecimalSeparator(myString[4]));
     this.weight         = Convert.ToDouble(Util.ChangeDecimalSeparator(myString[5]));
     this.sportID        = Convert.ToInt32(myString[6]);
     this.speciallityID  = Convert.ToInt32(myString[7]);
     this.practice       = Convert.ToInt32(myString[8]);
     this.description    = myString[9];
     this.race           = Convert.ToInt32(myString[10]);
     this.countryID      = Convert.ToInt32(myString[11]);
     this.serverUniqueID = Convert.ToInt32(myString[12]);         //remember don't do this on server
 }
Exemplo n.º 20
0
 public static void Update(Person myPerson)
 {
     Sqlite.Open();
     dbcmd.CommandText = "UPDATE " + Constants.PersonTable +
                         " SET name = \"" + myPerson.Name +
                         "\", sex = \"" + myPerson.Sex +
                         "\", dateborn = \"" + UtilDate.ToSql(myPerson.DateBorn) +
                         "\", race = " + myPerson.Race +
                         ", countryID = " + myPerson.CountryID +
                         ", description = \"" + myPerson.Description +
                         "\", serverUniqueID = " + myPerson.ServerUniqueID +
                         " WHERE uniqueID == " + myPerson.UniqueID;
     LogB.SQL(dbcmd.CommandText.ToString());
     dbcmd.ExecuteNonQuery();
     Sqlite.Close();
 }
Exemplo n.º 21
0
 public static void Update(int uniqueID, string name, string place, DateTime date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments)
 {
     //TODO: serverUniqueID (but cannot be changed in gui/edit, then not need now)
     Sqlite.Open();
     dbcmd.CommandText = "UPDATE " + Constants.SessionTable + " " +
                         " SET name = \"" + name +
                         "\" , date = \"" + UtilDate.ToSql(date) +
                         "\" , place = \"" + place +
                         "\" , personsSportID = " + personsSportID +
                         ", personsSpeciallityID = " + personsSpeciallityID +
                         ", personsPractice = " + personsPractice +
                         ", comments = \"" + comments +
                         "\" WHERE uniqueID == " + uniqueID;
     dbcmd.ExecuteNonQuery();
     Sqlite.Close();
 }
Exemplo n.º 22
0
 public HttpResponseMessage getNextEvents()
 {
     try
     {
         using (var unitOfWork = new UnitOfWork(new FoolStaffContext()))
         {
             long dataOdierna = UtilDate.CurrentTimeMillis();
             var  entity      = unitOfWork.Eventi.Search(e => e.DataEvento > dataOdierna).Include(u => u.Prenotazioni).OrderBy(t => t.DataEvento).ToList();
             log.Debug("getnextevents - metodo eseguito con successo");
             return(Request.CreateResponse(HttpStatusCode.OK, entity));
         }
     }
     catch (Exception ex)
     {
         log.Error("getnextevents - errore nell'esecuzione ", ex);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
Exemplo n.º 23
0
        public HttpResponseMessage getLogFile(string sfilename)
        {
            try
            {
                List <FileLog> fileEntries = new List <FileLog>();
                log4net.Appender.IAppender[] logAppenders = log.Logger.Repository.GetAppenders();
                FileLog oFileLog = new FileLog();
                foreach (log4net.Appender.IAppender s in logAppenders)
                {
                    string filePath = ((log4net.Appender.FileAppender)s).File;
                    string fileName = Path.GetFileName(filePath);

                    if (sfilename != fileName)
                    {
                        continue;
                    }

                    DateTime oTime = System.IO.File.GetLastWriteTime(filePath);
                    oFileLog.fileName       = Path.GetFileName(filePath);
                    oFileLog.dateLastUpdate = UtilDate.CurrentTimeMillis(oTime);
                    string content = "";

                    using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            while (!reader.EndOfStream)
                            {
                                content = reader.ReadToEnd();
                            }
                        }
                    }
                    oFileLog.content = content;
                    break;
                }
                log.Debug("getLogFile - metodo eseguito con successo");
                return(Request.CreateResponse(HttpStatusCode.OK, oFileLog));
            }
            catch (Exception ex)
            {
                log.Error("getLogFile - errore nell'esecuzione ", ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemplo n.º 24
0
    //force sensor
    public void UpdateForceSensorCalibration(double weight, double calibrationFactor)
    {
        if (calibrationFactor == -1)
        {
            return;
        }

        //change preferences object and SqlitePreferences
        DateTime dt = DateTime.Now;

        forceSensorCalibrationDateTime = UtilDate.ToFile(dt);
        SqlitePreferences.Update(SqlitePreferences.ForceSensorCalibrationDateTimeStr, forceSensorCalibrationDateTime, false);

        forceSensorCalibrationWeight = weight;
        SqlitePreferences.Update(SqlitePreferences.ForceSensorCalibrationWeightStr, Util.ConvertToPoint(weight), false);

        forceSensorCalibrationFactor = calibrationFactor;
        SqlitePreferences.Update(SqlitePreferences.ForceSensorCalibrationFactorStr, Util.ConvertToPoint(calibrationFactor), false);
    }
Exemplo n.º 25
0
    public Session Select(string myUniqueID)
    {
        if (type == DatabaseType.DEFAULT)
        {
            return(SqliteSession.Select(myUniqueID));
        }
        else
        {
            // This code could be refactored from existing code in SqliteSession::Select()

            SqliteGeneral sqliteGeneral = new SqliteGeneral(databasePath);
            SqliteCommand dbcommand     = sqliteGeneral.command();

            dbcommand.CommandText = "SELECT * FROM Session WHERE uniqueID == @myUniqueID";
            dbcommand.Parameters.Add(new SqliteParameter("@myUniqueID", myUniqueID));

            SqliteDataReader reader = dbcommand.ExecuteReader();

            // Copied from a non-callable (yet) static method: SqliteSession::Select()
            string [] values = new string[9];

            while (reader.Read())
            {
                values[0] = reader[0].ToString();
                values[1] = reader[1].ToString();
                values[2] = reader[2].ToString();
                values[3] = reader[3].ToString();
                values[4] = reader[4].ToString();
                values[5] = reader[5].ToString();
                values[6] = reader[6].ToString();
                values[7] = reader[7].ToString();
                values[8] = reader[8].ToString();
            }

            Session mySession = new Session(values[0],
                                            values[1], values[2], UtilDate.FromSql(values[3]),
                                            Convert.ToInt32(values[4]), Convert.ToInt32(values[5]), Convert.ToInt32(values[6]),
                                            values[7], Convert.ToInt32(values[8]));

            return(mySession);
        }
    }
Exemplo n.º 26
0
    public static int InsertEvaluator(bool dbconOpened, string code, string name, string email, DateTime dateBorn,
                                      int countryID, string chronometer, string device, string comments, bool confiable)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        string uniqueID = "NULL";

        string myString = "INSERT INTO " + Constants.ServerEvaluatorTable +
                          " (uniqueID, code, name, email, dateBorn, countryID, chronometer, device, comments, confiable) VALUES (" +
                          uniqueID + ", \"" +
                          code + "\", \"" + name + "\", \"" +
                          email + "\", \"" + UtilDate.ToSql(dateBorn) + "\", " +
                          countryID + ", \"" + chronometer + "\", \"" +
                          device + "\", \"" + comments + "\", " +
                                                  //Util.BoolToInt(confiable) +
                          Util.BoolToInt(false) + //security: cannot directly insert a confiable person
                          ")";

        dbcmd.CommandText = myString;

        LogB.SQL(dbcmd.CommandText.ToString());

        dbcmd.ExecuteNonQuery();


        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        myString          = @"select last_insert_rowid()";
        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

        if (!dbconOpened)
        {
            Sqlite.Close();
        }

        return(myLast);
    }
Exemplo n.º 27
0
    public static Session SelectDo(SqliteCommand mydbcmd)
    {
        try {
            Sqlite.Open();
        } catch {
            //done because there's an eventual problem maybe thread related on very few starts of chronojump
            LogB.SQL("Catched dbcon problem at Session.Select");
            Sqlite.Close();
            Sqlite.Open();
            LogB.SQL("reopened again");
        }
        LogB.SQL(mydbcmd.CommandText.ToString());

        SqliteDataReader reader;

        reader = mydbcmd.ExecuteReader();

        string [] values = new string[9];

        while (reader.Read())
        {
            values[0] = reader[0].ToString();
            values[1] = reader[1].ToString();
            values[2] = reader[2].ToString();
            values[3] = reader[3].ToString();
            values[4] = reader[4].ToString();
            values[5] = reader[5].ToString();
            values[6] = reader[6].ToString();
            values[7] = reader[7].ToString();
            values[8] = reader[8].ToString();
        }

        Session mySession = new Session(values[0],
                                        values[1], values[2], UtilDate.FromSql(values[3]),
                                        Convert.ToInt32(values[4]), Convert.ToInt32(values[5]), Convert.ToInt32(values[6]),
                                        values[7], Convert.ToInt32(values[8]));

        reader.Close();
        Sqlite.Close();
        return(mySession);
    }
Exemplo n.º 28
0
        public ActionResult gerarExcel()
        {
            var ids = UtilRequest.getListInt("ids");
            var listaEstoqueSaida = this.OEstoqueSaidaBL.listarPorId(ids).ToList();

            if (listaEstoqueSaida.Count > 0)
            {
                var listaExcel = listaEstoqueSaida.Select(x => new {
                    x.id,
                    x.ProdutoEstoque.dtMovimentacao,
                    tipoSaida = x.TipoReferenciaSaida.descricao,
                    saidaPara = ((x.idTipoReferenciaSaida == (int)TipoReferenciaSaidaEnum.FUNCIONARIOS) ?
                                 this.OFuncionarioConsultaBL.carregar(x.idReferencia).Pessoa.nome :
                                 "Outros"),
                    produto    = x.ProdutoEstoque.Produto.nome,
                    quantidade = x.ProdutoEstoque.qtdMovimentada,
                    descricao  = x.ProdutoEstoque.descricao,
                    dtCadastro = UtilDate.toDisplay(x.dtCadastro.ToString()),
                    status     = (x.ativo == "S") ? "Sim" : "Não",
                }).ToList();

                var OGrid = new GridView();
                OGrid.DataSource = listaExcel;
                OGrid.DataBind();

                OGrid.HeaderRow.Cells[0].Text = "ID";
                OGrid.HeaderRow.Cells[1].Text = "Data Entrada";
                OGrid.HeaderRow.Cells[2].Text = "Tipo Saída";
                OGrid.HeaderRow.Cells[3].Text = "Saída Para";
                OGrid.HeaderRow.Cells[4].Text = "Produto";
                OGrid.HeaderRow.Cells[5].Text = "Quantidade";
                OGrid.HeaderRow.Cells[6].Text = "Descriç&atilde;o";
                OGrid.HeaderRow.Cells[7].Text = "Data de Cadastro";
                OGrid.HeaderRow.Cells[8].Text = "Ativo";

                UTIL.Excel.UtilExcel OExcel = new UTIL.Excel.UtilExcel();
                OExcel.downloadExcel(Response, OGrid, String.Concat("Lista de Saída do Estoque - ", DateTime.Now.ToShortDateString().Replace("/", "-"), ".xls"));
            }

            return(null);
        }
Exemplo n.º 29
0
    public static Person Select(bool dbconOpened, string whereStr)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        dbcmd.CommandText = "SELECT * FROM " + Constants.PersonTable + " " + whereStr;

        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        Person p = new Person(-1);

        if (reader.Read())
        {
            p = new Person(
                Convert.ToInt32(reader[0].ToString()),                        //uniqueID
                reader[1].ToString(),                                         //name
                reader[2].ToString(),                                         //sex
                UtilDate.FromSql(reader[3].ToString()),                       //dateBorn
                Convert.ToInt32(reader[4].ToString()),                        //race
                Convert.ToInt32(reader[5].ToString()),                        //countryID
                reader[6].ToString(),                                         //description
                reader[7].ToString(),                                         //future1: rfid
                Convert.ToInt32(reader[9].ToString())                         //serverUniqueID
                );
        }
        reader.Close();
        if (!dbconOpened)
        {
            Sqlite.Close();
        }

        return(p);
    }
Exemplo n.º 30
0
    public static int Insert(bool dbconOpened, string uniqueID, string name, string sex, DateTime dateBorn,
                             int race, int countryID, string description, string future1, int serverUniqueID)
    {
        LogB.SQL("going to insert");
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        if (uniqueID == "-1")
        {
            uniqueID = "NULL";
        }

        // -----------------------
        //ATTENTION: if this changes, change the Person.ToSQLInsertString()
        // -----------------------
        string myString = "INSERT INTO " + Constants.PersonTable +
                          " (uniqueID, name, sex, dateBorn, race, countryID, description, future1, future2, serverUniqueID) VALUES (" + uniqueID + ", \"" +
                          name + "\", \"" + sex + "\", \"" + UtilDate.ToSql(dateBorn) + "\", " +
                          race + ", " + countryID + ", \"" + description + "\", \"" + future1 + "\", \"\", " + serverUniqueID + ")";

        dbcmd.CommandText = myString;
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        //int myLast = -10000; //dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        myString          = @"select last_insert_rowid()";
        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

        if (!dbconOpened)
        {
            Sqlite.Close();
        }

        return(myLast);
    }