Esempio n. 1
0
        public PostGroupUserPushNotificationSetting[] getSubscribedPostGroupsSettings(long userID)
        {
            List <PostGroupUserPushNotificationSetting> subscribedIDs = new List <PostGroupUserPushNotificationSetting>();

            using (StreamReader sr = new StreamReader(file_subscribedPostGroups))
            {
                string currentLine = null;
                while ((currentLine = sr.ReadLine()) != null)
                {
                    string[] args        = currentLine.Split(";");
                    long     foundedUser = Convert.ToInt64(args[0]);

                    if (foundedUser == userID)
                    {
                        PostGroupUserPushNotificationSetting setting = convertLineTOItem(currentLine);

                        if (subscribedIDs.SingleOrDefault(x => x.PostGroupID == setting.PostGroupID) == null)
                        {
                            subscribedIDs.Add(setting);
                        }
                    }
                }
            }
            return(subscribedIDs.Distinct().ToArray());
        }
Esempio n. 2
0
        public PostGroupUserPushNotificationSetting[] getSubscribedPostGroupsSettings(long userID)
        {
            sqlConnection = null;
            sqlConnection = TimeTableDatabase.getConnection();
            try
            {
                using (sqlConnection)
                {
                    PostGroupUserPushNotificationSetting SQLItem = new PostGroupUserPushNotificationSetting();

                    List <PostGroupUserPushNotificationSetting> list = new List <PostGroupUserPushNotificationSetting>();

                    string SQL = "SELECT[newsgroupid],[active] FROM subscribe WHERE userid='" + userID.ToString() + "';";

                    sqlConnection.Open();
                    SqlDataReader myReader  = null;
                    SqlCommand    myCommand = new SqlCommand(SQL, sqlConnection);
                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        SQLItem.PostGroupID     = Convert.ToInt32(myReader["newsgroupid"].ToString());
                        SQLItem.PostGroupActive = Convert.ToBoolean(myReader["active"].ToString());
                        list.Add(SQLItem);
                        SQLItem = new PostGroupUserPushNotificationSetting();
                    }
                    sqlConnection.Close();
                    sqlConnection = null;
                    return(list.ToArray());
                }
            }
            catch (System.Exception)
            {
                sqlConnection.Close();
                sqlConnection = null;
                return(null);
            }
        }
Esempio n. 3
0
 private string convertItemToLine(PostGroupUserPushNotificationSetting item)
 {
     return($"{item.PostGroupID};{item.PostGroupActive};{item.Type}");
 }