Exemplo n.º 1
0
    static void Main(string[] args)
    {
        Options options = new Options();

        if (!options.Parse(args))
        {
            Environment.Exit(1);
        }

        RetsSession session = options.SessionFactory();

        session.SetIncrementalMetadata(options.full_metadata ? false : true);

        try
        {
            if (!session.Login(options.user_name, options.user_password))
            {
                Console.WriteLine("Invalid login");
                Environment.Exit(1);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("RetsException: " + e);
            Environment.Exit(1);
        }

        RetsMetadata metadata = session.GetMetadata();

        dumpSystem(metadata);
        dumpForeignKeys(metadata);
        dumpAllResources(metadata);

        session.Logout();
    }
Exemplo n.º 2
0
    static void dumpSystem(RetsMetadata metadata)
    {
        MetadataSystem system = metadata.GetSystem();

        Console.WriteLine("System ID: " + system.GetSystemID());
        Console.WriteLine("Description: " + system.GetSystemDescription());
        Console.WriteLine("Comment: " + system.GetComments());
    }
Exemplo n.º 3
0
 static void dumpAllLookupTypes(RetsMetadata metadata,
     MetadataLookup lookup)
 {
     IEnumerable lookupTypes = metadata.GetAllLookupTypes(lookup);
     foreach (MetadataLookupType lookupType in lookupTypes)
     {
         Console.WriteLine("Lookup value: " + lookupType.GetValue() +
             " (" + lookupType.GetShortValue() + ", " +
             lookupType.GetLongValue() + ")");
     }
 }
Exemplo n.º 4
0
    static void dumpAllLookupTypes(RetsMetadata metadata,
                                   MetadataLookup lookup)
    {
        IEnumerable lookupTypes = metadata.GetAllLookupTypes(lookup);

        foreach (MetadataLookupType lookupType in lookupTypes)
        {
            Console.WriteLine("Lookup value: " + lookupType.GetValue() +
                              " (" + lookupType.GetShortValue() + ", " +
                              lookupType.GetLongValue() + ")");
        }
    }
Exemplo n.º 5
0
        static void dumpAllTables(RetsMetadata metadata, MetadataClass aClass)
        {
            IEnumerable tables = metadata.GetAllTables(aClass);

            foreach (MetadataTable table in tables)
            {
                Console.WriteLine("Table name: " + table.GetSystemName() + " [" +
                                  table.GetStandardName() + "]");
                Console.WriteLine("\tTable datatype: " + table.GetDataType());
                Console.WriteLine("\tUnique: " + table.IsUnique());
                Console.WriteLine("\tMax Length: " + table.GetMaximumLength());
            }
        }
Exemplo n.º 6
0
 static void dumpAllResources(RetsMetadata metadata)
 {
     Console.WriteLine();
     IEnumerable resources = metadata.GetAllResources();
     foreach (MetadataResource resource in resources)
     {
         dumpAllClasses(metadata, resource);
     }
     foreach (MetadataResource resource in resources)
     {
         dumpAllLookups(metadata, resource);
     }
 }
Exemplo n.º 7
0
    static void dumpAllResources(RetsMetadata metadata)
    {
        Console.WriteLine();
        IEnumerable resources = metadata.GetAllResources();

        foreach (MetadataResource resource in resources)
        {
            dumpAllClasses(metadata, resource);
        }
        foreach (MetadataResource resource in resources)
        {
            dumpAllLookups(metadata, resource);
        }
    }
Exemplo n.º 8
0
 static void dumpAllTables(RetsMetadata metadata, MetadataClass aClass)
 {
     IEnumerable tables = metadata.GetAllTables(aClass);
     foreach (MetadataTable table in tables)
     {
         Console.WriteLine("Table name: " + table.GetSystemName() + " [" +
             table.GetStandardName() + "]");
         Console.WriteLine("\tTable datatype: " + table.GetDataType());
         Console.WriteLine("\tUnique: " + table.IsUnique());
         Console.WriteLine("\tMax Length: " + table.GetMaximumLength());
         if (table.InKeyIndex())
             Console.WriteLine("\tInKeyIndex");
     }
 }
Exemplo n.º 9
0
 static void dumpAllClasses(RetsMetadata metadata,
     MetadataResource resource)
 {
     string resourceName = resource.GetResourceID();
     IEnumerable classes = metadata.GetAllClasses(resourceName);
     foreach (MetadataClass aClass in classes)
     {
         Console.WriteLine("Resource name: " + resourceName + " [" +
             resource.GetStandardName() + "]");
         Console.WriteLine("Class name: " + aClass.GetClassName() + " [" +
             aClass.GetStandardName() + "]");
         dumpAllTables(metadata, aClass);
         Console.WriteLine();
     }
 }
Exemplo n.º 10
0
 static void dumpForeignKeys(RetsMetadata metadata)
 {
     Console.WriteLine();
     IEnumerable foreignKeys = metadata.GetAllForeignKeys();
     foreach (MetadataForeignKey foreignKey in foreignKeys)
     {
         Console.WriteLine("Foreign Key ID: " + foreignKey.GetForeignKeyID());
         Console.Write     ("  Parent Resource: " + foreignKey.GetParentResourceID());
         Console.Write     (", Class: " + foreignKey.GetParentClassID());
         Console.WriteLine (", Name: " + foreignKey.GetParentSystemName());
         Console.Write     ("  Child Resource: " + foreignKey.GetChildResourceID());
         Console.Write     (", Class: " + foreignKey.GetChildClassID());
         Console.WriteLine (", Name: " + foreignKey.GetChildSystemName());
     }
 }
Exemplo n.º 11
0
 static void dumpAllLookups(RetsMetadata metadata,
     MetadataResource resource)
 {
     string resourceName = resource.GetResourceID();
     IEnumerable lookups = metadata.GetAllLookups(resourceName);
     foreach (MetadataLookup lookup in lookups)
     {
         Console.WriteLine("Resource name: " + resourceName + " [" +
             resource.GetStandardName() + "]");
         Console.WriteLine("Lokup name: " + lookup.GetLookupName() + " (" +
             lookup.GetVisibleName() + ")");
         dumpAllLookupTypes(metadata, lookup);
         Console.WriteLine();
     }
 }
Exemplo n.º 12
0
    static void dumpAllLookups(RetsMetadata metadata,
                               MetadataResource resource)
    {
        string      resourceName = resource.GetResourceID();
        IEnumerable lookups      = metadata.GetAllLookups(resourceName);

        foreach (MetadataLookup lookup in lookups)
        {
            Console.WriteLine("Resource name: " + resourceName + " [" +
                              resource.GetStandardName() + "]");
            Console.WriteLine("Lookup name: " + lookup.GetLookupName() + " (" +
                              lookup.GetVisibleName() + ")");
            dumpAllLookupTypes(metadata, lookup);
            Console.WriteLine();
        }
    }
Exemplo n.º 13
0
    static void dumpForeignKeys(RetsMetadata metadata)
    {
        Console.WriteLine();
        IEnumerable foreignKeys = metadata.GetAllForeignKeys();

        foreach (MetadataForeignKey foreignKey in foreignKeys)
        {
            Console.WriteLine("Foreign Key ID: " + foreignKey.GetForeignKeyID());
            Console.Write("  Parent Resource: " + foreignKey.GetParentResourceID());
            Console.Write(", Class: " + foreignKey.GetParentClassID());
            Console.WriteLine(", Name: " + foreignKey.GetParentSystemName());
            Console.Write("  Child Resource: " + foreignKey.GetChildResourceID());
            Console.Write(", Class: " + foreignKey.GetChildClassID());
            Console.WriteLine(", Name: " + foreignKey.GetChildSystemName());
        }
    }
Exemplo n.º 14
0
    static void dumpAllClasses(RetsMetadata metadata,
                               MetadataResource resource)
    {
        string      resourceName = resource.GetResourceID();
        IEnumerable classes      = metadata.GetAllClasses(resourceName);

        foreach (MetadataClass aClass in classes)
        {
            Console.WriteLine("Resource name: " + resourceName + " [" +
                              resource.GetStandardName() + "]");
            Console.WriteLine("Class name: " + aClass.GetClassName() + " [" +
                              aClass.GetStandardName() + "]");
            dumpAllTables(metadata, aClass);
            Console.WriteLine();
        }
    }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            bool isLoggedIn = false;

            using (RetsSession retssession = new RetsSession("http://www.eele-rets.com:6160/rets/login"))
            {
                retssession.UseHttpGet(true);
                //retssession.
                isLoggedIn = retssession.Login("corcoran", "JDXzmkGa");

                if (isLoggedIn)
                {
                    var urls = retssession.GetCapabilityUrls();
                    Console.WriteLine(urls.GetLoginUrl());

                    RetsMetadata metadata  = retssession.GetMetadata();
                    IEnumerable  resources = metadata.GetAllResources();

                    using (SearchRequest searchRequest = retssession.CreateSearchRequest(
                               "Property",
                               "CLISTINGS",
                               "(Modified=2016-12-12T00:00:00+)"))
                    {
                        searchRequest.SetQueryType(SearchRequest.QueryType.DMQL2);
                        searchRequest.SetStandardNames(false);
                        searchRequest.SetOffset(SearchRequest.OFFSET_NONE);
                        SearchResultSet results = retssession.Search(searchRequest);
                        Console.WriteLine("Record count: " + results.GetCount());
                        Console.WriteLine();
                        IEnumerable columns = results.GetColumns();
                        while (results.HasNext())
                        {
                            foreach (string column in columns)
                            {
                                Console.WriteLine(column + ": " + results.GetString(column));
                            }
                            Console.WriteLine();
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
 static void dumpSystem(RetsMetadata metadata)
 {
     MetadataSystem system = metadata.GetSystem();
     Console.WriteLine("System ID: " + system.GetSystemID());
     Console.WriteLine("Description: " + system.GetSystemDescription());
     Console.WriteLine("Comment: " + system.GetComments());
 }
Exemplo n.º 17
0
    /*
     * This class demonstrates the interleaving of search transactions.
     */
    static void Main(string[] args)
    {
        Options options = new Options();

        if (!options.Parse(args))
        {
            Environment.Exit(1);
        }

        RetsSession session = options.SessionFactory();

        try {
            if (!session.Login(options.user_name, options.user_password))
            {
                Console.WriteLine("Invalid login");
                Environment.Exit(1);
            }
        } catch (Exception e)
        {
            Console.WriteLine("RetsException: " + e);
            Environment.Exit(1);
        }

        RetsVersion version = session.GetDetectedRetsVersion();

        Console.WriteLine("RETS Version: " +
                          ((version == RetsVersion.RETS_1_5) ? "1.5" :
                           ((version == RetsVersion.RETS_1_7) ? "1.7" : "1.0")));

        /*
         * Find the key field for the resource.
         */
        RetsMetadata     metadata         = session.GetMetadata();
        MetadataResource metadataResource = metadata.GetResource(options.search_type);

        if (metadataResource == null)
        {
            Console.WriteLine("Invalid resource: " + options.search_type);
            session.Logout();
            Environment.Exit(1);
        }

        string keyField = metadataResource.GetKeyField();

        /*
         * Find the timestamp field if it is known (RETS 1.7 and later). If
         * not known, then the user must provide it.
         */
        MetadataClass metadataClass = metadata.GetClass(options.search_type, options.search_class);

        if (metadataClass == null)
        {
            Console.WriteLine("Invalid resource:class: " + options.search_type + ":" + options.search_class);
            session.Logout();
            Environment.Exit(2);
        }

        if (options.classTimeStamp != null && options.classTimeStamp.Length == 0)
        {
            options.classTimeStamp = metadataClass.GetStringAttribute("ClassTimeStamp");
        }

        if (options.classTimeStamp == null || options.classTimeStamp.Length == 0)
        {
            Console.WriteLine("Class " + options.search_type +
                              ":" + options.search_class +
                              " has no ClassTimeStamp specified in the metadata.");
            Console.WriteLine("Please manually provide one using the --timetsamp switch.");
            session.Logout();
            Environment.Exit(2);
        }

        /*
         * See if the last modified timestamp has been provided. If not, use yesterday.
         */
        if (options.lastModified == null || options.lastModified.Length == 0)
        {
            DateTime ts = DateTime.Now;

            options.lastModified = ts.AddDays(-1).ToString("yyyy-MM-dd");
        }

        /*
         * OK - let's find all listings that have changed since the lastModified date.
         */

        SearchRequest searchRequest = session.CreateSearchRequest(
            options.search_type,
            options.search_class,
            "(" +
            options.classTimeStamp.ToString() +
            "=" +
            options.lastModified.ToString() +
            "+)");

        searchRequest.SetSelect(keyField);
        searchRequest.SetLimit(SearchRequest.LIMIT_NONE);
        searchRequest.SetOffset(SearchRequest.OFFSET_NONE);
        searchRequest.SetCountType(SearchRequest.CountType.RECORD_COUNT_AND_RESULTS);
        searchRequest.SetStandardNames(false);

        /*
         * This starts the outer search.
         */
        SearchResultSet results = session.Search(searchRequest);

        Console.WriteLine("Record count: " + results.GetCount());
        Console.WriteLine();

        while (results.HasNext())
        {
            /*
             * Fetch the listing detail and media. This will cause a separate search transaction
             * to be open within the outer search transaction.
             */
            SearchRequest listingRequest = session.CreateSearchRequest(
                options.search_type,
                options.search_class,
                "(" +
                keyField +
                "=" +
                results.GetString(keyField) +
                ")");
            listingRequest.SetStandardNames(false);
            listingRequest.SetLimit(SearchRequest.LIMIT_DEFAULT);
            listingRequest.SetOffset(SearchRequest.OFFSET_NONE);
            listingRequest.SetCountType(SearchRequest.CountType.NO_RECORD_COUNT);
            listingRequest.SetFormatType(SearchRequest.FormatType.COMPACT);

            SearchResultSet listingResult = session.Search(listingRequest);
            IEnumerable     columns       = null;

            while (listingResult.HasNext())
            {
                if (columns == null)
                {
                    columns = listingResult.GetColumns();
                }

                /*
                 * Show the listing detail.
                 */
                foreach (string column in columns)
                {
                    Console.WriteLine("{0,15}: {1}", column, listingResult.GetString(column));
                }
                Console.WriteLine();

                /*
                 * Now set up to fetch the objects associated with this listing.
                 */
                GetObjectRequest getObjectRequest = new GetObjectRequest(options.search_type, "Photo");
                getObjectRequest.AddAllObjects(listingResult.GetString(keyField));

                GetObjectResponse getObjectResponse = session.GetObject(getObjectRequest);

                foreach (ObjectDescriptor objectDescriptor in getObjectResponse)
                {
                    /*
                     * Report the object details.
                     */
                    string objectKey = objectDescriptor.GetObjectKey();
                    int    objectId  = objectDescriptor.GetObjectId();
                    //string  contentType = objectDescriptor.GetContentType();
                    string description = objectDescriptor.GetDescription();

                    Console.Write("Object " + objectKey + ":" + objectId.ToString());
                    if (description.Length > 0)
                    {
                        Console.Write(", description: " + description);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("=================");
            }
        }

        session.Logout();
    }