예제 #1
0
파일: RDB.cs 프로젝트: keyanmca/_Signage
 public Boolean RemoveScreen(Screen screenName)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         Screen deleteScreen = new Screen();
         deleteScreen = session.Load<Screen>(screenName.Id);
         session.Delete(deleteScreen);
         session.SaveChanges();
         return true;
     }
     return false;
 }
예제 #2
0
파일: RDB.cs 프로젝트: keyanmca/_Signage
        public string RegisterDisplayClientLogin(string screenid)
        {
            InitDB();

            si.sii("Registering Displayclient with DB: " + screenid);
            string functionResult = "_none";

            using (var session = documentStore.OpenSession())
            {
                var screenC = from x in session.Query<Screen>()
                              //where x.Screenname == screenid
                              select x;

                Boolean f = false;
                foreach (var s in screenC)
                {
                    if (s.Screenname == screenid)
                    {
                        f = true; //do update
                        s.Lastactive = (DateTime)DateTime.Now;
                        functionResult = s.Groupid;
                        session.Store(s);
                        session.SaveChanges();
                        return functionResult;
                    }
                }

                if (!f) //not found, add screen
                {
                    Screen newScreen = new Screen();
                    newScreen.Screenname = screenid;
                    newScreen.Description = "New";
                    newScreen.Location = "Default";
                    newScreen.Groupid = "Global";
                    newScreen.Lastactive = (DateTime)DateTime.Now;
                    functionResult = "_registered";
                    session.Store(newScreen);
                    session.SaveChanges();
                    return functionResult;
                }
            }

            return null;
        }
예제 #3
0
파일: RDB.cs 프로젝트: keyanmca/_Signage
 public Boolean ChangeScreenGroup(Screen screen)
 {
     InitDB();
     Screen updateScreen = new Screen();
     using (var session = documentStore.OpenSession())
     {
         updateScreen = session.Load<Screen>(screen.Id);
         updateScreen.Groupid = screen.Groupid;
         session.Store(updateScreen);
         session.SaveChanges();
     }
     //updateScreen.LoadByPrimaryKey((long)screen.Id);
     //updateScreen.Groupid = screen.Groupid;
     //updateScreen.Save();
     return true;
 }
예제 #4
0
파일: RDB.cs 프로젝트: keyanmca/_Signage
 public Boolean InsertScreen(Screen screen)
 {
     InitDB();
     using (var session = documentStore.OpenSession())
     {
         Screen newScreen = new Screen();
         newScreen.Screenname = screen.Screenname;
         newScreen.Description = screen.Description;
         newScreen.Location = screen.Location;
         newScreen.Groupid = screen.Groupid;
         session.Store(newScreen);
         session.SaveChanges();
         return true;
     }
     return false;
 }
예제 #5
0
파일: RDB.cs 프로젝트: keyanmca/_Signage
        public string RegisterDisplayClientLogin(string screenid)
        {
            InitDB();
            string functionResult = "_none";

            using (var session = documentStore.OpenSession())
            {
                var screenC = from x in session.Query<Screen>()
                              where x.Screenname.ToLower() == screenid.ToLower()
                              select x;
                if (screenC.Count() <= 0) //New
                {
                    Screen newScreen = new Screen();
                    newScreen.Screenname = screenid;
                    newScreen.Description = "New";
                    newScreen.Location = "Default";
                    newScreen.Groupid = "Global";
                    newScreen.Lastactive = (DateTime)DateTime.Now;
                    functionResult = "_registered";
                    try
                    {
                        session.Store(newScreen);
                        session.SaveChanges();
                        functionResult = "_registered";
                    }
                    catch (Exception ex)
                    {
                        functionResult = "_error";
                    }
                }
                else
                {
                    foreach (Screen item in screenC)
                    {
                        item.Lastactive = (DateTime)DateTime.Now;
                        functionResult = item.Groupid;
                        session.Store(item);
                    }
                    session.SaveChanges();
                }
            }
            return functionResult;
        }