private static ScanFilePrefix ExtractFileName(string body)
        {
            string faxCode = string.Empty;
            string user    = string.Empty;
            string line;

            char[] space = new char[] { ' ' };

            using (StringReader reader = new StringReader(body))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains("User:"******"\\"))
                        {
                            user = user.Substring(user.IndexOf('\\') + 1);
                        }
                    }
                    else if (line.Contains("-- Destination", StringComparison.OrdinalIgnoreCase))
                    {
                        // The destination info is on the next line.
                        line    = reader.ReadLine();
                        faxCode = line.Split(space, StringSplitOptions.RemoveEmptyEntries)[0];
                    }
                }
            }

            return(ScanFilePrefix.ParseFromFax(faxCode, user));
        }
Esempio n. 2
0
        private static ScanFilePrefix ExtractFileName(string hpfFile)
        {
            string faxCode = string.Empty;
            string user    = string.Empty;

            foreach (string line in File.ReadLines(hpfFile))
            {
                if (!string.IsNullOrEmpty(line))
                {
                    string[] parts = line.Split(' ');
                    switch (parts[0])
                    {
                    case "##UserName":
                        user = parts[1];
                        break;

                    case "##dial":
                        faxCode = parts[1];
                        break;
                    }
                }
            }

            return(ScanFilePrefix.ParseFromFax(faxCode, user));
        }
        private string GetSessionId(IDataRecord record)
        {
            // See if we can use the name of the delivered file
            object result = record["DeliveredFileName"];

            if (result != null)
            {
                string fileName = result.ToString();
                if (ScanFilePrefix.MatchesPattern(fileName))
                {
                    ScanFilePrefix prefix = ScanFilePrefix.Parse(fileName);
                    return(prefix.SessionId);
                }
            }

            // See if we can use the fax number
            result = record["FaxNumber"];
            if (result != null)
            {
                try
                {
                    ScanFilePrefix prefix = ScanFilePrefix.ParseFromFax(result.ToString(), "u");
                    return(prefix.SessionId);
                }
                catch (FormatException)
                {
                    // Wrong format - do nothing
                }
            }

            // Use the last session we saw
            return(_sessionId);
        }