protected void Page_Load(object sender, EventArgs e)
    {
        profMsg = Profile.ProfileMsg.MsgList;
        warnMsg.Text = string.Empty;

        if (!IsPostBack)
        {
            //检查是否需要继续上次未完成的任务
            SendMsgHelper helper = new SendMsgHelper
            {
                uidUser = (Guid)Membership.GetUser(User.Identity.Name).ProviderUserKey,
            };
            if (helper.IsHasWaitingTasks())
            {
                Response.Redirect("./Submitting.aspx");
                return;
            }

            if (profMsg.Count == 0)
                profMsg.Add(new WxMsg());

            LoadProfMsg(0);

        }
    }
Exemplo n.º 2
0
    private void SubmitMsg()
    {
        Logger logger = new Logger(logFile);

        logger.Log(startToken);
        logger.Log("初始化SendMsgHelper");
        SendMsgHelper helper = new SendMsgHelper
        {
            uidUser = Guid.Parse(uidUser),
            logger = logger,
            ImgsPath = Server.MapPath("~/UploadedImages/" + uidUser)
        };

        try
        {
            logger.Log("检查遗留任务");
            if (helper.IsHasWaitingTasks())
            {
                logger.Log("发现之前还有未发送的信息!");
                helper.ExecTask(profMsg);
                logger.Log(completeToken);
                return;
            }

            logger.Log("初始化任务数据库");
            if (0 == helper.InitTask())
            {
                logger.Log(completeToken);
                return;
            }
            logger.Log("初始化成功");

            logger.Log("开始发送信息");
            helper.ExecTask(profMsg);
            logger.Log(completeToken);
        }
        catch (Exception ex)
        {
            //sw = new StreamWriter(logFile, true);
            logger.Log(string.Format("系统异常:{0}", ex.ToString()));
            logger.Log(completeToken);
            //sw.Close();
            return;
        }
    }