Exemplo n.º 1
0
        /// <summary>
        /// Handle the Screen Pop to the user.
        /// </summary>
        /// <param name="interaction"></param>
        public void HandleInteraction(IInteraction interaction)
        {
            Boolean isChat, isIncident, isVoice = false;

            switch (interaction.Type)
            {
            case MediaType.Voice:

                SynchronizationContext.Current.Post(scree =>
                {
                    try
                    {
                        AsyncObservableCollection <Entities> UUIs = new AsyncObservableCollection <Entities>();
                        ScreenPopConfig screenPopConfigs          = interaction.ScreenPopConfiguration;


                        if (screenPopConfigs.CanScreenPop)
                        {
                            string UUIvalue           = interaction.InteractionData["UUI"];
                            ScreenPopOptions UUIstart = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUIStart", StringComparison.OrdinalIgnoreCase));
                            string start             = UUIstart == null ? ";" : UUIstart.Description;
                            ScreenPopOptions UUIstop = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUIStop", StringComparison.OrdinalIgnoreCase));
                            string stop             = UUIstop == null ? ":" : UUIstop.Description;
                            ScreenPopOptions UUIsep = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUISep", StringComparison.OrdinalIgnoreCase));
                            char seperator          = UUIsep == null ? '!' : UUIsep.Description.ToCharArray()[0];
                            int startindex          = UUIvalue.IndexOf(start, 0) + 1;
                            int lastindex           = UUIvalue.LastIndexOf(stop) == -1 ? UUIvalue.Length : UUIvalue.LastIndexOf(stop);
                            int len         = lastindex - startindex;
                            string[] uuival = UUIvalue.Substring(startindex, len).Split(seperator);

                            isChat     = Array.IndexOf(uuival, InteractionIQAType.FEAT_IQA_ORACLE_CHAT.ToString()) >= 0;
                            isIncident = Array.IndexOf(uuival, InteractionIQAType.FEAT_IQA_ORACLE_EMAIL.ToString()) >= 0;

                            ArrayList uuiCI = new ArrayList();

                            //Namachi
                            Regex UUICIRegex = new Regex("^UUI[1-2]", RegexOptions.IgnoreCase);
                            List <ScreenPopOptions> UUICI = screenPopConfigs.ScreenPopOptionsList.Where(p => p.Type == 0 && UUICIRegex.Matches(p.Name).Count > 0).ToList();
                            Regex UUIRegex = new Regex("^UUI[3-7]", RegexOptions.IgnoreCase);
                            List <ScreenPopOptions> UUI = screenPopConfigs.ScreenPopOptionsList.Where(p => p.Type == 0 && UUIRegex.Matches(p.Name).Count > 0).ToList();

                            //foreach (string filterval in uuival) {
                            //    if (filterval != UUICI[0].Description && filterval != UUICI[1].Description) uuiCI.Add(filterval);
                            //}
                            for (int i = 0; i < uuival.Length; i++)
                            {
                                if (i == 0 || i == 1)
                                {
                                    if ((uuival[i] != UUICI[0].Description && uuival[i] != UUICI[1].Description) && (uuival[i] != null && uuival[i] != ""))
                                    {
                                        uuiCI.Add(uuival[i]);
                                    }
                                }
                                else if (uuival[i] != UUICI[0].Description && uuival[i] != UUICI[1].Description)
                                {
                                    uuiCI.Add(uuival[i]);
                                }
                            }


                            int index          = 1;
                            bool IsMatched     = false;
                            string searchvalue = "";
                            if ((interaction as ICall).CallType == CallType.Inbound)
                            {
                                searchvalue = interaction.Address;
                            }
                            else
                            {
                                string[] address = interaction.InteractionData["Consult"].Split('|');
                                searchvalue      = address[0];
                            }

                            AsyncObservableCollection <Entities> consolidatefilter = CombineEntity((string[])uuiCI.ToArray(typeof(string)), UUI, searchvalue);

                            foreach (Entities filter in consolidatefilter)
                            {
                                string workspace   = filter.Entity;
                                bool found         = false;
                                Entities searchval = SearchEntites(filter);
                                if (searchval.IDs.Count > 0)
                                {
                                    Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals(searchval.Entity, StringComparison.OrdinalIgnoreCase));
                                    if (dup != null)
                                    {
                                        searchval.IDs.ToList().ForEach(x => dup.IDs.Add(x.ToString()));
                                    }
                                    else
                                    {
                                        UUIs.Add(searchval);
                                    }

                                    found = true;
                                }
                                if (!IsMatched && found)
                                {
                                    IsMatched = found;
                                }
                            }

                            Open(UUIs);
                            UUIs.Clear();


                            if ((interaction as ICall).CallType == CallType.Inbound)
                            {
                                ScreenPopOptions aniscreenpop = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("ANIPop", StringComparison.OrdinalIgnoreCase));
                                if (!IsMatched && aniscreenpop != null && aniscreenpop.Description == "Y")
                                {
                                    bool found = false;    // SearchAndPop("Contact", "Phones.RawNumber", "any_phone", searchvalue);

                                    Entities searchval = SearchEntites("Contact", "Phones.RawNumber", SEARCH_EXPRESSION["contact"].ToString(), searchvalue);
                                    //Entities searchval = SearchEntites("organization", "orgs.org_id", SEARCH_EXPRESSION["organization"].ToString(), searchvalue);
                                    if (searchval.IDs.Count > 0)
                                    {
                                        Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals(searchval.Entity, StringComparison.OrdinalIgnoreCase));
                                        if (dup != null)
                                        {
                                            searchval.IDs.ToList().ForEach(x => dup.IDs.Add(x.ToString()));
                                        }
                                        else
                                        {
                                            UUIs.Add(searchval);
                                        }

                                        found = true;
                                    }

                                    if (!IsMatched && found)
                                    {
                                        IsMatched = found;
                                    }
                                }
                                //if (!(screenPopConfigs.CanOpen) && !IsMatched && aniscreenpop.Description == "Y")
                                //{
                                //WorkspaceRecordType recordtype;
                                //if (Enum.TryParse<WorkspaceRecordType>(screenPopConfigs.DefaultWorkSpace, out recordtype))
                                //{
                                //    IsMatched = true;
                                //    RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype);
                                //}
                                //}

                                WorkspaceRecordType recordtype;
                                if (screenPopConfigs.ChatScreenPop)
                                {
                                    if (isChat && !IsMatched)
                                    {
                                        if (screenPopConfigs.CanOpenChat == false)
                                        {
                                            if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.ChatDefaultWorkspace, out recordtype))
                                            {
                                                IsMatched = true;
                                                RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype);
                                            }
                                        }
                                    }
                                }
                                if (screenPopConfigs.IncidentScreenPop)
                                {
                                    if (isIncident && !IsMatched)
                                    {
                                        if (screenPopConfigs.CanOpenIncident == false)
                                        {
                                            if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.IncidentDefaultWorkspace, out recordtype))
                                            {
                                                IsMatched = true;
                                                RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype);
                                            }
                                        }
                                    }
                                }
                                if (screenPopConfigs.VoiceScreenPop)
                                {
                                    if (!isIncident && !isChat && !IsMatched)
                                    {
                                        if (screenPopConfigs.CanOpen == false)
                                        {
                                            if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.DefaultWorkSpace, out recordtype))
                                            {
                                                IsMatched = true;
                                                RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype);
                                            }
                                        }
                                    }
                                }


                                Logger.Logger.Log.Info(string.Format("ScreenPopHandler: Inbound ScreenPop Address {0}", searchvalue));
                            }
                            else if ((interaction as ICall).CallType == CallType.Consult)
                            {
                                ScreenPopOptions aniscreenpop = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("TranPop", StringComparison.OrdinalIgnoreCase));
                                if (!IsMatched && aniscreenpop != null && (aniscreenpop.Description == "Y" || aniscreenpop.Description == "D"))
                                {
                                    bool found = false;    // SearchAndPop("Contact", "Phones.RawNumber", "any_phone", searchvalue);
                                    //"organization", "orgs.org_id"
                                    Entities searchval = SearchEntites("Contact", "Phones.RawNumber", SEARCH_EXPRESSION["contact"].ToString(), searchvalue);
                                    //Entities searchval = SearchEntites("organization", "organization.org_id", SEARCH_EXPRESSION["organization"].ToString(), searchvalue);
                                    if (searchval.IDs.Count > 0)
                                    {
                                        Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals(searchval.Entity, StringComparison.OrdinalIgnoreCase));
                                        if (dup != null)
                                        {
                                            searchval.IDs.ToList().ForEach(x => dup.IDs.Add(x.ToString()));
                                        }
                                        else
                                        {
                                            UUIs.Add(searchval);
                                        }

                                        found = true;
                                    }
                                    if (!IsMatched && found)
                                    {
                                        IsMatched = found;
                                    }
                                }

                                if (!(screenPopConfigs.CanOpen) && !IsMatched && (aniscreenpop.Description == "Y" || aniscreenpop.Description == "D"))
                                {
                                    WorkspaceRecordType recordtype;
                                    if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.DefaultWorkSpace, out recordtype))
                                    {
                                        IsMatched = true;
                                        RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype);
                                    }
                                }
                                Logger.Logger.Log.Info(string.Format("ScreenPopHandler: Consult ScreenPop Address {0}  UUI = {1}", searchvalue, UUIvalue));
                            }
                            Open(UUIs);

                            UUIs.Clear();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Logger.Log.Error("ScreenPopHandler", ex);
                    }
                }, null);

                break;

            case MediaType.Web:
            case MediaType.Email:
                RightNowGlobalContext.AutomationContext.EditWorkspaceRecord(WorkspaceRecordType.Incident, long.Parse(interaction.AdditionalIdentifiers["ReferenceId"]));
                break;

            default:
                return;
            }
        }
Exemplo n.º 2
0
        void LoadDbcExecute()
        {
            try
            {
                FilterOutString = "Loading database";
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.DefaultExt = ".dbc";
                dlg.Filter     = "DBC Files (*.dbc)|*.dbc";
                if (dlg.ShowDialog() == true)
                {
                    String sPath = dlg.FileName;
                    if (System.IO.File.Exists(sPath))
                    {
                        const string MESSAGES_EXP = @"BO_ (?<message_id>[0-9]+) (?<message_name>[a-zA-Z0-9_]+): (?<message_dlc>[0-8]) (?<message_ecu>[a-zA-Z0-9_]+)\r\n(?<message_signals>( SG_[^\r\n]+\r\n)+)";
                        const string SIGNALS_EXP  = @"SG_ (?<signal_name>[a-zA-Z0-9_]+)(?<signal_sbit>[a-zA-Z0-9_ ]*): (?<signal_sbit>[0-9]+)\|(?<signal_len>[0-9]+)\@(?<signal_intel>[0-9]+)(?<signal_signed>[\+\-]+)";

                        StreamReader    sr          = new StreamReader(sPath);
                        String          FileContent = sr.ReadToEnd();
                        MatchCollection mcMessages  = Regex.Matches(FileContent, MESSAGES_EXP, RegexOptions.Multiline);
                        Match           mComment;
                        Int64           i64MsgId;
                        string          sCommentPattern;
                        _messages.Clear();
                        foreach (Match mMessages in mcMessages)
                        {
                            CMessageViewModel oMsvm = new CMessageViewModel();
                            i64MsgId = Convert.ToInt64(mMessages.Groups["message_id"].Value);
                            if (i64MsgId == 1414)
                            {
                            }
                            if (i64MsgId <= Int32.MaxValue)
                            {
                                oMsvm.MessageId   = Convert.ToInt32(i64MsgId);
                                oMsvm.MessageName = Convert.ToString(mMessages.Groups["message_name"].Value);
                                oMsvm.MessageDlc  = Convert.ToInt32(mMessages.Groups["message_dlc"].Value);
                                oMsvm.MessageEcu  = Convert.ToString(mMessages.Groups["message_ecu"].Value);
                                oMsvm.MessageData = new byte[oMsvm.MessageDlc];
                                sCommentPattern   = @"CM_ BO_ " + mMessages.Groups["message_id"].Value.ToString() + @" ""(?<message_comment>.*)""";
                                mComment          = Regex.Match(FileContent, sCommentPattern);
                                if (mComment.Success)
                                {
                                    oMsvm.MessageComment = mComment.Groups["message_comment"].Value;
                                }
                                MatchCollection mcSignals = Regex.Matches(mMessages.Groups["message_signals"].ToString(), SIGNALS_EXP, RegexOptions.Multiline);
                                foreach (Match mSignals in mcSignals)
                                {
                                    CSignalViewModel oSigvm = new CSignalViewModel();
                                    oSigvm.SignalName     = Convert.ToString(mSignals.Groups["signal_name"].Value);
                                    oSigvm.SignalStartBit = Convert.ToInt32(mSignals.Groups["signal_sbit"].Value);
                                    oSigvm.SignalLenght   = Convert.ToInt32(mSignals.Groups["signal_len"].Value);
                                    oSigvm.SignalIntel    = Convert.ToString(mSignals.Groups["signal_intel"].Value);
                                    oSigvm.SignalSigned   = Convert.ToString(mSignals.Groups["signal_signed"].Value);
                                    sCommentPattern       = @"CM_ SG_ " + mMessages.Groups["message_id"].Value.ToString() + @" " + mSignals.Groups["signal_name"].Value.ToString() + @" ""(?<signal_comment>.*)""";
                                    mComment = Regex.Match(FileContent, sCommentPattern);
                                    if (mComment.Success)
                                    {
                                        oSigvm.SignalComment = mComment.Groups["signal_comment"].Value;
                                    }
                                    oMsvm.Signals.Add(oSigvm);
                                }
                                this.Messages.Add(oMsvm);
                            }
                        }
                        ProjectPathDbc = (String)sPath;
                    }
                    else
                    {
                        MessageBox.Show(String.Format("The File {0} does not exist", sPath));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            FilterOutString = "Database loaded";
        }