Exemple #1
0
        // ------------------------------------------------------------
        //      Cop\y document links from Document Set Document Link
        // ------------------------------------------------------------
        public void ReplicateDocSetDocLinkToClient(int ClientUID, int ClientSetUID, int DocumentSetUID)
        {
            // 1... GetClientDocument
            // List documents for a Client Set Document
            //
            var clientDocumentList = new ClientDocument();

            //clientDocumentList.List( ClientUID, ClientSetUID );
            RepClientDocument.List(clientDocumentList, ClientUID, ClientSetUID);

            // 2... foreach( clientDocument )
            // For each client document, retrieve the linked documents
            //
            foreach (var clientDocument in clientDocumentList.clientDocSetDocLink)
            {
                // 3...... GetDocumentChildren( currentClientDocument)
                // This part retrieves Document Links and not ClientDocument Links
                var children = DocumentSetDocumentLinkList.ListRelatedDocuments(DocumentSetUID, clientDocument.document.UID, type: "ALL");

                // 4...... foreach (GetDocumentChildren)
                foreach (var child in children.documentSetDocumentLinkList)
                {
                    // 5..... CreateClientDocumentLink(Client,ClientSet,DocumentParent,DocumentChild, Type)

                    ClientDocumentLink newLink = new ClientDocumentLink();
                    newLink.FKClientDocumentSetUID = ClientSetUID;
                    newLink.FKClientUID            = ClientUID;
                    newLink.FKParentDocumentUID    = clientDocument.document.UID;
                    newLink.FKChildDocumentUID     = child.FKChildDocumentUID;
                    newLink.LinkType = child.LinkType;
                    newLink.Add();
                }
            }
        }
Exemple #2
0
        // -----------------------------------------------------
        //    Save Links
        // -----------------------------------------------------
        public static void LinkDocuments(
            int clientUID,
            int clientDocumentSetUID,
            int parentDocumentUID, int childDocumentUID,
            string LinkType)
        {
            ClientDocumentLink findOne = new ClientDocumentLink();

            if (findOne.Read(
                    ParentID: parentDocumentUID,
                    ChildID: childDocumentUID,
                    LinkType: LinkType,
                    clientUID: clientUID,
                    clientDocumentSetUID: clientDocumentSetUID))
            {
                // Already exists
            }
            else
            {
                findOne.FKClientUID            = clientUID;
                findOne.FKClientDocumentSetUID = clientDocumentSetUID;
                findOne.LinkType            = LinkType;
                findOne.FKParentDocumentUID = parentDocumentUID;
                findOne.FKChildDocumentUID  = childDocumentUID;

                findOne.Add();
            }
        }
Exemple #3
0
        // ---------------------------------------------------------
        //      Copy document links to client document links
        // ---------------------------------------------------------
        public void ReplicateDocLinkToClientDeprecated(int ClientUID, int ClientSetUID)
        {
            // 1... GetClientDocument
            // List documents for a Client Set Document
            //
            var clientDocumentList = new ClientDocument();

            // clientDocumentList.List(ClientUID, ClientSetUID);

            RepClientDocument.List(clientDocumentList, ClientUID, ClientSetUID);

            // 2... foreach( clientDocument )
            // For each client document, retrieve the linked documents
            //
            foreach (var clientDocument in clientDocumentList.clientDocSetDocLink)
            {
                // 3...... GetDocumentChildren( currentClientDocument)
                // This part retrieves Document Links and not ClientDocument Links
                // that's why we need to get the equivalent ClientDocumentUID...
                var children = DocumentLinkList.ListRelatedDocuments(clientDocument.document.UID);

                // 4...... foreach (GetDocumentChildren)
                foreach (var child in children.documentLinkList)
                {
                    // 5..... CreateClientDocumentLink(Client,ClientSet,DocumentParent,DocumentChild, Type)

                    ClientDocumentLink newLink = new ClientDocumentLink();
                    // This is the client document UID
                    newLink.FKParentDocumentUID = clientDocument.clientDocument.UID;

                    // Get clientUID for child document
                    ClientDocument childDocument = new ClientDocument();
                    //childDocument.FKDocumentUID = child.UID;
                    childDocument.FKDocumentUID = child.documentTo.UID;

                    // childDocument.Find(child.documentTo.UID, clientDocument.clientDocumentSet.UID, 'N', ClientUID);

                    childDocument = RepClientDocument.Find(child.documentTo.UID, clientDocument.clientDocumentSet.UID, 'N', ClientUID);

                    if (childDocument.UID > 0)
                    {
                        newLink.FKChildDocumentUID = childDocument.UID;

                        newLink.LinkType = child.LinkType; // Replace by link type
                        newLink.Add();
                    }
                }
            }


            //using (var connection = new MySqlConnection(ConnString.ConnectionString))
            //{

            //    var commandString = string.Format(
            //    " SELECT " +
            //    "   UID " +
            //    "   FROM ClientDocument " +
            //    "   WHERE " +
            //    "       FKClientUID = {0} " +
            //    "   AND FKClientDocumentSetUID = {1} ",
            //    ClientUID,
            //    ClientSetUID
            //    );

            //    using (var command = new MySqlCommand(
            //                          commandString, connection))
            //    {
            //        connection.Open();
            //        using (MySqlDataReader reader = command.ExecuteReader())
            //        {
            //            while (reader.Read())
            //            {
            //                int ClientDocumentUID;
            //                ClientDocumentUID = Convert.ToInt32(reader["UID"].ToString());


            //            }
            //        }
            //    }
            //}
        }