public override IQuery GetHsql(Object data)
        {
            StringBuilder    sql = new StringBuilder("select a from NodeDocumentType a    where  ");
            NodeDocumentType nodedocumenttype = (NodeDocumentType)data;

            if (nodedocumenttype != null)
            {
                Parms = new List <Object[]>();
                if (nodedocumenttype.RowID != 0)
                {
                    sql.Append(" a.RowID = :id     and   ");
                    Parms.Add(new Object[] { "id", nodedocumenttype.RowID });
                }

                if (nodedocumenttype.Node != null && nodedocumenttype.Node.NodeID != 0)
                {
                    sql.Append(" a.Node.NodeID = :id1     and   ");
                    Parms.Add(new Object[] { "id1", nodedocumenttype.Node.NodeID });
                }

                if (nodedocumenttype.DocType != null && nodedocumenttype.DocType.DocTypeID != 0)
                {
                    sql.Append(" a.DocType.DocTypeID= :id2     and   ");
                    Parms.Add(new Object[] { "id2", nodedocumenttype.DocType.DocTypeID });
                }
            }

            sql = new StringBuilder(sql.ToString());
            sql.Append("1=1 order by a.RowID asc ");
            IQuery query = Factory.Session.CreateQuery(sql.ToString());

            SetParameters(query);
            return(query);
        }
예제 #2
0
        private string[] SaveDownloadedDocuments(NodeDocumentType[] documents,
                                                 List <string> documentIDs,
                                                 List <string> documentNames,
                                                 string downloadDirectory,
                                                 bool overwriteExistingFiles)
        {
            if ((documents != null) && (documents.Length > 0))
            {
                string downloadDir = downloadDirectory ?? Path.Combine(_tempPath, Guid.NewGuid().ToString());

                Directory.CreateDirectory(downloadDir);

                string[] newDocPaths = new string[documents.Length];
                for (int i = 0; i < documents.Length; ++i)
                {
                    NodeDocumentType newDoc = documents[i];
                    string           docName;
                    if (!string.IsNullOrEmpty(newDoc.documentName))
                    {
                        docName = newDoc.documentName;
                    }
                    else if (!string.IsNullOrEmpty(newDoc.documentId))
                    {
                        docName = newDoc.documentId;
                    }
                    else
                    {
                        docName = Guid.NewGuid().ToString();
                    }
                    string newDocPath = Path.Combine(downloadDir, docName);
                    if (File.Exists(newDocPath) && !overwriteExistingFiles)
                    {
                        newDocPath = Path.Combine(downloadDir, Guid.NewGuid().ToString());
                    }
                    File.WriteAllBytes(newDocPath, newDoc.documentContent.Value);
                    newDocPaths[i] = newDocPath;
                    if (documentIDs != null)
                    {
                        documentIDs.Add(newDoc.documentId);
                    }
                    if (documentNames != null)
                    {
                        documentNames.Add(newDoc.documentName);
                    }
                }
                return(newDocPaths);
            }
            else
            {
                return(new string[0]);
            }
        }
        public IList <NodeDocumentType> Select(NodeDocumentType data)
        {
            IList <NodeDocumentType> datos = new List <NodeDocumentType>();

            try {
                datos = GetHsql(data).List <NodeDocumentType>();
                if (!Factory.IsTransactional)
                {
                    Factory.Commit();
                }
            }
            catch (Exception e)
            {
                NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e));
            }

            return(datos);
        }
예제 #4
0
        private string[] Download(string flow, string transactionId, string[] documentIdsOrNames,
                                  bool areDocIds, List <string> documentIDs, List <string> documentNames,
                                  string downloadDirectory, bool overwriteExistingFiles)
        {
            Download download           = NewDownloadObject(flow, transactionId);
            bool     haveInputDocuments = (documentIdsOrNames != null) && (documentIdsOrNames.Length > 0);

            if (haveInputDocuments)
            {
                download.documents = new NodeDocumentType[documentIdsOrNames.Length];
                for (int i = 0; i < documentIdsOrNames.Length; ++i)
                {
                    NodeDocumentType newDoc = new NodeDocumentType();
                    if (areDocIds)
                    {
                        newDoc.documentId = documentIdsOrNames[i];
                    }
                    else
                    {
                        newDoc.documentName = documentIdsOrNames[i];
                    }
                    download.documents[i] = newDoc;
                }
            }
            else
            {
            }
            NodeDocumentType[] newDocuments = _requestor.Download(download);
            // TODO: Should an exception be thrown if newDocuments.Length != documentIdsOrNames.Length?
            if (areDocIds && haveInputDocuments)
            {
                if ((newDocuments == null) || (newDocuments.Length != documentIdsOrNames.Length))
                {
                    throw new ArgumentException("newDocuments.Length != documentIdsOrNames.Length");
                }
            }
            return(SaveDownloadedDocuments(newDocuments, documentIDs, documentNames, downloadDirectory,
                                           overwriteExistingFiles));
        }
예제 #5
0
 public void DeleteNodeDocumentType(NodeDocumentType data)
 {
     try {
     SetService();  SerClient.DeleteNodeDocumentType(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
예제 #6
0
 public NodeDocumentType SaveNodeDocumentType(NodeDocumentType data)
 {
     try {
     SetService();  return SerClient.SaveNodeDocumentType(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
예제 #7
0
        private NodeDocumentType[] LoadDocumentsToSubmit(IList <string> documentPaths, IList <EndpointDocument> documents)
        {
            if (CollectionUtils.IsNullOrEmpty(documentPaths) &&
                CollectionUtils.IsNullOrEmpty(documents))
            {
                throw new ArgumentException("Must have documents to submit.");
            }
            List <NodeDocumentType> docs = new List <NodeDocumentType>();

            if (!CollectionUtils.IsNullOrEmpty(documentPaths))
            {
                for (int i = 0; i < documentPaths.Count; ++i)
                {
                    NodeDocumentType doc     = new NodeDocumentType();
                    string           docPath = documentPaths[i];
                    doc.documentContent       = new AttachmentType();
                    doc.documentContent.Value = File.ReadAllBytes(docPath);
                    doc.documentName          = Path.GetFileName(docPath);
                    switch (Path.GetExtension(docPath).ToLower())
                    {
                    case ".zip":
                        doc.documentFormat = DocumentFormatType.ZIP;
                        doc.documentContent.contentType = "application/zip";
                        break;

                    case ".xml":
                        doc.documentFormat = DocumentFormatType.XML;
                        doc.documentContent.contentType = "text/xml";
                        break;

                    case ".txt":
                        doc.documentFormat = DocumentFormatType.FLAT;
                        doc.documentContent.contentType = "text/plain";
                        break;

                    case ".bin":
                        doc.documentFormat = DocumentFormatType.BIN;
                        doc.documentContent.contentType = "application/octet-stream";
                        break;

                    default:
                        doc.documentFormat = DocumentFormatType.OTHER;
                        doc.documentContent.contentType = "application/x";
                        break;
                    }
                    docs.Add(doc);
                }
            }
            if (!CollectionUtils.IsNullOrEmpty(documents))
            {
                for (int i = 0; i < documents.Count; ++i)
                {
                    NodeDocumentType doc = new NodeDocumentType();
                    EndpointDocument endpointDocument = documents[i];
                    doc.documentContent = new AttachmentType();
                    if (endpointDocument.ContentBytes != null)
                    {
                        doc.documentContent.Value = endpointDocument.ContentBytes;
                    }
                    else if (endpointDocument.ContentFilePath != null)
                    {
                        doc.documentContent.Value = File.ReadAllBytes(endpointDocument.ContentFilePath);
                    }
                    else
                    {
                        throw new ArgumentException("endpointDocument does not have content");
                    }
                    doc.documentName = endpointDocument.DocName;
                    switch (endpointDocument.DocType)
                    {
                    case CommonContentType.ZIP:
                        doc.documentFormat = DocumentFormatType.ZIP;
                        doc.documentContent.contentType = "application/zip";
                        break;

                    case CommonContentType.XML:
                        doc.documentFormat = DocumentFormatType.XML;
                        doc.documentContent.contentType = "text/xml";
                        break;

                    case CommonContentType.Flat:
                        doc.documentFormat = DocumentFormatType.FLAT;
                        doc.documentContent.contentType = "text/plain";
                        break;

                    case CommonContentType.Bin:
                        doc.documentFormat = DocumentFormatType.BIN;
                        doc.documentContent.contentType = "application/octet-stream";
                        break;

                    default:
                        doc.documentFormat = DocumentFormatType.OTHER;
                        doc.documentContent.contentType = "application/x";
                        break;
                    }
                    docs.Add(doc);
                }
            }
            return(docs.ToArray());
        }
 public NodeDocumentType SelectById(NodeDocumentType data)
 {
     return((NodeDocumentType)base.SelectById(data));
 }
 public Boolean Delete(NodeDocumentType data)
 {
     return(base.Delete(data));
 }
 public Boolean Update(NodeDocumentType data)
 {
     return(base.Update(data));
 }
 public NodeDocumentType Save(NodeDocumentType data)
 {
     return((NodeDocumentType)base.Save(data));
 }