I'm trying to figure out how to make a conference call (adding and merging phone calls of different contacts - cellular not VoIP) using C# in UWP.
I see the sample code "PhoneCall" provded in github:
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/PhoneCall
on how to dial a number:
public async void DialOnCurrentLineAsync(string PhoneNumber, string DisplayName)
{
if ((currentPhoneLine != null) && (PhoneNumber.Trim().Length > 0))
{
currentPhoneLine.Dial(PhoneNumber, DisplayName);
}
else
{
var dialog = new MessageDialog("No line found to place the call");
await dialog.ShowAsync();
}
}
But I don't see any part of the code to add and merge calls.
For now, there's no sucn built-in API for you to make conference call in UWP. It should be a feature request. You could submit your feature request on WP UserVoice.
Related
I have implemented Voice call in my code using .net with NServiceBus version 7.
Below is the code snippet to send voice call:
public Task Handle(AddServiceAuto message, IMessageHandlerContext context)
{
try
{
string VoiceCallCode = null;
Guid userID = User.userID;
VoiceCallCode = GetVoiceCallCode(userID);
if (VoiceCallCode != null)
{
publishAddVoiceCallEvent(context, user.caseID, userID.Mobile,
userID.Voicecall, VoiceMessageText, VoiceCallCode);
}
}
}
private void publishAddVoiceCallEvent(IMessageHandlerContext context,
Guid caseID, string mobile, bool voicecall,
string voiceMessageText, string voiceCallCode)
{
AddVoiceCallEvent addVoiceCallEvent = new AddVoiceCallEvent()
{
CaseID = caseID,
Mobile = mobile,
Voicecall = voicecall,
VoiceMessageText = voiceMessageText,
VoiceCallCode = voiceCallCode
};
context.Publish(addVoiceCallEvent).ConfigureAwait(false);
}
public Task Handle(AddVoiceCallEvent message, IMessageHandlerContext context)
{
try
{
Logger.InfoFormat("message.CaseID: {0}", message.CaseID);
Logger.InfoFormat("message.Voicecall= {0}", message.Voicecall);
Logger.InfoFormat("message.Mobile {0}", message.Mobile);
Logger.InfoFormat("message.VoiceCallCode {0}", message.VoiceCallCode);
// The user should satisfy below conditions in order to receive a voice call.
if ((message.Voicecall) && !string.IsNullOrEmpty(message.Mobile) &&
!string.IsNullOrEmpty(message.VoiceMessageText) &&
!string.IsNullOrEmpty(message.VoiceCallCode))
{
Voicecall(message.Mobile, message.Voicecall,
message.VoiceMessageText, message.VoiceCallCode);
}
else
{
Logger.Error("Mobile Value is Empty (OR) Voicecall is False (OR)
+ VoiceMessageText is Empty (OR) VoiceCallCode is Empty");
}
}
}
If condition satisfied it will send voice call, else it will print log.
Problem:
The Voice call is random i.e. sometimes user is receiving voice call and sometimes not(even though with same settings i.e mobile, VoiceCallCode values stored properly in DB and Voicecall is also true)
and the Strange part is, though the values are stored correctly DB, when we look into the logs that we are printing, it shows the value of Mobile, VoiceCallCode is null and Voicecall is false.
Again after 5 mins I tried, it worked.
One more thing is, when voice call is not working.
Logger.InfoFormat("message.CaseID: {0}", message.CaseID); // CaseID printed
For Below, data is not printing even though data is there in available in DB (i.e. printing as null)
Logger.InfoFormat("message.Voicecall= {0}", message.Voicecall);
Logger.InfoFormat("message.Mobile {0}", message.Mobile);
Logger.InfoFormat("message.VoiceCallCode {0}", message.VoiceCallCode);
Strange is that, for CaseID it printed while for others it is not printing.
Why this is happening? Can someone please help on this?
The code you've shared doesn't seem to be a running code (try w/o catch) therefore it would be hard to pinpoint what contributes to the issue. But the random behaviour could be attributed to improper use of async APIs. The handler methods should return a Task or use async/await. So are operations invoked on IMessageHandlerContext.
For example, publishAddVoiceCallEvent should be returning a Task and not void. The code inside it (context.Publish(addVoiceCallEvent).ConfigureAwait(false);) should be either return context.Publish(addVoiceCallEvent); or await context.Publish(addVoiceCallEvent).ConfigureAwait(false);.
NServiceBus comes with a Rozlyn analyzer to help with these issues.
I need to know the function / method to retrieve the return code to remove data of Azure DataBase (I use DeleteAsync), so that in case of error or NO-OK show me a screen with error. I need the same with different operations (Insert, update ...)
Next step show my code ...
void delete_click_button(object sender, EventArgs a)
{
if (ID != "")
{
App.AzureService.Delete(ID);
**//If return correct code....{**
DisplayAlert("Warning", "Delete satisfactory", "Back");
Navigation.PopAsync();
**}
//If return code error when delete....
{
//display message
}**
}
Thanks, I hope answer :D
According to your description, I assumed that you are using azure mobile apps as your mobile backend. For C# mobile app backend, the delete action under the TableController would be defined as follows by default:
//DELETE tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public Task DeleteTodoItem(string id)
{
return DeleteAsync(id);
}
For you mobile client, you could invoke the delete operation as follows:
//delete a item and return nothing
await onlineTodoTable.DeleteAsync(new TodoItem() {Id= "bb29f1655fb94897a3074f8e5b91b86d"});
Or
//delete a item and return a JToken
JObject obj = new JObject();
obj.Add("id", "faa9a47e57114988b0395a4c32b7d05d");
var jtoken=await onlineTodoTable.DeleteAsync(obj);
For deleting a item and return custom response, you could change the action as follows:
//DELETE tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959
public async Task<string> DeleteTodoItem(string id)
{
await DeleteAsync(id);
return id;
}
As I known, the Insert,Update operations would return the related values after the action executes successfully. And mobile client operations against your mobile backend would throw a exception when the request failed. I recommend that you could just wrap your mobile client operations with try-catch and handle the exception (e.g log the error message or alert the client user) when calling CRUD operations against your mobile app backend instead of retrieving the http status code.
I'm using ZXing.Net.Mobile and have the following code to scan the QR code.
await scanner.Scan().ContinueWith(t =>
{
if (t.Result != null)
HandleScanResult(t.Result);
});
scanner.UseCustomOverlay = false;
scanner.ScanContinuously(async (res) =>
{
var msg = "Found Barcode: " + res.Text;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
ViewHelper.showMessage(msg, "");
});
});
I've tried both ContinueWith and ScanContinuosly but none of them work.
I get a camera view with red line but it does not scan the QR code.
Where am I going wrong.
I suppose you're using the ZXing.NET package?
Mike Taulty wrote a whole blog post series on an app with Scanning on Windows 8.1, then porting it to Windows 10 and even running it on HoloLens. The final post also has a small companion app that runs on UWP for simple scanning (with speech to command the app to scan).
In that sample, he's using following method:
ZXingQrCodeScanner.ScanFirstCameraForQrCode(
result =>
{
this.txtResult.Text = result?.Text ?? "none";
},
TimeSpan.FromSeconds(30));
There’s an assumption that the first camera found on the system should be used for QR code scanning but the classes that underpin this would allow for taking a more flexible approach and that ScanFirstCameraForQrCode function expands out into the following steps below
public static class ZXingQrCodeScanner
{
public static async void ScanFirstCameraForQrCode(
Action<Result> resultCallback,
TimeSpan timeout)
{
Result result = null;
var mediaFrameSourceFinder = new MediaFrameSourceFinder();
// We want a source of media frame groups which contains a color video
// preview (and we'll take the first one).
var populated = await mediaFrameSourceFinder.PopulateAsync(
MediaFrameSourceFinder.ColorVideoPreviewFilter,
MediaFrameSourceFinder.FirstOrDefault);
if (populated)
{
// We'll take the first video capture device.
var videoCaptureDevice =
await VideoCaptureDeviceFinder.FindFirstOrDefaultAsync();
if (videoCaptureDevice != null)
{
// Make a processor which will pull frames from the camera and run
// ZXing over them to look for QR codes.
var frameProcessor = new QrCaptureFrameProcessor(
mediaFrameSourceFinder,
videoCaptureDevice,
MediaEncodingSubtypes.Bgra8);
// Remember to ask for auto-focus on the video capture device.
frameProcessor.SetVideoDeviceControllerInitialiser(
vd => vd.Focus.TrySetAuto(true));
// Process frames for up to 30 seconds to see if we get any QR codes...
await frameProcessor.ProcessFramesAsync(timeout);
// See what result we got.
result = frameProcessor.QrZxingResult;
}
}
// Call back with whatever result we got.
resultCallback(result);
}
}
Source:
Mike Taulty's blog post
Sample app on GitHub
I hope this approach helps you forward.
You can try my ready solution:
Barcode_Scanner_UWP on GitHub
I'v tried to make adoption of VideoScanZXingWinRT repo
Both of them are using ZXing.Net
But in compare with old Mike Taulty sample could catch QR "on the fly"
I was wondering if there are any SWF workflow C# sample code available for the AWS .NET SDK?
AWS Forum Post: https://forums.aws.amazon.com/thread.jspa?threadID=122216&tstart=0
As part of getting familiar with SWF, I ended up writing a common case library that I hope others can use as well. It's called SimpleWorkflowFramework.NET and is available as open source at https://github.com/sdebnath/SimpleWorkflowFramework.NET. It definitely could use a lot of help, so if you are interested, jump right in! :)
I have developed an open source .NET library- Guflow to program Amazon SWF. Here is how you can write a workflow to transcode the video:
[WorkflowDescription("1.0")]
public class TranscodeWorkflow : Workflow
{
public TranscodeWorkflow()
{
//DownloadActivity is the startup activity and will be scheduled when workflow is started.
ScheduleActivity<DownloadActivity>().OnFailure(Reschedule);
//After DownloadActivity is completed TranscodeActivity activity will be scheduled.
ScheduleActivity<TranscodeActivity>().AfterActivity<DownloadActivity>()
.WithInput(a => new {InputFile = ParentResult(a).DownloadedFile, Format = "MP4"})
ScheduleActivity<UploadToS3Activity>().AfterActivity<TranscodeActivity>()
.WithInput(a => new {InputFile = ParentResult(a).TranscodedFile});
ScheduleActivity<SendConfirmationActivity>().AfterActivity<UploadToS3Activity>();
}
private static dynamic ParentResult(IActivityItem a) => a.ParentActivity().Result();
}
In above example I have left out task routing for clarity.
Here is how you can create an activity:
[ActivityDescription("1.0")]
public class DownloadActivity : Activity
{
//It supports both sync/async method.
[ActivityMethod]
public async Task<Response> Execute(string input)
{
//simulate downloading of file
await Task.Delay(10);
return new Response() { DownloadedFile = "downloaded path", PollingQueue = PollingQueue.Download};
}
public class Response
{
public string DownloadedFile;
}
}
For clarity I'm leaving out examples of other activities. Guflow it supported by documentation, tutorial and samples.
Building In-App Purchases in a Windows Store App requires using the In-App Purchase Simulator. It is almost identical to the real In-App Purchase Namespace. While building my app, I use the simulator. I have reserved my name in the Store. I have even created an In-App Purchase in the Store for my App. Is there a way to test the real IAP before submitting my app for Certification?
No, In-App Purchases are not "real" in the Windows Store until your app is submitted for Certification. That means your final step before submission is to swap out the Simulator code for the real code. And, yes, it means you cannot test your real code - the Store tester will be the first to test it for you.
One more thing
Having said that, I created a helper class that wraps both the real and the simulator API. Though it will only help 90% of the use cases out there, it is perfect for those 90%. I have validated the code with the IAP product team and submitted real apps that use it.
You can find this helper here: http://codepaste.net/rqwtcy
Here's the syntax if you want to remove advertisements, for example...
I add it to my View Model like this:
public async Task Start()
{
// in app purchase setup
m_HideAdsFeature = await new InAppPurchaseHelper(HIDEADSFAETURENAME,
System.Diagnostics.Debugger.IsAttached).Setup();
this.HideAds = m_HideAdsFeature.IsPurchased;
}
bool m_HideAds = false;
public bool HideAds { get { return m_HideAds; } set { SetProperty(ref m_HideAds, value); } }
const string HIDEADSFAETURENAME = "HideAds";
InAppPurchaseHelper m_HideAdsFeature;
// http://codepaste.net/ho9s5a
DelegateCommand m_PurchaseHideAdsCommand = null;
public DelegateCommand PurchaseHideAdsCommand
{
get
{
if (m_PurchaseHideAdsCommand != null)
return m_PurchaseHideAdsCommand;
m_PurchaseHideAdsCommand = new DelegateCommand(
PurchaseHideAdsCommandExecute, PurchaseHideAdsCommandCanExecute);
this.PropertyChanged += (s, e) => m_PurchaseHideAdsCommand.RaiseCanExecuteChanged();
return m_PurchaseHideAdsCommand;
}
}
async void PurchaseHideAdsCommandExecute()
{
PauseCommandExecute();
await m_HideAdsFeature.Purchase();
HideAds = m_HideAdsFeature.IsPurchased;
}
bool PurchaseHideAdsCommandCanExecute()
{
if (m_HideAdsFeature == null)
return false;
return !m_HideAdsFeature.IsPurchased;
}
I add it to my XAML like this:
<UI:AdControl x:Name="MyAdControl"
Width="250" Height="250"
HorizontalAlignment="Left" VerticalAlignment="Top"
AdUnitId="10043107" ApplicationId="d25517cb-12d4-4699-8bdc-52040c712cab"
Visibility="{Binding HideAds,
Converter={StaticResource CollapsedWhenTrueConverter}}" />
Best of luck!