Missing customer name/address information in SquareUp Console using Square.Connect.Api - square-connect

We are creating a Square 2.0 transaction but when we login to our Square account, the customer name/address information is missing. We are creating a customer address object and populating the properties but they are not showing up in the Square console.
Here is our code:
using Square.Connect.Api;
using Square.Connect.Model;
using Square.Connect.Client;
private static bool RunCreditCardSquare(int? adminId, Models.ReservationReceivePaymentViewModel payment, Models.GuestViewModel guest, String ipaddress, String orderdescription, int reservationId, decimal amountDue)
{
Data.BigRigEntities db = new Data.BigRigEntities();
TransactionsApi transactionsApi = new TransactionsApi();
Square.Connect.Client.Configuration.Default.AccessToken = accessToken;
string uuid = Guid.NewGuid().ToString();
Money amount = new Money((long)amountDue * 100, Money.CurrencyEnum.USD);
// (https://docs.connect.squareup.com/payments/transactions/overview#mpt-overview).
ChargeRequest body = new ChargeRequest(AmountMoney: amount, IdempotencyKey: uuid, CardNonce: payment.CardNonce);
Square.Connect.Model.Address.CountryEnum GuestCountry = Square.Connect.Model.Address.CountryEnum.US;
body.ShippingAddress = new Square.Connect.Model.Address(guest.Address1, "", "", guest.City, "", "", "", "", "", "", guest.PostalCode, GuestCountry, guest.FirstName, guest.LastName, "");
body.BillingAddress = new Square.Connect.Model.Address(guest.Address1, "", "", guest.City, "", "", "", "", "", "", guest.PostalCode, GuestCountry, guest.FirstName, guest.LastName, "");
body.ReferenceId = reservationId.ToString() ;
body.CardNonce = payment.CardNonce;
body.BuyerEmailAddress = guest.EmailAddress;
body.Note = "Conf #:" + reservationId.ToString() + " - " + orderdescription;
var charged = false;
var transactionid = "";
var error = "";
decimal chargeamount = 0.0M;
try
{
var response = transactionsApi.Charge(LocationId, body);
transactionid = response.Transaction.Id;
chargeamount = (decimal) (response.Transaction.Tenders[0].AmountMoney.Amount/100) ;
charged = true;
}
catch (ApiException e)
{
error = e.Message;
}

The shipping address and billing address are only available via API, not the Square Dashboard. To see this information attached to a customer in the Dashboard you should Create a Customer first and then pass the customer_id along when you charge.

Related

How do I Attach an AdaptiveCardFromJson in a LUIS Bot C#?

I asked a similar question recently but wasn't specific enough. I see that there is some code with the AdaptiveCards NuGet Package to attach an AdaptiveCardFromJson and AdaptiveCardFromSDK, which under a the normal Microsoft Bot Model is available.
However, under the Microsoft LUIS Bot Model isn't an option, here's the code I have which returns an employee lookup result from a SQL DB Search:
[LuisIntent("Who_is_Employee")]
public async Task Who_is_EmployeeIntent(IDialogContext context, LuisResult result)
{
EntityRecommendation recommendation;
if (result.TryFindEntity("Communication.ContactName", out recommendation))
{
List<Employee> results = EmployeeService.FindEmployees(recommendation.Entity);
if (results.Count > 0)
{
string response = "";
foreach (Employee e in results)
{
string name = e.FullName;
string title = e.JobTitle;
response += " " + name + " " + title + "\n";
}
await context.PostAsync(response);
}
}
else
{
await context.PostAsync(" Sorry, I couldn't find who you were looking for.");
}
}
I would like that information to be returned as an AdaptiveCard, how do I achieve this?
Mark,
you need to craft your adaptive card either as json or using the SDK to create an instance of AdaptiveCard. Here is a great place to learn more about this.
Once you've crafted your card and have an instance of the AdaptiveCard class, you need to create a new message and attach the card to that message. The new message is what you'll post back to the user.
The code will look something like this
var card = AdaptiveCard.FromJson(<your json here>);
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
var myRespsonse = context.MakeMessage();
myRespsonse.Attachments.Add(attachment);
await context.PostAsync(myRespsonse, CancellationToken.None);
This was the code I ended up having to use to make this successful:
[LuisIntent("Who_is_Employee")]
public async Task Who_is_EmployeeIntent(IDialogContext context, LuisResult result)
{
EntityRecommendation recommendation;
if (result.TryFindEntity("Communication.ContactName", out recommendation))
{
List<Employee> results = EmployeeService.FindEmployees(recommendation.Entity);
if (results.Count > 0)
{
/* Single line per result */
/*
string response = "";
foreach (Employee e in results)
{
string name = e.FullName;
string title = e.JobTitle;
response += " " + name + " " + title + "\n";
}
await context.PostAsync(response);
*/
/* Adaptive card per result */
// Load json template
string physicalPath = System.Web.HttpContext.Current.Server.MapPath("../AdaptiveCards/EmployeeLookup.json");
string jsonTemplate = "";
using (StreamReader r = new StreamReader(physicalPath))
{
jsonTemplate = r.ReadToEnd();
}
var respsonse = context.MakeMessage();
foreach (Employee e in results)
{
string employeeJson = jsonTemplate;
employeeJson = employeeJson.Replace("{{FullName}}", e.FullName);
employeeJson = employeeJson.Replace("{{JobTitle}}", e.JobTitle);
employeeJson = employeeJson.Replace("{{Reference}}", e.Reference);
employeeJson = employeeJson.Replace("{{Phone}}", e.Phone);
employeeJson = employeeJson.Replace("{{Email}}", e.Email);
employeeJson = employeeJson.Replace("{{Mobile}}", e.Mobile);
AdaptiveCard card = AdaptiveCard.FromJson(employeeJson).Card;
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
respsonse.Attachments.Add(attachment);
}
await context.PostAsync(respsonse);
}
}
else
{
await context.PostAsync(" Sorry, I couldn't find who you were looking for.");
}
}

Silverlight some wcf problems

I have created a WCF Service which is called many times,
An example of a call
This Service will do a call to a Database. Lets say in my Client I do have a List with 200 Values. Every Value will match a Database Entry. Every Database Entry does have 10 Values. Now what I do is the following. I select some of the list entrys and call in a loop the WCF Service.
I have 2 Issues
First: the UI will hang for that time the WCF Calls are made
Second: The data will come back step by step, how can I collect them and send it back when all calls are completed?
Please excuse any typos I made, my english is not the best.
Here is my source code
[ServiceContract(Namespace = "")]
[SilverlightFaultBehavior]
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerCall)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[OperationContract]
public List<string> GetData(string sWert1, string sWert2)
{
List<string> realtimanswer = new List<string>();
string applicationPath = HostingEnvironment.MapPath("~/Configuration");
cIniReader _ini = new cIniReader(applicationPath + #"\config.ini");
string connectionString = _ini.ReadString("Database", "ConnectionString", "");
OracleConnection connection = new OracleConnection();
connection.ConnectionString = connectionString;
try
{
connection.Open();
OracleCommand cmd = connection.CreateCommand();
cmd = new OracleCommand("GETDATA", connection);
cmd.Parameters.Clear();
OracleParameter param1 = new OracleParameter("PI_Wert1", OracleDbType.Varchar2);
OracleParameter param2 = new OracleParameter("PI_Wert2", OracleDbType.Varchar2);
OracleParameter param3 = new OracleParameter("PO_Wert3", OracleDbType.Int16);
OracleParameter param4 = new OracleParameter("PO_Wert3", OracleDbType.Int16);
OracleParameter param5 = new OracleParameter("PO_Wert4", OracleDbType.Int16);
param1.Value = sWert1;
param2.Value = sWert2;
param1.Direction = System.Data.ParameterDirection.Input;
param1.Size = 4096;
param2.Direction = System.Data.ParameterDirection.Input;
param2.Size = 4096;
param3.Direction = System.Data.ParameterDirection.Output;
param3.Size = 4096;
param4.Direction = System.Data.ParameterDirection.Output;
param4.Size = 4096;
param5.Direction = System.Data.ParameterDirection.Output;
param5.Size = 4096;
cmd.Parameters.Add(param1);
cmd.Parameters.Add(param2);
cmd.Parameters.Add(param3);
cmd.Parameters.Add(param4);
cmd.Parameters.Add(param5);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
//cmd.CommandTimeout = 30;
int test = cmd.ExecuteNonQuery();
string returnCode = cmd.Parameters[17 - 1].Value.ToString();
if (returnCode == "OK")
{
string sErg1 = cmd.Parameters[3 - 1].Value.ToString();
realtimanswer.Add(sErg1);
string sErg2 = cmd.Parameters[4 - 1].Value.ToString();
realtimanswer.Add(sErg2);
string sErg3 = cmd.Parameters[5 - 1].Value.ToString();
realtimanswer.Add(sErg3);
string sErg4 = cmd.Parameters[6 - 1].Value.ToString();
realtimanswer.Add(sErg4);
string sErg5 = cmd.Parameters[7 - 1].Value.ToString();
realtimanswer.Add(sErg5);
}
}
catch (Exception exp)
{
cDebugLog.Log("Error in Function: GetData " + exp.Message + " StackTrace: " + exp.StackTrace);
connection.Close();
}
connection.Close();
return realtimanswer;
}
}
I call this with this Code
void Button1_Click(object sender, EventArgs e)
{
busyRealTimeViewPage.IsBusy = true;
try
{
string url = Application.Current.Host.Source.AbsoluteUri;
url = url.Replace("/ClientBin/ICWeb.xap", "/DBService.svc");
var proxy_GetRealTime_DBService = new DBServiceReference.DBServiceClient();
proxy_GetRealTime_DBService.Endpoint.Address = new System.ServiceModel.EndpointAddress(url);
proxy_GetRealTime_DBService.GetDataCompleted += new EventHandler<DBServiceReference.GetDataCompletedEventArgs>(proxy_GetRealTime_DBService_GetDataCompleted);
for (int i = 0; i < lstRealtime.Items.Count; i++)
{
if ((lstRealtim.ItemsSource as ObservableCollection<ListOfData>)[i].IsSelected == true)
{
object[] w_toread = new object[5];
string sWrk = (lstMappedWorkgroups.ItemsSource as ObservableCollection<ListOfWorkgroups>)[i].Content;
w_toread[0] = sDat;
w_toread[1] = sDat + "_DE";
w_toread[2] = sDat + "_FR";
proxy_GetRealTime_DBService.GetDataAsync(w_toread[1].ToString(), "current", w_toread[1]);
proxy_GetRealTime_DBService.GetDataAsync(w_toread[2].ToString(), "current", w_toread[2]);
}
}
}
catch (Exception exp)
{
cDebugLog logger = new cDebugLog();
logger.LogMessage("Error in Function: Button1_Click " + exp.Message + " StackTrace: " + exp.StackTrace);
}
and now here is the rest of it
void proxy_GetRealTime_DBService_GetDataCompleted(object sender, DBServiceReference.GetMarqueeDataCompletedEventArgs e)
{
try
{
string help = e.UserState.ToString();
string sWrktoView = cStringFunctions.Left(e.UserState.ToString(), help.Length - 3);
// string sWrktoView = (lstMappedWorkgroups.ItemsSource as ObservableCollection<ListOfWorkgroups>)[i].Content;
string sWrktoViewDE = sWrktoView + "_DE";
string sWrktoViewFR = sWrktoView + "_FR";
if ((sWrktoViewDE == e.UserState.ToString()) || (sWrktoViewFR == e.UserState.ToString()))
{
if (!(toView.Any(wrk => wrk.Workgroup == sWrktoView)))
{
if (sWrktoViewDE == e.UserState.ToString())
{
toView.Add(new RealtTime(sWrktoView, sWrktoViewDE, e.Result[0], e.Result[1], e.Result[2], e.Result[3], e.Result[4], e.Result[5], e.Result[6], e.Result[7], e.Result[8], e.Result[9], e.Result[10], e.Result[11], e.Result[12], e.Result[13], sWrktoViewFR, "", "", "", "", "", "", "", "", "", "", "", "", "", ""));
}
if (sWrktoViewFR == e.UserState.ToString())
{
toView.Add(new RealtTime(sWrktoView, sWrktoViewDE, "", "", "", "", "", "", "", "", "", "", "", "", "", "", sWrktoViewFR, e.Result[0], e.Result[1], e.Result[2], e.Result[3], e.Result[4], e.Result[5], e.Result[6], e.Result[7], e.Result[8], e.Result[9], e.Result[10], e.Result[11], e.Result[12], e.Result[13]));
}
}
}
if (sWrktoViewFR == e.UserState.ToString())
{
var wrkFR = toView.FirstOrDefault(x => x.WorkgroupFR == sWrktoViewFR);
if (wrkFR != null)
{
wrkFR.WorkgroupFR = sWrktoViewFR;
wrkFR.erg1FR = e.Result[0];
wrkFR.erg2FR = e.Result[1];
wrkFR.erg3FR = e.Result[2];
wrkFR.erg4FR = e.Result[3];
wrkFR.erg5FR = e.Result[4];
// fill with other data
}
}
if (sWrktoViewDE == e.UserState.ToString())
{
var wrkDE = toView.FirstOrDefault(x => x.WorkgroupDE == sWrktoViewDE);
if (wrkDE != null)
{
wrkDE.WorkgroupDE = sWrktoViewDE;
wrkDE.erg1DE = e.Result[0];
wrkDE.erg2DE = e.Result[1];
wrkDE.erg3DE = e.Result[2];
wrkDE.erg4DE = e.Result[3];
wrkDE.erg5DE = e.Result[4];
// fill with other Data
}
}
dgridRealTimeView.ItemsSource = null;
dgridRealTimeView.ItemsSource = toView;
busyRealTimeViewPage.IsBusy = false;
}
catch (Exception exp)
{
cDebugLog logger = new cDebugLog();
logger.LogMessage("Methode: proxy_GetRealTime_DBService_GetDataCompleted: " + exp.Message + " StackTrace: " + exp.StackTrace);
}
}
I hope someone can help me out.
Regards
Martin
This call
for (int i = 0; i < lstRealtime.Items.Count; i++)
can take a long time if the there are a lot of items in the list.
You should consider creating a new method on the WCF Service to do all the operations and then returning the result.
public List<string> GetData(string[] sWert1, string[] sWert2)
{
}

Scaffold/Generate an object's properties in an initializer

Does anyone know how to "scaffold" or "generate" a constructor block for all of an objects properties? I've got VS2010 with Resharper and am looking to generate something like:
public Customer CustomerB = new Customer
{
firstName = "",
middleName = "",
lastName = "",
additionalPhone = "0",
address1 = "",
address2 = "",
birthDate = new DateTime(),
cellPhone = "",
city = "",
driverLicenseNumber = "",
driverLicenseState = "",
emailAddress = "",
country = "",
fax = "",
grossIncome = 0,
education = null,
leadRequest = null
};
Where I can then double back and fill in the blanks so to speak. Everything i've found is all DatabaseFirst and Getter/Setters Class Properties...
I think it is not possible to generate object initializer for all properties with VS and ReSharper. You need to press Ctrl+Space for every property selection.

How to Get the Array of data from json array using WEB API in mvc3?

I have create web services using Web Api in mvc3,in this i want get the data from json. Json Result like this
{"order": {
"locationid": "1",
"deviceidentifier": "XXXXXXXXXXXXXXXXXXXXXXX",
"ordercontactname": "XXXXXXXXXXXXXXXXXXXXXXX",
"ordercontactphone": "XXXXXXXXXXXXXXXXXXXXXXX",
"ordercontactemail": "XXXXXXXXXXXXXXXXXXXXXXX",
"shipaddress1": "17 Brookfield",
"shipaddress2": "Suite 17",
"shipcity": "Irvine",
"shipstate": "CA",
"shipzipcode": "92604",
"shipphonenumber": "9493742114",
"shipemail": "Info#mail.com",
"shipmethod": "pickup",
"billingfirstname":"Tester",
"billinglastname":"test",
"billingmiddleinitial":"S",
"billingaddress":"field",
"billingcity":"Sample",
"billingstate":"SM",
"billingzipcode":"523201",
"billingphonenumber": "1234567891",
"billingemail": "",
"paytype":"creditcard",
"amount"="10.50",
"acctno"="123456789987",
"exproute"="0114",
"coupon"="X2323",
"notes"="",
"items": [
{"itemid":"1","quantity":"1","price":"2.5","notes":"make it spicy"},
{"itemid":"4","quantity":"2","price":"4.5","notes":""},
{"itemid":"3","quantity":"1","price":"1.5","notes":""}
]
}}
for this i have create Poco class and i get Order data using poco class, but i can't get the items array data how can i get items data
Here is my code
public List<Message> PlaceOrder(PlaceOrder order)
{
// List<PlaceOrder> entities = (List<PlaceOrder>)JavaScriptConvert.DeserializeObject(json, typeof(List<PlaceOrder>));
int PayOrderID = 0;
List<Message> Result;
Result = new List<Message>();
try
{
Order objOrder = new Order();
PayHist objPayhis = new PayHist();
objOrder.LocationId = order.LocationId;
objOrder.DeviceIdentifier = order.DeviceIdentifier;
objOrder.OrderContactName = order.OrderContactName;
objOrder.OrderContactPhone = order.OrderContactPhone;
objOrder.OrderContactEmail = order.OrderContactEmail;
string guid = Guid.NewGuid().ToString();
objOrder.ShipMethod = order.ShipMethod;
objOrder.ShippingDate = Convert.ToDateTime(order.PickupDate);
objOrder.OrderGuid = guid;
entities.AddObject("Orders", objOrder);
entities.SaveChanges();
int orderId = objOrder.OrderId;
PayOrderID = orderId;
objPayhis.OrderId = orderId;
objPayhis.PayType = order.ShipMethod;
objPayhis.Amount = float.Parse(order.Amount);
entities.AddObject("PayHists", objPayhis);
entities.SaveChanges();
JavaScriptSerializer ser = new JavaScriptSerializer();
// Order foo = ser.Deserialize<Order>(json);
Message objMessage = new Message();
objMessage.Messagevalue = "Sucess";
Result.Add(objMessage);
return Result;
}
Please help me..
Try this (you need to fix your Json by replacing the "=" signs by ":" signs" before):
[WebInvoke(Method = "POST", UriTemplate = "")]
public HttpResponseMessage Add(JsonValue json) {
JsonValue order = json["order"];
JsonArray items = (JsonArray) order["items"];
JsonValue item1 = items[0];
var notes1 = item1["notes"];
return new HttpResponseMessage(HttpStatusCode.OK);
}

How do I retrieve global contacts with Exchange Web Services (EWS)?

I am using EWS and wish to obtain the global address list from exchange for the company. I know how to retrieve the personal contact list.
All the samples in the API documentation deal with updating user information but not specifically how to retrieve them.
I've even tried the following to list the folders but it doesn't yeild the correct results.
private static void ListFolder(ExchangeService svc, FolderId parent, int depth) {
string s;
foreach (var v in svc.FindFolders(parent, new FolderView(int.MaxValue))) {
Folder f = v as Folder;
if (f != null) {
s = String.Format("[{0}]", f.DisplayName);
Console.WriteLine(s.PadLeft(s.Length + (depth * 2)));
ListFolder(svc, f.Id, depth + 1);
try {
foreach (Item i in f.FindItems(new ItemView(20))) {
Console.WriteLine(
i.Subject.PadLeft(i.Subject.Length + ((depth + 1) * 2)));
}
} catch (Exception) {
}
}
}
}
While the question has already been raised (How to get contact list from Exchange Server?) this question deals specifically with using EWS to get the global address list while this question asks for advice on a general level.
you may got ItemType objects in a specifiedfolder with the code snippet below
and then cast ItemType objects to ContactItemType (for contact objects) ....
/// <summary>
/// gets list of ItemType objects with maxreturncriteria specicification
/// </summary>
/// <param name="esb">ExchangeServiceBinding object</param>
/// <param name="folder">FolderIdType to get items inside</param>
/// <param name="maxEntriesReturned">the max count of items to return</param>
public static List<ItemType> FindItems(ExchangeServiceBinding esb, FolderIdType folder, int maxEntriesReturned)
{
List<ItemType> returnItems = new List<ItemType>();
// Form the FindItem request
FindItemType request = new FindItemType();
request.Traversal = ItemQueryTraversalType.Shallow;
request.ItemShape = new ItemResponseShapeType();
request.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;
request.ParentFolderIds = new FolderIdType[] { folder };
IndexedPageViewType indexedPageView = new IndexedPageViewType();
indexedPageView.BasePoint = IndexBasePointType.Beginning;
indexedPageView.Offset = 0;
indexedPageView.MaxEntriesReturned = 100;
indexedPageView.MaxEntriesReturnedSpecified = true;
request.Item = indexedPageView;
FindItemResponseType response = esb.FindItem(request);
foreach (FindItemResponseMessageType firmtMessage in response.ResponseMessages.Items)
{
if (firmtMessage.ResponseClass == ResponseClassType.Success)
{
if (firmtMessage.RootFolder.TotalItemsInView > 0)
foreach (ItemType item in ((ArrayOfRealItemsType)firmtMessage.RootFolder.Item).Items)
returnItems.Add(item);
//Console.WriteLine(item.GetType().Name + ": " + item.Subject + ", " + item.DateTimeReceived.Date.ToString("dd/MM/yyyy"));
}
else
{
//handle error log here
}
}
return returnItems;
}
I just did a similiar thing. However, I was unable to get the list of contacts via Exchange since that only gets users that have mailboxes, and not necessarily all users or groups. I eventually ended up getting all the users via AD
here is code to get all the contacts in AD. All you need is the folderID of the global address list which can be gotten from using the ADSI.msc tool on your AD server and browsing to the Global address list folder, look at properties and grab the value of the "purported search". In my system the searchPath for the global address list is"(&(objectClass=user)(objectCategory=person)(mailNickname=)(msExchHomeServerName=))"
public List<ListItem> SearchAD(string keyword, XmlDocument valueXml)
{
List<ListItem> ewsItems = new List<ListItem>();
using (DirectoryEntry ad = Utils.GetNewDirectoryEntry("LDAP://yourdomain.com"))
{
Trace.Info("searcherをつくる");
using (DirectorySearcher searcher = new DirectorySearcher(ad))
{
if (this.EnableSizeLimit)
{
searcher.SizeLimit = GetMaxResultCount();
if (Utils.maxResultsCount > 1000)
{
searcher.PageSize = 100;
}
}
else
{
searcher.SizeLimit = 1000;
searcher.PageSize = 10;
}
string sisya = Utils.DecodeXml(valueXml.SelectSingleNode("Folder/SearchPath").InnerText); //this is the folder to grab your contacts from. In your case Global Address list
//Container
if(String.IsNullOrEmpty(sisya))
{
return null;
}
keyword = Utils.EncodeLdap(keyword);
string text = Utils.DecodeXml(valueXml.SelectSingleNode("Folder/Text").InnerText);
searcher.Filter = this.CreateFilter(keyword, sisya);
searcher.Sort = new SortOption("DisplayName", System.DirectoryServices.SortDirection.Ascending);
//一つのPropertyをロードすると、全Propertyを取らないようになる
searcher.PropertiesToLoad.Add("SAMAccountName"); //どのPropertyでもいい。
SearchResultCollection searchResults = searcher.FindAll();
foreach (SearchResult searchResult in searchResults)
{
//ListItem contact = null;
using (DirectoryEntry userEntry = searchResult.GetDirectoryEntry())
{
try
{
string schemaClassName = userEntry.SchemaClassName;
switch (schemaClassName)
{
case "user":
case "contact":
string fname = userEntry.Properties["GivenName"].Value == null ? "" : userEntry.Properties["GivenName"].Value.ToString();
string lname = userEntry.Properties["sn"].Value == null ? "" : userEntry.Properties["sn"].Value.ToString();
string dname = userEntry.Properties["DisplayName"][0] == null ? lname + " " + fname : userEntry.Properties["DisplayName"][0].ToString();
//No Mail address
if ((userEntry.Properties["mail"] != null) && (userEntry.Properties["mail"].Count > 0))
{
string sAMAccountName = "";
if(userEntry.Properties["SAMAccountName"].Value != null){
sAMAccountName = userEntry.Properties["SAMAccountName"].Value.ToString();
}
else{
sAMAccountName = userEntry.Properties["cn"].Value.ToString();
}
string contactXml = Utils.ListViewXml(sAMAccountName, UserType.User, Utils.UserXml(fname, lname, userEntry.Properties["mail"].Value.ToString(), dname, null), ServerType.Ad);
ewsItems.Add(new ListItem(dname + "<" + userEntry.Properties["mail"].Value.ToString() + ">", contactXml));
}
else
{
ListItem contact = new ListItem(dname, null);
contact.Enabled = false;
ewsItems.Add(contact);
Trace.Info("追加できないユーザ: " + searchResult.Path);
}
break;
case "group":
ewsItems.Add(new ListItem(userEntry.Properties["DisplayName"].Value.ToString(), Utils.ListViewXml(userEntry.Properties["SAMAccountName"].Value.ToString(), UserType.Group, null, ServerType.Ad)));
break;
default:
userEntry.Properties["SAMAccountName"].Value.ToString());
ewsItems.Add(new ListItem(userEntry.Properties["name"].Value.ToString(), Utils.ListViewXml(userEntry.Properties["SAMAccountName"].Value.ToString(), UserType.Group, null, ServerType.Ad)));
break;
}
}
catch (Exception ex)
{
Trace.Error("User data取得失敗", ex);
}
}
}
searchResults.Dispose();
}
}
return ewsItems;
}

Resources