Пример #1
0
 /// <summary>
 /// 保存,保存后关闭
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         Rss rss = new Rss();
         rss.CreateDate = DateTime.Now.ToString();
         rss.DateType   = ddlDateType.SelectedItem.Text;
         rss.SendDay    = ddlDate.SelectedIndex + 1;
         rss.SendTime  += ddlTime.SelectedIndex.ToString().PadLeft(2, '0') + ":00:00";
         rss.SendTo     = txtCC.Text;
         rss.TemplateID = hideTempID.Value;
         rss.UserID     = Request.QueryString["userid"];
         rss.SendType   = ddlSendType.SelectedItem.Text;
         if (!String.IsNullOrEmpty(rss.TemplateID))
         {
             SubscribeDB.DeleteSubScribe(rss);
         }
         SubscribeDB.InsertSubScribe(rss);
         lblError.Text = "成功";
         string userID = Request.QueryString["userid"];
         if (!string.IsNullOrEmpty(userID))
         {
             BindSubscribeList(userID);
         }
     }
     catch (Exception ex)
     {
         lblError.Text    = ex.Message;
         lblError.Visible = true;
     }
 }
Пример #2
0
    private void BindSubscribeList(string userID)
    {
        List <Rss> rssList        = SubscribeDB.GetSubScribeList(userID);
        int        curReportIndex = rssList.FindIndex(p => p.TemplateID == Request.QueryString["reportid"]);

        if (curReportIndex >= 0)
        {
            lbtnAddCurReport.Visible = false;
        }
        gridSubscribe.DataSource = rssList;
        gridSubscribe.DataBind();
        gridSubscribe.SelectedIndex = curReportIndex;
    }
 [HttpPost]//object initilaization syntax
 //maps viewmodel to actualy database model.
 public ActionResult Subscribe(SubscribeViewModel sub)
 {
     if (ModelState.IsValid)
     {
         Subscriber s = new Subscriber()
         {
             FirstName    = sub.FirstName,
             Lastname     = sub.Lastname,
             EmailAddress = sub.EmailAddress
         };
         SubscribeDB.Subsribe(s);
         return(RedirectToAction("Index", "Home"));
     }
     //return model back to page with errors
     return(View(sub));
 }
Пример #4
0
    private void BindGrid(string userID, string reportID)
    {
        SubscribeDB.UpdateReadStates(userID, reportID, true);
        if (!System.IO.Directory.Exists(Server.MapPath("../Csv/" + userID)))
        {
            return;
        }
        string[] files           = System.IO.Directory.GetFiles(Server.MapPath("../Csv/" + userID), "*.csv");
        System.Data.DataTable dt = new System.Data.DataTable();
        dt.Columns.Add("报表");
        dt.Columns.Add("生成时间");
        dt.Columns.Add("路径");
        foreach (string str in files)
        {
            string s = str.Substring(str.LastIndexOf('['));
            if (s.StartsWith("[" + reportID + "]"))
            {
                DataRow row = dt.NewRow();
                row[2] = s;
                s      = s.Substring(s.IndexOf(']') + 1);
                row[0] = s.Substring(0, s.IndexOf('('));
                s      = s.Substring(s.IndexOf('(') + 1);
                row[1] = s.Substring(0, 4) + "年" + s.Substring(4, 2) + "月" + s.Substring(6, 2) + "日" + s.Substring(8, 2) + "时";
                dt.Rows.Add(row);
            }
        }
        gridCsv.Columns.Clear();
        gridCsv.AutoGenerateColumns = false;
        for (int i = 0; i < 2; i++)
        {
            BoundField col = new BoundField();
            col.HeaderText = dt.Columns[i].ColumnName;
            col.DataField  = dt.Columns[i].ColumnName;
            gridCsv.Columns.Add(col);
        }
        HyperLinkField btnCol = new HyperLinkField();

        btnCol.Text = "下载";
        btnCol.DataNavigateUrlFormatString = "../Csv/" + userID + "/{0}";
        btnCol.DataNavigateUrlFields       = new string[1] {
            dt.Columns[2].ColumnName
        };
        gridCsv.Columns.Add(btnCol);
        gridCsv.DataSource = dt;
        gridCsv.DataBind();
        Boco.CommonToolLibrary.Grid.Grid.HyperLinkFieldEncodeHack(gridCsv);
    }
Пример #5
0
    private void InitSelectSubscribe(string userID, string reportID)
    {
        divSetting.Visible = true;
        Rss entity = SubscribeDB.GetSubScribe(userID, reportID);

        if (entity == null)
        {
            hideTempID.Value = reportID;
            FillDateType("");
            FillDate(-1);
            FillTime(-1);
            FillSendType("");
            return;
        }
        FillDateType(entity.DateType);
        hideTempID.Value = entity.TemplateID;
        lblTempName.Text = entity.TemplateName;
        FillDate(entity.SendDay);
        FillTime(Convert.ToDateTime(entity.SendTime).Hour);
        FillSendType(entity.SendType);
        txtCC.Text = entity.SendTo;
    }
Пример #6
0
 protected void gridSubscribe_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Setting")
     {
         int rowindex = int.Parse(e.CommandArgument.ToString());
         gridSubscribe.SelectedIndex = rowindex;
         string reportID = gridSubscribe.DataKeys[rowindex].Value.ToString();
         InitSelectSubscribe(Request.QueryString["userid"], reportID);
     }
     else if (e.CommandName == "DelRss")
     {
         int    rowindex = int.Parse(e.CommandArgument.ToString());
         string reportID = gridSubscribe.DataKeys[rowindex].Value.ToString();
         Rss    rss      = new Rss();
         string userID   = Request.QueryString["userid"];
         rss.UserID     = userID;
         rss.TemplateID = reportID;
         SubscribeDB.DeleteSubScribe(rss);
         BindSubscribeList(userID);
         divSetting.Visible = false;
     }
 }