Ejemplo n.º 1
0
        public int InsertPhoto(Photo_Post photo_Post, Group group, Member member)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                MemoryStream ms = new MemoryStream();
                photo_Post.Photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                SqlCommand cmd = new SqlCommand("uspInsertPhoto", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@Photo", ms.ToArray()));
                cmd.Parameters.Add(new SqlParameter("@PhotoName", photo_Post.PhotoName));
                cmd.Parameters.Add(new SqlParameter("@PhotoCaption", photo_Post.PhotoCaption));


                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    connection.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return(postId);
            }
        }
Ejemplo n.º 2
0
        protected void SavePicture(AjaxFileUploadEventArgs file)
        {
            byte[] imageBytes = file.GetContents();
            string fileName   = file.FileName.Split('\\').Last();

            MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);

            // Convert byte[] to Image
            ms.Write(imageBytes, 0, imageBytes.Length);
            System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);

            Photo_Post photoPost = new Photo_Post();
            Group      g         = new Group();
            PostDAL    postDAl   = new PostDAL();

            aMember.MemberId = (string)Session["memberID"];
            g.GroupId        = int.Parse(ThisGroupsID.Value);

            photoPost.Photo        = image;
            photoPost.PhotoName    = fileName;
            photoPost.PhotoCaption = captionP;
            postDAl.InsertPhoto(photoPost, g, aMember);
        }
Ejemplo n.º 3
0
        public ArrayList GetPost(Post post)
        {
            ArrayList custArray;
            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPost", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["EventName"].ToString(), dbReader["EventDetails"].ToString(), dbReader["EventVenue"].ToString(), DateTime.Parse(dbReader["StartDate"].ToString()), DateTime.Parse(dbReader["EndDate"].ToString()), dbReader["Host"].ToString(), dbReader["EventType"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {

                        Photo_Post aCountry = new Photo_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PhotoCaption"].ToString(), dbReader["PhotoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                //else if (post.PostType == "Article")
                //{
                //    while (dbReader.Read())
                //    {
                //        Article_Post aCountry = new Article_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["Title"].ToString(), dbReader["ArticleText"].ToString());
                //        custArray.Add(aCountry);
                //    }
                //}
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["VideoCaption"].ToString(), long.Parse(dbReader["VideoSize"].ToString()), dbReader["VideoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["FileCaption"].ToString(), long.Parse(dbReader["FileSize"].ToString()), dbReader["FileName"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return custArray;
        }
Ejemplo n.º 4
0
        public ArrayList GetPost(Post post)
        {
            ArrayList custArray;

            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPost", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["EventName"].ToString(), dbReader["EventDetails"].ToString(), dbReader["EventVenue"].ToString(), DateTime.Parse(dbReader["StartDate"].ToString()), DateTime.Parse(dbReader["EndDate"].ToString()), dbReader["Host"].ToString(), dbReader["EventType"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {
                        Photo_Post aCountry = new Photo_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PhotoCaption"].ToString(), dbReader["PhotoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                //else if (post.PostType == "Article")
                //{
                //    while (dbReader.Read())
                //    {
                //        Article_Post aCountry = new Article_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["Title"].ToString(), dbReader["ArticleText"].ToString());
                //        custArray.Add(aCountry);
                //    }
                //}
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["VideoCaption"].ToString(), long.Parse(dbReader["VideoSize"].ToString()), dbReader["VideoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["FileCaption"].ToString(), long.Parse(dbReader["FileSize"].ToString()), dbReader["FileName"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return(custArray);
        }
Ejemplo n.º 5
0
        public int InsertPhoto(Photo_Post photo_Post, Group group, Member member)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                MemoryStream ms = new MemoryStream();
                photo_Post.Photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                SqlCommand cmd = new SqlCommand("uspInsertPhoto", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@Photo", ms.ToArray()));
                cmd.Parameters.Add(new SqlParameter("@PhotoName", photo_Post.PhotoName));
                cmd.Parameters.Add(new SqlParameter("@PhotoCaption", photo_Post.PhotoCaption));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    connection.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;

            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Literal title = (Literal)Master.FindControl("pageTitle");

            caption = (HiddenField)Master.FindControl("caption");

            #region NEWSFEED
            MessagesDAL member = new MessagesDAL();
            if (!IsPostBack)
            {
                if (Session["memberID"] == null)
                {
                    Response.Redirect("~/Login.aspx");
                }
                else if (loginDAL.GetMemberStatus(member_Status = new Member_Status(Session["memberID"].ToString())))
                {
                    if (Request.Cookies["login"] != null)
                    {
                        var c = new HttpCookie("login");
                        c.Expires = DateTime.Now.AddDays(-1);
                        Response.Cookies.Add(c);
                        Session.Abandon();
                    }

                    Response.Redirect("~/Login.aspx");
                }
                else if (Session["GroupInfo"] != null)
                {
                    string m = Session["GroupInfo"].ToString();

                    string[] data = m.Split('&');

                    groupID            = int.Parse(data[0]);
                    ThisGroupsID.Value = "" + groupID;
                    title.Text         = data[1];

                    #region RIGHT COLUMN GET 5 JOINEDGROUPS
                    //JOINED GROUPS==============================================================================


                    string memberId = Context.Session["memberID"].ToString();
                    aMember.MemberId = memberId;

                    Reusable_Methods reusable_Methods = new Reusable_Methods(aMember);
                    allgroups = reusable_Methods.RightColumnGet5JoinedGroups();
                    //===========================================================================================
                    #endregion

                    #region NEWS FEED

                    string TabName = "Posts";

                    BulabulaApp.WebServices.postsWebservice posts = new WebServices.postsWebservice();

                    newsfeed = posts.GetTabContents(TabName, groupID, -1);
                    #endregion

                    #region RIGHT COLUMN FRIENDS ONLINE
                    //FRIENDS ONLINE==============================================================================

                    memberId         = Context.Session["memberID"].ToString();
                    aMember.MemberId = memberId;

                    reusable_Methods    = new Reusable_Methods(aMember);
                    FriendsOnlineString = reusable_Methods.RightColumnGetFriendsOnline();

                    //===========================================================================================
                    #endregion
                }
            }//END MAIN if loading for first time
            #endregion

            #region Picture Upload
            if (Request.QueryString["preview"] == "1" && !string.IsNullOrEmpty(Request.QueryString["fileId"]) && uploadType == "Picture")
            {
                var    fileId          = Request.QueryString["fileId"];
                var    fileContentType = (string)Session["fileContentType_" + fileId];
                var    fileName        = (string)Session["fileName_" + fileId];
                byte[] imageBytes      = File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath("~") + "file.png");
                var    fileContents    = imageBytes;

                string ct = (string)Session["fileContentType_" + fileId];
                if (ct.Contains("jpg") || ct.Contains("gif") || ct.Contains("png") || ct.Contains("jpeg"))
                {
                    fileContents = (byte[])Session["fileContents_" + fileId];
                }



                MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
                // Convert byte[] to Image
                ms.Write(imageBytes, 0, imageBytes.Length);
                System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);

                Photo_Post photoPost = new Photo_Post();
                Group      g         = new Group();
                PostDAL    postDAl   = new PostDAL();

                aMember.MemberId = "5ZMjMHEwVN7GyJ2miPDjeQ==";
                g.GroupId        = 1;

                photoPost.Photo        = image;
                photoPost.PhotoName    = fileName;
                photoPost.PhotoCaption = "STeVO";

                postDAl.InsertPhoto(photoPost, g, aMember);
                Response.Clear();
                Response.ContentType = fileContentType;
                Response.BinaryWrite(fileContents);
                Response.End();
            }

            #endregion

            #region Video Upload

            if (Request.QueryString["preview"] == "1" && !string.IsNullOrEmpty(Request.QueryString["fileId"]) && uploadType == "Video")
            {
                var    videoFileId          = Request.QueryString["fileId"];
                var    videofileContentType = (string)Session["fileContentType_" + videoFileId];
                var    videofileName        = (string)Session["fileName_" + videoFileId];
                byte[] videoBytes           = File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath("~") + "file.png");
                var    videofileContents    = videoBytes;

                string ct = (string)Session["fileContentType_" + videoFileId];
                if (ct.Contains("mp4") || ct.Contains("mov") || ct.Contains("vlc") || ct.Contains("avi") || ct.Contains("jpeg"))
                {
                    videofileContents = (byte[])Session["fileContents_" + videoFileId];
                }



                //  MemoryStream vs = new MemoryStream(videoBytes, 0, videoBytes.Length);
                // Convert byte[] to Image
                //vs.Write(videoBytes, 0, videoBytes.Length);
                //System.Drawing.Image image = System.Drawing.Image.FromStream(vs, true);

                Video_Post videoPost = new Video_Post();
                Group      g         = new Group();
                PostDAL    postDAl   = new PostDAL();

                aMember.MemberId = "5ZMjMHEwVN7GyJ2miPDjeQ==";
                g.GroupId        = 1;

                videoPost.Video        = videoBytes;
                videoPost.VideoName    = videofileName;
                videoPost.VideoCaption = "STeVO";
                //videoPost.VideoSize =


                //postDAl.InsertPhoto1(photoPost, g, aMember);
                postDAl.InsertVideo(videoPost, g, aMember);



                //Response.Clear();
                //Response.ContentType = fileContentType;
                //Response.BinaryWrite(fileContents);
                //Response.End();
            }


            #endregion
        }
Ejemplo n.º 7
0
        public ArrayList GetPostCaption(Post post)
        {
            ArrayList custArray;
            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPostCaption", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(dbReader["EventName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {
                        Photo_Post aCountry = new Photo_Post(dbReader["PhotoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Article")
                {
                    while (dbReader.Read())
                    {
                        Article_Post aCountry = new Article_Post(dbReader["Title"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(dbReader["VideoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(dbReader["FileCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return custArray;
        }
Ejemplo n.º 8
0
        public ArrayList GetPostCaption(Post post)
        {
            ArrayList custArray;

            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPostCaption", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(dbReader["EventName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {
                        Photo_Post aCountry = new Photo_Post(dbReader["PhotoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Article")
                {
                    while (dbReader.Read())
                    {
                        Article_Post aCountry = new Article_Post(dbReader["Title"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(dbReader["VideoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(dbReader["FileCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return(custArray);
        }