Example #1
0
        internal void ValidateShareSkillData()
        {
            //Validate Entered Title
            GlobalDefinitions.ValidateFieldData(GlobalDefinitions.ExcelLib.ReadData(2, "Title"), Title.GetAttribute("value"), "Title");

            //Validate Entered Description
            GlobalDefinitions.ValidateFieldData(GlobalDefinitions.ExcelLib.ReadData(2, "Description"), Description.Text, "Description");

            //Validate Selected Category
            GlobalDefinitions.ValidateDropDown(CategoryDropDown, GlobalDefinitions.ExcelLib.ReadData(2, "Category"), "Category");

            //Validate Selected SubCategory
            GlobalDefinitions.ValidateDropDown(SubCategoryDropDown, GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory"), "SubCategory");

            //Validate Entered Tags
            GlobalDefinitions.ValidateFieldData(GlobalDefinitions.ExcelLib.ReadData(2, "Tags"), EnteredTag.Text.Replace(EnteredTag.FindElement(By.XPath("./*")).Text, ""), "Tag");

            //Validate Service Type
            GlobalDefinitions.ValidateRadioButton(ServiceTypeOptions, By.Name("serviceType"), GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType"), "ServiceType");

            //Validate Location Type
            GlobalDefinitions.ValidateRadioButton(LocationTypeOption, By.Name("locationType"), GlobalDefinitions.ExcelLib.ReadData(2, "LocationType"), "LocationType");

            //Validate Start Date
            GlobalDefinitions.ValidateFieldData(Convert.ToDateTime(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")).ToString("yyyy-MM-dd"), StartDateDropDown.GetAttribute("value"), "Start Date");

            //Validate End Date
            GlobalDefinitions.ValidateFieldData(Convert.ToDateTime(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")).ToString("yyyy-MM-dd"), EndDateDropDown.GetAttribute("value"), "End Date");

            //Validate Days and Time
            ValidateDaysAndTime();

            //Validate Skill Trade
            ValidateRadioButton(SkillTradeOption, By.Name("skillTrades"), GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade"), "SkillTrade");
            try
            {
                if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade").ToUpper() == "SKILL-EXCHANGE")
                {
                    //Validate Skill Exchange
                    GlobalDefinitions.ValidateFieldData(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange"), SkillExchangeTag.Text.Replace(EnteredTag.FindElement(By.XPath("./*")).Text, ""), "Skill-Exchange");
                }
                else if (GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade").ToUpper() == "CREDIT")
                {
                    GlobalDefinitions.ValidateFieldData(GlobalDefinitions.ExcelLib.ReadData(2, "Credit"), CreditAmount.GetAttribute("value"), "Credit");
                }
            }
            catch (Exception e)
            {
                Base.test.Log(LogStatus.Fail, "Caught Exception For Skill Exchange/Credit ", e.Message);
            }

            //Validate Selected Sample File
            // GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//label[@class='worksamples-file']//a"), 5);
            GlobalDefinitions.ValidateFieldData(WorkSamplesFile.Text, "empty.txt", "Work Sample File");

            //Validate Active
            GlobalDefinitions.ValidateRadioButton(ActiveOption, By.Name("isActive"), GlobalDefinitions.ExcelLib.ReadData(2, "Active"), "Active");
        }
Example #2
0
        } // end constructor

        // The method searchButton_Click initiates the asynchronous Flickr search query; 
        // display results when query completes
        private async void SearchButton_Click(object sender, EventArgs e)
        {
            // Check whether user started a search previously (i.e., flickrTask is not null and the prior search has not completed) and,
            // if so, whether that search is already completed. 
            if (_flickrTask != null &&
                _flickrTask.Status != TaskStatus.RanToCompletion)
            {
                //If an existing search is still being performed, the program displays a dialog asking if user wish  to cancel the search. 
                var result = MessageBox.Show(
                   "Cancel the current Flickr search?",
                   "Are you sure?", MessageBoxButtons.YesNo,
                   MessageBoxIcon.Question);

                // If user clicks No, the event handler simply returns. Otherwise, the program calls  the WebClient's  CancelAsync 
                //method to terminiate the search.
                if (result == DialogResult.No)
                    return;
                else
                    _flickrClient.CancelAsync(); // cancel current search
            } // end if

            // Create a URL for invoking the Flickr web service's method flickr.photos.search.
            // with Key you get from the Flickr website, tag, tag_mode=all, per_page = 500 and 
            // privacy_filter=1. Use the inputTextBox.Text.Replace(" ", ",") for tag.

            var flickrURL = string.Format("https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key={0}&tags={1}&tag_mode=all&privacy_filter=1", KEY, EnteredTag.Replace(" ", ","));


            ImagesList.Clear();                          // clear imagesListBox
            DisplayedImage.Source = null;                // clear pictureBox
            ImagesList.Add(new FlickrResult { Title = "Loading..." });   // display Loading...

            try
            {
                // Call WebClient's DownloadStringTaskAsync method using the flickrURL specified as the method's string argument to request information from
                // the server. Assign the task returned from the method to flickrTask.
                _flickrTask =
                    _flickrClient.DownloadStringTaskAsync(flickrURL);

                // await fickrTask then parse results with XDocument
                XDocument xmlResponse = XDocument.Parse(await _flickrTask);

                // Gather  from each photo element in the XML the id, title, secret, server, and farm attributes, then create an object class FlickResult using LINQ.
                // Each FlickrResult contains:
                //      A Title property - initialized with the photo element's title attribute
                //      A URL property - assembled fromt the photo element's id, secret, server, and farm (a farm is a collection of servers on the Internet) attributes.
                //      The format of the URL for each image is specified at http://www.flickr.com/services/api/misc.urls.html
                var flickrPhotos =
                   from photo in xmlResponse.Descendants("photo")
                   let id = photo.Attribute("id").Value
                   let title = photo.Attribute("title").Value
                   let secret = photo.Attribute("secret").Value
                   let server = photo.Attribute("server").Value
                   let farm = photo.Attribute("farm").Value
                   select new FlickrResult
                   {
                       Title = title,
                       URL = string.Format("https://farm{0}.staticflickr.com/{1}/{2}_{3}.jpg",
                                            farm, server, id, secret)
                   };
                ImagesList.Clear();             // clear imagesListBox
                                                // set ListBox properties only if results were found
                if (flickrPhotos.Any())
                {
                    // Invoke to ToList on the flickrPhotos LINQ query to convert it to list, then assign the result to the ListBox's DataSource property
                    // Set the ListBox's DisplayMember property to the Title property.
                    ImagesList = new ObservableCollection<FlickrResult>(flickrPhotos);
                    SelectedImage = ImagesList[0];
                } // end if 
                else // no matches were found
                    ImagesList.Add(new FlickrResult { Title = "No matches" });
            } // end try
            catch (WebException)
            {
                // check whether Task failed
                if (_flickrTask.Status == TaskStatus.Faulted)
                    MessageBox.Show("Unable to get results from Flickr",
                       "Flickr Error", MessageBoxButtons.OK,
                       MessageBoxIcon.Error);

                ImagesList.Clear();  // clear imagesListBox
                ImagesList.Add(new FlickrResult { Title = "Error occurred" });
            } // end catch
        } // end method searchButton_Click