I am fetching Vendor payment data from Netsuite via SOAP API in .Net. Unable to get the Internal Id in the result. My code as below
TransactionSearchAdvanced TSA = new TransactionSearchAdvanced();
TSA.savedSearchId = "2218";
TransactionSearch TS = new TransactionSearch();
TransactionSearchBasic TSB = new TransactionSearchBasic();
#region Setting From & To Period
DateTime theSearchStartDate = System.DateTime.Today.AddDays(-365);
DateTime theSearchFinishDate = System.DateTime.Today;
SearchDateField theDTSearch = new SearchDateField();
theDTSearch.operatorSpecified = true;
theDTSearch.#operator = SearchDateFieldOperator.within;
theDTSearch.searchValue2Specified = true;
theDTSearch.searchValueSpecified = true;
theDTSearch.searchValue = theSearchStartDate;
theDTSearch.searchValue2 = theSearchFinishDate;
#endregion
TSB.tranDate = theDTSearch;
TS.basic = TSB;
TSA.criteria = TS;
SearchResult SR = NService.search(TSA);
Related
I have an issue about webapi2 and Authorization.
If I call web api with the old .Net 2.0 client (WebClient) there are not problems and the code is here:
//old 2.0 client
using (WebClient oldClient = new WebClient())
{
oldClient.UseDefaultCredentials = true;
oldClient.Credentials = CredentialCache.DefaultCredentials;
oldClient.Headers[HttpRequestHeader.ContentType] = "application/json";
oldClient.Headers[HttpRequestHeader.Accept] = "application/json";
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
javaScriptSerializer.MaxJsonLength = 2147483644;
ASCIIEncoding encoding = new ASCIIEncoding();
string objectToSendJson = javaScriptSerializer.Serialize(objectToSend);
byte[] objectToSendByte = encoding.GetBytes(objectToSendJson);
byte[] serviceOutput = oldClient.UploadData(uri + actionController, "POST", objectToSendByte);
string jsonStr = Encoding.UTF8.GetString(serviceOutput);
toReturn = JsonConvert.DeserializeObject<T>(jsonStr);
return toReturn;
}
but if I use the new 4.5 HttpClient WebApi return me Unauthorized
and the code is here:
HttpClientHandler httpWebApiClienthandler = new HttpClientHandler
{
UseDefaultCredentials = true,
Credentials = CredentialCache.DefaultCredentials,
};
System.Net.Http.HttpClient newHttpClient = new System.Net.Http.HttpClient(httpWebApiClienthandler)
//new 4.5 client
JsonMediaTypeFormatter jsonFormatter = new JsonMediaTypeFormatter();
if (objectToSend == null)
throw new Exception("object to send is null");
HttpContent httpContent = new ObjectContent<object>(objectToSend, jsonFormatter);
httpContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
response = newHttpClient.PostAsync(actionController, httpContent).Result;
Any help is highly appreciated.
I'm currently trying to create a popup like this:
http://i.stack.imgur.com/faqQA.png
But i don't know where to start.
Is it a Webresource? If yes is it done via JScript or ASPX?
Recheck my article that describes creation of own dialog windows step-by-step - http://a33ik.blogspot.com/2014/06/step-by-step-creating-dialog-windows.html
You would want an iFrame for this
public IOrganizationService GetCRMService()
{
string Username = "**********";
string password = "**********";
IOrganizationService _service;
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = Username;
credentials.UserName.Password = password;
credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Uri serviceUri = new Uri("https://*******.api.crm**.dynamics.com/XRMServices/2011/Organization.svc");
Uri HomeRealm = null;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, HomeRealm, credentials, null);
{
_service = (IOrganizationService)proxy;
}
return _service;
}<!---- Modal Gridvview popup for Dynamic crm -------!>protected void Page_Load(object sender, EventArgs e)
{
IOrganizationService _service = GetCRMService();
QueryExpression Query = new QueryExpression("contact");
Query.ColumnSet.AllColumns = true;
filtering conditions
Query.Criteria.AddCondition("fullname", ConditionOperator.NotEqual, "xxx");
Query.Criteria.AddCondition("emailaddress1", ConditionOperator.NotEqual, "xxx");
Query.Criteria.AddCondition("telephone1", ConditionOperator.NotEqual, "xxx");
Query.Criteria.AddCondition("address1_line2", ConditionOperator.NotEqual, "xxx");
EntityCollection collection = _service.RetrieveMultiple(Query);
DataTable dt = new DataTable();
dt.Columns.Add("fullname");
dt.Columns.Add("emailaddress1");
dt.Columns.Add("telephone1");
dt.Columns.Add("address1_line2");
dt.Columns.Add("");
foreach (Entity entity in collection.Entities)
{
DataRow dr = dt.NewRow();
dr["fullname"] = entity.Attributes["fullname"].ToString();
dr["emailaddress1"] = entity.Attributes["emailaddress1"].ToString();
dr["telephone1"] = entity.Attributes["telephone1"].ToString();
dr["address1_line2"] = entity.Attributes["address1_line2"].ToString();
dt.Rows.Add(dr);
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
How to send successfully push notification of APNS in production
When I use in development, it's work.
But use in production,it appear error.
My app is in App Store, so p12 file is production.
My server side is asp.net.
asp.net code:
//key
//True if you are using sandbox certificate, or false if using production
bool sandbox = false;
string p12File = "InspirePass.p12";
string p12Filename = System.IO.Path.Combine(MapPath("~"), p12File);
string p12FilePassword = "xxxxxxxx";
NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1);
//send
foreach (DataRow eachUserRow in userTable.Rows)
{
//Create a new notification to send
if (eachUserRow["pushStatus"].ToString() == "N")
{ //////no repeat
Notification alertNotification = new Notification(eachUserRow["device_token"].ToString());
alertNotification.Payload.Alert.Body = eachUserRow["menuMessage"].ToString() + "(" + eachUserRow["menuTitle"].ToString() + ")";
alertNotification.Payload.Sound = "default";
alertNotification.Payload.Badge = selectEventPush_IOS.Rows.Count + selectSignPush_IOS.Rows.Count;
// alertNotification.Payload. = 1;
string[] items = new string[1];
string[] items2 = new string[1];
if (userTable.Rows.Count > 0)
{
items[0] = Convert.ToString(selectEventPush_IOS.Rows.Count);
items2[0] = Convert.ToString(selectSignPush_IOS.Rows.Count);
}
alertNotification.Payload.CustomItems.Add("items2", items2);
alertNotification.Payload.CustomItems.Add("items", items);
//Queue the notification to be sent
if (service.QueueNotification(alertNotification))
result = 1;
else
result = -1;
///////change chat_document/pushStatus=Y
string Identifier = "";
Identifier = eachUserRow["Identifier"].ToString();
DataRow yespushuser = DBiphone.UpdatedPushStatus(Identifier);
}
}//end if
service.Close();
service.Dispose();
Response.Write(result.ToString());
I can get email attachments from exchange server 2003 (MAPI.Attachment). How can I save the pdf attachment file as binary into the database?
Here's some code to understand better. For testing purposes I am saving the attachment pdf file into a filesystem. How ca I go about saving that into a database? Or how can I convert that into a byte array? Also, how can I get the size of the file since I need that when I declare the byte array "fileData"...
byte[] fileData = new byte[10000];
string[] fileTokens = new string[2];
string[] result = new string[3];
message.Unread = false;
emailSubject = message.Subject.ToString();
emailBody = message.Text.ToString();
MAPI.Attachments test = null;
test = (MAPI.Attachments)message.Attachments;
int attachmentCount = (int)test.Count;
for (int loopCounter = 1; loopCounter <= attachmentCount; loopCounter++)
{
MAPI.Attachment test2 = (MAPI.Attachment)test.get_Item(loopCounter);
bool temp = (test2.Name.ToString().Contains(".pdf") && test2.Name.ToString().IndexOf('Q') == 0);
if (test2.Name.ToString().Contains(".pdf") && test2.Name.ToString().IndexOf('Q') == 0)
{
//test2.ReadFromFile(fileData);
test2.WriteToFile("d:\\data\\" + test2.Name);
PDFParser pdfParser = new PDFParser();
pdfParser.ReadPdfFile("d:\\data\\" + test2.Name, result);
sentTime = (DateTime)message.TimeSent;
string fileName = (string)test2.Name;
fileTokens = fileName.Split('.');
}
RequestHistorySet historySet = new RequestHistorySet(1, sentTime, fileData, fileTokens[1]);
bool res = historySet.Update();
message.Unread = false;
message.Update();
And here's the Update function from historySet Class
public bool Update()
{
using (SqlConnection mySqlConnection = ...))
{
// Set up the Command object
SqlCommand myCommand = new SqlCommand("CONNECTION STRING..", mySqlConnection);
// Set up the OriginalName parameter
SqlParameter prmId = new SqlParameter("#id", SqlDbType.Int);
prmId.Value = id;
myCommand.Parameters.Add(prmId);
SqlParameter prmRequsetDate = new SqlParameter("#requestDate", SqlDbType.DateTime);
prmRequsetDate.Value = requestDate;
myCommand.Parameters.Add(prmRequsetDate);
// Set up the FileData parameter
SqlParameter prmFileData = new SqlParameter("#uplodedQuote_File ", SqlDbType.VarBinary);
prmFileData.Value = fileData;
prmFileData.Size = fileData.Length;
myCommand.Parameters.Add(prmFileData);
SqlParameter prmFileExtension = new SqlParameter("#uplodedQuote_Ext", SqlDbType.NVarChar);
prmFileExtension.Value = fileExtension;
myCommand.Parameters.Add(prmFileExtension);
// Execute the command, and clean up.
mySqlConnection.Open();
bool result = myCommand.ExecuteNonQuery() > 0;
mySqlConnection.Close();
return result;
}
}
As of now this is what I have done. I save it to a filesystem and then read from there.
test2.WriteToFile("d:\\data\\" + test2.Name);
fileData = FileToByteArray("d:\\data\\" + test2.Name);
PDFParser pdfParser = new PDFParser();
pdfParser.ReadPdfFile("d:\\data\\" + test2.Name, result);
TryToDelete("d:\\data\\" + test2.Name);
sentTime = (DateTime)message.TimeSent;
string fileName = (string)test2.Name;
fileTokens = fileName.Split('.');
historySet = new RequestHistorySet(1, sentTime, fileData, fileTokens[1]);
Is it possible to send out an email with multiple email addresses specified in the "to" field? I have it working for single recipients, but can't figure out how to send to multiple, here is my current code for emailing a single user:
public static void sendCRMNotification(string userGuid, string emailSubject, string emailBody, string recipientType)
{
//Set up CRM service
crmService crmservice = GetCrmService();
// Create a FROM activity party for the email.
activityparty fromParty = new activityparty();
fromParty.partyid = new Lookup();
fromParty.partyid.type = EntityName.systemuser.ToString();
fromParty.partyid.Value = new Guid(/*guid of sending user*/);
//Create a TO activity party for email
activityparty toParty = new activityparty();
toParty.partyid = new Lookup();
toParty.partyid.type = EntityName.contact.ToString();
toParty.partyid.Value = new Guid(userGuid);
//Create a new email
email emailInstance = new email();
//set email parameters
emailInstance.from = new activityparty[] { fromParty };
emailInstance.to = new activityparty[] { toParty };
emailInstance.subject = emailSubject;
emailInstance.description = emailBody;
//Create a GUId for the email
Guid emailId = crmservice.Create(emailInstance);
//Create a SendEmailRequest
SendEmailRequest request = new SendEmailRequest();
request.EmailId = emailId;
request.IssueSend = true;
request.TrackingToken = "";
//Execute request
crmservice.Execute(request);
}
This is what I have done in the past. Create the array in the beginning before you set it to the email property.
activityparty[] toParty = new activityparty[2];
toParty[0] = new activityparty();
toParty[0].partyid = new Lookup(EntityName.contact.ToString(), userGuid);
toParty[1] = new activityparty();
toParty[1].partyid = new Lookup(EntityName.contact.ToString(), anotherUserGuid);
emailMessage.to = toParty;