Esempio n. 1
0
        public ActionResult AddFeed(string url, string name, string cat)
        {
            int userid = (int)Session["userid"];

            if (Db.currentUser == null)
            {
                Db.currentUser = Db.users.Where(c => c.Id == userid).FirstOrDefault();
            }
            Categories category = Db.categories.Where(c => c.name == cat).FirstOrDefault();

            if (category == null)
            {
                category        = new Categories();
                category.name   = cat;
                category.userId = userid;
                Db.categories.Add(category);
                Db.SaveChanges();
            }

            channel newCh = new channel();

            newCh.categoryId = category.id;
            newCh.title      = name;
            newCh.link       = url;
            newCh.userId     = userid;
            Db.channels.Add(newCh);
            //Db.Entry(newCh).State = System.Data.Entity.EntityState.Modified;
            Db.SaveChanges();

            return(RedirectToAction("RSSIndex"));
        }
Esempio n. 2
0
        public async Task <bool> UpdateTitle(string title)
        {
            bool    success = false;
            channel channel = new channel()
            {
                status = title
            };

            using (HttpClient webClient = CreateHttpClient())
            {
                string endpoint = $"channels/{ConfigurationManager.AppSettings["username"]}";

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, endpoint);
                request.Content = new StringContent(JsonConvert.SerializeObject(new ChannelViewModel()
                {
                    channel = channel
                }), Encoding.UTF8, "application/json");

                HttpResponseMessage response = await webClient.SendAsync(request);

                if (response.IsSuccessStatusCode)
                {
                    success = true;
                }
            }

            return(success);
        }
Esempio n. 3
0
        public void Yield_ClosedChan_ShouldNotBeBlocked()
        {
            channel <int> sut      = new channel <int>(2);
            Task          producer = Task.Run(() =>
            {
                sut.Send(1);
                sut.Send(2);
                sut.Send(3);
            });

            List <int> items    = new List <int>();
            bool       called   = false;
            Task       consumer = Task.Run(() =>
            {
                foreach (int i in sut)
                {
                    items.Add(i);
                }
                called = true;
            });

            producer.Wait();
            sut.Close();
            consumer.Wait(m_awaitTimeout);

            Assert.AreEqual(3, items.Count);
            Assert.IsTrue(called);
        }
Esempio n. 4
0
    void checkDel()
    {
        List <int> delList = new List <int>();

        for (int i = 0; i < socketUsedIDList.Count; i++)
        {
            if (socketList[socketUsedIDList[i]].del || !socketList[socketUsedIDList[i]].socket.Connected)
            {
                socketList[socketUsedIDList[i]].del = false;
                delList.Add(i);
            }
        }
        for (int i = 0; i < delList.Count; i++)
        {
            int        id = socketUsedIDList[delList[i]];
            SocketData so = socketList[id];
            AddFreeID(id);
            Debug.Log("Disconnect from Game " + id);
            while (so.channels.Count > 0)
            {
                channel c = ChannelObjectList[so.channels[0]].GetComponent <channel>();
                if (c != null)
                {
                    c.UnregisterEntity(id);
                }
            }
        }
    }
Esempio n. 5
0
        public void ProducerConsumer_MoreThanChanSize()
        {
            channel <int> sut            = new channel <int>(2);
            bool          producerCalled = false;
            int           totalItemCount = 100;
            Task          producer       = Task.Run(() =>
            {
                for (int i = 1; i <= totalItemCount; i++)
                {
                    sut.Send(i);
                }
                producerCalled = true;
            });

            bool       consumerCalled = false;
            List <int> items          = new List <int>();
            Task       consumer       = Task.Run(() =>
            {
                for (int i = 1; i <= totalItemCount; i++)
                {
                    items.Add(sut.Receive());
                }
                consumerCalled = true;
            });

            Task.WaitAll(producer, consumer);

            Assert.AreEqual(0, sut.Length);
            Assert.IsTrue(producerCalled);
            Assert.IsTrue(consumerCalled);
            CollectionAssert.AreEquivalent(Enumerable.Range(1, totalItemCount).ToArray(), items.ToArray());
        }
        private void Ekle_Click(object sender, RoutedEventArgs e)
        {
            bool checkDup(string nm)
            {
                foreach (channel chanName in chans)
                {
                    if (chanName.username == nm)
                    {
                        return(true);
                    }
                }
                return(false);
            }

            if (textbox_username.Text == String.Empty)
            {
                MessageBox.Show("İsim boş olamaz!", "Uyarı");
                return;
            }
            else if (checkDup(textbox_username.Text))
            {
                textbox_username.Text = String.Empty;
                return;
            }
            ;
            channel ChanToAppend = new channel()
            {
                username = textbox_username.Text.ToLower(), isOnline = "Unknown"
            };

            isimler.Items.Add(ChanToAppend);
            chans.Add(ChanToAppend);
            textbox_username.Text = String.Empty;
        }
Esempio n. 7
0
        public void ProducerConsumer_FastProducer_SlowConsumer()
        {
            channel <int> sut            = new channel <int>(2);
            bool          producerCalled = false;
            Task          producer       = Task.Run(() =>
            {
                sut.Send(1);
                sut.Send(2);
                sut.Send(3);
                producerCalled = true;
            });

            bool       consumerCalled = false;
            List <int> items          = new List <int>();
            Task       consumer       = Task.Run(async() =>
            {
                await Task.Delay(m_slowActionLatency);
                items.Add(sut.Receive());
                await Task.Delay(m_slowActionLatency);
                items.Add(sut.Receive());
                await Task.Delay(m_slowActionLatency);
                items.Add(sut.Receive());
                consumerCalled = true;
            });

            Task.WaitAll(producer, consumer);

            Assert.AreEqual(0, sut.Length);
            Assert.IsTrue(producerCalled);
            Assert.IsTrue(consumerCalled);
            CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, items.ToArray());
        }
        private async Task <(channel, bool)> isOnline(channel channel)
        {
            var client  = new RestClient();
            var request = new RestRequest($"https://api.twitch.tv/kraken/users?login={channel.username}");

            request.AddHeader("Accept", "application/vnd.twitchtv.v5+json");
            request.AddHeader("Client-ID", "***CLIENT-ID***");
            var response = await client.ExecuteAsync(request);

            JsonDataModel jsonresponse = JsonConvert.DeserializeObject <JsonDataModel>(response.Content);

            if (jsonresponse._total == 0)
            {
                return(channel, false);
            }
            string _id = jsonresponse.users[0]["_id"];

            var request2 = new RestRequest($"https://api.twitch.tv/kraken/streams/{_id}");

            request2.AddHeader("Accept", "application/vnd.twitchtv.v5+json");
            request2.AddHeader("Client-ID", "***CLIENT-ID***");
            var response2 = await client.ExecuteAsync(request2);

            JsonDataModel2 jsonresponse2 = JsonConvert.DeserializeObject <JsonDataModel2>(response2.Content);

            if (jsonresponse2.stream == null)
            {
                return(channel, false);
            }
            else
            {
                return(channel, true);
            }
        }
Esempio n. 9
0
        public void Send_CancellationToken_ShouldThrow()
        {
            channel <int>           sut       = new channel <int>(2);
            Exception               exception = null;
            CancellationTokenSource cts       = new CancellationTokenSource();
            Task producer = Task.Run(() =>
            {
                sut.Send(1);
                sut.Send(2);
                try
                {
                    sut.Send(3, cts.Token);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            });

            producer.Wait(m_awaitTimeout);
            cts.Cancel();
            producer.Wait(); // Await the catch block to finish

            Assert.AreEqual(2, sut.Length);
            Assert.IsInstanceOfType(exception, typeof(OperationCanceledException));
        }
Esempio n. 10
0
        public void SendMany_ReceiveFew_SendShouldBeBlocked()
        {
            channel <int> sut      = new channel <int>(2);
            bool?         called   = null;
            Task          producer = Task.Run(() =>
            {
                sut.Send(1);
                sut.Send(2);
                sut.Send(3);
                sut.Send(4);
                sut.Send(5);
                called = false;
                sut.Send(6);
                called = true;
            });

            List <int> items = new List <int> {
                sut.Receive(), sut.Receive(), sut.Receive()
            };

            producer.Wait(m_awaitTimeout);

            Assert.AreEqual(2, sut.Length);
            Assert.IsFalse(called.GetValueOrDefault());
            CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, items.ToArray());
        }
Esempio n. 11
0
        public ActionResult AddFeed(string url, string name, string cat)
        {
            int userid = (int)Session["userid"];
            if (Db.currentUser == null)
            {
                Db.currentUser = Db.users.Where(c => c.Id == userid).FirstOrDefault();
            }
            Categories category = Db.categories.Where(c => c.name == cat).FirstOrDefault();
            if (category == null)
            {
                category = new Categories();
                category.name = cat;
                category.userId = userid;
                Db.categories.Add(category);
                Db.SaveChanges();
            }

            channel newCh = new channel();
            newCh.categoryId = category.id;
            newCh.title = name;
            newCh.link = url;
            newCh.userId = userid;
            Db.channels.Add(newCh);
            //Db.Entry(newCh).State = System.Data.Entity.EntityState.Modified;
            Db.SaveChanges();

            return RedirectToAction("RSSIndex");
        }
Esempio n. 12
0
        public ActionResult DeleteConfirmed(int id)
        {
            channel channel = db.channels.Find(id);

            db.channels.Remove(channel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 13
0
 public static void DeserializationTest(channel catalog1)
 {
     using (StreamWriter writer1 =
                new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Updates\\Test" + ".xml"))
     {
         writer1.WriteLine(catalog1.item[0].description);
     }
 }
Esempio n. 14
0
 //Main form controls/////////////////////////////////////////
 public videoPlayer(int videoId, int userId, int channelId)
 {
     InitializeComponent();
     thisVideo   = bl.getVideo(videoId);
     thisUser    = bl.getUser(userId);
     thisChannel = bl.getChannel(channelId);
     buildToolBar();
 }
 public populateResponse(ref ptr <Response> res = default, channel <ptr <Response> > ch = default, bool wroteHeader = default, bool hasContent = default, bool sentResponse = default, ref ptr <io.PipeWriter> pw = default)
 {
     this.res          = res;
     this.ch           = ch;
     this.wroteHeader  = wroteHeader;
     this.hasContent   = hasContent;
     this.sentResponse = sentResponse;
     this.pw           = pw;
 }
Esempio n. 16
0
    // Update is called once per frame
    void Update()
    {
        CheckPingOut();
        checkDel();
        List <network_utils.cl_data> messages = new List <network_utils.cl_data>();

        messages.Clear();
        Receive(ref messages);
        foreach (network_utils.cl_data bb in messages)
        {
            int count = 0;
            bb.data.CopyTo(bb.data, count);
            network_utils.HEADER header = network_utils.nData.Instance.DeserializeMsg <network_utils.HEADER>(bb.data);
            if (header.signum != network_utils.SIGNUM.BIN)
            {
                continue;
            }
            SetPing(bb.containerID);
            switch (header.command)
            {
/*                case (int)network_data.COMMANDS.cend_ingame:
 *                  {
 *                      network_data.end_ingame com = network_utils.nData.Instance.DeserializeMsg<network_data.end_ingame>(bb.data);
 *                      socketList[com.header.containerID].del = true;
 *                  }
 *                  break;
 */
            case (int)network_data.COMMANDS.cping:
            {
                network_data.ping com = network_utils.nData.Instance.DeserializeMsg <network_data.ping>(bb.data);
                com.relfecttime = Timer.ElapsedMilliseconds;
                byte[] data = network_utils.nData.Instance.SerializeMsg <network_data.ping>(com);
                Send(com.header.containerID, data);
            }
            break;

            case (int)network_data.COMMANDS.cset_ingame_param:
            {
                network_data.set_ingame_param com = network_utils.nData.Instance.DeserializeMsg <network_data.set_ingame_param>(bb.data);
                socketList[com.header.containerID].playername = com.playername;
            }
            break;

            default:
            {
                channel c = ChannelObjectList[header.channelID].GetComponent <channel>();
                c.ProcessMessage(ref bb.data, c.gameObject.GetComponent <receiver>());
            }
            break;
            }
        }
        if (beginning == true && socketUsedIDList.Count == 0)
        {
            endgame = true;
        }
    }
Esempio n. 17
0
            private void Move_Down_Click(object sender, EventArgs e)
            {
                int     s = Channel_View.SelectedIndex;
                channel t = (channel)Channel_View.Items[s];

                Channel_View.Items.Insert(s + 1, t);
                Channel_View.Items.RemoveAt(s - 1);
                Update_Channel_IDS();
                Clear_Render();
            }
Esempio n. 18
0
 public ActionResult Edit([Bind(Include = "channelid,name,picture")] channel channel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(channel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(channel));
 }
Esempio n. 19
0
        public ActionResult Create([Bind(Include = "channelid,name,picture")] channel channel)
        {
            if (ModelState.IsValid)
            {
                db.channels.Add(channel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(channel));
        }
Esempio n. 20
0
        public UserConnectedChannelResult(channel channelWhithSingleConnected)
        {
            var connect = channelWhithSingleConnected.GetConnections().First();

            ChannelData           = channelWhithSingleConnected;
            ChannelConnectionId   = connect.Id;
            MessageSend           = connect.messageSend;
            MessageRead           = connect.messageRead;
            ConnectedUserId       = connect.userId;
            ConnectedUserPassword = connect.password;
        }
Esempio n. 21
0
    static void sum(slice <int> s, ref channel <int> c)
    {
        var sum = 0;

        foreach ((long, int)_tuple in s)
        {
            var(_, v) = _tuple;
            sum      += v;
        }
        c.Send(sum); // send sum to c
    }
Esempio n. 22
0
 // Use this for initialization
 public void Init(channel mychannel)
 {
     this.mychannel = mychannel;
     if (InteractionLink)
     {
         link = InteractionLink.GetComponent <interactionlink>();
         if (link)
         {
             link.SetTrigger(this);
         }
     }
 }
Esempio n. 23
0
                // MaybeReadByte reads a single byte from r with ~50% probability. This is used
                // to ensure that callers do not depend on non-guaranteed behaviour, e.g.
                // assuming that rsa.GenerateKey is deterministic w.r.t. a given random stream.
                //
                // This does not affect tests that pass a stream of fixed bytes as the random
                // source (e.g. a zeroReader).
                public static void MaybeReadByte(io.Reader r)
                {
                    closedChanOnce.Do(() =>
                    {
                        closedChan = make_channel <object>();
                        close(closedChan);
                    });

                    return;

                    array <byte> buf = new array <byte>(1L);

                    r.Read(buf[..]);
Esempio n. 24
0
    static void fibonacci(int n, channel <int> c)
    {
        int x = 0, y = 1;

        for (int i = 0; i < n; i++)
        {
            c.Send(x);
            var _y1 = x + y;
            x = y;
            y = _y1;
        }
        close(c);
    }
Esempio n. 25
0
        public ActionResult EditChannel(int channelId, string nName)
        {
            channel ch = Db.channels.Where(c => c.id == channelId).FirstOrDefault();

            if (ch != null)
            {
                ch.title           = nName;
                Db.Entry(ch).State = System.Data.Entity.EntityState.Modified;
                Db.SaveChanges();
            }

            return(RedirectToAction("RSSIndex"));
        }
        public static channel ConvertRowChannelWhithConnectedChannel(dynamic sqlResponceChannelWithConnectedChannel)
        {
            var item = sqlResponceChannelWithConnectedChannel;

            var hasChannel = item.channel_connection__Id != null && item.channel_connection__Id != 0;

            if (!hasChannel)
            {
                throw new ArgumentNullException(Error.ChannelNotExist);
            }
            var channel = new channel
            {
                Id          = (int)item.channel__channelId,
                channelType = (byte)item.channel__channelType,
                channelName = (string)item.channel__channelName,
                password    = (string)item.channel__password,
                dateCreate  = (int)item.channel__dateCreate,
                creatorId   = (int)item.channel__creatorId,
                creatorName = (string)item.channel__creatorName,
                channelIcon = (string)item.channel__channelIcon
            };


            var hasChk = item.channel_connection__Id != null && item.channel_connection__Id != 0;
            channel_connection chCon = null;

            if (hasChk)
            {
                chCon = new channel_connection
                {
                    Id          = (long)item.channel_connection__Id,
                    channelId   = (int)item.channel_connection__channelId,
                    channelType = (byte)item.channel_connection__channelType,
                    userId      = (int)item.channel_connection__userId,
                    password    = (string)item.channel_connection__password,
                    messageRead = (bool)item.channel_connection__messageRead,
                    messageSend = (bool)item.channel_connection__messageSend
                };
            }

            if (!hasChk)
            {
                return(channel);
            }
            chCon.SetChannel(channel);
            channel.SetConnections(new List <channel_connection>(1)
            {
                chCon
            });
            return(channel);
        }
Esempio n. 27
0
        private void myChannelView_Load(object sender, EventArgs e)
        {
            //place holder
            //MessageBox.Show(sender.ToString());
            thisUser    = bl.getUser(1);
            thisChannel = bl.getChannel(1);

            List <video> videoData = new List <video>();

            videoData = thisChannel.getVidoes();
            listBoxVidoes.DisplayMember = "nameText";
            listBoxVidoes.DataSource    = videoData;
            LabelChannelName.Text       = thisChannel.getName();
        }
Esempio n. 28
0
        public static DeliveryMethod ToDeliveryMethod(this channel deliveryMethod)
        {
            switch (deliveryMethod)
            {
            case channel.PRINT:
                return(DeliveryMethod.Print);

            case channel.DIGIPOST:
                return(DeliveryMethod.Digipost);

            default:
                throw new ArgumentOutOfRangeException(nameof(deliveryMethod), deliveryMethod, null);
            }
        }
Esempio n. 29
0
        public void Receive_FromNonEmptyChan_ShouldNotBeBlocked()
        {
            channel <int> sut = new channel <int>(2);

            sut.Send(1);
            sut.Send(2);

            int item1 = sut.Receive();
            int item2 = sut.Receive();

            Assert.AreEqual(0, sut.Length);
            Assert.AreEqual(1, item1);
            Assert.AreEqual(2, item2);
        }
Esempio n. 30
0
        public void Receive_NoSend_NoBufferedChan_ShouldBlock()
        {
            channel <int> sut      = new channel <int>(1);
            bool          called   = false;
            Task          receiver = Task.Run(() =>
            {
                sut.Receive();
                called = true;
            });

            receiver.Wait(m_awaitTimeout);

            Assert.IsFalse(called);
        }
Esempio n. 31
0
        public void Receive_ShouldBeBlocked_IfNoOneSend()
        {
            channel <int> chan   = new channel <int>(1);
            bool          called = false;
            Task          task   = Task.Run(() =>
            {
                chan.Receive();
                called = true;
            });

            task.Wait(m_awaitTimeout);

            Assert.IsFalse(called);
        }
        public void AddChannelHistory()
        {
            try
            {
                string channelNo = Context.Request["channelNo"];
                string url = Context.Request["url"];
                string ip = Context.Request["ip"];
                string mac = Context.Request["mac"];

                DateTime createDate = DateTime.Now.Date;
                bool isExists = channelhistory.Exists("channelNo = @0 and ip = @1 and createdate=@2", channelNo, (string.IsNullOrWhiteSpace(mac) ? ip : mac), createDate);

                if (isExists)
                {
                    PrintSuccessJson(true.ToString().ToLower());
                }
                else
                {

                    channel model = channel.SingleOrDefault("where channelNo = @0", channelNo);
                    if (model == null)
                    {
                        model = new channel();
                    }

                    if (model.IsNew())
                    {
                        model.count = 1;
                        model.date_created = DateTime.Now;
                        model.channelNo = channelNo;
                        model.Insert();
                    }
                    else
                    {
                        model.count += 1;
                        model.Update();
                    }
                    channelhistory channelHistoryModel = new channelhistory();
                    channelHistoryModel.channelNo = channelNo;
                    channelHistoryModel.date_created = DateTime.Now;
                    channelHistoryModel.url = url;
                    channelHistoryModel.createdate = createDate;
                    channelHistoryModel.ip = string.IsNullOrWhiteSpace(mac) ? ip :mac;
                    channelHistoryModel.Insert();

                    //安装量、ip流量统计
                    channelinstallinfo installmodel = channelinstallinfo.SingleOrDefault("where channelNo = @0 and createdate=@1", channelNo, createDate);
                    if (installmodel == null)
                    {
                        installmodel = new channelinstallinfo();
                    }

                    if (installmodel.IsNew())
                    {
                        installmodel.ipcount = 1;
                        installmodel.realinstallcount = 0;
                        installmodel.createdate = createDate;
                        installmodel.inputinstallcount = 0;
                        installmodel.channelNo = channelNo;
                        installmodel.paymentstate = false;
                        installmodel.date_created = DateTime.Now;
                        installmodel.Insert();
                    }
                    else
                    {
                        installmodel.ipcount += 1;
                        installmodel.Update();
                    }


                    PrintSuccessJson(true.ToString().ToLower());
                }
            }
            catch (Exception ex)
            {
                PrintSuccessJson(false.ToString().ToLower());
            }
        }
		private async void AddFeedUrl( string url ) {
			var newFeed = new channel {
				DateAdded = DateTime.Now,
				Url = url
			};

			using ( var client = new HttpClient( ) ) {
				var xmlFeed = await client.GetStringAsync( url );
				var doc = XDocument.Parse( xmlFeed );

				var channel = doc.Descendants( "channel" ).FirstOrDefault( ).Element( "title" ).Value;
				newFeed.Name = channel;

				XNamespace dc = "http://purl.org/dc/elements/1.1/";
				newFeed.Allitem = ( from item in doc.Descendants( "item" )
					select new items {
						Title = item.Element( "title" ).Value,
						PubDate = item.Element( "pubDate" ).Value,
						Creator = item.Element( dc + "creator" ).Value,
						Link = item.Element( "link" ).Value
					} ).ToList( );

				_feeds.Add(newFeed);
				UpdateList( );
			}
		}