Exemplo n.º 1
0
        /***********************************************************
         * Description: Get the list of:							    *
         *                Publication (Title,Interpretation,State),	*
         *				  Image_Publication (imageData),			*
         *				  Resources (source)						*
         ************************************************************
         * Author: Alex Villegas Carranza							*
         *************************************************************
         * Parameters:  @idSection									*
         ************************************************************/

        public static List <ClimaticPublication> getPublicationBySection(int idSection)
        {
            Connection();
            try
            {
                using (SqlCommand cmd = new SqlCommand("sp_getPublicationBySection", _con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@idSection", idSection);
                    _con.Open();
                    SqlDataReader reader            = cmd.ExecuteReader();
                    List <ClimaticPublication> list = new List <ClimaticPublication>();
                    ClimaticPublication        item;
                    while (reader.Read())
                    {
                        item                = new ClimaticPublication();
                        item.title          = Convert.ToString(reader["title"]);
                        item.source         = Convert.ToString(reader["source"]);
                        item.State          = Convert.ToByte(reader["pubState"]);
                        item.Scrap          = Convert.ToByte(reader["Scrap"]);
                        item.OriginalURL    = Convert.ToString(reader["OriginalURL"]);
                        item.interpretation = reader["interpretation"].ToString();
                        item.img            = reader["imageData"].ToString().Replace("\"", "");
                        item.idPublication  = Convert.ToInt32(reader["idPub"]);
                        item.idDisplayMode  = Convert.ToInt32(reader["idDisplayMode"]);


                        //IF ScrapSettings has values
                        if (item.Scrap == 1)
                        {
                            int nodeIndex;
                            Int32.TryParse(reader["nodeIndex"].ToString(), out nodeIndex);
                            item.nodeIndex = nodeIndex;
                            item.tagType   = Convert.ToString(reader["tagType"]);
                        }

                        list.Add(item);
                    }

                    return(list);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (_con.State == ConnectionState.Open)
                {
                    _con.Close();
                }
            }
        }
Exemplo n.º 2
0
        public static Boolean setPublicationInfo_Source(ClimaticPublication pub)
        {
            Connection();
            try
            {
                using (SqlCommand cmd = new SqlCommand("sp_updateClimaticPublication_source", _con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@idPub", pub.idPublication);
                    cmd.Parameters.AddWithValue("@title", pub.title);
                    cmd.Parameters.AddWithValue("@interpretation", pub.interpretation);
                    cmd.Parameters.AddWithValue("@state", pub.State);
                    cmd.Parameters.AddWithValue("@source", pub.source);
                    //
                    //EMAIL  just for test
                    cmd.Parameters.AddWithValue("@email", "ND");//current user, must be fixedd!

                    if (pub.img == null)
                    {
                        cmd.Parameters.Add("@imageData", SqlDbType.VarBinary, -1);
                        cmd.Parameters["@imageData"].Value = DBNull.Value;
                    }

                    else
                    {
                        cmd.Parameters.AddWithValue("@imageData", pub.img);
                    }


                    _con.Open();
                    int n = cmd.ExecuteNonQuery();
                    return(n >= 1);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (_con.State == ConnectionState.Open)
                {
                    _con.Close();
                }
            }
        }
Exemplo n.º 3
0
 public static String setInterviewPublicationInfo(ClimaticPublication pub)
 {
     return(DBcontext.setInterviewPublicationInfo(pub));
 }
Exemplo n.º 4
0
 public static Boolean setPublicationInfo_Source(ClimaticPublication pub)
 {
     return(DBcontext.setPublicationInfo_Source(pub));
 }