Esempio n. 1
0
 //check entry of attendace in database
 public bool checkAuthorizedofdate(string currentdate, string attendancedate)
 {
     try
     {
         //S form type is denoted show attandance
         _propertise = new Propertise();
         if (!string.IsNullOrEmpty(currentdate) && !string.IsNullOrEmpty(attendancedate))
         {
             if (DateTime.Parse(_propertise.ConsoleDateTimeFormat(attendancedate)) <= DateTime.Parse(_propertise.ConsoleDateTimeFormat(currentdate)))
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(false);
 }
Esempio n. 2
0
        /// <summary>
        /// method declare for TimeTable sync
        /// </summary>
        /// <param name="Connection"></param>
        /// <returns></returns>
        public static async Task syncTimeTable(int _UserID, UserType.enumUserType _userType, bool _FromStudentData = true)
        {
            Propertise gbl          = new Propertise();
            string     ServerPortNo = string.Empty;
            var        Client       = new HttpClient();

            try
            {
                GeneralProperties.ServicesMethodName = ServiceAPIInfo.SyncTimeTable;

                string url = ServiceAPIInfo.serviceAPI + GeneralProperties.ServicesMethodName;
                Client.BaseAddress = new Uri(url);
                Client.Timeout     = TimeSpan.FromMilliseconds(ServiceAPIInfo.service_TimeOut);

                //call student bind class and set data
                TimeTableRequest timetableRequest = new TimeTableRequest()
                {
                    UserID      = _UserID,
                    UserType    = (int)_userType,
                    DateString  = gbl.ConsoleDateTimeFormat(Propertise.todayDate()),
                    CheckStatus = _FromStudentData
                };

                TimeTableResponse download_TimeTableResponse = new TimeTableResponse();

                var json        = JsonConvert.SerializeObject(timetableRequest, 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;
                    download_TimeTableResponse = JsonConvert.DeserializeObject <TimeTableResponse>(test.Result);
                    if (download_TimeTableResponse.TimeTable.Count == 0)
                    {
                        return;
                    }
                    int codeMasterTimeTable = await App.Database.save_DownloadTimeTableResponse(download_TimeTableResponse);

                    if (codeMasterTimeTable > 0)
                    {
                        TimeTableAcknowledgementRequest timeTableAcknowledgementRequest = new TimeTableAcknowledgementRequest()
                        {
                            UserID              = _UserID,
                            UserType            = (int)_userType,
                            TimeTableMasterCode = codeMasterTimeTable
                        };
                        GeneralProperties.ServicesMethodName = ServiceAPIInfo.request_TimeTableAcknowledgementStatus;

                        url = ServiceAPIInfo.serviceAPI + GeneralProperties.ServicesMethodName;
                        Client.BaseAddress = new Uri(url);
                        Client.Timeout     = TimeSpan.FromMilliseconds(ServiceAPIInfo.service_TimeOut);
                        json        = JsonConvert.SerializeObject(timeTableAcknowledgementRequest, Formatting.Indented);
                        contentjson = new StringContent(json, Encoding.UTF8, ServiceAPIInfo.ContentMediaType);
                        responseAPI = Client.PostAsync(url, contentjson).Result;
                        if (responseAPI.IsSuccessStatusCode == true)
                        {
                            test      = responseAPI.Content.ReadAsStringAsync();
                            stringmsg = (object)test.Result;
                        }
                        else
                        {
                            Console.WriteLine("Time Table Acknowledgement status {0}", responseAPI.StatusCode);
                        }
                    }
                }
                else
                {
                    Console.Write(responseAPI.RequestMessage);
                }
            }
            catch (WebException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 3
0
        public static bool syncStudent(int usertype = 0)
        {
            Propertise gbl          = new Propertise();
            string     ServerPortNo = string.Empty;
            var        Client       = new HttpClient();
            int        _UserID      = 0;

            try
            {
                var login = App.Database.GetLogInAsync();
                if (login != null)
                {
                    _UserID = login.Result.Code;
                }
                if (_UserID == 0 || usertype == 0)
                {
                    return(false);
                }
                //call student bind class and set data
                StudentAttendanceRequest studentRequest = new StudentAttendanceRequest()
                {
                    UserID     = _UserID,
                    UserType   = usertype,
                    DateString = gbl.ConsoleDateTimeFormat(Propertise.todayDate())
                };
                StudentAcknowledgementRequest studentAcknowledgementRequest = new StudentAcknowledgementRequest();

                GeneralProperties.ServicesMethodName = ServiceAPIInfo.download_StudentMetadata;
                string url = ServiceAPIInfo.serviceAPI + GeneralProperties.ServicesMethodName;
                Client.BaseAddress = new Uri(url);
                Client.Timeout     = TimeSpan.FromMilliseconds(ServiceAPIInfo.service_TimeOut);

                var json        = JsonConvert.SerializeObject(studentRequest, 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;
                    var download_Response = JsonConvert.DeserializeObject <StudentAttendanceResponse>(test.Result);
                    if (string.IsNullOrEmpty(download_Response.ToString()) || download_Response.Students.StudentAttendance.Count == 0)
                    {
                        return(false);
                    }
                    else
                    {
                        int status = App.Database.syncAttandanceData(download_Response).Result;
                        if (status > 0)
                        {
                            //after save data send student data in server
                            studentAcknowledgementRequest.UserID   = _UserID;
                            studentAcknowledgementRequest.UserType = usertype;
                            IList <EAttendanceTransaction> transactions = new List <EAttendanceTransaction>();
                            if (download_Response.Students.StudentAttendance.Count > 0)
                            {
                                for (int i = 0; i < download_Response.Students.StudentAttendance.Count; i++)
                                {
                                    int transactiontableCount = download_Response.Students.StudentAttendance[i].AttendanceTransaction.Count;
                                    for (int j = 0; j < transactiontableCount; j++)
                                    {
                                        EAttendanceTransaction transaction = new EAttendanceTransaction();
                                        transaction.Code = download_Response.Students.StudentAttendance[i].AttendanceTransaction[j].Code;
                                        transaction.AttendanceMaster_Code = download_Response.Students.StudentAttendance[i].AttendanceTransaction[j].AttendanceMaster_Code;
                                        transaction.FacultyMaster_Code    = download_Response.Students.StudentAttendance[i].AttendanceTransaction[j].FacultyMaster_Code;
                                        transaction.StudentMaster_Code    = download_Response.Students.StudentAttendance[i].AttendanceTransaction[j].StudentMaster_Code;
                                        transaction.StudentName           = download_Response.Students.StudentAttendance[i].AttendanceTransaction[j].StudentName;
                                        transaction.Status = download_Response.Students.StudentAttendance[i].AttendanceTransaction[j].Status;
                                        transactions.Add(transaction);
                                    }
                                }
                                studentAcknowledgementRequest.Transactions = transactions;
                            }

                            //here we again call for acknowledgement
                            GeneralProperties.ServicesMethodName = ServiceAPIInfo.request_Studentid;
                            url = ServiceAPIInfo.serviceAPI + GeneralProperties.ServicesMethodName;
                            Client.BaseAddress = new Uri(url);
                            Client.Timeout     = TimeSpan.FromMilliseconds(ServiceAPIInfo.service_TimeOut);

                            json        = JsonConvert.SerializeObject(studentAcknowledgementRequest, Formatting.Indented);
                            contentjson = new StringContent(json, Encoding.UTF8, ServiceAPIInfo.ContentMediaType);
                            responseAPI = Client.PostAsync(url, contentjson).Result;
                            if (responseAPI.IsSuccessStatusCode == true)
                            {
                                test      = responseAPI.Content.ReadAsStringAsync();
                                stringmsg = (object)test.Result;
                                if (!string.IsNullOrEmpty(stringmsg.ToString()))
                                {
                                    Console.WriteLine("Successfull download student data !");
                                    return(true);
                                }
                                else
                                {
                                    Console.WriteLine("Fail on the Acknowledge request !");
                                    return(false);
                                }
                            }
                        }
                    }
                }
                else
                {
                    Console.Write(responseAPI.RequestMessage);
                }
            }
            catch (WebException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(false);
        }