예제 #1
0
        public void usernotificationsNumber(int userId)
        {
            Classes.UserInfo      ui     = new Classes.UserInfo();
            Tuple <int, int, int> result = ui.notificationsNumber(userId);

            int messagesNumber      = result.Item1;
            int notificationsNumber = result.Item2;
            int requestsNumber      = result.Item3;

            var context = GlobalHost.ConnectionManager.GetHubContext <ChatHub>();

            context.Clients.Group(userId.ToString()).updateNotificationNumbers(messagesNumber.ToString(), notificationsNumber.ToString(), requestsNumber.ToString());
            // text, notificationType, notificationid,notificationLink, unread(boool)
            //context.Clients.Group(userId.ToString()).receiveNotification("text", 10, 10, "profile/4", true);
        }
예제 #2
0
파일: Invite.cs 프로젝트: m3hrad/CityCrowd
        public int inviteSend(int userId, string email)
        {
            int status = 0;

            Classes.UserInfo ui = new Classes.UserInfo();
            string userFullName = ui.getUserFullNameByUserId(userId);

            string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
            string link = siteLink + "Register/" + userId.ToString();
            Classes.Mail m = new Classes.Mail();
            int status2 = m.sendMail("invite", email,
                "Hi, " + userFullName + " invited you to join CityCrowd.<br/><a href='"
                + link + "'>CLICK HERE</a> to join your friend and other CityCrowders.<br/><br/>CityCowd Team", userFullName);

            status = 1;

            return status;
        }
예제 #3
0
파일: Invite.cs 프로젝트: m3hrad/CityCrowd
        public int inviteSend(int userId, string email)
        {
            int status = 0;

            Classes.UserInfo ui           = new Classes.UserInfo();
            string           userFullName = ui.getUserFullNameByUserId(userId);

            string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
            string link     = siteLink + "Register/" + userId.ToString();

            Classes.Mail m       = new Classes.Mail();
            int          status2 = m.sendMail("invite", email,
                                              "Hi, " + userFullName + " invited you to join CityCrowd.<br/><a href='"
                                              + link + "'>CLICK HERE</a> to join your friend and other CityCrowders.<br/><br/>CityCowd Team", userFullName);

            status = 1;

            return(status);
        }
예제 #4
0
        public Tuple<int, string, int> register(string email, string password1, string password2)
        {
            int status = 0;
            string message = "";
            int userId = 0;

            if (password1.Length == 0) // check if email entered blank
            {
                status = -1;
                message = "Enter email address!";
            }
            else // check if email is correct
            {
                string expression = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" + @"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" + @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";

                Match match = Regex.Match(email, expression, RegexOptions.IgnoreCase);
                if (!match.Success)
                {
                    status = -1;
                    message = "Email address is not correct!";
                }
                else
                {
                    if (password1.Length == 0) // check if password is blank
                    {
                        status = -1;
                        message = "Enter password!";
                    }
                    else
                    {
                        if (password1.Length < 4) // check if password is less than 4 characters
                        {
                            status = -1;
                            message = "Password must be at least 4 characters!";
                        }
                        else
                        {
                            if (password1 != password2) // check if password and retype password are the same
                            {
                                status = -1;
                                message = "Password and retype password must be the same!";
                            }
                            else
                            {
                                Classes.UserInfo ui = new Classes.UserInfo();
                                int UserId = ui.getUserIdByEmail(email);
                                if (UserId != 0) //user registered before
                                {
                                    status = -1;
                                    message = "Email address already registered before!";
                                }
                                else
                                {
                                    SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                                    SqlCommand sqlCmd = new SqlCommand("sp_register", sqlConn);
                                    sqlCmd.CommandType = CommandType.StoredProcedure;
                                    sqlCmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;
                                    sqlCmd.Parameters.Add("@Password", SqlDbType.NVarChar).Value = password1;
                                    sqlCmd.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = Convert.ToString(Guid.NewGuid());

                                    try
                                    {
                                        sqlConn.Open();
                                        sqlCmd.ExecuteNonQuery();
                                    }
                                    catch
                                    {

                                    }
                                    finally
                                    {
                                        sqlConn.Close();
                                        sqlConn.Dispose();
                                        sqlCmd.Dispose();
                                    }

                                    status = 1;
                                }
                            }
                        }
                    }
                }
            }

            return new Tuple<int, string, int>(status, message, userId);
        }
예제 #5
0
        public Int16 username(int userId, string username)
        {
            Int16 status = 0; //0 user entered it's own username -1 exists before -2 username not valid -3 no special char -4 enter username 1 successful

            //check username valid
            Regex RgxUrl = new Regex("[^a-zA-Z]");

            if (Regex.Matches(username, @"[a-zA-Z]").Count == 0)
            {
                status = -2;
            }
            else
            {
                //special symbols
                RgxUrl = new Regex("[^a-zA-Z0-9]");

                if (RgxUrl.IsMatch(username))
                {
                    status = -3;
                }
                else
                {
                    //empty
                    if (username.Length == 0)
                    {
                        status = -4;
                    }
                    else
                    {
                        //check if it's own username
                        Classes.UserInfo ui = new Classes.UserInfo();
                        string           currentUsername = ui.getUsernameByUserId(userId);

                        if (currentUsername == username)
                        {
                            status = 0;
                        }
                        else
                        {
                            //check username exists
                            bool usernameExists = ui.checkUsernameExists(username);

                            if (usernameExists)
                            {
                                status = -1;
                            }
                            else
                            {
                                status = 1;

                                SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                                SqlCommand    sqlCmd  = new SqlCommand("sp_settingsUsernameSet", sqlConn);
                                sqlCmd.CommandType = CommandType.StoredProcedure;
                                sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value       = userId;
                                sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = username;

                                //try
                                //{
                                sqlConn.Open();
                                sqlCmd.ExecuteNonQuery();
                                //}
                                //catch (Exception ex)
                                //{

                                //}
                                //finally
                                //{
                                sqlConn.Close();
                                sqlCmd.Dispose();
                                sqlConn.Dispose();
                                //}
                            }
                        }
                    }
                }
            }

            return(status);
        }
예제 #6
0
        public Int16 completion(int userId, string username, string firstName, string lastName, Int16 gender, int locationId, string birthDate, bool hasPhoto)
        {
            Int16 status = 0;

            //check username valid
            Regex RgxUrl = new Regex("[^a-zA-Z]");

            if (Regex.Matches(username, @"[a-zA-Z]").Count == 0)
            {
                status = -2;
            }
            else
            {
                //special symbols
                RgxUrl = new Regex("[^a-zA-Z0-9]");

                if (RgxUrl.IsMatch(username))
                {
                    status = -3;
                }
                else
                {
                    //check username exists
                    Classes.UserInfo ui             = new Classes.UserInfo();
                    bool             usernameExists = ui.checkUsernameExists(username);

                    if (usernameExists)
                    {
                        status = -1;
                    }
                    else
                    {
                        status = 1;

                        SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                        SqlCommand    sqlCmd  = new SqlCommand("sp_completion", sqlConn);
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value         = userId;
                        sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value   = username;
                        sqlCmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = firstName;
                        sqlCmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value  = lastName;
                        sqlCmd.Parameters.Add("@Gender", SqlDbType.TinyInt).Value     = gender;
                        sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value     = locationId;
                        sqlCmd.Parameters.Add("@BirthDate", SqlDbType.Date).Value     = Convert.ToDateTime(birthDate);//Convert.ToDateTime(dob);
                        sqlCmd.Parameters.Add("@HasPhoto", SqlDbType.Bit).Value       = hasPhoto;

                        //try
                        //{
                        sqlConn.Open();
                        sqlCmd.ExecuteNonQuery();
                        //}
                        //catch (Exception ex)
                        //{

                        //}
                        //finally
                        //{
                        sqlConn.Close();
                        sqlCmd.Dispose();
                        sqlConn.Dispose();
                        //}

                        Classes.Notifications n = new Classes.Notifications();
                        n.notificationAdd(userId, 1, Convert.ToInt64(userId));

                        string email    = ui.getEmailByUserId(userId);
                        string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                        string link     = siteLink;
                        string message  = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                                          + link + "'>CLICK HERE</a> to visit the website.<br/><br/>CityCowd Team";

                        if (!ui.isUserEmailVerified(userId))
                        {
                            string        VCode    = Convert.ToString(Guid.NewGuid());
                            SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                            SqlCommand    sqlCmd2  = new SqlCommand("sp_verifyEmailAdd", sqlConn2);
                            sqlCmd2.CommandType = CommandType.StoredProcedure;
                            sqlCmd2.Parameters.Add("@UserId", SqlDbType.Int).Value     = userId;
                            sqlCmd2.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode;

                            sqlConn2.Open();
                            sqlCmd2.ExecuteNonQuery();

                            link    = siteLink + "Verify/Email/" + VCode;
                            message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                                      + link + "'>CLICK HERE</a> to verify your email address and visit the website.<br/><br/>CityCowd Team";
                        }

                        Classes.Mail m       = new Classes.Mail();
                        int          status2 = m.sendMail("register", email,
                                                          "Hi, " + firstName + message, "");
                    }
                }
            }

            return(status);
        }
예제 #7
0
        public Tuple <int, string, int> register(string email, string password1, string password2, int inviteId)
        {
            int    status  = 0;
            string message = "";
            int    userId  = 0;

            if (password1.Length == 0) // check if email entered blank
            {
                status  = -1;
                message = "Enter email address!";
            }
            else // check if email is correct
            {
                string expression = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" + @"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" + @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";

                Match match = Regex.Match(email, expression, RegexOptions.IgnoreCase);
                if (!match.Success)
                {
                    status  = -1;
                    message = "Email address is not correct!";
                }
                else
                {
                    if (password1.Length == 0) // check if password is blank
                    {
                        status  = -1;
                        message = "Enter password!";
                    }
                    else
                    {
                        if (password1.Length < 4) // check if password is less than 4 characters
                        {
                            status  = -1;
                            message = "Password must be at least 4 characters!";
                        }
                        else
                        {
                            if (password1 != password2) // check if password and retype password are the same
                            {
                                status  = -1;
                                message = "Password and retype password must be the same!";
                            }
                            else
                            {
                                Classes.UserInfo ui = new Classes.UserInfo();
                                int UserId          = ui.getUserIdByEmail(email);
                                if (UserId != 0) //user registered before
                                {
                                    status  = -1;
                                    message = "Email address already registered before!";
                                }
                                else
                                {
                                    SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                                    SqlCommand    sqlCmd  = new SqlCommand("sp_register", sqlConn);
                                    sqlCmd.CommandType = CommandType.StoredProcedure;
                                    sqlCmd.Parameters.Add("@Email", SqlDbType.VarChar).Value     = email;
                                    sqlCmd.Parameters.Add("@Password", SqlDbType.NVarChar).Value = password1;
                                    sqlCmd.Parameters.Add("@VCode", SqlDbType.NVarChar).Value    = Convert.ToString(Guid.NewGuid());
                                    sqlCmd.Parameters.Add("@InviteId", SqlDbType.Int).Value      = inviteId;

                                    //try
                                    //{
                                    sqlConn.Open();
                                    sqlCmd.ExecuteNonQuery();
                                    //}
                                    //catch
                                    //{

                                    //}
                                    //finally
                                    //{
                                    sqlConn.Close();
                                    sqlConn.Dispose();
                                    sqlCmd.Dispose();
                                    //}

                                    status = 1;
                                }
                            }
                        }
                    }
                }
            }

            return(new Tuple <int, string, int>(status, message, userId));
        }
예제 #8
0
        public int eventAdd(int userId, string name, string date, int participants, int locationId, string address, Int16 typeId, Int16 coverId, string descriptions)
        {
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlCommand    sqlCmd  = new SqlCommand("sp_eventAdd", sqlConn);

            sqlCmd.CommandType = CommandType.StoredProcedure;
            // user id
            sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
            // name +max 50
            sqlCmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = name;
            // date +add time
            sqlCmd.Parameters.Add("@Date", SqlDbType.SmallDateTime).Value = date;
            // participants +limit
            sqlCmd.Parameters.Add("@Participants", SqlDbType.Int).Value = participants;
            // location +near own location or trip
            sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId;
            // location +near own location or trip
            sqlCmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = address;
            // type id +limit
            sqlCmd.Parameters.Add("@TypeId", SqlDbType.SmallInt).Value = typeId;
            // type id +limit
            sqlCmd.Parameters.Add("@CoverId", SqlDbType.SmallInt).Value = coverId;
            // descriptions +limit to max
            sqlCmd.Parameters.Add("@Descriptions", SqlDbType.NVarChar).Value = descriptions;

            //try
            //{
            sqlConn.Open();
            sqlCmd.ExecuteNonQuery();
            //}
            //catch
            //{

            //}
            //finally
            //{
            sqlConn.Close();
            sqlConn.Dispose();
            sqlCmd.Dispose();
            //}

            string[] hashtags = Regex.Matches(descriptions, @"\#\w*").Cast <Match>().Select(m => m.Value).ToArray();

            if (hashtags.Length > 0)
            {
                Classes.UserInfo ui          = new Classes.UserInfo();
                Int64            lastEventId = ui.getLastEvent(userId);

                DataTable dtTags = new DataTable();
                DataRow   drTags = null;

                //define the columns
                dtTags.Columns.Add(new DataColumn("EventId", typeof(Int64)));
                dtTags.Columns.Add(new DataColumn("LocationId", typeof(Int32)));
                dtTags.Columns.Add(new DataColumn("Hashtag", typeof(string)));
                dtTags.Columns.Add(new DataColumn("ExpireDate", typeof(string)));

                for (int i = 0; i < hashtags.Length; i++)
                {
                    //create new row
                    drTags = dtTags.NewRow();

                    //add values to each rows
                    drTags["EventId"]    = lastEventId;
                    drTags["LocationId"] = locationId;
                    drTags["Hashtag"]    = hashtags[i].Replace("#", "");
                    drTags["ExpireDate"] = date;

                    //add the row to DataTable
                    dtTags.Rows.Add(drTags);
                }

                SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                SqlCommand    sqlCmd2  = new SqlCommand("sp_eventAddHashtagsAdd", sqlConn2);
                sqlCmd2.CommandType = CommandType.StoredProcedure;
                sqlCmd2.Parameters.Add("@HashtagsTable", dtTags);

                //try
                //{
                sqlConn2.Open();
                sqlCmd2.ExecuteNonQuery();
                //}
                //catch
                //{

                //}
                //finally
                //{
                sqlConn2.Close();
                sqlConn2.Dispose();
                sqlCmd2.Dispose();
                //}
            }

            return(1);
        }
예제 #9
0
        public Int16 username(int userId, string username)
        {
            Int16 status = 0; //0 user entered it's own username -1 exists before -2 username not valid -3 no special char -4 enter username 1 successful

            //check username valid
            Regex RgxUrl = new Regex("[^a-zA-Z]");
            if (Regex.Matches(username, @"[a-zA-Z]").Count == 0)
            {
                status = -2;
            }
            else
            {
                //special symbols
                RgxUrl = new Regex("[^a-zA-Z0-9]");

                if (RgxUrl.IsMatch(username))
                {
                    status = -3;
                }
                else
                {
                    
                    //empty
                    if (username.Length == 0)
                    {
                        status = -4;
                    }
                    else
                    {
                        //check if it's own username
                        Classes.UserInfo ui = new Classes.UserInfo();
                        string currentUsername = ui.getUsernameByUserId(userId);

                        if (currentUsername == username)
                        {
                            status = 0;
                        }
                        else
                        {
                            //check username exists
                            bool usernameExists = ui.checkUsernameExists(username);

                            if (usernameExists)
                            {
                                status = -1;
                            }
                            else
                            {
                                status = 1;

                                SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                                SqlCommand sqlCmd = new SqlCommand("sp_settingsUsernameSet", sqlConn);
                                sqlCmd.CommandType = CommandType.StoredProcedure;
                                sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
                                sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = username;

                                //try
                                //{
                                    sqlConn.Open();
                                    sqlCmd.ExecuteNonQuery();
                                //}
                                //catch (Exception ex)
                                //{

                                //}
                                //finally
                                //{
                                    sqlConn.Close();
                                    sqlCmd.Dispose();
                                    sqlConn.Dispose();
                                //}
                            }
                        }
                    }
                }
            }

            return status;
        }
예제 #10
0
        public Int16 completion(int userId, string username, string firstName, string lastName, Int16 gender, int locationId, string birthDate, bool hasPhoto)
        {
            Int16 status = 0;

            //check username valid
            Regex RgxUrl = new Regex("[^a-zA-Z]");
            if (Regex.Matches(username, @"[a-zA-Z]").Count == 0)
            {
                status = -2;
            }
            else
            {
                //special symbols
                RgxUrl = new Regex("[^a-zA-Z0-9]");

                if (RgxUrl.IsMatch(username))
                {
                    status = -3;
                }
                else
                {

                    //check username exists
                    Classes.UserInfo ui = new Classes.UserInfo();
                    bool usernameExists = ui.checkUsernameExists(username);

                    if (usernameExists)
                    {
                        status = -1;
                    }
                    else
                    {
                        status = 1;

                        SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                        SqlCommand sqlCmd = new SqlCommand("sp_completion", sqlConn);
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
                        sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = username;
                        sqlCmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = firstName;
                        sqlCmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = lastName;
                        sqlCmd.Parameters.Add("@Gender", SqlDbType.TinyInt).Value = gender;
                        sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId;
                        sqlCmd.Parameters.Add("@BirthDate", SqlDbType.Date).Value = Convert.ToDateTime(birthDate);//Convert.ToDateTime(dob);
                        sqlCmd.Parameters.Add("@HasPhoto", SqlDbType.Bit).Value = hasPhoto;

                        //try
                        //{
                            sqlConn.Open();
                            sqlCmd.ExecuteNonQuery();
                        //}
                        //catch (Exception ex)
                        //{

                        //}
                        //finally
                        //{
                            sqlConn.Close();
                            sqlCmd.Dispose();
                            sqlConn.Dispose();
                        //}

                        Classes.Notifications n = new Classes.Notifications();
                        n.notificationAdd(userId, 1, Convert.ToInt64(userId));

                        string email = ui.getEmailByUserId(userId);
                        string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                        string link = siteLink;
                        string message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                            + link + "'>CLICK HERE</a> to visit the website.<br/><br/>CityCowd Team";

                        if(!ui.isUserEmailVerified(userId))
                        {
                            string VCode = Convert.ToString(Guid.NewGuid());
                            SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                            SqlCommand sqlCmd2 = new SqlCommand("sp_verifyEmailAdd", sqlConn2);
                            sqlCmd2.CommandType = CommandType.StoredProcedure;
                            sqlCmd2.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
                            sqlCmd2.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode;

                            sqlConn2.Open();
                            sqlCmd2.ExecuteNonQuery();

                            link = siteLink + "Verify/Email/" + VCode;
                            message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                            + link + "'>CLICK HERE</a> to verify your email address and visit the website.<br/><br/>CityCowd Team";
                        }
                        
                        Classes.Mail m = new Classes.Mail();
                        int status2 = m.sendMail("register", email,
                            "Hi, " + firstName + message, "");
                    }
                }
            }

            return status;
        }
예제 #11
0
        public EventObjectAll eventsFollowing(int userId, Int64 eventId)
        {
            EventObjectAll allObjects = new EventObjectAll();

            if (eventId == 0)
            {
                eventId = 99999999;
            }

            Classes.UserInfo ui = new Classes.UserInfo();
            int locationId      = ui.locationIdByUserId(userId);

            DataTable      dt      = new DataTable();
            DataSet        ds      = new DataSet();
            SqlConnection  sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda     = new SqlDataAdapter("sp_followingEvents", sqlConn);

            sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value     = userId;
            sda.SelectCommand.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId;

            //try
            //{
            sda.Fill(ds);
            dt = ds.Tables[0];
            //}
            //catch (Exception ex)
            //{

            //}
            //finally
            //{
            sqlConn.Close();
            sda.Dispose();
            sqlConn.Dispose();
            //}

            if (dt.Rows.Count == 0)
            {
                return(allObjects);
            }
            else
            {
                Classes.Date   d = new Classes.Date();
                Classes.Nearby n = new Classes.Nearby();

                EventObject object1 = new EventObject();
                EventObject object2 = new EventObject();
                EventObject object3 = new EventObject();
                EventObject object4 = new EventObject();
                EventObject object5 = new EventObject();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string            Location   = "";
                    Classes.Locations l          = new Classes.Locations();
                    DataTable         dtLocation = l.getLocationInfoByCityId(Convert.ToInt32(dt.Rows[i]["LocationId"].ToString()));
                    if (dtLocation.Rows.Count == 0)
                    {
                        Location = "Not Available!";
                    }
                    else
                    {
                        Location = dtLocation.Rows[0]["CountryName"].ToString() + " - " + dtLocation.Rows[0]["CityName"].ToString();
                    }

                    // Show profile's photo
                    string profilePicUrl;
                    if (Convert.ToBoolean(dt.Rows[i]["HasPhoto"].ToString()))
                    {
                        profilePicUrl = "Files/ProfilesPhotos/" + dt.Rows[i]["OwnerId"].ToString() + "-100.jpg";
                    }
                    else
                    {
                        profilePicUrl = "Images/nophoto.png";
                    }

                    // Rate
                    int rate           = 0;
                    int rateSufficient = Convert.ToInt32(ConfigurationManager.AppSettings["RateSufficient"].ToString());
                    int rateCount      = Convert.ToInt32(dt.Rows[i]["rateCount"].ToString());
                    int rateScore      = Convert.ToInt32(dt.Rows[i]["rateScore"].ToString());
                    if (rateCount >= rateSufficient)
                    {
                        rate = (20 * rateScore) / rateCount;
                    }

                    EventObject myEventObject = new EventObject(
                        Convert.ToInt64(dt.Rows[i]["EventId"].ToString()),
                        dt.Rows[i]["Name"].ToString(),
                        d.FormatRemainedDate(dt.Rows[i]["Date"].ToString()),
                        Convert.ToInt16(dt.Rows[i]["TypeId"].ToString()),
                        Convert.ToInt16(dt.Rows[i]["CoverId"].ToString()),
                        Convert.ToInt32(dt.Rows[i]["OwnerId"].ToString()),
                        Location,
                        rate,
                        dt.Rows[i]["OwnerName"].ToString(),
                        Convert.ToInt32(dt.Rows[i]["Participants"].ToString() + 1),
                        Convert.ToInt32(dt.Rows[i]["ParticipantsAccepted"].ToString() + 1),
                        profilePicUrl);

                    switch (i)
                    {
                    case 0:
                    {
                        object1 = myEventObject;
                        break;
                    }

                    case 1:
                    {
                        object2 = myEventObject;
                        break;
                    }

                    case 2:
                    {
                        object3 = myEventObject;
                        break;
                    }

                    case 3:
                    {
                        object4 = myEventObject;
                        break;
                    }

                    case 4:
                    {
                        object5 = myEventObject;
                        break;
                    }
                    }

                    allObjects = new EventObjectAll(
                        object1,
                        object2,
                        object3,
                        object4,
                        object5);
                }

                return(allObjects);
            }
        }
예제 #12
0
파일: Done.cs 프로젝트: m3hrad/CityCrowd
        public DoneObject getDone(string type, int userId, Int64 eventId)
        {
            Boolean donestatus = false;
            string smiley = "";
            string title = "";
            string message = "";
            Int16 number = 0;
            string item1text = "";
            string item1url = "";
            string item1image = "";
            string item1color = "";
            string item2text = "";
            string item2url = "";
            string item2image = "";
            string item2color = "";
            string item3text = "";
            string item3url = "";
            string item3image = "";
            string item3color = "";
            string item4text = "";
            string item4url = "";
            string item4image = "";
            string item4color = "";

            switch (type.ToLower())
            {
                case "welcome":
                    {
                        title = "Welcome!";
                        smiley = ":)";
                        message = doneMessage("welcome");
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("A", "");
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("K", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("B", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("F", "");
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "register":
                    {
                        title = "Congratulations!";
                        smiley = ":)";
                        message = "Congratulations! You are now a CityCrowder!";
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("B", "");
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("A", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("F", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("C", "");
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "eventadded":
                    {
                        Classes.UserInfo ui = new Classes.UserInfo();
                        Int64 value = ui.getLastEvent(userId);

                        title = "Done!";
                        smiley = ":)";
                        message = doneMessage("eventadded");
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("H", value.ToString());
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("A", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("B", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("J", value.ToString());
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "eventmodified":
                    {
                        Classes.UserInfo ui = new Classes.UserInfo();
                        Int64 value = ui.getLastEvent(userId);

                        title = "Done!";
                        smiley = ":)";
                        message = doneMessage("eventmodified");
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("A", "");
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("H", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("E", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("J", value.ToString());
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "eventdeleted":
                    {
                        title = "Done!";
                        smiley = ":)";
                        message = doneMessage("eventdeleted");
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("A", "");
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("B", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("E", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("F", "");
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "reportsent":
                    {
                        title = "Done!";
                        smiley = ":)";
                        message = doneMessage("reportsent");
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("A", "");
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("B", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("E", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("F", "");
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "reviewsubmited":
                    {
                        title = "Done!";
                        smiley = ":)";
                        message = doneMessage("reviewsubmited");
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("A", "");
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("B", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("C", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("F", "");
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "feedbacksubmited":
                    {
                        title = "Done!";
                        smiley = ":)";
                        message = doneMessage("feedbacksubmited");
                        number = 4;

                        Tuple<string, string, string, string> result = doneItem("A", "");
                        item1text = result.Item1;
                        item1url = result.Item2;
                        item1image = result.Item3;
                        item1color = result.Item4;

                        result = doneItem("C", "");
                        item2text = result.Item1;
                        item2url = result.Item2;
                        item2image = result.Item3;
                        item2color = result.Item4;

                        result = doneItem("B", "");
                        item3text = result.Item1;
                        item3url = result.Item2;
                        item3image = result.Item3;
                        item3color = result.Item4;

                        result = doneItem("K", "");
                        item4text = result.Item1;
                        item4url = result.Item2;
                        item4image = result.Item3;
                        item4color = result.Item4;

                        break;
                    }
                case "reviewsempty":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Reviews";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("C", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("E", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "explore":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Explore";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("C", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("E", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "nearby":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Nearby";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("C", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("E", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("F", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "requests0":
                case "requests2":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Requests";
                        message = doneMessage(type);
                        number = 1;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;
                        break;
                    }
                case "eventscreated":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Events";
                        message = doneMessage(type);
                        number = 1;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;
                        break;
                    }
                case "eventsaccepted":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Events";
                        message = doneMessage(type);
                        number = 1;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;
                        break;
                    }
                case "eventsrequested":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Events";
                        message = doneMessage(type);
                        number = 1;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;
                        break;
                    }
                case "eventsbookmarked":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Events";
                        message = doneMessage(type);
                        number = 1;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;
                        break;
                    }
                case "emailverified":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Email Verified";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("C", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("F", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                    /////////////////////////////// ERROR
                case "404":
                    {
                        donestatus = true;
                        smiley = ":|";
                        title = "Error";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("G", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("K", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("E", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "emailverificationfailed":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Verification Failed";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("C", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("F", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "noprofile":
                    {
                        donestatus = true;
                        smiley = ":|";
                        title = "Error";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("G", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("K", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("E", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "restrictedprofile":
                    {
                        donestatus = true;
                        smiley = ":|";
                        title = "Error";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("K", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("E", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "eventnotfound":
                    {
                        donestatus = true;
                        smiley = ":|";
                        title = "Error";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("E", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("B", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("K", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "usernoteventowner":
                    {
                        donestatus = true;
                        smiley = ":|";
                        title = "Error";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("E", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("B", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("K", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
                case "prequestnotfound":
                    {
                        donestatus = true;
                        smiley = ":|";
                        title = "Error";
                        message = doneMessage(type);
                        number = 2;

                        Tuple<string, string, string, string> result1 = doneItem("L", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("M", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;
                        break;
                    }
                case "following":
                    {
                        donestatus = true;
                        smiley = ":)";
                        title = "Following";
                        message = doneMessage(type);
                        number = 4;

                        Tuple<string, string, string, string> result1 = doneItem("A", "");
                        item1text = result1.Item1;
                        item1url = result1.Item2;
                        item1image = result1.Item3;
                        item1color = result1.Item4;

                        Tuple<string, string, string, string> result2 = doneItem("B", "");
                        item2text = result2.Item1;
                        item2url = result2.Item2;
                        item2image = result2.Item3;
                        item2color = result2.Item4;

                        Tuple<string, string, string, string> result3 = doneItem("K", "");
                        item3text = result3.Item1;
                        item3url = result3.Item2;
                        item3image = result3.Item3;
                        item3color = result3.Item4;

                        Tuple<string, string, string, string> result4 = doneItem("C", "");
                        item4text = result4.Item1;
                        item4url = result4.Item2;
                        item4image = result4.Item3;
                        item4color = result4.Item4;
                        break;
                    }
            }

            DoneObject myDoneObject = new DoneObject(
                donestatus, smiley, title, message, number,
                item1text, item1url, item1image, item1color,
                item2text, item2url, item2image, item2color,
                item3text, item3url, item3image, item3color,
                item4text, item4url, item4image, item4color);

            return myDoneObject;
        }
예제 #13
0
파일: Nearby.cs 프로젝트: m3hrad/CityCrowd
        public EventObjectAll eventsCity(int userId, Int64 eventId, int mode)
        {
            EventObjectAll allObjects = new EventObjectAll();

            string spName = "";
            int days = 0;

            if (eventId == 0)
            {
                eventId = 99999999;
            }

            if (mode == 1)
            {
                spName = "sp_nearbyCityAll";
            }
            else if (mode == 2)//day
            {
                spName = "sp_nearbyCityDate";
                days = 1;
            }
            else if (mode == 3)//week
            {
                spName = "sp_nearbyCityDate";
                days = 7;
            }
            else if (mode == 4)//month
            {
                spName = "sp_nearbyCityDate";
                days = 31;
            }

            Classes.UserInfo ui = new Classes.UserInfo();
            int locationId = ui.locationIdByUserId(userId);

            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda = new SqlDataAdapter(spName, sqlConn);

            sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda.SelectCommand.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId;
            sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
            sda.SelectCommand.Parameters.Add("@EventId", SqlDbType.BigInt).Value = eventId;
            sda.SelectCommand.Parameters.Add("@Days", SqlDbType.SmallInt).Value = days;

            //try
            //{
                sda.Fill(ds);
                dt = ds.Tables[0];
            //}
            //catch (Exception ex)
            //{

            //}
            //finally
            //{
                sqlConn.Close();
                sda.Dispose();
                sqlConn.Dispose();
            //}

            if (dt.Rows.Count == 0)
            {
                return allObjects;
            }
            else
            {
                Classes.Date d = new Classes.Date();
                Classes.Nearby n = new Classes.Nearby();

                EventObject object1 = new EventObject();
                EventObject object2 = new EventObject();
                EventObject object3 = new EventObject();
                EventObject object4 = new EventObject();
                EventObject object5 = new EventObject();

                string Location = "";
                Classes.Locations l = new Classes.Locations();
                DataTable dtLocation = l.getLocationInfoByCityId(Convert.ToInt32(locationId));
                if (dtLocation.Rows.Count == 0)
                {
                    Location = "Not Available!";
                }
                else
                {
                    Location = dtLocation.Rows[0]["CountryName"].ToString() + " - " + dtLocation.Rows[0]["CityName"].ToString();
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    // Show profile's photo
                    string profilePicUrl;
                    if (Convert.ToBoolean(dt.Rows[i]["HasPhoto"].ToString()))
                    {
                        profilePicUrl = "Files/ProfilesPhotos/" + dt.Rows[i]["OwnerId"].ToString() + "-100.jpg";
                    }
                    else
                    {
                        profilePicUrl = "Images/nophoto.png";
                    }

                    // Rate
                    int rate = 0;
                    int rateSufficient = Convert.ToInt32(ConfigurationManager.AppSettings["RateSufficient"].ToString());
                    int rateCount = Convert.ToInt32(dt.Rows[i]["rateCount"].ToString());
                    int rateScore = Convert.ToInt32(dt.Rows[i]["rateScore"].ToString());
                    if (rateCount >= rateSufficient)
                    {
                        rate = (20 * rateScore) / rateCount;

                    }

                    EventObject myEventObject = new EventObject(
                        Convert.ToInt64(dt.Rows[i]["EventId"].ToString()),
                        dt.Rows[i]["Name"].ToString(),
                        d.FormatRemainedDate(dt.Rows[i]["Date"].ToString()),
                        Convert.ToInt16(dt.Rows[i]["TypeId"].ToString()),
                        Convert.ToInt16(dt.Rows[i]["CoverId"].ToString()),
                        Convert.ToInt32(dt.Rows[i]["OwnerId"].ToString()),
                        Location,
                        rate,
                        dt.Rows[i]["OwnerName"].ToString(),
                        Convert.ToInt32(dt.Rows[i]["Participants"].ToString() + 1),
                        Convert.ToInt32(dt.Rows[i]["ParticipantsAccepted"].ToString() + 1),
                        profilePicUrl);

                    switch (i)
                    {
                        case 0:
                            {
                                object1 = myEventObject;
                                break;
                            }
                        case 1:
                            {
                                object2 = myEventObject;
                                break;
                            }
                        case 2:
                            {
                                object3 = myEventObject;
                                break;
                            }
                        case 3:
                            {
                                object4 = myEventObject;
                                break;
                            }
                        case 4:
                            {
                                object5 = myEventObject;
                                break;
                            }
                    }
                }
                allObjects = new EventObjectAll(
                        object1,
                        object2,
                        object3,
                        object4,
                        object5);

                return allObjects;
            }
        }
예제 #14
0
파일: Events.cs 프로젝트: m3hrad/CityCrowd
        public int eventAdd(int userId, string name, string date, int participants, int locationId, string address, Int16 typeId, Int16 coverId, string descriptions)
        {
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlCommand sqlCmd = new SqlCommand("sp_eventAdd", sqlConn);
            sqlCmd.CommandType = CommandType.StoredProcedure;
            // user id
            sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
            // name +max 50
            sqlCmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = name;
            // date +add time
            sqlCmd.Parameters.Add("@Date", SqlDbType.SmallDateTime).Value = date;
            // participants +limit
            sqlCmd.Parameters.Add("@Participants", SqlDbType.Int).Value = participants;
            // location +near own location or trip
            sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId;
            // location +near own location or trip
            sqlCmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = address;
            // type id +limit
            sqlCmd.Parameters.Add("@TypeId", SqlDbType.SmallInt).Value = typeId;
            // type id +limit
            sqlCmd.Parameters.Add("@CoverId", SqlDbType.SmallInt).Value = coverId;
            // descriptions +limit to max
            sqlCmd.Parameters.Add("@Descriptions", SqlDbType.NVarChar).Value = descriptions;

            //try
            //{
                sqlConn.Open();
                sqlCmd.ExecuteNonQuery();
            //}
            //catch
            //{

            //}
            //finally
            //{
                sqlConn.Close();
                sqlConn.Dispose();
                sqlCmd.Dispose();
            //}

            string[] hashtags = Regex.Matches(descriptions, @"\#\w*").Cast<Match>().Select(m => m.Value).ToArray();

            if (hashtags.Length > 0)
            {
                Classes.UserInfo ui = new Classes.UserInfo();
                Int64 lastEventId = ui.getLastEvent(userId);

                DataTable dtTags = new DataTable();
                DataRow drTags = null;

                //define the columns
                dtTags.Columns.Add(new DataColumn("EventId", typeof(Int64)));
                dtTags.Columns.Add(new DataColumn("LocationId", typeof(Int32)));
                dtTags.Columns.Add(new DataColumn("Hashtag", typeof(string)));
                dtTags.Columns.Add(new DataColumn("ExpireDate", typeof(string)));

                for (int i = 0; i < hashtags.Length; i++)
                {

                    //create new row
                    drTags = dtTags.NewRow();

                    //add values to each rows
                    drTags["EventId"] = lastEventId;
                    drTags["LocationId"] = locationId;
                    drTags["Hashtag"] = hashtags[i].Replace("#", "");
                    drTags["ExpireDate"] = date;

                    //add the row to DataTable
                    dtTags.Rows.Add(drTags);
                }

                SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                SqlCommand sqlCmd2 = new SqlCommand("sp_eventAddHashtagsAdd", sqlConn2);
                sqlCmd2.CommandType = CommandType.StoredProcedure;
                sqlCmd2.Parameters.Add("@HashtagsTable", dtTags);

                //try
                //{
                    sqlConn2.Open();
                    sqlCmd2.ExecuteNonQuery();
                //}
                //catch
                //{

                //}
                //finally
                //{
                    sqlConn2.Close();
                    sqlConn2.Dispose();
                    sqlCmd2.Dispose();
                //}
            }

            return 1;
        }
예제 #15
0
        public string notificationText(int NotificationType, Int64 itemId)
        {
            switch (NotificationType)
            {
            case 1:
            {
                return("Congratulations! You have successfully registered!");

                break;
            }

            case 2:
            {
                Classes.Events e         = new Classes.Events();
                string         eventName = e.getEventNameByEventId(itemId);
                return("Guess what?! You have been accepted to participate in this event: " + eventName);

                break;
            }

            case 3:
            {
                Classes.Events e         = new Classes.Events();
                string         eventName = e.getEventNameByEventId(itemId);
                return("Your event, " + eventName + " is full now!");

                break;
            }

            case 4:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " started following you.");

                break;
            }

            case 5:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " registered in the app with your invitation.");

                break;
            }

            case 6:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " just reviewed you!");

                break;
            }

            case 7:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " canceled participation in your event.");

                break;
            }

            case 8:
            {
                Classes.Events e         = new Classes.Events();
                string         eventName = e.getEventNameByEventId(itemId);
                return("You just got removed from " + eventName + ".");

                break;
            }

            case 9:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " removed an event that you were a participant in it.");

                break;
            }

            case 10:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " is waiting for your review.");

                break;
            }

            case 11:
            {
                return("You have successfully verified your email address.");

                break;
            }

            case 12:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " from your Facebook friends just became a CityCrowder.");

                break;
            }

            case 13:
            {
                Classes.UserInfo ui           = new Classes.UserInfo();
                string           userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                return(userFullName + " became a CityCrowder with your invitation.");

                break;
            }

            case 14:
            {
                Classes.Locations l            = new Classes.Locations();
                string            locationName = l.getLocationInfoById(Convert.ToInt32(itemId));
                return("Good news! The location you requested to be added is now available! Locaion: " + locationName);

                break;
            }

            default:
            {
                return("");

                break;
            }
            }
        }
예제 #16
0
 public string notificationText(int NotificationType, Int64 itemId)
 {
     switch (NotificationType)
     {
         case 1:
             {
                 return "Congratulations! You have successfully registered!";
                 break;
             }
         case 2:
             {
                 Classes.Events e = new Classes.Events();
                 string eventName = e.getEventNameByEventId(itemId);
                 return "Guess what?! You have been accepted to participate in this event: " + eventName;
                 break;
             }
         case 3:
             {
                 Classes.Events e = new Classes.Events();
                 string eventName = e.getEventNameByEventId(itemId);
                 return "Your event, " + eventName + " is full now!";
                 break;
             }
         case 4:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " started following you.";
                 break;
             }
         case 5:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " registered in the app with your invitation.";
                 break;
             }
         case 6:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " just reviewed you!";
                 break;
             }
         case 7:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " canceled participation in your event.";
                 break;
             }
         case 8:
             {
                 Classes.Events e = new Classes.Events();
                 string eventName = e.getEventNameByEventId(itemId);
                 return  "You just got removed from " + eventName + ".";
                 break;
             }
         case 9:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " removed an event that you were a participant in it.";
                 break;
             }
         case 10:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " is waiting for your review.";
                 break;
             }
         case 11:
             {
                 return "You have successfully verified your email address.";
                 break;
             }
         case 12:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " from your Facebook friends just became a CityCrowder.";
                 break;
             }
         case 13:
             {
                 Classes.UserInfo ui = new Classes.UserInfo();
                 string userFullName = ui.getUserFullNameByUserId(Convert.ToInt32(itemId));
                 return userFullName + " became a CityCrowder with your invitation.";
                 break;
             }
         case 14:
             {
                 Classes.Locations l = new Classes.Locations();
                 string locationName = l.getLocationInfoById(Convert.ToInt32(itemId));
                 return "Good news! The location you requested to be added is now available! Locaion: " + locationName;
                 break;
             }
         default:
             {
                 return "";
                 break;
             }
     }
 }