Example #1
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);
        }
Example #2
0
        /// <summary>
        /// Metoda pentru inserarea Documentului scanat curent
        /// </summary>
        /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns>
        public response Insert()
        {
            //try { if (this.DATA_INCARCARE == new DateTime() || this.DATA_INCARCARE == null) this.DATA_INCARCARE = GetFileCreationDate(); }
            try { if (this.DATA_INCARCARE == new DateTime() || this.DATA_INCARCARE == null)
                  {
                      this.DATA_INCARCARE = DateTime.Now;
                  }
            }
            catch { }
            try
            {
                if (this.FILE_CONTENT == null && this.CALE_FISIER != null)
                {
                    //this.FILE_CONTENT = FileManager.GetFileContentFromFile(this.CALE_FISIER);
                    this.FILE_CONTENT      = FileManager.UploadFile(this.CALE_FISIER);
                    this.SMALL_ICON        = (byte[])ThumbNails.GenerateByteThumbNail(this.CALE_FISIER, CommonFunctions.GetThumbNailSizes(ThumbNailType.Small)).Result;
                    this.MEDIUM_ICON       = (byte[])ThumbNails.GenerateByteThumbNail(this.CALE_FISIER, CommonFunctions.GetThumbNailSizes(ThumbNailType.Custom)).Result;
                    this.DIMENSIUNE_FISIER = this.FILE_CONTENT.Length;
                    this.EXTENSIE_FISIER   = this.CALE_FISIER.Substring(this.CALE_FISIER.LastIndexOf('.'));
                    //File.Delete(this.CALE_FISIER); // nu mai stergem, ca ne trebuie si in File Storage !
                }
                if (this.FILE_CONTENT != null && this.CALE_FISIER != null)
                {
                    this.SMALL_ICON  = (byte[])ThumbNails.GenerateByteThumbNail(this.CALE_FISIER, CommonFunctions.GetThumbNailSizes(ThumbNailType.Small)).Result;
                    this.MEDIUM_ICON = (byte[])ThumbNails.GenerateByteThumbNail(this.CALE_FISIER, CommonFunctions.GetThumbNailSizes(ThumbNailType.Custom)).Result;
                }
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.Message, null, null, new List <Error>()
                {
                    new Error(exp)
                })); }
            response toReturn = Validare();

            if (!toReturn.Status)
            {
                return(toReturn);
            }
            PropertyInfo[] props       = this.GetType().GetProperties();
            ArrayList      _parameters = new ArrayList();
            var            col         = CommonFunctions.table_columns(authenticatedUserId, connectionString, "documente_scanate");

            foreach (PropertyInfo prop in props)
            {
                if (col != null && col.ToUpper().IndexOf(prop.Name.ToUpper()) > -1) // ca sa includem in Array-ul de parametri doar coloanele tabelei, nu si campurile externe si/sau alte proprietati
                {
                    string propName  = prop.Name;
                    string propType  = prop.PropertyType.ToString();
                    object propValue = prop.GetValue(this, null);
                    propValue = propValue == null ? DBNull.Value : propValue;
                    if (propType != null)
                    {
                        if (propName.ToUpper() != "ID") // il vom folosi doar la Edit!
                        {
                            _parameters.Add(new MySqlParameter(String.Format("_{0}", propName.ToUpper()), propValue));
                        }
                    }
                }
            }
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "DOCUMENTE_SCANATEsp_insert", _parameters.ToArray());

            toReturn = da.ExecuteInsertQuery();
            if (toReturn.Status)
            {
                this.ID = toReturn.InsertedId;

                /*
                 * 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 nou", 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);
        }