public formAccountCreator(AccountCatalog catalog) : base( ) { this.currentCatalog = catalog; this.buttonOK.Visible = true; this.CancelButton = this.buttonCancel; }
public bool Delete(AccountCatalog catalog) { var tmpCatalogEntity = AccountCatalogConvertor.Convert(catalog); bool tmpExecuteResult = this.catalogDataAccess.Delete(tmpCatalogEntity); return(tmpExecuteResult); }
private bool DeleteCatalog(AccountCatalog catalogItem) { if (catalogItem != null) { var tmpMessageBoxTitle = SafePassResource.DeletePermanentlySelectedCatalogTitle; var tmpCatalogService = new HuiruiSoft.Safe.Service.CatalogService(); if (tmpCatalogService.GetChildCatalogCount(catalogItem.CatalogId) > 0) { MessageBox.Show(string.Format(SafePassResource.DeleteSelectedCatalogErrorForNotEmpty, catalogItem.Name), tmpMessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } var tmpAccountService = new HuiruiSoft.Safe.Service.AccountService(); if (tmpAccountService.GetBelongAccountCount(catalogItem.CatalogId) > 0) { MessageBox.Show(string.Format(SafePassResource.DeleteSelectedCatalogErrorForNotEmpty, catalogItem.Name), tmpMessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { var tmpMessageBoxPrompt = SafePassResource.DeletePermanentlySelectedCatalogQuestion; if (MessageBox.Show(string.Format(tmpMessageBoxPrompt, catalogItem.Name), tmpMessageBoxTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK) { return(tmpCatalogService.Delete(catalogItem)); } } } return(false); }
private static XmlElement BuildCatalogElement(XmlElement parentNode, AccountCatalog catalog) { XmlElement tmpCatalogNode = null; if (catalog != null && parentNode != null) { tmpCatalogNode = parentNode.OwnerDocument.CreateElement(ElementCatalog); tmpCatalogNode.SetAttribute("id", string.Format("{0}", catalog.CatalogId)); tmpCatalogNode.SetAttribute("ParentId", string.Format("{0}", catalog.ParentId)); tmpCatalogNode.SetAttribute("Name", catalog.Name); tmpCatalogNode.SetAttribute("Depth", string.Format("{0}", catalog.Depth)); tmpCatalogNode.SetAttribute("Order", string.Format("{0}", catalog.Order)); tmpCatalogNode.SetAttribute("Version", string.Format("{0}", catalog.VersionNo)); tmpCatalogNode.SetAttribute("CreateTime", catalog.CreateTime.ToString(ApplicationDefines.DateTimeFormat)); tmpCatalogNode.SetAttribute("UpdateTime", catalog.UpdateTime.ToString(ApplicationDefines.DateTimeFormat)); if (!string.IsNullOrEmpty(catalog.Description)) { var tmpCommentNode = tmpCatalogNode.OwnerDocument.CreateElement("Comment"); tmpCommentNode.InnerText = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(catalog.Description)); tmpCatalogNode.AppendChild(tmpCommentNode); } parentNode.AppendChild(tmpCatalogNode); } return(tmpCatalogNode); }
private bool InitializeDataBase(string dataDirectory, string userName, string password) { bool tmpCreateResult = false; var tmpSQLiteDataBase = new HuiruiSoft.Data.SQLite.GeneralSQLiteDataBase(); tmpSQLiteDataBase.DataSource = string.Format(@"{0}\SafePassData.dat", dataDirectory); tmpSQLiteDataBase.Password = Md5DigestHelper.Md5Salt(password, userName); tmpSQLiteDataBase.CreateDataBase(); var tmpResourceStream = ResourceStreamHelper.GetStream("resources.database.SafePass.sql", typeof(ResourceFinder)); if (tmpResourceStream != null) { byte[] bytes = new byte[tmpResourceStream.Length]; tmpResourceStream.Read(bytes, 0, bytes.Length); string tmpCommandString = System.Text.Encoding.UTF8.GetString(bytes); tmpSQLiteDataBase.ExecuteNonQuery(tmpCommandString); var tmpRootCatalog = new AccountCatalog(); tmpRootCatalog.Depth = 1; tmpRootCatalog.ParentId = -1; tmpRootCatalog.Name = this.textSafePassName.Text; tmpCreateResult = tmpSQLiteDataBase.CreateRootCatalog(tmpRootCatalog); if (tmpCreateResult) { // } } return(tmpCreateResult); }
public static List <AccountCatalog> ReadAccountCatalogs(string fileName) { List <AccountCatalog> tmpAccountCatalogs = null; var tmpImportDocument = new XmlDocument(); tmpImportDocument.Load(fileName); var tmpAccountNodes = tmpImportDocument.SelectNodes("Account//Catalog"); if (tmpAccountNodes != null) { tmpAccountCatalogs = new List <AccountCatalog>(); foreach (XmlElement tmpCatalogNode in tmpAccountNodes) { var tmpCatalogInfo = new AccountCatalog(); tmpCatalogInfo.CatalogId = XmlDocumentHelper.GetAttributeValue(tmpCatalogNode, "id", 0); tmpCatalogInfo.ParentId = XmlDocumentHelper.GetAttributeValue(tmpCatalogNode, "ParentId", -1); tmpCatalogInfo.Name = XmlDocumentHelper.GetAttributeString(tmpCatalogNode, "Name"); tmpCatalogInfo.Order = XmlDocumentHelper.GetAttributeValue(tmpCatalogNode, "Order", 0); tmpCatalogInfo.Depth = XmlDocumentHelper.GetAttributeValue(tmpCatalogNode, "Depth", 1); tmpCatalogInfo.VersionNo = XmlDocumentHelper.GetAttributeValue(tmpCatalogNode, "Version", 1); tmpCatalogInfo.CreateTime = XmlDocumentHelper.GetAttributeValue(tmpCatalogNode, "CreateTime"); tmpCatalogInfo.UpdateTime = XmlDocumentHelper.GetAttributeValue(tmpCatalogNode, "UpdateTime"); tmpAccountCatalogs.Add(tmpCatalogInfo); } } return(tmpAccountCatalogs); }
protected override void buttonOK_Click(object sender, System.EventArgs args) { if (base.CheckInputValidity()) { var tmpInputErrorCaption = SafePassResource.MessageBoxCaptionInputError; string tmpCatalogName = this.textCatalogName.Text; bool tmpCheckupResult = true; if (this.parentCatalogItem == null) { //检查在此目录下是否已经存在一个相同名称的目录 } else { //检查在此目录下是否已经存在一个相同名称的目录 } if (!tmpCheckupResult) { MessageBox.Show(string.Format(SafePassResource.CatalogEditorPromptCatalogNameRepeat, tmpCatalogName), tmpInputErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.textCatalogName.Focus(); return; } else { this.createCatalogItem = new AccountCatalog(); this.createCatalogItem.Name = tmpCatalogName; string tmpDescription = this.textDescription.Text.Trim(); if (!string.IsNullOrEmpty(tmpDescription)) { this.createCatalogItem.Description = tmpDescription; } if (this.parentCatalogItem == null) { this.createCatalogItem.Depth = 1; this.createCatalogItem.ParentId = -1; } else { this.createCatalogItem.Depth = this.parentCatalogItem.Depth + 1; this.createCatalogItem.ParentId = this.parentCatalogItem.CatalogId; } var tmpCatalogService = new HuiruiSoft.Safe.Service.CatalogService(); if (tmpCatalogService.New(this.createCatalogItem)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { this.createCatalogItem = null; } } } }
private void OpenCatalogViewer(AccountCatalog catalogItem) { if (catalogItem != null) { var tmpCatalogViewer = new formCatalogViewer(catalogItem); tmpCatalogViewer.ShowDialog( ); tmpCatalogViewer.Dispose( ); } }
public bool Update(AccountCatalog catalog) { var tmpCatalogEntity = AccountCatalogConvertor.Convert(catalog); tmpCatalogEntity.UpdateTime = System.DateTime.Now; bool tmpUpdateResult = this.catalogDataAccess.Update(tmpCatalogEntity); return(tmpUpdateResult); }
public IList <AccountModel> GetAccountInfos(AccountCatalog catalog) { IList <AccountModel> tmpAccountModels = null; if (catalog != null) { tmpAccountModels = this.GetAccountInfos(catalog.CatalogId); } return(tmpAccountModels); }
public bool CreateRootCatalog(AccountCatalog catalog) { if (catalog == null) { throw new System.ArgumentNullException("参数 catalog 不能为空。"); } bool tmpExecuteResult = false; using (var tmpDataConnection = ((IDataBase)this).CreateConnection(this.ConnectionString)) { var tmpInsertCommand = ((IDataBase)this).CreateCommand(); tmpInsertCommand.Connection = tmpDataConnection; tmpInsertCommand.CommandType = System.Data.CommandType.Text; tmpInsertCommand.CommandText = "INSERT INTO safe_account_catalog(Name, ParentId, Depth, OrderNo, VersionNo, CreateTime, UpdateTime, Description) VALUES (@Name, @ParentId, @Depth, @OrderNo, 1, DATETIME('NOW','LOCALTIME'), DATETIME('NOW','LOCALTIME'), @Description); SELECT LAST_INSERT_ROWID() AS CatalogId"; tmpInsertCommand.Parameters.Add(new SQLiteParameter("@Name", System.Data.DbType.String, 30)); tmpInsertCommand.Parameters.Add(new SQLiteParameter("@ParentId", System.Data.DbType.Int32)); tmpInsertCommand.Parameters.Add(new SQLiteParameter("@OrderNo", System.Data.DbType.Int32)); tmpInsertCommand.Parameters.Add(new SQLiteParameter("@Depth", System.Data.DbType.Int32)); tmpInsertCommand.Parameters.Add(new SQLiteParameter("@Description", System.Data.DbType.String, 255)); try { tmpDataConnection.Open(); tmpInsertCommand.Parameters["@Name"].Value = catalog.Name; tmpInsertCommand.Parameters["@ParentId"].Value = catalog.ParentId; tmpInsertCommand.Parameters["@OrderNo"].Value = catalog.Order; tmpInsertCommand.Parameters["@Depth"].Value = catalog.Depth; tmpInsertCommand.Parameters["@Description"].Value = catalog.Description; int tmpRowsAffected = tmpInsertCommand.ExecuteNonQuery(); tmpExecuteResult = tmpRowsAffected > 0; } catch (System.SystemException exception) { loger.Error(exception); throw exception; } finally { if (tmpDataConnection.State == System.Data.ConnectionState.Open) { tmpDataConnection.Close(); } tmpDataConnection.Dispose(); } } return(tmpExecuteResult); }
public AccountCatalog GetAccountCatalog(int catalogId) { AccountCatalog tmpCatalogInfo = null; var tmpCatalogEntity = this.catalogDataAccess.GetCatalogEntity(catalogId); if (tmpCatalogEntity != null) { tmpCatalogInfo = AccountCatalogConvertor.Convert(tmpCatalogEntity); } return(tmpCatalogInfo); }
public bool New(AccountCatalog catalog) { var tmpCatalogEntity = AccountCatalogConvertor.Convert(catalog); tmpCatalogEntity.UpdateTime = tmpCatalogEntity.CreateTime = System.DateTime.Now; var tmpCreateResult = this.catalogDataAccess.Create(tmpCatalogEntity); if (tmpCreateResult) { catalog.CatalogId = tmpCatalogEntity.CatalogId; } return(tmpCreateResult); }
private void CreateCatalogTreeNodes(System.Data.DataTable catalogTable, TreeNode parentTreeNode, int parentId) { if (catalogTable != null) { catalogTable.DefaultView.RowFilter = string.Format("ParentId = {0}", parentId); for (int i = 0; i < catalogTable.DefaultView.Count; i++) { var tmpCatalogItem = new AccountCatalog(); tmpCatalogItem.CatalogId = int.Parse(string.Format("{0}", catalogTable.DefaultView[i]["CatalogId"])); tmpCatalogItem.ParentId = int.Parse(string.Format("{0}", catalogTable.DefaultView[i]["ParentId"])); tmpCatalogItem.Name = string.Format("{0}", catalogTable.DefaultView[i]["Name"]); tmpCatalogItem.Depth = int.Parse(string.Format("{0}", catalogTable.DefaultView[i]["Depth"])); tmpCatalogItem.Order = int.Parse(string.Format("{0}", catalogTable.DefaultView[i]["OrderNo"])); tmpCatalogItem.VersionNo = int.Parse(string.Format("{0}", catalogTable.DefaultView[i]["VersionNo"])); tmpCatalogItem.CreateTime = (System.DateTime)catalogTable.DefaultView[i]["CreateTime"]; tmpCatalogItem.UpdateTime = (System.DateTime)catalogTable.DefaultView[i]["UpdateTime"]; tmpCatalogItem.Description = string.Format("{0}", catalogTable.DefaultView[i]["Description"]); var tmpCatalogNode = new TreeNode(); tmpCatalogNode.Text = tmpCatalogItem.Name; tmpCatalogNode.Tag = tmpCatalogItem; tmpCatalogNode.ImageIndex = 0; tmpCatalogNode.SelectedImageIndex = 1; if (parentTreeNode != null) { parentTreeNode.Nodes.Add(tmpCatalogNode); } else { this.treeViewCatalog.Nodes.Add(tmpCatalogNode); } } if (parentTreeNode == null) { foreach (TreeNode tmpCatalogNode in this.treeViewCatalog.Nodes) { this.CreateCatalogTreeNodes(catalogTable, tmpCatalogNode, ((AccountCatalog)(tmpCatalogNode.Tag)).CatalogId); } } else { foreach (TreeNode tmpCatalogNode in parentTreeNode.Nodes) { this.CreateCatalogTreeNodes(catalogTable, tmpCatalogNode, ((AccountCatalog)(tmpCatalogNode.Tag)).CatalogId); } } } }
public LoginPageVm() { UserSingleton = LoggedUserSingleton.Instance; NavigationControl = MainFrameSingleton.Instance; AccountCatalog = new AccountCatalog(); RawPassword = string.Empty; RawUsername = string.Empty; StatusMessages = string.Empty; LoginCommand = new DelegateCommand(LoginCommandM); LogOut = new DelegateCommand(LogOutM); LoginMenuFlyout = "Visible"; AccountFlyout = "Collapsed"; AccountButtonContent = "Login"; }
public formCatalogViewer(AccountCatalog currentCatalog) : base() { this.currentCatalogItem = currentCatalog; if (this.currentCatalogItem != null) { this.textCatalogName.Text = this.currentCatalogItem.Name; this.textDescription.Text = this.currentCatalogItem.Description; } this.textCatalogName.ReadOnly = true; this.textDescription.ReadOnly = true; this.buttonOK.Visible = false; this.CancelButton = this.buttonCancel; this.AcceptButton = this.buttonCancel; }
private DialogResult OpenCatalogCreator( ) { var tmpSelectTreeNode = this.treeViewCatalog.SelectedNode; AccountCatalog tmpParentCatalog = null; if (tmpSelectTreeNode != null && (tmpSelectTreeNode.Tag is AccountCatalog)) { tmpParentCatalog = (AccountCatalog)(tmpSelectTreeNode.Tag); } var tmpCatalogCreator = new formCatalogCreator(tmpParentCatalog); var tmpDialogResult = tmpCatalogCreator.ShowDialog( ); if (tmpDialogResult == DialogResult.OK) { if (tmpCatalogCreator.NewCatalog != null) { var tmpNewCatalog = (AccountCatalog)tmpCatalogCreator.NewCatalog.Clone( ); var tmpNewCatalogTreeNode = new TreeNode( ); tmpNewCatalogTreeNode.Text = tmpNewCatalog.Name; tmpNewCatalogTreeNode.ImageIndex = tmpNewCatalogTreeNode.SelectedImageIndex = 0; tmpNewCatalogTreeNode.Tag = tmpNewCatalog; if (tmpSelectTreeNode == null) { this.treeViewCatalog.Nodes.Add(tmpNewCatalogTreeNode); } else { tmpSelectTreeNode.Nodes.Add(tmpNewCatalogTreeNode); tmpSelectTreeNode.ExpandAll( ); } } } tmpCatalogCreator.Dispose( ); return(tmpDialogResult); }
public static AccountCatalog Convert(AccountCatalogEntity entity) { AccountCatalog tmpCatalogModel = null; if (entity != null) { tmpCatalogModel = new AccountCatalog(); tmpCatalogModel.CatalogId = entity.CatalogId; tmpCatalogModel.Name = entity.Name; tmpCatalogModel.Depth = entity.Depth; tmpCatalogModel.Order = entity.Order; tmpCatalogModel.ParentId = entity.ParentId; tmpCatalogModel.VersionNo = entity.VersionNo; tmpCatalogModel.CreateTime = entity.CreateTime; tmpCatalogModel.UpdateTime = entity.UpdateTime; tmpCatalogModel.Description = entity.Description; } return(tmpCatalogModel); }
public static AccountCatalogEntity Convert(AccountCatalog catalog) { AccountCatalogEntity tmpCatalogEntity = null; if (catalog != null) { tmpCatalogEntity = new AccountCatalogEntity(); tmpCatalogEntity.CatalogId = catalog.CatalogId; tmpCatalogEntity.Name = catalog.Name; tmpCatalogEntity.Depth = catalog.Depth; tmpCatalogEntity.Order = catalog.Order; tmpCatalogEntity.ParentId = catalog.ParentId; tmpCatalogEntity.VersionNo = catalog.VersionNo; tmpCatalogEntity.CreateTime = catalog.CreateTime; tmpCatalogEntity.UpdateTime = catalog.UpdateTime; tmpCatalogEntity.Description = catalog.Description; } return(tmpCatalogEntity); }
private void GetCatalogChildAccounts(AccountCatalog catalog) { this.accountDataTable.BeginLoadData( ); this.accountDataTable.Rows.Clear( ); if (catalog != null) { Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; var tmpAccountModels = this.allAccountEntries.FindAll(delegate(AccountModel item) { return(item.CatalogId == catalog.CatalogId); }); if (tmpAccountModels != null) { this.FillAccountDataGrid(tmpAccountModels); } Cursor.Current = System.Windows.Forms.Cursors.Default; } this.accountDataTable.EndLoadData( ); }
public formCatalogCreator(AccountCatalog parentCatalog) : base() { this.parentCatalogItem = parentCatalog; }
public formCatalogEditor(AccountCatalog currentCatalog) : base() { this.currentCatalogItem = currentCatalog; this.textCatalogName.Text = this.currentCatalogItem.Name; this.textDescription.Text = this.currentCatalogItem.Description; }