コード例 #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);
 }
コード例 #2
0
        static TimeTableGroup()
        {
            try
            {
                string className = string.Empty;
                _timeTableList = new List <TimeTableModelCell>();
                ObservableCollection <TimeTableGroup> Groups;
                TimeTableGroup timeTablegroup;
                _timeTableList = App.Database.getTimeTableData(Propertise.todayDate(), MasterChooseDetails.ClassMaster_Code, MasterChooseDetails.StreamMaster_Code, MasterChooseDetails.SectionMaster_Code).Result;
                if (_timeTableList != null)
                {
                    if (_timeTableList.Count > 0)
                    {
                        Groups = new ObservableCollection <TimeTableGroup>();
                        for (int j = 0; j < _timeTableList.Count(); j++)
                        {
                            //check week day not blank
                            if (!string.IsNullOrEmpty(_timeTableList[j].DayofWeek))
                            {
                                string shortname = string.Empty;
                                string weakName  = string.Empty;
                                //here set weak day
                                weakName       = getWeakName(j, ref shortname);
                                timeTablegroup = new TimeTableGroup(weakName, shortname, false);
                                #region bind_Lecture
                                //-1 for Holiday and 0 for Break
                                //check subject not blank
                                //for 1 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture1);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture1);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-1", Description = className
                                });
                                //for 2 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture2);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture2);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-2", Description = className
                                });
                                //for 3 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture3);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture3);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-3", Description = className
                                });
                                //for 4 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture4);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture4);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-4", Description = className
                                });
                                //for 5 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture5);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture5);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-5", Description = className
                                });
                                //for 6 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture6);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture6);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-6", Description = className
                                });
                                //for 7 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture7);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture7);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-7", Description = className
                                });
                                //for 8 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture8);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture8);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-8", Description = className
                                });
                                //for 9 lecture
                                className = "";
                                className = App.Database.t_GetSubjectCode(_timeTableList[j].Lecture9);
                                if (string.IsNullOrEmpty(className))
                                {
                                    className = getClassEmptyData(_timeTableList[j].Lecture9);
                                }
                                timeTablegroup.Add(new Weak()
                                {
                                    Name = "Lecture-9", Description = className
                                });

                                Groups.Add(timeTablegroup);
                                #endregion
                            }
                        }
                        All = Groups;
                    }
                }
                else
                {
                    Groups = new ObservableCollection <TimeTableGroup>
                    {
                        new TimeTableGroup("Sunday", "S")
                        {
                            new Weak {
                                Name = "Not Avilable"
                            },
                        },
                        new TimeTableGroup("Monday", "M", true)
                        {
                            new Weak {
                                Name = "Not Avilable"
                            },
                        },
                        new TimeTableGroup("Tuesday", "T")
                        {
                            new Weak {
                                Name = "Not Avilable"
                            },
                        },
                        new TimeTableGroup("Wednesday", "W")
                        {
                            new Weak {
                                Name = "Not Avilable"
                            },
                        },
                        new TimeTableGroup("Thursday", "Th")
                        {
                            new Weak {
                                Name = "Not Avilable"
                            },
                        },
                        new TimeTableGroup("Friday", "F")
                        {
                            new Weak {
                                Name = "Not Avilable"
                            },
                        },
                        new TimeTableGroup("Saturday", "Sat")
                        {
                            new Weak {
                                Name = "Not Avilable"
                            },
                        }
                    };
                    All = Groups;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #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);
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        public static bool syncAttendanceOnServer(int userId, int userType)
        {
            Propertise gbl          = new Propertise();
            string     ServerPortNo = string.Empty;
            var        Client       = new HttpClient();
            int        _UserID      = userId;
            int        usertype     = userType;

            try
            {
                //var login = App.Database.GetLogInAsync();
                //if (login.Result.Count > 0)
                //{
                //    _UserID = login.Result[0].Code;
                //    usertype = 2;
                //}

                if (_UserID == 0 || usertype == 0)
                {
                    return(false);
                }
                //call student bind class and set data
                var classAttendace = App.Database.bindStudentsData().Result;
                if (classAttendace == null || classAttendace.Count == 0)
                {
                    return(false);
                }
                ClassAttendanceRequest classAttendanceRequest = new ClassAttendanceRequest()
                {
                    UserID          = _UserID,
                    UserType        = usertype,
                    ClassAttendance = classAttendace,
                };


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

                var json        = JsonConvert.SerializeObject(classAttendanceRequest, 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 <ClassAttendanceResponse>(test.Result);
                    if (download_Response.SyncAttendanceStatus)
                    {
                        App.Database.UpdateStudentStatus();
                        return(true);
                    }
                    else
                    {
                        Console.WriteLine("Attendance have not found !");
                        return(false);
                    }
                }
                else
                {
                    Console.Write(responseAPI.RequestMessage);
                }
            }
            catch (WebException Ex)
            {
                Console.WriteLine(Ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(false);
        }