public AsyncRequestResult BeginPostGroupCollection(API_AgeGroupCollection ageGroups, RequestCompleted <API_AgeGroupCollection> callback, Object asyncState)
 {
     return(BeginPostSerializableT("Calendar", "PostGroupCollection", String.Empty, ageGroups, callback, asyncState, true));
 }
Пример #2
0
        private void Client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            BZID           = string.Empty;
            LastError      = string.Empty;
            OK             = false;
            NameRegistered = false;

            if (e.Error != null)
            {
                LastError = e.Error.ToString();
                if (RequestErrored != null)
                {
                    RequestErrored.Invoke(this, EventArgs.Empty);
                }

                return;
            }

            try
            {
                foreach (string line in e.Result.Split("\r\n".ToCharArray()))
                {
                    if (line == string.Empty || LastError != string.Empty)
                    {
                        continue;
                    }

                    string[] cmdParts = line.Split(":".ToCharArray(), 2);
                    string   command  = cmdParts[0];
                    if (command.ToUpperInvariant() == "MSG:")
                    {
                        continue;
                    }

                    if (command == "TOKGOOD")
                    {
                        LastError      = string.Empty;
                        OK             = true;
                        NameRegistered = true;

                        string[] parts = cmdParts[1].Trim().Split(":".ToCharArray());

                        string[] desiredGroups = Groups.ToArray();

                        Groups.Clear();
                        foreach (string g in parts) // scan the groups to match the names up to the requested format, if not just blast it in.
                        {
                            string n = g;
                            foreach (var dg in desiredGroups)
                            {
                                if (dg.ToUpperInvariant() == g.ToUpperInvariant())
                                {
                                    n = dg;
                                }
                            }

                            Groups.Add(n);
                        }
                    }
                    else if (command == "TOKBAD")
                    {
                        NameRegistered = true;
                        LastError      = "Bad Token";
                        OK             = false;
                    }
                    else if (command == "UNK")
                    {
                        OK             = false;
                        NameRegistered = true;
                    }
                    else if (command == "BZID")
                    {
                        if (cmdParts.Length == 1)
                        {
                            LastError = "Malformed BZID";
                        }
                        else
                        {
                            string[] parts = cmdParts[1].Trim().Split(" ".ToCharArray());
                            if (parts.Length == 0)
                            {
                                LastError = "Malformed BZID";
                            }
                            else
                            {
                                BZID = parts[0];
                            }
                        }
                    }
                    else if (command == "ERROR")
                    {
                        LastError = "ERROR " + cmdParts[1].Trim();
                    }
                    else if (command == "NOTICE")
                    {
                        LastError = "NOTICE " + cmdParts[1].Trim();
                    }
                    else
                    {
                    }
                }
            }
            catch (System.Exception ex)
            {
                //LastToken = string.Empty;
                LastError = ex.ToString();
            }

            if (OK && BZID == string.Empty)
            {
                OK        = false;
                LastError = "Missing BZID";
            }

            if (LastError != string.Empty)
            {
                OK = false;

                if (RequestErrored != null)
                {
                    RequestErrored.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                OK = true;
                if (RequestCompleted != null)
                {
                    RequestCompleted.Invoke(this, EventArgs.Empty);
                }
            }
        }
 public AsyncRequestResult BeginPostGroup(Comp_AgeGroupApiModel ageGroup, RequestCompleted <Comp_AgeGroupApiModel> callback, Object asyncState)
 {
     return(BeginPostSerializableT("Calendar", "PostGroup", String.Empty, ageGroup, callback, asyncState, true));
 }
Пример #4
0
 public AsyncRequestResult BeginPostClimberCollection(API_ClimbersCollection climbers, RequestCompleted <API_ClimbersCollection> callback, Object asyncState)
 {
     return(BeginPostSerializableT("Calendar", "PostClimberCollection", String.Empty, climbers, callback, asyncState, true));
 }
Пример #5
0
 internal void OnRequestCompleted(RequestContext context)
 {
     RequestCompleted?.Invoke(this, new GraphQLServerEventArgs(context));
 }
Пример #6
0
 public AsyncRequestResult BeginGetRegions(RequestCompleted <API_RegionCollection> callback, Object asyncState)
 {
     return(BeginGetSerializableT("Calendar", "Teams", String.Format(CultureInfo.InvariantCulture, "/{0}", this.CompId),
                                  callback, asyncState));
 }
Пример #7
0
 public AsyncRequestResult BeginPostRegionCollection(API_RegionCollection regions, RequestCompleted <API_RegionCollection> callback, Object asyncState)
 {
     return(BeginPostSerializableT("Calendar", "PostTeamCollection", String.Empty, regions, callback, asyncState, true));
 }
Пример #8
0
 public AsyncGetObject(HttpWebRequest request, RequestCompleted <T> callback, Object asyncState)
 {
     this.Request    = request;
     this.Callback   = callback;
     this.AsyncState = asyncState;
 }
Пример #9
0
 protected void RaiseRequestCompleted(HttpRequestMessage request,
                                      HttpResponseMessage response,
                                      Exception thrownException = null)
 {
     RequestCompleted?.Invoke(this, new ClientRequestLogEventArgs(request, response, thrownException));
 }
Пример #10
0
        private void Client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            LastError = string.Empty;
            LastToken = string.Empty;

            if (e.Error != null)
            {
                LastError = e.Error.ToString();
                if (RequestErrored != null)
                {
                    RequestErrored.Invoke(this, EventArgs.Empty);
                }

                return;
            }

            try
            {
                foreach (string line in e.Result.Split("\r\n".ToCharArray()))
                {
                    if (line == string.Empty)
                    {
                        continue;
                    }

                    string[] cmdParts = line.Split(":".ToCharArray(), 2);
                    string   command  = cmdParts[0];
                    if (command == "TOKEN")
                    {
                        LastToken = cmdParts[1].Trim();
                    }
                    else if (command == "NOTOK")
                    {
                        LastError = "No Token " + cmdParts[1].Trim();
                    }
                    else if (command == "ERROR")
                    {
                        LastError = "ERROR " + cmdParts[1].Trim();
                    }
                    else if (command == "NOTICE")
                    {
                        LastError = "NOTICE " + cmdParts[1].Trim();
                    }
                    else
                    {
                    }
                }
            }
            catch (System.Exception ex)
            {
                //LastToken = string.Empty;
                LastError = ex.ToString();
            }


            if (LastError != string.Empty)
            {
                if (RequestErrored != null)
                {
                    RequestErrored.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (RequestCompleted != null)
                {
                    RequestCompleted.Invoke(this, EventArgs.Empty);
                }
            }
        }
 public AsyncRequestResult BeginGetCompetitions(int year, RequestCompleted <API_CompetitionCollection> callback, Object asyncState)
 {
     return(BeginGetSerializableT("Calendar", "Competitions",
                                  String.Format(CultureInfo.InvariantCulture, "/{0}", year), callback, asyncState));
 }
Пример #12
0
 public AsyncRequestResult BeginLoadResultsPackage(ApiListLineCollection regions, RequestCompleted <object> callback, Object asyncState)
 {
     return(BeginPostSerializableTTOut("Results", "LoadResultsPackage", String.Empty, regions, callback, asyncState, false));
 }
Пример #13
0
 public AsyncRequestResult BeginPostListLine(ApiListLine region, RequestCompleted <object> callback, Object asyncState)
 {
     return(BeginPostSerializableTTOut("Results", "PostListLine", String.Empty, region, callback, asyncState, false));
 }
 public AsyncRequestResult BeginPostListHeaderCollection(ApiListHeaderCollection regions, RequestCompleted <object> callback, Object asyncState)
 {
     return(BeginPostSerializableTTOut("Results", "ReloadAllLists", String.Empty, regions, callback, asyncState, false));
 }
Пример #15
0
        private void Client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            LastError = string.Empty;
            LastToken = string.Empty;

            if (e.Error != null)
            {
                LastError = e.Error.ToString();
                if (RequestErrored != null)
                {
                    RequestErrored.Invoke(this, EventArgs.Empty);
                }

                return;
            }

            ServerList.Clear();

            try
            {
                foreach (string line in e.Result.Split("\r\n".ToCharArray()))
                {
                    if (line == string.Empty)
                    {
                        continue;
                    }

                    string[] cmdParts = line.Split(":".ToCharArray(), 2);
                    string   command  = cmdParts[0];
                    if (command == "TOKEN")
                    {
                        LastToken = cmdParts[1].Trim();
                    }
                    else if (command == "NOTOK")
                    {
                        LastError = "No Token " + cmdParts[1].Trim();
                    }
                    else if (command == "ERROR")
                    {
                        LastError = "ERROR " + cmdParts[1].Trim();
                    }
                    else if (command == "NOTICE")
                    {
                        LastError = "NOTICE " + cmdParts[1].Trim();
                    }
                    else
                    {
                        ListServerData data = new ListServerData();

                        string[] dataParts = line.Split(" ".ToCharArray(), 5);
                        data.Name    = dataParts[0];
                        data.Version = dataParts[1];
                        data.Info.ReadFromString(dataParts[2]);
                        IPAddress.TryParse(dataParts[3], out data.Address);

                        data.Host = dataParts[3];
                        data.Port = 5154;
                        if (dataParts[0].Contains(":"))
                        {
                            string[] portParts = dataParts[0].Split(":".ToCharArray(), 2);

                            data.Host = portParts[0];
                            int.TryParse(portParts[1], out data.Port);
                        }

                        if (dataParts.Length > 4)
                        {
                            data.Description = dataParts[4];
                        }

                        ServerList.Add(data);
                    }
                }
            }
            catch (System.Exception ex)
            {
                //LastToken = string.Empty;
                LastError = ex.ToString();
            }


            if (LastError != string.Empty)
            {
                if (RequestErrored != null)
                {
                    RequestErrored.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (RequestCompleted != null)
                {
                    RequestCompleted.Invoke(this, EventArgs.Empty);
                }
            }
        }
 private AsyncRequestResult BeginPostSerializableT <T>(String controller, String action, String parameters, T value, RequestCompleted <T> callback, object asyncState, bool needResponseData)
     where T : APIBaseRequest
 {
     return(BeginPostSerializableTTOut <T, T>(controller, action, parameters, value, callback, asyncState, needResponseData));
 }
Пример #17
0
 private void OnRequestCompleted()
 {
     RequestCompleted?.Invoke(this, EventArgs.Empty);
 }
        private AsyncRequestResult BeginPostSerializableTTOut <T, TOut>(String controller, String action, String parameters, T value, RequestCompleted <TOut> callback, object asyncState, bool needResponseData)
            where T : APIBaseRequest
        {
            byte[] bytedata;
            var    request = PreparePostRequest(controller, action, parameters, value, out bytedata);



            var           data = new AsyncGetObject <TOut>(request, callback, asyncState);
            AsyncCallback asyncCallBack;

            if (needResponseData)
            {
                asyncCallBack = EndGetPostSerializableT <TOut>;
            }
            else
            {
                asyncCallBack = EndGetPostSerializableNoData;
            }
            RequestData <TOut> rqd = new RequestData <TOut>
            {
                Data      = bytedata,
                AsyncData = data,
                Callback  = asyncCallBack
            };

            request.BeginGetRequestStream(EndGetRequestStream <TOut>, rqd);
            return(new AsyncRequestResult(request));
        }
Пример #19
0
 public AsyncRequestResult BeginPostRegion(RegionApiModel region, RequestCompleted <RegionApiModel> callback, Object asyncState)
 {
     return(BeginPostSerializableT("Calendar", "PostTeam", String.Empty, region, callback, asyncState, true));
 }
        private AsyncRequestResult BeginGetSerializableT <T>(String controller, String action, String parameters, RequestCompleted <T> callback, object asyncState)
        {
            var request             = GetApiRequest(controller, action, parameters);
            AsyncGetObject <T> data = new AsyncGetObject <T>(request, callback, asyncState);

            request.BeginGetResponse(EndGetPostSerializableT <T>, data);
            return(new AsyncRequestResult(request));
        }
 protected override void OnCompleted()
 {
     tasksConsumerService.Enqueue(() => RequestCompleted?.Invoke(config.UniqueName, TopicId, Result));
 }
Пример #22
0
 public AsyncRequestResult BeginPostClimber(Comp_CompetitorRegistrationApiModel climber, RequestCompleted <Comp_CompetitorRegistrationApiModel> callback, Object asyncState)
 {
     return(BeginPostSerializableT("Calendar", "PostClimber", String.Empty, climber, callback, asyncState, true));
 }