Exemple #1
0
    private void dgdAnnex_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        switch (e.Item.ItemType)
        {
        case ListItemType.Item:
        case ListItemType.AlternatingItem:
        {
            AnnexInfo annexInfo = (AnnexInfo)e.Item.DataItem;
            e.Item.Attributes["id"]      = annexInfo.AnnexCode.ToString();
            e.Item.Attributes["onclick"] = string.Concat(new string[]
                {
                    "doClick(this,'",
                    this.dgdAnnex.ClientID,
                    "');clickAnnexRow('",
                    this.btnDel.ClientID,
                    "','",
                    this.hdnAnnexCode.ClientID,
                    "','",
                    annexInfo.AnnexCode.ToString(),
                    "');"
                });
            e.Item.Attributes["onmouseover"] = "doMouseOver(this);";
            e.Item.Attributes["onmouseout"]  = "doMouseOut(this);";
            ((HyperLink)e.Item.Cells[4].Controls[1]).NavigateUrl = "/Common/DownLoad2.aspx?path=" + HttpUtility.UrlEncode(annexInfo.FilePath + annexInfo.AnnexName, Encoding.UTF8) + "&Name=" + HttpUtility.UrlEncode(annexInfo.OriginalName, Encoding.UTF8);
            ((HyperLink)e.Item.Cells[4].Controls[1]).Target      = "_blank";
            return;
        }

        default:
            return;
        }
    }
Exemple #2
0
        private bool SaveToDataBase(Guid annexCode, string thumbnailPath, string thumbnaName)
        {
            AnnexInfo singleAnnexInfo = this.annexAction.GetSingleAnnexInfo(annexCode);
            DataTable table           = publicDbOpClass.DataTableQuary("select a.projectcode,a.Remark from EPM_Book_ConstructTask a,Xpm_basic_AnnexList b where cast(a.noteid as nvarchar)=b.recordcode and b.recordcode='" + singleAnnexInfo.RecordCode + "'");
            string    str2            = "";

            if (table.Rows.Count > 0)
            {
                str2  = (table.Rows[0]["Remark"] as string) ?? string.Empty;
                table = publicDbOpClass.DataTableQuary("select prjName from PT_PrjInfo where prjguid='" + table.Rows[0]["projectcode"] + "'");
            }
            string str3 = "";

            if (table.Rows.Count > 0)
            {
                str3 = table.Rows[0]["prjName"].ToString();
            }
            Thumbnai thumbnai = new Thumbnai {
                ThumbnaiCode   = new Guid(annexCode.ToString()),
                ShowContent    = str3 + " " + DateTime.Now.ToString("yyyyMMdd"),
                ThumbnaImgPath = thumbnailPath + "thumbnail/",
                ThumbnaName    = thumbnaName,
                AddDate        = DateTime.Now,
                Remark         = str2,
                ImgPath        = singleAnnexInfo.FilePath + singleAnnexInfo.AnnexName
            };

            return(this.AddThumbnai(thumbnai));
        }
Exemple #3
0
        public int AddAnnexs(HttpPostedFile postedFile, AnnexInfo annexInfo, AnnexModuleSettingsInfo settingsInfo)
        {
            FileUpload upload = new FileUpload {
                ExtName    = settingsInfo.ExtName,
                FileSize   = settingsInfo.FileSize,
                UploadPath = settingsInfo.FilePath + annexInfo.AnnexType.ToString() + "/"
            };

            if (upload.UploadValidator(postedFile))
            {
                annexInfo.OriginalName = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf(@"\") + 1);
                string fileName = "";
                fileName            = ((DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString().PadLeft(2, '0') + DateTime.Today.Day.ToString().PadLeft(2, '0')) + "_" + DateTime.Now.ToLongTimeString().Replace(":", "")) + annexInfo.OriginalName;
                annexInfo.AnnexName = fileName;
                annexInfo.FilePath  = settingsInfo.FilePath + annexInfo.AnnexType.ToString() + "/" + fileName.Substring(0, 6) + "/";
                annexInfo.FileSize  = postedFile.ContentLength;
                string str2 = "";
                str2 = "insert into XPM_Basic_AnnexList(AnnexCode,ModuleID,RecordCode,AnnexType,FileCode,AnnexName,OriginalName,FilePath,FileSize,AddDate,State,HumanCode,Remark)";
                string str3 = str2;
                object obj2 = str3 + " values('" + annexInfo.AnnexCode.ToString() + "'," + annexInfo.ModuleID.ToString() + ",'" + annexInfo.RecordCode.ToString() + "'," + annexInfo.AnnexType.ToString() + ",'" + annexInfo.FileCode + "',";
                string str4 = string.Concat(new object[] { obj2, "'", annexInfo.AnnexName, "','", annexInfo.OriginalName, "','", annexInfo.FilePath, "',", annexInfo.FileSize, ",'", annexInfo.AddDate.ToShortDateString(), "'," });
                if (publicDbOpClass.ExecSqlString(str4 + "-1,'" + annexInfo.HumanCode + "','" + annexInfo.Remark + "') ") != 1)
                {
                    return(-2);
                }
                if (upload.Upload(postedFile, fileName, true))
                {
                    return(publicDbOpClass.ExecSqlString("update XPM_Basic_AnnexList set State = 1 where AnnexCode = '" + annexInfo.AnnexCode.ToString() + "'"));
                }
            }
            return(-1);
        }
Exemple #4
0
        public int DelAnnex(AnnexInfo annexInfo)
        {
            FileUpload upload = new FileUpload();

            if (upload.Delete(annexInfo.FilePath + annexInfo.AnnexName))
            {
                return(publicDbOpClass.ExecSqlString("delete from XPM_Basic_AnnexList where AnnexCode = '" + annexInfo.AnnexCode.ToString() + "'"));
            }
            return(0);
        }
Exemple #5
0
        public AnnexInfo GetSingleAnnexInfo(Guid annexCode)
        {
            AnnexInfo info = new AnnexInfo();

            using (DataTable table = publicDbOpClass.DataTableQuary("select * from XPM_Basic_AnnexList where AnnexCode = '" + annexCode.ToString() + "'"))
            {
                if (table.Rows.Count == 1)
                {
                    return(this.GetAnnexInfoFromDataRow(table.Rows[0]));
                }
            }
            return(info);
        }
Exemple #6
0
 public int AddAnnex(HttpPostedFile postedFile, AnnexInfo annexInfo, AnnexModuleSettingsInfo settingsInfo)
 {
     if (this.AddAnnexs(postedFile, annexInfo, settingsInfo) == 1)
     {
         AnnexInfo singleAnnexInfo   = this.annexAction.GetSingleAnnexInfo(annexInfo.AnnexCode);
         string    thumbnailPath     = HttpContext.Current.Server.MapPath(singleAnnexInfo.FilePath);
         string    originalImagePath = thumbnailPath + singleAnnexInfo.AnnexName;
         string    thumbnailName     = Guid.NewGuid().ToString() + ".jpg";
         if (this.MakeToThumbnail(originalImagePath, thumbnailPath, thumbnailName, 80, 0x37, "HW") && this.SaveToDataBase(singleAnnexInfo.AnnexCode, singleAnnexInfo.FilePath, thumbnailName))
         {
             return(1);
         }
     }
     return(0);
 }
        public Task CreateAsync(AnnexInfo annexinfo, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (annexinfo == null)
            {
                throw new ArgumentNullException(nameof(annexinfo));
            }

            if (string.IsNullOrEmpty(annexinfo.ID))
            {
                annexinfo.ID = Guid.NewGuid().ToString();
            }

            Context.Add(annexinfo);
            return(Context.SaveChangesAsync(cancellationToken));
        }
Exemple #8
0
    private void btnAdd_Click(object sender, EventArgs e)
    {
        AnnexInfo annexInfo = new AnnexInfo();

        annexInfo.AnnexCode = Guid.NewGuid();
        annexInfo.ModuleID  = this._ModuleID;
        annexInfo.AnnexType = this._AnnexType;
        annexInfo.FileCode  = this.txtFileCode.Text;
        annexInfo.HumanCode = this.Session["yhdm"].ToString();
        annexInfo.Remark    = this.txtRemark.Text;
        AnnexModuleSettingsInfo settingsInfo = new AnnexModuleSettingsInfo();

        settingsInfo = AnnexAssistAction.GetAnnexModelInfo(this._ModuleID);
        if (this._AnnexAction.AddAnnex(this.fileAnnex.PostedFile, annexInfo, settingsInfo) != 1)
        {
            this.js.Text = "alert('上传文件失败!');";
            return;
        }
        this.js.Text = "window.returnValue=true;alert('上传文件成功!');window.close();";
    }