Beispiel #1
0
        public override void ProcessChatRoomMessage(object sender, MessageEventArgs e)
        {
            string[] SplitMessage = e.ReceivedMessage.Split(null);
            foreach (string Word in SplitMessage) //We do this to handle multiple videos
            {
                string VideoID = ExtractID(Word);

                if (string.IsNullOrEmpty(VideoID))
                {
                    //Do Nothing
                }
                else
                {
                    string VideoData = GetVideoData(VideoID);
                    if (string.IsNullOrEmpty(VideoData))
                    {
                        //Do Nothing
                    }
                    else
                    {
                        string item = VideoData;//.Replace("\n", string.Empty);
                        string TimeString;

                        Console.WriteLine(item);

                        dynamic    red  = JsonConvert.DeserializeObject(item);
                        RootObject data = JsonConvert.DeserializeObject <RootObject>(item);

                        string time = data.items[0].contentDetails.duration;

                        if (time.Contains("D"))
                        {
                            TimeString = "Over 24 Hours long";
                        }
                        else
                        {
                            TimeString = XmlConvert.ToTimeSpan(time).ToString();
                        }

                        string Hoursheader = "00:";
                        if (TimeString.StartsWith(Hoursheader))
                        {
                            TimeString = TimeString.Substring(Hoursheader.Length, TimeString.Length - Hoursheader.Length);
                        }
                        if (TimeString.Equals("00:00"))
                        {
                            TimeString = "Stream";
                        }
                        e.ReplyMessage = data.items[0].snippet.title + " [" + TimeString + "]";
                        e.InterfaceHandlerDestination.SendChatRoomMessage(this, e);
                    }
                    Console.WriteLine(GetVideoData(VideoID));
                }
            }
        }
Beispiel #2
0
        private void ShowDetail(int Line)
        {
            CurrentLine = Line;
            gntDetail.ClearChartBars();
            label2.Text        = "Resource # " + Line.ToString() + " Detail";
            gntDetail.FromDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 0, 0, 0);
            gntDetail.ToDate   = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59);

            DataTable dt = _DS.Tables[0];
            int       i = 0;
            int       etHrs, etMins;
            string    ProductionLine, PrevProductionLine, TimeString, ProductName;
            int       stHrs = -1;
            int       stMins = -1;
            DateTime  StartTime, EndTime;
            Double    Setup, RunTime, RunLength;

            //     PrevProductionLine is used to iterate through the rows of the input dataset and
            //     determine when we have found the right production line to display
            PrevProductionLine = "";
            gntDetail.ClearSelection();

            int dbIndex = 0;

            foreach (DataRow dr in dt.Rows)
            {
                if (dr.RowState == DataRowState.Deleted)
                {
                    dbIndex++;
                    continue;
                }
                EndTime        = (DateTime)dr["End Time"];
                Setup          = (double)dr["Setup Time"];
                RunTime        = (double)dr["Run Time"];
                ProductionLine = dr["Resource Number"].ToString();
                ProductName    = (string)dr["Product Name"];
                if (Convert.ToInt32(ProductionLine) == Line)
                {
                    if (PrevProductionLine != ProductionLine)
                    {
                        RunLength = RunTime + Setup;
                        TimeSpan ts = new TimeSpan(0, (int)RunLength, 0);
                        StartTime  = EndTime - ts;
                        TimeString = StartTime.ToString("HH:mm");
                        stHrs      = Convert.ToInt32(TimeString.Substring(0, 2));
                        stMins     = Convert.ToInt32(TimeString.Substring(3, 2));
                    }
                    if (Setup != 0)
                    {
                        TimeSpan ts       = new TimeSpan(0, (int)RunTime, 0);
                        DateTime SetupEnd = EndTime - ts;
                        TimeString = SetupEnd.ToString("HH:mm");
                        etHrs      = Convert.ToInt32(TimeString.Substring(0, 2));
                        etMins     = Convert.ToInt32(TimeString.Substring(3, 2));
                        gntDetail.AddChartBar(ProductName, ProductionLine, new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, stHrs, stMins, 0),
                                              new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, etHrs, etMins, 0), SetupColor, Color.Khaki, i, dbIndex, true, false);

                        stHrs  = etHrs;
                        stMins = etMins;
                    }
                    TimeString = EndTime.ToString("HH:mm");
                    etHrs      = Convert.ToInt32(TimeString.Substring(0, 2));
                    etMins     = Convert.ToInt32(TimeString.Substring(3, 2));

                    gntDetail.AddChartBar(ProductName, ProductionLine, new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, stHrs, stMins, 0),
                                          new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, etHrs, etMins, 0), RunColor, Color.Khaki, i, dbIndex, false, false);
                    stHrs  = etHrs;
                    stMins = etMins;
                    i++;
                }
                dbIndex++;
            }
            gntDetail.PaintChart();
        }