get outlook single occurrence of recurring calendar event from double click on calendar - outlook

I am creating an outlook plugin that opens a SharePoint Calendar event for editing. The SharePoint Calendar is added to outlook as an overlay.
When clicking on the series event and editing a series everything works fine. But when I select just this one (occurrence). I am unable to get any of the properties for the AppointmentItem object.
I have tried both the ReadComplete and the Open events and still get an exception:
Exception from HRESULT: 0x80040108" and I am unable to access the
Parent. It appears all of the properties are null except Class = 26
and MessageClass = "IPM.Appointment"
private void Application_ItemLoad(object item)
{
_item = item;
try
{
if (!(item is AppointmentItem) || !_exp.CurrentFolder.Name.Contains("Test - Conference Room ")) return;
_warnUser = true;
_apptItem = (AppointmentItem) item;
_apptItem.ReadComplete += test;
_apptItem.Open += McAI_Open;
}
catch (Exception ex)
{
var expMessage = ex.Message;
MessageBox.Show(expMessage);
}
}
private static void ThisAddIn_Shutdown(object sender, EventArgs e)
{
// Note: Outlook no longer raises this event. If you have code that
// must run when Outlook shuts down, see https://go.microsoft.com/fwlink/?LinkId=506785
}
private void McAI_Open(ref bool cancel)
{
_warnUser = false;
var conferenceRoom = _exp.CurrentFolder.Name;
conferenceRoom = conferenceRoom.Replace("Test - ", "");
if (!(_item is AppointmentItem)){return;}
try
{
var g = _apptItem.IsRecurring;
if (_apptItem != null && _exp.CurrentFolder.Name.Contains("Test") && _apptItem.Location != null)
{
var location = _apptItem.Location;
var result = location.Substring(location.LastIndexOf(':') + 1);
cancel = true;
var sharePointItemId = int.Parse(result);
var frm = new FrmCalendarSelection(
"<SharePointURL>" + conferenceRoom,
sharePointItemId);
frm.Show();
frm.Closed += Frm_Closed;
}
else if (_apptItem != null && _exp.CurrentFolder.Name.Contains("Test") && _apptItem.Location == null)
{
cancel = true;
var frm = new FrmCalendarSelection(
"<SharePointURL>" + conferenceRoom);
frm.Show();
frm.Closed += Frm_Closed;
}
}
catch (Exception e)
{
throw e;
}
}

Related

WebView File Chooser stops to respond after cancelled selection

we have implement file chooser for web view. it works successfully when attachment is selected, but fails when cancelled without file specification. The file chooser just stops to react on click
any help is appreciated. Thanks
we use chrome client. it works fine if in all cases, file selection is listed. but even from the first file selection is cancelled, no longer file chooser will work. It is Xamarin.Android app based fully on webview
Our code is:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
{
if (requestCode == FILECHOOSER_RESULTCODE)
{
if (null == _mUploadMessage)
return;
// Check that the response is a good one
if (resultCode == Result.Ok)
{
Android.Net.Uri[] results = null;
if (intent == null)
{
// If there is not data, then we may have taken a photo
if (mCameraPhotoPath != null)
{
results = new Android.Net.Uri[] { Android.Net.Uri.Parse(mCameraPhotoPath) };
}
}
else
{
if (intent.DataString != null)
{
results = new Android.Net.Uri[] { Android.Net.Uri.Parse(intent.DataString) };
}
}
_mUploadMessage.OnReceiveValue(results);
_mUploadMessage = null;
}
}
}
Chrome client:
var chrome = new FileChooserWebChromeClient((uploadMsg) =>
{
_mUploadMessage = uploadMsg;
mCameraPhotoPath = null;
Intent takePictureIntent = new Intent(Android.Provider.MediaStore.ActionImageCapture);
//Create the File where the photo should go
File photoFile = null;
try
{
string folder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
photoFile = new File(folder, "image" + DateTime.Now.Millisecond + ".png");
takePictureIntent.PutExtra("PhotoPath", mCameraPhotoPath);
}
catch (IOException ex)
{
// Error occurred while creating the File
System.Console.WriteLine("" + ex.ToString());
}
// Continue only if the File was successfully created
if (photoFile != null)
{
mCameraPhotoPath = "file:" + photoFile.AbsolutePath;
takePictureIntent.PutExtra(Android.Provider.MediaStore.ExtraOutput,
Android.Net.Uri.FromFile(photoFile));
}
else
{
takePictureIntent = null;
}
Intent contentSelectionIntent = new Intent(Intent.ActionGetContent);
contentSelectionIntent.AddCategory(Intent.CategoryOpenable);
contentSelectionIntent.SetType("image/*");
Intent[] intentArray;
if (takePictureIntent != null)
{
intentArray = new Intent[] { takePictureIntent };
}
else
{
intentArray = new Intent[0];
}
Intent chooserIntent = new Intent(Intent.ActionChooser);
chooserIntent.PutExtra(Intent.ExtraIntent, contentSelectionIntent);
chooserIntent.PutExtra(Intent.ExtraTitle, this.GetStringFromResource(Resource.String.chose_photo));
chooserIntent.PutExtra(Intent.ExtraInitialIntents, intentArray);
base.StartActivityForResult(chooserIntent, HarmonyAndroid.AndroidMainActivity.FILECHOOSER_RESULTCODE);
});
return chrome;
Part 2
class FileChooserWebChromeClient : WebChromeClient
{
Action<IValueCallback> callback;
public FileChooserWebChromeClient(Action<IValueCallback> callback)
{
this.callback = callback;
}
public override bool OnShowFileChooser(WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
{
callback(filePathCallback);
return true;
}
public override void OnCloseWindow(WebView window)
{
base.OnCloseWindow(window);
}
}
Part 3
webView.ImprovePerformance();
webView.SetWebViewClient(new HomeWebViewClient(customWebViewClientListener, clientId));
webView.SetWebChromeClient(chrome);
webView.Settings.JavaScriptEnabled = true;
webView.Settings.DomStorageEnabled = true;
webView.SetDownloadListener(new CustomDownloadListener(activity, customDownloadListener));
webView.AddJavascriptInterface(new JavaScriptToCSharpCommunication(activity, javaScriptToCSharpCommunicationListener), Constants.JS_CSHARP_COMMUNICATOR_NAME);
Try to give a null object to the uri callback, when the resultCode is not RESULT_OK.
add in your OnActivityResult method:
if (resultCode != Result.Ok)
{
_mUploadMessage.OnReceiveValue(null);
_mUploadMessage = null;
return;
}

How to update outlook Search folder result for a new search programmaticaly without changing the folder name

I created Outlook search folder using add-in express for a outlook plugin as below. it is based on this article.
is there similar way to update search folder name for a new result ?
private void adxOutlookEvents_AdvancedSearchComplete(object sender, object hostObj) {
Outlook.Search advancedSearch = null;
Outlook.Results advancedSearchResults = null;
Outlook.MailItem resultItem = null;
System.Text.StringBuilder strBuilder = null;
try {
advancedSearch = hostObj as Outlook.Search;
if (advancedSearch.Tag == advancedSearchTag) {
System.Diagnostics.Debug.WriteLine("!!! adxOutlookEvents_AdvancedSearchComplete");
advancedSearchResults = advancedSearch.Results;
if (advancedSearchResults.Count > 0) {
if (HostMajorVersion > 10) {
object folder = advancedSearch.GetType().InvokeMember("Save",
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.InvokeMethod |
System.Reflection.BindingFlags.Public,
null, advancedSearch,
new object[] { advancedSearchTag });
}
} else {
System.Diagnostics.Debug.WriteLine("!!!" + "There are no items found.");
}
}
} catch (Exception ex) {
MessageBox.Show(ex.Message, "An exception is occured");
} finally {
if (resultItem != null) Marshal.ReleaseComObject(resultItem);
if (advancedSearchResults != null)
Marshal.ReleaseComObject(advancedSearchResults);
}
}
Application.AdvancedSearch returns Search object. You can call Search.Save passing the name (string) - it will return MAPIFolder object. You can modify the MAPIFolder.Name property at any time.

Is there any plugin or way to show 'new version of app available' alert when user opens app

I have Xamarin.Android app, I want to show alert to user (when user opens app) that please download latest version. Like other apps. How can I do that?
I have tried few ways but didn't get succeed. I have tried this. This is quite different from Android. I need it for Xamarin.
I already asked this question but existing functionality broke down due to having some changes in play store policies, consequently I am not getting specific string "itemprop=\"softwareVersion\">" from play store so I asked new question. Thank you
Working answer. I have used plugin for that Plugin.LatestVersion for Xam.Android to get latest version of app from Google play store. below line of code was returning latest app version.
var appStoreVersionString = await CrossLatestVersion.Current.GetLatestVersionNumber();
Then this is the further implementation
private void CompareVersion()
{
double currentVersion = 0d;
double appStoreversion = 0d;
bool IsUpdateRequired = false;
if (Context.PackageName != null)
{
PackageInfo info = Context.PackageManager.GetPackageInfo(Context.PackageName, PackageInfoFlags.Activities);
string currentVersionStrig = info.VersionName;
currentVersion = Convert.ToDouble(currentVersionStrig);
}
try
{
if (IsUpdateRequired == false)
{
string appStoreVersionString = string.Empty;
if (CheckNetConnection.IsNetConnected())
{
Task.Run(async () => { appStoreVersionString = await CrossLatestVersion.Current.GetLatestVersionNumber();}).Wait();
if (!string.IsNullOrEmpty(appStoreVersionString))
{
appStoreversion = Convert.ToDouble(appStoreVersionString);
if ((appStoreversion.ToString() != currentVersion.ToString() && (appStoreversion > currentVersion)))
{
IsUpdateRequired = true;
}
}
}
}
if (IsUpdateRequired)
{
Activity.RunOnUiThread(() =>
{
AlertDialog dialog = null;
var Alertdialog = new Android.App.AlertDialog.Builder(Context);
Alertdialog.SetTitle("Update Available");
Alertdialog.SetMessage($"A new version of [" + appStoreversion + "] is available. Please update to version [" + appStoreversion + "] now.");
Alertdialog.SetNegativeButton("Cancel", (sender, e) =>
{
if (dialog == null)
{
dialog = Alertdialog.Create();
}
dialog.Dismiss();
});
Alertdialog.SetPositiveButton("Update", (sender, e) =>
{
string appPackage = string.Empty;
try
{
appPackage = Application.Context.PackageName;
Utilities.Logout(Activity);
var ints = new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + appPackage));
ints.SetFlags(ActivityFlags.ClearTop);
ints.SetFlags(ActivityFlags.NoAnimation);
ints.SetFlags(ActivityFlags.NewTask);
Application.Context.StartActivity(ints);
}
catch (ActivityNotFoundException)
{
var apppack = Application.Context.PackageName;
Utilities.Logout(Activity);
var ints = new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + appPackage));
ints.SetFlags(ActivityFlags.ClearTop);
ints.SetFlags(ActivityFlags.NoAnimation);
ints.SetFlags(ActivityFlags.NewTask);
Application.Context.StartActivity(ints);
}
//this kills the app?
Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
System.Environment.Exit(1);
});
if (dialog == null)
dialog = Alertdialog.Create();
dialog.Show();
});
}
}
catch (Exception ex)
{
var objLog = new LogService();
objLog.MobileLog(ex, SISConst.UserName);
}
}

Xamarin Forms button event not firing on Android

I have a Xamarin Forms app, in one of my pages I have two buttons, on Android when you tap the button it does not fire the event, it just highlights the button, if you tap a second time then it fires the event, on iOS it runs flawlessly. Below is some Code extracts, sorry if my code has bad practices, I am a noob, so please do correct me, best way to learn:
//Initialize Page
public GameDetailsNew(Game myEvent)
{
InitializeComponent();
MyEvent.Text = myEvent.EventName;
MyTimeHeader.Text = myEvent.TimeOfEvent;
myEventID = myEvent.EventID;
Task.Run(() => { GetAttendingEvent(myEvent.EventID); });
}
//GetAttendingEvent
private void GetAttendingEvent(int eventID)
{
var registerLable = "";
var attendinIsVisible = false;
var notAttendingIsVisible = false;
try
{
HelperFiles.APICaller ac = new HelperFiles.APICaller();
var x = (string)ac.CallCOFMOBILEBool("GetIsAttending?eventID=" + eventID);
if (x == "Attending")
{
registerLable = "You are currently Attending this Event";
attendinIsVisible = false;
notAttendingIsVisible = true;
}
else
{
registerLable = "You are currently NOT Attending this Event";
attendinIsVisible = true;
notAttendingIsVisible = false;
}
Device.BeginInvokeOnMainThread(() =>
{
RegisterLable.Text = registerLable;
AttendingButton.IsVisible = attendinIsVisible;
NotAttendingButton.IsVisible = notAttendingIsVisible;
});
}
catch (Exception ex)
{
MyAlerts("Error", ex.Message, "OK");
}
}
//My To Button Event Handlers
//Sets User as attending event
void AttendingClicked(object sender, System.EventArgs e)
{
try
{
HelperFiles.APICaller ac = new HelperFiles.APICaller();
var x = (string)ac.CallCOFMOBILEBool("GetCreateAttending?eventID=" + myEventID);
if (x == "1")
{
RegisterLable.Text = "You are currently Attending this Event";
AttendingButton.IsVisible = false;
NotAttendingButton.IsVisible = true;
}
else
{
RegisterLable.Text = "You are currently NOT Attending this Event";
AttendingButton.IsVisible = true;
NotAttendingButton.IsVisible = false;
}
GetDeployingEvent(myEventID);
}
catch (Exception ex)
{
MyAlerts("Error", ex.Message, "OK");
}
}
//Sets User as Not attending event
void NotAttendingClicked(object sender, System.EventArgs e)
{
try
{
HelperFiles.APICaller ac = new HelperFiles.APICaller();
var x = (string)ac.CallCOFMOBILEBool("GetCreateNotAttending?eventID=" + myEventID);
if (x != "1")
{
RegisterLable.Text = "You are currently Attending this Event";
AttendingButton.IsVisible = false;
NotAttendingButton.IsVisible = true;
}
else
{
RegisterLable.Text = "You are currently NOT Attending this Event";
AttendingButton.IsVisible = true;
NotAttendingButton.IsVisible = false;
}
GetDeployingEvent(myEventID);
}
catch (Exception ex)
{
MyAlerts("Error", ex.Message, "OK");
}
}
I just wanted to update on this, I managed to resolve the issue. about 8 months ago I started my project in Xamarin Studio, fast forward a few months, Xamarin Studios changed to Visual Studio. No matter what i done i could not get rid of this bug, I then started a brand new app and pasted all my code in to the new app. This has resolved the bug.

How to handle list picker in Wp7

I have a list picker which is displayed in my phone application page.I have created list picker in starting of class,and i am adding the list picker in the phoneApplicationPage_loaded() method.When the page is launched the first time, ,the scenario works perfectly and its navigates further to second page.When i navigate back to previous page(containing list picker),it shows Invalid Operation Exception occured stating "Element is already the child of another element."
I want to know how to handle these scenarios?
Code is below
namespace My.Design
{
public partial class myclass : PhoneApplicationPage
{
String[] values = null;
ListPicker picker = new ListPicker();
StackPanel sp;
StackPanel mainFrame;
String statementInfo = "";
public myclass()
{
InitializeComponent();
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
Debug.WriteLine("Phone Application Page Loaded_>>>>>>");
List<String> source = new List<String>();
displayUI();
}
public void displayUI()
{
Debug.WriteLine("About to display UI in miniStatement");
Debug.WriteLine("<-------------Data--------->");
Debug.WriteLine(statementInfo);
Debug.WriteLine("<-------------Data--------->");
int count = VisualTreeHelper.GetChildrenCount(this);
if (count > 0)
{
for (int i = 0; i < count; i++)
{
UIElement child = (UIElement)VisualTreeHelper.GetChild(this, i);
string childTypeName = child.GetType().ToString();
Debug.WriteLine("Elements in this Child" + childTypeName);
}
}
List<String> source = new List<String>();
String[] allParams = ItemString.Split('#');
source.Add("PleaseSelect");
for (int i = 0; i < allParams.Length; i++)
{
Debug.WriteLine("All Params Length" + allParams[i]);
if (!(allParams[i].Equals("") && (!allParams[i].Equals(null))))
{
if (values != null)
{
Debug.WriteLine("Values length" + values.Length);
values[values.Length] = allParams[i];
}
else
{
Debug.WriteLine("Allparams Length" + allParams[i]);
source.Add(allParams[i]);
}
}
}
//picker = new ListPicker();
this.picker.ItemsSource = source;
mainFrame = new StackPanel();
TextBlock box = new TextBlock();
box.Text = "> DEmoClass";
box.FontSize = 40;
mainFrame.Children.Add(box);
Canvas canvas = new Canvas();
StackPanel sp = new StackPanel();
TextBlock box1 = new TextBlock();
box1.Text = "Number";
box1.HorizontalAlignment = HorizontalAlignment.Center;
box1.FontSize = 40;
SolidColorBrush scb1 = new SolidColorBrush(Colors.Black);
box1.Foreground = scb1;
sp.Children.Add(box1);
picker.Width = 400;
picker.Height = 150;
sp.Children.Add(picker);
Canvas.SetTop(sp, 150);
canvas.Children.Add(sp);
mainFrame.Children.Add(canvas);
this.ContentPanel1.Children.Add(mainFrame);
}
protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
{
/*
Debug.WriteLine("OnNavigatingFrom>>>.>>MainPage");
if (sp != null)
{
sp.Children.Remove(picker);
}*/
base.OnNavigatingFrom(e);
}
}
}
If you are not intending to update the listpicker after navigating back from the second page add the following line in your Loaded event handler
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
this.Loaded -= PhoneApplicationPage_Loaded;
Debug.WriteLine("Phone Application Page Loaded_>>>>>>");
List<String> source = new List<String>();
displayUI();
}
i don't know why you can not use that case when app resume from tombstoned.
error happened because when you back to your page , loaded event runs again.
by the way,
Application_Activated 's argument can tell you app resumes from tombstoned or not--.
if (e.IsApplicationInstancePreserved)
{
IsTombstoning = false;
}
else
{
IsTombstoning = true;
}
I'm curious why you're creating it in code and not leaving it in XAML? Also the error is coming from the fact that you're attempting to add it twice into a location that can probably only have a single content element. What's the higher level problem you're trying to solve?

Resources