[英]Best way to comapare Phone contacts with Server
我正在使用Corodva Contacts插件来获取本地电话联系人的功能,现在,我需要将其与数据库进行比较,我不在使用本地db,我正在使用sql server 2012,并且已经使用WEBAPI编写了一些后端代码。比较需要花费大量时间。 我需要一些替代解决方案。 请建议以下是我的代码。
//Javascript///
var phoneNumberCollection = new Array();
function showContacts() {
var options = new ContactFindOptions();
options.filter = "";
options.multiple = true;
options.desiredFields = [navigator.contacts.fieldType.id,navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name, navigator.contacts.fieldType.phoneNumbers];
options.hasPhoneNumber = true;
var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
navigator.contacts.find(fields, onSuccess, onError, options);
}
function onSuccess(contacts)
{
// here i have all contacts and i am pushing each number into "phoneNumberCollection" array//
}
function onError(err)
{
}
self.GetContactsData = function () {
self.PhoneNumberCollection = phoneNumberCollection;
jQuery.support.cors = true;
$.ajax({
type: "POST",
dataType: "json",
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({mobilecollection: self.PhoneNumberCollection,}),
url: Url + 'api/xxxxxx/xxxxxxxx',
success: function (data) {
self.items($.map(data, function (item) {
return new ContactsModel(item);
}));
},
error: function (err, type, httpStatus) {
}
})
}
//Web API
[HttpPost]
public IHttpActionResult GetContacts(JObject jsonData)
{
try
{
if (jsonData != null)
{
dynamic json = jsonData;
string[] mobilenumberCollection = json.mobilecollection.ToObject<string[]>();
//here i am getting Mobile collection and i am comparing each number with DB. i need some alternative sugggestion for this
var getContacts = CBFriends.getAllcontacts(mobilenumberCollection, deviceUID);
if (getAllContacts != null)
{
return Ok(getAllContacts);
}
else { return NotFound(); }
}
else {
return BadRequest();}
}
catch (Exception)
{ }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.