private void HandleCallStatus(ArrayList calls)
        {
            List <Call> callList = new List <Call>();

            foreach (Hashtable call in calls)
            {
                string     callId     = (string)call[CMessageParser.ApiStringConstants.CallStatusResponse.Id];
                HoldStates holdStatus = StringToHoldState((string)call[CMessageParser.ApiStringConstants.CallStatusResponse.HoldStatus]);

                List <CallParticipant> callParticipantList = new List <CallParticipant>();

                ArrayList participants = call[CMessageParser.ApiStringConstants.CallStatusResponse.Participants] as ArrayList;
                foreach (Hashtable participant in participants)
                {
                    string     number        = (string)participant[CMessageParser.ApiStringConstants.CallParticipant.Number];
                    string     displayName   = (string)participant[CMessageParser.ApiStringConstants.CallParticipant.DisplayName];
                    CallStates state         = StringToCallState((string)participant[CMessageParser.ApiStringConstants.CallParticipant.State]);
                    long       timeInitiated = System.Convert.ToInt64((string)participant[CMessageParser.ApiStringConstants.CallParticipant.TimeInitiated]);

                    CallParticipant callParticipant = new CallParticipant(number, displayName, state, timeInitiated);
                    callParticipantList.Add(callParticipant);
                }

                Call callData = new Call(callId, holdStatus, callParticipantList);
                callList.Add(callData);
            }

            if (OnCallStatus != null)
            {
                OnCallStatus(this, new CallStatusEventArgs(callList));
            }
        }
Exemplo n.º 2
0
        public static bool IsEmployee(this CallParticipant participant)
        {
            if (participant.Title == null) //If It is null, it is an external participant
            {
                return(false);
            }

            if (participant.Title.ToLower() == "operator" || participant.Name.ToLower() == "operator") //If it is the operator
            {
                return(false);
            }

            if (participant.Title.Contains("--"))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public async Task <string[]> PrepareTweetsFromTranscriptAsync(Transcript trans, int include_highlight_count)
        {
            //Sentence Value Pairs
            TextValuePair[] SVPs = null;
            try
            {
                SVPs = trans.RankSentences();
            }
            catch (Exception e)
            {
                throw new Exception("Fatal error while ranking transcript sentences. Internal error message: " + e.Message);
            }

            List <string> ToTweet = new List <string>();

            #region "First Tweet (Intro)"

            string Tweet1Text = "Earnings Call Highlights"; //The value here should be replaced anyway.

            //Get company symbol
            if (trans.Title.Contains("(") && trans.Title.Contains(")"))
            {
                int    loc1   = trans.Title.LastIndexOf("(");
                int    loc2   = trans.Title.IndexOf(")", loc1 + 1);
                string symbol = trans.Title.Substring(loc1 + 1, loc2 - loc1 - 1);
                Equity eq     = Equity.Create(symbol);
                await eq.DownloadSummaryAsync();

                Tweet1Text = eq.Summary.Name + " $" + symbol.ToUpper().Trim() + " held an earnings call on " + trans.CallDateTimeStamp.ToShortDateString() + ". Here are the highlights:";
            }
            else
            {
                Tweet1Text = trans.Title.Replace(" Transcript", "") + " highlights: ";
            }

            ToTweet.Add(Tweet1Text);

            #endregion

            #region "Highlights"

            int t = 0;

            for (t = 0; t < include_highlight_count; t++)
            {
                if (SVPs.Length >= (t + 1))
                {
                    try
                    {
                        //Find the speaker
                        CallParticipant speaker = trans.WhoSaid(SVPs[t].Text);

                        //Get the sentence
                        string sen = SVPs[t].Text;

                        //write the tweet
                        string ThisTweet = speaker.Name + ": \"" + sen + "\"";

                        //Trim it down (if it goes past 280 characters)
                        if (ThisTweet.Length > 280)
                        {
                            ThisTweet = ThisTweet.Substring(0, 276);
                            ThisTweet = ThisTweet + "...\"";
                        }

                        //Add it
                        ToTweet.Add(ThisTweet);
                    }
                    catch
                    {
                    }
                }
            }

            #endregion


            return(ToTweet.ToArray());
        }