public Collection <ConnectMe> GetAllConnectMe(ConnectMe request) { request.SPCalled = "[DBO].[GetConnectMe]"; var dataCollection = new Collection <ConnectMe>(); SqlDataReader reader = GetSPDetails(request); ConnectMe objFirst = new ConnectMe() { SessionDate = "SessionDate", alias = "Alias", sessionId = "Session ID", chatId = "ChatId", SessionStartTime = "SessionStartTime", ChatStartTime = "ChatStartTime", ChatRequestedTime = "ChatRequestedTime", ChatEndTime = "ChatEndTime", BOTTime = "BOTTime", AgentChatWaitTime = "AgentChatWaitTime", PostCallWork = "PostCallWork", AgentAbandoned = "AgentAbandoned", CallAvoided = "CallAvoided", AgentChatDuration = "AgentChatDuration", SessionDuration = "SessionDuration", Country = "Country", Topic = "Topic", SupervisorActivity = "SupervisorActivity", AgentChatMonth = "AgentChatMonth", SessionMonth = "SessionMonth" }; dataCollection.Add(objFirst); while (reader.HasRows) { while (reader.Read()) { ConnectMe obj = new ConnectMe(); obj.SessionDate = reader["SessionDate"].ToString() == null ? "" : reader["SessionDate"].ToString(); obj.alias = reader["alias"].ToString() == null ? "" : reader["alias"].ToString(); obj.sessionId = "1"; obj.chatId = "1"; obj.SessionStartTime = reader["SessionStartTime"].ToString(); obj.ChatStartTime = reader["ChatStartTime"].ToString() == null ? "" : reader["ChatStartTime"].ToString(); obj.ChatRequestedTime = reader["ChatRequestedTime"].ToString() == null ? "" : reader["ChatRequestedTime"].ToString(); obj.ChatEndTime = reader["ChatEndTime"].ToString() == null ? "" : reader["ChatEndTime"].ToString(); obj.BOTTime = reader["BOTTime"].ToString() == null ? "" : reader["BOTTime"].ToString(); obj.AgentChatWaitTime = reader["AgentChatWaitTime"].ToString(); obj.PostCallWork = reader["PostCallWork"].ToString() == null ? "" : reader["PostCallWork"].ToString(); obj.AgentAbandoned = reader["AgentAbandoned"].ToString() == null ? "" : reader["AgentAbandoned"].ToString(); obj.CallAvoided = reader["CallAvoided"].ToString() == null ? "" : reader["CallAvoided"].ToString(); obj.AgentChatDuration = reader["AgentChatDuration"].ToString() == null ? "" : reader["AgentChatDuration"].ToString(); obj.SessionDuration = reader["SessionDuration"].ToString() == null ? "" : reader["SessionDuration"].ToString(); obj.Country = reader["Country"].ToString() == null ? "" : reader["Country"].ToString(); obj.Topic = reader["Topic"].ToString() == null ? "" : reader["Topic"].ToString(); obj.SupervisorActivity = reader["SupervisorActivity"].ToString() == null ? "" : reader["SupervisorActivity"].ToString(); obj.AgentChatMonth = reader["AgentChatMonth"].ToString() == null ? "" : reader["AgentChatMonth"].ToString(); obj.SessionMonth = reader["SessionMonth"].ToString() == null ? "" : reader["SessionMonth"].ToString(); dataCollection.Add(obj); } reader.NextResult(); } return(dataCollection); }
public Collection <ConnectMe> GetAllConnectMe(ConnectMe request) { return(_repository.GetAllConnectMe(request)); }
// GET: ConnectMe public ActionResult ConnectMe() { IEnumerable <ConnectMe> _connectMe = null; var modelObj = new ConnectMe(); var SCRequestData = new Collection <ConnectMe>(); PivotService _pivotService = new PivotService(); SCRequestData = _pivotService.GetAllConnectMe(modelObj); _connectMe = (from item in SCRequestData select new ConnectMe { SessionDate = item.SessionDate, alias = item.alias, sessionId = item.sessionId, chatId = item.chatId, SessionStartTime = item.SessionStartTime, ChatStartTime = item.ChatStartTime, ChatRequestedTime = item.ChatRequestedTime, ChatEndTime = item.ChatEndTime, BOTTime = item.BOTTime, AgentChatWaitTime = item.AgentChatWaitTime, PostCallWork = item.PostCallWork, AgentAbandoned = item.AgentAbandoned, CallAvoided = item.CallAvoided, AgentChatDuration = item.AgentChatDuration, SessionDuration = item.SessionDuration, Country = item.Country, Topic = item.Topic, SupervisorActivity = item.SupervisorActivity, AgentChatMonth = item.AgentChatMonth, SessionMonth = item.SessionMonth, }); var result = new StringBuilder(); foreach (var item in _connectMe) { result.Append(item.SessionDate + "," + item.alias + "," + item.sessionId + "," + item.chatId + "," + item.SessionStartTime + "," + item.ChatStartTime + "," + item.ChatRequestedTime + "," + item.ChatEndTime + "," + item.BOTTime + "," + item.AgentChatWaitTime + "," + item.PostCallWork + "," + item.AgentAbandoned + "," + item.CallAvoided + "," + item.AgentChatDuration + "," + item.SessionDuration + "," + item.Country + "," + item.Topic + "," + item.SupervisorActivity + "," + item.AgentChatMonth + "," + item.SessionMonth + "\n"); } System.IO.File.WriteAllText(@"D:\Pivot\PivotExcel05-01-2017\PivotExcel\MSIT.Web.ExcelPivot\MSIT.Web.ExcelPivot\data.csv", Convert.ToString(result)); string newFileName = AppDomain.CurrentDomain.BaseDirectory + "data.csv"; return(View()); }