private void SetWidth(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parms = Utility.SplitLines(args.Data, CurrentContext, localSessionManager);
            string width = Utility.GetAndRemoveParameter(parms, "width");

            MyCanvas.Width = double.Parse(width);
        }
        /// <summary>
        /// The action event handler for UII is used to receive actions from other hosted controls or adapters in  UII.
        /// </summary>
        /// <param name="args"></param>
        protected override void DoAction(RequestActionEventArgs args)
        {
            //The action handler allows UII to accept actions from "non CTI aware" applications in the UII Space.
            // In this case we will show an example of a reject call command from the search provider.

            // Check to see if the requested action is "RejectCall"
            if (args.Action.Equals("RejectCall", StringComparison.InvariantCultureIgnoreCase))
            {
                // The UII Call ID that we would like to reject.
                if (!string.IsNullOrEmpty(args.Data))
                {
                    try
                    {
                        // Convert it to a Guid and call the local DoRejectCall Method.
                        DoRejectCall(new Guid(args.Data));
                    }
                    catch (Exception ex)
                    {
                        // Error here.
                    }
                }
            }

            // ... other handlers here as necessary

            base.DoAction(args);
        }
        private void CaptureEmailAttachments(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSession);

            id = Utility.GetAndRemoveParameter(parameters, "id");
            FileList.Items.Clear();
        }
 public void CloseApplication(RequestActionEventArgs args)
 {
     try
     {
         var application = GetParamValue(args, UsdParameter.Application);
         foreach (Session session in localSessionManager)
         {
             if (!session.Global)
             {
                 localSessionManager.SetActiveSession(session.SessionId);
             }
             foreach (IHostedApplication app in session)
             {
                 if (app.ApplicationName.Equals(application, StringComparison.OrdinalIgnoreCase))
                 {
                     FireRequestAction(new Microsoft.Uii.Csr.RequestActionEventArgs(application, UsdAction.Close, null));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.LogError($"Unexpected error has occurred while closing the applications.{ex.StackTrace.ToString()}");
         var eventParams = new Dictionary <string, string>
         {
             { "text", "Unexpected error has occurred while closing the applications." },
             { "caption", "Closing App - Error" },
         };
         FireRequestAction(new Microsoft.Uii.Csr.RequestActionEventArgs(UsdHostedControl.CrmGlobalManager, UsdAction.DisplayMessage, null));
     }
 }
        private WebRioSsoConfig GetWebRioSsoConfiguration(RequestActionEventArgs args)
        {
            var configuration = new WebRioSsoConfig();

            configuration.JSessionId  = GetParamValue(args, UsdParameter.WebRioJSessionId);
            configuration.RequestType = GetRequestType(args);
            if (configuration.RequestType == RequestType.TravelPlanner)
            {
                configuration.TravelPlannerId = GetParamValue(args, UsdParameter.EntityId);
                if (!string.IsNullOrWhiteSpace(configuration.TravelPlannerId))
                {
                    CrmService.GetInitialsFrom(_client.CrmInterface, configuration);
                }
            }
            if (configuration.RequestType == RequestType.Booking)
            {
                GetBookingDetails(args, configuration);
            }
            else if (configuration.RequestType == RequestType.TravelPlanner)
            {
                GetTravelPlannerDetails(args, configuration);
            }
            CrmService.GetWebRioSsoConfiguration(_client.CrmInterface, configuration);

            configuration.Login      = CrmService.GetSsoLoginDetails(_client.CrmInterface, _client.CrmInterface.GetMyCrmUserId());
            configuration.PrivateKey = CrmService.GetWebRioPrivateKey(_client.CrmInterface);
            ValidateConfiguration(configuration);
            return(configuration);
        }
        private void ShowForm(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > lines = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string formname = Utility.GetAndRemoveParameter(lines, "name");

            try
            {
                ParserContext pc = new ParserContext();
                pc.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                Entity theform = base.CRMWindowRouter.usdForms.Where(a => a.Attributes["msdyusd_name"].ToString().Equals(formname)).FirstOrDefault();
                if (theform != null)
                {
                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                    {
                        string replacedDisplay = Utility.GetContextReplacedString(theform.Attributes["msdyusd_markup"].ToString(), CurrentContext, localSession);
                        if (Utility.IsAllReplacementValuesReplaced(replacedDisplay))
                        {
                            byte[] displayData = System.Text.ASCIIEncoding.Unicode.GetBytes(replacedDisplay);
                            ms.Write(displayData, 0, displayData.Length);
                            ms.Seek(0, System.IO.SeekOrigin.Begin);
                            UIElement displayElement = XamlReader.Load(ms, pc) as UIElement;
                            MainGrid.Children.Add(displayElement);

                            HookupButtonClickEvents();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error in Form Viewer");
                Trace.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
 protected override void DoAction(RequestActionEventArgs args)
 {
     _logger.LogInformation($"{ApplicationName} -- DoAction called for action: {args.Action}");
     if (args.Action.Equals(EntityRecords.Configuration.OpenOwr, StringComparison.OrdinalIgnoreCase))
     {
         DoActionsOnOpenOwr(args);
     }
 }
Esempio n. 8
0
 private void HideTrayIcon(RequestActionEventArgs args)
 {
     if (notifyIcon == null)
     {
         return;
     }
     notifyIcon.Visible = false;
 }
Esempio n. 9
0
 protected override void DoAction(RequestActionEventArgs args)
 {
     // Log process.
     LogWriter.Log($"{ApplicationName} -- DoAction called for action: {args.Action}", TraceEventType.Information);
     if (args.Action.Equals(ActionName.OpenOwr, StringComparison.OrdinalIgnoreCase))
     {
         DoActionsOnOpenOwr(args);
     }
 }
 public void GetTravelPlannerDetails(RequestActionEventArgs args, WebRioSsoConfig configuration)
 {
     if (configuration.RequestType != RequestType.TravelPlanner)
     {
         return;
     }
     configuration.ConsultationReference = GetParamValue(args, UsdParameter.WebRioConsultationNo);
     configuration.CustomerId            = GetParamValue(args, UsdParameter.CustomerId);
 }
Esempio n. 11
0
        protected virtual void OnRequestClose(RequestActionEventArgs e)
        {
            var handler = this.RequestClose;

            if (handler != null)
            {
                handler(this, e);
            }
        }
 protected override void DoAction(RequestActionEventArgs args)
 {
     System.Diagnostics.Debug.WriteLine("Sessiontabs: DoAction " + args.Action + " data=" + args.Data);
     if (args.Action.Equals("CloseSession", StringComparison.InvariantCultureIgnoreCase))
     {
         List <KeyValuePair <string, string> > parameters = Utility.SplitLines(args.Data, CurrentContext, localSessionManager);
         string sessionId = Utility.GetAndRemoveParameter(parameters, "sessionid");
         if (String.IsNullOrEmpty(sessionId))
         {
             sessionId = localSessionManager.ActiveSession.SessionId.ToString();
         }
         FireEvent("SessionClosing", new Dictionary <string, string>()
         {
             { "SessionId", sessionId }
         });
         if (null != this.SessionClosed)
         {
             this.SessionClosed(this, null);
         }
         FireEvent("SessionClosed", new Dictionary <string, string>()
         {
             { "SessionId", sessionId }
         });
         return;
     }
     else if (args.Action.Equals("ResetProgressIndicator", StringComparison.InvariantCultureIgnoreCase))
     {
         throw new Exception("Not implemented");
         //Guid SessionId = Guid.Parse(args.Data);
         //ResetProgressIndicator(SessionId);
     }
     else if (args.Action.Equals("HideProgressIndicator", StringComparison.InvariantCultureIgnoreCase))
     {
         throw new Exception("Not implemented");
         //Guid SessionId = Guid.Parse(args.Data);
         //HideProgressIndicator(SessionId);
     }
     else if (args.Action.Equals("ChatAgentIndicator", StringComparison.InvariantCultureIgnoreCase))
     {
         throw new Exception("Not implemented");
         //Guid SessionId = Guid.Parse(args.Data);
         //StartChatIndicator(SessionId, true);
     }
     else if (args.Action.Equals("ChatCustomerIndicator", StringComparison.InvariantCultureIgnoreCase))
     {
         throw new Exception("Not implemented");
         //Guid SessionId = Guid.Parse(args.Data);
         //StartChatIndicator(SessionId, false);
     }
     else if (args.Action.Equals("HideChatIndicator", StringComparison.InvariantCultureIgnoreCase))
     {
         throw new Exception("Not implemented");
         //Guid SessionId = Guid.Parse(args.Data);
         //HideChatIndicator(SessionId);
     }
     base.DoAction(args);
 }
        private string GetParamValue(RequestActionEventArgs args, string paramName)
        {
            List <KeyValuePair <string, string> > actionDataList = Utility.SplitLines(args.Data, CurrentContext,
                                                                                      localSession);
            var paramValue = Utility.GetAndRemoveParameter(actionDataList, paramName);

            _logger.LogInformation($"Parameter {paramName} is {paramValue}");
            return(paramValue);
        }
        /// <summary>
        // If the citrix connection isn't yet established or has been disconnected, then the Citrix virtual channel
        // will timeout or otherwise hang.  This helps avoid this scenario.
        /// </summary>
        /// <param name="args">args for the action</param>
        protected override void DoAction(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 (this.VCClientComm.IsServerAlive)
            {
                base.DoAction(args);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Performs an action based on what the user entered in the text boxes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void runAction_Click(object sender, EventArgs e)
        {
            RequestActionEventArgs raArgs = new RequestActionEventArgs(application.Text, actionName.Text, actionData.Text);

            FireRequestAction(raArgs);
            if (raArgs.ActionReturnValue != null && raArgs.ActionReturnValue.Length > 0)
            {
                Trace.WriteLine(string.Format("{0}: ActionReturnValue: {1}", Name, raArgs.ActionReturnValue));
            }
        }
 public void EditFlagUserControl_ViewModel_Creating(object sender, RequestActionEventArgs<JryFlag> e)
 {
     this.Dispatcher.Invoke(async () =>
     {
         if (this.ViewModel.Items.Collection.FirstOrDefault(z => z.Source.Value == e.Arg.Value) != null)
         {
             e.IsAccept = false;
             await this.ShowMessageAsync("error", String.Format("the '{0}' was ready in {1}", e.Arg.Value, this.ViewModel.Type.GetLocalizeString()));
         }
     });
 }
Esempio n. 17
0
 public void EditFlagUserControl_ViewModel_Creating(object sender, RequestActionEventArgs <JryFlag> e)
 {
     this.Dispatcher.Invoke(() =>
     {
         if (this.ViewModel.Items.Collection.FirstOrDefault(z => z.Source.Value == e.Arg.Value) != null)
         {
             e.IsAccept = false;
             this.ShowJryVideoMessage("ERROR", $"the '{e.Arg.Value}' was ready in {this.ViewModel.Type.GetLocalizeString()}");
         }
     });
 }
Esempio n. 18
0
 public void EditFlagUserControl_ViewModel_Creating(object sender, RequestActionEventArgs<JryFlag> e)
 {
     this.Dispatcher.Invoke(() =>
     {
         if (this.ViewModel.Items.Collection.FirstOrDefault(z => z.Source.Value == e.Arg.Value) != null)
         {
             e.IsAccept = false;
             this.ShowJryVideoMessage("ERROR", $"the '{e.Arg.Value}' was ready in {this.ViewModel.Type.GetLocalizeString()}");
         }
     });
 }
Esempio n. 19
0
 private void ShowTrayIcon(RequestActionEventArgs args)
 {
     if (notifyIcon == null)
     {
         notifyIcon = new NotifyIcon();
         Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Microsoft.USD.ComponentLibrary.Resources.icoCRM.ico");
         notifyIcon.Icon         = new System.Drawing.Icon(s);
         notifyIcon.ContextMenu  = contextMenu;
         notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
     }
     notifyIcon.Visible = true;
 }
 /// <summary>
 /// Thread Safe version of the Uii Send Action
 /// </summary>
 /// <param name="oData"></param>
 private void SendAction(object oData)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new SendActionDel(SendAction), new object[] { oData });
     }
     else
     {
         SendCommandParams      cmd  = (SendCommandParams)oData;
         RequestActionEventArgs args = new RequestActionEventArgs(cmd.Target, cmd.Action, cmd.Data);
         FireRequestAction(args);
     }
 }
        private void ReadForm(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > lines = Utility.SplitLines(args.Data, CurrentContext, localSession);
            string clear     = Utility.GetAndRemoveParameter(lines, "clear");
            bool   clearBool = false;

            if (!String.IsNullOrEmpty(clear) && bool.TryParse(clear, out clearBool) && clearBool == true)
            {
                DynamicsCustomerRecord customerRecord = (DynamicsCustomerRecord)localSession.Customer.DesktopCustomer;
                customerRecord.ClearReplaceableParameter(this.ApplicationName);
            }
            ReadForm();
        }
Esempio n. 22
0
        private void AddMenuItem(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > argList = Utility.SplitLines(args.Data, CurrentContext, localSession);

            foreach (KeyValuePair <string, string> arg in argList)
            {
                System.Windows.Forms.MenuItem mi = new System.Windows.Forms.MenuItem();
                mi.Text   = arg.Key;
                mi.Tag    = arg.Value;
                mi.Click += Mi_Click;
                contextMenu.MenuItems.Add(mi);
            }
        }
        protected override void DoAction(RequestActionEventArgs args)
        {
            //Check the action name to see if it's something we know how to handle and perform appropriate work
            switch (args.Action)
            {
            case "UpdateFirstName":
                txtFirstName.Text = args.Data;
                break;

            case "UpdateLastName":
                txtLastName.Text = args.Data;
                break;
            }
        }
        protected override void DoAction(RequestActionEventArgs raArgs)
        {
            if (!_IsInitializationComplete)
            {
                Logging.Information(ApplicationName, "Incoming DoAction(" + raArgs.Action + ") while Citrix communication channels are not ready");
            }

            switch (raArgs.Action)
            {
            case AutomationImplicitAction.FindControl:
                if (_IsInitializationComplete)
                {
                    base.DoAction(raArgs);
                }
                else
                {
                    // the Citrix communication channels are not yet ready, so report false
                    raArgs.ActionReturnValue = bool.FalseString;
                }
                break;

            case AutomationImplicitAction.GetControlValue:
            case AutomationImplicitAction.SetControlValue:
            case AutomationImplicitAction.ExecuteControlAction:
            case AutomationImplicitAction.AddDoActionEventTrigger:
            case AutomationImplicitAction.RemoveDoActionEventTrigger:
                if (_IsInitializationComplete)
                {
                    base.DoAction(raArgs);
                }
                else
                {
                    // the Citrix communication channels are not yet ready, so dont bother transmitting the action to the stub
                    raArgs.ActionReturnValue = string.Empty;
                }
                break;

            // actions implemented via Automations on CitrixApplicationHostedControls are implemented in code here
            case "MsgHelloWorld":
                if (_IsInitializationComplete)
                {
                    Action action = new Action(0, raArgs.Action, @"<ActionInit><Automation>
<Type>Microsoft.Ccf.QuickStarts.QsAutomationProject.MsgHelloWorld,file://C:\CCF\Public\Microsoft.Ccf.Samples.Csr.AgentDesktop\Microsoft.Ccf.Samples\QuickStarts\QsAutomationProject\bin\Debug\Microsoft.Ccf.QuickStarts.QsAutomationProject.dll</Type>
</Automation></ActionInit>");
                    _AutomationAdapter.DoAction(action, raArgs);
                }
                break;
            }
        }
Esempio n. 25
0
        public void CallSsoService(RequestActionEventArgs args)
        {
            var requestType = GetParamValue(args, Configuration.OwrRequestType);
            var id          = GetParamValue(args, Configuration.OwrRecordIdParameterName);

            if (string.IsNullOrWhiteSpace(requestType) || string.IsNullOrWhiteSpace(id))
            {
                FireEventOnOwrError("Action is started with missing parameters");
                return;
            }
            if (requestType.Equals(OwrRequestType.TravelPlanner.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                CallTravelPlannerSso(id);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// please sure call obj.BuildMetaData() before call this.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected async Task <T> CommitAsync(IObjectEditProvider <T> provider, T obj)
        {
            if (obj.HasError())
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
                return(null);
            }

            switch (this.Action)
            {
            case ObjectChangedAction.Create:
                obj.ResetCreated();
                var arg = new RequestActionEventArgs <T>(obj)
                {
                    IsAccept = true
                };
                this.Creating.Fire(this, arg);
                if (arg.IsAccept && await provider.InsertAsync(obj))
                {
                    this.Clear();
                    this.Created.BeginFire(this, obj);
                    return(obj);
                }
                else
                {
                    return(null);
                }

            case ObjectChangedAction.Modify:
                if (await this.OnUpdateAsync(provider, obj))
                {
                    this.Updated.BeginFire(this, obj);
                    return(obj);
                }
                else
                {
                    return(null);
                }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void CallSsoService(RequestActionEventArgs args)
        {
            var opportunityId     = GetParamValue(args, EntityRecords.Configuration.OwrOpportunityIdParamName);
            var createdByInitials = GetCreatorsInitials(opportunityId);
            var login             = GetSsoDetails(_client.CrmInterface.GetMyCrmUserId());
            var privateKey        = GetPrivateInfo();
            var expiredSeconds    = GetConfig(EntityRecords.Configuration.OwrSsoTokenExpired);
            var notBeforeSeconds  = GetConfig(EntityRecords.Configuration.OwrSsoTokenNotBefore);
            var payload           = GetPayload(login, expiredSeconds, notBeforeSeconds, createdByInitials);
            var token             = _jtiService.CreateJwtToken(privateKey, payload);
            var data        = WebServiceExchangeHelper.GetCustomerTravelPlannerJson();
            var serviceUrl  = GetConfig(EntityRecords.Configuration.OwrUrlConfigName);
            var content     = _jtiService.SendHttpRequest(HttpMethod.Post, serviceUrl, token, data).Content;
            var eventParams = WebServiceExchangeHelper.ContentToEventParams(content);

            FireEvent(EntityRecords.Configuration.SsoCompleteEvent, eventParams);
        }
        private RequestType GetRequestType(RequestActionEventArgs args)
        {
            var requestType = GetParamValue(args, UsdParameter.WebRioRequestType);

            if (string.IsNullOrWhiteSpace(requestType))
            {
                return(RequestType.Other);
            }
            else if (requestType.Equals(RequestType.Admin.ToString(), StringComparison.OrdinalIgnoreCase) ||
                     requestType.Equals(RequestType.Booking.ToString(), StringComparison.OrdinalIgnoreCase) ||
                     requestType.Equals(RequestType.TravelPlanner.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                return((RequestType)Enum.Parse(typeof(RequestType), requestType, true));
            }
            else
            {
                return(RequestType.Other);
            }
        }
        protected override void DoAction(RequestActionEventArgs raArgs)
        {
            switch (raArgs.Action)
            {
            case "CustomAction1":
                break;

            case "CustomAction2":
                break;

            default:
                // This block is required.
                // route unrecognized Actions to the AutomationAdapter so HAT will work
                if (actions.Contains(raArgs.Action))
                {
                    _AutomationAdapter.DoAction(actions[raArgs.Action] as Action, raArgs);
                }
                break;
            }
        }
        private void SetProperties(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > proplines = Utility.SplitLines(args.Data, CurrentContext, localSession);

            bool.TryParse(Utility.GetAndRemoveParameter(proplines, "AddressBar"), out AddressBar);
            bool.TryParse(Utility.GetAndRemoveParameter(proplines, "MenuBar"), out MenuBar);
            bool.TryParse(Utility.GetAndRemoveParameter(proplines, "StatusBar"), out StatusBar);
            int.TryParse(Utility.GetAndRemoveParameter(proplines, "ToolBar"), out ToolBar);

            if (this.web != null)
            {
                this.web.AddressBar = AddressBar;
                this.web.MenuBar    = MenuBar;
                this.web.StatusBar  = StatusBar;
                this.web.ToolBar    = ToolBar;
                if (userCanClose == false)
                {
                    RemoveBrowserClose((IntPtr)web.HWND);
                }
            }
        }
        private void AddNotification(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parms = Utility.SplitLines(args.Data, CurrentContext, localSessionManager);
            string     text         = Utility.GetAndRemoveParameter(parms, "text");
            string     milliseconds = Utility.GetAndRemoveParameter(parms, "milliseconds");
            NotifyItem item         = new NotifyItem();
            TextBlock  tb           = new TextBlock();

            tb.Text             = text;
            item.animatedObject = tb;
            int result;

            if (int.TryParse(milliseconds, out result))
            {
                item.timeout = DateTime.Now + TimeSpan.FromMilliseconds(result);
            }
            lock (notifyItems)
                notifyItems.Add(item);
            if (notifyItems.Count == 1)
            {
                SetMarqueeText();
            }
        }
        public void GetBookingDetails(RequestActionEventArgs args, WebRioSsoConfig configuration)
        {
            if (configuration.RequestType != RequestType.Booking)
            {
                return;
            }
            var url        = GetParamValue(args, UsdParameter.Url);
            var decodedUrl = WebUtility.UrlDecode(url);

            decodedUrl = decodedUrl.Replace("%25", "");
            decodedUrl = decodedUrl.Replace("%3d", "=");

            var etc = decodedUrl.Substring(decodedUrl.IndexOf("etc="));

            configuration.ObjectTypeCode = etc.Substring(4, etc.IndexOf('&') - 4);


            var id = decodedUrl.Substring(decodedUrl.IndexOf("id="));

            id = id.Substring(3, id.IndexOf("7d") - 3);
            configuration.BookingSummaryId = id.Replace("7b", "");

            CrmService.GetConsultationReferenceFromBookingSummary(_client.CrmInterface, configuration);
        }
		protected virtual void OnRequestClose (RequestActionEventArgs e)
		{
			var handler = this.RequestClose;
			if (handler != null)
				handler (this, e);
		}