示例#1
0
        public async Task <JToken> cdcallDriverAllocPUT(DriverAllocation dalloc)
        {
            cdCallAPI mycallAPI = new cdCallAPI();
            var       response  = await mycallAPI.cdCallPutAPI(App.cdDriverAllocURLPutPost, dalloc, App.cdDriverAllocationKey);

            return(response);
        }
        async void callGetDriver(Account logAccount)
        {
            try
            {
                cdQueryAttr qryAcct = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "StudentIDindex";
                qryAcct.ColName   = "StudentID";
                qryAcct.ColValue  = logAccount.UserName;

                getDriver        myDriverArray = new getDriver();
                DriverAllocation pubDriverInfo = new DriverAllocation();
                cdCallAPI        mycallAPI     = new cdCallAPI();

                var jsreponse = await mycallAPI.cdcallDriverAllocGET(qryAcct);

                myDriverArray = JsonConvert.DeserializeObject <getDriver>((string)jsreponse);

                pubDriverInfo = myDriverArray.DriverAllocation[0];

                DriverName.Text          = "Driver Name: " + pubDriverInfo.DriverName;
                CarType.Text             = "Car Type: " + pubDriverInfo.Attr3;
                LicensePlate.Text        = "License Plate: " + pubDriverInfo.Attr4;
                DestinationAddress.Text  = "Address: " + pubDriverInfo.Attr1;
                DestinationAddress2.Text = "               " + pubDriverInfo.Attr2;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Clubs Loop " + ex);
                await DisplayAlert("Action", "Update Status Failed", "OK");
            }
        }
        async void cdTrack(object sender, System.EventArgs e)
        {
            try
            {
                System.Diagnostics.Debug.WriteLine(" Clicked Track Button");
                cdQueryAttr qryAcct = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "StudentIDindex";
                qryAcct.ColName   = "StudentID";
                qryAcct.ColValue  = mystudAccounts.Account[counter].UserName;

                getDriver        myDriverArray = new getDriver();
                DriverAllocation pubDriverInfo = new DriverAllocation();
                cdCallAPI        mycallAPI     = new cdCallAPI();

                var jsreponse = await mycallAPI.cdcallDriverAllocGET(qryAcct);

                myDriverArray = JsonConvert.DeserializeObject <getDriver>((string)jsreponse);

                pubDriverInfo = myDriverArray.DriverAllocation[0];

                String trackkey = pubDriverInfo.DriverID + DateTime.Now.ToShortDateString();
                System.Diagnostics.Debug.WriteLine(" Tracking " + mystudAccounts.Account[counter].UserName + "with the key " + trackkey);

                var tpage = new cdTrackRiders(trackkey, loginAccount);
                await Navigation.PushModalAsync(tpage);
            }
            catch (Exception ex)
            {
                await DisplayAlert("No Tracking", "No Tracking information available for this student", "OK");

                System.Diagnostics.Debug.WriteLine("Exception is " + ex);
            }
        }
        async void getStudentData(Account logAccount)
        {
            //Getting Student Information
            try
            {
                cdQueryAttr qryAcct = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "DriverIDAllocationIDindex";
                qryAcct.ColName   = "DriverID";
                qryAcct.ColValue  = logAccount.UserName;
                counter           = 0;

                getDriver        myStudentArray = new getDriver();
                DriverAllocation pubStudentInfo = new DriverAllocation();
                cdCallAPI        mycallAPI      = new cdCallAPI();

                var jsreponse = await mycallAPI.cdcallDriverAllocGET(qryAcct);

                myStudentArray = JsonConvert.DeserializeObject <getDriver>((string)jsreponse);
                mystudArray    = myStudentArray;

                System.Diagnostics.Debug.WriteLine("Get response for students is " + jsreponse);
                try {
                    foreach (var dalloc in myStudentArray.DriverAllocation)
                    {
                        maxarray = maxarray + 1;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("End of Array " + ex);
                }

                System.Diagnostics.Debug.WriteLine("Assigning student name. Max array " + maxarray);

                StudentName.Text         = "Student Name: " + mystudArray.DriverAllocation[counter].StudentName;
                DestinationAddress.Text  = "Destination Address : " + mystudArray.DriverAllocation[counter].Attr1;
                DestinationAddress2.Text = "                       " + mystudArray.DriverAllocation[counter].Attr2;
                System.Diagnostics.Debug.WriteLine("Assigned dest address ");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
                await DisplayAlert("No Student Allocation Found", "No Student Allocation Found " + ex, "ok");
            }
            if (counter >= maxarray)
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = false;
            }
            else
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = true;
            }
        }
示例#5
0
        async Task <JToken> cdMapStdDrv(String myCurrentEventID)
        {
            List <EventSignup> drveventsignups  = new List <EventSignup>();
            List <EventSignup> stdeventsignups  = new List <EventSignup>();
            cdAllEventSignups  curreventsignups = new cdAllEventSignups();

            cdCallAPI            mycallAPI = new cdCallAPI();
            cdUpdateEventMembers updem     = new cdUpdateEventMembers();
            cdQueryAttr          qryAcct   = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "EventIDIndex";
            qryAcct.ColName   = "EventID";
            qryAcct.ColValue  = myCurrentEventID;
            int esmaxarray = -1;
            int drvarray   = -1;
            int stdarray   = -1;

            var response = await mycallAPI.cdcallEventMembersGET(qryAcct);

            curreventsignups = JsonConvert.DeserializeObject <cdAllEventSignups>((string)response);

            System.Diagnostics.Debug.WriteLine(" Event Signup payload is " + response);

            try
            {
                foreach (var divsignup in curreventsignups.EventSignup)
                {
                    esmaxarray = esmaxarray + 1;
                    try
                    {
                        if (divsignup.MemberRole.Contains("D") == true)
                        {
                            System.Diagnostics.Debug.WriteLine("Adding Driver " + divsignup.MemberAccountID);
                            drvarray = drvarray + 1;
                            drveventsignups.Add(divsignup);
                            System.Diagnostics.Debug.WriteLine("Added Driver " + divsignup.MemberAccountID);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("Adding Student " + divsignup.MemberAccountID);
                            stdarray = stdarray + 1;
                            stdeventsignups.Add(divsignup);
                            System.Diagnostics.Debug.WriteLine("Added Student " + divsignup.MemberAccountID);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Out of loop " + ex);
                    }
                }

                System.Diagnostics.Debug.WriteLine(" Event signups devided. Max array is " + esmaxarray);
                int stdcounter = 0;

                foreach (var allsignup in drveventsignups)
                {
                    int rcount = Convert.ToInt32(allsignup.RiderCount);
                    try
                    {
                        for (stdcounter = 0; stdcounter <= stdarray && rcount > 0; stdcounter++)
                        {
                            rcount = rcount - 1;
                            //Do student driver allocation
                            DriverAllocation myDriverAlloc = new DriverAllocation();
                            myDriverAlloc.AllocationID = allsignup.MemberAccountID + stdeventsignups[stdcounter].MemberAccountID + myCurrentEventID;
                            myDriverAlloc.EventID      = myCurrentEventID;
                            myDriverAlloc.ClubID       = allsignup.ClubID;
                            myDriverAlloc.DriverID     = allsignup.MemberAccountID;
                            myDriverAlloc.StudentID    = stdeventsignups[stdcounter].MemberAccountID;
                            myDriverAlloc.EventName    = allsignup.EventName;
                            myDriverAlloc.ClubName     = allsignup.ClubName;
                            myDriverAlloc.StudentName  = stdeventsignups[stdcounter].MemberName;
                            myDriverAlloc.DriverName   = allsignup.MemberName;
                            myDriverAlloc.Attr1        = allsignup.Attr1;
                            myDriverAlloc.Attr2        = allsignup.Attr2;
                            myDriverAlloc.Attr3        = allsignup.Attr3;
                            myDriverAlloc.Attr4        = allsignup.Attr4;
                            myDriverAlloc.Attr5        = "None";
                            myDriverAlloc.Attr6        = "None";
                            myDriverAlloc.Attr7        = "None";
                            myDriverAlloc.Attr8        = "None";
                            myDriverAlloc.Attr9        = "None";
                            myDriverAlloc.Attr10       = "None";

                            var daresponse = await mycallAPI.cdcallDriverAllocPUT(myDriverAlloc);

                            if (daresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Put API Call failed " + daresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Put API Call Successful ");
                            }

                            //Set Student to Allocated
                            updem.EventMemberID = stdeventsignups[stdcounter].EventMemberID;
                            updem.ColumnName    = "AllocationStatus";
                            updem.ColumnValue   = "ALLOCATED";
                            updem.ColumnName1   = "RiderCount";
                            updem.ColumnValue1  = "0";
                            updem.ColumnName2   = "Attr1";
                            updem.ColumnValue2  = "None";
                            updem.ColumnName3   = "Attr2";
                            updem.ColumnValue3  = "None";
                            updem.ColumnName4   = "Attr3";
                            updem.ColumnValue4  = "None";

                            daresponse = await mycallAPI.cdEventMembersPOST(updem);

                            if (daresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call failed " + daresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call Successful  ");
                            }
                        }

                        if (rcount <= 0)
                        {
                            //Set driver to allocated
                            updem.EventMemberID = allsignup.EventMemberID;
                            updem.ColumnName    = "AllocationStatus";
                            updem.ColumnValue   = "ALLOCATED";
                            updem.ColumnName1   = "RiderCount";
                            updem.ColumnValue1  = "0";
                            updem.ColumnName2   = "Attr1";
                            updem.ColumnValue2  = "None";
                            updem.ColumnName3   = "Attr2";
                            updem.ColumnValue3  = "None";
                            updem.ColumnName4   = "Attr3";
                            updem.ColumnValue4  = "None";

                            var dauresponse = await mycallAPI.cdEventMembersPOST(updem);

                            if (dauresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call failed " + dauresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call Successful ");
                            }
                        }
                        else
                        {
                            updem.EventMemberID = allsignup.EventMemberID;
                            updem.ColumnName    = "AllocationStatus";
                            updem.ColumnValue   = "UNALLOCATED";
                            updem.ColumnName1   = "RiderCount";
                            updem.ColumnValue1  = rcount.ToString();
                            updem.ColumnName2   = "Attr1";
                            updem.ColumnValue2  = "None";
                            updem.ColumnName3   = "Attr2";
                            updem.ColumnValue3  = "None";
                            updem.ColumnName4   = "Attr3";
                            updem.ColumnValue4  = "None";

                            var dauresponse = await mycallAPI.cdEventMembersPOST(updem);

                            if (dauresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call failed " + dauresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call Successful ");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Out of loop " + ex);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Loop " + ex);
            }

            return("success");
        }