コード例 #1
0
        /// <summary>
        /// write the response back
        /// </summary>
        public void Send()
        {
            ctx.Response.Write("<channel>");

            ctx.Response.Write("<title>");
            ctx.Response.Write(collection.Name);
            ctx.Response.Write("</title>");

            /*
             * if (slog.Link != "")
             * {
             *      ctx.Response.Write("<link>");
             *      ctx.Response.Write( slog.Link );
             *      ctx.Response.Write("</link>");
             * }
             */

            ctx.Response.Write("<language>");
            ctx.Response.Write("en-us");
            ctx.Response.Write("</language>");

            ctx.Response.Write("<copyright>");
            ctx.Response.Write("(c) Novell, Inc.");
            ctx.Response.Write("</copyright>");

            ctx.Response.Write("<managingEditor>");
            Domain domain = store.GetDomain(store.DefaultDomain);

            if (collection.Owner.FN != null && collection.Owner.FN != "")
            {
                ctx.Response.Write(collection.Owner.FN);
            }
            else
            {
                ctx.Response.Write(collection.Owner.Name);
            }
            ctx.Response.Write("</managingEditor>");

            ctx.Response.Write("<webmaster>");
            //member = domain.GetMemberByID( domain.Owner );
            if (domain.Owner.FN != null && domain.Owner.FN != "")
            {
                ctx.Response.Write(domain.Owner.FN);
            }
            else
            {
                ctx.Response.Write(domain.Owner.Name);
            }
            ctx.Response.Write("</webmaster>");

            try
            {
                Simias.Storage.Property descProp =
                    collection.Properties.GetSingleProperty("Description");
                if (descProp != null)
                {
                    ctx.Response.Write("<description>" + descProp.Value.ToString() + "</description>");
                }
                else
                {
                    ctx.Response.Write("<description>" + collection.Type.ToString() + "</description>");
                }
            }
            catch {}

            ctx.Response.Write(
                String.Format(
                    "<link>{0}{1}:{2}{3}{4}?feed={5}</link>",
                    ctx.Request.IsSecureConnection ? "https://" : "http://",
                    ctx.Request.Url.Host,
                    ctx.Request.Url.Port.ToString(),
                    ctx.Request.ApplicationPath,
                    (publicAccess == true) ? "/pubrss.ashx" : "/rss.ashx",
                    HttpUtility.UrlEncode(collection.Name)));

            Simias.Storage.Property colProp =
                collection.Properties.GetSingleProperty(Simias.RssFeed.Util.LastModified);
            DateTime latest = (colProp != null) ? (DateTime)colProp.Value : collection.CreationTime;


            /*
             * ICSList nodes = collection.Search( Simias.RssFeed.Util.LastModified, dt, SearchOp.Greater );
             * ICSEnumerator nodesEnum = null;
             * if ( nodes.Count > 0 )
             * {
             *      nodesEnum = nodes.GetEnumerator() as ICSEnumerator;
             *      if ( nodesEnum != null &&
             *                      nodesEnum.SetCursor( IndexOrigin.SET, nodesEnum.Count - 1 ) == true )
             *      {
             *              nodesEnum.MoveNext();
             *
             *              try
             *              {
             *                      ShallowNode sn = nodesEnum.Current as ShallowNode;
             *                      log.Debug( "sn: " + sn.Name );
             *
             *                      Item item = new Item( collection, sn );
             *                      if ( item.Published > latest )
             *                      {
             *                              latest = item.Published;
             *                      }
             *              }
             *              catch( Exception e )
             *              {
             *                      log.Debug( e.Message );
             *              }
             *      }
             * }
             */

            Simias.RssFeed.Util.SendPublishDate(ctx, latest);

            ctx.Response.Write("<lastBuildDate>");
            ctx.Response.Write(Util.GetRfc822Date(latest));
            ctx.Response.Write("</lastBuildDate>");

            ctx.Response.Write("<generator>");
            ctx.Response.Write("Simias");
            ctx.Response.Write("</generator>");

            /*
             *      ctx.Response.Write("<cloud>");
             *      ctx.Response.Write( node.Cloud );
             *      ctx.Response.Write("</cloud>");
             */

            ctx.Response.Write("<ttl>");
            ctx.Response.Write(Simias.RssFeed.Util.DefaultTtl.ToString());
            ctx.Response.Write("</ttl>");

            ctx.Response.Write("<rating>");
            ctx.Response.Write(Simias.RssFeed.Util.DefaultRating);
            ctx.Response.Write("</rating>");

            if (strict == false)
            {
                ctx.Response.Write("<authorID>" + collection.Owner.UserID + "</authorID>");
                ctx.Response.Write("<type>" + collection.Type.ToString() + "</type>");
                ctx.Response.Write("<id>" + collection.ID + "</id>");
            }

            if (items == true)
            {
                ICSList nodes =
                    collection.Search(
                        Simias.RssFeed.Util.LastModified,
                        new DateTime(1992, 1, 1, 0, 0, 0),
                        SearchOp.Greater);
                if (nodes != null && nodes.Count > 0)
                {
                    ICSEnumerator nodesEnum = nodes.GetEnumerator() as ICSEnumerator;
                    int           count     = nodesEnum.Count;
                    while (count-- > 0)
                    {
                        if (nodesEnum.SetCursor(IndexOrigin.SET, count) == true)
                        {
                            nodesEnum.MoveNext();
                            ShallowNode sn   = nodesEnum.Current as ShallowNode;
                            Item        item = null;
                            if (this.types.Count == 0)
                            {
                                if (sn.Type == "FileNode")
                                {
                                    item = new Item(collection, sn, publicAccess);
                                }
                            }
                            else
                            {
                                foreach (string ctype in this.types)
                                {
                                    if (ctype == sn.Type)
                                    {
                                        item = new Item(collection, sn, publicAccess);
                                        break;
                                    }
                                }
                            }

                            if (item != null)
                            {
                                item.Strict     = this.strict;
                                item.Enclosures = this.enclosures;
                                item.Send(ctx);
                            }
                        }
                    }
                }
            }

            ctx.Response.Write("</channel>");
        }
コード例 #2
0
    // open store and enable the login for all users. It will also delete 'DisabledAt' property for all users, if it was set earlier.
    //DisabledAt property means during e-dir sync, somehow server interpreted that user was deleted in e-dir, so disabled in iFolder and currently
    // it is under grace itnerval period. After grace interval, server will completely delete that user and orphan his iFolders.
    public static void EnableUserLogins(bool replace)
    {
        if (replace == false)
        {
            Console.WriteLine("You have opted to view and not delete..Use enable to modify also ");
        }
        else
        {
            Console.WriteLine("It will modify the members");
        }
        Store.Initialize(SimiasDataPath, true, -1);
        Store store = Store.GetStore();

        if (store == null)
        {
            Console.WriteLine("store could not be initialized.....");
        }
        Domain domain = store.GetDomain(store.DefaultDomain);

        try{
            ICSList FullMemList = domain.GetMemberList();
            foreach (ShallowNode sn in FullMemList)
            {
                Member memObject = new Member(domain, sn);
                Simias.Storage.Property disabledAt = memObject.Properties.GetSingleProperty(disabledAtProperty);
                if (disabledAt != null)
                {
                    if (replace)
                    {
                        memObject.DeleteProperty = disabledAtProperty;
                    }

                    if (domain.GetLoginpolicy(memObject.UserID) == true)                          //it returns true if user is disabled
                    {
                        // if login was disabled, then enable login
                        if (replace == true)
                        {
                            domain.SetLoginDisabled(memObject.UserID, false);                               //false means it will delete the logindisabled property
                        }
                        Console.WriteLine("Enabled the login for user :"******"Login already enabled for user :"******"Removed the disabledAt property for user :"******"Got exception: " + ee.Message);
        }
        finally{
            Store.DeleteInstance();
        }
    }
コード例 #3
0
    public static void CheckiFolderConsistency(Store store, Domain domain, Member member)
    {
        ICSList ColList = store.GetCollectionsByOwner(member.UserID);
        // Now match the total number of files and dirs in the node and that on physical filesystem.
        string UnManagedPath = null;
        long   missingFile   = 0;
        string errorLine     = "";

        foreach (ShallowNode sn in ColList)
        {
            Collection c = store.GetCollectionByID(sn.ID);
            if (c != null)
            {
                DirNode rootNode = c.GetRootDirectory();
                if (rootNode != null)
                {
                    Simias.Storage.Property localPath = rootNode.Properties.GetSingleProperty(PropertyTags.Root);
                    if (localPath != null)
                    {
                        UnManagedPath = localPath.Value as string;

                        /*  Iterate over all the file nodes
                         */
                        ICSList FileList = c.GetNodesByType(NodeTypes.FileNodeType);
                        errorLine += ("\n\niFolder Name: " + c.Name + "\n");
                        errorLine += ("                Action If Any: ");
                        foreach (ShallowNode sn2 in FileList)
                        {
                            try
                            {
                                Node fileNode = c.GetNodeByID(sn2.ID);
                                Simias.Storage.Property property = fileNode.Properties.GetSingleProperty(PropertyTags.FileSystemPath);
                                if (property != null)
                                {
                                    string filePath = property.Value.ToString();
                                    string fullPath = Path.Combine(UnManagedPath, filePath);;
                                    if (!File.Exists(fullPath))
                                    {
                                        String fileName = fileNode.Name;                                                        //fileNode.Properties.GetSingleProperty( "name" ).Value as string;
                                        // File entry in nodelist is not present in actual path so this user cannot be moved.
                                        c.Commit(c.Delete(fileNode));
                                        errorLine += ("       File Node Deleted: " + fileName);
                                        missingFile++;
                                    }
                                }
                            }
                            catch (Exception e)
                            { Console.WriteLine("some exception while iteration of files."); }
                        }

                        /*   Iterate over all the folder nodes.     */
                        ICSList DirList = c.GetNodesByType(NodeTypes.DirNodeType);
                        foreach (ShallowNode sn2 in DirList)
                        {
                            try
                            {
                                Node folNode = c.GetNodeByID(sn2.ID);
                                Simias.Storage.Property property = folNode.Properties.GetSingleProperty(PropertyTags.FileSystemPath);
                                if (property != null)
                                {
                                    string filePath = property.Value.ToString();
                                    string fullPath = Path.Combine(UnManagedPath, filePath);;
                                    if (!Directory.Exists(fullPath))
                                    {
                                        String folderName = folNode.Name;
                                        // File entry in nodelist is not present in actual path so this user cannot be moved.
                                        c.Commit(c.Delete(folNode));
                                        errorLine += ("       Folder Node Deleted: " + folderName);
                                        missingFile++;
                                    }
                                }
                            }
                            catch (Exception e)
                            { Console.WriteLine("some exception while iteration of files."); }
                        }
                    }
                }
            }
        }
        Console.WriteLine();
        Console.WriteLine();
        if (missingFile == 0)
        {
            Console.WriteLine("*********************" + member.FN + "   (" + member.Name + ")           Passed  *******************");
        }
        else
        {
            Console.WriteLine("*********************" + member.FN + "   (" + member.Name + ")         " + missingFile + " inconsistent files or folders  *******************");
            Console.WriteLine(errorLine);
        }
    }