JBO-27008: Attribute HQBranchIndicator in view object OrganizationParty cannot be set - c#

I am getting an error when try to creation organization in the oracle webservice.
The field is set to nullable and I did not use that field. To resolve the issue I need to set HQBranchIndicator to empty string " ". But Other field error will occure there are too many fields to best. How to resolve this issue? Can i set all the fields to empty string?
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=12)]
public string HQBranchIndicator {
get {
return this.hQBranchIndicatorField;
}
set {
this.hQBranchIndicatorField = value;
this.RaisePropertyChanged("HQBranchIndicator");
}
}

Related

How to fetch value from an ExtensionDataObject of a wcf reponse

I have a WCF service which returns ExtensionDataObject during runtime as attached snapshot:
Im struck with fetching value for these objects. Could anyone please help here:
Have tried with below code using reflection, which throws Parameter count missing exception
List<System.Runtime.Serialization.ExtensionDataObject> extData = temp.Select(x => x.ExtensionData).ToList();
var GetCountry = extData.GetType().GetProperties();
string Country = string.Empty;
foreach (var property in GetCountry)
{
string name = property.Name;
object value = property.GetValue(extData, null);
if (name == "Country")
Country = value.ToString();
}
The Extensiondataobject field is generated to control the data contract incompatibility between the server and the client, so it will return a field named extensiondataobject. In other words, your client data contract implements the IExtensionDataObject interface.
[DataContract(Namespace="abcd")]
public class Product: IExtensibleDataObject
{
[DataMember]
public int ID { get; set; }
[DataMember]
public string Name { get; set; }
public ExtensionDataObject ExtensionData { get ; set ; }
}
If we capture this request through Fiddle, you can even see all the data directly.
In a word, you only need to add the Country property to the Data class of X object. It will be deserialized automatically. This class should be your client-side data contract class, instead of the server-side data class.
Finally, it seems that the value of these fields is null. We should ensure that the server and client data contracts have the same namespace. It cannot be the default value(http://tempuri.org). As I defined above, this namespace attribute should be consistent with the server-side value.
Feel free to let me know if there is anything I can help with.

Windows 10 (Universal Windows App) data validation

I was trying to figure out how to do the data validation under UWP, but according to what I have found out, there is basically nothing I can implemented yet.
Due to that I tried to implement my custom validation logic. Problem I have now is, that I am showing error information on one TextBlock rather than directly under the specific TextBox which contains data error.
This is what I do at the moment:
public class Customer : ViewModel
{
private string _Name = default(string);
public string Name { get { return _Name; } set { SetProperty(ref _Name, value); OnPropertyChanged("IsValid"); } }
private string _Surname = default(string);
public string Surname { get { return _Surname; } set { SetProperty(ref _Surname, value); OnPropertyChanged("IsValid"); } }
private DateTime _DateOfBirth = default(DateTime);
public DateTime DateOfBirth { get { return _DateOfBirth; } set { SetProperty(ref _DateOfBirth, value); OnPropertyChanged("IsValid"); } }
public int ID { get; set; }
public bool IsValid
{
get
{
//restart error info
_ErrorInfo = default(string);
if (string.IsNullOrWhiteSpace(Name))
_ErrorInfo += "Name cannot be empty!" + Environment.NewLine;
if (string.IsNullOrWhiteSpace(Surname))
_ErrorInfo += "Surname cannot be empty!" + Environment.NewLine;
//raise property changed
OnPropertyChanged("ErrorInfo");
return !string.IsNullOrWhiteSpace(Name) &&
!string.IsNullOrWhiteSpace(Surname);
}
}
private string _ErrorInfo = default(string);
public string ErrorInfo { get { return _ErrorInfo; } set { SetProperty(ref _ErrorInfo, value); } }
}
Question:
How to adjust my code, so that rather than having one label with all error information, I can assign label under each textbox and display validation error there? Should I use Dictionary for this? If yes, how can I bind it to my View?
I have quickly become a fan of using Prism, see this wonderful demonstration User input validation with Prism and data annotations on the UWP.
Its better than anything I could type here.
You can make a flyout inside a textbox.
As soon as the textbox loses focus with wrong input, the flyout shows up .
You can set the placament of the flyout on top/bottom/side of the textbox.
Best of luck !
The problem with Prism is that it uses a string indexer. But Bind in uwp just will not allow string indexes... Integers only! There are also some key features lacking such as coordination between entity view models and between them and the context.
I've done some R&D and it seems that the following are key elements of a good validator in uwp
- use of strings as the binding target, to avoid dropping conversion exceptions
- tracking conversion errors separately from validation errors
- base class for the validating view model AND automatically generated derived classes specifying the property names
- events to tie multiple view models together so that multiple parts of the ui are kept consistent
- centralized error count and save / revert ability associated with the context
Anything out there that can do that? If so then I haven't found it yet.
sjb

StackOverflowException in DAO

I am learning about Data Access Object Design Patterns and implementing it with c# / oracle. However when I try to run the program I get an error.
I am simply trying to add data to my database, however I keep getting the following error:
An unhandled exception of type 'System.StackOverflowException' occurred in Test.dll
It happens at my ReviewGame getter and setter.
Would you be so kind to view my code and see where I am going wrong? I would appreciate any help.
public string ReviewGame { get; set; }
"insert into review values(review_seq.nextval," + 2+ "," + review.MemberId + ", '" +review.ReviewGame+ "')";
ReviewDao reviewDao = new ReviewDaoImp();
Review r = new Review();
r.reviewGame = textBox1.Text;
r.ToString();
reviewDao.addReview(r);
}
Your properties call themselves in their getter and setter. You need to use a backing field to store the data:
private string _reviewGame;
public string ReviewGame
{
get { return _reviewGame; }
set { _reviewGame = value; }
}
Or you can use an auto property:
public string ReviewGame { get; set; }
(Note that I also changed to property name to start with an upper case, which is according to conventions.)

How to Clear/Remove an ActiveDirectory property with ExtensionSet

I'm using the Principal Extensions for a User in AD to access properties not normally retrieved by the UserPrincipal. My custom properties are defined like such:
[DirectoryProperty("facsimileTelephoneNumber")]
public string FaxNumber
{
get
{
if (ExtensionGet("facsimileTelephoneNumber").Length != 1)
return null;
return (string)ExtensionGet("facsimileTelephoneNumber")[0];
}
set
{
ExtensionSet("facsimileTelephoneNumber", value);
}
}
How do you clear the property with ExtensionSet? If I input null or empty string, I will almost always get this error message: "The attribute syntax specified to the directory service is invalid.". It sounds like you should clear the property but I'm unsure how this works with ExtensionSet.
The problem was I was not sending back an array, I was only sending back the value, not an array:
[DirectoryProperty("facsimileTelephoneNumber")]
public string FaxNumber
{
get
{
if (ExtensionGet("facsimileTelephoneNumber").Length != 1)
return null;
return (string)ExtensionGet("facsimileTelephoneNumber")[0];
}
set
{
ExtensionSet("facsimileTelephoneNumber", string.IsNullOrEmpty(value) ? new string[1] {null} : new string[1] {value});
}
}

Remove property name from validation message

Is it possible to remove property name form the validation message? For example, instead of:
Field 'Name' should not be empty.
I want to show:
Field should not be empty.
I need to do this global, for all validators.
You can do this using the localization customization like so to make the change globally. You can then of course override specific errors with a custom format if you need a one-off change.
ValidatorOptions.ResourceProviderType = typeof(MyResources);
...
public class MyResources {
public static string notempty_error {
get {
return "Field should not be empty.";
}
}
}
easiest way would be to pass a custom message. You can also override it so it always uses that message.
[Required(ErrorMessage = "Field should not be Empty")]
public string Name { get; set; }

Categories