Пример #1
0
        public string MoveTempPicture(ref string errMessage, TempPicture oTempPicture)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            try
            {
                string ret          = null;
                string destFilePath = SystemParametersBusiness.Instance.ListSystemParameter["CapPicPath"] + @"\" + oTempPicture.CameraID +
                                      @"\" + oTempPicture.Datetime.ToString(@"yyyy\\MM\\dd\\HH\\") + oTempPicture.CameraID + oTempPicture.Datetime.ToString(@"_yyyy_MM_dd_HH_mm_ss_fff") + ".jpg";
                if (File.Exists(oTempPicture.FilePath))
                {
                    string path = Path.GetDirectoryName(destFilePath);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    File.Move(oTempPicture.FilePath, destFilePath);
                    TempPictureDataAccess.DeleteTempPicture(db, oTempPicture.PictureID);
                    ret = destFilePath;
                }
                return(ret);
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(null);
            }
        }
Пример #2
0
        public int DeleteTempPictureFromDb(ref string errMessage, int pictureId)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            try
            {
                return(TempPictureDataAccess.DeleteTempPicture(db, pictureId));
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(-1);
            }
        }
Пример #3
0
        public int DeleteTempPictureFromDbAndDisk(ref string errMessage, TempPicture oTempPicture)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            try
            {
                if (File.Exists(oTempPicture.FilePath))
                {
                    File.Delete(oTempPicture.FilePath);
                }
                return(TempPictureDataAccess.DeleteTempPicture(db, oTempPicture.PictureID));
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(-1);
            }
        }