Пример #1
0
        public override void Init()
        {
            Logger.LogInfo("I'm InjectLogin Plugin,I'm made in CHINA");
            Logger.LogInfo("Add User Type \"Inject\" to User Login Pane");
            LoginUserType usertype = new LoginUserType();


            usertype.HaveGUI   = "true";
            usertype.LoginText = "外置登录";
            var icon = new PackIcon()
            {
                Width = double.NaN, Height = double.NaN, Kind = PackIconKind.AccountReactivateOutline
            };

            usertype.Icon = icon;
            usertype.user = new InjectUser();
            usertype.AllowedLoginPanel = new LoginPane();
            UserTypeManager.AddUserType(usertype);
            Logger.LogInfo("Added");
            EventHelper.OnWindowLoaded += (object s, EventArgs e) =>
            {
                ColorHelper.BingdingBackgroundedForegoundToControl(icon);
            };
            Logger.LogInfo("Binded Color");
        }
Пример #2
0
        public void AddUserType(LoginUserType type)
        {
            Button btn = new Button();

            Logger.LogInfo("CheckGUI:" + type.HaveGUI);
            if (type.HaveGUI == "true")
            {
                Logger.LogInfo("Good! this pluginned user have GUI!");
                TabItem item = new TabItem();
                TABC_Users.Items.Add(item);
                item.Margin     = new Thickness(0);
                item.Height     = item.Width = 0;
                item.Background = item.Foreground = item.BorderBrush = null;
                item.Padding    = new Thickness(0);
                item.Content    = type.AllowedLoginPanel;
                (item.Content as UserControl).Height = double.NaN;
                (item.Content as UserControl).Width  = double.NaN;
                (item.Content as UserControl).HorizontalAlignment = HorizontalAlignment.Stretch;
                (item.Content as UserControl).VerticalAlignment   = VerticalAlignment.Stretch;
                btn.Click += (object sender, RoutedEventArgs e) =>
                {
                    TABC_Users.SelectedItem = item;
                };
            }
            SetEBinding(offacc, "Background", btn, Button.BackgroundProperty);
            SetEBinding(offacc, "BorderBrush", btn, Button.BorderBrushProperty);
            SetEBinding(offacc, "BorderThickness", btn, Button.BorderThicknessProperty);
            SetEBinding(offacc, "Width", btn, Button.WidthProperty);
            SetEBinding(offacc, "Height", btn, Button.HeightProperty);
            SetEBinding(offacc, "HorizontalContentAlignment", btn, HorizontalContentAlignmentProperty);
            SetEBinding(offacc, "VerticalContentAlignment", btn, Button.VerticalContentAlignmentProperty);
            SetEBinding(offacc, "Padding", btn, Button.PaddingProperty);
            SetEBinding(offacc, "Opacity", btn, Button.OpacityProperty);
            SetEBinding(offacc, "Margin", btn, Button.MarginProperty);
            Grid  content = new Grid();
            Label label   = new Label();

            SetEBinding(offacc, "Foreground", label, Label.ForegroundProperty);
            label.Content             = type.LoginText;
            label.VerticalAlignment   = VerticalAlignment.Center;
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.Margin   = new Thickness(0, 58, 0, 0);
            label.FontSize = 15;
            Label icongrid = new Label();

            icongrid.Padding                    = new Thickness(0);
            icongrid.HorizontalAlignment        = HorizontalAlignment.Center;
            icongrid.VerticalAlignment          = VerticalAlignment.Center;
            icongrid.HorizontalContentAlignment = HorizontalAlignment.Center;
            icongrid.VerticalContentAlignment   = VerticalAlignment.Center;
            icongrid.Margin  = new Thickness(0, -36, 0, 0);
            icongrid.Width   = icongrid.Height = 50;
            icongrid.Content = type.Icon;
            content.Children.Add(label);
            content.Children.Add(icongrid);
            btn.Content = content;

            buttonwrap.Children.Add(btn);
        }
Пример #3
0
 public async Task <dynamic> Update([FromBody] LoginUserType loginusertype)
 {
     if (_postUserLoginTypeProcessor != null)
     {
         return(await _putUserLoginTypeProcessor.PutExistingUserRecord(loginusertype, _cloudantService));
     }
     else
     {
         return(new string[] { "No database connection" });
     }
 }
Пример #4
0
            public Boolean AddUser(int idUser, LoginUserType loginType, String email, String userName)
            {
                var usermanager = new AppUserManager(new AppUserStore(new MyDbContext()));
                var tempuser    = new IdentityUser()
                {
                    UserName = userName, Email = email
                };

                usermanager.Create(tempuser, "Admin@123");
                usermanager.SaveAll();
                usermanager.Dispose();
                return(true);
            }
        public async Task <dynamic> Update([FromBody] LoginUserType loginUserType)
        {
            if (_cloudantService != null)
            {
                return(await _cloudantService.UpdateAsync(loginUserType));

                //Console.WriteLine("Update RESULT " + response);
                //return new string[] { employee.IBMEmailID, employee._id, employee._rev };
                //return JsonConvert.DeserializeObject<UpdateEmployeeResponse>(response.Result);
            }
            else
            {
                return(new string[] { "No database connection" });
            }
        }
Пример #6
0
        public Boolean  CreateUser(int idUser, LoginUserType loginType, String email, String userName)
        {
            var dbUSer = new MyDbContext();
            ApplicationDbInitializer dbApp = new ApplicationDbInitializer();
            var res = dbApp.AddUser(idUser, loginType, email, userName);

            if (res)
            {
                var xuser = db.AspNetUsers.Where(x => x.UserName == userName).FirstOrDefault();
                xuser.IdUser = idUser;
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        public async Task <dynamic> UpdateAsync(LoginUserType item)
        {
            string jsonInString = JsonConvert.SerializeObject(item);

            var _client = _factory.CreateClient("cloudant");

            var response = await _client.PutAsync(_client.BaseAddress + _dbName + "/" + _urlEncoder.Encode(item._id) + "?rev=" + _urlEncoder.Encode(item._rev), new StringContent(jsonInString, Encoding.UTF8, "application/json"));

            if (response.IsSuccessStatusCode)
            {
                var responseJson = await response.Content.ReadAsStringAsync();

                return(responseJson);
            }

            string msg = "Failure to POST. Status Code: " + response.StatusCode + ". Reason: " + response.ReasonPhrase;

            Console.WriteLine(msg);
            return(JsonConvert.SerializeObject(new { msg = "Failure to POST. Status Code: " + response.StatusCode + ". Reason: " + response.ReasonPhrase }));
        }
Пример #8
0
        public async Task <UpdateLoginUserTypesResponse> PutExistingUserRecord(LoginUserType loginuserUpdateRequest, ICloudantService cloudantService = null)
        {
            //AuditData auditData = new AuditData();
            //auditData.eventname = "edit";
            //auditData.loginid = employeeUpdateRequest.loginid;
            //auditData.datetime = System.DateTime.UtcNow.ToString();
            //auditData.empid = employeeUpdateRequest.FormattedEmployeedId;

            if (cloudantService != null)
            {
                var response = await cloudantService.UpdateAsync(loginuserUpdateRequest, DBNames.loginusertype.ToString());

                //var audit = await cloudantService.CreateAsync(auditData, DBNames.auditdata.ToString());
                return(JsonConvert.DeserializeObject <UpdateLoginUserTypesResponse>(response));
            }
            else
            {
                return(new UpdateLoginUserTypesResponse());
            }
        }