Exemplo n.º 1
0
        /// <summary>
        /// 图纸文件上传后回调函数
        /// </summary>
        /// <param name="code"></param>
        /// <param name="path"></param>
        /// <param name="module"></param>
        /// <returns></returns>
        public ActionResult UploadDocComp(string code, string path, string type, string typename, string node, string nodename, string module)
        {
            string         fileName   = Path.GetFileName(path);
            Doc_Attachment attachment = new Doc_Attachment();

            attachment.Dat_Name    = fileName;
            attachment.Dat_Path    = path;
            attachment.Dat_Module  = module;
            attachment.Dat_RefCode = code;

            //文件类型(不同的类型不同的处理方式)
            attachment.Dat_Type        = Path.GetExtension(path).Trim('.');
            attachment.Dat_Date        = DateTime.Now;
            attachment.Dat_Creator     = SessionConfig.UserId();
            attachment.Dat_CreatorName = SessionConfig.UserName();
            attachment.Dat_Code        = diInstance.GenerateAttachmentCode();
            //图纸的类型-->全工艺 、工艺节点
            attachment.Dat_Udef1 = type;
            attachment.Dat_Udef2 = typename;
            attachment.Dat_Udef3 = node;
            attachment.Dat_Udef4 = nodename;
            diInstance.AddAttachment(attachment);

            BLL.Bll_Comm.OpLog("Upload", "Upload", string.Format("上传附件:{0}", attachment.Dat_RefCode));

            return(new JsonResult {
                Data = new { result = "success", Msg = "数据更新成功!" }
            });
        }
Exemplo n.º 2
0
        public bool UpdateAttachment(Doc_Attachment model)
        {
            if (aInstance.Update(model) > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public bool AddAttachment(Doc_Attachment model)
        {
            if (aInstance.Add(model) > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public bool DelAttachment(Doc_Attachment model)
        {
            model.Stat = 1;
            if (aInstance.Update(model) > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        public ActionResult AttachmentDelete(string id)
        {
            Doc_Attachment doc = diInstance.GetAttachModel(id);

            doc.Stat = 1;
            diInstance.UpdateAttachment(doc);

            BLL.Bll_Comm.OpLog("Attachment", "AttachmentDelete", string.Format("删除附件:附件编号:{0},附件所属文件编号:{1}", id, doc.Dat_RefCode));

            return(Json(new { result = "success", message = "成功" }, "text/json"));
        }
Exemplo n.º 6
0
        public ActionResult GetDownload(string id)
        {
            var flag = false;

            string ftype    = Request["ftype"];
            string compcode = Request["CompCode"];

            if (string.IsNullOrEmpty(ftype))
            {
                ftype = "Pic";
            }

            string filepath = string.Empty;
            string filename = string.Empty;

            List <Doc_Attachment> list = dinfoInstance.GetAttachmentListByFtype(id, ftype);

            Doc_Attachment attach = new Doc_Attachment();

            if (list.Count != 0)
            {
                //通过文件类型判断是需要下载还是查看
                attach = list.FirstOrDefault();
                var path = attach.Dat_Path;
                filepath = path;
                filename = attach.Dat_Name;
                flag     = true;
            }
            else
            {
                return(Content("该文件并没有维护相关图纸文件!"));
            }
            //if(flag)
            if (flag && IsHavePermission(id, ftype, compcode))
            {
                if (ftype == "Pic")
                {
                    BLL.Bll_Comm.OpLog("Bse_ComponentsModule", "GetDownload", string.Format("查看图纸:{0}", id));
                    ViewData["File"] = attach.Dat_Code;
                    return(View("ViewPic"));
                }
                else
                {
                    BLL.Bll_Comm.OpLog("Bse_ComponentsModule", "GetDownload", string.Format("下载图纸:{0}", id));
                    return(File(new FileStream(filepath, FileMode.Open), "application/x-zip-compressed", filename));
                }
            }
            else
            {
                return(Content("您没有操作当前文件的权限!"));
            }
        }
Exemplo n.º 7
0
        public ActionResult UploadFile(string code, string path, string module)
        {
            string         fileName   = Path.GetFileName(path);
            Doc_Attachment attachment = new Doc_Attachment();

            attachment.Dat_Name    = fileName;
            attachment.Dat_Path    = path;
            attachment.Dat_Module  = module;
            attachment.Dat_RefCode = code;
            attachment.Dat_Code    = diInstance.GenerateAttachmentCode();
            diInstance.AddAttachment(attachment);
            return(new JsonResult {
                Data = new { result = "success", Msg = "数据更新成功!" }
            });
        }
Exemplo n.º 8
0
        public ActionResult UploadDoc(string code, string path, string module)
        {
            string         fileName   = Path.GetFileName(path);
            Doc_Attachment attachment = new Doc_Attachment();

            attachment.Dat_Name        = fileName;
            attachment.Dat_Path        = path;
            attachment.Dat_Module      = module;
            attachment.Dat_RefCode     = code;
            attachment.Dat_Date        = DateTime.Now;
            attachment.Dat_Creator     = SessionConfig.UserId();
            attachment.Dat_CreatorName = SessionConfig.UserName();
            attachment.Dat_Code        = diInstance.GenerateAttachmentCode();
            diInstance.AddAttachment(attachment);

            BLL.Bll_Comm.OpLog("Upload", "Upload", string.Format("上传附件:{0}", attachment.Dat_RefCode));

            return(new JsonResult {
                Data = new { result = "success", Msg = "数据更新成功!" }
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取所有的Doc_Attachment对象(即:一条记录
        /// </summary>
        public List <Doc_Attachment> GetAll()
        {
            List <Doc_Attachment> ret = new List <Doc_Attachment>();
            string        sql         = "SELECT  Dat_ID,Dat_Code,Dat_Name,Dat_Path,Dat_Module,Dat_RefCode,Dat_Type,Dat_Stat,Dat_Order,Dat_Date,Dat_Creator,Dat_CreatorName,CreateTime,UpdateTime,DeleteTime,Stat,Dat_Udef1,Dat_Udef2,Dat_Udef3,Dat_Udef4,Dat_ShowName FROM Doc_Attachment where 1=1 AND ((Stat is null) or (Stat=0) ) order by Dat_ID desc ";
            SqlDataReader dr          = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    Doc_Attachment doc_Attachment = new Doc_Attachment();
                    if (dr["Dat_ID"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_ID = Convert.ToDecimal(dr["Dat_ID"]);
                    }
                    if (dr["Dat_Code"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Code = Convert.ToString(dr["Dat_Code"]);
                    }
                    if (dr["Dat_Name"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Name = Convert.ToString(dr["Dat_Name"]);
                    }
                    if (dr["Dat_Path"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Path = Convert.ToString(dr["Dat_Path"]);
                    }
                    if (dr["Dat_Module"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Module = Convert.ToString(dr["Dat_Module"]);
                    }
                    if (dr["Dat_RefCode"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_RefCode = Convert.ToString(dr["Dat_RefCode"]);
                    }
                    if (dr["Dat_Type"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Type = Convert.ToString(dr["Dat_Type"]);
                    }
                    if (dr["Dat_Stat"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Stat = Convert.ToString(dr["Dat_Stat"]);
                    }
                    if (dr["Dat_Order"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Order = Convert.ToInt32(dr["Dat_Order"]);
                    }
                    if (dr["Dat_Date"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Date = Convert.ToDateTime(dr["Dat_Date"]);
                    }
                    if (dr["Dat_Creator"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Creator = Convert.ToString(dr["Dat_Creator"]);
                    }
                    if (dr["Dat_CreatorName"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_CreatorName = Convert.ToString(dr["Dat_CreatorName"]);
                    }
                    if (dr["CreateTime"] != DBNull.Value)
                    {
                        doc_Attachment.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
                    }
                    if (dr["UpdateTime"] != DBNull.Value)
                    {
                        doc_Attachment.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
                    }
                    if (dr["DeleteTime"] != DBNull.Value)
                    {
                        doc_Attachment.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        doc_Attachment.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    if (dr["Dat_Udef1"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Udef1 = Convert.ToString(dr["Dat_Udef1"]);
                    }
                    if (dr["Dat_Udef2"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Udef2 = Convert.ToString(dr["Dat_Udef2"]);
                    }
                    if (dr["Dat_Udef3"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Udef3 = Convert.ToString(dr["Dat_Udef3"]);
                    }
                    if (dr["Dat_Udef4"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_Udef4 = Convert.ToString(dr["Dat_Udef4"]);
                    }
                    if (dr["Dat_ShowName"] != DBNull.Value)
                    {
                        doc_Attachment.Dat_ShowName = Convert.ToString(dr["Dat_ShowName"]);
                    }
                    ret.Add(doc_Attachment);
                }
            }catch (System.Exception ex) { throw ex; }  finally { if (dr != null)
                                                                  {
                                                                      dr.Close();
                                                                  }
                                                                  if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open)
                                                                  {
                                                                      idb.GetConnection().Close();
                                                                  }
            }
            return(ret);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 更新Doc_Attachment对象(即:一条记录
        /// </summary>
        public int Update(Doc_Attachment doc_Attachment)
        {
            StringBuilder sbParameter = new StringBuilder();
            StringBuilder sb          = new StringBuilder();

            sb.Append(@"UPDATE       Doc_Attachment       SET ");
            if (doc_Attachment.Dat_Code_IsChanged)
            {
                sbParameter.Append("Dat_Code=@Dat_Code, ");
            }
            if (doc_Attachment.Dat_Name_IsChanged)
            {
                sbParameter.Append("Dat_Name=@Dat_Name, ");
            }
            if (doc_Attachment.Dat_Path_IsChanged)
            {
                sbParameter.Append("Dat_Path=@Dat_Path, ");
            }
            if (doc_Attachment.Dat_Module_IsChanged)
            {
                sbParameter.Append("Dat_Module=@Dat_Module, ");
            }
            if (doc_Attachment.Dat_RefCode_IsChanged)
            {
                sbParameter.Append("Dat_RefCode=@Dat_RefCode, ");
            }
            if (doc_Attachment.Dat_Type_IsChanged)
            {
                sbParameter.Append("Dat_Type=@Dat_Type, ");
            }
            if (doc_Attachment.Dat_Stat_IsChanged)
            {
                sbParameter.Append("Dat_Stat=@Dat_Stat, ");
            }
            if (doc_Attachment.Dat_Order_IsChanged)
            {
                sbParameter.Append("Dat_Order=@Dat_Order, ");
            }
            if (doc_Attachment.Dat_Date_IsChanged)
            {
                sbParameter.Append("Dat_Date=@Dat_Date, ");
            }
            if (doc_Attachment.Dat_Creator_IsChanged)
            {
                sbParameter.Append("Dat_Creator=@Dat_Creator, ");
            }
            if (doc_Attachment.Dat_CreatorName_IsChanged)
            {
                sbParameter.Append("Dat_CreatorName=@Dat_CreatorName, ");
            }
            if (doc_Attachment.CreateTime_IsChanged)
            {
                sbParameter.Append("CreateTime=@CreateTime, ");
            }
            if (doc_Attachment.UpdateTime_IsChanged)
            {
                sbParameter.Append("UpdateTime=@UpdateTime, ");
            }
            if (doc_Attachment.DeleteTime_IsChanged)
            {
                sbParameter.Append("DeleteTime=@DeleteTime, ");
            }
            if (doc_Attachment.Stat_IsChanged)
            {
                sbParameter.Append("Stat=@Stat, ");
            }
            if (doc_Attachment.Dat_Udef1_IsChanged)
            {
                sbParameter.Append("Dat_Udef1=@Dat_Udef1, ");
            }
            if (doc_Attachment.Dat_Udef2_IsChanged)
            {
                sbParameter.Append("Dat_Udef2=@Dat_Udef2, ");
            }
            if (doc_Attachment.Dat_Udef3_IsChanged)
            {
                sbParameter.Append("Dat_Udef3=@Dat_Udef3, ");
            }
            if (doc_Attachment.Dat_Udef4_IsChanged)
            {
                sbParameter.Append("Dat_Udef4=@Dat_Udef4, ");
            }
            if (doc_Attachment.Dat_ShowName_IsChanged)
            {
                sbParameter.Append("Dat_ShowName=@Dat_ShowName ");
            }
            sb.Append(sbParameter.ToString().Trim().TrimEnd(','));
            sb.Append(" WHERE 1=1 AND ((Stat is null) or (Stat=0))   and Dat_ID=@Dat_ID; ");
            string sql = sb.ToString();

            if (doc_Attachment.Dat_Code_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Code))
                {
                    idb.AddParameter("@Dat_Code", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Code", doc_Attachment.Dat_Code);
                }
            }
            if (doc_Attachment.Dat_Name_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Name))
                {
                    idb.AddParameter("@Dat_Name", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Name", doc_Attachment.Dat_Name);
                }
            }
            if (doc_Attachment.Dat_Path_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Path))
                {
                    idb.AddParameter("@Dat_Path", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Path", doc_Attachment.Dat_Path);
                }
            }
            if (doc_Attachment.Dat_Module_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Module))
                {
                    idb.AddParameter("@Dat_Module", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Module", doc_Attachment.Dat_Module);
                }
            }
            if (doc_Attachment.Dat_RefCode_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_RefCode))
                {
                    idb.AddParameter("@Dat_RefCode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_RefCode", doc_Attachment.Dat_RefCode);
                }
            }
            if (doc_Attachment.Dat_Type_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Type))
                {
                    idb.AddParameter("@Dat_Type", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Type", doc_Attachment.Dat_Type);
                }
            }
            if (doc_Attachment.Dat_Stat_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Stat))
                {
                    idb.AddParameter("@Dat_Stat", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Stat", doc_Attachment.Dat_Stat);
                }
            }
            if (doc_Attachment.Dat_Order_IsChanged)
            {
                if (doc_Attachment.Dat_Order == 0)
                {
                    idb.AddParameter("@Dat_Order", 0);
                }
                else
                {
                    idb.AddParameter("@Dat_Order", doc_Attachment.Dat_Order);
                }
            }
            if (doc_Attachment.Dat_Date_IsChanged)
            {
                if (doc_Attachment.Dat_Date == DateTime.MinValue)
                {
                    idb.AddParameter("@Dat_Date", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Date", doc_Attachment.Dat_Date);
                }
            }
            if (doc_Attachment.Dat_Creator_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Creator))
                {
                    idb.AddParameter("@Dat_Creator", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Creator", doc_Attachment.Dat_Creator);
                }
            }
            if (doc_Attachment.Dat_CreatorName_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_CreatorName))
                {
                    idb.AddParameter("@Dat_CreatorName", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_CreatorName", doc_Attachment.Dat_CreatorName);
                }
            }
            if (doc_Attachment.CreateTime_IsChanged)
            {
                if (doc_Attachment.CreateTime == DateTime.MinValue)
                {
                    idb.AddParameter("@CreateTime", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@CreateTime", doc_Attachment.CreateTime);
                }
            }
            if (doc_Attachment.UpdateTime_IsChanged)
            {
                if (doc_Attachment.UpdateTime == DateTime.MinValue)
                {
                    idb.AddParameter("@UpdateTime", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@UpdateTime", doc_Attachment.UpdateTime);
                }
            }
            if (doc_Attachment.DeleteTime_IsChanged)
            {
                if (doc_Attachment.DeleteTime == DateTime.MinValue)
                {
                    idb.AddParameter("@DeleteTime", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@DeleteTime", doc_Attachment.DeleteTime);
                }
            }
            if (doc_Attachment.Stat_IsChanged)
            {
                if (doc_Attachment.Stat == 0)
                {
                    idb.AddParameter("@Stat", 0);
                }
                else
                {
                    idb.AddParameter("@Stat", doc_Attachment.Stat);
                }
            }
            if (doc_Attachment.Dat_Udef1_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef1))
                {
                    idb.AddParameter("@Dat_Udef1", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Udef1", doc_Attachment.Dat_Udef1);
                }
            }
            if (doc_Attachment.Dat_Udef2_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef2))
                {
                    idb.AddParameter("@Dat_Udef2", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Udef2", doc_Attachment.Dat_Udef2);
                }
            }
            if (doc_Attachment.Dat_Udef3_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef3))
                {
                    idb.AddParameter("@Dat_Udef3", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Udef3", doc_Attachment.Dat_Udef3);
                }
            }
            if (doc_Attachment.Dat_Udef4_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef4))
                {
                    idb.AddParameter("@Dat_Udef4", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_Udef4", doc_Attachment.Dat_Udef4);
                }
            }
            if (doc_Attachment.Dat_ShowName_IsChanged)
            {
                if (string.IsNullOrEmpty(doc_Attachment.Dat_ShowName))
                {
                    idb.AddParameter("@Dat_ShowName", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@Dat_ShowName", doc_Attachment.Dat_ShowName);
                }
            }

            idb.AddParameter("@Dat_ID", doc_Attachment.Dat_ID);

            return(idb.ExeCmd(sql));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 添加Doc_Attachment对象(即:一条记录)
        /// </summary>
        public object AddWithReturn(Doc_Attachment doc_Attachment)
        {
            string sql = "INSERT INTO Doc_Attachment (Dat_Code,Dat_Name,Dat_Path,Dat_Module,Dat_RefCode,Dat_Type,Dat_Stat,Dat_Order,Dat_Date,Dat_Creator,Dat_CreatorName,CreateTime,UpdateTime,DeleteTime,Stat,Dat_Udef1,Dat_Udef2,Dat_Udef3,Dat_Udef4,Dat_ShowName) VALUES (@Dat_Code,@Dat_Name,@Dat_Path,@Dat_Module,@Dat_RefCode,@Dat_Type,@Dat_Stat,@Dat_Order,@Dat_Date,@Dat_Creator,@Dat_CreatorName,@CreateTime,@UpdateTime,@DeleteTime,@Stat,@Dat_Udef1,@Dat_Udef2,@Dat_Udef3,@Dat_Udef4,@Dat_ShowName);SELECT @@IDENTITY AS ReturnID;";

            if (string.IsNullOrEmpty(doc_Attachment.Dat_Code))
            {
                idb.AddParameter("@Dat_Code", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Code", doc_Attachment.Dat_Code);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Name))
            {
                idb.AddParameter("@Dat_Name", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Name", doc_Attachment.Dat_Name);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Path))
            {
                idb.AddParameter("@Dat_Path", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Path", doc_Attachment.Dat_Path);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Module))
            {
                idb.AddParameter("@Dat_Module", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Module", doc_Attachment.Dat_Module);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_RefCode))
            {
                idb.AddParameter("@Dat_RefCode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_RefCode", doc_Attachment.Dat_RefCode);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Type))
            {
                idb.AddParameter("@Dat_Type", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Type", doc_Attachment.Dat_Type);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Stat))
            {
                idb.AddParameter("@Dat_Stat", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Stat", doc_Attachment.Dat_Stat);
            }
            if (doc_Attachment.Dat_Order == 0)
            {
                idb.AddParameter("@Dat_Order", 0);
            }
            else
            {
                idb.AddParameter("@Dat_Order", doc_Attachment.Dat_Order);
            }
            if (doc_Attachment.Dat_Date == DateTime.MinValue)
            {
                idb.AddParameter("@Dat_Date", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Date", doc_Attachment.Dat_Date);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Creator))
            {
                idb.AddParameter("@Dat_Creator", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Creator", doc_Attachment.Dat_Creator);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_CreatorName))
            {
                idb.AddParameter("@Dat_CreatorName", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_CreatorName", doc_Attachment.Dat_CreatorName);
            }
            if (doc_Attachment.CreateTime == DateTime.MinValue)
            {
                idb.AddParameter("@CreateTime", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@CreateTime", doc_Attachment.CreateTime);
            }
            if (doc_Attachment.UpdateTime == DateTime.MinValue)
            {
                idb.AddParameter("@UpdateTime", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@UpdateTime", doc_Attachment.UpdateTime);
            }
            if (doc_Attachment.DeleteTime == DateTime.MinValue)
            {
                idb.AddParameter("@DeleteTime", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@DeleteTime", doc_Attachment.DeleteTime);
            }
            if (doc_Attachment.Stat == 0)
            {
                idb.AddParameter("@Stat", 0);
            }
            else
            {
                idb.AddParameter("@Stat", doc_Attachment.Stat);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef1))
            {
                idb.AddParameter("@Dat_Udef1", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Udef1", doc_Attachment.Dat_Udef1);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef2))
            {
                idb.AddParameter("@Dat_Udef2", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Udef2", doc_Attachment.Dat_Udef2);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef3))
            {
                idb.AddParameter("@Dat_Udef3", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Udef3", doc_Attachment.Dat_Udef3);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_Udef4))
            {
                idb.AddParameter("@Dat_Udef4", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_Udef4", doc_Attachment.Dat_Udef4);
            }
            if (string.IsNullOrEmpty(doc_Attachment.Dat_ShowName))
            {
                idb.AddParameter("@Dat_ShowName", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@Dat_ShowName", doc_Attachment.Dat_ShowName);
            }

            return(idb.ReturnValue(sql));
        }
Exemplo n.º 12
0
        public ActionResult GetDownload(string id)
        {
            var flag = false;

            string ftype = Request["ftype"];

            if (string.IsNullOrEmpty(ftype))
            {
                ftype = "Doc_AttachmentModule";
            }

            string filepath = string.Empty;
            string filename = string.Empty;

            switch (ftype)
            {
            case "Bse_ComponentsModule":
            {
                flag = IsHaveDownloadPermission("400700", AuditModuleEnum.CompAudit.ToString());
                Doc_Attachment attach = diInstance.GetAttachModel(id);
                var            path   = attach.Dat_Path;
                filepath = path;
                filename = attach.Dat_Name;
                break;
            }

            case "Bse_FileModule":
            {
                flag = IsHaveDownloadPermission("300700", AuditModuleEnum.ComFileAudit.ToString());
                Doc_Attachment attach = diInstance.GetAttachModel(id);
                var            path   = attach.Dat_Path;
                filepath = path;
                filename = attach.Dat_Name;
                break;
            }

            case "Doc_AttachmentModule":
            default:
            {
                flag = IsHaveDownloadPermission("200700", AuditModuleEnum.DocumentAudit.ToString());

                Doc_Attachment attach = diInstance.GetAttachModel(id);
                var            path   = attach.Dat_Path;
                filepath = path;
                filename = attach.Dat_Name;

                if (attach.Dat_Creator == SessionConfig.UserId())
                {
                    flag = true;
                }

                break;
            }
            }

            if (flag)
            {
                switch (ftype)
                {
                case "Comp":
                {
                    BLL.Bll_Comm.OpLog("Bse_ComponentsModule", "GetDownload", string.Format("下载图纸:{0}", id));
                    break;
                }

                case "File":
                {
                    BLL.Bll_Comm.OpLog("Bse_FileModule", "GetDownload", string.Format("下载文档:{0}", id));
                    break;
                }

                case "Doc":
                default:
                {
                    BLL.Bll_Comm.OpLog("CListDoc_Info", "GetDownload", string.Format("下载公文:{0}", id));

                    break;
                }
                }
                return(File(new FileStream(filepath, FileMode.Open), "text/plain", filename));
            }
            else
            {
                return(Content("您没有下载当前文件的权限!"));
            }
        }