Пример #1
0
        public static List <ATTMessageAttachment> GetMsgAttachmentByIDs(int?orgID, int?msgID)
        {
            List <ATTMessageAttachment> lst = new List <ATTMessageAttachment>();

            try
            {
                DataTable tbl = DLLMessageAttachment.GetMsgAttachmentByIDs(orgID, msgID);
                foreach (DataRow row in tbl.Rows)
                {
                    ATTMessageAttachment att = new ATTMessageAttachment();
                    att.OrgID        = int.Parse(row["org_id"].ToString());
                    att.MessageID    = int.Parse(row["msg_id"].ToString());
                    att.AttachmentID = int.Parse(row["MSG_ATTACH_ID"].ToString());
                    att.FileName     = row["FILE_NAME"].ToString();
                    att.ContentFile  = row["FILE_BYTES"] as byte[];

                    lst.Add(att);
                }

                tbl.Dispose();
                return(lst);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
    public List <ATTMessageAttachment> GetOutboxAttachmentList(ATTMessage objRqdMsg)
    {
        try
        {
            List <ATTMessageAttachment> tmpAttachmentLst = new List <ATTMessageAttachment>();
            ArrayList arrVal = new ArrayList();

            foreach (ATTMessageAttachment objAttachment in objRqdMsg.LstMsgAttachment)
            {
                int  l    = 0;
                bool flag = false;
                if (arrVal.Count > 0)
                {
                    for (int k = 0; k < arrVal.Count; k++)
                    {
                        if (objAttachment.AttachmentID == int.Parse(arrVal[k].ToString()))
                        {
                            flag = true;
                            break;
                        }
                    }
                }

                if (!flag)
                {
                    ATTMessageAttachment obj = new ATTMessageAttachment();
                    obj.OrgID        = objAttachment.OrgID;
                    obj.MessageID    = objAttachment.MessageID;
                    obj.AttachmentID = objAttachment.AttachmentID;
                    obj.FileName     = objAttachment.FileName;

                    arrVal.Add(objAttachment.AttachmentID.ToString());

                    tmpAttachmentLst.Add(obj);
                }
            }

            return(tmpAttachmentLst);
        }
        catch (Exception ex)
        {
            throw(ex);
        }
    }
Пример #3
0
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        try
        {
            string arguments = ((LinkButton)sender).CommandArgument.ToString();
            CalculateIDs(arguments);
            ATTMessage objMsg = (ATTMessage)Session["objRqdMsg"];

            List <ATTMessageAttachment> lstMsgAttachment = new List <ATTMessageAttachment>();
            lstMsgAttachment = objMsg.LstMsgAttachment;


            ATTMessageAttachment objRqdMsgAttachment = lstMsgAttachment.Find(delegate(ATTMessageAttachment obj)
            {
                return(obj.OrgID == orgID && obj.MessageID == msgID && obj.AttachmentID == attachID);
            }

                                                                             );

            if (objRqdMsgAttachment != null)
            {
                byte[] fileByte = objRqdMsgAttachment.ContentFile;
                Response.Clear();

                Response.AddHeader("Content-Disposition", "attachment; filename=" + objRqdMsgAttachment.FileName);

                Response.ContentType = "application/octet-stream";

                Response.BinaryWrite(fileByte);
            }
        }
        catch (Exception ex)
        {
            throw(ex);
        }
    }
Пример #4
0
        public static List <ATTMessageAttachment> SetMessageAttachment(int orgID, int messageID, int?msgSeq, string type)
        {
            try
            {
                List <ATTMessageAttachment> lstMsgAttachment = new List <ATTMessageAttachment>();

                foreach (DataRow row in tblMsgAttachment.Rows)
                {
                    bool flag = false;
                    if (type == "IN")
                    {
                        if (orgID == int.Parse(row["ORG_ID"].ToString()) &&
                            messageID == int.Parse(row["MSG_ID"].ToString()) &&
                            msgSeq == int.Parse(row["MSG_SEQ"].ToString())
                            )
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        if (orgID == int.Parse(row["ORG_ID"].ToString()) &&
                            messageID == int.Parse(row["MSG_ID"].ToString())
                            )
                        {
                            flag = true;
                        }
                    }



                    //if (orgID == int.Parse(row["ORG_ID"].ToString()) &&
                    //     messageID == int.Parse(row["MSG_ID"].ToString())
                    //   )
                    if (flag)
                    {
                        ATTMessageAttachment objMsgAttachment = new ATTMessageAttachment(
                            int.Parse(row["ORG_ID"].ToString()),
                            int.Parse(row["MSG_ID"].ToString()),
                            int.Parse(row["MSG_ATTACH_ID"].ToString()),
                            row["FILE_NAME"].ToString().Trim(),
                            (byte[])(row["FILE_BYTES"])
                            );


                        if (row["FILE_NAME"].ToString().Trim().Length > 15)
                        {
                            objMsgAttachment.DisplayName = row["FILE_NAME"].ToString().Trim().Substring(0, 15) + ".....";
                        }
                        else
                        {
                            objMsgAttachment.DisplayName = row["FILE_NAME"].ToString().Trim();
                        }


                        lstMsgAttachment.Add(objMsgAttachment);
                    }
                }

                return(lstMsgAttachment);
            }
            catch (Exception ex)
            {
                throw(ex);
            }
        }