コード例 #1
0
        /// <summary>
        /// Creates a new document
        /// </summary>
        /// <param Name="Name">The Name (.Text property) of the document</param>
        /// <param Name="dct">The documenttype</param>
        /// <param Name="u">The usercontext under which the action are performed</param>
        /// <param Name="ParentId">The id of the parent to the document</param>
        /// <returns>The newly created document</returns>
        public static Document MakeNew(string Name, DocumentType dct, User u, int ParentId)
        {
            Guid newId = Guid.NewGuid();
            // Updated to match level from base node
            CMSNode n        = new CMSNode(ParentId);
            int     newLevel = n.Level;

            newLevel++;
            MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
            Document tmp = new Document(newId, true);

            tmp.CreateContent(dct);
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(_ConnString, CommandType.Text,
                                                                       "insert into cmsDocument (newest, nodeId, published, documentUser, versionId, Text) values (1, " +
                                                                       tmp.Id + ", 0, " +
                                                                       u.Id + ", '" + tmp.Version + "', N'" + SqlHelper.SafeString(tmp.Text) + "')");

            // Update the sortOrder if the parent was the root!
            if (ParentId == -1)
            {
                CMSNode c = new CMSNode(newId);
                c.sortOrder = GetRootDocuments().Length + 1;
            }

            Document d = new Document(newId);

            // Log
            Log.Add(LogTypes.New, u, d.Id, "");

            // Run Handler
            Action.RunActionHandlers(d, new ActionNew());

            // Index
            try
            {
                Indexer.IndexNode(_objectType, d.Id, d.Text, d.User.Name, d.CreateDateTime, null, true);
            }
            catch (Exception ee)
            {
                Log.Add(LogTypes.Error, d.User, d.Id,
                        string.Format("Error indexing document: {0}", ee));
            }

            return(d);
        }
コード例 #2
0
ファイル: Document.cs プロジェクト: JianwenSun/mono-soc-2007
        /// <summary>
        /// Creates a new document
        /// </summary>
        /// <param Name="Name">The Name (.Text property) of the document</param>
        /// <param Name="dct">The documenttype</param>
        /// <param Name="u">The usercontext under which the action are performed</param>
        /// <param Name="ParentId">The id of the parent to the document</param>
        /// <returns>The newly created document</returns>
        public static Document MakeNew(string Name, DocumentType dct, User u, int ParentId)
        {
            Guid newId = Guid.NewGuid();
            // Updated to match level from base node
            CMSNode n = new CMSNode(ParentId);
            int newLevel = n.Level;
            newLevel++;
            MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
            Document tmp = new Document(newId, true);
            tmp.CreateContent(dct);
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(_ConnString, CommandType.Text,
                                      "insert into cmsDocument (newest, nodeId, published, documentUser, versionId, Text) values (1, " +
                                      tmp.Id + ", 0, " +
                                      u.Id + ", '" + tmp.Version + "', N'" + SqlHelper.SafeString(tmp.Text) + "')");

            // Update the sortOrder if the parent was the root!
            if (ParentId == -1)
            {
                CMSNode c = new CMSNode(newId);
                c.sortOrder = GetRootDocuments().Length + 1;
            }

            Document d = new Document(newId);

            // Log
            Log.Add(LogTypes.New, u, d.Id, "");

            // Run Handler				
            Action.RunActionHandlers(d, new ActionNew());

            // Index
            try
            {
                Indexer.IndexNode(_objectType, d.Id, d.Text, d.User.Name, d.CreateDateTime, null, true);
            }
            catch (Exception ee)
            {
                Log.Add(LogTypes.Error, d.User, d.Id,
                        string.Format("Error indexing document: {0}", ee));
            }

            return d;
        }