/// <summary> /// Raised when an action is sent to this control /// </summary> /// <param name="args">args for the action</param> protected override void DoAction(Microsoft.Uii.Csr.RequestActionEventArgs args) { // Log process. LogWriter.Log(string.Format(CultureInfo.CurrentCulture, "{0} -- DoAction called for action: {1}", this.ApplicationName, args.Action), System.Diagnostics.TraceEventType.Information); if (args.Action.Equals("SetCacheSize", StringComparison.InvariantCultureIgnoreCase)) { List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession); string cachesizeString = Utility.GetAndRemoveParameter(parameters, "cachesize"); string allowGrowString = Utility.GetAndRemoveParameter(parameters, "allowgrow"); if (!String.IsNullOrEmpty(allowGrowString)) { allowGrow = bool.Parse(allowGrowString); } cachesize = 20; if (!String.IsNullOrEmpty(cachesizeString)) { cachesize = int.Parse(cachesizeString); } LoadupCache(); } else if (args.Action.Equals("ClearCache", StringComparison.InvariantCultureIgnoreCase)) { ClearCache(); } base.DoAction(args); }
private void ShowReminders(Microsoft.Uii.Csr.RequestActionEventArgs args = null) { if (args != null) { List <KeyValuePair <string, string> > argList = Utility.SplitLines(args.Data, CurrentContext, localSession); snoozeText = Utility.GetAndRemoveParameter(argList, "snooze"); dismissText = Utility.GetAndRemoveParameter(argList, "dismiss"); dismissallText = Utility.GetAndRemoveParameter(argList, "dismissall"); openitemText = Utility.GetAndRemoveParameter(argList, "openitem"); clicksnoozeText = Utility.GetAndRemoveParameter(argList, "clicksnooze"); dueText = Utility.GetAndRemoveParameter(argList, "due"); subjectText = Utility.GetAndRemoveParameter(argList, "subject"); } Dispatcher.Invoke(new Action(delegate { try { if (outlookNotificationWindow != null) { outlookNotificationWindow.Activate(); return; } outlookNotificationWindow = new OutlookNotification(this, notifyItems , snoozeText, dismissText, dismissallText, openitemText, clicksnoozeText, dueText, subjectText); outlookNotificationWindow.ShowInTaskbar = true; outlookNotificationWindow.Closing += new System.ComponentModel.CancelEventHandler(outlookNotificationWindow_Closing); outlookNotificationWindow.Show(); } catch (Exception ex) { DynamicsLogger.Logger.Log("ShowReminders: " + ex.Message + "\r\n" + ex.StackTrace); outlookNotificationWindow = null; } })); }
/// <summary> /// Raised when an action is sent to this control /// </summary> /// <param name="args">args for the action</param> protected override void DoAction(Microsoft.Uii.Csr.RequestActionEventArgs args) { // Log process. logWriter.Log(string.Format(CultureInfo.CurrentCulture, "{0} -- DoAction called for action: {1}", this.ApplicationName, args.Action), System.Diagnostics.TraceEventType.Information); base.DoAction(args); }
/// <summary> /// Raised when an action is sent to this control /// </summary> /// <param name="args">args for the action</param> protected override void DoAction(Microsoft.Uii.Csr.RequestActionEventArgs args) { // Log process. LogWriter.Log(string.Format(CultureInfo.CurrentCulture, "{0} -- DoAction called for action: {1}", this.ApplicationName, args.Action), System.Diagnostics.TraceEventType.Information); // Process Actions. if (args.Action.Equals("SetExpanderState", StringComparison.OrdinalIgnoreCase)) { List <KeyValuePair <string, string> > actionDataList = Utility.SplitLines(args.Data, CurrentContext, localSession); string ExpanderName = Utility.GetAndRemoveParameter(actionDataList, "ExpanderName"); string ExpanderRequestedState = Utility.GetAndRemoveParameter(actionDataList, "State"); // Call back to process the event to make sure we are on the same thread. Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { // Only act if we have the right data and the panel is in the right state. var frameworkItem = this.FindName(ExpanderName); if (frameworkItem != null && frameworkItem is Expander) { if (ExpanderRequestedState.Equals("expanded", StringComparison.OrdinalIgnoreCase)) { if (!((Expander)frameworkItem).IsExpanded) { ((Expander)frameworkItem).IsExpanded = true; } } if (ExpanderRequestedState.Equals("collapsed", StringComparison.OrdinalIgnoreCase)) { if (((Expander)frameworkItem).IsExpanded) { ((Expander)frameworkItem).IsExpanded = false; } } } })); } #region Example process action //if (args.Action.Equals("your action name", StringComparison.OrdinalIgnoreCase)) //{ // // Do some work // // Access CRM and fetch a Record // Microsoft.Xrm.Sdk.Messages.RetrieveRequest req = new Microsoft.Xrm.Sdk.Messages.RetrieveRequest(); // req.Target = new Microsoft.Xrm.Sdk.EntityReference( "account" , Guid.Parse("0EF05F4F-0D39-4219-A3F5-07A0A5E46FD5")); // req.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("accountid" , "name" ); // Microsoft.Xrm.Sdk.Messages.RetrieveResponse response = (Microsoft.Xrm.Sdk.Messages.RetrieveResponse)this._client.CrmInterface.ExecuteCrmOrganizationRequest(req, "Requesting Account"); // // Example of pulling some data out of the passed in data array // List<KeyValuePair<string, string>> actionDataList = Utility.SplitLines(args.Data, CurrentContext, localSession); // string valueIwant = Utility.GetAndRemoveParameter(actionDataList, "mykey"); // assume there is a myKey=<value> in the data. // // Example of pushing data to USD // string global = Utility.GetAndRemoveParameter(actionDataList, "global"); // Assume there is a global=true/false in the data // bool saveInGlobalSession = false; // if (!String.IsNullOrEmpty(global)) // saveInGlobalSession = bool.Parse(global); // Dictionary<string, CRMApplicationData> myDataToSet = new Dictionary<string, CRMApplicationData>(); // // add a string: // myDataToSet.Add("myNewKey", new CRMApplicationData() { name = "myNewKey", type = "string", value = "TEST" }); // // add a entity lookup: // myDataToSet.Add("myNewKey", new CRMApplicationData() { name = "myAccount", type = "lookup", value = "account,0EF05F4F-0D39-4219-A3F5-07A0A5E46FD5,MyAccount" }); // if (saveInGlobalSession) // { // // add context item to the global session // ((DynamicsCustomerRecord)((AgentDesktopSession)localSessionManager.GlobalSession).Customer.DesktopCustomer).MergeReplacementParameter(this.ApplicationName, myDataToSet, true); // } // else // { // // Add context item to the current session. // ((DynamicsCustomerRecord)((AgentDesktopSession)localSessionManager.ActiveSession).Customer.DesktopCustomer).MergeReplacementParameter(this.ApplicationName, myDataToSet, true); // } //} #endregion base.DoAction(args); }
/// <summary> /// Raised when an action is sent to this control /// </summary> /// <param name="args">args for the action</param> protected override void DoAction(Microsoft.Uii.Csr.RequestActionEventArgs args) { // Log process. LogWriter.Log(string.Format(CultureInfo.CurrentCulture, "{0} -- DoAction called for action: {1}", this.ApplicationName, args.Action), System.Diagnostics.TraceEventType.Information); if (args.Action.Equals("SetView", StringComparison.OrdinalIgnoreCase)) { List <KeyValuePair <string, string> > actionDataList = Utility.SplitLines(args.Data, CurrentContext, localSession); string value = Utility.GetAndRemoveParameter(actionDataList, "View"); // asume there is a myKey=<value> in the data. switch (value.ToLower()) { case "oneday": SetStyle(scheduler.OneDayStyle); break; case "workingweek": SetStyle(scheduler.WorkingWeekStyle); break; case "week": SetStyle(scheduler.WeekStyle); break; case "month": SetStyle(scheduler.MonthStyle); break; case "timeline": SetStyle(scheduler.TimeLineStyle); break; } #region Example process action // // Access CRM and fetch a Record // Microsoft.Xrm.Sdk.Messages.RetrieveRequest req = new Microsoft.Xrm.Sdk.Messages.RetrieveRequest(); // req.Target = new Microsoft.Xrm.Sdk.EntityReference( "account" , Guid.Parse("0EF05F4F-0D39-4219-A3F5-07A0A5E46FD5")); // req.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("accountid" , "name" ); // Microsoft.Xrm.Sdk.Messages.RetrieveResponse response = (Microsoft.Xrm.Sdk.Messages.RetrieveResponse)this._client.CrmInterface.ExecuteCrmOrganizationRequest(req, "Requesting Account"); // // Example of pulling some data out of the passed in data array // List<KeyValuePair<string, string>> actionDataList = Utility.SplitLines(args.Data, CurrentContext, localSession); // string valueIwant = Utility.GetAndRemoveParameter(actionDataList, "mykey"); // asume there is a myKey=<value> in the data. // // Example of pushing data to USD // string global = Utility.GetAndRemoveParameter(actionDataList, "global"); // Assume there is a global=true/false in the data // bool saveInGlobalSession = false; // if (!String.IsNullOrEmpty(global)) // saveInGlobalSession = bool.Parse(global); // Dictionary<string, CRMApplicationData> myDataToSet = new Dictionary<string, CRMApplicationData>(); // // add a string: // myDataToSet.Add("myNewKey", new CRMApplicationData() { name = "myNewKey", type = "string", value = "TEST" }); // // add a entity lookup: // myDataToSet.Add("myNewKey", new CRMApplicationData() { name = "myAccount", type = "lookup", value = "account,0EF05F4F-0D39-4219-A3F5-07A0A5E46FD5,MyAccount" }); // if (saveInGlobalSession) // { // // add context item to the global session // ((DynamicsCustomerRecord)((AgentDesktopSession)localSessionManager.GlobalSession).Customer.DesktopCustomer).MergeReplacementParameter(this.ApplicationName, myDataToSet, true); // } // else // { // // Add context item to the current session. // ((DynamicsCustomerRecord)((AgentDesktopSession)localSessionManager.ActiveSession).Customer.DesktopCustomer).MergeReplacementParameter(this.ApplicationName, myDataToSet, true); // } #endregion } base.DoAction(args); }