Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            name = QueryString[Constants.MYQUERY_NAME];
            if (!Page.IsPostBack)
            {
                WebHelper.SetControlAttributes(btnSubmit, new TextBoxVal[] { txtTitle, HtmlUrl, AspxUrl });
                if (CurrentUser.IsAdmin())//仅管理员才能操作
                {
                    HtmlUrl.Enabled = true;
                    DepId.Enabled   = true;
                    divUp.Visible   = true;
                    btnUp.Visible   = true;
                    WebHelper.SetAttributesOfFile(fileHtml);
                    WebHelper.SetAttributesOfFile(fileXml);
                }
                else
                {
                    HtmlUrl.Enabled = false;
                    DepId.Enabled   = false;
                    divUp.Visible   = false;
                    btnUp.Visible   = false;
                }
                try
                {
                    DataFrom dataFrom = new DataFrom();
                    dataFrom.BindListCtrl(String.Format("select id,case when parentid='0' then '' else '  ' end+name from f_city where iflag=1 and (parentid='{0}' or id='{0}') order by parentid,id", CurrentUser.DepID), DepId, CurrentUser.IsAdmin());
                    if (!String.IsNullOrEmpty(name))
                    {
                        HtmlUrl.Text = name;
                        DataTable dt = dataFrom.GetDataTable("select Title,AspxUrl,depid from HtmlTemplate where HtmlUrl='" + name + "'");
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            txtTitle.Text = dt.Rows[0]["Title"].ToString();
                            AspxUrl.Text  = dt.Rows[0]["AspxUrl"].ToString();
                            WebHelper.SetSelCtrl(dt.Rows[0]["depid"].ToString(), DepId);
                        }
                        Content.Text = TxtHelper.GetString(WebHelper.GetMyXmlPath() + "\\tpl\\" + name + Constants.HTML_SUFFIX);

                        XmlDocument doc = FromXml.GetXml(name);
                        if (doc == null)
                        {
                            txtXml.Text = XmlHelper.GetXmlDocument(true).DocumentElement.OuterXml;
                        }
                        else
                        {
                            txtXml.Text = XmlHelper.GetFormatXml(doc);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("初始化失败", ex);
                    RedirectError("初始化失败,请稍候再试。原因:" + ex.Message);
                    return;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 给常规任务相关人发邮件
        /// </summary>
        /// <param name="mailContent">内容</param>
        /// <param name="userids">多个用,分割</param>
        /// <param name="userid">不空时 则通知其部门领导</param>
        public void SendMailTask(string mailContent, string userids, string userid)
        {
            DataTable dt = null;

            if (String.IsNullOrEmpty(userids))
            {
                dt          = dao.GetDataTable(@"select ProjectMilestone.*,s_user.Name as createrName,TechnicManager.Name as TechnicManagerName
                                from ProjectMilestone
                                inner join s_user on ProjectMilestone.UserId=s_user.id
                                left join s_user TechnicManager on ProjectMilestone.TechnicManager=TechnicManager.id
                                where ProjectMilestone.id=" + mailContent);
                userid      = dt.Rows[0]["TechnicManager"].ToString();
                userids     = dt.Rows[0]["UserId"].ToString() + "," + userid;
                mailContent = TxtHelper.GetString(WebHelper.GetRootServerPath() + "Project\\Mail\\MilestoneTask" + Constants.HTML_SUFFIX);
                string flagDes = "";
                switch (Convert.ToInt32(dt.Rows[0]["iflag"]))
                {
                case 0:
                    flagDes = "关闭";
                    break;

                case 1:
                    flagDes = "进行中";
                    break;
                }
                mailContent = String.Format(mailContent, dt.Rows[0]["Name"], currentUser.Name, dt.Rows[0]["createrName"], dt.Rows[0]["TechnicManagerName"], dt.Rows[0]["StartDate"], dt.Rows[0]["EndDate"], flagDes);
            }
            if (!String.IsNullOrEmpty(mailContent) && !String.IsNullOrEmpty(userids))
            {
                string sql = "select email from S_User where id " + SqlHelper.GetSqlInWhere(userids);
                if (!String.IsNullOrEmpty(userid))
                {
                    sql += " or id in (select s_dep.Manager from s_dep inner join s_user on s_dep.id=s_user.depid where s_user.id='" + userid + "')";
                }
                dt = dao.GetDataTable(sql);
                MailHelper.SendMail(DataHelper.GetString(dt.Rows, null), "任务处理提醒邮件", mailContent, null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 执行任务
        /// </summary>
        public void Run()
        {
            string msg = "任务开始时间:" + DateTime.Now.ToString();

            try
            {
                //查找超时未填报任务
                string sql = @"select S_User.Name,S_User.EMail
,(select max(workday) as workday from WorkWeek where datediff(day,WorkDay,getdate())>"
                             + _days + @" and Iflag=1) as workday"
                             + (_toHeader ? ",manager.EMail as HeaderEmail" : "") + @"
 from S_User";
                if (_toHeader)
                {
                    sql += @" left join s_dep on s_dep.id=s_user.depid
 left join s_user manager on s_dep.Manager=manager.id";
                }
                sql += @" where S_User.Iflag='1' and S_User.IsEffort=1 and s_user.id in (select distinct s_user.id
 from S_User
 inner join WorkWeek d on d.WorkDay>s_user.startdate
 left join ProjectWorkLog l on l.WorkDay=d.WorkDay and s_user.id=l.worker and l.EffortState=1
 where d.Iflag=1 and d.workday<=(select max(workday) as workday from WorkWeek where datediff(day,WorkDay,getdate())>" + _days + @" and Iflag=1)
 group by s_user.id,d.workday
 having isnull(sum(l.Effort),0)<8)";
                DataTable dt = new Dao().GetDataTable(sql);
                if (dt == null || dt.Rows.Count == 0)
                {
                    msg += ",没有超时未填报的人员";
                }
                else
                {
                    msg += ",超时未填报共" + dt.Rows.Count + "人";
                    string mailContent = TxtHelper.GetString(WebHelper.GetRootServerPath() + "Log\\Mail\\UnWrite" + Constants.HTML_SUFFIX);
                    string mailHeader  = null;
                    if (_toHeader)
                    {
                        mailHeader = TxtHelper.GetString(WebHelper.GetRootServerPath() + "Log\\Mail\\UnWriteHeader" + Constants.HTML_SUFFIX);
                    }
                    foreach (DataRow dr in dt.Rows)
                    {
                        msg += "\r\n给" + dr["EMail"].ToString() + "发邮件";
                        try
                        {
                            MailHelper.SendMail(dr["EMail"].ToString(), "日志未填写提醒", String.Format(mailContent, dr["workday"]), null);
                            if (_toHeader && !String.IsNullOrEmpty(mailHeader))
                            {
                                msg += ",同时给领导" + dr["HeaderEmail"].ToString() + "发邮件";
                                MailHelper.SendMail(dr["HeaderEmail"].ToString(), "督促日志按时填写提醒", String.Format(mailHeader, dr["Name"], dr["workday"]), null);
                            }
                        }
                        catch (Exception ex)
                        {
                            msg += ",处理异常:" + ex.Message + "已放弃";
                        }
                    }
                }
                msg += "。完成";
            }
            catch (Exception ex)
            {
                msg += ",处理异常:" + ex.Message + "已放弃";
            }
            msg += "时间:" + DateTime.Now.ToString();
            LogHelper.WriteToFile("UnWrite", msg);
        }