public void log(string msg, string where)
        {
            if (this.enabled)
                {
                    try
                    {
                        msg = msg.Replace("'", "@");
                        using (var entity = new db_SeguimientoProtocolo_r2Entities())
                        {
                            string sqlExists = " if object_id('templog','u') is null begin create table templog (id int identity(1,1) , msg nvarchar(max), t datetime) end";
                            entity.ExecuteStoreCommand(sqlExists);

                            string sqlInsert = "insert into templog(msg,t) select '" + where + " _ [" + msg + "]',getdate()";
                            entity.ExecuteStoreCommand(sqlInsert);
                        }
                    }
                    catch (Exception)
                    {
                        ;
                    }
                }
        }
 public static void ExecuteSqlString(object sqlStmt)
 {
     string sSqlStmt = (string)sqlStmt;
     using (var entity = new db_SeguimientoProtocolo_r2Entities())
     {
         try
         {
             ServerSQLLogger.Instance.log(sSqlStmt, "CiRegistroRepository.ExecuteSqlString");
             entity.ExecuteStoreCommand(sSqlStmt);
         }
         catch (Exception ex)
         {
             ServerSQLLogger.Instance.log(ex, "CiRegistroRepository.ExecuteSqlString");
         }
     }
 }
        //Upsert a la info recibida del cliente
        public long PrepareBulkUpsertUploaded()
        {
            long session = 0;
            using (var entity = new db_SeguimientoProtocolo_r2Entities())
            {
                session = (new UNID()).getNewUNID();
                string sqlCmd = "select TOP 1 * into " + this.GetTmpUploadedTable(session) + " from CI_REGISTRO; TRUNCATE TABLE " + this.GetTmpUploadedTable(session);
                entity.ExecuteStoreCommand(sqlCmd);
            }

            return session;
        }