Beispiel #1
0
 public Boolean InsertLoop(Loop loop)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         Loop newLoop = new Loop();
         newLoop.Name = loop.Name;
         newLoop.Description = loop.Description;
         newLoop.Templateid = loop.Templateid;
         newLoop.Templatename = loop.Templatename;
         session.Store(newLoop);
         session.SaveChanges();
         return true;
     }
     return false;
 }
Beispiel #2
0
 public Boolean RemoveLoop(Loop loop)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         Loop deleteLoop = new Loop();
         deleteLoop = session.Load<Loop>(loop.Id);
         session.Delete(deleteLoop);
         session.SaveChanges();
         return true;
     }
     return false;
 }
Beispiel #3
0
        public Loop CollectThisLoop(string loopName)
        {
            InitDB();
                Loop lc = new Loop();

                using (var session = documentStore.OpenSession())
                {
                    var d = (from x in session.Query<Loop>()
                             where x.Name == loopName
                             select x).SingleOrDefault();
                    lc = d;
                }

                try
                {
                    Console.WriteLine(DateTime.Now.ToShortTimeString() + "  " + "Collecting Loop:" + lc.Name);
                    return lc;
                }
                catch (Exception)
                {
                    return null;
                }
        }
Beispiel #4
0
 public ObservableCollection<LoopContent> CollectLoopContentForZone(Template zone, Loop loop)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         var lc = from x in session.Query<LoopContent>()
                  where x.Zoneid == zone.Id && x.Loopid == loop.Id
                  select x;
         return new ObservableCollection<LoopContent>(lc);
     }
     return null;
 }
Beispiel #5
0
        private void ConfigureAndTriggerSchedule(DAL.Schedule currentSchedule)
        {
            Boolean CoreWorkingOK = true;

            si.sie("ConfigureAndTriggerSchedule");
            string allTickerText = "";
            KillTicker();

            Boolean tickerFound = false;
            TickerMetaToUse = "";
            contentCollection.Clear();

            try
            {
                //"text 0 690 1024 80 clWhite Arial 48 5"
                gridFive.Visibility = Visibility.Collapsed;
                gridFour.Visibility = Visibility.Collapsed;
                gridThree.Visibility = Visibility.Collapsed;
                gridTwo.Visibility = Visibility.Collapsed;

                #region CollectContentCollection
                try
                {
                    foreach (DAL.Content item in proxy.CollectMedia())
                    {
                        contentCollection.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    CoreWorkingOK = false;
                    contentCollection.Clear();
                }

                si.sii("Content Collection Count = " + contentCollection.Count().ToString());


                //if there is an error the collection is cleared and loaded from xml, if it worked the collection is saved for future use
                if (contentCollection.Count > 0)
                {
                    SerializeContentCollection(@"c:\tmp\content.xml");
                }
                else
                {
                    contentCollection.Clear();
                    if (FTPONLY)
                    {
                        contentCollection = DeSerializeContentCollection(@"c:\tmp\xml\content.xml");
                    } 
                    else
                    {
                        contentCollection = DeSerializeContentCollection(@"c:\tmp\content.xml");
                    }
                };
                #endregion


                si.sii("Collecting Media in Content Collection");
                CollectMediaInContentCollection(); //Collect All Media
                si.sii("Collect this loop:"+currentSchedule.Loopname);

                #region CollectCurrentLoop
                try
                {
                    if (CoreWorkingOK)
                    {
                        currentLoop = proxy.CollectThisLoop(currentSchedule.Loopname); //Collect Loop
                        SerializeCurrentLoop(@"c:\tmp\loop.xml");
                    }
                    else
                    {
                        currentLoop = null;
                    }
                }
                catch (Exception)
                {
                    currentLoop = null;
                }

                if (currentLoop == null) si.sii("Current Loop is NULL possibly because Core isn't working - Collect from XML");
                si.sii("FTP Only Variable = "+FTPONLY.ToString());

                if (currentLoop == null)
                {
                    if (FTPONLY)
                    {
                        si.sii(@"INSIDE FTP ONLY - Deserializing c:\tmp\xml\loops.xml");
                        ObservableCollection<Loop> lc = new ObservableCollection<Loop>();
                        //DAL.LoopCollection lc = new LoopCollection();
                        try
                        {
                            lc = DeSerializeLoopCollection(@"c:\tmp\xml\loops.xml");
                            si.sii(@"Items in Loops.xml:"+lc.Count.ToString());
                        }
                        catch (Exception e3)
                        {
                            si.six(e3);
                        }
                        
                        foreach (var l in lc)
                        {
                            si.sii("Stepping through loops.xml:"+l.Name+"/"+l.Templatename+"/"+l.Templateid.ToString());
                           if (l.Name == currentSchedule.Loopname)
                           {
                               currentLoop = l;
                               si.sii("Current Loop = "+currentLoop.Name);
                               break;
                           }
                        }
                    } else
                    {
                        currentLoop = DeSerializeCurrentLoop(@"c:\tmp\loop.xml");    
                    }
                }
                #endregion

                try
                {
                    LastLoopTick = proxy.CollectDelta("loop");
                    LastTickerTick = proxy.CollectDelta("ticker");
                }
                catch (Exception)
                {
                }

                #region CollectTemplateCollection
                si.sii("Collect this template:" + currentLoop.Templatename);
                try
                {
                    templateCollection = proxy.CollectZonesForThisTemplateName(currentLoop.Templatename); //CollectTemplate
                }
                catch (Exception)
                {
                    templateCollection.Clear();
                }

                if (templateCollection.Count > 0)
                {
                    SerializeTemplateCollection(@"c:\tmp\template.xml");
                }
                else
                {
                    if (FTPONLY)
                    {
                        try
                        {
                            templateCollection.Clear();
                            //TemplateCollection tmpCollection = new TemplateCollection();
                            ObservableCollection<Template> tmpCollection = new ObservableCollection<DAL.Template>();
                            tmpCollection = DeSerializeTemplateCollection(@"c:\tmp\xml\template.xml");
                            foreach (var t in tmpCollection)
                            {
                                if (t.Name == currentLoop.Templatename && t.Zonename != "_template")
                                {
                                    templateCollection.Add(t);
                                    si.sii("Template Zone Added = " + t.Name + "/" + t.Zonename + "/" + t.Zonedescription);
                                }
                            }
                            si.sii("Zones in Template = "+templateCollection.Count.ToString());
                        }
                        catch (Exception x1)
                        {
                            si.six(x1);
                        }
                    } else
                    {
                        templateCollection = DeSerializeTemplateCollection(@"c:\tmp\template.xml");
                        foreach (var t in templateCollection)
                        {
                            si.sii("Template Zone Added = " + t.Name + "/" + t.Zonename + "/" + t.Zonedescription);
                        }
                        si.sii("Zones in Template = " + templateCollection.Count.ToString());
                    }
                }
                #endregion

                //Populate Zones
                contentQ.Clear();
                contentQ2.Clear();
                contentQ3.Clear();
                contentQ4.Clear();
                contentQ5.Clear();
                int count = 1;
                int tickerInCount = 0; //equals count where ticker is found, 0 by default means no ticker
                int backGroundCount = 0; // //equals count where ticker is found, 0 by default means background is empty (we hide this grid)
                string TickerBackgroundColour = "";
                double TickerOpacity = 0;
                allTickerText = "";

                si.sii("===============================");
                si.sii("===============================");

                foreach (var item in templateCollection)
                {
                    try
                    {
                        if (CoreWorkingOK)
                        {
                            loopContentCollection = proxy.CollectLoopContentForZoneByName(item.Zonename, currentLoop.Name);
                            SerializeLoopContentCollection(@"c:\tmp\zone\" + item.Zonename + ".xml", loopContentCollection);
                        }
                        else
                            if (FTPONLY && File.Exists(@"c:\tmp\xml\allloopcontent.xml"))
                            {
                                //LoopContentCollection tmpLCC = new LoopContentCollection();
                                ObservableCollection<LoopContent> tmpLCC = new ObservableCollection<LoopContent>();
                                si.sii("Collecting from tmpxml alllloopcontent.xml");
                                tmpLCC = DeSerializeLoopContentCollection(@"c:\tmp\xml\allloopcontent.xml");
                                si.sii("LoopContent Items collected from xml = " + tmpLCC.Count.ToString());
                                loopContentCollection.Clear();
                                foreach (LoopContent c in tmpLCC)
                                {
                                    si.sii("STEPPING THROUGH Loop Content tmpLCC:" + c.Medianame);
                                    if (c.Zonename == item.Zonename && c.Loopname == currentLoop.Name)
                                    {
                                        si.sii("ADDING TO LOOP Content Collection Content tmpLCC:" + c.Medianame);
                                        loopContentCollection.Add(c);
                                    }
                                }
                            }
                            else
                            {
                                loopContentCollection = DeSerializeLoopContentCollection(@"c:\tmp\zone\" + item.Zonename + ".xml");
                            }
                    }
                    catch (Exception ei)
                    {
                        si.six(ei);
                    }

                    if (item.ZoneType.ToLower() == "Location and Weather strip".ToLower())
                    {
                        tbLocation.Text = Properties.Settings.Default.ClientID.ToUpper();
                        borderWeatherStrip.Visibility = Visibility.Visible;
                        UpdateWeather();
                    }

                    if (item.ZoneType.ToLower() == "Weather Box".ToLower())
                    {
                        tbLocation.Text = Properties.Settings.Default.ClientID.ToUpper();
                        borderWeatherRight.Visibility = Visibility.Visible;
                        UpdateWeather();
                    }

                    si.sii(item.Zonename + "/" + item.X + "/" + item.Width);
                    foreach (var lc in loopContentCollection)
                    {
                        #region First Configure the Ticker
                        try
                        {
                            foreach (var cc in contentCollection)
                            {
                                if (cc.Contenttype == "Ticker" && lc.Mediaid == cc.Id)
                                {
                                    //Return All TickerMeta
                                    allTickerText += cc.Metadata8 + "    ";
                                    TickerMeta = "text";
                                    TickerMeta += " " + item.X.ToString(); //"text 0 690 1024 80 clWhite Arial 48 5"
                                    TickerMeta += " " + item.Y.ToString();
                                    TickerMeta += " " + item.Width.ToString();
                                    TickerMeta += " " + item.Height.ToString();
                                    Color tickerC = new Color();
                                    ColorConverter ccv = new ColorConverter();
                                    string tickerColour = cc.Metadata4;
                                    TickerMeta += " $00" + tickerColour.Substring(7, 2) + tickerColour.Substring(5, 2) + tickerColour.Substring(3, 2);//0000FF";// Color.FromRgb(0xFF, 0xFF, 0xFF).ToString(); //Color

                                    TickerBackgroundColour = cc.Metadata6;
                                    TickerOpacity = Convert.ToDouble(cc.Metadata7);
                                    UserControlContent.TickerBackgroundOpacity = TickerOpacity;
                                    
                                    TickerMeta += " " + cc.Metadata2; //Font
                                    TickerMeta += " " + cc.Metadata3; //Size
                                    //TickerMeta += " " + cc.Metadata5; //Speed
                                    TickerMeta += " 12";
                                    if (lc.Order == 1)
                                    {
                                        tickerFound = true;
                                        UserControlContent.TickerBackgroundColour = TickerBackgroundColour;
                                        TickerMetaToUse = TickerMeta;
                                        tickerInCount = count;
                                        si.sii("TICKER METADATA = " + TickerMeta);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {    
                        }
                        #endregion

                        //Do the rest
                        si.sii("Looping through ContentCollection...Medianame="+lc.Medianame+" / LoopName="+lc.Loopname);
                        foreach (var cc in contentCollection)
                        {
                            if (cc.Contenttype != "Ticker" && lc.Mediaid == cc.Id)
                                {
                                    //selectedn = @"c:\content\_media\" + System.IO.Path.GetFileName(selectedn);
                                    if (cc.Contenttype == "Background") backGroundCount = count;
                                    if (count == 1)
                                    {
                                        contentQ2.Add(cc);
                                        si.sii("ADDING CONTENT TO Q2:"+cc.Filelocation);
                                    }
                                    if (count == 2)
                                    {
                                        contentQ3.Add(cc);
                                        si.sii("ADDING CONTENT TO Q3:" + cc.Filelocation);
                                    }
                                    if (count == 3)
                                    {
                                        contentQ4.Add(cc);
                                    }
                                    if (count == 4) contentQ5.Add(cc);
                                    si.sii(@"c:\content\_media\" + System.IO.Path.GetFileName(cc.Filelocation));
                                }
                        }
                    }

                    try
                    {
                        WriteTickerFile(allTickerText);
                    }
                    catch (Exception)
                    {
                    }

                    uccTwo = new UserControlContent();
                    uccThree = new UserControlContent();
                    uccFour = new UserControlContent();
                    uccFive = new UserControlContent();

                    Grid currentGrid = null;

                    #region PopulateGridWithContent
                    if (count == 1)
                    {
                        if (tickerInCount == 1)
                        {
                            uccTwo.IsTickerBackground = true;
                        }
                        gridTwo.Children.Clear();
                        gridTwo.Children.Add(uccTwo);
                        currentGrid = gridTwo;
                        if (contentQ.Count == 0) currentGrid = gridHiddenGrid;
                        uccTwo.SetContentQ(contentQ2);
                        KeepAliveTicker++;
                        si.sii("Firing Grid 2");
                    }
                    else
                        if (count == 2)
                        {
                            if (tickerInCount == 2)
                            {
                                uccThree.IsTickerBackground = true;
                            }
                            gridThree.Children.Clear();
                            gridThree.Children.Add(uccThree);
                            currentGrid = gridThree;
                            uccThree.SetContentQ(contentQ3);
                            KeepAliveTicker++;
                            si.sii("Firing Grid 3");
                        }
                        else
                            if (count == 3)
                            {
                                if (tickerInCount == 3)
                                {
                                    uccFour.IsTickerBackground = true;
                                }
                                gridFour.Children.Clear();
                                gridFour.Children.Add(uccFour);
                                currentGrid = gridFour;
                                uccFour.SetContentQ(contentQ4);
                                KeepAliveTicker++;
                                si.sii("Firing Grid 4");
                            }
                            else
                                if (count == 4)
                                {
                                    if (tickerInCount == 4)
                                    {
                                        uccFive.IsTickerBackground = true;
                                    }
                                    gridFive.Children.Clear();
                                    gridFive.Children.Add(uccFive);
                                    currentGrid = gridFive;
                                    uccFive.SetContentQ(contentQ5);
                                    KeepAliveTicker++;
                                    si.sii("Firing Grid 5");
                                };
                    #endregion
                    //gridTwo.Children.Add(ucc);
                    //ucc.SetContentQ(contentQ);

                    double x = Convert.ToDouble(item.X); //sim("targetx=" + target.x);
                    double y = Convert.ToDouble(item.Y); //sim("targety=" + target.y);
                    double width = Convert.ToDouble(item.Width);
                    double height = Convert.ToDouble(item.Height);

                    currentGrid.Width = width;
                    currentGrid.Height = height;
                    currentGrid.Opacity = Convert.ToDouble(item.Opacity);
                    Canvas.SetTop(currentGrid, y);
                    Canvas.SetLeft(currentGrid, x);

                    //Canvas.SetZIndex(currentGrid, Convert.ToInt16(target.layer));
                    //sim(gridIndex + "|" + currentGrid + "x=" + x + " y=" + y);

                    currentGrid.Visibility = Visibility.Visible;

                    count++;

                    if (backGroundCount == 1) gridTwo.Visibility = Visibility.Collapsed;
                    if (backGroundCount == 2) gridThree.Visibility = Visibility.Collapsed;
                    if (backGroundCount == 3) gridFour.Visibility = Visibility.Collapsed;
                    if (backGroundCount == 4) gridFive.Visibility = Visibility.Collapsed;
                }
            }
            catch
            {
            }
            try
            {
                tickerTimer.Start();
            }
            catch (Exception ex)
            {
                
            }
            
            si.sil("ConfigureAndTriggerSchedule");
            //this.Topmost = true;
            //this.Activate();
            //this.Focus();
        }
Beispiel #6
0
        private DAL.Loop DeSerializeCurrentLoop(string FileName)
        {
            DAL.Loop xmlResult = new DAL.Loop();
            try
            {
                using (FileStream fs = new FileStream(FileName, FileMode.Open))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(DAL.Loop));
                    xmlResult = (DAL.Loop)ser.Deserialize(fs);
                }
            }
            catch (Exception ex)
            {

            }
            return xmlResult;
        }
Beispiel #7
0
        public MainWindow()
        {
            InitializeComponent();

            this.Topmost = true;
            this.Activate();
            this.Focus();

            InitTmpFolder();

            borderWeatherStrip.Visibility = Visibility.Hidden;
            borderWeatherRight.Visibility = Visibility.Hidden;

            if (Properties.Settings.Default.Registration == "U")
            {
                AttemptSoftwareRegistration();
            }

            currentLoop = new DAL.Loop();
            currentLoop.Id = "0"; //Set for Startup so that there is no current loop firing and so that schedule fires right away

            si.EnableSmartInspect("DC", true);

            CreateFolders();
            BuildTimers();
            borderConfiguration.Visibility = Visibility.Collapsed;
            try
            {
                InitializeServices();
            }
            catch (Exception ex)
            {
            }

            try
            {
                TestService();
            }
            catch (Exception ex)
            {
            }
            
            //if (Properties.Settings.Default.Diagnostic == true)
            //{
            //    FetchTicker();
            //    SetTickerMeta();
            //    ShowTickerHTML(TickerMeta);
            //    if (IsTickerRunning() == false)
            //    {
            //        System.Threading.Thread.Sleep(500);
            //        ShowTickerHTML(TickerMeta); //"text 0 690 1024 80 clWhite Arial 48 5"
            //    }
            //}

            SimulateMouseClick();
        }