BB 10: Getting String Exception while returning of QByteArray - blackberry-10

I am getting exception: Exception String ""
on my code:
const QByteArray aa = ContactService().contactToVCard(le)
here le is contact

Related

Uncaught Error: TypeError: 100: type 'JSInt' is not a subtype of type 'String'

void main() {
String num = "50";
int quantity = 2;
num = (int.parse(num) * quantity) as String;
print("num is "+num);
}
This is giving me error
Actually i want to convert a string to numerical value and perform calculations and update the string back with the updated value.
// Assume the intial value of
// item.quantity = 1, item.cost = 20
-----------------------------------------------------------------
item.quantity++;
item.cost = (int.parse(item.cost) * item.quantity) as String;
-----------------------------------------------------------------
====================================================
expected result item.cost = 40
generated result is 2020
====================================================
By using toString you create a new String value. By casting as T you tell the compiler that an unknown value you want as T value.
void main() {
String numer = "50";
int quantity = 2;
numer = (num.parse(numer) * quantity).toString();
print("sum is $numer"); // sum is 100
}
Note: avoid use names which is reserved by system to avoid conflict.

Unhandled Exception: 'package:realm_dart/src/helpers.dart': error: line 26 pos 3: native function 'Helpers_invokeStatic' (2 arguments) cannot be found

Unhandled Exception: 'package:realm_dart/src/helpers.dart': error: line 26 pos 3: native function 'Helpers_invokeStatic' (2 arguments) cannot be found
While starting the application its working perfectly and fetching data but when I restart the application it throws above error.
main.dart
void ints() {
print("initState");
var config = new Configuration();
config.schema.add(Car);
var realm = new Realm(config);
realm.write(() {
print("realm write callback");
var car = realm.create(new Car()..make = "Audi");
print("The car is ${car.make}");
car.make = "VW";
print("The car is ${car.make}");
});
var objects = realm.objects<Car>();
var indexedCar = objects[1];
print('here');
print("The indexedCar is ${indexedCar.make}");
}
Configuration.dart
add(Type type) {
print(type);
var schema = Helpers.invokeStatic(type, "getSchema");
//set the static field on the T class.
TypeStaticProperties.setValue(type, "schema", schema);
// _generateSchema(type);
innerList.add(type);
}
Helpers.dart
class Helpers {
static DateTime createDateTime(int miliseconds) {
return DateTime.fromMillisecondsSinceEpoch(miliseconds, isUtc: true);
}
static dynamic invokeStatic(Type type, String name) native "Helpers_invokeStatic";
}

length of server response in flutter http package

I am using future builder for building list view. I am getting the response from server. I am getting exactly what i need. There is single error that i am trying to resolve. The error is when i fetch data from server using http.get method : String data=response.body; I am getting the right response that i want and i am parsing it as String catagoeryId=jsonDecode(data)["data"][i]["_id"];
Now the problem i faced when i decode this json i passed this String inside my constructor using for loop. But i have to give length to stop for loop. the length i am using is: data.length. It decode my json response and passes inside my constructor. But after the json length end its stop working and crashed. I checked the length of data.length its something around 344. But i am having only 3 objects. Here is the code i am using for parsing:
Future<List<ProductCatagoery>> getCatagories()async{
http.Response response = await http.get("http://138.68.134.226:3020/api/category/");
List<ProductCatagoery> products=[];
String data=response.body;
for (int i=0;i<=data.length;i++) {
String catagoeryId=jsonDecode(data)["data"][i]["_id"];
String catagoeryThumb=jsonDecode(data)["data"][i]["thumb"];
String catagoeryName=jsonDecode(data)["data"][i]["name"];
bool catagoeryActive=jsonDecode(data)["data"][i]["active"];
print('name is: $catagoeryId : $catagoeryThumb : $catagoeryName : $catagoeryActive');
ProductCatagoery newUser=
ProductCatagoery(catagoeryId,catagoeryThumb,catagoeryName,catagoeryActive);
products.add(newUser);
print('added ${newUser.id}');
print('length is${products.length}');
print('last length data: ${data.length}');
}
return products;
}
Model class:
class ProductCatagoery {
final String id;
final String thumb;
final String name;
final bool active;
ProductCatagoery(this.id,this.thumb,this.name,this.active);
}
Response is:
{"success":true,"data":[{"_id":"5f13cc94c63abc03522eff41","thumb":"category/fresh-meat.jpg","name":"Fresh Meat","active":true},{"_id":"5f13cc73c63abc03522eff40","thumb":"category/fruits-vegetables.jpg","name":"Fruits & Vegetables","active":true},{"_id":"5f13cca5c63abc03522eff42","thumb":"category/grocery.jpg","name":"Grocery","active":true}]}
Note: I just need String data=response.body; data length. I am not using an map etc. I also showed products in list if i return product list after 1, 2 or 3th iteration.
First, decode the response received
final responseFormat = json.decode(response.body);
Then, you can get the list you want to loop with this
final data = responseFormat["data"];
Finally, you can get the length of the list : data.length.
Full code
List<ProductCatagoery> products = [];
final responseFormat = json.decode(response.body);
final data = responseFormat["data"];
for (int i = 0; i < data.length; i++) {
String catagoeryId = data[i]["_id"];
String catagoeryThumb = data[i]["thumb"];
String catagoeryName = data[i]["name"];
bool catagoeryActive = data[i]["active"];
print(
'name is: $catagoeryId : $catagoeryThumb : $catagoeryName : $catagoeryActive');
ProductCatagoery newUser = ProductCatagoery(
catagoeryId, catagoeryThumb, catagoeryName, catagoeryActive);
products.add(newUser);
print('added ${newUser.id}');
print('length is${products.length}');
print('last length data: ${data.length}');
}

Crystal Report: Failed to load from data database

I am using this code but gives me this error:
Failed to retrieve data from the database. Details: [Database Vendor Code: 201 ]
public JsonResult ReportCertificateOfEmployment(int EmployeeId, int SigId, string SigPosition)
{
string Userkey = "gHeOai6bFzWskyUxX2ivq4+pJ7ALwbzwF55dZvy/23BrHAfvDVj7mg ";
string PassKey = "lLAHwegN8zdS7mIZyZZj+EmzlkUXkvEYxLvgAYjuBVtU8sw6wKXy2g ";
string rptlogin = ConfigurationManager.AppSettings.Get("rptlogin");
string rptPassword = ConfigurationManager.AppSettings.Get("rptPassword");
MemoryStream oStream;
CertificateOfEmployment rpt = new CertificateOfEmployment();
rpt.Refresh();
rpt.SetDatabaseLogon(rptlogin, rptPassword);
rpt.SetParameterValue(0, EmployeeId);
rpt.SetParameterValue(1, SigId);
rpt.SetParameterValue(2, SigPosition);
rpt.SetParameterValue(3, DateTime.Now);
oStream = (MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); --------- this gives me an error
// extract only the fielname
string filename = Convert.ToString((DateTime.Now.Month) + Convert.ToString(DateTime.Now.Day) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Hour) + Convert.ToString(DateTime.Now.Minute) + Convert.ToString(DateTime.Now.Second) + Convert.ToString(DateTime.Now.Millisecond)) + "BarangayClearance";
var len = oStream.Length;
// store the file inside ~/App_Data/uploads folder
// var path = Path.Combine(Server.MapPath("~/Content/Images"), fileName);
// file.SaveAs(path);
FileTransferServiceClient client2 = new FileTransferServiceClient();
RemoteFileInfo rmi = new RemoteFileInfo();
DateTime dt = DateTime.Now;
// upload file using webservice
DownloadRequest dr = new DownloadRequest();
//web service method to upload a file and return the unique id of the newly uploaded file
string fId = client2.UploadFileGetId("", filename, len, PassKey, Userkey, oStream);
//Instantiate the object Img which is a table in the database server of the application
//Download file using web service;
//DownloadFile in Refence.cs has been edited to return a RemoteFileInfo Class
//before, the return type of DownloadFile method was a Stream type
JsonResult result = new JsonResult();
result.Data = new
{
fileId = fId,
filename = filename
};
rpt.Close();
rpt.Dispose();
var arr = oStream.ToArray();
oStream.Close();
oStream.Dispose();
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
return result;
}

facebook publish story error

I am using following code to publish story on facebook:
FacebookWebClient facebookWebClient = new FacebookWebClient(UserSession.CurrentFacebookProfileAccessToken);
string URL="https://graph.facebook.com/me/tsstesting:start";
var parameters = new Dictionary<string, object>();
parameters["og:type"] = "tsstesting:myurl";
parameters["urlname"] = "http://on.fb.me/12rMxhV";
parameters["title"] = "QBSTab";
try
{
dynamic result = facebookWebClient.Post(URL, parameters); // again here should be your app name instead of "myapp"
JObject friendListJson = JObject.Parse(result.ToString());
string returval = friendListJson["id"].ToString();
return returval;
}
catch (Exception e)
{
return e.Message;
}
It gives me exception Object at URL 'https://www.facebook.com/' of type 'website' is invalid because the given value 'www' for property 'og:locale:alternate' could not be parsed as type 'enum'.
What I am missing here?