Ejemplo n.º 1
0
        public List <CallIncoming> notRecallAnalyze()
        {
            List <CallIncoming> returnCalls = new List <CallIncoming>();
            var Stages = phones.Stages;

            foreach (var call in phones.getPhones())
            {
                FullCall LastCall = new FullCall(call.Value.phoneNumber,
                                                 call.Value.link,
                                                 call.Value.stages.First().Key,
                                                 call.Value.stages.First().Value.First().Date,
                                                 call.Value.stages.First().Value.First().Outgoing,
                                                 call.Value.stages.First().Value.First().comment,
                                                 call.Value.GetManager());
                DateTime datelastcallfirststage  = new DateTime();
                DateTime datelastcallsecondstage = new DateTime();
                foreach (var stage in call.Value.stages)
                {
                    foreach (var curCall in stage.Value)
                    {
                        if (curCall.Date > datelastcallfirststage && phones.Stages[stage.Key] == 1)
                        {
                            datelastcallfirststage = curCall.Date;
                            LastCall.date          = curCall.Date;
                            LastCall.stage         = stage.Key;
                            LastCall.outgoing      = curCall.Outgoing;
                            LastCall.Comment       = curCall.comment;
                        }
                        if (curCall.Date > datelastcallsecondstage && phones.Stages[stage.Key] == 2)
                        {
                            datelastcallfirststage = curCall.Date;
                        }
                    }
                }
                if (datelastcallfirststage != datelastcallsecondstage)
                {
                    var AddedCall = new ProcessedCall();
                    AddedCall.Client  = call.Value.phoneNumber;
                    AddedCall.Link    = call.Value.link;
                    AddedCall.Comment = LastCall.Comment;
                    if (!InputDoc.hasPhone(processedCalls, AddedCall))
                    {
                        returnCalls.Add(new CallIncoming(call.Value.phoneNumber, call.Value.link, String.Format("{0:dd.MM.yy}", datelastcallfirststage), LastCall.Comment + "\nДата второго звонка: " + (datelastcallsecondstage.Year > 2000 ?  datelastcallsecondstage.ToString("dd.MM.yyyy") : "отсутствует"), call.Value.GetManager(), new ProcessedCall(), call.Value.DealState, call.Value.DateDeal));
                    }
                    else
                    {
                        var samecall = InputDoc.getSamePhone(processedCalls, AddedCall);
                        if (samecall.ClientState != null && samecall.ClientState.ToUpper() == "В РАБОТЕ")
                        {
                            returnCalls.Add(new CallIncoming(call.Value.phoneNumber, call.Value.link,
                                                             String.Format("{0:dd.MM.yy}", datelastcallfirststage),
                                                             LastCall.Comment + "\nДата второго звонка: " + (datelastcallsecondstage.Year > 2000 ? datelastcallsecondstage.ToString("dd.MM.yyyy") : "отсутствует"), call.Value.GetManager(), samecall, call.Value.DealState, call.Value.DateDeal));
                        }
                    }
                }
            }
            return(returnCalls);
        }
Ejemplo n.º 2
0
        public List <CallPreAgreement> getCallsPreAgreement()
        {
            List <CallPreAgreement> returnCalls = new List <CallPreAgreement>();
            var Stages = phones.Stages;

            foreach (var phone in phones.getPhones())
            {
                string lastStage = getLastStage(phone.Value, phones.Stages);
                if (lastStage == PreAgreementStage)
                {
                    OneCall FirstCall = phone.Value.stages[lastStage].First();
                    foreach (var call in phone.Value.stages[lastStage])
                    {
                        if (call.Date < FirstCall.Date)
                        {
                            FirstCall = call;
                        }
                    }
                    OneCall LastCall = FirstCall;
                    foreach (var stage in phone.Value.stages)
                    {
                        foreach (var call in stage.Value)
                        {
                            if (LastCall.Date < call.Date)
                            {
                                LastCall = (OneCall)call.Clone();
                                if (stage.Key != lastStage)
                                {
                                    LastCall.comment = LastCall.comment + " (" + stage.Key + ") ";
                                }
                            }
                        }
                    }
                    var AddedCall = new ProcessedCall();
                    AddedCall.Client  = phone.Value.phoneNumber;
                    AddedCall.Comment = LastCall.comment;
                    if (!InputDoc.hasPhone(processedCalls, AddedCall))
                    {
                        returnCalls.Add(new CallPreAgreement(phone.Value.phoneNumber, phone.Value.link, String.Format("{0:dd.MM.yy}", LastCall.Date), LastCall.comment, lastStage, phone.Value.GetManager(), new ProcessedCall(), phone.Value.DealState, phone.Value.DateDeal));
                    }
                    else
                    {
                        var samecall = InputDoc.getSamePhone(processedCalls, AddedCall);
                        if (samecall.ClientState != null && samecall.ClientState.ToUpper() == "В РАБОТЕ")
                        {
                            returnCalls.Add(new CallPreAgreement(phone.Value.phoneNumber, phone.Value.link,
                                                                 String.Format("{0:dd.MM.yy}", LastCall.Date),
                                                                 LastCall.comment, lastStage, phone.Value.GetManager(), samecall, phone.Value.DealState, phone.Value.DateDeal));
                        }
                    }
                }
            }
            return(returnCalls);
        }
Ejemplo n.º 3
0
        public List <CallIncoming> getIncomeWithoutOutGoing()
        {
            List <CallIncoming> returnCalls = new List <CallIncoming>();
            var Stages = phones.Stages;

            foreach (var call in phones.getPhones())
            {
                FullCall LastCall = new FullCall(call.Value.phoneNumber,
                                                 call.Value.link,
                                                 call.Value.stages.First().Key,
                                                 call.Value.stages.First().Value.First().Date,
                                                 call.Value.stages.First().Value.First().Outgoing,
                                                 call.Value.stages.First().Value.First().comment,
                                                 call.Value.GetManager());
                foreach (var stage in call.Value.stages)
                {
                    foreach (var curCall in stage.Value)
                    {
                        if (curCall.Date > LastCall.date || (curCall.Date == LastCall.date && curCall.Outgoing))
                        {
                            LastCall.date     = curCall.Date;
                            LastCall.stage    = stage.Key;
                            LastCall.outgoing = curCall.Outgoing;
                            LastCall.Comment  = curCall.comment;
                        }
                    }
                }
                // !LastCall.outgoing && убрали, так как захотели, чтоб анализировали не только входящие
                if (!call.Value.stages.ContainsKey(AgreementStage))
                {
                    var AddedCall = new ProcessedCall();
                    AddedCall.Client  = call.Value.phoneNumber;
                    AddedCall.Link    = call.Value.link;
                    AddedCall.Comment = LastCall.Comment;
                    if (!InputDoc.hasPhone(processedCalls, AddedCall))
                    {
                        returnCalls.Add(new CallIncoming(call.Value.phoneNumber, call.Value.link, String.Format("{0:dd.MM.yy}", LastCall.date), LastCall.Comment, call.Value.GetManager(), new ProcessedCall(), call.Value.DealState, call.Value.DateDeal));
                    }
                    else
                    {
                        var samecall = InputDoc.getSamePhone(processedCalls, AddedCall);
                        if (samecall.ClientState != null && samecall.ClientState.ToUpper() == "В РАБОТЕ")
                        {
                            returnCalls.Add(new CallIncoming(call.Value.phoneNumber, call.Value.link,
                                                             String.Format("{0:dd.MM.yy}", LastCall.date),
                                                             LastCall.Comment, call.Value.GetManager(), samecall, call.Value.DealState, call.Value.DateDeal));
                        }
                    }
                }
            }


            return(returnCalls);
        }
Ejemplo n.º 4
0
        public List <CallPreAgreement> getCallsPreAgreement()
        {
            List <CallPreAgreement> returnCalls = new List <CallPreAgreement>();
            var Stages = phones.Stages;

            foreach (var call in phones.getPhones())
            {
                int    NumMaxStage = Stages.Values.Max();
                string maxStage    = call.Value.stages.First().Key;
                foreach (var stage in call.Value.stages)
                {
                    if (Stages[maxStage] < Stages[stage.Key])
                    {
                        maxStage = stage.Key;
                    }
                }


                if (Stages[maxStage] == NumMaxStage - 3)
                {
                    OneCall compcall = call.Value.stages[maxStage].First();
                    foreach (var date in call.Value.stages[maxStage])
                    {
                        if (compcall.Date < date.Date)
                        {
                            compcall = date;
                        }
                    }
                    var AddedCall = new ProcessedCall();
                    AddedCall.Client  = call.Key;
                    AddedCall.Link    = "";
                    AddedCall.Comment = compcall.comment;
                    if (!InputDoc.hasPhone(processedCalls, AddedCall))
                    {
                        returnCalls.Add(new CallPreAgreement(call.Value.phoneNumber, call.Value.link, String.Format("{0:dd.MM.yy}", compcall.Date), compcall.comment, maxStage, call.Value.GetManager(), new ProcessedCall(), call.Value.DealState, call.Value.DateDeal));
                    }
                    else
                    {
                        var samecall = InputDoc.getSamePhone(processedCalls, AddedCall);
                        if (samecall.ClientState != null && samecall.ClientState.ToUpper() == "В РАБОТЕ")
                        {
                            returnCalls.Add(new CallPreAgreement(call.Value.phoneNumber, call.Value.link, String.Format("{0:dd.MM.yy}", compcall.Date), compcall.comment, maxStage, call.Value.GetManager(),
                                                                 samecall, call.Value.DealState, call.Value.DateDeal));
                        }
                    }
                }
            }
            return(returnCalls);
        }
Ejemplo n.º 5
0
        public List <CallPerWeek> getCallsPerWeek()
        {
            List <CallPerWeek> returnCalls = new List <CallPerWeek>();

            var Stages = phones.Stages;


            foreach (var call in phones.getPhones())
            {
                FullCall LastCall = new FullCall(call.Value.phoneNumber,
                                                 call.Value.link,
                                                 call.Value.stages.First().Key,
                                                 call.Value.stages.First().Value.First().Date,
                                                 call.Value.stages.First().Value.First().Outgoing,
                                                 call.Value.stages.First().Value.First().comment,
                                                 call.Value.GetManager());
                foreach (var stage in call.Value.stages)
                {
                    foreach (var curCall in stage.Value)
                    {
                        if (curCall.Date > LastCall.date)
                        {
                            LastCall.date     = curCall.Date;
                            LastCall.stage    = stage.Key;
                            LastCall.outgoing = curCall.Outgoing;
                            LastCall.Comment  = curCall.comment;
                        }
                    }
                }

                TimeSpan t1 = DateTime.Now.Subtract(LastCall.date);

                if (((t1.TotalDays >= 23 && !DS) || (DS && t1.TotalDays > 61)) && !call.Value.stages.ContainsKey(AgreementStage))
                {
                    CallPerWeek curCall = new CallPerWeek();
                    curCall.FirstWeek   = "-";
                    curCall.phoneNumber = call.Value.phoneNumber;
                    curCall.Manager     = call.Value.GetManager();
                    if (call.Value.link != "")
                    {
                        curCall.Link = new XLHyperlink(new Uri(call.Value.link));
                    }
                    curCall.comment = LastCall.Comment;
                    if (!LastCall.outgoing)
                    {
                        curCall.comment = curCall.comment + " (Входящий)";
                    }
                    if (t1.TotalDays >= 30 && !DS)
                    {
                        curCall.SecondWeek = "-";
                    }
                    else
                    {
                        curCall.SecondWeek = "+";
                    }
                    //if (t1.TotalDays >= 22)
                    //{
                    //    curCall.ThirdWeek = "-";
                    //}
                    //else
                    //{
                    //    curCall.ThirdWeek = "+";
                    //}
                    var AddedCall = new ProcessedCall();
                    AddedCall.Client  = curCall.phoneNumber;
                    AddedCall.Link    = call.Value.link;
                    AddedCall.Comment = curCall.comment;
                    curCall.DateDeal  = "";
                    if (call.Value.DealState.ToUpper() != "В РАБОТЕ" && call.Value.DealState != "")
                    {
                        curCall.DealState = "Закрыт";
                        curCall.NoticeCRM = call.Value.DealState;
                        curCall.DateDeal  = call.Value.DateDeal.ToString("dd.MM.yyyy");
                    }
                    if (call.Value.DealState.ToUpper() == "В РАБОТЕ")
                    {
                        curCall.DealState = call.Value.DealState;
                        if (call.Value.DateDeal.Year > 2000)
                        {
                            curCall.DateDeal = call.Value.DateDeal.ToString("dd.MM.yyyy");
                        }
                    }

                    if (!InputDoc.hasPhone(processedCalls, AddedCall))
                    {
                        returnCalls.Add(curCall);
                    }
                    else
                    {
                        var samecall = InputDoc.getSamePhone(processedCalls, AddedCall);
                        if (samecall.ClientState != null && samecall.ClientState.ToUpper() == "В РАБОТЕ")
                        {
                            curCall.call = samecall;
                            returnCalls.Add(curCall);
                        }
                    }
                }
            }

            return(returnCalls);
        }
Ejemplo n.º 6
0
        public List <CallOneStage> getCallsOneStage()
        {
            List <CallOneStage> returnCalls = new List <CallOneStage>();
            var Stages = phones.Stages;

            foreach (var phone in phones.getPhones())
            {
                string  lastStage = getLastStage(phone.Value, phones.Stages);
                OneCall FirstCall = phone.Value.stages[lastStage].First();
                foreach (var call in phone.Value.stages[lastStage])
                {
                    if (call.Date < FirstCall.Date)
                    {
                        FirstCall = call;
                    }
                }
                List <OneCall> dt = new List <OneCall>();
                dt.Add(FirstCall);
                foreach (var stage in phone.Value.stages)
                {
                    foreach (var call in stage.Value)
                    {
                        if (call.Date > FirstCall.Date)
                        {
                            OneCall addcall = (OneCall)call.Clone();
                            if (stage.Key != lastStage)
                            {
                                addcall.comment = call.comment + " (" + stage.Key + ")";
                            }
                            dt.Add(addcall);
                        }
                    }
                }

                if (lastStage != AgreementStage && dt.Count > 2)
                {
                    CallOneStage curCall = new CallOneStage();

                    curCall.phoneNumber = phone.Value.phoneNumber;
                    curCall.Manager     = phone.Value.GetManager();
                    if (phone.Value.link != "")
                    {
                        curCall.Link = new XLHyperlink(new Uri(phone.Value.link));
                    }
                    curCall.qty   = dt.Count.ToString();
                    curCall.stage = lastStage;
                    curCall.date  = "";
                    string          comment  = "";
                    DateTime        lastDate = dt.First().Date;
                    List <DateTime> uniqDT   = new List <DateTime>();
                    foreach (var call in dt)
                    {
                        if (!uniqDT.Contains(call.Date))
                        {
                            curCall.date = curCall.date + String.Format("{0:dd.MM.yy}", call.Date) + ", ";
                            uniqDT.Add(call.Date);
                        }
                        if (lastDate < call.Date)
                        {
                            comment  = call.comment;
                            lastDate = call.Date;
                        }
                    }
                    curCall.date    = curCall.date.TrimEnd(' ').Trim(',');
                    curCall.comment = comment;
                    var AddedCall = new ProcessedCall();
                    AddedCall.Client  = phone.Value.phoneNumber;
                    AddedCall.Link    = phone.Value.link;
                    AddedCall.Comment = curCall.comment;
                    curCall.DateDeal  = "";
                    if (phone.Value.DealState.ToUpper() != "В РАБОТЕ" && phone.Value.DealState != "")
                    {
                        curCall.DealState = "Закрыт";
                        curCall.NoticeCRM = phone.Value.DealState;
                        curCall.DateDeal  = phone.Value.DateDeal.ToString("dd.MM.yyyy");
                    }
                    if (phone.Value.DealState.ToUpper() == "В РАБОТЕ")
                    {
                        curCall.DealState = phone.Value.DealState;
                        if (phone.Value.DateDeal.Year > 2000)
                        {
                            curCall.DateDeal = phone.Value.DateDeal.ToString("dd.MM.yyyy");
                        }
                    }
                    if (!InputDoc.hasPhone(processedCalls, AddedCall))
                    {
                        returnCalls.Add(curCall);
                    }
                    else
                    {
                        var samecall = InputDoc.getSamePhone(processedCalls, AddedCall);
                        if (samecall.ClientState != null && samecall.ClientState.ToUpper() == "В РАБОТЕ")
                        {
                            curCall.call = samecall;
                            returnCalls.Add(curCall);
                        }
                    }
                }
            }
            return(returnCalls);
        }
Ejemplo n.º 7
0
        public List <CallOneStage> getCallsOneStage()
        {
            List <CallOneStage> returnCalls = new List <CallOneStage>();
            var Stages = phones.Stages;

            foreach (var call in phones.getPhones())
            {
                string maxStage = call.Value.stages.First().Key;
                foreach (var stage in call.Value.stages)
                {
                    if (Stages[maxStage] < Stages[stage.Key])
                    {
                        maxStage = stage.Key;
                    }
                }
                if (Stages[maxStage] < Stages.Values.Max() && call.Value.stages[maxStage].Count > 2)
                {
                    CallOneStage curCall = new CallOneStage();
                    curCall.phoneNumber = call.Value.phoneNumber;
                    if (call.Value.link != "")
                    {
                        curCall.Link = new XLHyperlink(new Uri(call.Value.link));
                    }
                    curCall.qty     = call.Value.stages[maxStage].Count.ToString();
                    curCall.stage   = maxStage;
                    curCall.date    = "";
                    curCall.Manager = call.Value.GetManager();
                    string comment = "";
                    foreach (var date in call.Value.stages[maxStage])
                    {
                        curCall.date = curCall.date + String.Format("{0:dd.MM.yy}", date.Date) + ", ";
                        comment      = date.comment;
                    }
                    curCall.date    = curCall.date.TrimEnd(' ').Trim(',');
                    curCall.comment = comment;
                    var AddedCall = new ProcessedCall();
                    AddedCall.Client  = curCall.phoneNumber;
                    AddedCall.Link    = "";
                    AddedCall.Comment = curCall.comment;
                    curCall.DateDeal  = "";
                    if (call.Value.DealState.ToUpper() != "В РАБОТЕ" && call.Value.DealState != "")
                    {
                        curCall.DealState = "Закрыт";
                        curCall.NoticeCRM = call.Value.DealState;
                        curCall.DateDeal  = call.Value.DateDeal.ToString("dd.MM.yyyy");
                    }
                    if (call.Value.DealState.ToUpper() == "В РАБОТЕ")
                    {
                        curCall.DealState = call.Value.DealState;
                        if (call.Value.DateDeal.Year > 2000)
                        {
                            curCall.DateDeal = call.Value.DateDeal.ToString("dd.MM.yyyy");
                        }
                    }
                    if (!InputDoc.hasPhone(processedCalls, AddedCall))
                    {
                        returnCalls.Add(curCall);
                    }
                    else
                    {
                        var samecall = InputDoc.getSamePhone(processedCalls, AddedCall);
                        if (samecall.ClientState != null && samecall.ClientState.ToUpper() == "В РАБОТЕ")
                        {
                            curCall.call = samecall;
                            returnCalls.Add(curCall);
                        }
                    }
                }
            }
            return(returnCalls);
        }