Exemplo n.º 1
0
        /// <summary>
        /// Executes the specified param.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();

            try
            {
                Match match = m_regex.Match(param);
                if (match.Success)
                {
                    string imagefile = match.Groups["imagepath"].Value.Replace("/", "\\");

                    // get latest image file from directory, notation example: @"c:\temp\test*.jpg"
                    if (imagefile.Contains("*"))
                    {
                        imagefile = GetFileInfo.GetNewestImage(imagefile);
                    }

                    opResult.AppendFormat("response={0}", AddInHost.Current.MediaCenterEnvironment.DialogNotification(
                                              match.Groups["message"].Value,
                                              new System.Collections.ArrayList(1),
                                              int.Parse(match.Groups["timeout"].Value),
                                              "file://" + imagefile
                                              ).ToString());
                    opResult.StatusCode = OpStatusCode.Ok;
                }
            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return(opResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the specified param.
        /// </summary>
        /// <param name="param">The param.</param>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();

            try
            {
                Match match = m_regex.Match(param);
                System.Collections.ArrayList buttonArray = new System.Collections.ArrayList();
                System.Collections.Hashtable buttonHT    = new System.Collections.Hashtable();

                int customButtonID = 100;

                if (match.Groups["buttoncodes"].Value.Length > 0)
                {
                    string[] buttons = match.Groups["buttoncodes"].Value.Split(';');

                    foreach (string button in buttons)
                    {
                        switch (button)
                        {
                        case "OK":
                            buttonArray.Add(1);
                            break;

                        case "Cancel":
                            buttonArray.Add(2);
                            break;

                        case "Yes":
                            buttonArray.Add(4);
                            break;

                        case "No":
                            buttonArray.Add(8);
                            break;

                        default:
                            buttonArray.Add(button);
                            buttonHT.Add(customButtonID.ToString(), button);
                            customButtonID++;
                            break;
                        }
                    }
                }

                if (match.Success)
                {
                    responseReceived = false;
                    dlg = new DialogClosedCallback(On_DialogResult);

                    string imagefile = match.Groups["imagepath"].Value.Replace("/", "\\");

                    // get latest image file from directory, notation example: @"c:\temp\test*.jpg"
                    if (imagefile.Contains("*"))
                    {
                        imagefile = GetFileInfo.GetNewestImage(imagefile);
                    }

                    AddInHost.Current.MediaCenterEnvironment.Dialog(
                        match.Groups["message"].Value
                        , match.Groups["caption"].Value
                        , buttonArray
                        , int.Parse(match.Groups["timeout"].Value)
                        , match.Groups["modal"].Value == "modal" ? true:false
                        , "file://" + imagefile
                        , dlg);

                    //wait for a response
                    while (!responseReceived)
                    {
                        System.Threading.Thread.Sleep(100);
                    }

                    string btnResult = "";

                    switch (m_dlgResult.ToString())
                    {
                    case "100":
                    case "101":
                    case "102":
                        btnResult = (string)buttonHT[m_dlgResult.ToString()];
                        break;

                    default:
                        btnResult = m_dlgResult.ToString();
                        break;
                    }

                    opResult.AppendFormat("response={0}", btnResult);

                    opResult.StatusCode = OpStatusCode.Success;
                }
            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return(opResult);
        }