Beispiel #1
0
        //
        // It returns a list of links for a given document set UID
        //
        public void List(DocumentSet documentSet)
        {
            documentSetDocumentList = new List <scDocoSetDocumentLink>();

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    "  [UID] " +
                    " ,[FKDocumentUID] " +
                    " ,[FKDocumentSetUID] " +
                    " ,[StartDate] " +
                    " ,[EndDate] " +
                    " ,[IsVoid] " +
                    "   FROM [DocumentSetDocument] " +
                    "   WHERE FKDocumentSetUID = {0} ",
                    documentSet.UID
                    );

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            // Ignore voids
                            if (Convert.ToChar(reader["IsVoid"]) == 'Y')
                            {
                                continue;
                            }

                            var docItem = new scDocoSetDocumentLink();

                            // Get document
                            //
                            docItem.document     = new Document();
                            docItem.document.UID = Convert.ToInt32(reader["FKDocumentUID"]);
                            docItem.document.Read();

                            // Get DocumentSet
                            //
                            docItem.documentSet     = new DocumentSet();
                            docItem.documentSet.UID = Convert.ToInt32(reader["FKDocumentSetUID"].ToString());

                            // Set DocumentSetDocument
                            docItem.DocumentSetDocument                  = new DocumentSetDocument();
                            docItem.DocumentSetDocument.UID              = Convert.ToInt32(reader["UID"].ToString());
                            docItem.DocumentSetDocument.FKDocumentUID    = Convert.ToInt32(reader["FKDocumentUID"].ToString());
                            docItem.DocumentSetDocument.FKDocumentSetUID = Convert.ToInt32(reader["FKDocumentSetUID"].ToString());
                            docItem.DocumentSetDocument.IsVoid           = Convert.ToChar(reader["IsVoid"].ToString());
                            docItem.DocumentSetDocument.StartDate        = Convert.ToDateTime(reader["StartDate"].ToString());

                            if (reader["EndDate"] == null)
                            {
                                docItem.DocumentSetDocument.EndDate = System.DateTime.MaxValue;
                            }
                            else
                            {
                                docItem.DocumentSetDocument.EndDate = Convert.ToDateTime(reader["EndDate"].ToString());
                            }
                            documentSetDocumentList.Add(docItem);
                        }
                    }
                }

                return;
            }
        }
Beispiel #2
0
        // -----------------------------------------------------
        //    Get Document Details
        // -----------------------------------------------------
        public static scDocoSetDocumentLink FindDocumentInSet(int documentSetUID, int documentUID)
        {
            //
            // EA SQL database
            //
            scDocoSetDocumentLink ret = new scDocoSetDocumentLink();

            ret.document            = new Document();
            ret.documentSet         = new DocumentSet();
            ret.DocumentSetDocument = new DocumentSetDocument();

            string commandString = "";

            commandString = string.Format(
                " SELECT " +
                "       [Document].[UID] DocumentUID" +
                "      ,[Document].[CUID] DocumentCUID " +
                "      ,[Document].[Name] DocumentName " +
                "      ,[Document].[SequenceNumber] DocumentSequenceNumber " +
                "      ,[Document].[IssueNumber] DocumentIssueNumber " +
                "      ,[Document].[Location] DocumentLocation " +
                "      ,[Document].[Comments] DocumentComments" +
                "      ,[Document].[UID] DocumentUID" +
                "      ,[Document].[FileName] DocumentFileName" +
                "      ,[Document].[SourceCode] DocumentSourceCode" +
                "      ,[Document].[FKClientUID] DocumentFKClientUID" +
                "      ,[Document].[ParentUID] DocumentParentUID" +
                "      ,[Document].[RecordType] DocumentRecordType" +
                "      ,[Document].[IsProjectPlan] DocumentIsProjectPlan" +
                "      ,[Document].[DocumentType] DocumentDocumentType" +
                "      ,[DocSetDoc].[UID] DocSetDocUID" +
                "      ,[DocSetDoc].[FKDocumentUID] DocSetDocFKDocumentUID" +
                "      ,[DocSetDoc].[FKDocumentSetUID] DocSetDocFKDocumentSetUID" +
                "      ,[DocSetDoc].[Location] DocSetDocLocation" +
                "      ,[DocSetDoc].[IsVoid] DocSetDocIsVoid" +
                "      ,[DocSetDoc].[StartDate] DocSetDocStartDate" +
                "      ,[DocSetDoc].[EndDate] DocSetDocEndDate" +
                "      ,[DocSetDoc].[FKParentDocumentUID] DocSetDocFKParentDocumentUID" +
                "      ,[DocSetDoc].[FKParentDocumentSetUID] DocSetDocFKParentDocumentSetUID" +
                "      ,[DocSet].[UID] SetUID" +
                "      ,[DocSet].[TemplateType] SetTemplateType" +
                "      ,[DocSet].[TemplateFolder] SetTemplateFolder" +
                "  FROM  [Document] Document" +
                "       ,[DocumentSetDocument] DocSetDoc " +
                "       ,[DocumentSet] DocSet " +
                " WHERE " +
                "        [Document].[UID] = [DocSetDoc].[FKDocumentUID] " +
                "    AND [DocSetDoc].[FKDocumentSetUID] = [DocSet].[UID] " +
                "    AND [Document].[UID] = {0} " +
                "    AND [DocSetDoc].[FKDocumentSetUID] = {1}",
                documentUID,
                documentSetUID);

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.Read())
                    {
                        try
                        {
                            // Document
                            //
                            Document.LoadDocumentFromReader(ret.document, "", reader);
                            //ret.document.UID = Convert.ToInt32(reader["DocumentUID"].ToString());
                            //ret.document.CUID = reader["DocumentCUID"].ToString();
                            //ret.document.Name = reader["DocumentName"].ToString();
                            //ret.document.SequenceNumber = Convert.ToInt32(reader["DocumentSequenceNumber"].ToString());
                            //ret.document.IssueNumber = Convert.ToInt32(reader["DocumentIssueNumber"].ToString());
                            //ret.document.Location = reader["DocumentLocation"].ToString();
                            //ret.document.Comments = reader["DocumentComments"].ToString();
                            //ret.document.FileName = reader["DocumentFileName"].ToString();
                            //ret.document.SourceCode = reader["DocumentSourceCode"].ToString();
                            //ret.document.FKClientUID = Convert.ToInt32(reader["DocumentFKClientUID"].ToString());
                            //ret.document.ParentUID = Convert.ToInt32(reader["DocumentParentUID"].ToString());
                            //ret.document.RecordType = reader["DocumentRecordType"].ToString();
                            //ret.document.IsProjectPlan = Convert.ToChar(reader["DocumentIsProjectPlan"]);
                            //ret.document.DocumentType = reader["DocumentDocumentType"].ToString();

                            // Document Set
                            //
                            ret.documentSet.UID            = Convert.ToInt32(reader["SetUID"].ToString());
                            ret.documentSet.TemplateType   = reader["SetTemplateType"].ToString();
                            ret.documentSet.TemplateFolder = reader["SetTemplateFolder"].ToString();
                            ret.documentSet.UIDNameDisplay = ret.documentSet.UID.ToString() +
                                                             "; " + ret.documentSet.TemplateType;

                            // DocumentSetDocument
                            //
                            ret.DocumentSetDocument.UID                    = Convert.ToInt32(reader["DocSetDocUID"].ToString());
                            ret.DocumentSetDocument.FKDocumentUID          = Convert.ToInt32(reader["DocSetDocFKDocumentUID"].ToString());
                            ret.DocumentSetDocument.FKDocumentSetUID       = Convert.ToInt32(reader["DocSetDocFKDocumentSetUID"].ToString());
                            ret.DocumentSetDocument.Location               = reader["DocSetDocLocation"].ToString();
                            ret.DocumentSetDocument.IsVoid                 = Convert.ToChar(reader["DocSetDocIsVoid"].ToString());
                            ret.DocumentSetDocument.StartDate              = Convert.ToDateTime(reader["DocSetDocStartDate"].ToString());
                            ret.DocumentSetDocument.EndDate                = Convert.ToDateTime(reader["DocSetDocEndDate"].ToString());
                            ret.DocumentSetDocument.FKParentDocumentUID    = Convert.ToInt32(reader["DocSetDocFKParentDocumentUID"].ToString());
                            ret.DocumentSetDocument.FKParentDocumentSetUID = Convert.ToInt32(reader["DocSetDocFKParentDocumentSetUID"].ToString());
                        }
                        catch
                        {
                        }
                    }
                }
            }
            return(ret);
        }