Exemplo n.º 1
0
        public void FileAsUncPath(string file, ReturnFormat format)
        {
            SimpleUriHandler handler = new SimpleUriHandler();
            string           uri     = $@"\\{Environment.MachineName}\" + Path.Combine(Environment.CurrentDirectory, file).ToLower().Replace("c:", "c$");

            SimpleUriHandlerParameters parms = new SimpleUriHandlerParameters()
            {
                Uri = uri, Format = format
            };
            string result = handler.GetFileUri(parms.ParsedUri.ToString());

            object o = handler.FormatData(result, parms.Format);
        }
Exemplo n.º 2
0
        public void FileAsUriPath(string file, ReturnFormat format)
        {
            SimpleUriHandler handler = new SimpleUriHandler();
            string           uri     = $"file://" + Path.Combine(Environment.CurrentDirectory, file);

            SimpleUriHandlerParameters parms = new SimpleUriHandlerParameters()
            {
                Uri = uri, Format = format
            };
            string result = handler.GetFileUri(parms.ParsedUri.ToString());

            object o = handler.FormatData(result, parms.Format);
        }
Exemplo n.º 3
0
    override public ExecuteResult Execute(HandlerStartInfo startInfo)
    {
        ExecuteResult result = new ExecuteResult()
        {
            Status = StatusType.Complete
        };
        string    msg       = string.Empty;
        Exception exception = null;
        object    exitData  = null;

        SimpleUriHandlerParameters parms = DeserializeOrNew <SimpleUriHandlerParameters>(startInfo.Parameters);

        OnProgress("Execute", $"Beginning fetch for {parms.Uri}.", StatusType.Running, startInfo.InstanceId, 1);

        try
        {
            switch (parms.ParsedUri.Scheme)
            {
            case "http":
            case "https":
            {
                exitData = GetHttpUri(parms.Uri).Result;
                break;
            }

            case "file":
            {
                exitData = GetFileUri(parms.Uri);
                break;
            }

            case "s3":
            case "blob":
            default:
            {
                throw new NotSupportedException($"URI scheme {parms.ParsedUri.Scheme} is not supported.");
            }
            }

            exitData = FormatData(exitData, parms.Format);

            if (parms.HasMerge)
            {
                MergeData(ref exitData, parms.Merge, parms.Format);
            }

            result.ExitData = exitData;

            msg = $"Successfully executed HttpClient.Get( {parms.Uri} ).";
        }
        catch (Exception ex)
        {
            result.Status   = StatusType.Failed;
            result.ExitData = msg = ex.Message;
            exception       = ex;
        }

        OnProgress("Execute", msg, result.Status, startInfo.InstanceId, Int32.MaxValue, false, exception);

        return(result);
    }