Example #1
0
        private string GetFieldXml(bool required, string additionalProperties, string fieldContent)
        {
            var format      = !string.IsNullOrEmpty(Format) ? " Format=\"" + Format + "\"" : string.Empty;
            var showField   = !string.IsNullOrEmpty(ShowField) ? " ShowField=\"" + ShowField + "\"" : string.Empty;
            var openTermSet = OpenTermSet ? " CreateValuesInEditForm=\"TRUE\" Open=\"TRUE\"" : string.Empty;

            var fieldXml = new StringBuilder();

            fieldXml.AppendFormat(
                "<Field ID=\"{0}\" Name=\"{1}\" DisplayName=\"{2}\" Type=\"{3}\" Hidden=\"{4}\" " +
                "Group=\"{5}\" Description=\"{6}\" Required=\"{7}\" " +
                "ShowInNewForm=\"{8}\" ShowInEditForm=\"{9}\" ShowInDisplayForm=\"{10}\"" +
                "{11}{12}{13} {14}>",
                ID.ToString("B"), InternalName.Trim(), DisplayName.Trim(), Type, Hidden,
                Group, Description, required.ToString().ToUpper(),
                ShowInNewForm.ToString().ToUpper(), ShowInEditForm.ToString().ToUpper(), ShowInDisplayForm.ToString().ToUpper(),
                format, showField, openTermSet, additionalProperties);

            if (!string.IsNullOrEmpty(Default))
            {
                fieldXml.AppendFormat("<Default>{0}</Default>", Default);
            }
            if (!string.IsNullOrEmpty(fieldContent))
            {
                fieldXml.Append(fieldContent);
            }
            fieldXml.Append("</Field>");

            return(fieldXml.ToString());
        }
Example #2
0
        private string[] Validate(int userId)
        {
            List <string> errors = new List <string>();

            if (userId == 0)
            {
                if (DisplayName.Trim() == "")
                {
                    errors.Add("Name cannot be blank");
                }
                if (System.Text.RegularExpressions.Regex.Match(DisplayName, "[A-Za-z0-9\\-_ \\.\\']{1,99}").Value != DisplayName)
                {
                    errors.Add("Invalid characters in name.");
                }
                if (!IsValidEmail(Email))
                {
                    errors.Add("Invalid email address.");
                }
                if (userId == 0 && Password == "")
                {
                    errors.Add("Password cannot be blank");
                }
                if (Password != "" && Password.Trim().Length < 6)
                {
                    errors.Add("Password must be at least 6 characters.");
                }
            }

            return(errors.ToArray());
        }
Example #3
0
 private void SetInitials()
 {
     if (AvatarInitials == null)
     {
         return;
     }
     if (!String.IsNullOrEmpty(DisplayName))
     {
         string   result = "";
         string[] split  = DisplayName.Trim().Split(' ');
         for (int i = 0; i < Math.Min(2, split.Length); i++)
         {
             if (split[i].Length == 0)
             {
                 continue;
             }
             result += split[i][0];
         }
         AvatarInitials.Text = result.ToUpper();
     }
     else
     {
         AvatarInitials.Text = "";
     }
     SetBackground();
 }
Example #4
0
        /** INSTANCE METHODS **/

        public bool Save()
        {
            // Get the Display Name
            if (DisplayName.Trim() == String.Empty)
            {
                this.DisplayName = GetDisplayName(this.Username);
            }

            DataAccessLayerBaseClass DBLayer = DataAccessLayerBaseClassHelper.GetDataAccessLayer();

            if (Id <= DefaultValues.GetUserIdMinValue())
            {
                int TempId = DBLayer.CreateNewUser(this);
                if (TempId > 0)
                {
                    _Id = TempId;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(DBLayer.UpdateUser(this));
            }
        }
Example #5
0
 public User TrimValues()
 {
     DisplayName = DisplayName.Trim();
     Email       = Email.Trim();
     Password    = Password.Trim();
     return(this);
 }
Example #6
0
 internal async Task OnNavigatingFrom()
 {
     Contact.ThreadDisplayName = DisplayName.Trim();
     await Task.Run(() =>
     {
         App.Handle.SaveAndDispatchSignalConversation(Contact, null);
     });
 }
Example #7
0
 public override DbProduct ToEntity(DbProduct original)
 {
     original.DisplayName = DisplayName.Trim();
     original.Discount    = Discount;
     original.Price       = Price;
     original.Description = Description == null ? string.Empty : Description.Trim();
     //original.DisplayName = this.DisplayName.Trim();
     //original.CategoryName = this.CategoryName.Trim();
     original.Id = Id;
     //original.Producer = this.Producer;
     return(original);
 }
Example #8
0
        public override bool Update()
        {
            bool result;

            StoredProcedure proc = new StoredProcedure(Constants.CONNECTION_STRING, Constants.STORED_PROC_UPDATE_USER);

            proc.AddInput("@UserId", UserId, System.Data.SqlDbType.Int);
            proc.AddInput("@displayName", DisplayName.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@description", Description.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@usersFollowed", UsersFollowed, System.Data.SqlDbType.Int);
            proc.AddInput("@usersFollowing", UsersFollowing, System.Data.SqlDbType.Int);
            proc.AddInput("@lastAlertCheck", LastAlertCheck, System.Data.SqlDbType.DateTime);

            result = proc.Execute();

            return(result);
        }
Example #9
0
        // User must use a stored procedure so that the SQL server can handle password encryption.
        public override bool Add()
        {
            bool result;

            StoredProcedure proc = new StoredProcedure(Constants.CONNECTION_STRING, Constants.STORED_PROC_ADD_USER);

            proc.AddInput("@userName", UserName.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@email", Email.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@password", Password.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@displayName", DisplayName.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@description", Description.Trim(), System.Data.SqlDbType.VarChar);

            System.Data.SqlClient.SqlParameter idParam = proc.AddOutput("@userId", System.Data.SqlDbType.Int);

            result = proc.Execute();

            if (result)
            {
                UserId = Convert.ToInt32(idParam.Value);
            }

            return(result);
        }
Example #10
0
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                if (ApplicationId == Guid.Empty)
                {
                    string uri = "http://" + DisplayName.Trim().Replace(' ', '_');

                    // Create an application and get the applicationId
                    CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters
                    {
                        DisplayName    = DisplayName,
                        IdentifierUris = new[] { uri },
                        HomePage       = uri
                    };

                    if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName)))
                    {
                        var application = ActiveDirectoryClient.CreateApplication(appParameters);
                        ApplicationId   = application.ApplicationId;
                    }
                }

                CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters
                {
                    ApplicationId  = ApplicationId,
                    AccountEnabled = true
                };

                switch (ParameterSetName)
                {
                case ParameterSet.ApplicationWithPasswordPlain:
                case ParameterSet.DisplayNameWithPasswordPlain:
                    createParameters.PasswordCredentials = new PSADPasswordCredential[]
                    {
                        new PSADPasswordCredential
                        {
                            StartDate = StartDate,
                            EndDate   = EndDate,
                            KeyId     = Guid.NewGuid(),
                            Password  = Password
                        }
                    };
                    break;

                case ParameterSet.ApplicationWithPasswordCredential:
                case ParameterSet.DisplayNameWithPasswordCredential:
                    createParameters.PasswordCredentials = PasswordCredentials;
                    break;

                case ParameterSet.ApplicationWithKeyPlain:
                case ParameterSet.DisplayNameWithKeyPlain:
                    createParameters.KeyCredentials = new PSADKeyCredential[]
                    {
                        new PSADKeyCredential
                        {
                            StartDate = StartDate,
                            EndDate   = EndDate,
                            KeyId     = Guid.NewGuid(),
                            CertValue = CertValue
                        }
                    };
                    break;

                case ParameterSet.ApplicationWithKeyCredential:
                case ParameterSet.DisplayNameWithKeyCredential:
                    createParameters.KeyCredentials = KeyCredentials;
                    break;
                }

                if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: string.Format("Adding a new service principal to be associated with an application having AppId '{0}'", createParameters.ApplicationId)))
                {
                    WriteObject(ActiveDirectoryClient.CreateServicePrincipal(createParameters));
                }
            });
        }
 public SuplierViewModel()
 {
     List          = new ObservableCollection <Suplier>(DataProvider.Ins.DB.Supliers);
     _ContractDate = DateTime.Now;
     #region Add
     AddCommand = new RelayCommand <object>((p) =>
     {
         if (string.IsNullOrWhiteSpace(DisplayName) || ContractDate == null)
         {
             return(false);
         }
         var displayList = DataProvider.Ins.DB.Supliers.Where(x => x.DisplayName == DisplayName);
         if (displayList == null || displayList.Count() != 0)
         {
             return(false);
         }
         return(true);
     }, (p) =>
     {
         var Suplier = new Suplier()
         {
             DisplayName = DisplayName.Trim(), Phone = Phone, Address = Address, Email = Email, ContractDate = ContractDate, MoreInfo = MoreInfo
         };
         DataProvider.Ins.DB.Supliers.Add(Suplier);
         DataProvider.Ins.DB.SaveChanges();
         List.Add(Suplier);
         Reset();
     });
     #endregion
     #region Edit
     EditCommand = new RelayCommand <object>((p) =>
     {
         if (SelectedItem == null || string.IsNullOrWhiteSpace(DisplayName))
         {
             return(false);
         }
         return(true);
     }, (p) =>
     {
         var Suplier          = DataProvider.Ins.DB.Supliers.Where(x => x.Id == SelectedItem.Id).SingleOrDefault();
         Suplier.Phone        = Phone;
         Suplier.DisplayName  = DisplayName.Trim();
         Suplier.Address      = Address;
         Suplier.Email        = Email;
         Suplier.ContractDate = ContractDate;
         Suplier.MoreInfo     = MoreInfo;
         DataProvider.Ins.DB.SaveChanges();
         Reset();
     });
     #endregion
     #region Sort
     SortIdCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortDisplayNameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortAddressCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Address", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Address", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortPhoneCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Phone", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Phone", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortOutputPriceCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("OutputPrice", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("OutputPrice", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortEmailCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Email", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Email", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortMoreInfoCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("MoreInfo", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("MoreInfo", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortContractDateCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("ContractDate", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("ContractDate", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     #endregion
 }
Example #12
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_OnClick(object sender, RoutedEventArgs e)
        {
            if (!_clsLoginModel.PermissionsFunc(_currentMenuId, (int)PermissionsEnum.修改))
            {
                _metroWindow.ShowMessageAsync("友情提示", "您没有修改菜单信息的权限");
                return;
            }
            if (!Verify())
            {
                return;
            }
            if (!JudgeDisplayNameNotRootName(_metroWindow, DisplayName))
            {
                return;
            }

            Action updateAction = () =>
            {
                var requestModel = new LeftMenusUpdateRequestModel
                {
                    DisplayName   = DisplayName,
                    DllPath       = DllPath,
                    EntryFunction = EntryFunction,
                    Ico           = null,
                    MenuId        = MenuId,
                    NavBarGroupId = NavBarGroupId,
                    ParentId      = ParentId,
                    StartWithSys  = StartWithSysYes,
                    Timestamp     = _leftMenusManage.ServerTime.ToUnixTimestamp()
                };
                var result = _leftMenusManage.Update(LeftMenuId, Timestamp, requestModel);
                if (result.ResultStatus == ResultStatus.Success)
                {
                    var selectedTreeView = GetSelectedTreeView();
                    Timestamp = result.Data.Timestamp;
                    ((LeftMenus)((TreeViewItem)selectedTreeView.SelectedItem).DataContext).Timestamp = result.Data.Timestamp;

                    var currentTreeView = GetSelectedTreeView();
                    UpdateSelectedItemPosition(LeftMenuId);
                    UpdateSort(currentTreeView.Items);
                    UpdateSelectedItem(currentTreeView.Items, LeftMenuId);

                    _leftMenu.LeftMenusList = _leftMenusManage.GetAll();
                }
                _metroWindow.ShowMessageAsync(result.ResultStatus == ResultStatus.Success ? "更新成功" : "更新失败", result.Message);
            };

            var setting = new MetroDialogSettings
            {
                AnimateShow           = true,
                AnimateHide           = true,
                AffirmativeButtonText = "确定",
                NegativeButtonText    = "取消",
                DefaultButtonFocus    = MessageDialogResult.Negative
            };

            _metroWindow.ShowMessageAsync("更新节点提示", "您确定要更新此节点信息吗?", MessageDialogStyle.AffirmativeAndNegative, setting).ContinueWith(
                t =>
            {
                _metroWindow.Dispatcher.Invoke((Action)(() =>
                {
                    if (t.Result == MessageDialogResult.Affirmative)
                    {
                        if (_leftMenusManage.Exist(a => a.Id != LeftMenuId && a.DisplayName == DisplayName.Trim()))
                        {
                            _metroWindow.ShowMessageAsync("信息重复提示", $"菜单名称“{DisplayName}”,在系统中已存在,是否仍使用该名称?", MessageDialogStyle.AffirmativeAndNegative, setting)
                            .ContinueWith(z =>
                            {
                                if (z.Result == MessageDialogResult.Affirmative)
                                {
                                    _metroWindow.Dispatcher.Invoke((Action)(() => {
                                        updateAction();
                                    }));
                                }
                            });
                        }
                        else
                        {
                            updateAction();
                        }
                    }
                }));
            });
        }
 public UnitViewModel()
 {
     List = new ObservableCollection <Unit>(DataProvider.Ins.DB.Units);
     #region Add
     AddCommand = new RelayCommand <Unit>((p) =>
     {
         if (string.IsNullOrWhiteSpace(DisplayName))
         {
             return(false);
         }
         var displayList = DataProvider.Ins.DB.Units.Where(x => x.DisplayName == DisplayName);
         if (displayList == null || displayList.Count() != 0)
         {
             return(false);
         }
         return(true);
     }, (p) =>
     {
         var unit = new Unit()
         {
             DisplayName = DisplayName.Trim()
         };
         DataProvider.Ins.DB.Units.Add(unit);
         DataProvider.Ins.DB.SaveChanges();
         List.Add(unit);
         DisplayName = null;
     });
     #endregion
     #region Edit
     EditCommand = new RelayCommand <object>((p) =>
     {
         if (string.IsNullOrEmpty(DisplayName) || SelectedItem == null)
         {
             return(false);
         }
         var displayList = DataProvider.Ins.DB.Units.Where(x => x.Id == SelectedItem.Id);
         if (displayList == null || displayList.Count() == 0)
         {
             return(false);
         }
         return(true);
     }, (p) =>
     {
         var unit         = DataProvider.Ins.DB.Units.Where(x => x.Id == SelectedItem.Id).SingleOrDefault();
         unit.DisplayName = DisplayName.Trim();
         DataProvider.Ins.DB.SaveChanges();
         DisplayName = null;
     });
     #endregion
     #region Sort
     SortDisplayNameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortIdCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     #endregion
 }
        /// <summary>
        /// To Validate all User Input Fields...
        /// </summary>
        /// <returns></returns>
        private async Task <bool> Validate()
        {
            UserDialog.ShowLoading("Please Wait…", MaskType.Clear);
            DisplayName = DisplayName.Trim();
            if (string.IsNullOrEmpty(DisplayName))
            {
                UserDialog.HideLoading();
                UserDialog.Alert("Please enter your display name.", "", "Ok");
                return(false);
            }
            //bool isValid1 = (Regex.IsMatch(DisplayName, _Name, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)));
            //if (!isValid1)
            //{
            //    UserDialog.HideLoading();
            //    UserDialog.Alert("Display name is not valid");
            //    return false;
            //}
            if (DisplayName.Length < 3 || DisplayName.Length > 50)
            {
                UserDialog.HideLoading();
                UserDialog.Alert("The display name should be between 3 to 50 characters.", "", "Ok");
                return(false);
            }
            if (string.IsNullOrEmpty(CountryOfResidency))
            {
                UserDialog.HideLoading();
                UserDialog.Alert("Please select your country of resident.", "", "Ok");
                return(false);
            }
            if (string.IsNullOrEmpty(Mobileno))
            {
                UserDialog.HideLoading();
                UserDialog.Alert("Please enter your mobile number.", "", "Ok");
                return(false);
            }
            if (Mobileno.Length < 8 || Mobileno.Length > 15)
            {
                UserDialog.HideLoading();
                UserDialog.Alert("The Mobile number should be between 8 to 15 digits.", "", "Ok");
                return(false);
            }
            bool isValid2 = (Regex.IsMatch(Mobileno, _Phone, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)));

            if (!isValid2)
            {
                UserDialog.HideLoading();
                UserDialog.Alert("Mobile number is not valid");
                return(false);
            }
            bool valphone = await CheckPhoneNumber();

            if (valphone == false)
            {
                UserDialog.HideLoading();
                UserDialog.Alert("Invalid Phone Number.");
                return(false);
            }
            if (IsAgreedToTC == false)
            {
                UserDialog.HideLoading();
                UserDialog.Alert("Please agree to our Terms and Conditions and Privacy Policy.", "", "Ok");
                return(false);
            }
            UserDialog.HideLoading();
            return(true);
        }
Example #15
0
 private void SavebtnMouseOver()
 {
     if ((SectionName == EmptyField || SectionName.Trim().ToString() == string.Empty) || (DisplayName == EmptyField || DisplayName.Trim().ToString() == string.Empty) || (StatisticsName == EmptyField || StatisticsName.Trim().ToString() == string.Empty) ||
         (TooltipValue == EmptyField || TooltipValue.Trim().ToString() == string.Empty) || (Threshold1 == EmptyField || Threshold1.Trim().ToString() == string.Empty) || (Threshold2 == EmptyField || Threshold2.Trim().ToString() == string.Empty) || (Threshold1 == DecimalFormat || Threshold1.Trim().ToString() == string.Empty) ||
         (Threshold2 == DecimalFormat || Threshold2.Trim().ToString() == string.Empty) || (Threshold1 == TimeFormat || Threshold1.Trim().ToString() == string.Empty) || (Threshold2 == TimeFormat || Threshold2.Trim().ToString() == string.Empty) ||
         (Threshold1 == ThresholdMessage1 || Threshold1.Trim().ToString() == string.Empty) || (Threshold2 == ThresholdMessage2 || Threshold2.Trim().ToString() == string.Empty))
     {
         IsSavebtnEnable = false;
     }
     else
     {
         IsSavebtnEnable = true;
     }
 }
        private void CreateSimpleServicePrincipal()
        {
            var subscriptionId = DefaultContext.Subscription?.Id;

            if (!this.IsParameterBound(c => c.StartDate))
            {
                DateTime currentTime = DateTime.UtcNow;
                StartDate = currentTime;
                WriteVerbose("No start date provided - using the current time as default.");
            }

            if (!this.IsParameterBound(c => c.EndDate))
            {
                EndDate = StartDate.AddYears(1);
                WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed);
            }

            if (!this.IsParameterBound(c => c.DisplayName))
            {
                DisplayName = "azure-powershell-" + StartDate.ToString("MM-dd-yyyy-HH-mm-ss");
                WriteVerbose(string.Format("No display name provided - using the default display name of '{0}'", DisplayName));
            }

            bool printPassword          = false;
            bool printUseExistingSecret = true;

            // Handle credentials
            var Password = Guid.NewGuid().ToString().ConvertToSecureString();

            // Create an application and get the applicationId
            if (!this.IsParameterBound(c => c.ApplicationId))
            {
                printUseExistingSecret = false;
                CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters
                {
                    DisplayName         = DisplayName,
                    HomePage            = "http://" + HttpUtility.UrlEncode(DisplayName.Trim()),
                    PasswordCredentials = new PSADPasswordCredential[]
                    {
                        new PSADPasswordCredential()
                        {
                            StartDate = StartDate,
                            EndDate   = EndDate,
                            KeyId     = Guid.NewGuid(),
                            Password  = SecureStringExtensions.ConvertToString(Password)
                        }
                    }
                };

                if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName)))
                {
                    var application = ActiveDirectoryClient.CreateApplication(appParameters);
                    ApplicationId = application.ApplicationId;
                    WriteVerbose(string.Format("No application id provided - created new AD application with application id '{0}'", ApplicationId));
                    printPassword = true;
                }
            }

            CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters
            {
                ApplicationId  = ApplicationId,
                AccountEnabled = true,
            };

            var shouldProcessMessage = string.Format("Adding a new service principal to be associated with an application " +
                                                     "having AppId '{0}' with no permissions.", createParameters.ApplicationId);

            if (!SkipRoleAssignment())
            {
                if (!this.IsParameterBound(c => c.Scope))
                {
                    Scope = string.Format("/subscriptions/{0}", subscriptionId);
                    WriteVerbose(string.Format("No scope provided - using the default scope '{0}'", Scope));
                }

                AuthorizationClient.ValidateScope(Scope, true);

                if (!this.IsParameterBound(c => c.Role))
                {
                    Role = "Contributor";
                    WriteVerbose(string.Format("No role provided - using the default role '{0}'", Role));
                }

                shouldProcessMessage = string.Format("Adding a new service principal to be associated with an application " +
                                                     "having AppId '{0}' with '{1}' role over scope '{2}'.", createParameters.ApplicationId, this.Role, this.Scope);
            }

            if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: shouldProcessMessage))
            {
                PSADServicePrincipalWrapper servicePrincipal = new PSADServicePrincipalWrapper(ActiveDirectoryClient.CreateServicePrincipal(createParameters));
                if (printPassword)
                {
                    servicePrincipal.Secret = Password;
                }
                else if (printUseExistingSecret)
                {
                    WriteVerbose(String.Format(ProjectResources.ServicePrincipalCreatedWithCredentials, ApplicationId));
                }
                WriteObject(servicePrincipal);
                if (SkipRoleAssignment())
                {
                    WriteVerbose("Skipping role assignment for the service principal.");
                    return;
                }

                WriteWarning(string.Format("Assigning role '{0}' over scope '{1}' to the new service principal.", this.Role, this.Scope));
                FilterRoleAssignmentsOptions parameters = new FilterRoleAssignmentsOptions()
                {
                    Scope = this.Scope,
                    RoleDefinitionName = this.Role,
                    ADObjectFilter     = new ADObjectFilterOptions
                    {
                        SPN = servicePrincipal.ApplicationId.ToString(),
                        Id  = servicePrincipal.Id.ToString()
                    },
                    ResourceIdentifier = new ResourceIdentifier()
                    {
                        Subscription = subscriptionId
                    },
                    CanDelegate = false
                };

                for (var i = 0; i < 6; i++)
                {
                    try
                    {
                        TestMockSupport.Delay(5000);
                        PoliciesClient.CreateRoleAssignment(parameters);
                        var ra = PoliciesClient.FilterRoleAssignments(parameters, subscriptionId);
                        if (ra != null)
                        {
                            WriteVerbose(string.Format("Role assignment with role '{0}' and scope '{1}' successfully created for the created service principal.", this.Role, this.Scope));
                            break;
                        }
                    }
                    catch (ErrorResponseException e)
                    {
                        throw new ErrorResponseException(string.Format(ProjectResources.ServicePrincipalRoleAssignmentCreationFailed, e.Body.Error.Message), e);
                    }
                    catch (Exception)
                    {
                        // if the error is something else fail silently as before
                    }
                }
            }
        }
Example #17
0
 private void TextChangedEvent()
 {
     if ((SectionName == EmptyField || SectionName.Trim().ToString() == string.Empty) || (DisplayName == EmptyField || DisplayName.Trim().ToString() == string.Empty) || (StatisticsName == EmptyField || StatisticsName.Trim().ToString() == string.Empty) ||
         (TooltipValue == EmptyField || TooltipValue.Trim().ToString() == string.Empty) || (Threshold1 == EmptyField || Threshold1.Trim().ToString() == string.Empty) || (Threshold2 == EmptyField || Threshold2.Trim().ToString() == string.Empty) || (Threshold1 == DecimalFormat || Threshold1.Trim().ToString() == string.Empty) ||
         (Threshold2 == DecimalFormat || Threshold2.Trim().ToString() == string.Empty) || (Threshold1 == TimeFormat || Threshold1.Trim().ToString() == string.Empty) || (Threshold2 == TimeFormat || Threshold2.Trim().ToString() == string.Empty) ||
         (Threshold1 == ThresholdMessage1 || Threshold1.Trim().ToString() == string.Empty) || (Threshold2 == ThresholdMessage2 || Threshold2.Trim().ToString() == string.Empty))
     {
         IsSavebtnEnable = false;
     }
     else
     {
         IsSavebtnEnable = true;
     }
     Settings.GetInstance().TValue1 = Threshold1;
     Settings.GetInstance().TValue2 = Threshold2;
 }
Example #18
0
 public bool Validate()
 {
     DisplayName = DisplayName.Trim();
     return(!string.IsNullOrEmpty(DisplayName));
 }
Example #19
0
        public CustomerViewModel()
        {
            List = new ObservableCollection <Customer>(DataProvider.Ins.DB.Customers);
            #region Add
            AddCommand = new RelayCommand <object>((p) =>
            {
                if (string.IsNullOrWhiteSpace(DisplayName))
                {
                    return(false);
                }
                var displayList = DataProvider.Ins.DB.Customers.Where(x => x.DisplayName == DisplayName);
                if (displayList == null || displayList.Count() != 0)
                {
                    return(false);
                }
                return(true);
            }, (p) =>
            {
                var Customer = new Customer()
                {
                    DisplayName = DisplayName.Trim(), Phone = Phone, MoreInfo = MoreInfo
                };
                DataProvider.Ins.DB.Customers.Add(Customer);
                DataProvider.Ins.DB.SaveChanges();
                List.Add(Customer);
                Reset();
            });
            #endregion

            #region Edit
            EditCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedItem == null || string.IsNullOrWhiteSpace(DisplayName))
                {
                    return(false);
                }

                var CustomerList = DataProvider.Ins.DB.Customers.Where(x => x.Id == SelectedItem.Id);
                if (CustomerList != null && CustomerList.Count() != 0)
                {
                    return(true);
                }
                return(false);
            }, (p) =>
            {
                var Customer         = DataProvider.Ins.DB.Customers.Where(x => x.Id == SelectedItem.Id).SingleOrDefault();
                Customer.DisplayName = DisplayName.Trim();
                Customer.Phone       = Phone;
                Customer.MoreInfo    = MoreInfo;
                DataProvider.Ins.DB.SaveChanges();
                Reset();
            });
            #endregion

            #region Sort
            SortIdCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            SortDisplaynameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Displayname", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Displayname", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            SortPhoneCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Phone", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Phone", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            SortMoreInfoCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("MoreInfo", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("MoreInfo", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            #endregion
        }
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                //safe gauard for login status, check if DefaultContext not existed, PSInvalidOperationException will be thrown
                var CheckDefaultContext = DefaultContext;

                if (this.ParameterSetName == SimpleParameterSet)
                {
                    CreateSimpleServicePrincipal();
                    return;
                }

                if (!this.IsParameterBound(c => c.EndDate))
                {
                    WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed);
                    EndDate = StartDate.AddYears(1);
                }

                if (this.IsParameterBound(c => c.ApplicationObject))
                {
                    ApplicationId = ApplicationObject.ApplicationId;
                    DisplayName   = ApplicationObject.DisplayName;
                }

                if (ApplicationId == Guid.Empty)
                {
                    string uri = "http://" + DisplayName.Trim().Replace(' ', '_');

                    // Create an application and get the applicationId
                    CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters
                    {
                        DisplayName    = DisplayName,
                        IdentifierUris = new[] { uri },
                        HomePage       = uri
                    };

                    if (this.IsParameterBound(c => c.PasswordCredential))
                    {
                        appParameters.PasswordCredentials = PasswordCredential;
                    }
                    else if (this.IsParameterBound(c => c.CertValue))
                    {
                        appParameters.KeyCredentials = new PSADKeyCredential[]
                        {
                            new PSADKeyCredential
                            {
                                StartDate = StartDate,
                                EndDate   = EndDate,
                                KeyId     = Guid.NewGuid(),
                                CertValue = CertValue
                            }
                        };
                    }
                    else if (this.IsParameterBound(c => c.KeyCredential))
                    {
                        appParameters.KeyCredentials = KeyCredential;
                    }

                    if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName)))
                    {
                        var application = ActiveDirectoryClient.CreateApplication(appParameters);
                        ApplicationId   = application.ApplicationId;
                    }
                }

                CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters
                {
                    ApplicationId  = ApplicationId,
                    AccountEnabled = true
                };

                if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: string.Format("Adding a new service principal to be associated with an application having AppId '{0}'", createParameters.ApplicationId)))
                {
                    var servicePrincipal = ActiveDirectoryClient.CreateServicePrincipal(createParameters);
                    WriteObject(servicePrincipal);
                }
            });
        }
Example #21
0
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                if (this.ParameterSetName == SimpleParameterSet)
                {
                    CreateSimpleServicePrincipal();
                    return;
                }

                if (this.IsParameterBound(c => c.ApplicationObject))
                {
                    ApplicationId = ApplicationObject.ApplicationId;
                    DisplayName   = ApplicationObject.DisplayName;
                }

                if (ApplicationId == Guid.Empty)
                {
                    string uri = "http://" + DisplayName.Trim().Replace(' ', '_');

                    // Create an application and get the applicationId
                    CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters
                    {
                        DisplayName    = DisplayName,
                        IdentifierUris = new[] { uri },
                        HomePage       = uri
                    };

                    if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName)))
                    {
                        var application = ActiveDirectoryClient.CreateApplication(appParameters);
                        ApplicationId   = application.ApplicationId;
                    }
                }

                CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters
                {
                    ApplicationId  = ApplicationId,
                    AccountEnabled = true
                };

                if (this.IsParameterBound(c => c.Password))
                {
                    string decodedPassword = SecureStringExtensions.ConvertToString(Password);
                    createParameters.PasswordCredentials = new PSADPasswordCredential[]
                    {
                        new PSADPasswordCredential
                        {
                            StartDate = StartDate,
                            EndDate   = EndDate,
                            KeyId     = Guid.NewGuid(),
                            Password  = decodedPassword
                        }
                    };
                }
                else if (this.IsParameterBound(c => c.PasswordCredential))
                {
                    createParameters.PasswordCredentials = PasswordCredential;
                }
                else if (this.IsParameterBound(c => c.CertValue))
                {
                    createParameters.KeyCredentials = new PSADKeyCredential[]
                    {
                        new PSADKeyCredential
                        {
                            StartDate = StartDate,
                            EndDate   = EndDate,
                            KeyId     = Guid.NewGuid(),
                            CertValue = CertValue
                        }
                    };
                }
                else if (this.IsParameterBound(c => c.KeyCredential))
                {
                    createParameters.KeyCredentials = KeyCredential;
                }

                if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: string.Format("Adding a new service principal to be associated with an application having AppId '{0}'", createParameters.ApplicationId)))
                {
                    var servicePrincipal = ActiveDirectoryClient.CreateServicePrincipal(createParameters);
                    WriteObject(servicePrincipal);
                }
            });
        }
        public ObjectViewModel()
        {
            List    = new ObservableCollection <Model.Object>(DataProvider.Ins.DB.Objects);
            Unit    = new ObservableCollection <Unit>(DataProvider.Ins.DB.Units);
            Suplier = new ObservableCollection <Suplier>(DataProvider.Ins.DB.Supliers);
            taikhoan tk       = new taikhoan();
            var      userinfo = DataProvider.Ins.DB.Users.Where(x => x.UserName == tk.UserName && x.IdRole == 1);

            #region Add
            AddCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedSuplier == null || SelectedUnit == null || string.IsNullOrWhiteSpace(DisplayName) || Price == null)
                {
                    return(false);
                }
                var displayList = DataProvider.Ins.DB.Objects.Where(x => x.DisplayName == DisplayName);
                if (displayList == null || displayList.Count() != 0)
                {
                    return(false);
                }
                return(true);
            }, (p) =>
            {
                if (Price <= 0)
                {
                    MessageBox.Show("Đơn giá không hợp lệ vui lòng nhập lại!");
                }
                else
                {
                    var Object = new Model.Object()
                    {
                        DisplayName = DisplayName.Trim(), Price = Price, BarCode = BarCode, QRCode = QRCode, IdSuplier = SelectedSuplier.Id, IdUnit = SelectedUnit.Id, Id = Guid.NewGuid().ToString()
                    };

                    DataProvider.Ins.DB.Objects.Add(Object);
                    DataProvider.Ins.DB.SaveChanges();
                    List.Add(Object);
                    Reset();
                }
            });
            #endregion
            #region Delete
            DeleteCommand = new RelayCommand <Window>((p) =>
            {
                if (SelectedItem == null || userinfo.Count() == 0)
                {
                    return(false);
                }
                return(true);
            }, (p) =>
            {
                if (MessageBox.Show("Bạn có thật sự muốn xóa?", "Thông báo", MessageBoxButton.OKCancel, MessageBoxImage.Warning) != MessageBoxResult.OK)
                {
                    return;
                }
                else
                {
                    //string idobject = SelectedItem.Id;
                    var inputinfos  = DataProvider.Ins.DB.InputInfoes.Where(x => x.IdObject == SelectedItem.Id); //lấy danh sách đơn nhập có sản phẩm đó
                    var outputinfos = DataProvider.Ins.DB.OutputInfoes.Where(x => x.IdObject == SelectedItem.Id);
                    foreach (var i in inputinfos)
                    {
                        string idinput = i.IdInput;
                        var inputinfo  = DataProvider.Ins.DB.InputInfoes.Where(x => x.IdInput == i.IdInput); //lấy ra danh sách phiếu nhập
                        if (inputinfo.Count() == 1)
                        {
                            var delinputinfo = DataProvider.Ins.DB.InputInfoes.Where(x => x.Id == i.Id).SingleOrDefault();
                            var delinput     = DataProvider.Ins.DB.Inputs.Where(x => x.Id == idinput).SingleOrDefault();
                            DataProvider.Ins.DB.InputInfoes.Remove(delinputinfo);
                            DataProvider.Ins.DB.Inputs.Remove(delinput);
                        }
                        else
                        {
                            var delinputinfo = DataProvider.Ins.DB.InputInfoes.Where(x => x.Id == i.Id).SingleOrDefault();
                            DataProvider.Ins.DB.InputInfoes.Remove(delinputinfo);
                        }
                    }
                    foreach (var o in outputinfos)
                    {
                        string idoutput = o.IdOutput;
                        var outputinfo  = DataProvider.Ins.DB.OutputInfoes.Where(x => x.IdOutput == o.IdOutput); //lấy ra danh sách phiếu nhập
                        if (outputinfo.Count() == 1)
                        {
                            var deloutputinfo = DataProvider.Ins.DB.OutputInfoes.Where(x => x.Id == o.Id).SingleOrDefault();
                            var deloutput     = DataProvider.Ins.DB.Outputs.Where(x => x.Id == idoutput).SingleOrDefault();
                            DataProvider.Ins.DB.OutputInfoes.Remove(deloutputinfo);
                            DataProvider.Ins.DB.Outputs.Remove(deloutput);
                        }
                        else
                        {
                            var deloutputinfo = DataProvider.Ins.DB.OutputInfoes.Where(x => x.Id == o.Id).SingleOrDefault();
                            DataProvider.Ins.DB.OutputInfoes.Remove(deloutputinfo);
                        }
                    }
                    var delobject = DataProvider.Ins.DB.Objects.Where(x => x.Id == SelectedItem.Id).SingleOrDefault();
                    DataProvider.Ins.DB.Objects.Remove(delobject);
                    DataProvider.Ins.DB.SaveChanges();
                    List.Remove(delobject);
                    Reset();
                    MessageBox.Show("Bạn đã xóa thành công");
                }
            });
            #endregion
            #region Edit
            EditCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedItem == null || SelectedSuplier == null || SelectedUnit == null || string.IsNullOrWhiteSpace(DisplayName) || Price == null)
                {
                    return(false);
                }
                var displayList = DataProvider.Ins.DB.Objects.Where(x => x.Id == SelectedItem.Id);
                if (displayList.Count() != 0)
                {
                    return(true);
                }
                return(false);
            }, (p) =>
            {
                if (Price <= 0)
                {
                    MessageBox.Show("Đơn giá không hợp lệ vui lòng nhập lại!");
                }
                else
                {
                    var Object         = DataProvider.Ins.DB.Objects.Where(x => x.Id == SelectedItem.Id).SingleOrDefault();
                    Object.DisplayName = DisplayName.Trim();
                    Object.BarCode     = BarCode;
                    Object.QRCode      = QRCode;
                    Object.Price       = Price;
                    Object.IdSuplier   = SelectedSuplier.Id;
                    Object.IdUnit      = SelectedUnit.Id;
                    DataProvider.Ins.DB.SaveChanges();
                    Reset();
                }
            });
            #endregion
            #region Sort
            SortIdCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            SortDisplayNameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            SortUnitDisplayNameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Unit.DisplayName", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Unit.DisplayName", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            SortSuplierDisplayNameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Suplier.DisplayName", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Suplier.DisplayName", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            SortPriceCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
                if (IsSort)
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Price", ListSortDirection.Ascending));
                }
                else
                {
                    //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
                    view.SortDescriptions.Clear();
                    view.SortDescriptions.Add(new SortDescription("Price", ListSortDirection.Descending));
                }
                IsSort = !IsSort;
            });
            #endregion
        }
Example #23
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
        {
            if (!_clsLoginModel.PermissionsFunc(_currentMenuId, (int)PermissionsEnum.添加))
            {
                _metroWindow.ShowMessageAsync("友情提示", "您没有添加菜单信息的权限");
                return;
            }
            if (!Verify())
            {
                return;
            }
            if (!JudgeDisplayNameNotRootName(_metroWindow, DisplayName))
            {
                return;
            }

            Action addAction = () =>
            {
                var requestModel = new LeftMenusAddRequestModel
                {
                    DisplayName   = DisplayName,
                    DllPath       = DllPath,
                    EntryFunction = EntryFunction,
                    MenuId        = MenuId,
                    NavBarGroupId = NavBarGroupId,
                    ParentId      = ParentId,
                    Sort          = int.MaxValue,
                    StartWithSys  = StartWithSysYes,
                    Timestamp     = _leftMenusManage.ServerTime.ToUnixTimestamp()
                };
                var result = _leftMenusManage.Add(requestModel);
                if (result.ResultStatus == ResultStatus.Success)
                {
                    ClearMenuData();
                    AddTreeViewItem(result.Data);
                    _leftMenu.LeftMenusList = _leftMenusManage.GetAll().ToList();
                }
                _metroWindow.ShowMessageAsync(result.ResultStatus == ResultStatus.Success ? "添加成功提示" : "添加失败提示", result.Message);
            };


            var setting = new MetroDialogSettings
            {
                AnimateShow           = true,
                AnimateHide           = true,
                AffirmativeButtonText = "是",
                NegativeButtonText    = "否",
                DefaultButtonFocus    = MessageDialogResult.Negative
            };

            if (_leftMenusManage.Exist(a => a.DisplayName == DisplayName.Trim()))
            {
                _metroWindow.ShowMessageAsync("信息重复提示", $"菜单名称“{DisplayName}”,在系统中已存在,是否仍使用该名称?", MessageDialogStyle.AffirmativeAndNegative, setting).ContinueWith(
                    t =>
                {
                    _metroWindow.Dispatcher.Invoke((Action)(() =>
                    {
                        if (t.Result == MessageDialogResult.Affirmative)
                        {
                            addAction();
                        }
                    }));
                });
            }
            else
            {
                addAction();
            }
        }
Example #24
0
            internal void SetPadding(int totalSize)
            {
                var padding = totalSize - GetDisplaySize();

                DisplayName = DisplayName.Trim() + new string(' ', padding);
            }