///
/// </summary>
/// <param name="objType"></param>
/// <param name="type"></param>
/// <returns></returns>
AsyncCallback callback = new AsyncCallback(ProcessContact);//这是。netFrameWork提供的class,AsyncCallback是一个委托
UserBCard userBCard = new UserBCard() { UserId = Cfsns.Bll.User.CurrentUserId, NetAccessType = type };
iContact.BeginGetContact(callback, userBCard);//
static void ProcessContact(IAsyncResult ar)
{
UserBCard userBCard = (UserBCard)ar.AsyncState;
AsyncResult aResult = (AsyncResult)ar;
Cfsns.NetAccess.Model.ServiceBase.GetContactorListDelegate temp = (Cfsns.NetAccess.Model.ServiceBase.GetContactorListDelegate)aResult.AsyncDelegate;
List<IUserInfo> list = temp.EndInvoke(aResult);//
using (var conn = Cfsns.Common.Sql.Operate.Sns)
{
OperateSqlAnswer answer = Cfsns.Applications.Connection.Bll.BCard.SelectImportFromBind(userBCard.NetAccessType, userBCard.UserId, conn);
DataTable dt1 = answer.DataSource.ToSourceTable();
IEnumerable<IUserInfo> list2 = list.Where(model => (dt1.Select("BindUID='" + model.Uid + "'").Length == 0));
List<Cfsns.Common.Tools.Model.IModelBase> toSave = new List<Cfsns.Common.Tools.Model.IModelBase>();
foreach (IUserInfo iUserInfo in list2)
{
//编辑json位置
string userInfoJson = "{\"Name\":{\"LastName\":\"" + iUserInfo.RealName.ToEmptyString(string.Empty) + "\",\"FirstName\":\"\",\"AdditionalNames\":\"\"},\"NickName\":\"" + iUserInfo.NickName + "\",\"NoteText\":\"\",\"Organization\":\"" + iUserInfo.Organization.ToEmptyString(string.Empty) + "\"," +
"\"PhoneNumbers\":[{\"Number\":\"" + iUserInfo.Phone.ToEmptyString(string.Empty) + "\",\"NumberType\":8},{\"Number\":\"" + iUserInfo.Phone.ToEmptyString(string.Empty) + "\",\"NumberType\":32},{\"Number\":\"" + iUserInfo.Phone.ToEmptyString(string.Empty) + "\",\"NumberType\":64}],\"Photo\":\"" + iUserInfo.Logo.ToEmptyString(Cfsns.PagePath.Images.IUserDefaultLogo) + "\",\"Title\":\"" + iUserInfo.Title.ToEmptyString(string.Empty) + "\"," +
"\"WorkURL\":[{\"WebSite\":\"" + iUserInfo.WebSite.ToEmptyString(string.Empty) + "\",\"WebSiteType\":32}],\"EmailAddresses\":[{\"Email\":\"" + iUserInfo.Email.ToEmptyString(string.Empty) + "\",\"EmailType\":64}],\"BirthDate\":\"" + iUserInfo.BirthDay.ToEmptyString(string.Empty) + "\"," +
"\"Address\":[{\"AddressType\":64,\"Address\":\"" + iUserInfo.Address.ToEmptyString(string.Empty) + "\"}],\"Specialities\":\"\"}";
Model.BCard iBcard = new Model.BCard();
iBcard.CreatorId = userBCard.UserId;
iBcard.BindType = userBCard.NetAccessType;
iBcard.JsonContent = userInfoJson;
iBcard.BindUID = iUserInfo.Uid;
toSave.Add(iBcard);
}
OperateSqlAnswer answerBCard = Cfsns.Common.Sql.Operate.Save(toSave, conn);
if (answer.ErrMessage.ErrorFlag)
{
Cfsns.Bll.SiteLog.LogIt(answer.ErrMessage, 1);
}
}
}