Ejemplo n.º 1
0
        private void OpenStream(String destination)
        {
            if (String.IsNullOrEmpty(destination))
            {
                _TypeOfOutputDestination = TypeOfOutputDestination.QueryResult;
            }
            else if (destination.ToLower().StartsWith(@"file:\\"))
            {
                #region file:

                _TypeOfOutputDestination = TypeOfOutputDestination.File;
                try
                {
                    if (!destination.EndsWith(".gql"))
                    {
                        destination = new StringBuilder(destination).Append(".gql").ToString();
                    }

                    _Stream = new StreamWriter(File.Create(destination.Substring(@"file:\\".Length).TrimStart('\\')));
                }
                catch (Exception ex)
                {
                    throw new StreamWriterException("System.IO.StreamWriter", "Error create File.", ex);
                }

                #endregion
            }
            else if (destination.ToLower().StartsWith("http://"))
            {
                #region http

                _TypeOfOutputDestination = TypeOfOutputDestination.Http;
                try
                {
                    _HttpWebRequest         = (HttpWebRequest)WebRequest.Create(destination);
                    _HttpWebRequest.Method  = "PUT";
                    _HttpWebRequest.Timeout = 1000;
                    _Stream = new StreamWriter(_HttpWebRequest.GetRequestStream());
                }
                catch (Exception ex)
                {
                    throw new StreamWriterException("System.IO.StreamWriter", "Error on HttpWebRequest.", ex);
                }

                #endregion
            }
            else
            {
                throw new InvalidDumpLocationException(destination, @"file:\\", "http://", "");
            }
        }
Ejemplo n.º 2
0
        private Exceptional OpenStream(String destination)
        {
            if (String.IsNullOrEmpty(destination))
            {
                _TypeOfOutputDestination = TypeOfOutputDestination.QueryResult;
            }
            else if (destination.ToLower().StartsWith(@"file:\\"))
            {
                #region file:

                _TypeOfOutputDestination = TypeOfOutputDestination.File;
                try
                {
                    _Stream = new StreamWriter(File.Create(destination.Substring(@"file:\\".Length).TrimStart('\\')));
                }
                catch (Exception ex)
                {
                    return new Exceptional(new Error_UnknownDBError(ex));
                }

                #endregion
            }
            else if (destination.ToLower().StartsWith("http://"))
            {
                #region http

                _TypeOfOutputDestination = TypeOfOutputDestination.Http;
                try
                {
                    request = (HttpWebRequest)WebRequest.Create(destination);
                    request.Method = "PUT";
                    request.Timeout = 1000;
                    _Stream = new StreamWriter(request.GetRequestStream());
                }
                catch (Exception ex)
                {
                    return new Exceptional(new Error_UnknownDBError(ex));
                }

                #endregion
            }
            else
            {
                return new Exceptional(new Error_InvalidDumpLocation(destination, @"file:\\", "http://"));
            }

            return Exceptional.OK;
        }
Ejemplo n.º 3
0
        private void OpenStream(String destination)
        {
            if (String.IsNullOrEmpty(destination))
            {
                _TypeOfOutputDestination = TypeOfOutputDestination.QueryResult;
            }
            else if (destination.ToLower().StartsWith(@"file:\\"))
            {
                #region file:

                _TypeOfOutputDestination = TypeOfOutputDestination.File;
                try
                {
                    if (!destination.EndsWith(".gql"))
                        destination = new StringBuilder(destination).Append(".gql").ToString();

                    _Stream = new StreamWriter(File.Create(destination.Substring(@"file:\\".Length).TrimStart('\\')));
                }
                catch (Exception ex)
                {
                    throw new StreamWriterException("System.IO.StreamWriter", "Error create File.", ex);
                }

                #endregion
            }
            else if (destination.ToLower().StartsWith("http://"))
            {
                #region http

                _TypeOfOutputDestination = TypeOfOutputDestination.Http;
                try
                {
                    _HttpWebRequest = (HttpWebRequest)WebRequest.Create(destination);
                    _HttpWebRequest.Method = "PUT";
                    _HttpWebRequest.Timeout = 1000;
                    _Stream = new StreamWriter(_HttpWebRequest.GetRequestStream());
                }
                catch (Exception ex)
                {
                    throw new StreamWriterException("System.IO.StreamWriter", "Error on HttpWebRequest.", ex);
                }

                #endregion
            }
            else
            {
                throw new InvalidDumpLocationException(destination, @"file:\\", "http://", "");
            }
        }