Exemplo n.º 1
0
        protected void Application_End()
        {
            GlobalHandle <ILifetimeScope> .GetCurrentRef()
            .Resolve <ILog>().Warning("The application is about to close!");

            GlobalHandle <ILifetimeScope> .Current.Dispose();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set binary data in the clipboard under the given format.
        /// </summary>
        public static void SetClipboardBinaryData(ReadOnlySpan <byte> span, ClipboardFormat format)
        {
            using GlobalHandle global   = Memory.Memory.GlobalAlloc((ulong)((span.Length + 1)), GlobalMemoryFlags.Moveable);
            using GlobalLock globalLock = global.Lock;
            Span <byte> buffer = globalLock.GetSpan <byte>();

            span.CopyTo(buffer);
            buffer[buffer.Length - 1] = 0;

            Imports.SetClipboardData((uint)format, globalLock.Pointer);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Set Unicode text in the clipboard under the given format.
        /// </summary>
        public static void SetClipboardUnicodeText(ReadOnlySpan <char> span, ClipboardFormat format = ClipboardFormat.UnicodeText)
        {
            using GlobalHandle global   = Memory.Memory.GlobalAlloc((ulong)((span.Length + 1) * sizeof(char)), GlobalMemoryFlags.Moveable);
            using GlobalLock globalLock = global.Lock;
            Span <char> buffer = globalLock.GetSpan <char>();

            span.CopyTo(buffer);
            buffer[buffer.Length - 1] = '\0';

            Imports.SetClipboardData((uint)format, globalLock.Pointer);
        }
Exemplo n.º 4
0
 private async void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (await GlobalHandle.checkLastuser() != null)
     {
         userEmail.Text = await GlobalHandle.checkLastuser();
     }
     if (await GlobalHandle.checkPassword() != null)
     {
         password.Password = await GlobalHandle.checkPassword();
     }
 }
Exemplo n.º 5
0
 private async void ShowLoginFormHandle(object sender, TappedRoutedEventArgs e)
 {
     ClearValue(SymbolIcon.ForegroundProperty);
     if (await GlobalHandle.checkToken() != null)
     {
         PageContent.Navigate(typeof(Views.UserInfomation));
     }
     else
     {
         PageContent.Navigate(typeof(Views.LoginForm));
     }
 }
 public AdminController(ILog logger, AuthDao auth = null)
     : base(logger)
 {
     if (auth == null)
     {
         _authDao = GlobalHandle <ILifetimeScope> .GetCurrentRef().Resolve <AuthDao>();
     }
     else
     {
         _authDao = auth;
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 需要对Mvc5的升级支持
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static ILifetimeScope GetContainer(ContainerBuilder builder)
        {
            IContainer container = builder.Build();

            ServiceLocator.SetLocatorProvider(() => new AutofacServiceLocator(container));
            var autofacDependencyResolver = new AutofacDependencyResolver(container);

            DependencyResolver.SetResolver(autofacDependencyResolver);
            GlobalHandle <ILifetimeScope> .Initialize(autofacDependencyResolver.ApplicationContainer);

            return(GlobalHandle <ILifetimeScope> .GetCurrentRef());
        }
Exemplo n.º 8
0
        private async void ShowListSonngHandle(object sender, TappedRoutedEventArgs e)
        {
            if (await GlobalHandle.checkToken() != null)
            {
                PageContent.Navigate(typeof(Views.ListSong));
            }
            else
            {
                var messageDialog = new MessageDialog("Vui lòng đăng nhập để sử dụng tính năng");
                await messageDialog.ShowAsync();

                PageContent.Navigate(typeof(Views.LoginForm));
            }
        }
Exemplo n.º 9
0
 public static extern IntPtr wasm_global_as_extern(GlobalHandle global);
Exemplo n.º 10
0
        private async void LoginHandle(object sender, RoutedEventArgs e)
        {
            this.currentMember.email    = userEmail.Text;
            this.currentMember.password = password.Password;
            var data            = Services.APIHandle.LoginHandle(this.currentMember).Result;
            var responseContent = Services.APIHandle.LoginHandle(this.currentMember).Result.Content.ReadAsStringAsync().Result;

            //Debug.WriteLine(data.Result.Content.ReadAsStringAsync().Result);
            if (data.StatusCode == System.Net.HttpStatusCode.Created)
            {
                // save file...
                Debug.WriteLine(responseContent);


                // Luu token
                GlobalHandle.saveToken(responseContent);
                //save email last user
                GlobalHandle.saveLastUser(this.currentMember.email);
                //save passWord if check savebox
                if (savePassword.IsChecked == true)
                {
                    GlobalHandle.savePassWord(this.currentMember.password);
                }
                else
                {
                    if (await GlobalHandle.checkPassword() != null)
                    {
                        GlobalHandle.deletePassword();
                    }
                }
                //Change Account Name in splitView
                Services.GlobalHandle.changeAccountName();
                Services.GlobalHandle.ShowSignOutButton();

                // Next page
                this.Frame.Navigate(typeof(Views.UserInfomation));
            }
            else
            {
                ErrorList error = JsonConvert.DeserializeObject <ErrorList>(responseContent);
                Debug.WriteLine(responseContent);
                if (error != null && error.error.Count > 0)
                {
                    var content = "";
                    foreach (var key in error.error.Keys)
                    {
                        //var textMessage = this.FindName(key);
                        //if (textMessage == null)
                        //{
                        //    continue;
                        //}
                        content += error.error[key].ToString();


                        //TextBlock textBlock = textMessage as TextBlock;
                        //textBlock.Text = error.error[key];
                        //textBlock.Visibility = Visibility.Visible;
                    }
                    var messageDialog = new MessageDialog(content);
                    await messageDialog.ShowAsync();
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 全局句柄初始化
        /// </summary>
        /// <param name="resolver">解析器</param>
        public static ILifetimeScope GlobalInitialize(this AutofacDependencyResolver resolver)
        {
            GlobalHandle <ILifetimeScope> .Initialize(resolver.RequestLifetimeScope);

            return(GlobalHandle <ILifetimeScope> .GetCurrentRef());
        }
        private async void RegisterHandle(object sender, RoutedEventArgs e)
        {
            registerMember.address = address.Text;

            registerMember.email     = email.Text;
            registerMember.firstName = firstName.Text;

            registerMember.lastName = lastName.Text;
            registerMember.password = password.Password;
            registerMember.phone    = phone.Text;
            registerMember.avatar   = ImageUrl.Text;
            var data            = Services.APIHandle.RegisterHandle(registerMember);
            var responseContent = data.Result.Content.ReadAsStringAsync().Result;

            if (data.Result.StatusCode == HttpStatusCode.Created)
            {
                Debug.WriteLine(data.Result.Content.ReadAsStringAsync().Result);
                var messageDialog = new MessageDialog("Đăng ký thành công");
                await messageDialog.ShowAsync();

                //Auto Login
                var loginData            = Services.APIHandle.LoginHandle(registerMember).Result;
                var loginResponseContent = Services.APIHandle.LoginHandle(registerMember).Result.Content.ReadAsStringAsync().Result;
                // Luu token
                GlobalHandle.saveToken(loginResponseContent);
                //save email last user
                GlobalHandle.saveLastUser(registerMember.email);
                //Change account Name
                Services.GlobalHandle.changeAccountName();
                //Show Login Button
                Services.GlobalHandle.ShowSignOutButton();
                //Navigate Frame
                this.Frame.Navigate(typeof(Views.HomePage));
            }
            else
            {
                ErrorList error = JsonConvert.DeserializeObject <ErrorList>(responseContent);
                Debug.WriteLine(responseContent);
                if (error != null && error.error.Count > 0)
                {
                    var content = "";
                    foreach (var key in error.error.Keys)
                    {
                        //var textMessage = this.FindName(key);
                        //if (textMessage == null)
                        //{
                        //    continue;
                        //}
                        content += error.error[key].ToString();
                        content += "\n";


                        //TextBlock textBlock = textMessage as TextBlock;
                        //textBlock.Text = error.error[key];
                        //textBlock.Visibility = Visibility.Visible;
                    }
                    var messageDialog = new MessageDialog(content);
                    await messageDialog.ShowAsync();
                }
            }
        }
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (GlobalHandle.checkToken() != null)
            {
                this.token.token = await GlobalHandle.checkToken();

                Debug.WriteLine(this.token.token);

                var data            = Services.APIHandle.UserInfomationHandle(this.token.token);
                var responseContent = data.Result.Content.ReadAsStringAsync().Result;
                if (data.Result.StatusCode == HttpStatusCode.Created)
                {
                    Member currentMember = JsonConvert.DeserializeObject <Member>(responseContent);
                    lastName.Text  = currentMember.lastName;
                    firstName.Text = currentMember.firstName;
                    email.Text     = currentMember.email;
                    phone.Text     = currentMember.phone;
                    address.Text   = currentMember.address;
                    ImageUrl.Text  = currentMember.avatar;

                    //check Gender
                    switch (currentMember.gender)
                    {
                    case 1:
                        Gender_Male.IsChecked = true;
                        break;

                    case 0:
                        Gender_Female.IsChecked = true;
                        break;

                    case 2:
                        Gender_Other.IsChecked = true;
                        break;

                    default:
                        break;
                    }

                    //show pic
                    Uri u;

                    try
                    {
                        u = new Uri(currentMember.avatar, UriKind.Absolute);
                        Debug.WriteLine(u.AbsoluteUri);
                        ImageUrl.Text   = u.AbsoluteUri;
                        MyAvatar.Source = new BitmapImage(u);
                    } catch (Exception error)
                    {
                    }



                    //add birthday into form
                    BirthDay.Date = DateTime.ParseExact(currentMember.birthday, "yyyy-MM-ddT00:00:00.000+0000", CultureInfo.InvariantCulture);
                }
                else
                {
                    ErrorList error = JsonConvert.DeserializeObject <ErrorList>(responseContent);
                    Debug.WriteLine(responseContent);
                    Debug.WriteLine(error.error.Count);
                    if (error != null)
                    {
                        var content = error.message;
                        content += "\n Tài khoản hết hạn, vui lòng đăng nhập lại";

                        var messageDialog = new MessageDialog(content);
                        await messageDialog.ShowAsync();

                        //Xoa file token
                        GlobalHandle.deleteToken();
                        //Chuyen huong frame
                        this.Frame.Navigate(typeof(Views.LoginForm));
                    }
                }
            }
        }