Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <LPWeb.Model.Email_AttachmentsTemp> DataTableToList(DataTable dt)
        {
            List <LPWeb.Model.Email_AttachmentsTemp> modelList = new List <LPWeb.Model.Email_AttachmentsTemp>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                LPWeb.Model.Email_AttachmentsTemp model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new LPWeb.Model.Email_AttachmentsTemp();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Token = dt.Rows[n]["Token"].ToString();
                    if (dt.Rows[n]["TemplAttachId"].ToString() != "")
                    {
                        model.TemplAttachId = int.Parse(dt.Rows[n]["TemplAttachId"].ToString());
                    }
                    model.Name     = dt.Rows[n]["Name"].ToString();
                    model.FileType = dt.Rows[n]["FileType"].ToString();
                    if (dt.Rows[n]["FileImage"].ToString() != "")
                    {
                        model.FileImage = (byte[])dt.Rows[n]["FileImage"];
                    }
                    if (dt.Rows[n]["CreateDateTime"].ToString() != "")
                    {
                        model.CreateDateTime = DateTime.Parse(dt.Rows[n]["CreateDateTime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["CloseDialogCodes"] != null) // 如果有LoanID
        {
            CloseDialogCodes = Request.QueryString["CloseDialogCodes"].ToString();
        }

        if (Request.QueryString["TemplEmailId"] != null) // 如果有LoanID
        {
            string sTemplEmailId = Request.QueryString["TemplEmailId"];

            if (PageCommon.IsID(sTemplEmailId) == false)
            {
                PageCommon.WriteJsEnd(this, sErrorMsg, CloseDialogCodes);
            }

            TemplEmailId = Convert.ToInt32(sTemplEmailId);
        }

        Token = Request.QueryString["token"] != null ? Request.QueryString["token"].ToString() : "";
        isListTemplEmailAttach = Request.QueryString["isListTemplEmailAttach"] != null?Convert.ToBoolean(Request.QueryString["isListTemplEmailAttach"]) : false;

        if (!IsPostBack)
        {
            if (isListTemplEmailAttach)
            {
                LPWeb.BLL.Template_Email_Attachments bllTempEmailAttach = new Template_Email_Attachments();

                var           ds = bllTempEmailAttach.GetListWithOutFileImage(" Enabled =1 AND TemplEmailId = " + TemplEmailId);
                StringBuilder sb = new StringBuilder();

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        sb.Append("<option value='s" + dr["TemplAttachId"].ToString() + "' >" + dr["Name"].ToString() + "." + dr["FileType"].ToString() + "</option>");
                    }
                }

                Default_lbxAttachments = sb.ToString();
            }
        }



        ///判定是不是 在执行发送
        if (Request.Form["hidIsSend"] != null)
        {
            sLocalTime = Request.Form["hfLocalTime"].ToString().Trim();
            //Attachment

            #region Attachments
            if (Request.Files.Count > 0)
            {
                foreach (var key in Request.Files.AllKeys)
                {
                    var file = Request.Files[key];

                    if (file.ContentLength > 0 && !string.IsNullOrEmpty(file.FileName))
                    {
                        if (file.ContentLength > 1024 * 1024 * 20)
                        {
                            ErrorMsg("The file you tried to upload has exceeded the allowed limit, 20MB.");
                            Response.End();
                        }

                        byte[] bytes = new byte[file.InputStream.Length];
                        file.InputStream.Read(bytes, 0, bytes.Length);
                        file.InputStream.Seek(0, SeekOrigin.Begin);

                        FileInfo info = new FileInfo(file.FileName);

                        Attachments.Add(info.Name, bytes);
                    }
                }
            }
            #endregion

            if (Attachments.Count == 0)
            {
                ErrorMsg("Attachments / Note is empty.");
                Response.End();
            }


            #region Save file

            try
            {
                LPWeb.BLL.Email_AttachmentsTemp bllEmailAttachTemp = new Email_AttachmentsTemp();
                foreach (var item in Attachments)
                {
                    LPWeb.Model.Email_AttachmentsTemp model = new LPWeb.Model.Email_AttachmentsTemp();

                    model.Token     = Token;
                    model.Name      = item.Key.ToString().Substring(0, item.Key.ToString().LastIndexOf('.'));
                    model.FileType  = item.Key.ToString().Substring(item.Key.ToString().LastIndexOf('.') + 1);
                    model.FileImage = item.Value;

                    bllEmailAttachTemp.Add(model);
                }

                ErrorMsg(true, "");
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message.Replace("\"", "").Replace("\\n", ""));
            }

            #endregion


            Response.End();
        }
    }
Exemplo n.º 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LPWeb.Model.Email_AttachmentsTemp model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(LPWeb.Model.Email_AttachmentsTemp model)
 {
     return(dal.Add(model));
 }