Ejemplo n.º 1
0
        protected virtual void AccountPtr_AccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            AccountAttribute.VerifyAccountIsNotControl <AccountPtr.accountID>(sender, e);

            AccountPtr row = e.Row as AccountPtr;

            if (row != null)
            {
                Account account = PXSelect <Account> .Search <Account.accountID>(this, e.NewValue);

                if (account != null && account.IsCashAccount == true)
                {
                    sender.RaiseExceptionHandling <AccountPtr.accountID>(row, e.NewValue,
                                                                         new PXSetPropertyException(GL.Messages.CashAccountIsNotForProjectPurposes, PXErrorLevel.Warning, account.AccountCD));
                }

                if (account != null && AccountGroup.Current != null && account.AccountGroupID != null && account.AccountGroupID != AccountGroup.Current.GroupID)
                {
                    PMAccountGroup ag = PXSelect <PMAccountGroup, Where <PMAccountGroup.groupID, Equal <Required <PMAccountGroup.groupID> > > > .Select(this, account.AccountGroupID);

                    sender.RaiseExceptionHandling <AccountPtr.accountID>(row, e.NewValue,
                                                                         new PXSetPropertyException(Warnings.AccountIsUsed, PXErrorLevel.Warning, ag.GroupCD));
                }
            }
        }
        public static AccountAttribute ConvertAttribute(string encryptKey, AccountAttributeEntity entity)
        {
            AccountAttribute tmpAttribute = null;

            if (entity != null)
            {
                tmpAttribute             = new AccountAttribute();
                tmpAttribute.AttributeId = entity.AttributeId;
                tmpAttribute.Order       = entity.Order;
                tmpAttribute.Name        = entity.Name;
                tmpAttribute.AccountId   = entity.AccountId;
                tmpAttribute.Encrypted   = entity.Encrypted;

                if (!tmpAttribute.Encrypted)
                {
                    tmpAttribute.Value = entity.Value;
                }
                else
                {
                    tmpAttribute.Value = EncryptorHelper.DESDecrypt(encryptKey, entity.Value);
                }
            }

            return(tmpAttribute);
        }
Ejemplo n.º 3
0
        public AccountAttribute Update(AccountAttribute attribute)
        {
            IRestRequest  request  = TDClient.BuildRequest(Method.PUT, ITEM, new { accountId = attribute.AccountId, nameOrId = attribute.Id }, attribute.Value);
            IRestResponse response = TDClient.InnerExecute(request);

            return(TDClient.ProcessOperationResponse <AccountAttribute>(request, response, "update"));
        }
        public static AccountAttributeEntity ConvertAttribute(string encryptKey, AccountAttribute attribute)
        {
            AccountAttributeEntity tmpAttributeEntity = null;

            if (attribute != null)
            {
                tmpAttributeEntity             = new AccountAttributeEntity();
                tmpAttributeEntity.AttributeId = attribute.AttributeId;
                tmpAttributeEntity.Order       = attribute.Order;
                tmpAttributeEntity.Name        = attribute.Name;
                tmpAttributeEntity.AccountId   = attribute.AccountId;
                tmpAttributeEntity.Encrypted   = attribute.Encrypted;

                if (!tmpAttributeEntity.Encrypted)
                {
                    tmpAttributeEntity.Value = attribute.Value;
                }
                else
                {
                    tmpAttributeEntity.Value = EncryptorHelper.DESEncrypt(encryptKey, attribute.Value);
                }
            }

            return(tmpAttributeEntity);
        }
Ejemplo n.º 5
0
 public PatchsetAttribute(dynamic json)
 {
     number = GerritStream.GetValue(json, "number");
     revision = GerritStream.GetValue(json, "revision");
     reference = GerritStream.GetValue(json, "ref");
     uploader = new AccountAttribute(GerritStream.GetValue(json, "uploader"));
     approvals = new ApprovalsAttribute(GerritStream.GetValue(json, "approvals"));
 }
Ejemplo n.º 6
0
 public ApprovalAttribute(dynamic json)
 {
     type = GerritStream.GetValue(json, "type");
     description = GerritStream.GetValue(json, "description");
     value = int.Parse(GerritStream.GetValue(json, "value"));
     grantedOn = GerritStream.GetValue(json, "grantedOn");
     by = new AccountAttribute(GerritStream.GetValue(json, "by"));
 }
Ejemplo n.º 7
0
        public AccountAttribute Create(int accountId, AccountAttribute attribute)
        {
            var nameOrId = attribute.Id > 0 ? attribute.Id.ToString() : attribute.Name;

            IRestRequest  request  = TDClient.BuildRequest(Method.POST, ITEM, new { accountId, nameOrId }, attribute.Value);
            IRestResponse response = TDClient.InnerExecute(request);

            return(TDClient.ProcessOperationResponse <AccountAttribute>(request, response, "add"));
        }
Ejemplo n.º 8
0
 public void Delete(AccountAttribute attribute)
 {
     if (attribute.Id > 0)
     {
         Delete(attribute.AccountId, attribute.Id);
     }
     else
     {
         Delete(attribute.AccountId, attribute.Name);
     }
 }
Ejemplo n.º 9
0
        protected virtual void FATran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            var tran = (FATran)e.Row;

            if (tran != null &&
                tran.Origin != FARegister.origin.Reversal &&
                (tran.TranType == FATran.tranType.DepreciationMinus ||
                 tran.TranType == FATran.tranType.DepreciationPlus))
            {
                AccountAttribute.VerifyAccountIsNotControl <FATran.debitAccountID>(sender, e);
            }
        }
Ejemplo n.º 10
0
        protected virtual void FATran_DebitAccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            var tran = (FATran)e.Row;

            if (tran != null &&
                e.ExternalCall &&
                (tran.TranType == FATran.tranType.DepreciationMinus ||
                 tran.TranType == FATran.tranType.DepreciationPlus))
            {
                AccountAttribute.VerifyAccountIsNotControl <FATran.debitAccountID>(sender, e);
            }
        }
        public bool CompareTo(AccountAttribute another)
        {
            if (another == null)
            {
                return(false);
            }

            return
                (this.Order == another.Order &&
                 this.Name == another.Name &&
                 this.Value == another.Value &&
                 this.Encrypted == another.Encrypted);
        }
Ejemplo n.º 12
0
        private void ValidateAccountGroupID(PXCache sender, Account account)
        {
            if (account.AccountGroupID == null)
            {
                return;
            }

            if (account.IsCashAccount == true)
            {
                throw new PXSetPropertyException(Messages.CashAccountIsNotForProjectPurposes, PXErrorLevel.Warning, account.AccountCD);
            }
            else
            {
                AccountAttribute.VerifyAccountIsNotControl(account);
            }
        }
Ejemplo n.º 13
0
 public ChangeAttribute(dynamic json)
 {
     project = GerritStream.GetValue(json, "project");
     branch = GerritStream.GetValue(json, "branch");
     topic = GerritStream.GetValue(json, "topic");
     id = GerritStream.GetValue(json, "id");
     number = int.Parse(GerritStream.GetValue(json, "number"));
     subject = GerritStream.GetValue(json, "subject");
     owner = new AccountAttribute(GerritStream.GetValue(json, "owner"));
     url = GerritStream.GetValue(json, "url");
     lastupdated = GerritStream.GetValue(json, "lastupdated");
     sortkey = GerritStream.GetValue(json, "sortkey");
     open = GerritStream.GetValue(json, "open");
     trackingids = new TrackingIdAttribute(GerritStream.GetValue(json, "trackingids"));
     currentpatchset = new PatchsetAttribute(GerritStream.GetValue(json, "currentpatchset"));
     patchsets = new PatchsetAttribute(GerritStream.GetValue(json, "patchsets"));
 }
Ejemplo n.º 14
0
        private void VerifyAccountIDToBeNoControl <T, A>(PXCache cache, EventArgs e, object accountID, int?ledgerID) where T : IBqlField where A : IBqlField
        {
            if (accountID == null)
            {
                return;
            }

            var ledger = (Ledger)PXSelect <Ledger> .Search <Ledger.ledgerID>(this, ledgerID);

            if (ledger?.BalanceType != LedgerBalanceType.Actual)
            {
                return;
            }

            var account = (Account)PXSelect <Account> .Search <A>(this, accountID);

            AccountAttribute.VerifyAccountIsNotControl <T>(cache, e, account);
        }
Ejemplo n.º 15
0
        protected virtual void AccountPtr_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            AccountAttribute.VerifyAccountIsNotControl <AccountPtr.accountID>(sender, e);

            AccountPtr row = e.Row as AccountPtr;

            if (row != null)
            {
                switch (e.Operation)
                {
                case PXDBOperation.Delete:
                    RemoveAccount(row);
                    break;

                case PXDBOperation.Insert:
                case PXDBOperation.Update:
                    AddAccount(row);
                    break;
                }

                e.Cancel = true;
            }
        }
Ejemplo n.º 16
0
        public static List <AccountModel> ReadAccountModels(string fileName)
        {
            List <AccountModel> tmpAccountModels = null;

            var tmpImportDocument = new XmlDocument();

            tmpImportDocument.Load(fileName);
            var tmpAccountNodes = tmpImportDocument.SelectNodes("Account//item");

            if (tmpAccountNodes != null)
            {
                tmpAccountModels = new List <AccountModel>();
                foreach (XmlElement tmpAccountNode in tmpAccountNodes)
                {
                    var tmpAccountInfo = new AccountModel();

                    tmpAccountInfo.AccountId   = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "id", 0);
                    tmpAccountInfo.CatalogId   = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "CatalogId", 0);
                    tmpAccountInfo.AccountGuid = XmlDocumentHelper.GetAttributeString(tmpAccountNode, "Guid");
                    tmpAccountInfo.Name        = XmlDocumentHelper.GetAttributeString(tmpAccountNode, "Name", null);
                    tmpAccountInfo.Order       = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "Order", 0);
                    tmpAccountInfo.URL         = XmlDocumentHelper.GetAttributeString(tmpAccountNode, "URL", null);
                    tmpAccountInfo.LoginName   = XmlDocumentHelper.GetAttributeString(tmpAccountNode, "LoginName", null);
                    tmpAccountInfo.Password    = XmlDocumentHelper.GetAttributeString(tmpAccountNode, "Password", null);
                    tmpAccountInfo.Email       = XmlDocumentHelper.GetAttributeString(tmpAccountNode, "Email", null);
                    tmpAccountInfo.Mobile      = XmlDocumentHelper.GetAttributeString(tmpAccountNode, "Mobile", null);
                    tmpAccountInfo.Deleted     = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "Delete", false);
                    tmpAccountInfo.TopMost     = (short)XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "TopMost", 0);
                    tmpAccountInfo.VersionNo   = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "Version", 1);
                    tmpAccountInfo.SecretRank  = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "SecretRank", SecretRank.绝密);
                    tmpAccountInfo.CreateTime  = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "CreateTime");
                    tmpAccountInfo.UpdateTime  = XmlDocumentHelper.GetAttributeValue(tmpAccountNode, "UpdateTime");

                    var tmpComment = XmlDocumentHelper.GetNodeInnerString(tmpAccountNode, "Comment");
                    if (!string.IsNullOrEmpty(tmpComment))
                    {
                        tmpAccountInfo.Comment = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(tmpComment));
                    }

                    var tmpAttributeNodes = tmpAccountNode.SelectNodes("Attributes/Attribute");
                    if (tmpAttributeNodes != null)
                    {
                        foreach (XmlElement tmpAttributeNode in tmpAttributeNodes)
                        {
                            var tmpAttribute = new AccountAttribute();
                            tmpAttribute.AccountId   = tmpAccountInfo.AccountId;
                            tmpAttribute.AttributeId = XmlDocumentHelper.GetAttributeValue(tmpAttributeNode, "Id", 0);
                            tmpAttribute.Order       = (short)XmlDocumentHelper.GetAttributeValue(tmpAttributeNode, "Order", 0);
                            tmpAttribute.Encrypted   = XmlDocumentHelper.GetAttributeValue(tmpAttributeNode, "Encrypted", false);
                            tmpAttribute.Name        = XmlDocumentHelper.GetAttributeString(tmpAttributeNode, "Name", string.Empty);
                            tmpAttribute.Value       = tmpAttributeNode.InnerText;

                            tmpAccountInfo.Attributes.Add(tmpAttribute);
                        }
                    }

                    tmpAccountModels.Add(tmpAccountInfo);
                }
            }

            return(tmpAccountModels);
        }
Ejemplo n.º 17
0
        public AccountAttribute Create(int accountId, AccountAttribute attribute)
        {
            var nameOrId = attribute.Id > 0 ? attribute.Id.ToString() : attribute.Name;

            return(Api.Post <AccountAttribute>($"/account/{accountId}/attribute/{nameOrId}", attribute.Value));
        }
Ejemplo n.º 18
0
        public AccountAttribute Update(AccountAttribute attribute)
        {
            var nameOrId = attribute.Id > 0 ? attribute.Id.ToString() : attribute.Name;

            return(Api.Put <AccountAttribute>($"/account/{attribute.AccountId}/attribute/{nameOrId}", attribute.Value));
        }
Ejemplo n.º 19
0
        protected override void buttonOK_Click(object sender, System.EventArgs args)
        {
            if (this.CheckInputValidity( ))
            {
                var tmpComment = this.textComment.Text.Trim( );
                var tmpEmail   = this.textEmail.Text.Trim( );
                var tmpMobile  = this.textMobile.Text.Trim( );
                var tmpHttpUrl = this.textURL.Text.Trim();

                var tmpInputErrorCaption = SafePassResource.MessageBoxCaptionInputError;

                var tmpPassword = this.textPassword.Text.Trim();
                if (!string.Equals(tmpPassword, this.textPwdRepeat.Text))
                {
                    this.textPwdRepeat.Focus();
                    MessageBox.Show(SafePassResource.PasswordRepeatFailed, tmpInputErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var tmpAccountInfo = new AccountModel( );
                tmpAccountInfo.AccountGuid = System.Guid.NewGuid( ).ToString("N");
                tmpAccountInfo.Name        = this.textName.Text.Trim();
                tmpAccountInfo.LoginName   = this.textLoginName.Text.Trim();
                tmpAccountInfo.Password    = tmpPassword;
                tmpAccountInfo.Email       = string.IsNullOrEmpty(tmpEmail) ? null : tmpEmail;
                tmpAccountInfo.URL         = string.IsNullOrEmpty(tmpHttpUrl) ? null : tmpHttpUrl;
                tmpAccountInfo.Mobile      = string.IsNullOrEmpty(tmpMobile) ? null : tmpMobile;
                tmpAccountInfo.Comment     = string.IsNullOrEmpty(tmpComment) ? null : tmpComment;
                tmpAccountInfo.CreateTime  = System.DateTime.Now;
                tmpAccountInfo.UpdateTime  = System.DateTime.Now;

                if (this.radioSecretRank0.Checked)
                {
                    tmpAccountInfo.SecretRank = SecretRank.公开;
                }
                else if (this.radioSecretRank1.Checked)
                {
                    tmpAccountInfo.SecretRank = SecretRank.秘密;
                }
                else if (this.radioSecretRank2.Checked)
                {
                    tmpAccountInfo.SecretRank = SecretRank.机密;
                }
                else if (this.radioSecretRank3.Checked)
                {
                    tmpAccountInfo.SecretRank = SecretRank.绝密;
                }
                else
                {
                    tmpAccountInfo.SecretRank = SecretRank.绝密;
                }

                if (this.currentCatalog != null)
                {
                    tmpAccountInfo.CatalogId = this.currentCatalog.CatalogId;
                }

                short order = 0;
                foreach (System.Data.DataRow tmpCurrentRow in this.accountDataTable.Rows)
                {
                    var attributeName  = string.Format("{0}", tmpCurrentRow[Account_Column_Name]);
                    var attributeValue = string.Format("{0}", tmpCurrentRow[Account_Column_Value]);

                    if (!string.IsNullOrEmpty(attributeName) && !string.IsNullOrEmpty(attributeValue))
                    {
                        var tmpAttribute = new AccountAttribute( );
                        tmpAttribute.AccountId = tmpAccountInfo.AccountId;
                        tmpAttribute.Order     = ++order;
                        tmpAttribute.Name      = attributeName;
                        tmpAttribute.Value     = attributeValue;

                        if (tmpCurrentRow[Account_Column_Encrypt] != System.DBNull.Value)
                        {
                            tmpAttribute.Encrypted = System.Convert.ToBoolean(tmpCurrentRow[Account_Column_Encrypt]);
                        }

                        tmpAccountInfo.Attributes.Add(tmpAttribute);
                    }
                }

                try
                {
                    Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                    var  tmpAccountService = new HuiruiSoft.Safe.Service.AccountService( );
                    bool tmpCreateResult   = tmpAccountService.CreateAccount(tmpAccountInfo);
                    tmpAccountService = null;

                    if (tmpCreateResult)
                    {
                        this.textName.Text      = "";
                        this.textLoginName.Text = "";
                        this.textMobile.Text    = "";
                        this.textURL.Text       = "";
                        this.textPassword.Text  = "";
                        this.textEmail.Text     = "";
                        this.textComment.Text   = "";
                        this.accountDataTable.Rows.Clear( );
                    }

                    Cursor.Current    = System.Windows.Forms.Cursors.Default;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                catch (System.Exception exception)
                {
                    loger.Error(exception);
                    Cursor.Current = System.Windows.Forms.Cursors.Default;
                    MessageBox.Show(string.Format(SafePassResource.AccountEditorDialogMessageCreateFailed, System.Environment.NewLine, exception.Message), SafePassResource.AccountEditorDialogTitleCreateFailed, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
Ejemplo n.º 20
0
        protected override void buttonOK_Click(object sender, System.EventArgs args)
        {
            if (base.CheckInputValidity())
            {
                var tmpInputErrorCaption = SafePassResource.MessageBoxCaptionInputError;

                string tmpAccountName = this.textName.Text.Trim();
                if (string.IsNullOrEmpty(tmpAccountName))
                {
                    this.textName.Focus();
                    MessageBox.Show(SafePassResource.AccountEditorPromptNameIsEmpty, tmpInputErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (tmpAccountName.Length > 30)      // if(HuiruiSoft.Shared.StringHelper.GetStringByteCount(tmpAccountName) > 30)
                {
                    this.textName.Focus();
                    MessageBox.Show(SafePassResource.AccountEditorPromptNameTooLong, tmpInputErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                string tmpComment = this.textComment.Text.Trim();
                var    tmpEmail   = this.textEmail.Text.Trim();
                var    tmpMobile  = this.textMobile.Text.Trim();
                var    tmpHttpUrl = this.textURL.Text.Trim();

                var tmpPassword = this.textPassword.Text.Trim();
                if (!string.Equals(tmpPassword, this.textPwdRepeat.Text))
                {
                    this.textPwdRepeat.Focus();
                    MessageBox.Show(SafePassResource.PasswordRepeatFailed, tmpInputErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                this.currentAccount.Name       = tmpAccountName;
                this.currentAccount.URL        = this.textURL.Text.Trim();
                this.currentAccount.LoginName  = this.textLoginName.Text.Trim();
                this.currentAccount.Password   = tmpPassword;
                this.currentAccount.Email      = string.IsNullOrEmpty(tmpEmail) ? null : tmpEmail;
                this.currentAccount.URL        = string.IsNullOrEmpty(tmpHttpUrl) ? null : tmpHttpUrl;
                this.currentAccount.Mobile     = string.IsNullOrEmpty(tmpMobile) ? null : tmpMobile;
                this.currentAccount.UpdateTime = System.DateTime.Now;
                this.currentAccount.Comment    = string.IsNullOrEmpty(tmpComment) ? null : tmpComment;

                if (this.radioSecretRank0.Checked)
                {
                    currentAccount.SecretRank = SecretRank.公开;
                }
                else if (this.radioSecretRank1.Checked)
                {
                    currentAccount.SecretRank = SecretRank.秘密;
                }
                else if (this.radioSecretRank2.Checked)
                {
                    currentAccount.SecretRank = SecretRank.机密;
                }
                else if (this.radioSecretRank3.Checked)
                {
                    currentAccount.SecretRank = SecretRank.绝密;
                }
                else
                {
                    currentAccount.SecretRank = SecretRank.绝密;
                }

                this.currentAccount.Attributes.Clear();

                short order = 0;
                foreach (System.Data.DataRow tmpCurrentRow in accountDataTable.Rows)
                {
                    string attributeName  = string.Format("{0}", tmpCurrentRow[Account_Column_Name]);
                    string attributeValue = string.Format("{0}", tmpCurrentRow[Account_Column_Value]);

                    if (!string.IsNullOrEmpty(attributeName) && !string.IsNullOrEmpty(attributeValue))
                    {
                        order++;

                        var tmpAttribute = new AccountAttribute();
                        tmpAttribute.AccountId = this.currentAccount.AccountId;

                        int tmpAttributeId = -1;
                        if (tmpCurrentRow[Account_Column_Id] != System.DBNull.Value)
                        {
                            int.TryParse(string.Format("{0}", tmpCurrentRow[Account_Column_Id]), out tmpAttributeId);
                        }
                        tmpAttribute.AttributeId = tmpAttributeId;

                        tmpAttribute.Order = order;
                        tmpAttribute.Name  = attributeName;
                        tmpAttribute.Value = attributeValue;

                        if (tmpCurrentRow[Account_Column_Encrypt] != System.DBNull.Value)
                        {
                            tmpAttribute.Encrypted = System.Convert.ToBoolean(tmpCurrentRow[Account_Column_Encrypt]);
                        }

                        this.currentAccount.Attributes.Add(tmpAttribute);
                    }
                }

                try
                {
                    Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                    var  tmpAccountService = new HuiruiSoft.Safe.Service.AccountService();
                    bool tmpUpdateResult   = tmpAccountService.UpdateAccount(this.currentAccount);
                    tmpAccountService = null;

                    Cursor.Current    = System.Windows.Forms.Cursors.Default;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                catch (System.Exception exception)
                {
                    loger.Error(exception);
                    Cursor.Current = System.Windows.Forms.Cursors.Default;
                    MessageBox.Show(string.Format(SafePassResource.AccountEditorDialogMessageUpdateFailed, System.Environment.NewLine, exception.Message), SafePassResource.AccountEditorDialogTitleUpdateFailed, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
Ejemplo n.º 21
0
 public AccountAttribute Create(AccountAttribute attribute)
 {
     return(Create(CurrentAccount, attribute));
 }