protected void Page_Load(object sender, EventArgs e)
        {
            string sequence = Request.QueryString["seq"];
            string userId = Request.QueryString["userId"];
            StudyDao studyDao = new ChinaUnion_DataAccess.StudyDao();
            Study study = studyDao.Get(Int32.Parse(sequence));

            if (study != null)
            {
                StudyReceiverLogDao studyReceiverLogDao = new StudyReceiverLogDao();
                StudyReceiverLog studyReceiverLog = new StudyReceiverLog();
                studyReceiverLog.studySequence = study.sequence;
                studyReceiverLog.readtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                studyReceiverLog.userId = userId;
                studyReceiverLogDao.Add(studyReceiverLog);

                Response.ContentType = "Application/pdf";
                this.Response.Clear();

                System.IO.Stream fs = this.Response.OutputStream;
                fs.Write(study.attachment, 0, study.attachment.Length);

                fs.Close();
                this.Response.End();
            }

        }
Exemple #2
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;


            // Queryworker.ReportProgress(4, "代理商佣金...\r\n");
            //代理商佣金
            StudyReceiverLogDao studyReceiverLogDao = new StudyReceiverLogDao();
            StudyDao studyDao = new StudyDao();
            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            IList<StudyReceiverLog> studyReceiverLogList = studyReceiverLogDao.GetList(this.txtSubjectKeyword.Text.Trim(), this.txtUserKeyword.Text.Trim(), this.dtDay.Value.ToString("yyyy-MM-dd"));
            dgStudyReadLog.Rows.Clear();
            dgStudyReadLog.Columns.Clear();
            if (studyReceiverLogList != null && studyReceiverLogList.Count > 0)
            {
                this.grpAgentFee.Text = "阅读日志(" + studyReceiverLogList.Count + ")";
                dgStudyReadLog.Columns.Add("渠道类型", "渠道类型");
                dgStudyReadLog.Columns.Add("渠道编码", "渠道编码");
                dgStudyReadLog.Columns.Add("渠道名称", "渠道名称");
                dgStudyReadLog.Columns.Add("代理商编号", "代理商编号");
                dgStudyReadLog.Columns.Add("代理商名称", "代理商名称");
                dgStudyReadLog.Columns.Add("用户账号", "用户账号");
                dgStudyReadLog.Columns.Add("用户名", "用户名");
                dgStudyReadLog.Columns.Add("用户微信", "用户微信");
                dgStudyReadLog.Columns.Add("阅读时间", "阅读时间");
                dgStudyReadLog.Columns.Add("主题", "主题");
                dgStudyReadLog.Columns.Add("内容", "内容");
               

                for (int i = 0; i < studyReceiverLogList.Count; i++)
                {

                   // Study study = studyDao.Get(Int32.Parse(studyReceiverLogList[i].studySequence));
                    //AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(studyReceiverLogList[i].userId);
                    dgStudyReadLog.Rows.Add();
                    DataGridViewRow row = dgStudyReadLog.Rows[i];
                    if (studyReceiverLogList[i].agentContact != null)
                    {
                        row.Cells[0].Value = studyReceiverLogList[i].agentContact.type;
                        row.Cells[1].Value = studyReceiverLogList[i].agentContact.branchNo;
                        row.Cells[2].Value = studyReceiverLogList[i].agentContact.branchName;
                        row.Cells[3].Value = studyReceiverLogList[i].agentContact.agentNo;
                        row.Cells[4].Value = studyReceiverLogList[i].agentContact.agentName;
                        row.Cells[5].Value = studyReceiverLogList[i].agentContact.contactId;
                        row.Cells[6].Value = studyReceiverLogList[i].agentContact.contactName;
                        row.Cells[7].Value = studyReceiverLogList[i].agentContact.contactWechat;
                    }
                    row.Cells[8].Value = studyReceiverLogList[i].readtime;
                    if (studyReceiverLogList[i].study != null)
                    {
                        row.Cells[9].Value = studyReceiverLogList[i].study.subject;
                        row.Cells[10].Value = studyReceiverLogList[i].study.content;
                    }
                   



                }
            }
            dgStudyReadLog.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
            this.dgStudyReadLog.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            dgStudyReadLog.AutoResizeColumns();


            this.Cursor = Cursors.Default;


        }
        void bindDataToGrid(String subject, String type, String search_scope, String agentNo,String userId)
        {
            logger.Info("bindDataToGrid=");
            logger.Info("subject=" + subject);
            logger.Info("type=" + type);
            logger.Info("search_scope=" + search_scope);
            logger.Info("agentNo=" + agentNo);
            logger.Info("userId=" + userId);
            StudyDao studyDao = new ChinaUnion_DataAccess.StudyDao();

            IList<Study> studyList = null;

            if (!String.IsNullOrEmpty(search_scope) && search_scope.Equals("validate"))
            {
                studyList = studyDao.GetAllValidatedList(subject, type);
                logger.Info("validate=");
            }


            if (!String.IsNullOrEmpty(search_scope) && search_scope.Equals("all"))
            {
                studyList = studyDao.GetList(subject, type);
                logger.Info("all=");
            }
            this.lblType.Text = type;
            this.lblScope.Text = search_scope;
            this.lblAgentNo.Text = agentNo;
            this.lblUserId.Text = userId;
            // int index = 1;
            DataTable dt = new DataTable();
            dt.Columns.Add("seq");
            dt.Columns.Add("userId");
            dt.Columns.Add("subject");
            dt.Columns.Add("content");
            dt.Columns.Add("attachment");
            dt.Columns.Add("validateStartTime");
            dt.Columns.Add("validateEndTime");

            DataRow row = null;
            if (studyList != null && studyList.Count>0)
            {
                foreach (Study study in studyList)
                {
                    if (!study.toAll.Equals("Y"))
                    {
                        AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                        AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(userId);

                        if (!String.IsNullOrEmpty(study.agentType) )
                        {
                              IList<String> list = study.agentType.Split(';').ToList<String>();
                              if (!list.Contains(agentWechatAccount.type))
                              {
                                  continue;
                              }
                        }
                        if (String.IsNullOrEmpty(study.agentType))
                        {
                            IList<String> agentNoList = studyDao.GetAllAgentNoListBySeq(study.sequence);
                            if (!agentNoList.Contains(agentNo))
                            {
                                logger.Info("userId=" + userId + " 没有权限范围" + study.sequence);
                                continue;
                            }
                        }
                    }
                    row = dt.NewRow();
                    row["seq"] = study.sequence;
                    row["userId"] = userId;
                    row["subject"] = study.subject;
                    if (study.content.Length > 10)
                    {
                        row["content"] = study.content.Substring(0, 10) + "......";
                    }
                    else
                    {
                        row["content"] = study.content;
                    }
                    if (!String.IsNullOrEmpty(study.attachmentName))
                    {
                        row["attachment"] = "附件";
                    }
                    row["validateStartTime"] = study.validateStartTime;
                    row["validateEndTime"] = study.validateEndTime;
                    dt.Rows.Add(row);
                }
            }
            else
            {
                this.lblMessag.Text = "未找到" + type + "记录!";
            }
            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string sequence =  Request.QueryString["seq"];
            string userId =  Request.QueryString["userId"];
            logger.Info("sequence=" + sequence);
            logger.Info("userId=" + userId);

            if (String.IsNullOrEmpty(sequence))
            {
                string code = Request.QueryString["code"];
                sequence = Request.QueryString["state"];
                string search_scope = Request.QueryString["search_scope"];
                string agentId = Request.QueryString["agentId"];
                logger.Info("agentId=" + Request.QueryString["agentId"]);
                logger.Info("code=" + Request.QueryString["code"]);
                logger.Info("state=" + Request.QueryString["state"]);
                logger.Info("search_scope=" + Request.QueryString["search_scope"]);
                WechatUtil wechatUtil = new Util.WechatUtil();
                HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
                logger.Info("result=" + result.Html);
                if (result != null && result.Html != null && result.Html.Contains("UserId"))
                {
                    WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));
                    userId = returnMessage.UserId;
                }
                
            }
            if (!String.IsNullOrEmpty(sequence))
            {
                StudyDao studyDao = new ChinaUnion_DataAccess.StudyDao();
                Study study = studyDao.Get(Int32.Parse(sequence));
                if (study != null)
                {
                    this.lblSubject.Text = study.subject;
                    this.lblSendTime.Text = study.creatTime;
                    if (!String.IsNullOrEmpty(study.content))
                    {
                        this.lblContent.Text = study.content.Replace("\r\n"," <br>").Replace("\n"," <br>");
                    }
                    this.lblValidateStartTime.Text = study.validateStartTime;
                    this.lblValidateEndTime.Text = study.validateEndTime;
                    this.lblAttachment.Text = study.attachmentName;
                    this.lblAttachment.NavigateUrl = "OnlineStudyAttachmentDetail.aspx?seq=" + study.sequence + "&userId=" + userId;

                    logger.Info("sequence=" + sequence);
                    logger.Info("userId=" + userId);
                    StudyReceiverLogDao studyReceiverLogDao = new StudyReceiverLogDao();
                    StudyReceiverLog studyReceiverLog = new StudyReceiverLog();
                    studyReceiverLog.studySequence = study.sequence;
                    studyReceiverLog.readtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    studyReceiverLog.userId = userId;
                    studyReceiverLogDao.Add(studyReceiverLog);


                    WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                    wechatQueryLog.agentName = "";
                    wechatQueryLog.module = Util.MyConstant.module_Study;
                    wechatQueryLog.subSystem = "在线学习";
                    wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    wechatQueryLog.queryString = study.type;
                    wechatQueryLog.wechatId = userId;
                    WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                    try
                    {
                        wechatQueryLogDao.Add(wechatQueryLog);
                    }
                    catch
                    {
                    }
                }
            }
        }