blackberry list contacts with email address - email

I am using this code snippet to retrieve contact's email addressees but what I want to do is list the contacts who has got email address. With this method it displays all of the contacts
try {
list = (BlackBerryContactList) PIM.getInstance()
.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
PIMItem contact = list.choose();
if (contact != null) {
String emailId = "";
for (int i = 0; i < contact.countValues(Contact.EMAIL); i++) {
emailId = contact.getString(Contact.EMAIL, i);
System.out.println("_ _ _ _ __ EMAIL : " + i + " " + emailId);
}
}
} catch (PIMException e) {
Dialog.inform("Proble creating contact list!");
e.printStackTrace();
}

Find below the function which return only those contact list which contains email address:
/*import email id from the contact list. */
public Vector getEmail()
{
Vector emailList=new Vector();//contains the list of contact
email_list.removeAllElements();
try
{
PIM pim = PIM.getInstance();
ContactList contacts;
contacts = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
Enumeration items;
items = contacts.items();
while(items.hasMoreElements())
{
Contact contact = (Contact) items.nextElement();
String emailID = "";
if (contacts.isSupportedField(Contact.EMAIL) && (contact.countValues(Contact.EMAIL) > 0) )
{
emailID=contact.getString(Contact.EMAIL, 0);
//emailList.addElement(arr);
}
String firstName = "";
if ((contacts.isSupportedField(Contact.NAME)) && (contact.countValues(Contact.NAME) > 0))
{
String[] name = contact.getStringArray(Contact.NAME, 0);
firstName = name[Contact.NAME_GIVEN];
// String lastName = name[Contact.NAME_FAMILY];
}
String arr[]={emailID,firstName};//array which contains emailid and first name
emailList.addElement(arr);
}
}
catch(Exception pe)
{
}
return emailList;
}

Related

contact_service is not displaying contacts names properly Flutter

I have been working on an application that need to fetch user's contacts from device and display to contact name saved in device which works for some contacts but not for all contacts. For fetching contacts I have been using contact_service package.
It is displaying the contact name for some of the contacts and then it is displaying the contact number of some of the contacts. I am fetching and getting name by using the following code snippets.
/// Fetching Contacts
Future getContactsFromGloble() async {
allcontacts = [];
var getContacts = [];
var newgetContacts = [];
var contacts =
(await ContactsService.getContacts(withThumbnails: false)).toList();
allcontacts = contacts;
if (allcontacts != null) {
print("TOTAL:>>>>>>>>>>>" + allcontacts.length.toString());
for (int i = 0; i < allcontacts.length; i++) {
Contact? c = allcontacts.elementAt(i);
getContacts.add(c.phones?.map((e) =>
e.value?.replaceAll(new RegExp(r"\s+\b|\b\s"), "").toString()));
}
}
print('global');
return allcontacts;
}
/// Fetching contact name
getContactName(mobile) {
if (allcontacts != null && mobile != null) {
var name = mobile;
for (var i = 0; i < allcontacts.length; i++) {
if (allcontacts[i]
.phones!
.map((e) => e.value)
.toString()
.replaceAll(new RegExp(r"\s+\b|\b\s"), "")
.contains(mobile)) {
name = allcontacts[i].displayName;
}
}
return name;
} else {
return mobile;
}
}

Need to edit the code "user info" for sdk ZKTeco device fb100

I have this code working 100% but with one device zkt fb100,This code is for set user name ,card number , with id to the device to register it:
public int sta_SetUserInfo(ListBox lblOutputInfo, TextBox txtUserID, TextBox txtName, ComboBox cbPrivilege, TextBox txtCardnumber, TextBox txtPassword)
{
if (GetConnectState() == false)
{
lblOutputInfo.Items.Add("*Please connect first!");
return -1024;
}
if (txtUserID.Text.Trim() == "" || cbPrivilege.Text.Trim() == "")
{
lblOutputInfo.Items.Add("*Please input data first!");
return -1023;
}
int iPrivilege = cbPrivilege.SelectedIndex;
bool bFlag = false;
if (iPrivilege == 5)
{
lblOutputInfo.Items.Add("*User Defined Role is Error! Please Register again!");
return -1023;
}
/*
if(iPrivilege == 4)
{
axCZKEM1.IsUserDefRoleEnable(iMachineNumber, 4, out bFlag);
if (bFlag == false)
{
lblOutputInfo.Items.Add("*User Defined Role is unable!");
return -1023;
}
}
*/
//lblOutputInfo.Items.Add("[func IsUserDefRoleEnable]Temporarily unsupported");
int iPIN2Width = 0;
int iIsABCPinEnable = 0;
int iT9FunOn = 0;
string strTemp = "";
axCZKEM1.GetSysOption(GetMachineNumber(), "~PIN2Width", out strTemp);
iPIN2Width = Convert.ToInt32(strTemp);
axCZKEM1.GetSysOption(GetMachineNumber(), "~IsABCPinEnable", out strTemp);
iIsABCPinEnable = Convert.ToInt32(strTemp);
axCZKEM1.GetSysOption(GetMachineNumber(), "~T9FunOn", out strTemp);
iT9FunOn = Convert.ToInt32(strTemp);
/*
axCZKEM1.GetDeviceInfo(iMachineNumber, 76, ref iPIN2Width);
axCZKEM1.GetDeviceInfo(iMachineNumber, 77, ref iIsABCPinEnable);
axCZKEM1.GetDeviceInfo(iMachineNumber, 78, ref iT9FunOn);
*/
if (txtUserID.Text.Length > iPIN2Width)
{
lblOutputInfo.Items.Add("*User ID error! The max length is " + iPIN2Width.ToString());
return -1022;
}
if (iIsABCPinEnable == 0 || iT9FunOn == 0)
{
if (txtUserID.Text.Substring(0,1) == "0")
{
lblOutputInfo.Items.Add("*User ID error! The first letter can not be as 0");
return -1022;
}
foreach (char tempchar in txtUserID.Text.ToCharArray())
{
if (!(char.IsDigit(tempchar)))
{
lblOutputInfo.Items.Add("*User ID error! User ID only support digital");
return -1022;
}
}
}
int idwErrorCode = 0;
string sdwEnrollNumber = txtUserID.Text.Trim();
string sName = txtName.Text.Trim();
string sCardnumber = txtCardnumber.Text.Trim();
string sPassword = txtPassword.Text.Trim();
bool bEnabled = true;
/*if (iPrivilege == 4)
{
bEnabled = false;
iPrivilege = 0;
}
else
{
bEnabled = true;
}*/
axCZKEM1.EnableDevice(iMachineNumber, false);
axCZKEM1.SetStrCardNumber(sCardnumber);//Before you using function SetUserInfo,set the card number to make sure you can upload it to the device
if (axCZKEM1.SSR_SetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled))//upload the user's information(card number included)
{
lblOutputInfo.Items.Add("Set user information successfully");
}
else
{
axCZKEM1.GetLastError(ref idwErrorCode);
lblOutputInfo.Items.Add("*Operation failed,ErrorCode=" + idwErrorCode.ToString());
}
axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed
axCZKEM1.EnableDevice(iMachineNumber, true);
return 1;
}
But if I have two device what should I change here ? .
I tried to change iMachineNumber to make first device is 1 and second device is 2 but not working too !
Finally I found the solution : in the button connect to device need to insert the above code in loop for one device and then next device and so on .

Regarding Trigger email

I have a trigger code:
Trigger AutoEmailsending on Order (after update)
{
Map<Id,Order> Orderdetail = new Map<Id,Order>();
Set<Id> Accountid = new Set<Id>();
for(order or1 : Trigger.new)
{
if(or1.Status == 'Submitted' && (or1.Subtype__c =='Offer' || or1.Subtype__c =='ASP'))
{
Orderdetail.put(or1.id,or1);
Accountid.add (or1.accountid);
}
}
List<Attachment> Attachmentlst = [Select Id,
ParentId,
Name,
BodyLength,
Body,
Description
From Attachment
where ParentId=:Orderdetail.keyset()];
Map<String, Blob> resources = new Map<String, Blob>();
for(StaticResource resource:[SELECT Name, Body FROM StaticResource where Name IN ('TC_for_France','TC_for_Italy')])
{
resources.put(resource.Name, resource.Body);
}
User currentUser = [Select Id,Phone,name from User where Id =:System.UserInfo.getUserId()];
for (attachment attachmentlst1 : attachmentlst )
{
List<String> Toaddress = new List<String>();
List<String> CCaddress = new List<String>();
String Orderid = attachmentlst1.ParentId;
String ResourceName;
String TCname;
string strHtmlBody;
String Emailaddress = UserInfo.getUserEmail();
String CustomerServiceEmail = Order_Configuration__c.getInstance().Customer_Service_Email__c;
string SellingOfficePhone = Order_Configuration__c.getInstance().Selling_Office_Phone__c;
String OrderNumber = Orderdetail.get(attachmentlst1.ParentId).OrderNumber;
List<Messaging.Emailfileattachment> fileAttachments = new List <Messaging.Emailfileattachment>();
if(Accountmap.get(Orderdetail.get(attachmentlst1.ParentId).accountid).Email_Address__c != null)
{
Toaddress.add(Accountmap.get(Orderdetail.get(attachmentlst1.ParentId).accountid).Email_Address__c);
}
String Market = Accountmap.get(Orderdetail.get(attachmentlst1.ParentId).accountid).Market__c;
CCaddress.add(emailaddress);
if(CustomerServiceEmail !=null)
CCaddress.add(CustomerServiceEmail);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(Toaddress);
mail.setCcAddresses(CCaddress);
if(Orderdetail.get(attachmentlst1.ParentId).Subtype__c =='Offer' || Market=='FR')
{
mail.setSenderDisplayName('Trade Order-FR');
ResourceName = 'TC_for_France';
TCname = 'CONDITIONS_GENERALES_DEVENTE.pdf';
}
}
The trigger should send mail for the created user of the particular order,it should not send mail for last modified user of Particular order How to over come this Scenario,Dont need about the logic what i have to add lines in the trigger code

GWT: multiple column sorting

I am trying to do multiple columns sorting in my application .
Like i have firstname , last name columns
Right now , when i click on firstname header , it sorts as per firstname , when i click on lastname column it sorts as per lastname column..
what i need is when i click on firstname header it should sort on the basis of firstname and then if i click on lastname(with shift or any other option) header it should sort on the basis of both firstname and lastname , firstname as primary column and last name as sub sorting column
here is what i have now
private void sortTableUsers(List<UserDTO> userList){
ListDataProvider<UserDTO> dataProvider = new ListDataProvider<UserDTO>();
dataProvider.addDataDisplay(usersTable);
List<UserDTO> list = dataProvider.getList();
for (UserDTO UserDTO : userList) {
list.add(UserDTO);
}
final ListHandler<UserDTO> columnSortHandler = new ListHandler<UserDTO>(list);
columnSortHandler.setComparator(firstNameColumn,new Comparator<UserDTO>() {
public int compare(UserDTO o1,UserDTO o2) {
if (o1 == o2) {
return 0;
}
// Compare the firstname columns.
if (o1 != null) {
return (o2 != null) ? o1.getUser().getFirstName().compareTo(o2.getUser().getFirstName()) : 1;
}
return -1;
}
});
columnSortHandler.setComparator(lastNameColumn,new Comparator<UserDTO>() {
public int compare(UserDTO o1,UserDTO o2) {
if (o1 == o2) {
return 0;
}
// Compare the lastname columns.
if (o1 != null) {
return (o2 != null) ? o1.getUser().getLastName().compareTo(o2.getUser().getLastName()) : 1;
}
return -1;
}
});
usersTable.getColumnSortList().push(firstNameColumn);
usersTable.getColumnSortList().push(middleNameColumn);
}
Well, you need a different comparator for each column, the second comparator is the one that you need to change.
First it must sort for FirstName,and if the firstnames are equal, then go on and compare the last names too.
I'm not using your DTO, and i don't check for nulls, but it's the same thing, you get the idea
ArrayList<Map> list = new ArrayList<Map>();
ListHandler<Map> _sortHandler = new ListHandler<Map>(list);
Column columnDefinitionFirstName = null; // create your column first name
columnDefinitionFirstName.setSortable(true);
//
_sortHandler.setComparator(columnDefinitionFirstName, new Comparator<Map>()
{
public int compare(Map o1, Map o2)
{
int res = 0;
String object1 = (String) o1.get("FIRST_NAME");
String object2 = (String) o2.get("FIRST_NAME");
res = object1.compareTo(object2);
return res;
}
});
Column columnDefinitionLastName = null; // create your column last name
columnDefinitionLastName.setSortable(true);
_sortHandler.setComparator(columnDefinitionLastName, new Comparator<Map>()
{
public int compare(Map o1, Map o2)
{
int res = 0;
String object1 = (String) o1.get("FIRST_NAME");
String object2 = (String) o2.get("FIRST_NAME");
res = object1.compareTo(object2);
if(res == 0)
{
String object11 = (String) o1.get("LAST_NAME");
String object22 = (String) o2.get("LAST_NAME");
res = object11.compareTo(object22);
}
return res;
}
});

IPP Create Customers Never Appears in QBD

I am trying to add a customer and an invoice to QuickBooks, but neither appear. QuickBooks responds with this XML:
http://pastebin.com/PLsFbA6N
My code for adding customers and invoices appears to work and I see no errors:
public Customer BuildCustomerAddRq(JMAOrder _Order)
{
// Construct subordinate required records
//BuildStandardTermsAddRq("Web Order");
// build the main customer record
Customer QBCustomerAdd = new Customer();
var Customer = _Order.BillingAddress;
var Billing = _Order.BillingAddress;
PhysicalAddress phy = new PhysicalAddress();
// if the setting is that all orders go under the same customer ID, then push
// the address lines down one and store the customer name on address line 1.
if (_qboSettings.CustomerID == "SingleName")
{
QBCustomerAdd.DBAName = "Web Store";
QBCustomerAdd.Email = new EmailAddress[] { new EmailAddress() { Address = "info#webstore.com", Tag = new string[] { "Business" } } };
QBCustomerAdd.GivenName = "Web";
QBCustomerAdd.Active = true;
QBCustomerAdd.FamilyName = "Store";
phy.Line1 = "Web Store";
phy.Line2 = "";
phy.Tag = new string[] { "Billing" };
}
else
{
//QBCustomerAdd.DBAName = GetCustId(_Order);
QBCustomerAdd.Email = new EmailAddress[] { new EmailAddress() { Address = Customer.Email, Tag = new string[] { "Business" } } };
QBCustomerAdd.GivenName = Customer.FirstName;
QBCustomerAdd.Active = true;
QBCustomerAdd.FamilyName = Customer.LastName;
if (!String.IsNullOrEmpty(Customer.PhoneNumber))
{
QBCustomerAdd.Phone = new TelephoneNumber[] { new TelephoneNumber() { FreeFormNumber = Customer.PhoneNumber, Tag = new string[] { "Business" } } };
}
phy.Line1 = Billing.Address1;
if (!String.IsNullOrEmpty(Billing.Address2))
{
phy.Line2 = Billing.Address2;
}
phy.City = Billing.City;
if (Billing.RegionName != null)
{
phy.CountrySubDivisionCode = Billing.RegionName;
}
phy.PostalCode = Billing.PostalCode;
phy.Country = Billing.CountryName;
phy.Tag = new string[] { "Billing" };
}
// build add request and exit
QBCustomerAdd.Address = new PhysicalAddress[] { phy };
try
{
Customer cu = dataServices.Add(QBCustomerAdd);
return cu;
}
catch (Exception ex)
{
ErrorMessageDataSource.Insert(new ErrorMessage(MessageSeverity.Error, "QBO", String.Format("Error adding customer : {0}", ex.ToString())));
Customer ct = new Customer();
return ct;
}
When I run Intuit Sync Manager, I see no new customer or invoice. Is it possible to add new customers to QuickBooks?
It appears that the customer entered QuickBooks in error state. I needed to add the QBCustomerAdd.Name field.
CustomerQuery cq = new CustomerQuery();
cq.ErroredObjectsOnly = true;
var bList = cq.ExecuteQuery<Customer>(dataServices.ServiceContext);