public response Delete(int _id)
        {
            //DocumentScanat item = JsonConvert.DeserializeObject<DocumentScanat>(Find(_id).Message);
            DocumentScanat item = (DocumentScanat)(Find(_id).Result);

            return(item.Delete());
        }
Beispiel #2
0
 public static void DeleteThumbNail(Models.DocumentScanat d)
 {
     try {
         if (File.Exists(Path.Combine(AppContext.BaseDirectory, "scans", d.DENUMIRE_FISIER.Replace(d.EXTENSIE_FISIER, "_Custom.jpg"))))
         {
             File.Delete(Path.Combine(AppContext.BaseDirectory, "scans", d.DENUMIRE_FISIER.Replace(d.EXTENSIE_FISIER, "_Custom.jpg")));
         }
     } catch { }
     try
     {
         if (File.Exists(Path.Combine(AppContext.BaseDirectory, "scans", d.DENUMIRE_FISIER.Replace(d.EXTENSIE_FISIER, "_Medium.jpg"))))
         {
             File.Delete(Path.Combine(AppContext.BaseDirectory, "scans", d.DENUMIRE_FISIER.Replace(d.EXTENSIE_FISIER, "_Medium.jpg")));
         }
     }
     catch { }
     try
     {
         if (File.Exists(Path.Combine(AppContext.BaseDirectory, "scans", d.DENUMIRE_FISIER.Replace(d.EXTENSIE_FISIER, "_Small.jpg"))))
         {
             File.Delete(Path.Combine(AppContext.BaseDirectory, "scans", d.DENUMIRE_FISIER.Replace(d.EXTENSIE_FISIER, "_Small.jpg")));
         }
     }
     catch { }
 }
 public response GetAll()
 {
     try
     {
         DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "DOCUMENTE_SCANATEsp_select", new object[] {
             new MySqlParameter("_SORT", null),
             new MySqlParameter("_ORDER", null),
             new MySqlParameter("_FILTER", null),
             new MySqlParameter("_LIMIT", null)
         });
         ArrayList       aList = new ArrayList();
         MySqlDataReader r     = da.ExecuteSelectQuery();
         while (r.Read())
         {
             DocumentScanat a = new DocumentScanat(authenticatedUserId, connectionString, (IDataRecord)r);
             aList.Add(a);
         }
         r.Close(); r.Dispose();
         DocumentScanat[] toReturn = new DocumentScanat[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (DocumentScanat)aList[i];
         }
         return(new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
         {
             new Error(exp)
         })); }
 }
        public response RestoreOrphanDocument(int _id)
        {
            DocumentScanat item     = (DocumentScanat)(Find(_id).Result);
            bool           toReturn = FileManager.RestoreFileFromDb(item);

            return(new response(toReturn, "", toReturn, null, null));
        }
        public response Update(string fieldValueCollection)
        {
            DocumentScanat tmpItem = JsonConvert.DeserializeObject <DocumentScanat>(fieldValueCollection);

            //return JsonConvert.DeserializeObject<DocumentScanat>(Find(Convert.ToInt32(tmpItem.ID)).Message).Update(fieldValueCollection);
            return(((DocumentScanat)(Find(Convert.ToInt32(tmpItem.ID)).Result)).Update(fieldValueCollection));
        }
        public response Update(int id, string fieldValueCollection)
        {
            //DocumentScanat item = JsonConvert.DeserializeObject<DocumentScanat>(Find(id).Message);
            DocumentScanat item = (DocumentScanat)(Find(id).Result);

            return(item.Update(fieldValueCollection));
        }
        public response Update(int id, string fieldValueCollection, object file)
        {
            DocumentScanat item = JsonConvert.DeserializeObject <DocumentScanat>(Find(id).Message);

            byte[] f = GetBytesFromParameter(file);
            item.FILE_CONTENT      = f;
            item.DIMENSIUNE_FISIER = item.FILE_CONTENT.Length;
            return(item.Update(fieldValueCollection));
        }
        public response Update(string fieldValueCollection, object file)
        {
            DocumentScanat tmpItem = JsonConvert.DeserializeObject <DocumentScanat>(fieldValueCollection);
            //DocumentScanat item = JsonConvert.DeserializeObject<DocumentScanat>(Find(Convert.ToInt32(tmpItem.ID)).Message);
            DocumentScanat item = (DocumentScanat)(Find(Convert.ToInt32(tmpItem.ID)).Result);

            byte[] f = GetBytesFromParameter(file);
            item.FILE_CONTENT      = f;
            item.DIMENSIUNE_FISIER = item.FILE_CONTENT.Length;
            return(item.Update(fieldValueCollection));
        }
 public response Find(int _id)
 {
     try
     {
         DocumentScanat item = new DocumentScanat(authenticatedUserId, connectionString, _id);
         return(new response(true, JsonConvert.SerializeObject(item, CommonFunctions.JsonSerializerSettings), item, null, null));;
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
         {
             new Error(exp)
         })); }
 }
Beispiel #10
0
 public static bool RestoreFileFromDb(Models.DocumentScanat ds)
 {
     try
     {
         FileStream fs = new FileStream(Path.Combine(CommonFunctions.GetScansFolder(), ds.CALE_FISIER), FileMode.Create, FileAccess.ReadWrite);
         fs.Write(ds.FILE_CONTENT, 0, ds.FILE_CONTENT.Length);
         fs.Flush();
         fs.Dispose();
         return(true);
         // to do - restore thumbnails
     }catch (Exception exp) { LogWriter.Log(exp); return(false); }
 }
        public response GetFiltered(string _sort, string _order, string _filter, string _limit)
        {
            try
            {
                try
                {
                    string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(DocumentScanat), _filter, authenticatedUserId, connectionString);
                    _filter = newFilter == null ? _filter : newFilter;
                }
                catch { }
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "DOCUMENTE_SCANATEsp_select", new object[] {
                    new MySqlParameter("_SORT", _sort),
                    new MySqlParameter("_ORDER", _order),
                    new MySqlParameter("_FILTER", _filter),
                    new MySqlParameter("_LIMIT", _limit)
                });

                /*
                 * ArrayList aList = new ArrayList();
                 * MySqlDataReader r = da.ExecuteSelectQuery();
                 * while (r.Read())
                 * {
                 *  DocumentScanat a = new DocumentScanat(authenticatedUserId, connectionString, (IDataRecord)r);
                 *  aList.Add(a);
                 * }
                 * r.Close(); r.Dispose(); da.CloseConnection();
                 * DocumentScanat[] toReturn = new DocumentScanat[aList.Count];
                 * for (int i = 0; i < aList.Count; i++)
                 *  toReturn[i] = (DocumentScanat)aList[i];
                 * return new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null);
                 */
                List <DocumentScanat> aList = new List <DocumentScanat>();
                MySqlDataReader       r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    DocumentScanat a = new DocumentScanat(authenticatedUserId, connectionString, (IDataRecord)r);
                    aList.Add(a);
                }
                r.Close(); r.Dispose(); da.CloseConnection();
                return(new response(true, JsonConvert.SerializeObject(aList.ToArray(), CommonFunctions.JsonSerializerSettings), aList.ToArray(), null, null));
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
                {
                    new Error(exp)
                })); }
        }
Beispiel #12
0
        public static byte[] GenerateImgThumbNail(Models.DocumentScanat _documentScanat, ThumbNailSizes s)
        {
            MemoryStream ms       = new MemoryStream(_documentScanat.FILE_CONTENT);
            Image        image    = Image.FromStream(ms);
            string       tmp_file = "tmp_" + DateTime.Now.ToString();
            response     r        = SaveThumbNail(ThumbNailType.Custom.ToString(), Path.Combine(AppContext.BaseDirectory, "scans"), tmp_file, image, s.Width, s.Height);
            FileStream   fs       = new FileStream(Path.Combine(AppContext.BaseDirectory, "scans", r.Message), FileMode.Open, FileAccess.Read);

            byte[] b = new byte[fs.Length];
            fs.Read(b, 0, (int)fs.Length);
            fs.Dispose();
            try
            {
                File.Delete(Path.Combine(AppContext.BaseDirectory, "scans", tmp_file));
            }
            catch { }
            return(b);
        }
Beispiel #13
0
        /// <summary>
        /// Metoda pentru stergerea Documentului scanat curent
        /// </summary>
        /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns>
        public response Delete()
        {
            DocumentScanat tmp = new DocumentScanat(authenticatedUserId, connectionString, Convert.ToInt32(this.ID));

            response  toReturn    = new response(false, "", null, null, new List <Error>());;
            ArrayList _parameters = new ArrayList();

            _parameters.Add(new MySqlParameter("_ID", this.ID));
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "DOCUMENTE_SCANATEsp_soft_delete", _parameters.ToArray());

            toReturn = da.ExecuteDeleteQuery();

            /*
             * if (toReturn.Status && _deleteFile)
             *  FileManager.DeleteFile(this.CALE_FISIER, this.DENUMIRE_FISIER, this.EXTENSIE_FISIER);
             */
            if (toReturn.Status)
            {
                try
                {
                    ThumbNails.DeleteThumbNail(tmp);
                    tmp = null;
                }
                catch { }
            }
            if (toReturn.Status)
            {
                /*
                 * try
                 * {
                 *  if (System.Web.HttpContext.Current.Request.Params["SEND_MESSAGE"] != null && Convert.ToBoolean(System.Web.HttpContext.Current.Request.Params["SEND_MESSAGE"]))
                 *      Mesaje.GenerateAndSendMessage(this.ID, DateTime.Now, "Document sters", Convert.ToInt32(System.Web.HttpContext.Current.Session["AUTHENTICATED_ID"]), (int)Mesaje.Importanta.Low);
                 * }
                 * catch { }
                 */
                try
                {
                    Dosar d = new Dosar(authenticatedUserId, connectionString, this.ID_DOSAR);
                    d.UpdateCounterDocumente(-1);
                }
                catch (Exception exp) { LogWriter.Log(exp); }
            }
            return(toReturn);
        }
        public response Update(int id, string fieldValueCollection, object file, ThumbNailSizes[] tSizes)
        {
            //DocumentScanat item = JsonConvert.DeserializeObject<DocumentScanat>(Find(id).Message);
            DocumentScanat item = (DocumentScanat)(Find(id).Result);

            byte[] f = GetBytesFromParameter(file);
            item.FILE_CONTENT      = f;
            item.DIMENSIUNE_FISIER = item.FILE_CONTENT.Length;
            response r = item.Update(fieldValueCollection);

            if (r.Status)
            {
                r = item.Update(tSizes);
                return(r);
            }
            else
            {
                return(r);
            }
        }
        public response RestoreOrphanDocument(int _id)
        {
            DocumentScanat item = (DocumentScanat)(Find(_id).Result);

            return(FileManager.RestoreFileFromDb(item));
        }
 public response GenerateThumbNails(DocumentScanat item, ThumbNailSizes[] tSizes)
 {
     return(item.GenerateImgThumbNails(tSizes));
 }
 public response GetChildren(DocumentScanat item, string tableName, int childrenId)
 {
     return(item.GetChildren(tableName, childrenId));
 }
 public response GetChildrens(DocumentScanat item, string tableName)
 {
     return(item.GetChildrens(tableName));
 }
 public response Update(DocumentScanat item)
 {
     return(item.Update());
 }
 public response Insert(DocumentScanat item)
 {
     return(item.Insert());
 }
 public response Insert(DocumentScanat item, ThumbNailSizes[] tSizes)
 {
     return(item.Insert(tSizes));
 }
 public response Insert(DocumentScanat item, object file)
 {
     item.FILE_CONTENT      = GetBytesFromParameter(file);
     item.DIMENSIUNE_FISIER = item.FILE_CONTENT.Length;
     return(item.Insert());
 }
 public response Update(DocumentScanat item, object file, ThumbNailSizes[] tSizes)
 {
     item.FILE_CONTENT      = GetBytesFromParameter(file);
     item.DIMENSIUNE_FISIER = item.FILE_CONTENT.Length;
     return(item.Update(tSizes));
 }
 public response Update(DocumentScanat item, ThumbNailSizes[] tSizes)
 {
     return(item.Update(tSizes));
 }
Beispiel #25
0
 public static byte[] GenerateImgThumbNail(int _authenticatedUserId, string _connectionString, int _idDocumentScanat, ThumbNailSizes s)
 {
     Models.DocumentScanat d = (Models.DocumentScanat)(new Models.DocumenteScanateRepository(_authenticatedUserId, _connectionString).Find(_idDocumentScanat).Result);
     return(GenerateImgThumbNail(d, s));
 }
 public response Delete(DocumentScanat item)
 {
     return(item.Delete());
 }
Beispiel #27
0
 public static void CreateArhiveEntryWithSignature(Models.DocumentScanat ds)
 {
 }
 public response Insert(DocumentScanat item, object file, ThumbNailSizes[] tSizes)
 {
     item.FILE_CONTENT = GetBytesFromParameter(file);
     return(item.Insert(tSizes));
 }