예제 #1
0
        private void menuSearch_Click(object sender, EventArgs e)
        {

            if (DetectDevice.DeviceType == DeviceType.Professional)
            {
                if (!string.IsNullOrEmpty(txtSearch.Text) && !ClientSettings.SearchItems.Contains(txtSearch.Text))
                {
                    ClientSettings.SearchItems.Enqueue(txtSearch.Text);
                    if (ClientSettings.SearchItems.Count > 8)
                    {
                        ClientSettings.SearchItems.Dequeue();
                    }
                    ClientSettings.SaveSettings();
                }
            }
            if (ClientSettings.UseGPS || ClientSettings.UseCellIDPosition)
            {
                Locator.StopPosition();
            }
            StringBuilder b = new StringBuilder();
            if (!string.IsNullOrEmpty(txtSearch.Text))
            {

                if (!txtSearch.Text.StartsWith("q="))
                {
                    b.Append("q=");
                    b.Append(System.Web.HttpUtility.UrlEncode(txtSearch.Text));
                }
                else
                {
                    // term is an advanced search
                    b.Append(txtSearch.Text);
                }
            }
            if (cmbLocation.Text != PockeTwit.Localization.XmlBasedResourceManager.GetString("Anywhere"))
            {
                if (!string.IsNullOrEmpty(cmbLocation.Text))
                {
                    Coordinate c = Geocode.GetCoordinates(cmbLocation.Text);
                    this.GPSLocation = System.Web.HttpUtility.UrlEncode(c.ToString());
                    if (!string.IsNullOrEmpty(cmbDistance.Text) && !string.IsNullOrEmpty(cmbMeasurement.Text))
                    {
                        if (b.Length > 0)
                        {
                            b.Append("&");
                        }
                        b.Append("geocode=" + this.GPSLocation);
                        b.Append("," + cmbDistance.Text);
                        string miles = PockeTwit.Localization.XmlBasedResourceManager.GetString("Miles");
                        if (cmbMeasurement.Text == miles)
                            b.Append("mi");
                        else                           
                            b.Append("km");
                    }
                }
            }
            this.SearchText = b.ToString();

            if (chkSaveSearch.Checked && !string.IsNullOrEmpty(txtGroupName.Text))
            {
                if (SureTheyWantToSave())
                {
                    SavedSearch = new SavedSearchTimeLine();
                    SavedSearch.name = txtGroupName.Text;
                    SavedSearch.SearchPhrase = this.SearchText;
                    SavedSearch.autoUpdate = chkAutoUpdate.Checked;
                    SpecialTimeLinesRepository.Add(SavedSearch);
                    SpecialTimeLinesRepository.Save();
                }
                else
                {
                    chkSaveSearch.Checked = false;
                    return;
                }

            }

            this.DialogResult = DialogResult.OK;
        }
        public static void Load()
        {
            using (var conn = DataBaseUtility.GetConnection())
            {
                conn.Open();
                using (var comm = new SQLiteCommand(conn))
                {
                    comm.CommandText =
                        "SELECT groupname, userid, exclusive, users.screenname FROM usersInGroups INNER JOIN users ON usersInGroups.userid = users.id";
                    using (var r = comm.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            var groupName = r.GetString(0);
                            var userID = r.GetString(1);
                            var exclusive = r.GetBoolean(2);
                            var screenName = r.GetString(3);
                            var thisLine = new UserGroupTimeLine();
                            if (Items.ContainsKey(groupName))
                            {
                                thisLine = (UserGroupTimeLine) Items[groupName];
                            }
                            else
                            {
                                thisLine.name = groupName;
                                Add(thisLine);
                            }
                            thisLine.AddItem(userID, screenName, exclusive);
                        }
                    }

                    comm.CommandText =
                        "SELECT searchName, searchTerm, autoUpdate from savedSearches;";

                    try
                    {

                        using (var r = comm.ExecuteReader())
                        {
                            while (r.Read())
                            {
                                var searchName = r.GetString(0);
                                var searchTerm = r.GetString(1);
                                var autoUpdate = r.GetBoolean(2);

                                var savedLine = new SavedSearchTimeLine
                                                    {
                                                        name = searchName,
                                                        SearchPhrase = searchTerm,
                                                        autoUpdate = autoUpdate
                                                    };
                                Add(savedLine);
                            }
                        }
                    }
                    //Ignore it when we have a mismatched save search table.
                    catch{}
                }
            }
        }
예제 #3
0
 private Library.status[] GetRegularSavedSearchTimeLine(SavedSearchTimeLine searchLine, Yedda.Twitter.PagingMode pagingMode)
 {
     var TwitterConn = new Twitter
     {
         AccountInfo =
         {
             ServerURL = ClientSettings.DefaultAccount.ServerURL,
             UserName = ClientSettings.DefaultAccount.UserName,
             Password = ClientSettings.DefaultAccount.Password,
             Enabled = ClientSettings.DefaultAccount.Enabled
         }
     };
     status[] items = SearchTwitter(TwitterConn, searchLine.SearchPhrase, pagingMode);
     
     return items;
 }