public Boolean ApplyLoopContentCollection(LoopContentCollection contentForZone) { InitDB(); try { LoopContentCollection lcc = new LoopContentCollection(); lcc.LoadAll(); foreach (var item in lcc) { foreach (var zoneitem in contentForZone) { if (zoneitem.Loopid == item.Loopid && zoneitem.Zoneid == item.Zoneid) { LoopContent lc = new LoopContent(); lc.LoadByPrimaryKey((Int32)item.Id); lc.MarkAsDeleted(); lc.Save(); } } } foreach (LoopContent item in contentForZone) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"--> "+item.Medianame); LoopContent nlc = new LoopContent(); nlc.Mediaid = item.Mediaid; nlc.Medianame = item.Medianame; nlc.Loopname = item.Loopname; nlc.Loopid = item.Loopid; nlc.Zoneid = item.Zoneid; nlc.Zonename = item.Zonename; nlc.Templateid = item.Templateid; nlc.Templatename = item.Templatename; nlc.Order = item.Order; nlc.Save(); } } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+ex.Message); } //SerializeLoopContentCollection(); AddUpdateDelta("loop"); return true; }
public LoopContentCollection CollectLoopContentForZoneByName(string zonename, string loopname) { InitDB(); LoopContentCollection loopContent = new LoopContentCollection(); //tempc.Query.Where(tempc.Query.Name.Equal(zone.Name)); //tempc.Query.Load(); try { loopContent.Query.Where(loopContent.Query.Zonename.Equal(zonename) && loopContent.Query.Loopname.Equal(loopname)); loopContent.Query.Load(); foreach (var item in loopContent) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"<-- " + item.Medianame); } } catch (Exception ex) { } return loopContent; }
public LoopContentCollection CollectLoopContentForZone(Template zone, Loop loop) { InitDB(); LoopContentCollection loopContent = new LoopContentCollection(); try { loopContent.Query.Where(loopContent.Query.Zoneid.Equal(zone.Id) && loopContent.Query.Loopid.Equal(loop.Id)); loopContent.Query.Load(); foreach (var item in loopContent) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"<-- " + item.Medianame); } } catch (Exception ex) { } return loopContent; }
private void SerializeLoopContentCollection() { try { LoopContentCollection loopcc = new LoopContentCollection(); loopcc.LoadAll(); LoopContent[] arrOfLoopContent = loopcc.ToArray(); string FileName = @"c:\content\media\xml\allloopcontent.xml"; using (FileStream fs = new FileStream(FileName, FileMode.Create)) { XmlSerializer ser = new XmlSerializer(typeof(LoopContent[])); ser.Serialize(fs, arrOfLoopContent); fs.Flush(); fs.Close(); } } catch (Exception ex) { } }