I was wondering if there is a way to display more readable description of managed object in XCode 6 when developping in Swift.
Cause now it displays :
//Printing description of station:
(targetName.BDD_Station) station = 0x00000001700dfdb0 {
targetName.BDD_Station = {
CoreData.NSManagedObject = {
ObjectiveC.NSObject = {}
}
}
Before it was nicer :)
<BDD_Station: 0x1702d6180> (entity: BDD_Station; id: 0xd0000000bb7c0008 <x-coredata://DFA941DB-A7E7-406F-B415-B628AA4D8FF1/BDD_Station/p11999> ; data: {
address = "254, Alexander Platz ";
address2 = "";
area = 72;
"brand_code" = TAC;
"brand_id" = 420;
"brand_name" = "HARIBO";
cheapest = nil;
city = PARIS;
code = NF000337;
"corporate_name" = nil;
country = FRANCE;
department = nil;
distance = 0;
email = "";
fax = nil;
ident = 827752;
latitude = "48.1278";
longitude = "-2.64937";
"map_id" = 744;
name = "my beautiful name";
"original_name" = nil;
phone = 0143543211;
toDelete = 0;
zip = 72000;
})
I tried to override var description, but it does'nt get called when I click "show description" in debugger.
Thanks for your help.
Related
I have the following command where I get my notification in ios, I want to get my key more I'm not getting it, what I tried was
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
Messaging.SharedInstance.AppDidReceiveMessage(userInfo);
NSString[] keys = { new NSString("Event_type") };
NSObject[] values = { new NSString("Recieve_Notification") };
var parameters = NSDictionary<NSString, NSObject>.FromObjectsAndKeys(keys, values, keys.Length);
Firebase.Analytics.Analytics.LogEvent("CustomEvent", parameters);
System.Diagnostics.Debug.WriteLine(userInfo);
// var aps_d = userInfo["aps"] as NSDictionary;
//var alert_d = aps_d["alert"] as NSDictionary;
//var body = alert_d["keys"] as NSString;
}
System.Diagnostics.Debug.WriteLine
receive this
[0:] {
aps = {
alert = {
body = "teste";
title = "teste";
};
};
"gcm.message_id" = "0:1505400569099941%712ac0f8712a1234";
"gcm.n.e" = 1;
"google.c.a.c_id" = 5974019197827881234;
"google.c.a.c_l" = "teste";
"google.c.a.e" = 1;
"google.c.a.ts" = 1505400123;
"google.c.a.udt" = 0;
keys = 152113;
}
keys is a top level and last entry in the dictionary, so you can directly access it via userInfo["keys"], i.e:
var keys = userInfo["keys"] as NSString;
How do you set a new Contact with a yearless birthday with Xamarin iOS?
iOS Documentation states you can just leave the NSDateComponent.year field blank for a yearless birthday.
After trying this in Xamarin iOS, it bugs out the birthday field on the New Contact UI, making it unusable.
var store = new CNContactStore();
var contact = new CNMutableContact();
// construct birthday w/o year
var birthDate = new NSDateComponents();
birthDate.Month = 11;
birthDate.Day = 12;
contact.Birthday = birthDate;
// pop iOS Contact UI
var editor = CNContactViewController.FromNewContact (contact);
editor.ContactStore = store;
editor.AllowsActions = false;
editor.AllowsEditing = true;
navcontroller.PushViewController(editor,true);
You need to save the contact first, then the iOS Contact Editor can handle the year-less date correctly.
var store = new CNContactStore();
var contact = new CNMutableContact()
{
GivenName = "Stack",
FamilyName = "Overflow"
};
var birthDate = new NSDateComponents();
contact.Birthday = new NSDateComponents()
{
Month = 11,
Day = 12,
};
######
var saveRequest = new CNSaveRequest();
saveRequest.AddContact(contact, null);
NSError error;
store.ExecuteSaveRequest(saveRequest, out error);
######
var editor = CNContactViewController.FromNewContact(contact);
editor.ContactStore = store;
editor.AllowsActions = false;
editor.AllowsEditing = true;
PresentViewControllerAsync(editor, true);
Figured it out. You have to set the calendar in the NSDateComponents to Gregorian.
var store = new CNContactStore();
var contact = new CNMutableContact();
// construct birthday w/o year
var birthDate = new NSDateComponents();
birthDate.Calendar = new NSCalendar(NSCalendarType.Gregorian);
birthDate.Month = 11;
birthDate.Day = 12;
contact.Birthday = birthDate;
// pop iOS Contact UI
var editor = CNContactViewController.FromNewContact (contact);
editor.ContactStore = store;
editor.AllowsActions = false;
editor.AllowsEditing = true;
navcontroller.PushViewController(editor,true);
I am trying to get youtube video information for each video in my youtube playlist. That way I can hook my PowerBI dashbaords and other email tool to a SQL database with all my youtube video meta data in it. I have a method that will grab all of the Snippet video information. But it fails when grabbing the other parts.This link clearly shows that content details is a valid operation but the APIgives me a 400 back. I have to be really close. Any ideas?
https://developers.google.com/youtube/v3/docs/videos/list#parameters
public YouTubeVideo GetVideoInfo(string id)
{
var videoRequest = ytservice.Videos.List("snippet");
var contentRequest = ytservice.Videos.List("contentdetials");
var itemRequest = ytservice.Videos.List("items");
var statsRequest = ytservice.Videos.List("Statistics");
videoRequest.Id = id;
contentRequest.Id = id;
itemRequest.Id = id;
statsRequest.Id = id;
var response = videoRequest.Execute();
var contentResponse = contentRequest.Execute();
var itemResponse = itemRequest.Execute();
var statsResponse = statsRequest.Execute();
var video = new YouTubeVideo();
if (response.Items.Count > 0)
{
video.id = videoRequest.Id;
video.caption = contentResponse.Items[0].ContentDetails.Caption;
video.title = response.Items[0].Snippet.Title;
video.description = response.Items[0].Snippet.Description;
video.publishDate = response.Items[0].Snippet.PublishedAt.Value;
video.ageGate = itemResponse.Items[0].AgeGating.Restricted;
video.viewCount = response.Items[0].Statistics.ViewCount;
video.likeCount = statsResponse.Items[0].Statistics.LikeCount;
video.dislikeCount = statsResponse.Items[0].Statistics.DislikeCount;
video.favoriteCount = statsResponse.Items[0].Statistics.FavoriteCount;
video.commentCount = statsResponse.Items[0].Statistics.CommentCount;
}
else
{
//Video not found
}
return video;
}
I figured out i could make all of the calls in the same string just seperated by commas :)
public YouTubeVideo GetVideoInfo(string id)
{
var videoRequest = ytservice.Videos.List("snippet, contentDetails, statistics");
videoRequest.Id = id;
var response = videoRequest.Execute();
var video = new YouTubeVideo();
if (response.Items.Count > 0)
{
video.id = videoRequest.Id;
video.caption = response.Items[0].ContentDetails.Caption;
video.title = response.Items[0].Snippet.Title;
video.description = response.Items[0].Snippet.Description;
video.publishDate = response.Items[0].Snippet.PublishedAt.Value;
//video.ageGate = (response.Items[0].AgeGating.Restricted = null) ? null : response.Items[0].AgeGating.Restricted;
video.viewCount = response.Items[0].Statistics.ViewCount;
video.likeCount = response.Items[0].Statistics.LikeCount;
video.dislikeCount = response.Items[0].Statistics.DislikeCount;
video.favoriteCount = response.Items[0].Statistics.FavoriteCount;
video.commentCount = response.Items[0].Statistics.CommentCount;
}
else
{
//Video not found
}
return video;
}
Using MVC3 and razor along with NuGet Doddle Report, I have built a nice report that opens a view model in Excel. I would like to allow the user to supply a filter and sort on the view before the report is exported to Excel.
Are there recommended ways to do this or resources I could check out?
Thanks!
EDIT
Controller code that creates report:
public ReportResult CaseReport()
{
var viewModel = new CasesReportViewModel();
var query = (from c in db.Cases
join customer in db.Customers on c.CustomerID equals customer.CustomerID
join category in db.CaseCategories on c.CaseCategoryID equals category.CaseCategoryID
join tech in db.Technicians on c.TechnicianID equals tech.TechnicianID
join engine in db.EngineModels on c.EngineModelID equals engine.EngineModelID
select new CasesReportViewModel()
{
CustomerName = c.Customer.CustomerName,
UserName = c.UserName,
PromoID = tech.PromoID,
EngineModelName = engine.EngineModelName,
CaseNumber = c.CaseNumber,
BMSWorkorder = c.BMSWorkorder,
CaseStatus = c.CaseStatus,
OpenedBy = c.OpenedBy,
OpenedDate = c.OpenedDate,
ClosedBy = c.ClosedBy,
ClosedDate = c.ClosedDate,
CategoryName = category.CategoryName,
CallerFirstName = c.CallerFirstName,
CallerLastName = c.CallerLastName,
AdditionalContact = c.AdditionalContact,
Qualified = c.Qualified,
Description = c.Description,
ESN = c.ESN,
Mileage = c.Mileage,
DateInService = c.DateInService,
ESTR = c.ESTR,
EDS = c.EDS
});
var report = new Report(query.ToReportSource());
//customize fields
report.TextFields.Title = "Case Report";
AppHelpers app = new AppHelpers();
report.TextFields.Header = "Report Date = " + Convert.ToString(app.GetEasternTime());
report.TextFields.Footer = "Copyright 2012";
//data fields
report.RenderHints.BooleanCheckboxes = true;
report.DataFields["CustomerName"].DataFormatString = "{0:c}";
report.DataFields["UserName"].DataFormatString = "{0:c}";
report.DataFields["EngineModelName"].DataFormatString = "{0:c}";
report.DataFields["CaseNumber"].DataFormatString = "{0:c}";
report.DataFields["BMSWorkorder"].DataFormatString = "{0:c}";
report.DataFields["CategoryName"].DataFormatString = "{0:c}";
report.DataFields["CaseStatus"].DataFormatString = "{0:c}";
report.DataFields["OpenedBy"].DataFormatString = "{0:c}";
report.DataFields["OpenedDate"].DataFormatString = "{0:d}";
report.DataFields["ClosedBy"].DataFormatString = "{0:c}";
report.DataFields["ClosedDate"].DataFormatString = "{0:d}";
report.DataFields["CallerFirstName"].DataFormatString = "{0:c}";
report.DataFields["CallerLastName"].DataFormatString = "{0:c}";
report.DataFields["AdditionalContact"].DataFormatString = "{0:c}";
report.DataFields["Qualified"].DataFormatString = "{0:c}";
report.DataFields["Description"].DataFormatString = "{0:c}";
report.DataFields["ESN"].DataFormatString = "{0:c}";
report.DataFields["Mileage"].DataFormatString = "{0:c}";
report.DataFields["DateInService"].DataFormatString = "{0:d}";
report.DataFields["ESTR"].DataFormatString = "{0:c}";
report.DataFields["EDS"].DataFormatString = "{0:c}";
return new ReportResult(report, new ExcelReportWriter(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileName = "CaseReport" };
}
i am writing the code below manner.
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions error:&error];
NSLog(#"%#",json);
The printed dictionary is
(
{
Contents = (
{
Id = 2;
LastUpdated = "/Date(1338048712847+0000)/";
Title = "Webinar: HP & MS solutions for Mid-Market";
Url = "http://infra2apps.blob.core.windows.net/content/VMMM019-HP-MS_MidMarket.wmv";
},
{
Id = 1;
LastUpdated = "/Date(1338048712773+0000)/";
Title = "Webinar: Private Cloud with HP & MS";
Url = "http://infra2apps.blob.core.windows.net/content/VMPC012-HPMS_PrivateCloud.wmv";
}
);
Id = 1;
ImageUrl = "http://infra2apps.blob.core.windows.net/eventapp/black-microsoft-logo.jpg";
Name = "Unified Communications & Collaborations";
Sessions = (
{
Description = "Microsoft Lync delivers Unified Communication to help People connect in new ways, anytime, anywhere. Learn how HP and Microsoft are helping customers transform their business infrastrucutre and gain greater productivity by making every communication an interaction that is more collaborative and engaging.";
EndDate = "/Date(1275822000000+0000)/";
FriendlyName = TB3257;
Id = 1;
Location = "Building N-4105";
Speakers = (
{
Company = Microsoft;
Email = "johndoe#microsoft.com";
Name = "John Doe";
Title = "Group Manager";
}
);
StartDate = "/Date(1275818400000+0000)/";
Title = "Connecting People in New Ways with Microsoft Lync";
},
{
Description = "Microsoft Lync delivers Unified Communication to help People connect in new ways, anytime, anywhere. Learn how HP and Microsoft are helping customers transform their business infrastrucutre and gain greater productivity by making every communication an interaction that is more collaborative and engaging.";
EndDate = "/Date(1275825600000+0000)/";
FriendlyName = TB3258;
Id = 2;
Location = "Building N-4105";
Speakers = (
{
Company = HP;
Email = "janedoe#hp.com";
Name = "Jane Doe";
Title = "Vice President";
},
{
Company = Microsoft;
Email = "johndoe#microsoft.com";
Name = "John Doe";
Title = "Group Manager";
}
);
StartDate = "/Date(1275822000000+0000)/";
Title = "Connecting People in New Ways with Microsoft Lync - Part 2";
}
);
},
....etc
And then store the content values into another dictionary after that i store into an array.
the below code is to store the array id
NSDictionary *boothmenucontents = [json valueForKey: #"Contents"];
NSMutableArray *dictResponseboothmenucontentsArray = [[NSMutableArray alloc] initWithObjects: boothmenucontents,nil];
for(int i = 0; i<[dictResponseboothmenucontentsArray count]; i++)
{
NSMutableArray *IdArrayboothmenucontentes=[[dictResponseboothmenucontentsArray objectAtIndex:i] valueForKey:#"Id"];
NSLog(#"id array is %#",IdArrayboothmenucontentes);
for(int k=0;k<[IdArrayboothmenucontentes count];k++)
{
NSString * strcontentId= [NSString stringWithFormat:#"%#",[IdArrayboothmenucontentes objectAtIndex:k]];
NSLog(#"strcontentId%#",strcontentId);
label.text=strcontentId;
[boothmenuidarrayvalues addObject:strcontentId];
NSLog(#"%#",boothmenuidarrayvalues);
}
}
finally i print the boothmenuidarrayvalues
it print like this
"(\n 2,\n 1\n)",
"(\n 4,\n 3\n)",
"(\n 6,\n 5\n)",
"(\n 8,\n 7\n)",
"(\n 10,\n 9\n)",
"(\n 12,\n 11\n)"
but i want to print content id only once but it print in a row in two times.
May be i follow a wrong method please tell me how to give own root for that response.
Please help me.......
Perhaps It will help you.
NSMutableArray *contenstsArray = [contentsDictionary ValueForKey:#"Contents"]; //Suppose you already brought all the json data into contentsDictionary
NSMutableArray *idArray = [[NSMutableArray alloc] init];
for(NSMutableDictionary *idDic in contenstsArray) {
NSString *idString = [idDic valueForKey:#"Id"];
[idArray addObject:];
}
This line looks wrong:
NSMutableArray *IdArrayboothmenucontentes=[[dictResponseboothmenucontentsArray objectAtIndex:i] valueForKey:#"Id"];
I'm not sure what you are expecting it to do, but what it looks like it does is grab the ith object in the dictResponseboothmenucontentsArray, which is a dictionary and then gets the object in that dictionary with the key "Id", which is an number, so IdArrayboothmenucontentes now contains an NSNumber, not an array.