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); }
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); }
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); }
public void AddCall(FullCall call) { phones.AddCall(call); }
public List <firstCallsToClient> getfirstCallForBelfan() { var returnCalls = new List <firstCallsToClient>(); var Stages = phones.Stages; foreach (var call in phonesForFirst.getPhones()) { FullCall LastCall = new FullCall(call.Key, "", 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()); var rStages = call.Value.stages.Where(s => Regex.Match(s.Key, "Первич|консульт|предварит", RegexOptions.IgnoreCase).Success); if (rStages.Any()) { foreach (var stage in call.Value.stages) { foreach (var curCall in stage.Value) { if (curCall.Date > LastCall.date) { if (rStages.Where(s => s.Key == stage.Key).Any()) { LastCall.date = curCall.Date; } LastCall.stage = stage.Key; LastCall.outgoing = curCall.Outgoing; LastCall.Comment = curCall.comment; } } } var FirstCalltoClient = new firstCallsToClient(); FirstCalltoClient.comment = LastCall.Comment; FirstCalltoClient.phoneNumber = call.Value.phoneNumber; if (call.Value.link != "") { FirstCalltoClient.Link = new XLHyperlink(new Uri(call.Value.link)); } else { FirstCalltoClient.Link = null; } FirstCalltoClient.date = String.Format("{0:dd.MM.yy}", LastCall.date); FirstCalltoClient.Manager = call.Value.GetManager(); FirstCalltoClient.DealState = call.Value.DealState; FirstCalltoClient.stage = String.Join(", ", rStages.Select(s => s.Key)); if (FirstCalltoClient.DealState.ToUpper() != "В РАБОТЕ" && FirstCalltoClient.DealState != "") { FirstCalltoClient.NoticeCRM = FirstCalltoClient.DealState; FirstCalltoClient.DateDeal = call.Value.DateDeal.ToString("dd.MM.yyyy"); } if (FirstCalltoClient.DealState.ToUpper() == "В РАБОТЕ") { FirstCalltoClient.DateDeal = call.Value.DateDeal.ToString("dd.MM.yyyy"); if (call.Value.DateDeal.Year < 2000) { FirstCalltoClient.DateDeal = ""; } } returnCalls.Add(FirstCalltoClient); } } return(returnCalls); }