Exemplo n.º 1
0
        /// <summary>
        /// Get session for working with files
        /// </summary>
        protected void Session()
        {
            IDirectoryOperation session = storage;

            while (true)
            {
                // Get request
                if (!Provider.GetRequest(out RequestData userData))
                {
                    continue;
                }

                if (!CheckSessionID(userData.SessionId))
                {
                    return;
                }

                // Main operations
                switch ((MainOperation)userData.Operation)
                {
                case MainOperation.GetAll:
                    Provider.SendResponse(session.GetAll());
                    break;

                case MainOperation.OpenFile:
                    SendResponse(session.OpenFile(userData.Property));
                    // Opening file, if incorrect sessionID inside, then close session here
                    if (!FileChange())
                    {
                        return;
                    }
                    break;

                case MainOperation.OpenFolder:
                    SendResponse(session.OpenFolder(userData.Property));
                    break;

                case MainOperation.CloseFolder:
                    SendResponse(session.CloseFolder());
                    break;

                case MainOperation.EndSession:
                    Provider.SendResponse(new ResponseData(SessionID, StatusCode.BadData, EndMessage));
                    Logger.Log(EndLog);
                    return;

                default:
                    Provider.SendResponse(new ResponseData(SessionID, StatusCode.BadRequest, $"Invalid operation"));
                    Logger.LogAll("Invalid operation");
                    break;
                }
            }
        }
 internal ActiveDirectoryRole(DirectoryEntry rootEntry, IDirectoryOperation operation)
 {
     if (rootEntry == null)
     {
         throw new ArgumentNullException("rootEntry");
     }
     this.m_root = rootEntry;
     this.m_operations = new List<IDirectoryOperation>();
     if (operation != null)
     {
         this.m_operations.Add(operation);
     }
 }
Exemplo n.º 3
0
 internal ActiveDirectoryRole(DirectoryEntry rootEntry, IDirectoryOperation operation)
 {
     if (rootEntry == null)
     {
         throw new ArgumentNullException("rootEntry");
     }
     this.m_root       = rootEntry;
     this.m_operations = new List <IDirectoryOperation>();
     if (operation != null)
     {
         this.m_operations.Add(operation);
     }
 }