Ejemplo n.º 1
0
		public string ExportRaw(ClientConfiguration clientConfiguration, Date from, Date to, string[] events = null)
		{
			try
			{
				var uri = MixPanelEndpointConfiguration.RawExportUrl;

				var parameterDictionary = new Dictionary<string, string>();

				parameterDictionary.Add(FromDateParamName, from.ToString());
				parameterDictionary.Add(ToDateParamName, to.ToString());
				if (events != null
				    && events.Any())
					parameterDictionary.Add(EventParamName, StringifyEvents(events));

				var callingUri =
					new Uri(uri.ToString() + "?" + string.Join("&", parameterDictionary.Select(x => x.Key + "=" + x.Value)));

				var webClientResponse = _webClient.QueryUri(callingUri,
				                                            new BasicAuthentication { UserName = clientConfiguration.Secret });

				return webClientResponse;
			}
			catch (WebException ex)
			{
				TryHandleWebException(ex);
				throw new MixPanelClientException(ex);
			}
			catch (Exception ex)
			{
				throw new MixPanelClientException(ex);
			}
		}
Ejemplo n.º 2
0
 // GetLeMondePrintNumber
 public static int GetPrintNumber(Date date)
 {
     // Le monde - 2012-12-02 - no 21110.pdf
     // Le monde - 2012-10-12 - no 21066.pdf
     // Le monde - 2012-07-19 - no 20993.pdf
     // pas de journal le 1er mai sauf si c'est un dimanche, journal le dimanche 1er mai 2011
     // Test_GetLeMondePrintNumber("2012-04-29"); // ok  20925
     // Test_GetLeMondePrintNumber("2012-05-02"); // ok  20926
     Date dateRef = new Date(2012, 12, 2);
     int noRef = 21110;
     while (date > dateRef)
     {
         if (dateRef.DayOfWeek != DayOfWeek.Sunday && (dateRef.Month != 5 || dateRef.Day != 1 || dateRef.DayOfWeek == DayOfWeek.Sunday))
             noRef++;
         dateRef = dateRef.AddDays(1);
     }
     while (date < dateRef)
     {
         if (dateRef.DayOfWeek != DayOfWeek.Monday && (dateRef.Month != 5 || dateRef.Day != 1 || dateRef.DayOfWeek == DayOfWeek.Sunday))
             noRef--;
         dateRef = dateRef.AddDays(-1);
     }
     if (date != dateRef) throw new PBException("error date not found {0}", date.ToString());
     return noRef;
 }
Ejemplo n.º 3
0
 public string GetDirectory(Date date)
 {
     string format = null;
     switch (Type)
     {
         case PrintDirectoryDateStorageType.YearSubDirectory:
             format = "yyyy";
             break;
         case PrintDirectoryDateStorageType.MonthSubDirectory:
             format = "yyyy-MM";
             break;
         case PrintDirectoryDateStorageType.DaySubDirectory:
             format = "yyyy-MM-dd";
             break;
     }
     if (format != null)
         return Prefix + date.ToString(format);
     else
         return null;
 }
		private Uri GetExpectedUrl(Date defaultStartDate, Date defaultEndDate, string @event)
		{
			var stringifiedUrl =
				$"{MixPanelEndpointConfiguration.RawExportUrl}?from_date={defaultStartDate.ToString()}&to_date={defaultEndDate.ToString()}&event=[\"{HttpUtility.UrlEncode(@event)}\"]";

			return new Uri(stringifiedUrl);
		}
		private Uri GetExpectedUrl(Date defaultStartDate, Date defaultEndDate)
		{
			var stringifiedUrl =
				$"{MixPanelEndpointConfiguration.RawExportUrl}?from_date={defaultStartDate.ToString()}&to_date={defaultEndDate.ToString()}";

			return new Uri(stringifiedUrl);
		}
 private static string BuildString(Date modifiedDate, TimeOfDay modifiedTime,
     Date? nullableModifiedDate, TimeOfDay? nullableModifiedTime)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("modifiedDate:").Append(modifiedDate).Append(",");
     sb.Append("modifiedTime:").Append(modifiedTime).Append(",");
     sb.Append("nullableModifiedDate:").Append(nullableModifiedDate == null ? "null" : nullableModifiedDate.ToString()).Append(",");
     sb.Append("nullableModifiedTime:").Append(nullableModifiedTime == null ? "null" : nullableModifiedTime.ToString());
     return sb.ToString();
 }
Ejemplo n.º 7
0
 public void to_string_uses_the_ugly_ddMMyyyy_format()
 {
     var date = new Date(2, 22, 2012);
     date.ToString().ShouldEqual("22022012");
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Write a Date value
        /// </summary>
        /// <param name="writer">The text writer to write the output to.</param>
        /// <param name="value">Date value to be written.</param>
        internal static void WriteValue(TextWriter writer, Date value)
        {
            Debug.Assert(writer != null, "writer != null");

            WriteQuoted(writer, value.ToString());
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Converts the given Date value to the string appropriate for Atom format.
 /// </summary>
 /// <param name="date">The Date value to convert.</param>
 /// <returns>The string version of the Date in Atom format.</returns>
 internal static string ToString(Date date)
 {
     return date.ToString();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Converts the Date to a String.
 /// </summary>
 /// <param name="d">The <see cref="Microsoft.OData.Edm.Library.Date"/> to be converted</param>
 /// <returns>A System.String representation of the supplied <see cref="Microsoft.OData.Edm.Library.Date"/>.</returns>
 internal static string DateAsXml(Date d)
 {
     var value = d.ToString();
     return value;
 }
Ejemplo n.º 11
0
        public void ToStringFormat(string expected, int year, int month, int day)
        {
            var value = new Date(year, month, day);

            Assert.AreEqual(expected, value.ToString());
        }
Ejemplo n.º 12
0
		public void CanPresentSortablePattern()
		{
			using (new CultureScope(CultureInfo.InvariantCulture))
			{
				Date d = new Date(2013, 4, 5);
				string s = d.ToString("s");

				Assert.AreEqual("2013-04-05", s);
			}
		}
Ejemplo n.º 13
0
		public void CanPresentRoundTripPattern()
		{
			using (new CultureScope(CultureInfo.InvariantCulture))
			{
				Date d = new Date(2013, 4, 5);
				string s1 = d.ToString("O");
				string s2 = d.ToString("o");

				Assert.AreEqual(s1, s2);
				Assert.AreEqual("2013-04-05", s1);
				Assert.AreEqual("2013-04-05", s2);
			}
		}