Alexa.Net cannot create a reminder: throws error - c#

While using the code base from the project to create a reminder, I get the following error:
Error at Alexa.NET.Response.RemindersClient.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AlexaWebAPI.Controllers.ReminderController.d__0.MoveNext()
Sample code I am using:
try
{
var reminder = new Reminder
{
RequestTime = DateTime.UtcNow,
Trigger = new RelativeTrigger(12 * 60 * 60),
AlertInformation = new AlertInformation(new[] {new SpokenContent("it's a test", "en-GB") }),
PushNotification = PushNotification.Disabled
};
var client = new RemindersClient(RemindersClient.ReminderDomain,input.Session.User.AccessToken);
var alertDetail = await client.Create(reminder);
Trace.TraceInformation(alertDetail.AlertToken);
return ResponseBuilder.Tell($"I would to create a reminder on ${date} .");
}
catch(Exception ex)
{
Trace.TraceError(ex.StackTrace);
return ResponseBuilder.Ask("Some error occured while creating reminder", null);
}

Related

Failed to save few order in SQL Server database when multiple user post order through ASP.NET API 2 at the same time

I have a web application which runs in IIS 7 and using SQL Server 2014 & web API2 in SOLID principle.
I have a Order Table which contains 51 column, where I save orders details from multiple client.
Firstly i validate the order details(duplicate,order id existence etc) and then I save it to the same table.
My MVC controller are decorated with Asynchronous type.
I am using transaction & logging in stored procedure where I wrote Insert query.
I googled the same issue,but a bit confused who to implement a quick solution for this.
My questions are:
What should be the right System design to handle such concurrent order request.
How should I design my database tables or stored procedure so that order can be saved successfully.
How should I optimize or introduce any new coding technique to solve such concurrent traffic at least 500 orders per sec.
I would be very glad if somebody can help me out with an example.
Error occurred on 10/5/2020 10:43:12.968, at bookingController/CacheOrderDetails Action
System.InvalidOperationException: BeginExecuteReader requires an open and available
Connection. The connection's current state is connecting.
at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__174_0(Task`1 result)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Dapper.SqlMapper.<QueryAsync>d__23`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at DAL.DbHelper.<StoredProcWithParamsAsync>d__20`1.MoveNext() in D:\SamWorkspace\DMS_Live_28\DAL\DbHelper.cs:line 303
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Repository.Impl.ApiIntegration.<CacheOrderDetails>d__1.MoveNext() in D:\SamWorkspace\DMS_Live_28\Repository\Impl\ApiIntegration.cs:line 25
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at bookingController.<CacheOrderDetails>d__59.MoveNext() in c:\DMS\LIVE_CODE\DmsLive_PublishCode\App_Code\api\bookingController.cs:line 1357
ActionMethod
public async Task<string> CacheOrderDetails(modelManifest Obj, Int64 UserId, Int64 CustId)
{
try
{
StringBuilder message = new StringBuilder("");
#region declare payload for Save Manifest
var data = new
{
CreatedById = UserId,
CustId = CustId,
AwbNo = Obj.AWB_NUMBER,
OrderNo = Obj.ORDER_NUMBER,
ProductType = Obj.PRODUCT,
Consignee = Obj.CONSIGNEE,
ConsigneeAdd1 = Obj.CONSIGNEE_ADDRESS1,
ConsigneeAdd2 = Obj.CONSIGNEE_ADDRESS2,
ConsigneeAdd3 = Obj.CONSIGNEE_ADDRESS3,
DestCity = Obj.DESTINATION_CITY,
DestPin = Obj.PINCODE,
State = Obj.STATE,
Mobile = Obj.MOBILE,
Telephone = Obj.TELEPHONE,
ItemDesc = Obj.ITEM_DESCRIPTION,
Pieces = Obj.PIECES,
Colvalue = Obj.COLLECTABLE_VALUE,
DeclValue = Obj.DECLARED_VALUE,
ActualWeight = Obj.ACTUAL_WEIGHT,
VolmWeight = Obj.VOLUMETRIC_WEIGHT,
Length = Obj.LENGTH,
Breadth = Obj.BREADTH,
height = Obj.HEIGHT,
PickupName = Obj.PICKUP_NAME,
PickupAdd1 = Obj.PICKUP_ADDRESS_LINE1,
PickupAdd2 = Obj.PICKUP_ADDRESS_LINE2,
PickupPin = Obj.PICKUP_PINCODE,
PickupPhone = Obj.PICKUP_PHONE,
PickupMobile = Obj.PICKUP_MOBILE,
ReturnPin = Obj.RETURN_PINCODE,
ReturnName = Obj.RETURN_NAME,
ReturnAdd1 = Obj.RETURN_ADDRESS_LINE1,
ReturnAdd2 = Obj.RETURN_ADDRESS_LINE2,
ReturnPhone = Obj.RETURN_PHONE,
ReturnMobile = Obj.RETURN_MOBILE,
VendorCode = Obj.VENDOR_CODE,
};
#endregion
if (data != null)
{
// Int32? ShipmentId = client.CreateShipment_ApiOnly(data);
Int32? ShipmentId = await client.CacheOrderDetails(data);
if (ShipmentId > 0 & Obj.PRODUCT.Contains("REV"))
{
#region declare payload for Save Manifest (QC params)
var QcParam = new
{
// ShipmentId = ShipmentId,
TempId = ShipmentId,
DrsUid = 0,
QC1_Text = Obj.QC1_Text,
QC2_Text = Obj.QC2_Text,
QC3_Text = Obj.QC3_Text,
QC4_Text = Obj.QC4_Text,
QC5_Text = Obj.QC5_Text,
QC6_Text = Obj.QC6_Text,
QC7_Text = Obj.QC7_Text,
QC8_Text = Obj.QC8_Text,
QC9_Text = Obj.QC9_Text,
QC10_Text = Obj.QC10_Text,
QC1_Val = Obj.QC1_Val,
QC2_Val = Obj.QC2_Val,
QC3_Val = Obj.QC3_Val,
QC4_Val = Obj.QC4_Val,
QC5_Val = Obj.QC5_Val,
QC6_Val = Obj.QC6_Val,
QC7_Val = Obj.QC7_Val,
QC8_Val = Obj.QC8_Val,
QC9_Val = Obj.QC9_Val,
QC10_Val = Obj.QC10_Val
};
#endregion
int? QcResult = DbCust.SaveShipmentQC_Details(QcParam);
if (QcResult == 0 || QcResult == null)
{
message.Append("Unable to update QC records");
}
else
message.Append("SUCCESS");
}
else
{
if (ShipmentId != null && ShipmentId > 0 && !Obj.PRODUCT.Contains("REV"))
{
message.Append("SUCCESS");
}
else
message.Append("Record already exists");
}
return message.ToString();
}
else
return "FAILURE";
}
catch (Exception ex)
{
log.LogError("bookingController/CacheOrderDetails Action", ex);
return "FAILURE";
}
}
Implementation Class
public async Task<Int32> CacheOrderDetails(object o)
{
// return DbHelper.StoredProcWithParamsAsync<Int32>("SaveOrderDetails", o).FirstOrDefault();
var res = await DbHelper.StoredProcWithParamsAsync<Int32>("SaveOrderDetails", o);
return res.FirstOrDefault();
}
DB Helper Class
public static async Task<List<T>> StoredProcWithParamsAsync<T>(string procname, dynamic parms, string connectionName = null)
{
using (SqlConnection connection = GetOpenConnectionAsync(connectionName))
{
var res= await connection.QueryAsync<T>(procname, (object)parms, commandType: CommandType.StoredProcedure);
return res.ToList();
}
}
Connection String Declaration
public static SqlConnection GetOpenConnectionAsync(string name = null)
{
string connString = "";
connString = ConfigurationManager.ConnectionStrings["connstr1"].ConnectionString;
var connection = new SqlConnection(connString);
connection.OpenAsync();
return connection;
}

Null exception when creating new event for calendar with Microsoft Graph

I am getting myself really confused here and going around in circles.
I have this basic code:
public async Task<bool> CreateEventData(OutlookCalendarData.OutlookCalendarData oData)
{
try
{
await oData.CreateEvent(oData.Weeks[0], _graphClient);
}
catch (Exception ex)
{
SimpleLog.Log(ex);
}
return true;
}
The code is calling is here:
public async Task<bool> CreateEvent(Week oWeek, GraphServiceClient graphClient)
{
// Event Body
// TODO: Build proper body text
ItemBody body = new ItemBody
{
Content = oWeek.WeeklyBibleReading,
ContentType = BodyType.Text
};
// Start Time
string strStartDateTime = oWeek.Date.ToString("yyyy-MM-dd") + "T" + oWeek.StartTime + ":00";
DateTime dateStartDateTime = DateTime.Parse(strStartDateTime);
DateTimeTimeZone startTime = new DateTimeTimeZone
{
DateTime = dateStartDateTime.ToString("o"),
TimeZone = TimeZoneInfo.Local.Id
};
// End Time
DateTimeTimeZone endTime = new DateTimeTimeZone
{
DateTime = dateStartDateTime.AddMinutes(oWeek.EventDuration).ToString("o"),
TimeZone = TimeZoneInfo.Local.Id
};
// Add the event
Event createdEvent = await graphClient.Me.Calendars[_CalendarID]
.Events
.Request()
.AddAsync(new Event
{
Subject = oWeek.Title,
Body = body,
Start = startTime,
End = endTime,
IsReminderOn = true,
ReminderMinutesBeforeStart = 1024,
});
// Extended Properties
if (createdEvent != null)
{
createdEvent.SingleValueExtendedProperties.Add(
new SingleValueLegacyExtendedProperty
{
Id = "String " + Guid.NewGuid().ToString() + " Name TruckleSoft1",
Value = "CLM_MidweekMeeting"
});
return true;
}
return false;
}
But I am getting an exception raised on this bit:
Event createdEvent = await graphClient.Me.Calendars[_CalendarID]
.Events
.Request()
.AddAsync(new Event
{
Subject = oWeek.Title,
Body = body,
Start = startTime,
End = endTime,
IsReminderOn = true,
ReminderMinutesBeforeStart = 1024,
});
The exception:
<LogEntry Date="2017-09-01 18:38:08" Severity="Exception" Source="OutlookCalIFConsole.Outlook+<CreateEventData>d__17.MoveNext" ThreadId="10">
<Exception Type="System.NullReferenceException" Source="OutlookCalIFConsole.OutlookCalendarData.OutlookCalendarData+<CreateEvent>d__10.MoveNext">
<Message>Object reference not set to an instance of an object.</Message>
<StackTrace> at OutlookCalIFConsole.OutlookCalendarData.OutlookCalendarData.<CreateEvent>d__10.MoveNext() in D:\My Programs\2017\OutlookCalIFConsole\OutlookCalIFConsole\OutlookCalendarData\OutlookCalendarData.cs:line 97
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OutlookCalIFConsole.Outlook.<CreateEventData>d__17.MoveNext() in D:\My Programs\2017\OutlookCalIFConsole\OutlookCalIFConsole\Outlook.cs:line 186</StackTrace>
</Exception>
</LogEntry>
I am confused. I have verified that all the bits I am using are not null.
Update
I moved my code around a little bit and can now confirm that it does create the event in the calendar. The exception is on the extended properties:
// Extended Properties
if (createdEvent != null)
{
createdEvent.SingleValueExtendedProperties.Add(
new SingleValueLegacyExtendedProperty
{
Id = "String " + Guid.NewGuid().ToString() + " Name TruckleSoft1",
Value = "CLM_MidweekMeeting"
});
return true;
}
Update
Ah, in debug mode, on closer inspection, SingleValueExtendedProperties in the Event object is null. I can't work out how to build a new set of properties.
Update
I have tried this but it does not like it:
List<SingleValueLegacyExtendedProperty> extendedProperties =
new List<SingleValueLegacyExtendedProperty>();
extendedProperties.Add(new SingleValueLegacyExtendedProperty
{
Id = "String " + Guid.NewGuid().ToString() + " Name TruckleSoft1",
Value = "CLM_MidweekMeeting"
});
// Add the event
Event createdEvent = await _graphClient.Me.Calendars[oData.CalendarID]
.Events
.Request()
.AddAsync(new Event
{
Subject = oWeek.Title,
Body = body,
Start = startTime,
End = endTime,
IsReminderOn = true,
ReminderMinutesBeforeStart = 1024,
SingleValueExtendedProperties = extendedProperties
});
Update
I have read this:
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/singlevaluelegacyextendedproperty_post_singlevalueextendedproperties
Yet I can't see why my approach fails really.
You're on the right track, you need to init the extendedProperties property. It isn't however a List<T> that you want, it is a EventSingleValueExtendedPropertiesCollectionPage.
Try this instead:
var extendedProperties = new EventSingleValueExtendedPropertiesCollectionPage();
extendedProperties.Add(new SingleValueLegacyExtendedProperty
{
Id = "String " + Guid.NewGuid().ToString() + " Name TruckleSoft1",
Value = "CLM_MidweekMeeting"
});

Guid is causing a format exception

I'm trying to set up RavenDb 3.5 and NServiceBus 6. After I senter the saga that I have set up in my NServiceBus endpoint, I enter a handler. Once this handler is finished, I get this error:
System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
My code:
public static class AutoFacConfig
{
public static IContainer ConfigureAutofac()
{
var builder = new ContainerBuilder();
var resourceManagerId = new Guid("6c9abcbb-c7ca-4a67-a149-5142f633f535");
var dtcRecoveryBasePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
var recoveryPath = Path.Combine(dtcRecoveryBasePath, "NServiceBus.RavenDB", resourceManagerId.ToString());
builder.Register(x =>
{
var store = new DocumentStore
{
ConnectionStringName = "RavenDB",
ResourceManagerId = resourceManagerId,
TransactionRecoveryStorage = new LocalDirectoryTransactionRecoveryStorage(recoveryPath)
};
store.DefaultDatabase = "MyDB";
store.Initialize();
store.Conventions.IdentityPartsSeparator = "-";
return store;
})
.As<IDocumentStore>()
.SingleInstance();
builder.Register<IFilesStore>(x =>
{
var fileStore = new FilesStore()
{
Url = "http://localhost:40000",
DefaultFileSystem = "MyFS",
}.Initialize();
return fileStore;
}).SingleInstance();
return builder.Build();
}
}
In the saga:
protected override void ConfigureHowToFindSaga(SagaPropertyMapper<FileToOrderSagaData> mapper)
{
mapper.ConfigureMapping<StartFileToOrderSagaCommand>(m => m.DataId)
.ToSaga(s => s.DataId);
}
public async Task Handle(StartFileToOrderSagaCommand message, IMessageHandlerContext context)
{
// Do Validation ValidateXmlCommand
Data.DataId = message.DataId;
await context.Send<ValidateXmlCommand>( x => { x.Filename = message.Filename; x.CustomerId = message.CustomerId; });
}
Here's the stack trace:
at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at Raven.Client.Converters.GuidConverter.ConvertTo(String value) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Converters\GuidConverter.cs:line 51
at Raven.Client.Document.GenerateEntityIdOnTheClient.SetPropertyOrField(Type propertyOrFieldType, Object entity, Action`1 setIdentifier, String id) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\GenerateEntityIdOnTheClient.cs:line 170
at Raven.Client.Document.GenerateEntityIdOnTheClient.TrySetIdentity(Object entity, String id) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\GenerateEntityIdOnTheClient.cs:line 143
at Raven.Client.Document.InMemoryDocumentSessionOperations.<GenerateDocumentKeyForStorageAsync>d__99.MoveNext() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 833
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Document.InMemoryDocumentSessionOperations.<StoreAsyncInternal>d__96.MoveNext() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 803
Any help guys?
After removing
store.Conventions.IdentityPartsSeparator = "-";
the issue was fixed.
See HadiEskandari's comment above and this link for more info: Exception in RavenDB.SagaPersister.Save, "Guid should contain 32 digits with 4 dashes". Guid is empty in Raven

LiveConnectException using live sdk

i'm new to Live SDK and i'm trying to use it to connect to a user's profile and get data from it
i have read about it and used the following code to login to user's account
private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
{
if (e.Status == LiveConnectSessionStatus.Connected)
{
session = e.Session;
client = new LiveConnectClient(session);
try
{
LiveAuthClient auth = new LiveAuthClient(btnSignin.ClientId);
//LiveLoginResult initializeResult = await auth.InitializeAsync();
try
{
LiveLoginResult loginResult = await auth.LoginAsync(new string[] { "wl.basic" });
if (loginResult.Status == LiveConnectSessionStatus.Connected)
{
LiveConnectClient connect = new LiveConnectClient(auth.Session);
LiveOperationResult operationResult = await connect.GetAsync("me");
dynamic result = operationResult.Result;
if (result != null)
{
this.infoTextBlock.Text = string.Join(" ", "Hello", result.name, "!");
}
else
{
this.infoTextBlock.Text = "Error getting name.";
}
}
}
catch (LiveAuthException exception)
{
this.infoTextBlock.Text = "Error signing in: " + exception.Message;
}
catch (LiveConnectException exception)
{
MessageBox.Show("Error calling API: " + exception.Message);
}
}
catch (LiveAuthException exception)
{
this.infoTextBlock.Text = "Error initializing: " + exception.Message;
}
}
else
{
client = null;
}
}
it logs in on my emulator and one of my 2 lumia 620 devices but with the other device it gives me the following Exception
**
*> {client_error: Microsoft.Live.LiveConnectException: Exception of type
'Microsoft.Live.LiveConnectException' was thrown. at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at PhoneApp2.MainPage.d__6.MoveNext()}*
**

Error while running LiveAuthClient's LoginAsync

I'm trying to write a simple windows store app that forces a user to login right away. I'm following these guides:
http://msdn.microsoft.com/en-us/library/live/hh968445.aspx
And
http://msdn.microsoft.com/en-us/library/live/hh826543.aspx#csharp
and I've added the following:
public LiveConnectSession Session
{
get
{
return _session;
}
set
{
_session = value;
}
}
private async void InitAuth()
{
if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
{
try
{
authClient = new LiveAuthClient();
List<string> perms = new List<string>() { "wl.signin", "wl.basic", "wl.skydrive" };
LiveLoginResult authResult = await authClient.LoginAsync(perms);
if (authResult.Status == LiveConnectSessionStatus.Connected)
{
this.Session = authResult.Session;
}
}
catch (Exception e)
{
String message = e.Message;
}
}
}
I call InitAuth() from the App() constructor.
I get an "Element Not Found" Excetion, and the following stack trace:
at Microsoft.Live.LiveAuthClient.<ExecuteAuthTaskAsync>d__4.MoveNext()
End of stack trace from previous location where exception was thrown
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at TuneHoc.App.<InitAuth>d__1.MoveNext() in <filename>
Does anyone know the problem?

Categories

Resources