private bool CheckFieldValidate(Transaction transaction, TransFieldBase field, bool writeBack) { if (writeBack) { if (string.IsNullOrWhiteSpace(field.SrcField)) { throw new ArgumentNullException("SrcField"); } if (string.IsNullOrWhiteSpace(field.DesField) && string.IsNullOrWhiteSpace(field.SrcGetValue)) { throw new ArgumentNullException("DesField or SrcGetValue"); } } else { if (string.IsNullOrWhiteSpace(field.DesField)) { throw new ArgumentNullException("DesField"); } if (string.IsNullOrWhiteSpace(field.SrcField) && string.IsNullOrWhiteSpace(field.SrcGetValue)) { throw new ArgumentNullException("SrcField or SrcGetValue"); } } if (string.IsNullOrWhiteSpace(field.SrcField)) { PropertyInfo sourceColumn = transaction.CurrentObject.GetType().GetProperty(field.SrcField); if (sourceColumn == null) { throw new ArgumentException(string.Format(MessageHelper.EFTransactionMessage.ColumnNotInTable, field.SrcField, transaction.CurrentObject.EntityKey.EntitySetName)); } } PropertyInfo destinationColumn = this.Context.CreateObject(transaction.TransTableName).GetType().GetProperty(field.DesField); if (destinationColumn == null) { throw new ArgumentException(string.Format(MessageHelper.EFTransactionMessage.ColumnNotInTable, field.DesField, transaction.TransTableName)); } return true; }
private string GetFieldDefaultValue(TransFieldBase field, EntityObject entityObject) { string defaultValue = field.SrcGetValue; char[] cs = defaultValue.ToCharArray(); #warning 加完ServerUtility再回来补 //object[] myret = SrvUtils.GetValue(defaultValue, (DataModule)((InfoTransaction)_transaction.Owner).OwnerComp); //if (myret != null && (int)myret[0] == 0) //{ // return (string)myret[1]; //} if (cs[0] != '"' && cs[0] != '\'') { char[] sep1 = "()".ToCharArray(); string[] sps1 = defaultValue.Split(sep1); if (sps1.Length == 3) { return this.Module.CallMethod(sps1[0], new object[] { entityObject }).ToString(); } if (sps1.Length == 1) { return sps1[0]; } if (sps1.Length != 1 && sps1.Length == 3) { //String message = SysMsg.GetSystemMessage(((DataModule)((InfoTransaction)_transaction.Owner).OwnerComp).Language, "Srvtools", "InfoTranscation", "msg_TransFieldBaseDefaultValueIsBad"); //throw new ArgumentException(String.Format(message, ((InfoTransaction)(_transaction.Owner)).Name, field.DesField)); } } char[] sep2 = null; if (cs[0] == '"') { sep2 = "\"".ToCharArray(); } if (cs[0] == '\'') { sep2 = "'".ToCharArray(); } string[] sps2 = defaultValue.Split(sep2); if (sps2.Length == 3) { return sps2[1]; } else { //String message = SysMsg.GetSystemMessage(((DataModule)((InfoTransaction)_transaction.Owner).OwnerComp).Language, "Srvtools", "InfoTranscation", "msg_TransFieldBaseDefaultValueIsBad"); //throw new ArgumentException(String.Format(message, ((InfoTransaction)(_transaction.Owner)).Name, field.DesField)); } return defaultValue; }