DateToMySql() статический приватный Метод

static private DateToMySql ( System.DateTime date ) : string
date System.DateTime
Результат string
Пример #1
0
        /// <summary>
        /// Returns count of photos between each pair of dates in the list.
        /// </summary>
        /// <remarks>If you pass in DateA, DateB and DateC it returns
        /// a list of the number of photos between DateA and DateB,
        /// followed by the number between DateB and DateC.
        /// More parameters means more sets.</remarks>
        /// <param name="dates">Comma-delimited list of dates in unix timestamp format. Optional.</param>
        /// <param name="takenDates">Comma-delimited list of dates in unix timestamp format. Optional.</param>
        /// <returns><see cref="PhotoCountCollection"/> class instance.</returns>
        public PhotoCountCollection PhotosGetCounts(DateTime[] dates, DateTime[] takenDates)
        {
            string dateString      = null;
            string takenDateString = null;

            if (dates != null && dates.Length > 0)
            {
                Array.Sort <DateTime>(dates);
                dateString = String.Join(",", new List <DateTime>(dates).ConvertAll <string>(new Converter <DateTime, string>(delegate(DateTime d) { return(UtilityMethods.DateToUnixTimestamp(d).ToString()); })).ToArray());
            }

            if (takenDates != null && takenDates.Length > 0)
            {
                Array.Sort <DateTime>(takenDates);
                takenDateString = String.Join(",", new List <DateTime>(takenDates).ConvertAll <string>(new Converter <DateTime, string>(delegate(DateTime d) { return(UtilityMethods.DateToMySql(d).ToString()); })).ToArray());
            }

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.photos.getCounts");
            if (dateString != null && dateString.Length > 0)
            {
                parameters.Add("dates", dateString);
            }
            if (takenDateString != null && takenDateString.Length > 0)
            {
                parameters.Add("taken_dates", takenDateString);
            }

            return(GetResponseCache <PhotoCountCollection>(parameters));
        }
Пример #2
0
 /// <summary>
 /// Takes the various properties of this instance and adds them to a <see cref="Dictionary{K,V}"/> instanced passed in, ready for sending to Flickr.
 /// </summary>
 /// <param name="parameters">The <see cref="Dictionary{K,V}"/> to add the options to.</param>
 public void AddToDictionary(Dictionary <string, string> parameters)
 {
     if (!string.IsNullOrEmpty(UserId))
     {
         parameters.Add("user_id", UserId);
     }
     if (!string.IsNullOrEmpty(GroupId))
     {
         parameters.Add("group_id", GroupId);
     }
     if (!string.IsNullOrEmpty(Text))
     {
         parameters.Add("text", Text);
     }
     if (!string.IsNullOrEmpty(Tags))
     {
         parameters.Add("tags", Tags);
     }
     if (TagMode != TagMode.None)
     {
         parameters.Add("tag_mode", UtilityMethods.TagModeToString(TagMode));
     }
     if (!string.IsNullOrEmpty(MachineTags))
     {
         parameters.Add("machine_tags", MachineTags);
     }
     if (MachineTagMode != MachineTagMode.None)
     {
         parameters.Add("machine_tag_mode", UtilityMethods.MachineTagModeToString(MachineTagMode));
     }
     if (MinUploadDate != DateTime.MinValue)
     {
         parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(MinUploadDate).ToString());
     }
     if (MaxUploadDate != DateTime.MinValue)
     {
         parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(MaxUploadDate).ToString());
     }
     if (MinTakenDate != DateTime.MinValue)
     {
         parameters.Add("min_taken_date", UtilityMethods.DateToMySql(MinTakenDate));
     }
     if (MaxTakenDate != DateTime.MinValue)
     {
         parameters.Add("max_taken_date", UtilityMethods.DateToMySql(MaxTakenDate));
     }
     if (Licenses.Count != 0)
     {
         var licenseArray = new List <string>();
         foreach (var license in Licenses)
         {
             licenseArray.Add(license.ToString("d"));
         }
         parameters.Add("license", String.Join(",", licenseArray.ToArray()));
     }
     if (PerPage != 0)
     {
         parameters.Add("per_page", PerPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Page != 0)
     {
         parameters.Add("page", Page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Extras != PhotoSearchExtras.None)
     {
         parameters.Add("extras", ExtrasString);
     }
     if (SortOrder != PhotoSearchSortOrder.None)
     {
         parameters.Add("sort", SortOrderString);
     }
     if (PrivacyFilter != PrivacyFilter.None)
     {
         parameters.Add("privacy_filter", PrivacyFilter.ToString("d"));
     }
     if (BoundaryBox != null && BoundaryBox.IsSet)
     {
         parameters.Add("bbox", BoundaryBox.ToString());
     }
     if (Accuracy != GeoAccuracy.None)
     {
         parameters.Add("accuracy", Accuracy.ToString("d"));
     }
     if (SafeSearch != SafetyLevel.None)
     {
         parameters.Add("safe_search", SafeSearch.ToString("d"));
     }
     if (ContentType != ContentTypeSearch.None)
     {
         parameters.Add("content_type", ContentType.ToString("d"));
     }
     if (HasGeo != null)
     {
         parameters.Add("has_geo", HasGeo.Value ? "1" : "0");
     }
     if (Latitude != null)
     {
         parameters.Add("lat", Latitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Longitude != null)
     {
         parameters.Add("lon", Longitude.Value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (Radius != null)
     {
         parameters.Add("radius", Radius.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (RadiusUnits != RadiusUnit.None)
     {
         parameters.Add("radius_units", (RadiusUnits == RadiusUnit.Miles ? "mi" : "km"));
     }
     if (Contacts != ContactSearch.None)
     {
         parameters.Add("contacts", (Contacts == ContactSearch.AllContacts ? "all" : "ff"));
     }
     if (WoeId != null)
     {
         parameters.Add("woe_id", WoeId);
     }
     if (PlaceId != null)
     {
         parameters.Add("place_id", PlaceId);
     }
     if (IsCommons)
     {
         parameters.Add("is_commons", "1");
     }
     if (InGallery)
     {
         parameters.Add("in_gallery", "1");
     }
     if (IsGetty)
     {
         parameters.Add("is_getty", "1");
     }
     if (MediaType != MediaType.None)
     {
         parameters.Add("media", UtilityMethods.MediaTypeToString(MediaType));
     }
     if (GeoContext != GeoContext.NotDefined)
     {
         parameters.Add("geo_context", GeoContext.ToString("d"));
     }
     if (Faves)
     {
         parameters.Add("faves", "1");
     }
     if (PersonId != null)
     {
         parameters.Add("person_id", PersonId);
     }
     if (Camera != null)
     {
         parameters.Add("camera", Camera);
     }
     if (JumpTo != null)
     {
         parameters.Add("jump_to", JumpTo);
     }
     if (!String.IsNullOrEmpty(Username))
     {
         parameters.Add("username", Username);
     }
     if (ExifMinExposure != null)
     {
         parameters.Add("exif_min_exposure", ExifMinExposure.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (ExifMaxExposure != null)
     {
         parameters.Add("exif_max_exposure", ExifMaxExposure.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (ExifMinAperture != null)
     {
         parameters.Add("exif_min_aperture", ExifMinAperture.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (ExifMaxAperture != null)
     {
         parameters.Add("exif_max_aperture", ExifMaxAperture.Value.ToString("0.00000", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (ExifMinFocalLength != null)
     {
         parameters.Add("exif_min_focallen", ExifMinFocalLength.Value.ToString("0", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (ExifMaxFocalLength != null)
     {
         parameters.Add("exif_max_focallen", ExifMaxFocalLength.Value.ToString("0", System.Globalization.NumberFormatInfo.InvariantInfo));
     }
     if (ExcludeUserID != null)
     {
         parameters.Add("exclude_user_id", ExcludeUserID);
     }
     if (FoursquareVenueID != null)
     {
         parameters.Add("foursquare_venueid", FoursquareVenueID);
     }
     if (FoursquareWoeID != null)
     {
         parameters.Add("foursquare_woeid", FoursquareWoeID);
     }
     if (GroupPathAlias != null)
     {
         parameters.Add("group_path_alias", GroupPathAlias);
     }
 }