예제 #1
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);
        }
예제 #2
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);
        }