Example #1
0
        public ActionMessage DeleteDocuments(string ids)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    List <DocumentInfo> infos = DocumentDataLayer.GetInstance().GetDocumentsByIds(connection, ids);
                    if (infos.Count > 0)
                    {
                        foreach (DocumentInfo document in infos)
                        {
                            FilesHelpers.DeleteFile(document.TableName, document.PreferId, document.FileName);
                        }
                    }
                    DocumentDataLayer.GetInstance().DeleteDocuments(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
Example #2
0
        public ActionMessage DeleteDocument(int id)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    DocumentInfo info = DocumentDataLayer.GetInstance().GetDocumentById(connection, id);
                    if (info.PreferId != null && info.TableName != "")
                    {
                        FilesHelpers.DeleteFile(info.TableName, info.PreferId, info.FileName);
                    }
                    DocumentDataLayer.GetInstance().DeleteDocument(connection, id);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }