示例#1
0
 private void AddValidations()
 {
     _email.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EMAIL_REQUIRED")
     });
     _email.Validations.Add(new EmailValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EMAIL_VALID")
     });
     _firstName.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("FIRSTNAME_REQUIRED")
     });
     _firstName.Validations.Add(new NameValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("FIRSTNAME_VALID")
     });
     _lastName.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("LASTNAME_REQUIRED")
     });
     _lastName.Validations.Add(new NameValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("LASTNAME_VALID")
     });
     _EUSR.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EUSR_REQUIRED")
     });
     _EUSR.Validations.Add(new EUSRNumericValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EUSR_VALID")
     });
     _contactNo.Validations.Add(new ContactNumericValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("CONTACT_VALID")
     });
 }
示例#2
0
 public override void Validate()
 {
     base.Validate();
     _email.Validate();
     _firstName.Validate();
     _lastName.Validate();
     if (_Roles != null)
     {
         RoleMessage = null;
         if (_Roles.RoleName == Engineer)
         {
             _EUSR.Validate();
         }
         else
         {
             _EUSR.IsValid = true;
         }
     }
     else
     {
         RoleMessage = ResponceCode.applicationErrorHandler("ROLE_REQUIRED");
     }
     Message = (IsAccept == false ? ResponceCode.applicationErrorHandler("ACEEPTSTERMS_REQUIRED") : "");
     _contactNo.Validate();
     this.SetValid();
 }
示例#3
0
 private void AddValidations()
 {
     _email.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EMAIL_REQUIRED")
     });
     _email.Validations.Add(new EmailValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EMAIL_VALID")
     });
 }
示例#4
0
 public async void IsCheckPermissions()
 {
     if (Client.IsLogged == false)
     {
         await LogOut();
     }
     else if (!Client.IsPermission)
     {
         await page.DisplayAlert("Access Permission", ResponceCode.customErrorFunction(403, null), "Ok");
     }
 }
        private async void ResponceCode_LoadCompleted(object sender, NavigationEventArgs e)
        {
            if (count == 0)
            {
                string functionString = String.Format("document.getElementById('uname').innerText = '{0}';", obj.eclassUsername);
                await ResponceCode.InvokeScriptAsync("eval", new string[] { functionString });

                functionString = String.Format("document.getElementById('pass').innerText = '{0}';", obj.eclassPass);
                await ResponceCode.InvokeScriptAsync("eval", new string[] { functionString });

                functionString = String.Format("document.getElementsByTagName('button')[document.getElementsByTagName('button').length-1].click();");
                await ResponceCode.InvokeScriptAsync("eval", new[] { functionString });

                count++;
            }
            else if (count == 1)
            {
                ResponceCode.Navigate(new Uri("https://eclass.aueb.gr/modules/announcements/?course=" + courseCodeRequested));
                count++;
            }
            else if (count == 2)
            {
                var scode = await ResponceCode.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" });

                var doc = new HtmlDocument();
                doc.LoadHtml(scode);
                var value = doc.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href"));
                var myval = value.Where(y => y.Attributes["href"].Value.Contains("/modules/announcements/rss.php"));
                if (eclassUID.Equals(""))
                {
                    eclassUID = (myval.First().Attributes["href"].Value.Split('&').GetValue(1).ToString()).Split('=').Last().ToString();
                    await StoreUserIdAsync(eclassUID);
                }
                else
                {
                    announcementToken = new Model.AnnouncementToken()
                    {
                        ID = courseCodeRequested, Token = (myval.First().Attributes["href"].Value.Split('&').GetValue(2).ToString()).Split('=').Last().ToString()
                    };
                }

                count++;
                ResponceCode.Navigate(new Uri("https://eclass.aueb.gr/"));
            }
            else if (count == 3)
            {
                if (!eclassUID.Equals(""))
                {
                    correctCourses();
                }

                count++;
            }
        }
示例#6
0
 internal DnsServerResponse(bool connectionOk, int id, ResponceCode rcode
                            , List <DnsRecord> answers
                            , List <DnsRecord> authoritiveAnswers
                            , List <DnsRecord> additionalAnswers)
 {
     m_Success             = connectionOk;
     m_ID                  = id;
     m_RCODE               = rcode;
     m_pAnswers            = answers;
     m_pAuthoritiveAnswers = authoritiveAnswers;
     m_pAdditionalAnswers  = additionalAnswers;
 }
示例#7
0
 private async void NavigationSync()
 {
     networkAccess = Connectivity.NetworkAccess;
     if (networkAccess == NetworkAccess.Internet)
     {
         await AllSyncService.DataAsync();
     }
     else
     {
         await page.DisplayAlert("Alert", ResponceCode.customErrorFunction(651, null), "Ok");
     }
 }
示例#8
0
 private void AddValidations()
 {
     _userName.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EMAIL_REQUIRED")
     });
     _userName.Validations.Add(new EmailValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("EMAIL_VALID")
     });
     _password.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("PASSWORD_REQUIRED")
     });
 }
示例#9
0
 public override void Validate()
 {
     base.Validate();
     if (_Roles != null)
     {
         Message = "";
     }
     else
     {
         Message = ResponceCode.applicationErrorHandler("ROLE_REQUIRED");
     }
     this.SetValid();
 }
示例#10
0
 private void AddValidations()
 {
     _oldPassword.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("OLDPASSWORD_REQUIRED")
     });
     _password.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("NEWPASSWORD_REQUIRED")
     });
     _password.Validations.Add(new PasswordValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("PASSWORD_VALID")
     });
     _confirmPassword.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("CONFIRMPASSWORD_REQUIRED")
     });
 }
示例#11
0
 private void AddValidations()
 {
     _otpCode.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("OTP_REQUIRED")
     });
     _password.Validations.Add(new IsNotNullOrEmptyRule <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("PASSWORD_REQUIRED")
     });
     _password.Validations.Add(new PasswordValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("PASSWORD_VALID")
     });
     _confirmPassword.Validations.Add(new PasswordValidator <string> {
         ValidationMessage = ResponceCode.applicationErrorHandler("CONFIRMPASSWORD_REQUIRED")
     });
     //   _confirmPassword.Validations.Add(new PasswordValidator<string> { ValidationMessage = "Confirm Password is not matched." });
 }
示例#12
0
 public void OnSubmit()
 {
     Validate();
     if (IsValid)
     {
         networkAccess = Connectivity.NetworkAccess;
         if (networkAccess == NetworkAccess.Internet)
         {
             IsBusy = true;
             this.OnSubmitExcute();
         }
         else
         {
             Message = ResponceCode.customErrorFunction(651, null);
         }
     }
 }
示例#13
0
 public override void Validate()
 {
     base.Validate();
     _otpCode.Validate();
     _password.Validate();
     if (_confirmPassword.Validate())
     {
         if (_password.Value != _confirmPassword.Value)
         {
             ConfirmPassword.Errors.Add(ResponceCode.applicationErrorHandler("CONFIRMPASSWORD_VALID"));
         }
         else
         {
             ConfirmPassword.Errors.Add("");
         }
     }
     this.SetValid();
 }
        private async void correctCourses()
        {
            CoursesViewer.IsHitTestVisible = false;
            ProgressUpdate.IsActive        = true;
            ProgressUpdate.Visibility      = Visibility.Visible;
            CoursesViewer.Visibility       = Visibility.Collapsed;
            if (obj.eclassUID == null)
            {
                obj.eclassUID = eclassUID;
            }
            foreach (Course course in Ycourses)
            {
                if (course.MyAnnouncements.Count == 0)
                {
                    try
                    {
                        var url = "http://auebunofficialapi.azurewebsites.net/Announcements/Details/" + course.Id;
                        Model.AnnouncementToken announcement;
                        var response = await url.GetAsync().ReceiveString();

                        announcement           = JsonConvert.DeserializeObject <Model.AnnouncementToken>(response);
                        course.Ans             = c = new EclassRssParser("https://eclass.aueb.gr/modules/announcements/rss.php?c=" + course.Id + "&uid=" + obj.eclassUID + "&token=" + announcement.Token);
                        course.MyAnnouncements = c.Announcements;
                    }
                    catch (FlurlHttpException)
                    {
                        courseCodeRequested = course.Id;
                        var url = "https://eclass.aueb.gr/modules/announcements/?course=" + course.Id;
                        count = 2;
                        ResponceCode.Navigate(new Uri(url));
                        await Task.Delay(1400);

                        course.Ans             = c = new EclassRssParser("https://eclass.aueb.gr/modules/announcements/rss.php?c=" + announcementToken.ID + "&uid=" + obj.eclassUID + "&token=" + announcementToken.Token);
                        course.MyAnnouncements = c.Announcements;
                        var urlCreate = "http://auebunofficialapi.azurewebsites.net/Announcements/Create/";
                        var response  = await urlCreate.PostUrlEncodedAsync(new { ID = announcementToken.ID, Token = announcementToken.Token });
                    }
                }
            }
            CoursesViewer.IsHitTestVisible = true;
            ProgressUpdate.IsActive        = false;
            ProgressUpdate.Visibility      = Visibility.Collapsed;
            CoursesViewer.Visibility       = Visibility.Visible;
        }
示例#15
0
        private IActionResult _InternalError(ServerAction action, string info, ResponceCode respCode)
        {
            Exception ex = HttpContext.Features.Get <ExceptionHandlerFeature>()?.Error;

            //string Page = GetAbsoluteUri(Request);
            info = info + "\r\n" + ex?.ToString();
            if (Response.StatusCode == 404)
            {
                respCode = ResponceCode.NotFound;
            }
            Response.StatusCode = Response.StatusCode == 404 ? 404 : (int)respCode;

            ViewData["where"]        = HomeController.ControllerName;
            ViewData["DetailedInfo"] = respCode.ToString();
            ViewData["ErrorAT"]      = action.ToString();
            ViewData["RespCode"]     = Response.StatusCode.ToString();
            ViewData["ErrorMessage"] = info;
            //ViewData["RAWResp"] = Page;

            string content = string.Join("\r\n",
                                         "Error Report:",
                                         DateTime.Now.ToNormalString(),
                                         CurrentUser.GetFullIdentity(),
                                         Response.StatusCode,
                                         //ViewData["RAWResp"],
                                         ViewData["ErrorMessage"].ToString(),
                                         ViewData["ErrorAT"],
                                         ViewData["DetailedInfo"]);

            WeChatSentMessage _Message = new WeChatSentMessage(WeChatSMsg.text, null, content, null, "liuhaoyu");

            L.E(content.Replace("\r\n", " -- "));

            if (respCode != ResponceCode.Default)
            {
                WeChatMessageSystem.AddToSendList(_Message);
            }
            return(View("Error"));
        }
示例#16
0
        private async Task GetStatusAsync()
        {
            try
            {
                // StatusService service = new StatusService();
                statusList.Clear();

                var GetStatus = await manager.GetPropertyStatusItemsAsync();

                if (GetStatus.Count == 0)
                {
                    networkAccess = Connectivity.NetworkAccess;
                    if (networkAccess == NetworkAccess.Internet)
                    {
                        Client.IsPermission = true;
                        GetStatus           = await manager.GetPropertyStatusItemsAsync(true);

                        //Check Permissions 401 && 403
                        IsCheckPermissions();
                    }
                    else
                    {
                        await page.DisplayAlert("Status Not available", ResponceCode.customErrorFunction(651, null), "Ok");
                    }
                }
                foreach (var item in GetStatus)
                {
                    statusList.Add(item);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsStatus = (statusList.Count == 0 ? false : true);
            }
        }
示例#17
0
 private async Task CallHistoryPage()
 {
     try
     {
         networkAccess = Connectivity.NetworkAccess;
         if (networkAccess == NetworkAccess.Internet)
         {
             await Application.Current.MainPage.Navigation.PushAsync(new PropertyHistoryPage(PropertyModel));
         }
         else
         {
             await page.DisplayAlert("Alert", ResponceCode.customErrorFunction(651, null), "Ok");
         }
     }
     catch (Exception ex)
     {
         Debug.Write(ex.Message);
     }
     finally
     {
         IsBusy = false;
     }
 }
        private async void An_LoadedAsync(object sender, RoutedEventArgs d)
        {
            await FilCoursesAsync();

            ResponceCode.Navigate(new Uri("https://eclass.aueb.gr"));
        }
示例#19
0
 protected IActionResult NotFoundError(ServerAction action, string item, ResponceCode respCode      = ResponceCode.NotFound) => _InternalError(action, XConfig.Messages.NotFound + item, respCode);
示例#20
0
 protected IActionResult PermissionDenied(ServerAction action, string Reason, ResponceCode respCode = ResponceCode.PermisstionDenied)
 => _InternalError(action, XConfig.Messages.UserPermissionDenied + Reason, respCode);
示例#21
0
        public async void OnSubmitExecute()
        {
            //#if OFFLINE_SYNC_ENABLED
            try
            {
                AccountService userService = new AccountService();
                LoginModel     loginModel  = new LoginModel();
                loginModel.Email    = _userName.Value;
                loginModel.Password = Password.Value;
                TokenModel tokenModel = await userService.AuthorizeUser(loginModel);

                if (tokenModel != null)
                {
                    if (tokenModel.message != null || string.IsNullOrEmpty(tokenModel.userId))
                    {
                        //  Client.IsLogged = false;
                        Message = tokenModel.message;
                    }
                    else
                    {
                        Client.IsUserMatched = true;
                        Client.IsRoleMatched = true;

                        if (tokenModel.username != Client.username && !string.IsNullOrEmpty(Client.username))
                        {
                            Client.IsUserMatched = false;
                        }

                        Client.IsLogged     = true;
                        Client.IsPermission = true;
                        Client.token        = tokenModel.token;
                        Client.username     = tokenModel.username;
                        Client.userId       = tokenModel.userId;

                        Client.PendingCount = 0;
                        RoleService role = new RoleService();
                        ObservableCollection <RoleModel> RoleList = new ObservableCollection <RoleModel>();
                        RoleList = await role.GetUserRole();

                        if (RoleList.Count == 1)
                        {
                            foreach (var item in RoleList)
                            {
                                await AccountService.UpdatePreferredRole(item.Id);

                                if (item.RoleName != Client.roleName && !string.IsNullOrEmpty(Client.roleName))
                                {
                                    Client.IsRoleMatched = false;
                                }
                                Client.roleId   = item.Id;
                                Client.roleName = item.RoleName;
                            }
                            if (Client.IsUserMatched == false || Client.IsRoleMatched == false)
                            {
                                ClearedDataSync();
                            }
                            SetApplicationData(true);
                            //await System.Threading.Tasks.Task.Run(() =>
                            // {
                            DataSync();
                            //}).ConfigureAwait(false);

                            await Application.Current.MainPage.Navigation.PushAsync(new IncidentOverviewPage());
                        }
                        else if (RoleList.Count > 1)
                        {
                            await Application.Current.MainPage.Navigation.PushAsync(new RolePage(RoleList));
                        }
                        else
                        {
                            Message = ResponceCode.customErrorFunction(651, null);
                        }
                    }
                }
                else
                {
                    Message = tokenModel.message;
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
            //#else
            //              Message = "Please check Network connection.";
            //#endif
        }
示例#22
0
 protected IActionResult DatabaseError(ServerAction action, string Reason, ResponceCode respCode = ResponceCode.InternalServerError)
 => _InternalError(action, XConfig.Messages.DataBaseError + Reason, respCode);
示例#23
0
 protected IActionResult RequestIllegal(ServerAction action, string Reason, ResponceCode respCode = ResponceCode.RequestIllegal)
 => _InternalError(action, XConfig.Messages.RequestIllegal + Reason, respCode);
示例#24
0
 protected IActionResult NotSupported(ServerAction action, string Reason, ResponceCode respCode = ResponceCode.NotSupported)
 => _InternalError(action, XConfig.Messages.NotSupported + Reason, respCode);
示例#25
0
        /// <summary>
        /// Parses query.
        /// </summary>
        /// <param name="reply">Dns server reply.</param>
        /// <returns></returns>
        private DnsServerResponse ParseQuery(byte[] reply)
        {
            //--- Parse headers ------------------------------------//

            /* RFC 1035 4.1.1. Header section format
             *
             *                              1  1  1  1  1  1
             * 0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                      ID                       |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    QDCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    ANCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    NSCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |                    ARCOUNT                    |
             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
             |
             | QDCOUNT
             |  an unsigned 16 bit integer specifying the number of
             |  entries in the question section.
             |
             | ANCOUNT
             |  an unsigned 16 bit integer specifying the number of
             |  resource records in the answer section.
             |
             | NSCOUNT
             |  an unsigned 16 bit integer specifying the number of name
             |  server resource records in the authority records section.
             |
             | ARCOUNT
             |  an unsigned 16 bit integer specifying the number of
             |  resource records in the additional records section.
             |
             */

            // Get reply code
            int          id                     = (reply[0] << 8 | reply[1]);
            OpCode       opcode                 = (OpCode)((reply[2] >> 3) & 15);
            ResponceCode replyCode              = (ResponceCode)(reply[3] & 15);
            int          queryCount             = (reply[4] << 8 | reply[5]);
            int          answerCount            = (reply[6] << 8 | reply[7]);
            int          authoritiveAnswerCount = (reply[8] << 8 | reply[9]);
            int          additionalAnswerCount  = (reply[10] << 8 | reply[11]);
            //---- End of headers ---------------------------------//

            int pos = 12;

            //----- Parse question part ------------//
            for (int q = 0; q < queryCount; q++)
            {
                string dummy = "";
                GetQName(reply, ref pos, ref dummy);
                //qtype + qclass
                pos += 4;
            }
            //--------------------------------------//

            // 1) parse answers
            // 2) parse authoritive answers
            // 3) parse additional answers
            List <DnsRecord> answers            = ParseAnswers(reply, answerCount, ref pos);
            List <DnsRecord> authoritiveAnswers = ParseAnswers(reply, authoritiveAnswerCount, ref pos);
            List <DnsRecord> additionalAnswers  = ParseAnswers(reply, additionalAnswerCount, ref pos);

            return(new DnsServerResponse(true, id, replyCode, answers, authoritiveAnswers, additionalAnswers));
        }
示例#26
0
 public static ResponseResult Success(ResponceCode code = ResponceCode.Ok) =>
 new ResponseResult
 {
     IsSuccess = true,
     Code      = code
 };