internal static TouchEventArgs Read(CustomLogReader areader)
        {
            TouchEventArgs args = new TouchEventArgs();

            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                while (reader.Read(0))
                {
                    string value;
                    if (reader.GetEmptyElementValue("filename", out value))
                    {
                        args.FileName = value;
                    }
                    else if (reader.GetEmptyElementValue("modification", out value))
                    {
                        args.LastWriteTime = XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Local);
                    }
                    else if (SessionRemoteException.IsResult(reader))
                    {
                        args.Error = SessionRemoteException.ReadResult(reader);
                    }
                }
            }

            return(args);
        }
Ejemplo n.º 2
0
        internal static TransferEventArgs Read(CustomLogReader areader)
        {
            TransferEventArgs args = new TransferEventArgs();

            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                while (reader.Read(0))
                {
                    string value;
                    if (reader.GetEmptyElementValue("filename", out value))
                    {
                        args.FileName = value;
                    }
                    else if (reader.GetEmptyElementValue("destination", out value))
                    {
                        args.Destination = value;
                    }
                    else if (SessionRemoteException.IsResult(reader))
                    {
                        args.Error = SessionRemoteException.ReadResult(reader);
                    }
                }
            }

            return args;
        }
        private static SessionRemoteException ReadMessages(CustomLogReader areader)
        {
            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                string        message   = null;
                List <string> messages  = new List <string>();
                bool          inMessage = false;

                while (reader.Read(0))
                {
                    if (reader.IsNonEmptyElement("message"))
                    {
                        inMessage = true;
                        message   = null;
                    }
                    else if (inMessage &&
                             (reader.NodeType == XmlNodeType.Text))
                    {
                        message += reader.Value;
                    }
                    else if (inMessage &&
                             reader.IsEndElement("message"))
                    {
                        messages.Add(message);
                        message   = null;
                        inMessage = false;
                    }
                }

                string error = string.Join(Environment.NewLine, messages.ToArray());
                return(new SessionRemoteException(reader.Session, error));
            }
        }
Ejemplo n.º 4
0
        internal static TransferEventArgs Read(ProgressSide side, CustomLogReader areader)
        {
            TransferEventArgs args = new TransferEventArgs()
            {
                Side = side
            };

            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                while (reader.Read(0))
                {
                    if (reader.GetEmptyElementValue("filename", out string value))
                    {
                        args.FileName = value;
                    }
                    else if (reader.GetEmptyElementValue("destination", out value))
                    {
                        args.Destination = value;
                    }
                    else if (reader.GetEmptyElementValue("size", out value))
                    {
                        args.Length = long.Parse(value, CultureInfo.InvariantCulture);
                    }
                    else if (SessionRemoteException.IsResult(reader))
                    {
                        args.Error = SessionRemoteException.ReadResult(reader);
                    }
                }
            }

            return(args);
        }
Ejemplo n.º 5
0
        internal static ChmodEventArgs Read(CustomLogReader areader)
        {
            ChmodEventArgs args = new ChmodEventArgs();

            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                while (reader.Read(0))
                {
                    string value;
                    if (reader.GetEmptyElementValue("filename", out value))
                    {
                        args.FileName = value;
                    }
                    else if (reader.GetEmptyElementValue("permissions", out value))
                    {
                        args.FilePermissions = FilePermissions.CreateReadOnlyFromText(value);
                    }
                    else if (SessionRemoteException.IsResult(reader))
                    {
                        args.Error = SessionRemoteException.ReadResult(reader);
                    }
                }
            }

            return args;
        }
Ejemplo n.º 6
0
        internal static TransferEventArgs Read(CustomLogReader areader)
        {
            TransferEventArgs args = new TransferEventArgs();

            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                while (reader.Read(0))
                {
                    string value;
                    if (reader.GetEmptyElementValue("filename", out value))
                    {
                        args.FileName = value;
                    }
                    else if (reader.GetEmptyElementValue("destination", out value))
                    {
                        args.Destination = value;
                    }
                    else if (SessionRemoteException.IsResult(reader))
                    {
                        args.Error = SessionRemoteException.ReadResult(reader);
                    }
                }
            }

            return(args);
        }
Ejemplo n.º 7
0
        internal static TouchEventArgs Read(CustomLogReader areader)
        {
            TouchEventArgs args = new TouchEventArgs();

            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                while (reader.Read(0))
                {
                    string value;
                    if (reader.GetEmptyElementValue("filename", out value))
                    {
                        args.FileName = value;
                    }
                    else if (reader.GetEmptyElementValue("modification", out value))
                    {
                        args.LastWriteTime = XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Local);
                    }
                    else if (SessionRemoteException.IsResult(reader))
                    {
                        args.Error = SessionRemoteException.ReadResult(reader);
                    }
                }
            }

            return args;
        }
Ejemplo n.º 8
0
        internal static ChmodEventArgs Read(CustomLogReader areader)
        {
            ChmodEventArgs args = new ChmodEventArgs();

            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                while (reader.Read(0))
                {
                    if (reader.GetEmptyElementValue("filename", out string value))
                    {
                        args.FileName = value;
                    }
                    else if (reader.GetEmptyElementValue("permissions", out value))
                    {
                        args.FilePermissions = FilePermissions.CreateReadOnlyFromText(value);
                    }
                    else if (SessionRemoteException.IsResult(reader))
                    {
                        args.Error = SessionRemoteException.ReadResult(reader);
                    }
                }
            }

            return(args);
        }
Ejemplo n.º 9
0
        internal static SessionRemoteException ReadResult(CustomLogReader areader)
        {
            SessionRemoteException e = null;

            if (areader.GetAttribute("success") == "false")
            {
                e = ReadMessages(areader);
            }

            return(e);
        }
Ejemplo n.º 10
0
        internal static SessionRemoteException ReadResult(CustomLogReader areader)
        {
            SessionRemoteException e = null;

            if (areader.GetAttribute("success") == "false")
            {
                e = ReadMessages(areader);
            }

            return e;
        }
Ejemplo n.º 11
0
        public ElementLogReader(CustomLogReader parentReader)
            : base(parentReader.Session)
        {
            _parentReader = parentReader;

            if ((NodeType != XmlNodeType.Element) ||
                IsEmptyElement)
            {
                throw new InvalidOperationException();
            }

            _localName = _parentReader.Reader.LocalName;
            _depth = _parentReader.Reader.Depth;
            _read = false;
        }
Ejemplo n.º 12
0
        public ElementLogReader(CustomLogReader parentReader) :
            base(parentReader.Session)
        {
            _parentReader = parentReader;

            if ((NodeType != XmlNodeType.Element) ||
                IsEmptyElement)
            {
                throw new InvalidOperationException();
            }

            _localName = _parentReader.Reader.LocalName;
            _depth     = _parentReader.Reader.Depth;
            _read      = false;
        }
Ejemplo n.º 13
0
        public ElementLogReader(CustomLogReader parentReader) :
            base(parentReader.Session)
        {
            _parentReader = parentReader;

            if ((NodeType != XmlNodeType.Element) ||
                IsEmptyElement)
            {
                throw Session.Logger.WriteException(new InvalidOperationException("Cannot use ElementLogReader with non-element node or empty element"));
            }

            _localName = _parentReader.Reader.LocalName;
            _depth     = _parentReader.Reader.Depth;
            _token     = _localName + "@" + _depth;
            _read      = false;
        }
Ejemplo n.º 14
0
        private static SessionRemoteException ReadMessages(CustomLogReader areader)
        {
            using (ElementLogReader reader = new ElementLogReader(areader))
            {
                string error = null;
                string message = null;
                List<string> messages = new List<string>();
                bool inMessage = false;

                while (reader.Read(0))
                {
                    if (reader.IsNonEmptyElement("message"))
                    {
                        inMessage = true;
                        message = null;
                    }
                    else if (inMessage &&
                        (reader.NodeType == XmlNodeType.Text))
                    {
                        message += reader.Value;
                    }
                    else if (inMessage &&
                        reader.IsEndElement("message"))
                    {
                        if (error == null)
                        {
                            error = message;
                        }
                        else
                        {
                            messages.Add(message);
                        }
                        message = null;
                        inMessage = false;
                    }
                }

                Exception inner = null;
                if (messages.Count > 0)
                {
                    inner = new SessionRemoteException(reader.Session, string.Join(Environment.NewLine, messages.ToArray()));
                }

                return new SessionRemoteException(reader.Session, error, inner);
            }
        }
Ejemplo n.º 15
0
 internal static SessionRemoteException ReadFailure(CustomLogReader reader)
 {
     return(ReadMessages(reader));
 }
Ejemplo n.º 16
0
 internal static bool IsResult(CustomLogReader reader)
 {
     return(reader.IsNonEmptyElement("result"));
 }
Ejemplo n.º 17
0
 public SessionElementLogReader(CustomLogReader parentReader) :
     base(parentReader)
 {
 }
Ejemplo n.º 18
0
 private void ReadFile(RemoteFileInfo fileInfo, CustomLogReader fileReader)
 {
     using (Logger.CreateCallstack())
     {
         string value;
         if (fileReader.GetEmptyElementValue("type", out value))
         {
             fileInfo.FileType = value[0];
         }
         else if (fileReader.GetEmptyElementValue("size", out value))
         {
             fileInfo.Length = long.Parse(value, CultureInfo.InvariantCulture);
         }
         else if (fileReader.GetEmptyElementValue("modification", out value))
         {
             fileInfo.LastWriteTime = XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Local);
         }
         else if (fileReader.GetEmptyElementValue("permissions", out value))
         {
             fileInfo.FilePermissions = FilePermissions.CreateReadOnlyFromText(value);
         }
     }
 }
Ejemplo n.º 19
0
 internal static SessionRemoteException ReadFailure(CustomLogReader reader)
 {
     return ReadMessages(reader);
 }
Ejemplo n.º 20
0
 internal static bool IsResult(CustomLogReader reader)
 {
     return reader.IsNonEmptyElement("result");
 }
Ejemplo n.º 21
0
 private static void ReadElement(CustomLogReader reader, LogReadFlags flags)
 {
     while (reader.Read(flags))
     {
     }
 }
Ejemplo n.º 22
0
 public SessionElementLogReader(CustomLogReader parentReader)
     : base(parentReader)
 {
 }