/// <summary>
    /// Metodo que me permite notificar al WebService de Tattersall Movil que se publicó un remate, 
    /// metodo solo para los Remate, NO para la Venta Directa
    /// </summary>
    /// <param name="remate">objeto remate que creó o publicó</param>
    public static void NotificarMovilRemate(co_re_remates remate)
    {
      try
      {
        getTransaccion();
        //1. valido si el remate a sido publicado
        if (remate.id_remateEstadoWeb.id == PUBLICADO)
        {
          //realizo la instancia del wsdl para la notificacion.
          WsNotificacion notificacion = new WsNotificacionClient();

          //obtengo todos los lotes del remate con la opcion de canal movil
          var lotes = new bf_rl_loteos().getLotesNotificacion(remate.id_remate, CANAL_MOVIL);
          if (!lotes.Any())
          {
            return;
          }
          string subcategoriasMovil = lotes.Aggregate(string.Empty, (current, lote) => current + lote.id_mosubcategoria + ",");
          if (subcategoriasMovil.Length > 0)
          {
            subcategoriasMovil = subcategoriasMovil.Substring(0, (subcategoriasMovil.Length - 1));
          }
          var usuariosWeb = new bf_ca_usuariosweb().getUsuariosSubcategoriasMovil(subcategoriasMovil);
          //verifico si hay usuario a los que notificar de lo contrario no hago nada
          if (usuariosWeb.Any())
          {
            string nombreCompleto = string.Empty;
            IList<Usuario> usuarios = new List<Usuario>();
            Publicacion publicacion = new Publicacion
            {
              esRemate = true,
              id = remate.id_remate,
              titulo = remate.rem_nombre
            };

            foreach (var usu in usuariosWeb)
            {
              int uuid = usu.id_usuarioWeb;
              nombreCompleto = usu.pe_nombrecompleto;
              usuarios.Add(new Usuario { uuid = uuid.ToString(), nombre = nombreCompleto });
            }
            publicacion.Usuarios = usuarios.ToArray();

            NotificarRequest notificarRequest = new NotificarRequest
            {
              DatosTransaccion = _transaccion,
              Publicacion = publicacion
            };

            NotificarResponse res = notificacion.Notificar(notificarRequest);
            GuardarResponseMovil(res, 0, remate.id_remate, publicacion);
          }
        }
      }
      catch (Exception)
      {
        //throw new Exception(ex.Message);
      }
    }
 private void ObtenerRematesAdicionales(ref IList<co_re_remates> listRemates, co_re_remates remate)
 {
   if (remate.id_familia == Constantes.FAMILIA_BIENESMUEBLES || remate.id_familia == Constantes.FAMILIA_BIENESMUEBLES_VENTADIRECTA)
   {
     listRemates = listRemates.Where(c => c.id_familia == Constantes.FAMILIA_BIENESMUEBLES || c.id_familia == Constantes.FAMILIA_BIENESMUEBLES_VENTADIRECTA).ToList();
   }
   else if (remate.id_familia == Constantes.FAMILIA_PROPIEDADES || remate.id_familia == Constantes.FAMILIA_PROPIEDADES_VENTADIRECTA)
   {
     listRemates = listRemates.Where(c => c.id_familia == Constantes.FAMILIA_PROPIEDADES || c.id_familia == Constantes.FAMILIA_PROPIEDADES_VENTADIRECTA).ToList();
   }
 }
 private int BuscarCategoria(string cat, co_re_remates remate, ref string mensaje)
 {
   if (!string.IsNullOrEmpty(cat))
   {
     co_re_categorias categoria = new bf_re_categorias().GetData(new co_re_categorias { ca_categoria = cat, id_familia = { id = remate.id_familia } }).FirstOrDefault();
     if (categoria != null)
     {
       if (categoria.id != 0)
       {
         return categoria.id;
       }
       else
       {
         mensaje += "Categoria \"" + cat + "\" no Existe. <br>";
       }
     }
     else
     {
       mensaje += "Categoria \"" + cat + "\" no Existe. <br>";
     }
   }
   else { mensaje += "Categoria \"" + cat + "\" no Existe. <br>"; }
   return 0;
 }
    protected void btnGuardar_Click(object sender, DirectEventArgs e)
    {
      try
      {
        string atributosParam = e.ExtraParams["atributos"];
        string fechaRemate = e.ExtraParams["fecha_remate"];
        string fechaFinalRemate = e.ExtraParams["fecha_final_remate"];
        IList<JsonAtributos> atributos = JsonConvert.DeserializeObject<List<JsonAtributos>>(atributosParam);
        List<co_tg_personasremate> listaContactos = new List<co_tg_personasremate>();
        if (ObtenerContactos(out listaContactos))
        {
          if (!string.IsNullOrEmpty(fechaRemate))
          {
            if (fechaRemate.Equals("null"))
            {
              fechaRemate = default(DateTime).ToShortDateString(); 
            }
            else
            {
              fechaRemate = fechaRemate.Substring(0, (fechaRemate.Length - 9));
            }
          }
          else
          {
            fechaRemate = default(DateTime).ToShortDateString();
          }

          if (!string.IsNullOrEmpty(fechaFinalRemate))
          {
            if (fechaFinalRemate.Equals("null"))
            {
              fechaFinalRemate = default(DateTime).ToShortDateString();
            }
            else {
              fechaFinalRemate = fechaFinalRemate.Substring(0, (fechaFinalRemate.Length - 9));
            }
          }
          else {
            fechaFinalRemate = default(DateTime).ToShortDateString();
          }


          string mensaje = ErrorText.REGISTRO_INGRESADO;
          co_re_remates remate = new co_re_remates();
          int id_remate = hidden_id_remate.Text.ValidaEntero(hidden_id_remate.FieldLabel);
          if (id_remate != 0)
          {
            remate = new bf_re_remates().GetData(id_remate);
            mensaje = ErrorText.REGISTRO_MODIFICADO;
          }

          remate.rem_nombre = txtNombre.Text.ToUpper();
          remate.rem_lugarRemate = txtLugarRemate.Text.ToUpper();
          //Presencial Mixto o Internet
          remate.id_tiporemate.id = cmbRemateWeb.SelectedItem.Value.ValidaEntero(cmbRemateWeb.FieldLabel);
          //remate o licitacion
          remate.id_tiporemateLicitacion = cmbTipo.SelectedItem.Value.ValidaEntero(cmbTipo.FieldLabel);
          //familias
          remate.id_familia = cmbFamilias.SelectedItem.Value.ValidaEntero(cmbFamilias.FieldLabel);
          //Estado del remate en Linea siempre sera Esperando Inicio
          remate.id_remateEstado.id =
            cmbEstadoRemateLinea.SelectedItem.Value.ValidaEntero(cmbEstadoRemateLinea.FieldLabel);
          //este siempre sera del tipo REMATE
          remate.id_rematetipo.id = id_rematetipo.Text.ValidaEntero(id_rematetipo.FieldLabel);
          //Estado del remate
          remate.id_remateEstadoWeb.id = cmbEstadoRemate.SelectedItem.Value.ValidaEntero(cmbEstadoRemate.FieldLabel);
          remate.rem_descripcionIng = txtFechaRemate.Value.ToString();

          remate.rem_fecha.Fecha = Convert.ToDateTime(fechaRemate);
          remate.rem_hora.Fecha = Convert.ToDateTime(fechaRemate + " " + txtHoraRemate.Value.ToString());
          remate.rem_descripcion = txtDescripcion.Text.ToUpper();
          remate.rem_exhibicion_texto = txtLugarExhibicion.Text.ToUpper();
          remate.id_moneda.id = 1;
          remate.rem_horaHasta.Fecha = Convert.ToDateTime(fechaFinalRemate + " " + txtHoraFinal.Value.ToString());

          List<co_re_canalesremates> listCanales = ObtenerCanales();
          
          List<co_re_responsables> listResponsables = ObtenerResponsables();

          remate = new bf_re_remates().Save(remate, listaContactos, listCanales, listResponsables, FWPConfiguration.get_ID_User(Session.SessionID));

          if (remate.id != 0)
          {
            GrabarAtributosRemate(remate.id_remate,atributos);
            Mensajes.Show("Mensaje", mensaje, "CloseIframe();", MessageBox.Icon.INFO);
          }
        }
        else
        {
          Mensajes.Error("Por favor asegurese de elegir al menos un contacto.");
        }
      }
      catch (Exception ex)
      {
        Mensajes.Error(ex.Message);
      }
    }
 private static bool EsRemate(co_re_remates remate)
 {
   if (VariableGlobal.ES_VENTA_DIRECTA(remate.id_familia))
   {
     return false;
   }
   if (VariableGlobal.ES_REMATE_LICITACION(remate.id_familia))
   {
     return true;
   }
   return false;
 }