示例#1
0
        public ConversationStreamResponse GetConversationStreamMessage(int[] reportIds, string filter, int rowsSkipped)
        {
            var response = new ConversationStreamResponse();

            try
            {
                var context          = new SmartSocialContext();
                var containerList    = new List <dynamic>();
                var filterValues     = filter.Split('|');
                var filterParameters = filterValues.ElementAt(1).Split(',');
                var smartChartId     = Convert.ToInt32(filterValues.ElementAt(0));
                var message          = filterValues.ElementAt(1);
                var socialPostList   = context.spGetChartData_MessageSocialPosts(smartChartId, message).ToList();

                foreach (var socialPost in socialPostList)
                {
                    response.conversationStreamObjects.Add(new ConversationStreamObject()
                    {
                        idSocialPost        = socialPost.idSocialPost.ToString(),
                        Message             = socialPost.Message,
                        MessageCreatedDate  = socialPost.MessageCreatedDate.ToString(),
                        PermaLink           = socialPost.PermaLink,
                        SenderProfileImgUrl = socialPost.SenderProfileImgUrl,
                        SenderScreenName    = socialPost.SenderScreenName,
                        SocialNetwork       = socialPost.SocialNetwork
                    });
                }
                response.Acknowledgment = true;
                response.Message        = "Success";
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting GetConversationStreamMessage Data exception:" + ex.Message;
            }
            return(response);
        }
示例#2
0
        public ConversationStreamResponse GetConversationStream(int[] reportIds, string filter, int rowsSkipped)
        {
            var response = new ConversationStreamResponse();
            var topN     = Convert.ToInt32(Resource.TopN.ToString());

            string conStr = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            try
            {
                foreach (var reportId in reportIds)
                {
                    using (SqlConnection con = new SqlConnection(conStr))
                    {
                        using (SqlCommand cmd = new SqlCommand("spGetChartData_SocialPostXIdXTopNXFilterXSkipRows", con))
                        {
                            var filterWhere = "";
                            using (var myDd = new SmartSocialContext())
                            {
                                var filterValues     = filter.Split('|');
                                var filterParameters = filterValues.ElementAt(1).Split(',');
                                var smartChartId     = Convert.ToInt32(filterValues.ElementAt(0));
                                filterWhere = myDd.SmartCharts.FirstOrDefault(x => x.idSmartChart == smartChartId).SocialPostFilter.Replace("SOCIALPOSTPARAM1", filterParameters.ElementAt(0));
                                if (filterParameters.Count() > 1)
                                {
                                    if (filterWhere.Contains("And [MessageCreatedDate]  = 'SOCIALPOSTPARAM2'"))
                                    {
                                        var dateFrom = DateTime.Parse(filterParameters.ElementAt(1)).Date;
                                        var dateTo   = DateTime.Parse(filterParameters.ElementAt(1)).Date.AddDays(1).AddTicks(-1);
                                        filterWhere = filterWhere.Replace("[MessageCreatedDate]  = 'SOCIALPOSTPARAM2'", "[MessageCreatedDate]  BETWEEN '" + dateFrom.ToString() + "' AND '" + dateTo.ToString() + "'");
                                    }
                                    else
                                    {
                                        filterWhere = filterWhere.Replace("SOCIALPOSTPARAM2", filterParameters.ElementAt(1));
                                    }
                                }
                            }

                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@Param1IdSmartReport", SqlDbType.Int).Value = reportId;
                            cmd.Parameters.Add("@Param2TopN", SqlDbType.Int).Value          = topN;// Solo 15
                            cmd.Parameters.Add("@Param3Filter", SqlDbType.NVarChar).Value   = filterWhere;
                            cmd.Parameters.Add("@Param4SkipRows", SqlDbType.Int).Value      = rowsSkipped;

                            con.Open();
                            SqlDataAdapter da = new SqlDataAdapter(cmd);
                            da.SelectCommand = cmd;
                            DataSet ds = new DataSet();
                            da.Fill(ds);
                            DataTable dt = ds.Tables[0];
                            foreach (DataRow dr in dt.Rows)
                            {
                                response.conversationStreamObjects.Add(new ConversationStreamObject()
                                {
                                    idSocialPost        = dr["idSocialPost"].ToString(),
                                    Message             = dr["Message"].ToString(),
                                    MessageCreatedDate  = dr["MessageCreatedDate"].ToString(),
                                    PermaLink           = dr["PermaLink"].ToString(),
                                    SenderProfileImgUrl = dr["SenderProfileImgUrl"].ToString(),
                                    SenderScreenName    = dr["SenderScreenName"].ToString(),
                                    SocialNetwork       = dr["SocialNetwork"].ToString()
                                });
                            }
                        }
                    }
                }


                response.Acknowledgment = true;
                response.Message        = "Success";
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting Conversation Stream. Exception:" + ex.Message;
            }


            return(response);
        }