Beispiel #1
0
 public bool Execute(string key)
 {
     if (ActionsDict.ContainsKey(key))
     {
         var step = ActionsDict[key].Execute(FileInfo);
         return(SetFile(_current + step));
     }
     return(false);
 }
Beispiel #2
0
        public static ActionHolder UpdateActionsHolder(string roomKey, string userGuid, SceneAction action)
        {
            foreach (var item in ActionsDict.Where(kvp => kvp.Value.TimeStamp < DateTime.Now.AddMinutes(-5)).ToList())
            {
                ActionsDict.Remove(item.Key);
            }
            ActionHolder aHolder = null;

            if (!ActionsDict.TryGetValue(roomKey, out aHolder))
            {
                aHolder = new ActionHolder();
                aHolder.ActionsOwnerId = userGuid;
            }

            if (action != null)
            {
                if (action.GoName == "slam_start_recording")
                {
                    if (aHolder.Actions.Find(x => x.GoName == "slam_end_recording") != null)
                    {
                        aHolder.Actions.Clear();
                        aHolder.ActionsOwnerId = userGuid;
                    }
                }
                if (aHolder.ActionsOwnerId != userGuid)
                {
                    return(null);
                }
                //if (action.GoName == "slam_end_recording")
                //{
                //    ActionsDict.Remove(roomKey);
                //    return null;
                //}

                var ac = aHolder.Actions.Find(x => x.GoName == action.GoName && x.SceneTime == action.SceneTime);
                if (ac == null)
                {
                    aHolder.Actions.Add(action);
                }
                aHolder.TimeStamp    = DateTime.Now; //update time
                ActionsDict[roomKey] = aHolder;
            }
            return(aHolder);
        }