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); }
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); }
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); }