Exemple #1
0
        public void UnlinkDocument(DocumentSet documentSet, Model.ModelDocument.Document document)
        {
            // This method deletes a document set link
            //

            // 1) Look for connection that is not voided
            // 2) Update the IsVoid flag to "Y"; EndDate to Today

            string ret = "Item updated successfully";

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString =
                    (
                        "UPDATE DocumentSetDocument " +
                        " SET " +
                        " EndDate = @EndDate" +
                        ",IsVoid = @IsVoid " +
                        " WHERE UID = @UID "
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    command.Parameters.Add("@UID", MySqlDbType.VarChar).Value      = UID;
                    command.Parameters.Add("@EndDate", MySqlDbType.DateTime).Value = DateTime.Today;
                    command.Parameters.Add("@IsVoid", MySqlDbType.VarChar).Value   = 'Y';

                    connection.Open();
                    command.ExecuteNonQuery();
                }
            }
            return;
        }
Exemple #2
0
        public void LinkDocument(DocumentSet documentSet, Model.ModelDocument.Document document)
        {
            // This method creates a document set link
            //
            // It links a document to a document set
            //

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString =
                    (
                        "INSERT INTO DocumentSetDocument " +
                        "(UID " +
                        ",FKDocumentUID " +
                        ",FKDocumentSetUID" +
                        ",SequenceNumber" +
                        ",Location" +
                        ",StartDate" +
                        ",EndDate" +
                        ",IsVoid" +
                        ",FKParentDocumentUID" +
                        ",FKParentDocumentSetUID" +
                        ")" +
                        " VALUES " +
                        "( @UID     " +
                        ", @FKDocumentUID    " +
                        ", @FKDocumentSetUID " +
                        ", @SequenceNumber" +
                        ", @Location" +
                        ", @StartDate" +
                        ", @EndDate" +
                        ", @IsVoid" +
                        ", @FKParentDocumentUID" +
                        ", @FKParentDocumentSetUID" +
                        " ) "
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    command.Parameters.Add("@UID", MySqlDbType.Int32).Value                    = UID;
                    command.Parameters.Add("@FKDocumentUID", MySqlDbType.Int32).Value          = FKDocumentUID;
                    command.Parameters.Add("@FKDocumentSetUID", MySqlDbType.Int32).Value       = FKDocumentSetUID;
                    command.Parameters.Add("@SequenceNumber", MySqlDbType.Int32).Value         = SequenceNumber;
                    command.Parameters.Add("@Location", MySqlDbType.Text).Value                = Location;
                    command.Parameters.Add("@StartDate", MySqlDbType.DateTime).Value           = StartDate;
                    command.Parameters.Add("@EndDate", MySqlDbType.DateTime).Value             = EndDate;
                    command.Parameters.Add("@IsVoid", MySqlDbType.VarChar).Value               = IsVoid;
                    command.Parameters.Add("@FKParentDocumentUID", MySqlDbType.Int32).Value    = FKParentDocumentUID;
                    command.Parameters.Add("@FKParentDocumentSetUID", MySqlDbType.Int32).Value = documentSet.UID;

                    connection.Open();
                    command.ExecuteNonQuery();
                }
            }
            return;
        }
Exemple #3
0
        /// <summary>
        /// List Document Set
        /// </summary>
        public static List <DocumentSet> ListS()
        {
            var documentSetList = new List <DocumentSet>();

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT UID " +
                    " ,TemplateType " +
                    " ,TemplateFolder " +
                    " ,IsVoid " +

                    "   FROM DocumentSet " +
                    "  WHERE IsVoid = 'N' "
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DocumentSet documentSet = new DocumentSet();
                            documentSet.UID            = Convert.ToInt32(reader["UID"].ToString());
                            documentSet.TemplateType   = reader["TemplateType"].ToString();
                            documentSet.TemplateFolder = reader["TemplateFolder"].ToString();
                            documentSet.IsVoid         = Convert.ToChar(reader["IsVoid"].ToString());
                            documentSet.UIDNameDisplay = documentSet.UID.ToString() + "; " + documentSet.TemplateType;

                            documentSetList.Add(documentSet);
                        }
                    }
                }
            }

            return(documentSetList);
        }
 // This method links the list of documents requested to
 // the document set requested
 //
 public void CopyDocumentList(DocumentList documentList, DocumentSet documentSet)
 {
 }
        //
        // 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 MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    "  UID " +
                    " ,FKDocumentUID " +
                    " ,FKDocumentSetUID " +
                    " ,StartDate " +
                    " ,EndDate " +
                    " ,IsVoid " +
                    "   FROM DocumentSetDocument " +
                    "   WHERE FKDocumentSetUID = {0} ",
                    documentSet.UID
                    );

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

                            var docItem = new scDocoSetDocumentLink();

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

                            // 11.01.2013
                            //
                            // docItem.document.Read();

                            docItem.document = RepDocument.Read(true, docItem.document.UID);

                            // 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;
            }
        }
Exemple #6
0
        /// <summary>
        /// Load document into document set
        /// </summary>
        public void LoadAllDocuments()
        {
            // Retrieve all documents
            // For each document (order by parent uid)
            // check if it is already connected to current Document Set
            // If it is not, connect document
            // Link with parent document in the set
            // Replicate Document Links


            // 21/08/2013
            // Stop using DocumentList
            //

            //DocumentList dl = new DocumentList();
            //dl.List();

            List <Document> docl = RepDocument.List(HeaderInfo.Instance);

            foreach (Document document in docl)
            {
                var found = DocumentSet.FindDocumentInSet(this.UID, document.UID);

                if (found.document.UID > 0)
                {
                    continue;
                }
                else
                {
                    DocumentSetDocument dsl = new DocumentSetDocument();

                    // Generate new UID
                    dsl.UID = this.GetLastUID() + 1;

                    // Add document to set
                    //
                    dsl.FKDocumentSetUID       = this.UID;
                    dsl.FKDocumentUID          = document.UID;
                    dsl.Location               = document.Location;
                    dsl.IsVoid                 = 'N';
                    dsl.StartDate              = System.DateTime.Today;
                    dsl.EndDate                = System.DateTime.MaxValue;
                    dsl.FKParentDocumentUID    = document.ParentUID; // Uses the Document UID as the source (Has to be combined with Doc Set)
                    dsl.FKParentDocumentSetUID = dsl.FKDocumentSetUID;
                    dsl.SequenceNumber         = document.SequenceNumber;

                    dsl.Add();
                }
            }

            // Replicate document links
            //
            foreach (Document document in docl)
            {
                var children = DocumentLinkList.ListRelatedDocuments(document.UID);

                foreach (var child in children.documentLinkList)
                {
                    //
                    DocumentSetDocumentLink dsdl = new DocumentSetDocumentLink();
                    dsdl.FKParentDocumentUID = 0;
                    dsdl.FKChildDocumentUID  = 0;
                    dsdl.IsVoid   = 'N';
                    dsdl.LinkType = child.LinkType;
                    dsdl.UID      = GetLastUID() + 1;

                    // Find parent

                    var parent1 = DocumentSet.FindDocumentInSet(this.UID, child.FKParentDocumentUID);

                    // Find child
                    var child1 = DocumentSet.FindDocumentInSet(this.UID, child.FKChildDocumentUID);

                    dsdl.FKParentDocumentUID = parent1.DocumentSetDocument.UID;
                    dsdl.FKChildDocumentUID  = child1.DocumentSetDocument.UID;

                    dsdl.Add();
                }
            }
        }