Ejemplo n.º 1
0
        /// <summary>
        /// 添加附件
        /// </summary>
        /// <param name="BusinessID"></param>
        /// <param name="FileName"></param>
        /// <param name="FileUrl"></param>
        /// <param name="fileStream"></param>
        private void AddAttachments(Guid BusinessID, string FileName, string FileUrl, FileStream fileStream)
        {
            string _Size = string.Empty;

            if (fileStream.Length > 1024 * 1024)
            {
                _Size = (fileStream.Length / (1024 * 1024)).ToString("D2") + " M";
            }
            else
            {
                _Size = (fileStream.Length / (1024)).ToString("D2") + " KB";
            }

            B_Attachment Att = new B_Attachment()
            {
                BusinessID   = BusinessID,
                FileName     = FileName,
                Url          = FileUrl,
                BusinessType = "系统生成Excel",
                CreateTime   = DateTime.Now,
                CreatorName  = "SystemTargetPlan",
                IsDeleted    = false,
                Size         = _Size
            };

            //判断是否存在
            var AttList = B_AttachmentOperator.Instance.GetAttachmentList(BusinessID, "系统生成Excel").ToList();

            if (AttList != null && AttList.Count > 0)
            {
                var UAtt = AttList.Where(A => A.FileName == FileName).FirstOrDefault();

                if (UAtt != null)
                {
                    UAtt.BusinessID   = BusinessID;
                    UAtt.FileName     = FileName;
                    UAtt.Url          = FileUrl;
                    UAtt.BusinessType = "系统生成Excel";
                    UAtt.CreateTime   = DateTime.Now;
                    UAtt.CreatorName  = "SystemTargetPlan";
                    UAtt.IsDeleted    = false;
                    UAtt.Size         = _Size;
                    B_AttachmentOperator.Instance.UpdateAttachment(UAtt); // 更新
                }
                else
                {
                    B_AttachmentOperator.Instance.AddAttachment(Att);
                }
            }
            else
            {
                B_AttachmentOperator.Instance.AddAttachment(Att);
            }
        }
Ejemplo n.º 2
0
        public static string PrepareOrderAttrImg(string sid)
        {
            string              r    = "";
            StringBuilder       hstr = new StringBuilder();
            SessionUserValidate iv   = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                Sys_Domain    sd  = sdb.Query(" and dtype='p'");
                string        zt  = bosb.QueryOrderStateImg(sid);
                B_Attachment  ba  = bmib.Query(" and sid='" + sid + "'");
                CB_OrderState cos = cbsb.Query("and sid='" + sid + "'");
                hstr.Append("<table style='border:none; width:100%'> ");
                hstr.AppendFormat("<tr><td align='center' height='40'><strong>状态:</strong></td><td align='center'><img src='{0}'></td></tr>", zt);
                hstr.AppendFormat("<tr><td align='center'height='40'><strong>日志:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/makep.png' id='{0}' onclick='ShowLogs(this.id)' style='cursor:pointer'/></td></tr>", sid);
                if (ba != null)
                {
                    hstr.AppendFormat("<tr><td align='center'height='40'><strong>附件:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/zip.gif' id='{0}' onclick='ShowAttachment(this.id)'style='cursor:pointer'/></td></tr>", sid);
                }
                if (cos != null)
                {
                    if (cos.iproduce > 0)
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>工单:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/has.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                    else
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>工单:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/cancel.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                    if (cos.iwjbh > 0)
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>备货:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/has.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                    else
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>备货:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/cancel.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                }
                hstr.Append("</table>");
                r = hstr.ToString();
            }
            else
            {
                r = iv.badstr;
            }
            return(r);
        }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["sid"] != null)
     {
         string filePath  = "";
         string fileName  = "";
         string sid       = Request.QueryString["sid"].ToString();
         string otype     = Request.QueryString["otype"].ToString();
         string ftype     = Request.QueryString["ftype"].ToString();
         bool   urlencode = true;
         string brower    = Request.Browser.Browser;
         if (brower == "Firefox")
         {
             urlencode = false;
         }
         #region//附件
         if (otype == "")
         {
             if (ftype == "a")
             {
                 B_Attachment ba = bmib.Query(" and id=" + sid + "");
                 if (ba != null)
                 {
                     filePath = Server.MapPath(ba.furl);
                     fileName = ba.fname;
                 }
             }
             if (ftype == "d")
             {
                 B_DesignPlan ba = bdpb.Query(" and id=" + sid + "");
                 if (ba != null)
                 {
                     filePath = Server.MapPath(ba.durl);
                     fileName = ba.dname;
                 }
             }
         }
         #endregion
         #region //木门单下载
         #endregion
         #region //木作单下载
         if (otype == "mz")
         {
             if (ftype == "rplan")
             {
                 B_MzRequstDesign bp = bmrdpb.Query(" and id=" + sid + "");
                 if (bp != null)
                 {
                     filePath = Server.MapPath(bp.url);
                     fileName = bp.pname;
                 }
             }
             if (ftype == "plan")
             {
                 B_MzDesignPlan bp = bmdpb.Query(" and id=" + sid + "");
                 if (bp != null)
                 {
                     filePath = Server.MapPath(bp.purl);
                     fileName = bp.pname;
                 }
             }
             if (ftype == "bj")
             {
                 B_MzPriceFile bp = bmpfb.Query(" and id=" + sid + "");
                 if (bp != null)
                 {
                     filePath = Server.MapPath(bp.furl);
                     fileName = bp.fname;
                 }
             }
         }
         #endregion
         #region//反馈单下载
         if (otype == "fk")
         {
             if (ftype == "bj")
             {
                 B_AfterPriceFile bp = bapfb.Query(" and id=" + sid + "");
                 if (bp != null)
                 {
                     filePath = Server.MapPath(bp.furl);
                     fileName = bp.fname;
                 }
             }
         }
         #endregion
         if (filePath != "" && fileName != "")
         {
             Downfiles(filePath, fileName, urlencode);
         }
     }
 }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string r = "", sid = "", gsid = "", fname = "", ftype = "";
            SessionUserValidate iv = SysValidateBll.ValidateSession();
            B_AttachmentBll     bmib = new B_AttachmentBll();

            if (iv.f)
            {
                HttpFileCollection files = Request.Files;
                if (Request.QueryString["sid"] != null)
                {
                    sid = Request.QueryString["sid"];
                }
                if (Request.QueryString["gsid"] != null)
                {
                    gsid = Request.QueryString["gsid"];
                }
                if (Request.QueryString["fname"] != null)
                {
                    fname = Request.QueryString["fname"];
                }
                if (Request.QueryString["ftype"] != null)
                {
                    ftype = Request.QueryString["ftype"];
                }
                string       newname = DateTime.Now.ToString("yyyyMMddhhmmssfff");
                UpFile       uf      = new UpFile();
                ArrayList    efile   = new ArrayList();
                B_Attachment spi     = new B_Attachment();
                string       url     = "/UpFile/Attachment/";
                string       ur      = uf.UpFiles(files[0], newname, url, 102400000);
                if (ur.Length > 1)
                {
                    string xname = uf.GetFileExName(files[0]);
                    spi.sid   = sid;
                    spi.gsid  = gsid;
                    spi.maker = iv.u.ename;
                    spi.fname = fname + xname;
                    spi.furl  = url + ur;
                    spi.ftype = ftype;
                    spi.cdate = DateTime.Now.ToString();
                    if (bmib.Add(spi) > 0)
                    {
                        r = "S";
                    }
                    else
                    {
                        r = "F";
                    }
                }
                else
                {
                    r = ur;
                }
            }
            else
            {
                r = iv.badstr;
            }
            Response.Write("{  msg:'" + r + "'}");
            Response.End();
        }
Ejemplo n.º 5
0
        public static string OrderAttrImg(string sid)
        {
            string              r    = "";
            StringBuilder       hstr = new StringBuilder();
            SessionUserValidate iv   = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                Sys_Domain          sd   = sdb.Query(" and dtype='p'");
                string              zt   = bosb.QueryOrderStateImg(sid);
                B_Attachment        ba   = bmib.Query(" and sid='" + sid + "'");
                CB_OrderState       cos  = cbsb.Query("and sid='" + sid + "'");
                CB_OrderProduceType ct   = coptb.Query("and sid='" + sid + "'");
                B_FeedBackImg       bfi  = bfbib.Query(" and sid='" + sid + "'");
                B_DesignPlan        bdp  = bdpb.Query(" and osid='" + sid + "' and dtype='0'");
                B_DesignPlan        bdpt = bdpb.Query(" and osid='" + sid + "' and dtype='1'");
                hstr.Append("<table style='border:none; width:100%'> ");
                hstr.AppendFormat("<tr><td align='center' height='40'><strong>状态:</strong></td><td align='center'><img src='{0}'></td></tr>", zt);
                hstr.AppendFormat("<tr><td align='center'height='40'><strong>日志:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/makep.png' id='{0}' onclick='ShowLogs(this.id)' style='cursor:pointer'/></td></tr>", sid);
                if (ba != null)
                {
                    hstr.AppendFormat("<tr><td align='center'height='40'><strong>附件:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/zip.gif' id='{0}' onclick='ShowAttachment(this.id)'style='cursor:pointer'/></td></tr>", sid);
                }
                if (bdp != null)
                {
                    hstr.AppendFormat("<tr><td align='center'height='40'><strong>方案:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/design.gif' id='{0}' onclick='ShowDesign(this.id,0)'style='cursor:pointer'/></td></tr>", sid);
                }
                if (bdpt != null)
                {
                    hstr.AppendFormat("<tr><td align='center'height='40'><strong>二次方案:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/design.gif' id='{0}' onclick='ShowDesign(this.id,1)'style='cursor:pointer'/></td></tr>", sid);
                }
                if (bfi != null)
                {
                    hstr.AppendFormat("<tr><td align='center'height='40'><strong>售后:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/afterimg.gif' id='{0}' onclick='ShowAfterImg()'style='cursor:pointer'/></td></tr>", sid);
                }
                if (ct != null)
                {
                    if (ct.gytype == "线上")
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>生产:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/online.gif'  style='cursor:pointer'/></td></tr>");
                    }
                    if (ct.gytype == "线下")
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>生产:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/offline.gif'  style='cursor:pointer'/></td></tr>");
                    }
                }
                if (cos != null)
                {
                    if (cos.inewpp > 0)
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>新报价:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/nbj.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                    if (cos.ipdraw == 1)
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>绘图中:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/drawing.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                    if (cos.ipdraw == 2)
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>已绘图:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/drawed.png' id='{0}' onclick='ShowDrawImage(this.id)'style='cursor:pointer'/></td></tr>", sid);
                    }
                    if (cos.imeasure == 1)
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>测量中:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/measuring.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                    if (cos.imeasure == 2)
                    {
                        hstr.AppendFormat("<tr><td align='center'height='40'><strong>已测量:</strong></td><td align='center'><img src='" + sd.url + "/Image/opeimage/measured.png' id='{0}' style='cursor:pointer'/></td></tr>", sid);
                    }
                }

                hstr.Append("</table>");
                r = hstr.ToString();
            }
            else
            {
                r = iv.badstr;
            }
            return(r);
        }
Ejemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            string r = "", sid = "", gsid = "", fname = "", ftype = "";
            SessionUserValidate iv = SysValidateBll.ValidateSession();
            B_AttachmentBll     bmdpb = new B_AttachmentBll();
            B_TempUpFileBll     btufb = new B_TempUpFileBll();

            if (iv.f)
            {
                string             rfname = context.Request["fileName"].ToString();
                string             pfname = context.Request["partName"].ToString();
                HttpFileCollection files  = context.Request.Files;
                if (context.Request.QueryString["sid"] != null)
                {
                    sid = context.Request.QueryString["sid"];
                }
                if (context.Request.QueryString["gsid"] != null)
                {
                    gsid = context.Request.QueryString["gsid"];
                }
                if (context.Request.QueryString["fname"] != null)
                {
                    fname = context.Request.QueryString["fname"];
                }
                if (context.Request.QueryString["ftype"] != null)
                {
                    ftype = context.Request.QueryString["ftype"];
                }
                string         newname = DateTime.Now.ToString("yyyyMMddhhmmssfff");
                UpFile         uf      = new UpFile();
                ArrayList      efile   = new ArrayList();
                B_Attachment   spi     = new B_Attachment();
                HttpPostedFile file    = files[0];
                if (sid != "")
                {
                    string[] f = pfname.Split('-');
                    if (f[1] == "0")
                    {
                        try
                        {
                            List <B_TempUpFile> lufp = btufb.QueryList("and fname like '" + rfname + "' and sid='" + sid + "' order by fdate asc");
                            if (lufp != null)
                            {
                                foreach (B_TempUpFile u in lufp)
                                {
                                    File.Delete(u.furl);
                                }
                                btufb.Delete(" and fname = '" + rfname + "' and sid='" + sid + "' ");
                            }
                        }
                        catch (Exception e)
                        {
                            Log4.WriteLog(e.ToString());
                        }
                    }
                    if (btufb.Exists(" and sid='" + sid + "' and fpname='" + pfname + "'"))
                    {
                    }
                    else
                    {
                        string       url          = "/UpFile/Attachment/Temp";
                        string       durl         = "/UpFile/Attachment/";
                        string       temSavePath  = context.Server.MapPath(url);
                        string       SavePath     = context.Server.MapPath(durl);
                        string       saveFileName = String.Format("{0}{1}", DateTime.Now.ToString("yyyyMMddhhmmssffff"), Path.GetExtension(rfname));//保存文件名称
                        string       fileName     = String.Format(@"{0}\{1}", temSavePath, saveFileName);
                        string       sfname       = SavePath + "/" + newname + Path.GetExtension(rfname);
                        string       xsfname      = durl + "/" + newname + Path.GetExtension(rfname);
                        B_TempUpFile btuf         = new B_TempUpFile();
                        btuf.sid    = sid;
                        btuf.fname  = rfname;
                        btuf.fover  = 0;
                        btuf.fpname = pfname;
                        btuf.fsize  = file.ContentLength;
                        btuf.furl   = fileName;
                        btufb.Add(btuf);
                        try
                        {
                            if (System.IO.File.Exists(fileName))
                            {
                                File.Delete(fileName);
                            }
                            file.SaveAs(fileName);
                            if (GetFileSize(fileName) != file.ContentLength)
                            {
                                r = "F";
                            }
                            else
                            {
                                btufb.Add(btuf);
                            }
                        }
                        catch
                        {
                            r = "F";
                        }
                        if (r != "F")
                        {
                            btufb.UpOver(" and sid='" + sid + "' and fpname='" + pfname + "'");
                            if (btufb.Exists(" and fname like '" + rfname + "%' and fsize<1000000 and sid='" + sid + "'"))
                            {
                                try
                                {
                                    List <B_TempUpFile> lufp = btufb.QueryList("and fname like '" + rfname + "' and sid='" + sid + "' order by fdate asc");
                                    if (lufp != null)
                                    {
                                        System.IO.FileStream fileStram = File.Open(sfname, FileMode.Create, FileAccess.Write);
                                        foreach (B_TempUpFile u in lufp)
                                        {
                                            FileStream save  = new FileStream(u.furl, FileMode.Open, FileAccess.Read);
                                            byte[]     bt    = new byte[1024];
                                            int        count = -1;
                                            while ((count = save.Read(bt, 0, bt.Length)) > 0)
                                            {
                                                fileStram.Write(bt, 0, count);
                                            }
                                            save.Close();
                                            save.Dispose();
                                        }
                                        fileStram.Close();
                                        fileStram.Dispose();
                                        spi.sid   = sid;
                                        spi.gsid  = gsid;
                                        spi.maker = iv.u.ename;
                                        spi.fname = fname + Path.GetExtension(rfname);
                                        spi.furl  = xsfname;
                                        spi.ftype = ftype;
                                        spi.cdate = DateTime.Now.ToString();
                                        if (bmdpb.Add(spi) > 0)
                                        {
                                            r = "S";
                                        }
                                        else
                                        {
                                            r = "F";
                                        }
                                        foreach (B_TempUpFile u in lufp)
                                        {
                                            File.Delete(u.furl);
                                        }
                                        btufb.Delete(" and fname = '" + rfname + "' and sid='" + sid + "' ");
                                    }
                                }
                                catch (Exception e)
                                {
                                    Log4.WriteLog(e.ToString());
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                r = iv.badstr;
            }
        }
Ejemplo n.º 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpPostedFile file   = context.Request.Files["FileData"];
            string         action = context.Request["action"];
            string         BizID  = context.Request["BusinessID"];

            string[] actions = action.Split(new char[] { '|' });


            string filePath = "Attachments\\" + WebHelper.DateTimeNow.ToString("yyyy_MM") + "\\";
            //string uploadpath = context.Server.MapPath(filePath);
            string uploadpath = Path.Combine(UploadFilePath, filePath);

            if (file != null)
            {
                try
                {
                    if (!Directory.Exists(uploadpath))
                    {
                        Directory.CreateDirectory(uploadpath);
                    }
                    B_Attachment _attachment = new B_Attachment();

                    _attachment.CreatorName = "System"; // WebHelper.GetCurrentUser().DisplayName;  当前上传附件的人,记录下来

                    Guid   ID       = B_AttachmentOperator.Instance.AddAttachment(_attachment);
                    string filename = ID + Path.GetExtension(file.FileName);
                    _attachment.ID = ID;

                    _attachment.BusinessType = action;
                    if (actions.Count() > 1)
                    {
                        _attachment.BusinessType = actions[0];
                        if (string.IsNullOrEmpty(actions[1]))
                        {
                            _attachment.BusinessID = Guid.Empty;
                        }
                        else
                        {
                            _attachment.BusinessID = Guid.Parse(actions[1]);
                        }
                    }
                    if (_attachment.BusinessID == Guid.Empty && !string.IsNullOrEmpty(BizID))
                    {
                        _attachment.BusinessID = Guid.Parse(BizID);
                    }

                    _attachment.FileName = file.FileName;
                    _attachment.Url      = filePath + filename;

                    if (file.ContentLength > 1024 * 1024)
                    {
                        _attachment.Size = (file.ContentLength / (1024 * 1024)).ToString("D2") + " M";
                    }
                    else
                    {
                        _attachment.Size = (file.ContentLength / (1024)).ToString("D2") + " KB";
                    }
                    file.SaveAs(uploadpath + filename);
                    context.Response.Write(filePath + filename);
                    B_AttachmentOperator.Instance.UpdateAttachment(_attachment);
                    string response = "{"
                                      + string.Format("ID:\"{0}\",CreatorName:\"{1}\",CreateTime:\"{2}\",Url:\"{3}\",Size:\"{4}\",FileName:\"{5}\""
                                                      , new string[] {
                        _attachment.ID.ToString(),
                        _attachment.CreatorName,
                        _attachment.CreateTime.ToShortDateString(),
                        HttpUtility.UrlEncode(_attachment.Url),
                        _attachment.Size,
                        _attachment.FileName
                    })
                                      + "}";

                    response = Encoding.GetEncoding("GB2312").GetString(Encoding.Default.GetBytes(response));

                    context.Response.Write(response);
                }
                catch (Exception exp)
                {
                    context.Response.Write("Faild:" + exp.Message);
                }
            }
            else
            {
                context.Response.Write("Faild:Empty file.");
            }
        }