Esempio n. 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "application/octet-stream";

            int FileId = int.Parse(Request.QueryString["Id"]);

            if (Request.QueryString["CName"] != null && Request.QueryString["CKey"] != null)
            {
                string           ContainerName = Request.QueryString["CName"];
                string           ContainerKey  = Request.QueryString["CKey"];
                BaseIbnContainer bic           = BaseIbnContainer.Create(ContainerName, ContainerKey);
                Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

                Mediachase.IBN.Business.ControlSystem.FileInfo fi = fs.GetFile(FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }
                FileHistoryInfo fhiLoad = null;
                if (Request["VId"] != null)
                {
                    FileHistoryInfo[] _fhi = fi.GetHistory();
                    foreach (FileHistoryInfo fhi in _fhi)
                    {
                        if (fhi.Id == int.Parse(Request["VId"]))
                        {
                            fhiLoad = fhi;
                            break;
                        }
                    }
                }
                if (fhiLoad == null)
                {
                    Response.ContentType = fi.FileBinaryContentType;
                    if (fi.FileBinaryContentType.ToLower().IndexOf("url") >= 0)
                    {
                        MemoryStream memStream = new MemoryStream();
                        fs.LoadFile(FileId, memStream);
                        memStream.Position = 0;
                        StreamReader reader = new StreamReader(memStream, Encoding.Unicode);
                        string       data   = reader.ReadLine();
                        string       sLink  = "";
                        while (data != null)
                        {
                            if (data.IndexOf("URL=") >= 0)
                            {
                                sLink = data.Substring(data.IndexOf("URL=") + 4);
                                break;
                            }
                            data = reader.ReadLine();
                        }
                        if (sLink != "")
                        {
                            if (!sLink.StartsWith("http://"))
                            {
                                sLink = "http://" + sLink;
                            }
                            Response.Redirect(sLink);
                            return;
                        }
                    }

                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    fs.LoadFile(FileId, Response.OutputStream);
                }
                else
                {
                    Response.ContentType = fhiLoad.FileBinaryContentType;
                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fhiLoad.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    fs.LoadFile(fhiLoad, Response.OutputStream);
                }
            }
            else
            {
                Mediachase.IBN.Business.ControlSystem.FileInfo fi = Mediachase.IBN.Business.ControlSystem.FileStorage.GetFile(Mediachase.IBN.Business.Security.CurrentUser.UserID, "Read", FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }
                Response.ContentType = fi.FileBinaryContentType;
                if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                {
                    Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                else
                {
                    Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                Mediachase.IBN.Business.ControlSystem.FileStorage.LightLoadFile(fi, Response.OutputStream);
            }


            Response.End();
        }
Esempio n. 2
0
        private void BindValues()
        {
            ddlPriority.DataSource     = Incident.GetListPriorities();
            ddlPriority.DataTextField  = "PriorityName";
            ddlPriority.DataValueField = "PriorityId";
            ddlPriority.DataBind();

            ddlProjects.DataSource     = Incident.GetListProjects();
            ddlProjects.DataTextField  = "Title";
            ddlProjects.DataValueField = "ProjectId";
            ddlProjects.DataBind();
            ListItem liNew = new ListItem(LocRM.GetString("ProjectNotSet"), "-1");

            ddlProjects.Items.Insert(0, liNew);
            ddlProjects.DataSource = null;
            ddlProjects.DataBind();

            ClearMHTCache(Server.MapPath(CommonHelper.ChartPath));

            ///	 Pop3MailRequestId, Sender, SenderIbnUserId, FirstName, LastName, Subject, InnerText,
            ///  Priority, PriorityName, Pop3BoxId, Received, MhtFileId, SenderType, Pop3BoxName
            using (IDataReader rdr = IssueRequest.Get(RequestId))
            {
                if (rdr.Read())
                {
                    txtSubject.Text     = rdr["Subject"].ToString();
                    txtDescription.Text = rdr["InnerText"].ToString();

                    Pop3BoxId = (int)rdr["Pop3BoxId"];
                    CommonHelper.SafeSelect(ddlPriority, rdr["Priority"].ToString());

                    if (rdr["SenderIbnUserId"] != DBNull.Value)
                    {
                        lblSender.Text = CommonHelper.GetUserStatus((int)rdr["SenderIbnUserId"]);

                        lblText.Text            = LocRM.GetString("ADText");
                        btnApproveCrete.Visible = false;
                    }
                    else
                    {
                        if (rdr["FirstName"].ToString() != String.Empty || rdr["LastName"].ToString() != String.Empty)
                        {
                            lblSender.Text = String.Format("<a href='mailto:{0}'>{1} {2}</a> ({3})", rdr["Sender"].ToString(), rdr["LastName"].ToString(), rdr["FirstName"].ToString(), LocRM.GetString("Unknown"));
                        }
                        else
                        {
                            lblSender.Text = String.Format("<a href='mailto:{0}'>{0}</a> ({1})", rdr["Sender"].ToString(), LocRM.GetString("Unknown"));
                        }

                        lblText.Text = LocRM.GetString("ADTextExternal");
                    }


                    lblReceived.Text = ((DateTime)rdr["Received"]).ToShortDateString();

                    lnkMailBox.Text        = rdr["Pop3BoxName"].ToString();
                    lnkMailBox.NavigateUrl = String.Format("~/Incidents/default.aspx?BTab=MailIncidents&MailBoxId={0}", rdr["Pop3BoxId"].ToString());

                    int mhtFileId = -1;
                    if (rdr["MhtFileId"] != DBNull.Value)
                    {
                        mhtFileId = (int)rdr["MhtFileId"];
                    }

                    if (mhtFileId > 0)
                    {
                        string wwwpath = CommonHelper.ChartPath + Guid.NewGuid().ToString() + ".mht";

                        Mediachase.IBN.Business.ControlSystem.FileStorage fileStorage = IssueRequest.GetFileStorage(RequestId);

                        using (Stream sw = File.Create(Server.MapPath(wwwpath)))
                        {
                            fileStorage.LoadFile(mhtFileId, sw);
                        }

                        iSrc = ResolveUrl(wwwpath);
                    }
                    else
                    {
                        trMHT.Visible = false;
                    }
                }
                else
                {
                    Response.Redirect("~/common/NotExistingId.aspx?IncidentId=" + RequestId);
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Check Security
            if (Security.CurrentUser == null)
            {
                int iObjectTypeId = -1;
                int iObjectId     = -1;

                using (IDataReader reader = Mediachase.IBN.Business.User.GetGateByGuid(ExternalID))
                {
                    if (reader.Read())
                    {
                        iObjectTypeId = (int)reader["ObjectTypeId"];
                        iObjectId     = (int)reader["ObjectId"];
                    }
                }

                if (iObjectTypeId != (int)ObjectTypes.Issue)
                {
                    throw new AccessDeniedException();
                }
            }

            // Download
            Response.ContentType = "application/octet-stream";
            int    FileId        = int.Parse(Request.QueryString["Id"]);
            string ContainerName = Request.QueryString["CName"];
            string ContainerKey  = Request.QueryString["CKey"];

            if (!String.IsNullOrEmpty(ContainerName) && !String.IsNullOrEmpty(ContainerKey))
            {
                BaseIbnContainer bic = BaseIbnContainer.Create(ContainerName, ContainerKey);
                Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

                FileInfo fi = fs.GetFile(FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }

                FileHistoryInfo fhiLoad = null;
                if (Request["VId"] != null)
                {
                    FileHistoryInfo[] _fhi = fi.GetHistory();
                    foreach (FileHistoryInfo fhi in _fhi)
                    {
                        if (fhi.Id == int.Parse(Request["VId"]))
                        {
                            fhiLoad = fhi;
                            break;
                        }
                    }
                }

                if (fhiLoad == null)
                {
                    Response.ContentType = fi.FileBinaryContentType;

                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    fs.LoadFile(FileId, Response.OutputStream);
                }
                else
                {
                    Response.ContentType = fhiLoad.FileBinaryContentType;
                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fhiLoad.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    fs.LoadFile(fhiLoad, Response.OutputStream);
                }
            }
            else
            {
                Mediachase.IBN.Business.ControlSystem.FileInfo fi = Mediachase.IBN.Business.ControlSystem.FileStorage.GetFile(Mediachase.IBN.Business.Security.CurrentUser.UserID, "Read", FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }
                Response.ContentType = fi.FileBinaryContentType;
                if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                {
                    Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                else
                {
                    Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                Mediachase.IBN.Business.ControlSystem.FileStorage.LightLoadFile(fi, Response.OutputStream);
            }

            Response.End();
        }