DomainOperationException in Silverlight Project with RIA Services - silverlight

I have a Silverlight project, and two entities, a master: UnidadDetalle and detail: UnidadLlantas
I want to modify an UnidadLlantas object to the UnidadDetalle and I have an error:
System.ServiceModel.DomainServices.Client.DomainOperationException: Error de la operaciĆ³n Submit. Object reference not set to an instance of an object
I try so many ways and this not work, I don't have any more idea, please somebody help me
my code:
mtto_UnidadDetalle unidad = new mtto_UnidadDetalle();
unidad = (mtto_UnidadDetalle)mtto_UnidadDetalleDomainDataSource.DataView.CurrentItem;
unidad.CantidadLlantas = Int32.Parse(txtCantidadLlantas.Text);
((mtto_UnidadLlantas)unidad.mtto_UnidadLlantas.Where(u => u.NumeroLlanta == 0).FirstOrDefault()).TipoLlanta = 36447;
mtto_UnidadDetalleDomainDataSource.SubmitChanges();
When debbug this, before the submit I inspected the object, and this look well, with all info ok, I don't know how fix it

Related

How to log data in DNN admin log or server event log

I simply want to debug a controller but I can't watch the variables I get from 2sxc functions.
I tried to log varables via Log4Net writting :
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(MyClassName));
but the type ILog is not known in a 2sxc controller. Am I missing a reference?
I also found this snippet:
using DotNetNuke.Services.Log.EventLog;
var objEventLog = new EventLogController();
objEventLog.AddLog("Sample Message", "Something Interesting Happened!", PortalSettings, UserId, EventLogController.EventLogType.ADMIN_ALERT)
But I don't know what to send to "PortalSettings" and I don't any clue in the helpers of the 2sxc programming interface.
How do you guys debug 2sxc controllers and log events (not only for debuging)?
Thank you for your help!
Credit of these snippets: Scott McCulloch (https://www.smcculloch.com/code/logging-to-the-dnn-event-log)
This gives part of the answer: http://www.dnnsoftware.com/community-blog/cid/141723/using-log4net-with-dotnetnuke. And, it looks like the namespace is DotNetNuke.Instrumentation.
As for PortalSettings, that's the portal settings for your portal. I think that you'd need to reference DotNetNuke.Entities.Portals, and then use PortalController to retrieve the portal settings object.
Joe Craig's previous post helped me a lot.
So, in a 2sxc application, I now can log in the DNN event log (not the Windows one):
#using DotNetNuke.Services.Log.EventLog;
#using DotNetNuke.Entities.Portals;
#{
var aujourdhui = DateTime.Now;
var objEventLog = new EventLogController();
PortalSettings PortalSettings = new PortalSettings();
objEventLog.AddLog("Debug info", "Variable \"Aujourdhui\" contains: " + aujourdhui.ToString("dddd d MMMM yyyy"), PortalSettings, #Dnn.User.UserID, EventLogController.EventLogType.ADMIN_ALERT);
}
The only little problem is that this PortalSettings returns the first portal even if my 2sxc app runs on the second portal (id=1). I must be missing something. But for now and what I need (debugging), thats Ok for me!

DiscoveryClient.GetAsync cannot connect to server

I have an issue when I am trying to set up this code:
var discoClient = new DiscoveryClient("http://localhost:5000") {Policy =
{RequireHttps = false}};
var disco = await discoClient.GetAsync();
The second line, var disco, tells me that it had issues connecting to the server, and I am at a loss trying to figure out why.
I am going through this tutorial: https://identityserver4.readthedocs.io/en/release/quickstarts/1_client_credentials.html.
I have everything else up to that point setup just like the walkthrough
What do I need to do to make this work?
Make sure you have both projects running.
In Solution Explorer select the solution file at the top.
Then right click and select the properties menu option.
Select the 'Multiple startup projects' and make sure the IdentityServer and Client Projects are set to 'Start'.

go-endpoint Invalid date format and method not found

Hy, I have some problems with the Go endpoints and Dart client library.
I use the Go library https://github.com/crhym3/go-endpoints and the dart generator https://github.com/dart-lang/discovery_api_dart_client_generator
The easy examples works fine. But they show never how to use time.Time.
In my project, I have a struct with a field:
Created time.Time `json:"created"`
The output in the explorer looks like this:
"created": "2014-12-08T20:42:54.299127593Z",
When i use it in the dart client library, I get the error
FormatException: Invalid date format 2014-12-08T20:53:56.346129718Z
Should I really format every time fields in the go app (Format Timestamp in outgoing JSON in Golang?)?
My research come to that the dart accept something:
t.Format(time.RFC3339) >> 2014-12-08T20:53:56Z
Second problem, if comment out the Created field or leave it blank. I get a other error:
The null object does not have a method 'map'.
NoSuchMethodError: method not found: 'map' Receiver: null Arguments:
[Closure: (dynamic) => dynamic]
But I can't figure it out which object is null. I'm not sure if I'm using the Dart client correct
import 'package:http/browser_client.dart' as http;
...
var nameValue = querySelector('#name').value;
var json = {'name':nameValue};
LaylistApi api = new LaylistApi(new http.BrowserClient());
api.create(new NewLayListReq.fromJson(json)).then((LayList l) {
print(l);
}).catchError((e) {
querySelector('#err-message').innerHtml=e.toString();
});
Does anyone know of a larger project on github with Go endpoint and Dart?
Thanks for any advice
UPDATE[2014-12-11]:
I fixed the
NoSuchMethodError
with the correct discovery url https://constant-wonder-789.appspot.com/_ah/api/discovery/v1/apis/greeting/v1/rest
The problem with the time FormatExcetion still open, but I'm one step further. If i create a new item, it doesn' work. But if I load the items from the datastore and send it back, this works.
I guess this can be fixed with implementing Marshaler interface, thanks Alex. I will update my source soon.
See my example:
http://constant-wonder-789.appspot.com/
The full source code:
https://github.com/cloosli/greeting-example

Backbone not sending PUT to server

I am having trouble with trying to get backbone to send a PUT request out to my rails server on save. I am not sure what I am doing wrong here, it is fine with GET requests just not PUT..
Here is the code that is in my view that I use to save my model.
e.preventDefault()
$(#el).find('#error_explanation').html ""
data = Backbone.Syphon.serialize(this)
setError = false
#model.set(data, error: (model, error) ->
setError = true
)
#model.save()
Any help would be greatly appreciated.
Thanks,
-do
Stupid me....
Here is what was in my model.
validate: ->
console.log "validating"
console.log "options: #{options}"
errors = []
if(!#.validateEmail(#.get('email')))
errors.push("Email can't be blank")
if(!#.validateName(#.get('first_name')))
errors.push("First name can't be blank")
if(!#.validateName(#.get('last_name')))
errors.push("Last name can't be blank")
return errors
This was actually being called when I was trying to save it which I was just trying to call manually. Since I wasn't returning the correct data saying that it was valid/invalid it just was always invalid.
ooops...
-do

Why is my MPMediaItem NowPlayingItem returning null?

I am incorporating the iPod player in my app. I am able to create a queue, then play the songs. I am not able to get the current song's property values. I have registered for the notifications and the log shows the notifications are bing triggered.
MPMediaItem *currentItem = self.musicPlayer.nowPlayingItem;
NSLog(#"currentItem = %#", currentItem);
Log output shows: currentItem = (null)
I'm running Xcode 4.5.2 iOS 6.0.
Any help is greatly appreciated.
For anyone else who may run into the same issue, the problem was that I synced my Music after running my application. You need to observe for Library changes:
MPMediaLibraryDidChangeNotification
[[MPMediaLibrary defaultLibrary] beginGeneratingLibraryChangeNotifications];
You wrote NSLog(#"currentItem = %#", currentItem); in your codes but maybe you have not got a full understand of what MPMediaItem is.
MPMediaItem is not NSString, and that's why you got null here. MPMediaItem has a lot of properties including song title, album name and artist name. To access the properties of MPMediaItem such as the title, use valueForProperty: method.
NSLog(#"currentItem = %#", [currentItem valueForProperty:MPMediaItemPropertyTitle])
Something like this.
I also had the problem that I mixed by accident the application player
[MPMusicPlayerController applicationMusicPlayer]
and the ipod player
[MPMusicPlayerController iPodMusicPlayer]
I was using the iPodMusicPlayer for playing music and tried to adjust the volume of the applicationMusicPlayer by accident.
So just beware not to mix them unintentionally ;-)

Resources