public async Task <IHttpActionResult> GetMediaReport(MediaNewsReportFilterSearchModel model) { var userId = 0; if (model.userId.HasValue) { userId = model.userId.Value; } else { userId = User.Identity.GetUserId <int>(); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } model.userId = userId; if (!model.isShift) { model.fromDate = model.fromDate.Date; model.toDate = model.toDate.Date.Add(new TimeSpan(23, 59, 59)); } var taskResult = await repository.GetMediaReport(model); return(Ok(taskResult)); }
public async Task <List <MediaFormListModel> > GetMediaReportDrillDown(MediaNewsReportFilterSearchModel model) { List <MediaFormListModel> result = new List <MediaFormListModel>(); try { await Task.Run(() => { using (SocialCRMEntities db = new SocialCRMEntities()) { result = db.GetMediaReportDrillDown(model.userId, model.mediaTypeId, model.newsTypeIds, model.channelIds, model.categoryIds, model.relavanceIds, model.fromDate, model.toDate, model.script, model.isKEActivity, model.reportType, model.filterType, model.xAxis1, model.xAxis2, model.pageNumber, model.pageSize).Select(x => new MediaFormListModel() { Id = x.Id, MediaType = x.MediaType, NewsType = x.NewsType, Channel = x.Channel, Sentiment = x.Sentiment, NewsRelevance = x.NewsRelation, TransmissionDate = x.NewsDate.ToString(), TransmissionTime = x.NewsTime.ToString(), NoiseIndex = Convert.ToDecimal(x.NoiseIndex), CreatedBy = x.CreatedBy, PrValue = x.ParValue, CreatedDate = x.CreatedDate.ToString(), Script = x.Script, ClippingAttachment = new MediaAttachmentModel() { FileName = x.FileName, ContentType = x.FileType } }).ToList(); } }); } catch (Exception ex) { result = null; } return(result); }
public async Task <List <MediaCustomizedReportModel> > GetMediaReport(MediaNewsReportFilterSearchModel model) { List <MediaCustomizedReportModel> result = new List <MediaCustomizedReportModel>(); try { await Task.Run(() => { DataTable table = new DataTable(); using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) using (var cmd = new SqlCommand("GetMediaReport", con)) using (var da = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = model.userId; cmd.Parameters.Add("@MediaTypeIds", SqlDbType.VarChar).Value = model.mediaTypeId; cmd.Parameters.Add("@NewsTypeIds", SqlDbType.VarChar).Value = model.newsTypeIds; cmd.Parameters.Add("@ChannelIds", SqlDbType.VarChar).Value = model.channelIds; cmd.Parameters.Add("@CategoryIds", SqlDbType.VarChar).Value = model.categoryIds; cmd.Parameters.Add("@RelevanceIds", SqlDbType.VarChar).Value = model.relavanceIds; cmd.Parameters.Add("@FromDate", SqlDbType.DateTime).Value = model.fromDate; cmd.Parameters.Add("@ToDate", SqlDbType.DateTime).Value = model.toDate; cmd.Parameters.Add("@Script", SqlDbType.VarChar).Value = model.script; cmd.Parameters.Add("@IsKEActivity", SqlDbType.Bit).Value = model.isKEActivity; cmd.Parameters.Add("@ReportType", SqlDbType.Int).Value = model.reportType; cmd.Parameters.Add("@FilterType", SqlDbType.Int).Value = model.filterType; da.Fill(table); foreach (DataRow row in table.Rows) { MediaCustomizedReportModel temp = new MediaCustomizedReportModel(); temp.XAxis = row.Field <string>(0); temp.InsertionDate = row.Field <DateTime?>(1); temp.Value1 = row.Field <int?>(2); temp.Value2 = row.Field <int?>(3); temp.Value3 = row.Field <int?>(4); temp.Value4 = row.Field <int?>(5); temp.Value5 = row.Field <int?>(6); temp.Value6 = row.Field <int?>(7); temp.Value7 = row.Field <int?>(8); temp.Value8 = row.Field <int?>(9); temp.Value9 = row.Field <int?>(10); temp.Value10 = row.Field <int?>(11); temp.Value11 = row.Field <int?>(12); temp.Value12 = row.Field <int?>(13); temp.Value13 = row.Field <int?>(14); temp.Value14 = row.Field <int?>(15); temp.Value15 = row.Field <int?>(16); temp.Value16 = row.Field <int?>(17); temp.Value17 = row.Field <int?>(18); temp.Value18 = row.Field <int?>(19); temp.Value19 = row.Field <int?>(20); temp.Value20 = row.Field <int?>(21); temp.Value21 = row.Field <int?>(22); temp.Value22 = row.Field <int?>(23); temp.Value23 = row.Field <int?>(24); temp.Value24 = row.Field <int?>(25); temp.Value25 = row.Field <int?>(26); temp.Value26 = row.Field <int?>(27); temp.Value27 = row.Field <int?>(28); temp.Value28 = row.Field <int?>(29); temp.Value29 = row.Field <int?>(30); temp.Value30 = row.Field <int?>(31); temp.Value31 = row.Field <int?>(32); temp.Value32 = row.Field <int?>(33); temp.Value33 = row.Field <int?>(34); temp.Value34 = row.Field <int?>(35); temp.Value35 = row.Field <int?>(36); result.Add(temp); } } }); } catch (Exception ex) { result = null; } return(result); }