Exemplo n.º 1
0
		public override void Load()
		{
			string message;
			var localMetaData = MetaDataContainer.Load(MetaDataConst.CategoriesDataTag);
			if (localMetaData != null)
			{
				DateTime? cloudLastUpdate = null;
				DateTime tempDate;
				var dateStr = MainController.Instance.SoapServiceConnection.GetMetaData(MetaDataConst.CategoriesDataTag, MetaDataConst.LastUpdatePropertyName, out message);
				if (DateTime.TryParse(dateStr, out tempDate))
					cloudLastUpdate = tempDate;
				if (!cloudLastUpdate.HasValue || cloudLastUpdate <= localMetaData.LastUpdate)
				{
					var localData = localMetaData.GetData<SearchTagList>();
					SearchGroups.AddRange(localData.SearchGroups);
					MaxTags = localData.MaxTags;
					TagCount = localData.TagCount;
					return;
				}
			}
			else
				localMetaData = new MetaDataContainer(MetaDataConst.CategoriesDataTag);

			SearchGroups.AddRange(LoadFromCloudData(MainController.Instance.SoapServiceConnection.GetCategories(out message)));

			int tempInt;
			if (Int32.TryParse(MainController.Instance.SoapServiceConnection.GetMetaData(MetaDataConst.CategoriesDataTag, MetaDataConst.MaxTagsPropertyName, out message), out tempInt))
				MaxTags = tempInt;
			if (Int32.TryParse(MainController.Instance.SoapServiceConnection.GetMetaData(MetaDataConst.CategoriesDataTag, MetaDataConst.CountTagsPropertyName, out message), out tempInt))
				TagCount = tempInt > 0;

			localMetaData.Content = JsonConvert.SerializeObject(this);
			localMetaData.Save();
		}
		public override void Load()
		{
			string message;
			var localMetaData = MetaDataContainer.Load(MetaDataConst.SuperFiltersDataTag);
			if (localMetaData != null)
			{
				DateTime? cloudLastUpdate = null;
				DateTime tempDate;
				var dateStr = MainController.Instance.SoapServiceConnection.GetMetaData(MetaDataConst.SuperFiltersDataTag, MetaDataConst.LastUpdatePropertyName, out message);
				if (DateTime.TryParse(dateStr, out tempDate))
					cloudLastUpdate = tempDate;
				if (!cloudLastUpdate.HasValue || cloudLastUpdate <= localMetaData.LastUpdate)
				{
					Items.AddRange(localMetaData.GetData<List<String>>());
					return;
				}
			}
			else
				localMetaData = new MetaDataContainer(MetaDataConst.SuperFiltersDataTag);

			Items.AddRange(MainController.Instance.SoapServiceConnection.GetSuperFilters(out message).Select(cloudSuperFilter => cloudSuperFilter.value));

			localMetaData.Content = JsonConvert.SerializeObject(Items);
			localMetaData.Save();
		}
Exemplo n.º 3
0
        public void Create(string clientId, string sessionId, string sourceId, enmMessageCategory category, string messageCode, object[] metaData = null)
        {
            string messageId = Guid.NewGuid().ToString();
            string message = LexiconCache.Read(messageCode);

            List<MetaDataContainer> mdcs = null;

            if (metaData != null) {
                mdcs = new List<MetaDataContainer>();
                foreach (object obj in metaData) {
                    MetaDataContainer mdc = new MetaDataContainer { Format = enmMessageFormat.Xml, Type = obj.GetType().ToString(), Value = obj };
                    mdcs.Add(mdc);
                }
            }

            _messageList.Add(new MessageContainer { ClientId = clientId, SessionId = sessionId, SourceId = Config.ClientId, Category = category, Id = messageId, Created = DateTime.Now, Payload = message, MetaDataList = mdcs });
        }
Exemplo n.º 4
0
		public void Load()
		{
			string message;
			var localMetaData = MetaDataContainer.Load(MetaDataConst.SecurityGroupsDataTag);
			if (localMetaData != null)
			{
				DateTime? cloudLastUpdate = null;
				DateTime tempDate;
				var dateStr = MainController.Instance.SoapServiceConnection.GetMetaData(MetaDataConst.SecurityGroupsDataTag, MetaDataConst.LastUpdatePropertyName, out message);
				if (DateTime.TryParse(dateStr, out tempDate))
					cloudLastUpdate = tempDate;
				if (!cloudLastUpdate.HasValue || cloudLastUpdate <= localMetaData.LastUpdate)
				{
					_groups.AddRange(localMetaData.GetData<List<LibraryGroup>>());
					return;
				}
			}
			else
				localMetaData = new MetaDataContainer(MetaDataConst.SecurityGroupsDataTag);
			_groups.AddRange(MainController.Instance.SoapServiceConnection.GetSecurityGroups(out message).Select(LibraryGroup.LoadFromCloudData));
			localMetaData.Content = JsonConvert.SerializeObject(_groups);
			localMetaData.Save();
		}
Exemplo n.º 5
0
    public IcyScheme(string sUrl)
    {
        m_Position     = 0;
        m_SinceLast    = 0;
        m_bShutdown    = false;
        m_uri          = new Uri(sUrl);
        m_ConnectEvent = new ManualResetEvent(false);

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_uri);
        ServicePoint   point   = request.ServicePoint;

        point.ReceiveBufferSize = DefaultReceiveBufferSize * 2;
        request.UserAgent       = "NSPlayer/12.00.7601.23471";
        request.Headers.Add("Icy-Metadata:1");

        bool OldUnsafe, UseOldUnsafe;

        UseOldUnsafe = AllowUnsafeHeaderParsing(true, out OldUnsafe);

        // Parts of BeginGetResponse are still done synchronously,
        // so we do it this way.
        Task.Factory.FromAsync <WebResponse>(request.BeginGetResponse,
                                             request.EndGetResponse,
                                             null)
        .ContinueWith(task =>
        {
            if (UseOldUnsafe)
            {
                AllowUnsafeHeaderParsing(OldUnsafe, out OldUnsafe);
            }

            if (task.Status == TaskStatus.RanToCompletion)
            {
                try
                {
                    WebResponse wr = task.Result;

                    // Turn the headers into metadata, plus store them as an
                    // IMFAttribute
                    LoadResponseHeaders(wr.Headers);

                    // The only part of the HttpWebRequest that we keep.
                    m_ResponseStream = wr.GetResponseStream();

                    // In order to (pretend  to) support seeking, we save off a block
                    // of data.  Any seeks to the first DefaultReceiveBufferSize bytes
                    // are resolved from this data.
                    m_PositionReal = long.MaxValue;
                    m_FirstBlock   = new byte[DefaultReceiveBufferSize];
                    WaitRead(m_FirstBlock, 0, DefaultReceiveBufferSize);
                    m_PositionReal = 0;

                    // Used to tell WaitForConnect that the connection is complete.
                    m_ConnectEvent.Set();
                }
                catch
                {
                    Dispose();
                }
            }
            else
            {
                Dispose();
            }
        });

        // While we are waiting for the connect/cache to complete, finish
        // the constructor.

        m_MetaData = new MetaDataContainer();
        MFError hrthrowonerror = MFExtern.MFCreateEventQueue(out m_events);

        m_FixNames = new Dictionary <string, string>(13);

        // Note that the keys are (intentionally) all lower case.
        m_FixNames["icy-name"]                = "WM/RadioStationName";
        m_FixNames["x-audiocast-name"]        = "WM/RadioStationName";
        m_FixNames["icy-genre"]               = "WM/Genre";
        m_FixNames["x-audiocast-genre"]       = "WM/Genre";
        m_FixNames["icy-url"]                 = "WM/PromotionURL";
        m_FixNames["x-audiocast-url"]         = "WM/PromotionURL";
        m_FixNames["x-audiocast-description"] = "Description";
        m_FixNames["x-audiocast-artist"]      = "Author";
        m_FixNames["x-audiocast-album"]       = "WM/AlbumTitle";
        m_FixNames["x-audiocast-br"]          = "BitRate";
        m_FixNames["icy-br"]      = "BitRate";
        m_FixNames["streamtitle"] = "Title";
        m_FixNames["streamurl"]   = "WM/AudioFileURL";

        hrthrowonerror = SetString(
            MFAttributesClsid.MF_BYTESTREAM_EFFECTIVE_URL,
            m_uri.AbsoluteUri);

        // Use this to make async calls to handle meta data.
        m_caller = new LoadValuesCaller(LoadValues);
    }