Beispiel #1
0
        /// <summary>
        /// Saves the metadata.
        /// </summary>
        /// <param name="MetaDataBind"></param>
        async void MetaDataBindForParent(DownloadParentMetadataResponse MetaDataResponse)
        {
            try
            {
                //saves the faculty data
                bool status = await App.Database.SaveFacultyAsync(null, null, MetaDataResponse.ParentDetails.ParentChildrenClass,
                                                                  MetaDataResponse.ParentDetails.ParentChildrenSections, MetaDataResponse.ParentDetails.ParentChildrenStream,
                                                                  null, MetaDataResponse.ParentDetails.ParentChildren, MetaDataResponse.ParentDetails.ParentChildrenSubject
                                                                  , MetaDataResponse.ParentDetails.ParentChildrenFaculty, null, MetaDataResponse.ParentDetails.Parent);

                if (status == false)
                {
                    StrMSG = App.Database.MSGFailure;
                    Console.WriteLine(App.Database.MSGFailure);
                    UserDialogs.Instance.Toast(StrMSG);
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        //Bind Data In Server
        /// <summary>
        /// Gets the metadata service.
        /// we are se S for student and M for Metadata
        /// </summary>
        /// <returns><c>true</c>, if metadata service was gotten, <c>false</c> otherwise.</returns>
        /// <param name="MetaDataType">Meta data type.</param>
        public bool GetMetadataService(char MetaDataType)
        {
            bool check_ServiceStatus = false;
            var  Client = new HttpClient();

            try
            {
                if (MetaDataType == 'M')
                {
                    if (UserType.currentUserType == UserType.enumUserType.Faculty)
                    {
                        ServiceAPIInfo.MetaDataMethod = "DownloadFacultyMetadata";
                    }
                    else if (UserType.currentUserType == UserType.enumUserType.Student)
                    {
                        ServiceAPIInfo.MetaDataMethod = "DownloadStudentMetadata";
                    }
                    else if (UserType.currentUserType == UserType.enumUserType.Parent)
                    {
                        ServiceAPIInfo.MetaDataMethod = "DownloadParentMetadata";
                    }
                    else if (UserType.currentUserType == UserType.enumUserType.Management)
                    {
                        ServiceAPIInfo.MetaDataMethod = "DownloadManagementMetadata";
                    }
                }
                else if (MetaDataType == 'S')
                {
                    ServiceAPIInfo.MetaDataMethod = "GetStudentAllAttendence";
                }
                DownloadUserMetadataRequest cngRequest = new DownloadUserMetadataRequest();
                StudentAttendanceRequest    lgR        = new StudentAttendanceRequest();
                GeneralProperties.ServicesMethodName = ServiceAPIInfo.MetaDataMethod;

                string url = ServiceAPIInfo.serviceAPI + GeneralProperties.ServicesMethodName;
                //Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                Client.BaseAddress = new Uri(url);
                //Client.Timeout = TimeSpan.FromMilliseconds(ServiceAPIInfo.service_TimeOut);

                string json     = "";
                var    id       = CrossSettings.Current.GetValueOrDefault("FacultyId", 0);
                var    userType = CrossSettings.Current.GetValueOrDefault("UserType", 0);

                if (MetaDataType == 'M')
                {
                    cngRequest.UserID = id;
                    //cngRequest.UserID = 1;
                    cngRequest.UserType = userType;
                    /* Encode class data */
                    json = JsonConvert.SerializeObject(cngRequest, Formatting.Indented);
                }
                else if (MetaDataType == 'S')
                {
                    lgR.UserID     = id;
                    lgR.UserType   = userType;
                    lgR.DateString = "";
                    json           = JsonConvert.SerializeObject(lgR, Formatting.Indented);
                }

                var contentjson = new StringContent(json, Encoding.UTF8, ServiceAPIInfo.ContentMediaType);
                HttpResponseMessage responseAPI = Client.PostAsync(url, contentjson).Result;
                if (responseAPI.IsSuccessStatusCode == true)
                {
                    var test      = responseAPI.Content.ReadAsStringAsync();
                    var stringmsg = (object)test.Result;
                    if (MetaDataType == 'M')
                    {
                        if (UserType.currentUserType == UserType.enumUserType.Faculty)
                        {
                            download_FacultyMetadataResponse = JsonConvert.DeserializeObject <DownloadFacultyMetadataResponse>(test.Result);
                            MetaDataBind(download_FacultyMetadataResponse);
                        }
                        else if (UserType.currentUserType == UserType.enumUserType.Student)
                        {
                            download_StudentMetadaaResponse = JsonConvert.DeserializeObject <DownloadStudentMetadataResponse>(test.Result);
                            MetaDataBindForStudent(download_StudentMetadaaResponse);
                        }
                        else if (UserType.currentUserType == UserType.enumUserType.Parent)
                        {
                            download_ParentMetadataResponse = JsonConvert.DeserializeObject <DownloadParentMetadataResponse>(test.Result);
                            MetaDataBindForParent(download_ParentMetadataResponse);
                        }
                        else if (UserType.currentUserType == UserType.enumUserType.Management)
                        {
                            //here we are defind for management
                        }
                    }
                    else if (MetaDataType == 'S')
                    {
                        responseStudentAttendance = JsonConvert.DeserializeObject <StudentAttendanceResponse>(test.Result);
                        StudentDataBind(responseStudentAttendance);
                    }
                    var result = JsonConvert.DeserializeObject <LogInResponse>(test.Result);
                    if (!string.IsNullOrWhiteSpace(result.ToString()))
                    {
                        check_ServiceStatus = true;
                    }
                }
                else
                {
                    StrMSG = ErrorMsg("Server is not responding..");
                    check_ServiceStatus = false;
                }
            }
            catch (WebException ex)
            {
                StrMSG = ErrorMsg(ex.ToString());
                check_ServiceStatus = false;
            }
            catch (ProtocolViolationException ex)
            {
                StrMSG = ErrorMsg(ex.ToString());
                check_ServiceStatus = false;
            }
            catch (AggregateException ex)
            {
                StrMSG = ErrorMsg("Server is not responding..");
                Console.WriteLine(ex.InnerException.Message);
                check_ServiceStatus = false;
            }
            catch (Exception ex)
            {
                StrMSG = ErrorMsg("Error on Downloading..");
                Console.WriteLine(ex.InnerException.Message);
                check_ServiceStatus = false;
            }
            return(check_ServiceStatus);
        }