public int AddpHoteInfo(HttpPostedFile postedFile, IntendancePhotoList annexInfo)
        {
            FileUpload upload = new FileUpload {
                FileSize   = 0x800000,
                UploadPath = "/UploadFiles/Image/PhotosCheckIn/"
            };

            if (upload.UploadValidator(postedFile))
            {
                annexInfo.PhotoName = 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.PhotoName;
                annexInfo.PhotoName = fileName;
                annexInfo.PhotoPath = "/UploadFiles/Image/PhotosCheckIn/" + fileName.Substring(0, 6) + "/";
                string str2 = "";
                str2 = "insert into OPM_EPCM_IntendancePhotoList(noteId,InfoGuid,PhotoNumber,PhotoExplain,PhotoPath,PhotoName,OPyhdm,PhotoType)";
                object obj2 = str2;
                if (publicDbOpClass.ExecSqlString(string.Concat(new object[] {
                    obj2, " values('", annexInfo.NoteId, "','", annexInfo.InfoGuid, "','", annexInfo.PhotoNumber.ToString(), "','", annexInfo.PhotoExplain.ToString(), "','", annexInfo.PhotoPath.ToString(), "','", annexInfo.PhotoName.ToString(), "','", annexInfo.UserCode.ToString(), "','",
                    annexInfo.PhotoType, "')"
                })) != 1)
                {
                    return(-2);
                }
                if (upload.Upload(postedFile, fileName, true))
                {
                    return(1);
                }
            }
            return(-1);
        }
Example #2
0
    private static string getJosn(string annexCodes)
    {
        List <IntendancePhotoList> list = new List <IntendancePhotoList>();
        string        sqlString         = "SELECT a.*,b.* FROM XPM_Basic_Thumbnai as a inner join OPM_EPCM_IntendancePhotoList as b on a.ThumbnaiCode=b.NoteID where ThumbnaiCode in(" + annexCodes + ")";
        DataTable     dataTable         = publicDbOpClass.DataTableQuary(sqlString);
        StringBuilder stringBuilder     = new StringBuilder();

        foreach (DataRow dataRow in dataTable.Rows)
        {
            IntendancePhotoList intendancePhotoList = new IntendancePhotoList();
            intendancePhotoList.ThumbnaImgPath = ((dataRow["ThumbnaImgPath"] as string) ?? string.Empty);
            intendancePhotoList.ThumbnaName    = ((dataRow["ThumbnaName"] as string) ?? string.Empty);
            intendancePhotoList.PhotoNumber    = ((dataRow["PhotoNumber"] as string) ?? string.Empty);
            intendancePhotoList.PhotoExplain   = ((dataRow["PhotoExplain"] as string) ?? string.Empty);
            intendancePhotoList.InfoGuid       = new Guid(dataRow["infoguid"].ToString());
            intendancePhotoList.PhotoType      = Convert.ToInt32(dataRow["photoType"]);
            if (dataRow["NoteId"] != DBNull.Value)
            {
                intendancePhotoList.NoteId = new Guid(dataRow["NoteId"].ToString());
            }
            list.Add(intendancePhotoList);
            stringBuilder.Remove(0, stringBuilder.Length);
        }
        JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

        return(javaScriptSerializer.Serialize(list));
    }
        public int DelAnnex(IntendancePhotoList annexInfo)
        {
            FileUpload upload = new FileUpload();

            if (upload.Delete(annexInfo.PhotoPath + annexInfo.PhotoName))
            {
                return(publicDbOpClass.ExecSqlString("delete from OPM_EPCM_IntendancePhotoList where noteId = '" + annexInfo.NoteId.ToString() + "'"));
            }
            return(0);
        }
        public IntendancePhotoList GetSinglePhotoInfo(Guid NoteID)
        {
            IntendancePhotoList list = new IntendancePhotoList();

            using (DataTable table = publicDbOpClass.DataTableQuary("select * from OPM_EPCM_IntendancePhotoList where NoteID = '" + NoteID + "'"))
            {
                if (table.Rows.Count == 1)
                {
                    return(this.GetPhotosInfoFromDataRow(table.Rows[0]));
                }
            }
            return(list);
        }
Example #5
0
 public int AddIntendancePhotoListAction(HttpPostedFile postedFile, IntendancePhotoList annexInfo)
 {
     if (this.intendancePhotoListAction.AddpHoteInfo(postedFile, annexInfo) == 1)
     {
         IntendancePhotoList singlePhotoInfo = this.intendancePhotoListAction.GetSinglePhotoInfo(annexInfo.NoteId);
         string thumbnailPath     = HttpContext.Current.Server.MapPath(singlePhotoInfo.PhotoPath);
         string originalImagePath = thumbnailPath + singlePhotoInfo.PhotoName;
         string thumbnailName     = Guid.NewGuid().ToString() + ".jpg";
         if (this.MakeToThumbnail(originalImagePath, thumbnailPath, thumbnailName, 80, 0x37, "HW") && this.SavePhotoToDataBase(singlePhotoInfo.NoteId, singlePhotoInfo.PhotoPath, thumbnailName))
         {
             return(1);
         }
     }
     return(0);
 }
Example #6
0
        private bool SavePhotoToDataBase(Guid annexCode, string thumbnailPath, string thumbnaName)
        {
            IntendancePhotoList singlePhotoInfo = this.intendancePhotoListAction.GetSinglePhotoInfo(annexCode);
            Thumbnai            thumbnai        = new Thumbnai {
                ThumbnaiCode   = new Guid(annexCode.ToString()),
                ShowContent    = DateTime.Now.ToString("yyyyMMdd"),
                ThumbnaImgPath = thumbnailPath + "thumbnail/",
                ThumbnaName    = thumbnaName,
                AddDate        = DateTime.Now,
                Remark         = singlePhotoInfo.PhotoExplain,
                ImgPath        = singlePhotoInfo.PhotoPath + singlePhotoInfo.PhotoName
            };

            return(this.AddThumbnai(thumbnai));
        }
Example #7
0
    private static string getJosn(string annexCodes, int type)
    {
        List <IntendancePhotoList> list = new List <IntendancePhotoList>();
        string sqlString = string.Concat(new object[]
        {
            "SELECT a.*,b.* FROM OPM_EPCM_IntendanceInfo as a inner join OPM_EPCM_IntendancePhotoList as b on a.NoteID=b.InfoGuid where b.noteId in(",
            annexCodes,
            ") and b.photoType=",
            type
        });
        DataTable dataTable = publicDbOpClass.DataTableQuary(sqlString);

        if (dataTable.Rows.Count <= 0)
        {
            string sqlString2 = string.Concat(new object[]
            {
                "select * from OPM_EPCM_IntendancePhotoList where noteId in(",
                annexCodes,
                ") and photoType=",
                type
            });
            dataTable = publicDbOpClass.DataTableQuary(sqlString2);
            dataTable.Columns.Add("QuestionExplain");
        }
        StringBuilder stringBuilder = new StringBuilder();

        foreach (DataRow dataRow in dataTable.Rows)
        {
            IntendancePhotoList intendancePhotoList = new IntendancePhotoList();
            intendancePhotoList.PhotoNumber  = ((dataRow["PhotoNumber"] as string) ?? string.Empty);
            intendancePhotoList.PhotoPath    = ((dataRow["PhotoPath"] as string) ?? string.Empty);
            intendancePhotoList.PhotoName    = ((dataRow["PhotoName"] as string) ?? string.Empty);
            intendancePhotoList.PhotoExplain = ((dataRow["PhotoExplain"] as string) ?? string.Empty);
            if (dataRow["NoteId"] != DBNull.Value)
            {
                intendancePhotoList.NoteId = new Guid(dataRow["NoteId"].ToString());
            }
            intendancePhotoList.ThumbnaName = ((dataRow["QuestionExplain"] as string) ?? string.Empty);
            list.Add(intendancePhotoList);
            stringBuilder.Remove(0, stringBuilder.Length);
        }
        if (list.Count > 0)
        {
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
            return(javaScriptSerializer.Serialize(list));
        }
        return("");
    }
Example #8
0
    private void btnAdd_Click(object sender, EventArgs e)
    {
        IntendancePhotoList intendancePhotoList = new IntendancePhotoList();

        intendancePhotoList.NoteId       = Guid.NewGuid();
        intendancePhotoList.InfoGuid     = this.IntendanceGuid;
        intendancePhotoList.PhotoNumber  = this.txtFileCode.Text;
        intendancePhotoList.PhotoExplain = this.txtRemark.Text;
        intendancePhotoList.UserCode     = base.UserCode;
        intendancePhotoList.PhotoType    = this.PhotoType;
        MakeThumbnail makeThumbnail = new MakeThumbnail();

        if (makeThumbnail.AddIntendancePhotoListAction(this.fileAnnex.PostedFile, intendancePhotoList) != 1)
        {
            this.js.Text = "alert('上传文件失败!');";
            return;
        }
        this.js.Text = "window.returnValue=true;alert('上传文件成功!');window.close();";
    }
Example #9
0
    public static string DelPhotosItem(string noteId)
    {
        IntendancePhotoListAction intendancePhotoListAction = new IntendancePhotoListAction();
        IntendancePhotoList       singlePhotoInfo           = intendancePhotoListAction.GetSinglePhotoInfo(new Guid(noteId));
        string result = "";

        if (singlePhotoInfo != null && intendancePhotoListAction.DelAnnex(singlePhotoInfo) > 0)
        {
            MakeThumbnail makeThumbnail = new MakeThumbnail();
            if (makeThumbnail.DelThumbnai(singlePhotoInfo.NoteId.ToString()))
            {
                result = "1";
            }
            else
            {
                result = "删除失败";
            }
        }
        return(result);
    }