private JObject CallBackRequestManagement(HttpContext context) { JObject responseJObj = new JObject(); try { //status: status, assignesAgentId: assignedAgentId, skillGroupId: skillGroupId, // dialOutType : dialOuttype,fromDate : fromDate,toDate : toDate Press3.BusinessRulesLayer.Calls callsObject = new Press3.BusinessRulesLayer.Calls(); UserDefinedClasses.CallbackRequest cbrObj = new UserDefinedClasses.CallbackRequest(); cbrObj.Mode = Convert.ToInt32(context.Request["mode"]); cbrObj.AccountId = accountId; cbrObj.AgentId = agentId; cbrObj.DialType = context.Request["dialType"] != null?Convert.ToInt32(context.Request["dialType"]) : 0; if (cbrObj.Mode == 1) { cbrObj.DateTime = context.Request["dateTime"] != null ? context.Request["dateTime"].ToString() : ""; cbrObj.Mobile = context.Request["mobile"] != null ? context.Request["mobile"].ToString() : ""; cbrObj.Notes = context.Request["notes"] != null ? context.Request["notes"].ToString() : ""; cbrObj.CallerId = context.Request["callerId"] != null?Convert.ToInt32(context.Request["callerId"]) : 0; cbrObj.CallId = context.Request["callId"] != null?Convert.ToInt32(context.Request["callId"]) : 0; } else if (cbrObj.Mode == 2) { cbrObj.CbrId = context.Request["CbrId"] != null?Convert.ToInt32(context.Request["CbrId"]) : 0; cbrObj.SearchText = context.Request["searchText"] != null ? context.Request["searchText"].ToString() : ""; cbrObj.AssignedAgentId = context.Request["assignesAgentId"] != null?Convert.ToInt32(context.Request["assignesAgentId"]) : 0; cbrObj.StatusId = context.Request["status"] != null?Convert.ToInt32(context.Request["status"]) : 0; cbrObj.SkillGroupId = context.Request["skillGroupId"] != null?Convert.ToInt32(context.Request["skillGroupId"]) : 0; cbrObj.FromDate = context.Request["fromDate"] != null ? context.Request["fromDate"].ToString() : ""; cbrObj.ToDate = context.Request["toDate"] != null ? context.Request["toDate"].ToString() : ""; cbrObj.StudioId = context.Request["StudioId"] != null?Convert.ToInt32(context.Request["StudioId"].ToString()) : 0; } cbrObj.PageNumber = context.Request["index"] != null?Convert.ToInt32(context.Request["index"].ToString()) : 1; cbrObj.PageSize = context.Request["length"] != null?Convert.ToInt32(context.Request["length"].ToString()) : 7; responseJObj = callsObject.CallBackRequestManagement(MyConfig.MyConnectionString, cbrObj); } catch (Exception ex) { Logger.Error(ex.ToString()); } return(responseJObj); }
public JObject CallBackRequestManagement(string connection, UserDefinedClasses.CallbackRequest cbrObj) { try { Press3.DataAccessLayer.Calls callsObject = new Press3.DataAccessLayer.Calls(connection); DataSet ds = callsObject.CallBackRequestManagement(cbrObj); if (ds == null) { helper.CreateProperty(UDC.Label.MESSAGE, "No data returned from database"); helper.CreateProperty(UDC.Label.SUCCESS, false); } else { helper.ParseDataSet(ds); } } catch (Exception ex) { Logger.Error("Exception In AgentLogout " + ex.ToString()); } return(helper.GetResponse()); }
public DataSet CallBackRequestManagement(UserDefinedClasses.CallbackRequest cbrObj) { _cmd = new SqlCommand(); _ds = new DataSet(); _da = new SqlDataAdapter(); try { _cmd.CommandText = "CallBackRequestManagement"; _cmd.CommandType = CommandType.StoredProcedure; _cmd.Connection = Connection; _cmd.Parameters.Add("@Mode", SqlDbType.TinyInt).Value = cbrObj.Mode; _cmd.Parameters.Add("@AccountId", SqlDbType.BigInt).Value = cbrObj.AccountId; _cmd.Parameters.Add("@AgentId", SqlDbType.BigInt).Value = cbrObj.AgentId; _cmd.Parameters.Add("@DialType", SqlDbType.TinyInt).Value = cbrObj.DialType; if (cbrObj.Mode == 1) { _cmd.Parameters.Add("@Mobile", SqlDbType.VarChar, 15).Value = cbrObj.Mobile; _cmd.Parameters.Add("@DateTime", SqlDbType.VarChar, 50).Value = cbrObj.DateTime; _cmd.Parameters.Add("@Notes", SqlDbType.NVarChar, -1).Value = cbrObj.Notes; _cmd.Parameters.Add("@CallerId", SqlDbType.Int).Value = cbrObj.CallerId; _cmd.Parameters.Add("@CallId", SqlDbType.Int).Value = cbrObj.CallId; } else if (cbrObj.Mode == 2) { _cmd.Parameters.Add("@CbrId", SqlDbType.Int).Value = cbrObj.CbrId; _cmd.Parameters.Add("@SearchText", SqlDbType.VarChar, 50).Value = cbrObj.SearchText; _cmd.Parameters.Add("@FromDate", SqlDbType.VarChar, 50).Value = cbrObj.FromDate; _cmd.Parameters.Add("@ToDate", SqlDbType.VarChar, 50).Value = cbrObj.ToDate; _cmd.Parameters.Add("@AssignedTo", SqlDbType.BigInt).Value = cbrObj.AssignedAgentId; _cmd.Parameters.Add("@SkillGroupId", SqlDbType.Int).Value = cbrObj.SkillGroupId; _cmd.Parameters.Add("@StatusId", SqlDbType.TinyInt).Value = cbrObj.StatusId; _cmd.Parameters.Add("@StudioId_", SqlDbType.Int).Value = cbrObj.StudioId; } _cmd.Parameters.Add("@PageNumber", SqlDbType.Int).Value = cbrObj.PageNumber; _cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value = cbrObj.PageSize; _cmd.Parameters.Add("@Total", SqlDbType.Int).Direction = ParameterDirection.Output; _cmd.Parameters.Add("@IsInCall", SqlDbType.Bit).Direction = ParameterDirection.Output; _cmd.Parameters.Add("@Message", SqlDbType.VarChar, 200).Direction = ParameterDirection.Output; _cmd.Parameters.Add("@Success", SqlDbType.Bit).Direction = ParameterDirection.Output; _da.SelectCommand = _cmd; _da.Fill(_ds); if (_ds.Tables.Count > 0) { int temp = _ds.Tables[0].Rows.Count; _ds.Tables[0].TableName = "CallBackRequests"; } _ds.Tables.Add(_helper.ConvertOutputParametersToDataTable(_cmd.Parameters)); } catch (Exception ex) { Logger.Error(ex.ToString()); throw; } finally { Connection.Close(); _cmd = null; } return(_ds); }
protected void DownloadToExcel_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); UserDefinedClasses.CallbackRequest cbrObj = new UserDefinedClasses.CallbackRequest(); cbrObj.Mode = 2; cbrObj.AccountId = Session["AccountId"] != null?Convert.ToInt32(Session["AccountId"]) : 0; cbrObj.AgentId = Session["AgentId"] != null?Convert.ToInt32(Session["AgentId"]) : 0; cbrObj.AssignedAgentId = hdnStickyAgent.Value != null?Convert.ToInt32(hdnStickyAgent.Value) : 0; cbrObj.StatusId = hdnstatus.Value != null?Convert.ToInt32(hdnstatus.Value) : 0; cbrObj.SkillGroupId = hdnSkillGroup.Value != null?Convert.ToInt32(hdnSkillGroup.Value) : 0; cbrObj.DialType = hdnDialOutType.Value != null?Convert.ToInt32(hdnDialOutType.Value) : 0; cbrObj.FromDate = hdnFromDate.Value != null?hdnFromDate.Value.ToString() : ""; cbrObj.ToDate = hdnToDate.Value != null?hdnToDate.Value.ToString() : ""; cbrObj.SearchText = hdnSearchText.Value != null?hdnSearchText.Value.ToString() : ""; cbrObj.StudioId = hdnStudioId.Value != null?Convert.ToInt32(hdnStudioId.Value) : 0; cbrObj.PageNumber = 1; cbrObj.PageSize = 0; Press3.BusinessRulesLayer.Calls callObj = new Press3.BusinessRulesLayer.Calls(); ds = callObj.DownloadCallBackRequests(MyConfig.MyConnectionString, cbrObj); string file_name = ""; if (ds.Tables[0].Rows.Count > 0) { try { var wb = new XSSFWorkbook(); var sheet = wb.CreateSheet("sheet1"); dynamic headerRow = sheet.CreateRow(0); //headerRow.CreateCell(0).SetCellValue("Id"); headerRow.CreateCell(0).SetCellValue("Status"); headerRow.CreateCell(1).SetCellValue("Closed By"); headerRow.CreateCell(2).SetCellValue("Scheduled On"); headerRow.CreateCell(3).SetCellValue("Caller Name"); headerRow.CreateCell(4).SetCellValue("Mobile Number"); headerRow.CreateCell(5).SetCellValue("CBR Notes"); headerRow.CreateCell(6).SetCellValue("IVR-Studio"); headerRow.CreateCell(7).SetCellValue("Created By"); headerRow.CreateCell(8).SetCellValue("Created On"); headerRow.CreateCell(9).SetCellValue("Skill Group"); headerRow.CreateCell(10).SetCellValue("Sticky Agent"); headerRow.CreateCell(11).SetCellValue("Dial Type"); //var dstable = ds.tables[0]; if (ds.Tables[0].Rows.Count > 0) { var _with1 = ds.Tables[0]; for (int i = 0; i <= _with1.Rows.Count - 1; i++) // _with1.Rows.Count - 1 { dynamic row = sheet.CreateRow(i + 1); for (int c = 0; c <= ds.Tables[0].Columns.Count - 1; c++) { switch (c) { case 0: row.CreateCell(c).SetCellValue(_with1.Rows[i]["Status"].ToString()); break; case 1: row.CreateCell(c).SetCellValue("-"); break; case 2: row.CreateCell(c).SetCellValue(_with1.Rows[i]["CallDateTime"].ToString()); break; case 3: row.CreateCell(c).SetCellValue(_with1.Rows[i]["CallerName"].ToString()); break; case 4: row.CreateCell(c).SetCellValue(_with1.Rows[i]["Mobile"].ToString()); break; case 5: row.CreateCell(c).SetCellValue(_with1.Rows[i]["Notes"].ToString()); break; case 6: row.CreateCell(c).SetCellValue(_with1.Rows[i]["StudioName"].ToString()); break; case 7: row.CreateCell(c).SetCellValue(_with1.Rows[i]["CreatedBy"].ToString()); break; case 8: row.CreateCell(c).SetCellValue(_with1.Rows[i]["CreatedOn"].ToString()); break; case 9: row.CreateCell(c).SetCellValue(_with1.Rows[i]["Name"].ToString()); break; case 10: row.CreateCell(c).SetCellValue(_with1.Rows[i]["AssignedToAgent"].ToString()); break; case 11: row.CreateCell(c).SetCellValue(_with1.Rows[i]["DialType"].ToString()); break; } } } } //for (var i = 0; i < ds.Tables[0].Rows.Count; i++) //{ // dynamic row = sheet.CreateRow(i + 1); // for (var c = 0; c < ds.Tables[0].Columns.Count - 2; c++) // { // row.CreateCell(c).SetCellValue(ds.Tables[0].Rows[i][c + 1].ToString()); // } //} string folderPath = ""; folderPath = HttpContext.Current.Server.MapPath("~/CallBackRequests/"); // floderName = "ScriptFileUpload"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = System.Web.HttpContext.Current.Server.MapPath("~"); file_name = "CallBackRequests_" + DateTime.Now.ToString("ddMMyyyyHHmmssfffff") + ".xlsx"; using (var exportData = new FileStream(path + "/CallBackRequests/" + file_name, FileMode.CreateNew)) { wb.Write(exportData); } HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", file_name)); FileInfo Dfile = new FileInfo(path + "/CallBackRequests/" + file_name); HttpContext.Current.Response.WriteFile(Dfile.FullName); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } catch (Exception ex) { Logger.Error(ex.ToString()); } } }