예제 #1
0
        static public async Task <ToCustomBotSnapshot> RequestSnapshotAsync(
            string ApiUri,
            FromCustomBotSnapshot FromBotSnapshot = null)
        {
            string RequestData = null;

            if (null != FromBotSnapshot)
            {
                RequestData = ToCustomBotSnapshot.SerializeToString(FromBotSnapshot);
            }

            string ResponseData = null;

            using (var client = new WebClient())
            {
                client.Encoding = Encoding.UTF8;
                client.Headers[HttpRequestHeader.ContentType] = "application/json";

                ResponseData = await client.UploadStringTaskAsync(ApiUri, "POST", RequestData ?? "");
            }

            if (null == ResponseData)
            {
                return(null);
            }

            return(ToCustomBotSnapshot.DeserializeFromString <ToCustomBotSnapshot>(ResponseData));
        }
예제 #2
0
 public InputSnapshot(
     Int64 Time,
     ToCustomBotSnapshot Snapshot,
     string SourceUri = null)
 {
     this.Time      = Time;
     this.Snapshot  = Snapshot;
     this.SourceUri = SourceUri;
 }
예제 #3
0
 public SnapshotRequestResult(
     Int64 Time,
     System.Exception Exception,
     ToCustomBotSnapshot ResponseSnapshot)
 {
     this.Time             = Time;
     this.Exception        = Exception;
     this.ResponseSnapshot = ResponseSnapshot;
 }
예제 #4
0
        static Optimat.EveOnline.CustomBot.InputSnapshot AlsInputSnapshot(
            Optimat.EveOnline.CustomBot.ToCustomBotSnapshot SensorSnapshot)
        {
            if (null == SensorSnapshot)
            {
                return(null);
            }

            return(new Optimat.EveOnline.CustomBot.InputSnapshot(SensorSnapshot.Time, SensorSnapshot));
        }
예제 #5
0
        static public async Task <SnapshotRequestResult> RequestSnapshotAsyncEncapsulated(
            string ApiUri,
            int DurationLimit,
            FromCustomBotSnapshot FromBotSnapshot = null)
        {
            var Time = Bib3.Glob.StopwatchZaitMiliSictInt();

            System.Exception    Exception        = null;
            ToCustomBotSnapshot ResponseSnapshot = null;

            try
            {
                if (null == ApiUri)
                {
                    throw new ArgumentNullException("ApiUrl");
                }

                var ResponseSnapshotTask =
                    RequestSnapshotAsync(ApiUri, FromBotSnapshot)
                    .TimeoutAfter(DurationLimit);

                ResponseSnapshot = await ResponseSnapshotTask;
            }
            catch (System.Exception tException)
            {
                Exception = tException;
            }
            finally
            {
            }

            return(new SnapshotRequestResult(
                       Time,
                       Exception,
                       ResponseSnapshot));
        }