Writing an array of custom objects to CSV

I am brand new to PS. I have been reading many, many forums and am stuck on something I think you all will find very easy.
Essentially all I want to do is use the test-path method to determine if a file and track yes or no. Repeat for several products. And finally export to a CSV.  So far I have cobbled together the If statement that will return a Yes Or No with the product name. 
Able to put it into an array of custom objects so I can export-csv without just getting the just the name lengths.  The problem is that I only get the last value of the custom objects over and over again.  Here's my simple code:
$hostname = hostname
$Products = @()
$myobj = "" | select COTS_Product, PassFail
If(test-Path -Path C:\"Program Files"\Java\jre7\THIRDPARTYLICENSEREADME.txt)
$myobj.COTS_Product = "JRE 7 on Host?"
$myobj.PassFail = "YES"
$Products += $myobj
else
$myobj.COTS_Product = "JRE 7 on Host?"
$myobj.PassFail = "NO"
$Products += $myobj
##Product 2
If(test-Path -Path H:\Smileys\6.gif)
$myobj.COTS_Product = "Smileys 6 on Host?"
$myobj.PassFail = "YES"
$Products += $myobj
else
$myobj.COTS_Product = "Smileys 6 on Host?"
$myobj.PassFail = "NO"
$Products += $myobj
$Products | Export-Csv H:\$hostname.csv -NoTypeInformation
Here's my output:
COTS_Product
PassFail
Smileys 6 on Host?
YES
Smileys 6 on Host?
YES
SHould Be:
COTS_Product
PassFail
JRE 7 on Host?
YES
Smileys 6 on Host?
YES
Please Help.

You have been  reading a lot of very old and very faulty misleading forums.  Start by actually sitting downa nd trying to learnPowerSHell.  You cannot guess your way through any relatively sophisticated technology.
Here is a little example of a way to do this in PowerShell.
function Test-Product{
Param(
$product,
$path
New-Object PsObject -Property @{
COTS_Product=$product
PassFail=Test-Path $path
$test_products=@{
'JRE 7'='C:\Program Files\Java\jre7\THIRDPARTYLICENSEREADME.txt'
'JSmileys 6'='h:\Smileys\6.gif'
$products=foreach($key in $test_products.keys){
Test-Product $key $test_products[$key]
$Products | Export-Csv H:\$hostname.csv -NoTypeInformation
This can be expanded in any way needed without issues.  It uses the design of PowerShell to set up the objects so they are manageable.  Until you learn about objects and formal programming logic and some elements of design you will have some difficulty
in figuring out how to do these things.  Once you learn the basics they will seem very simple.  You cannot learn the basics from reading forum posts.
¯\_(ツ)_/¯

Similar Messages

  • Using Arrays in custom objects

    All,
    I have searched for an answer to this but have not been able to find out so I'll post the issue and see what happens.
    I am creating a service and client for use with a JavaCard system. We have a pre-existing domain class called CardMetaData wich holds information about a card such as it's type, it's name, and an array of strings representing the static keys required to create a secure channel to the card. Essentially it looks like this:
    public class CardMetaData implements Serializable
            String[] cardStaticKeys = {"key1","key2","key3");
            String name;
            String type;
            ///getters and setters..
            //plus
            public String getStaticKey(int keyType)
              return this.cardStaticKeys[keyType];
         public void setCardStaticKey(String keyValue, int keyType)
              //Validation of input may be added later or put in an Aspect
              this.cardStaticKeys[keyType]=keyValue;
    }This is a datat transfer object.
    It is served up by a service with the following interface:
    public interface JCTemplateService extends Remote
         public CardMetaData getTemplate(String ATR) throws java.rmi.RemoteException;
    }Everything compiles and deploys find. The WSDL is:
    <definitions name="JCCardTemplateService" targetNamespace="urn:JCCardTemplateService">
         <types>
         <schema targetNamespace="urn:JCCardTemplateService">
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
         <complexType name="CardTemplate">
         <sequence>
    <element name="cardStaticKeys" type="tns:ArrayOfstring"/>
    <element name="description" type="string"/>
    <element name="name" type="string"/>
    </sequence>
    </complexType>
         <complexType name="ArrayOfstring">
         <complexContent>
         <restriction base="soap11-enc:Array">
    <attribute ref="soap11-enc:arrayType" wsdl:arrayType="string[]"/>
    </restriction>
    </complexContent>
    </complexType>
    </schema>
    </types>
         <message name="JCTemplateService_getTemplate">
    <part name="String_1" type="xsd:string"/>
    </message>
         <message name="JCTemplateService_getTemplateResponse">
    <part name="result" type="tns:CardTemplate"/>
    </message>
         <portType name="JCTemplateService">
         <operation name="getTemplate" parameterOrder="String_1">
    <input message="tns:JCTemplateService_getTemplate"/>
    <output message="tns:JCTemplateService_getTemplateResponse"/>
    </operation>
    </portType>
         <binding name="JCTemplateServiceBinding" type="tns:JCTemplateService">
         <operation name="getTemplate">
         <input>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:JCCardTemplateService"/>
    </input>
         <output>
    <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:JCCardTemplateService"/>
    </output>
    <soap:operation soapAction=""/>
    </operation>
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
    </binding>
         <service name="JCCardTemplateService">
         <port name="JCTemplateServicePort" binding="tns:JCTemplateServiceBinding">
    <soap:address location="http://localhost:8080/jcaa/templateService"/>
    </port>
    </service>
    </definitions>When I use a dynamic proxy to access this service like this:
    public static void main(String[] args) throws Exception
              URL urlWsdl =
                   new URL("http://localhost:8080/jcaa/templateService?WSDL");
              String nameSpaceUri = "urn:JCCardTemplateService";
              String serviceName = "JCCardTemplateService";
              String portName = "JCTemplateServicePort";
              ServiceFactory serviceFactory = ServiceFactory.newInstance();
              Service service =
                   serviceFactory.createService(
                        urlWsdl,
                        new QName(nameSpaceUri, serviceName));
               JCTemplateService myProxy =
                   (JCTemplateService) service.getPort(
                        new QName(nameSpaceUri, portName),
              JCTemplateService.class);
         ->    CardMetaData ct=myProxy.getTemplate("123456");
              System.out.println("CardTemplate from WS is "+ct.getDescription());
              System.out.println("key 1 from WS is "+ct.getKeyENC());
              System.out.println("key 2 from WS is "+ct.getKeyMAC());
              System.out.println("key 3 from WS is "+ct.getKeyKEK());
              System.out.println("Name is "+ct.getName());
         }It fails with a 'deserializzation error incomplete object' error at the line indicated above. If I remove the String[] from the value object and replace it with 3 separate string variables it works.
    Any idea's?
    Mike

    Does this mean, if you need the Dynamic Proxy client approach (and cannot use the Static Stub client, since it's J2EE implementation specific as I've learned from you, Kathy), today you cannot expect String arrays to work in J2EE web services?
    I have got a datatype Foo with an ArrayList containing String Arrays. In webMethods GLUE my server and client understand each other, it works pretty well. But I found that the WSDL is way to complex/not correctly understood by other SOAP client implementations like MS SOAP Toolkit or Mozilla Web Service Implementation.
    So my idea was to switch from GLUE to J2EE. Ok, this leads me to a WS Basic Profile I compliant WSDL and all. But now it seems this works only for really simple java types.
    I really need the ArrayList with the String Array elements. But I think in my web service (WSDL) I have to use a wrapper type which is the String representation of my (serialized by hand) Foo type and I have on the client side to create the Foo type from the string. That would not be nice, my hope was that J2EE supports more in this area. :-) Anyway, at the end it's important for me to have a portable (interoperable!) way to create and use a web service.
    So, to ask the question short and to the point:
    Today, if I want my client to work with different J2EE implementations using the Dynamic Proxy client approach and other clients, like MS SOAP Toolkit, can I offer on the J2EE web service server side a datatype with an ArrayList containing String arrays in a portable and interoperable way without the need of custom deserializers on client side?
    Merten

  • How do I serialize an array of custom objects?

    I need to serialize this array:
    public class MyData
       public Triplet[,] MyArray = new Triplet[12, 12];
       ...etc...
    where:
    public class Triplet
       public Int16 X;
       public Int16 Y;
       public Int16 Z;
       public bool Modified;
    I get this error:
    "Cannot serialize object of type Triplet[,]. Multidimensional arrays are not supported."
    The serialization code in MyData is as follows:
       XmlSerializer serializer = new XmlSerializer(this.GetType());
       using (StreamWriter writer = new StreamWriter(fileName))
          serializer.Serialize(writer, this);
    Do you know how I should serialize MyArray?
    Thank you.

    XMLSerializer does not support multi-dimentional array.
    use binary serialization
    https://social.msdn.microsoft.com/Forums/en-US/90c98754-2580-404a-81ae-aedba5f2604d/serialize-multidimensional-arrays?forum=csharplanguage
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Need help creating custom objects and adding them to an array.

    Hi Everyone,
    So I'm dinking around in Powershell today and I'm failing at creating an array of custom objects.  I want to create a HTML report that builds out after every MDT image update. To do that, I need to collect my data on what's contained in each build.
    Here's my current script in progress -
    function Parse-Dependents($fullname){
    #PARAMETER SWITCHING
    if(!($fullname)){
    $dependents = get-dependents
    if($fullname){
    $dependents = get-dependents -fullname $fullname
    #SPIN THROUGH ARRAY OF GUIDS FROM GET-DEPENDENTS
    foreach($d in $dependents){
    #SPIN THROUGH EACH APP IN APPLICATIONS.XML
    foreach ($app in $apps){
    #IF MATCH THEN ADD OBJECT WITH PROPERTIES
    if($d -match $app.guid){
    #ADD APPLICATION MATCH TO THE ARRAY
    $applications = @{
    'Name' = $app.ShortName;
    'GUID' = $app.Guid;
    'Version' = $app.Version;
    'Last Modified Time' = $app.LastModifiedTime;
    'Last Modified By' = $app.LastModifiedBy;
    'Install Directory' = [string]'\\my\path\to\MDT\' + $app.WorkingDirectory.TrimStart(".","\")
    'CommandLine' = $app.CommandLine;
    new-object -typename PSObject -property $applications
    #RETURN MATCHED ARRAY
    return $applications
    It all works great until I look at my output and see that I get my expected properties and array, but at the end it's created additional empty entries for each of my initial properties I assigned.  So I get my list of apps like this :
    powershell.ex... OrgChart Plugin  \\my\mdt\server\ XX\user                     9/22/2014 5:... {ffee7497-0c...
    And then below it :
                     CommandLine                                                                                    
                     Name                                                                                           
                     Install Direc...                                                                               
                     Last Modified By                                                                               
                     Version                                                                                        
                     Last Modified...                                                                               
                     GUID                                                                                           
    And these are all listed under the Name property.  I'm still pretty new to PS (8 months or so now), and rarely have to create a custom object, but this seems like a case for doing so to create a custom html report.  Any ideas would be greatly appreciated.
    Ryan

    It's not really all that strange.  
    If you look at your script, you're not outputting the hash table until both loops finish.  The values are dependent on the properties of the $app objects enumerated in the inner loop, and only outputting an object if the dependent ($d) matches the $app
    guid property.
    At the end, you're outputting the hash table without that test, so it's going to have values based on the last $app in the loop, regardless of whether the guid matches the dependents or not.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • How to create the data for custom objects in pList

    Hi,
    I am new in developing on iPhone and I don't know much about this area. I would like to ask a question. I couldn't find the answer on this question in apple documentation but I hope Internet community will help me.
    Lets say I have a class called classA. The classA has 2 public properties (or fields):
    *int customIndex*;
    and
    NSString *customTitle;
    My view controller class showMeSomething has a property NSArray which holds the objects of type classA. I would like to load the array from the plist resource file. How do I edit the resource file with initial values or how do I know the format of the plist which can be loaded from using mainBundle for my array of custom objects?
    Thanks!

    Here's some info on working with plists:
    http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Introduc tion/chapter1_section1.html
    They can be edited with any text editor. Xcode provides a graphical editor for them - make sure to use the .plist extension so Xcode will recognize it.

  • How to access custom object as property in yField

    Hi All,
    I have a stacked column chart. The data provider (dp) has an
    array of object DataObject which has array of custom objects of
    class ClientRev:
    public function ClientRev(name: String, rev : Number)
    cName = name;
    cRev = rev;
    // data provider
    public class DataObject
    public var clientRev : Array;
    Now I have to use cRev property of clientRev elements of
    DataObject (DataObjects makes data provider) in yField of
    ColumnSeries.
    if i write,
    yField="{clientRev[0].cRev}",
    It doesn't work. Please lemme know how can I achieve my goal.
    Thanks for help.

    "vaibhav.chauhan" <[email protected]> wrote
    in message
    news:gdmhok$2eq$[email protected]..
    > Hi All,
    > I have a stacked column chart. The data provider (dp)
    has an array of
    > object
    > DataObject which has array of custom objects of class
    ClientRev:
    > public function ClientRev(name: String, rev : Number)
    > {
    > cName = name;
    > cRev = rev;
    > }
    >
    > // data provider
    > public class DataObject
    > {
    > public var clientRev : Array;
    > }
    >
    > Now I have to use cRev property of clientRev elements of
    DataObject
    > (DataObjects makes data provider) in yField of
    ColumnSeries.
    >
    > if i write,
    > yField="{clientRev[0].cRev}",
    >
    > It doesn't work. Please lemme know how can I achieve my
    goal.
    Use a dataFunction

  • Newbie - help needed with array and dictionary objects

    Hi all
    Please see the code below. I've posted this code in another thread however the original issue was resolved and this is now a new issue I'm having although centered around the same code.
    The issue is that I'm populating an array with dictionary objects. each dictionary object has a key and it's value is another array of custom objects.
    I've found that the code runs without error and I end up with my array as I'm expecting however all of the dictionary objects are the same.
    I assume it's something to do with pointers and/or re-using the same objects but i'm new to obj-c and pointers so i am a bit lost.
    Any help again is very much appreciated.
    // Open the database connection and retrieve minimal information for all objects.
    - (void)initializeDatabase {
    NSMutableArray *authorArray = [[NSMutableArray alloc] init];
    self.authors = authorArray;
    [authorArray release];
    // The database is stored in the application bundle.
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"books.sql"];
    // Open the database. The database was prepared outside the application.
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
    // Get the primary key for all books.
    const char *sql = "SELECT id, author FROM author";
    sqlite3_stmt *statement;
    // Preparing a statement compiles the SQL query into a byte-code program in the SQLite library.
    // The third parameter is either the length of the SQL string or -1 to read up to the first null terminator.
    if (sqlite3preparev2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
    // We "step" through the results - once for each row.
    // We start with Letter A...we're building an A - Z grouping
    NSString *letter = @"A";
    NSMutableArray *tempauthors = [[NSMutableArray alloc] init];
    while (sqlite3_step(statement) == SQLITE_ROW) {
    author *author = [[author alloc] init];
    author.primaryKey = sqlite3columnint(statement, 0);
    author.title = [NSString stringWithUTF8String:(char *)sqlite3columntext(statement, 0)];
    // FOLLOWING WAS LEFT OVER FROM ORIGINAL COMMENTS IN SQLBooks example....
    // We avoid the alloc-init-autorelease pattern here because we are in a tight loop and
    // autorelease is slightly more expensive than release. This design choice has nothing to do with
    // actual memory management - at the end of this block of code, all the book objects allocated
    // here will be in memory regardless of whether we use autorelease or release, because they are
    // retained by the books array.
    // if the author starts with the Letter we currently have, add it to the temp array
    if ([[author.title substringToIndex:1] compare:letter] == NSOrderedSame){
    [tempauthors addObject:author];
    } // if this is different letter, then we need to deal with that too...
    else {
    // create a dictionary to store the current tempauthors array in...
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    // add the dictionary to our appDelegate-level array
    [authors addObject:tempDictionary];
    // now prepare for the next loop...
    // set the new letter...
    letter = [author.title substringToIndex:1];
    // remove all of the previous authors so we don't duplicate...
    [tempauthors removeAllObjects];
    // add the current author as this was the one that didn't match the Letter and so
    // never went into the previous array...
    [tempauthors addObject:author];
    // release ready for the next loop...
    [author release];
    // clear up the remaining authors that weren't picked up and saved in the "else" statement above...
    if (tempauthors.count > 0){
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    [authors addObject:tempDictionary];
    else {
    printf("Failed preparing statement %s
    ", sqlite3_errmsg(database));
    // "Finalize" the statement - releases the resources associated with the statement.
    sqlite3_finalize(statement);
    } else {
    // Even though the open failed, call close to properly clean up resources.
    sqlite3_close(database);
    NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
    // Additional error handling, as appropriate...
    Message was edited by: dotnetter

    Ok, so I know what the issue is now...I just don't know enough to be able to resolve it!
    it's the tempAuthors objects.
    It's an NSMutableArray which is create on the line before the start of the WHILE loop.
    Having looked through the debugger, I can see that each dictionary object is created (with different codes which I assume are memory addresses) so all is well there. However, on each iteration of the loop in the middle there is an IF...ELSE... statement which in the ELSE section is clearing all objects from the tempAuthors array and beginning to repopulate it again.
    Looking at the containing dictionary objects in the debugger I can see that the tempAuthors object that each contains has the same code (again, I'm assuming this is a memory address) - so if I understand correctly, it's the same object...I assumed that when I created the dictionary using the dictionWithObject call that I would be passing in a copy of the object, but it's referencing back to the object which I then go on to change.
    Assuming the above is correct, I've tried several "stabs in the dark" at fixing it.
    I've tried relasing the tempAuthors object within the ELSE and initialising it again via an alloc...init - but this didn't work and again looking through the debugger it looks as though it was confused as to which object it was supposed to be using on the following iteration of the WHILE loop (it tried to access the released object).
    Having read a little more about memory management can someone tell me if I'm correct in saying that the above is because the tempAuthors object is declare outside the scope of the WHILE loop yet I then try to re-instantiate it within the loop (does that make sense???).
    Sorry for the long post...the more I can understand the process the less I can hopefully stop relying on others for help so much.
    I am continuing to read up on memory management etc but just not there yet.
    Regards
    Wayne

  • Error creating a Custom Object via REST

    Hi- we're developing a third party app that will publish to Eloqua and may need to create and upsert to Custom Objects.  We whipped up a quick PoC using the sample code provided (thank you) but we're having trouble getting the create operation to be successful.  The code we're using is Java and works fine for: reading/writing contacts and reading Custom Objects.  Here's the wire info on the Create call that is failing:
    Request payload (authentication works fine - we're using it for other successful calls):
    POST: https://secure.eloqua.com/API/REST/1.0/assets/customObject/
    {"id":9987,"name":"rest test","fields":[{"name":"sample text field","dataType":"2","type":"CustomObjectField","id":1},{"name":"sample numeric field","dataType":"1","type":"CustomObjectField","id":2},{"name":"sample date field","dataType":"5","type":"CustomObjectField","id":3}],"page":0,"pageSize":0}
    Response:
    <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"><Code><Value>Receiver</Value><Subcode><Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</Value></Subcode></Code><Reason><Text xml:lang="en-US">The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the &lt;serviceDebug&gt; configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.</Text></Reason></Fault>
    I'm assuming that we're just forgetting to set something in the header or payload of the call.  Can you provide some insight into what we're doing wrong here?
    Thanks!

    Fred,
    Thanks for the info above.  I retried the call with various combinations of IDs ranging from:
    - All different negative IDs
    - All the same negative IDs (-1)
    - Custom Object negative and fields positive (and vice versa)
    None of them worked.  I've attached the full HTTP envelope this time... I find it curious that the response is 404 (vs. 5XX)... am I calling the correct method/URL?
    Thanks,
    Dan
    ======================================================
    POST /API/REST/1.0/assets/customObject/ HTTP/1.1
    Content-Type: application/json
    Authorization: Basic [masked]==
    User-Agent: Java/1.6.0_37
    Host: secure.eloqua.com
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive
    Content-Length: 303
    {"id":-100,"name":"rest test","fields":[{"name":"sample text field","dataType":"2","type":"CustomObjectField","id":-1},{"name":"sample numeric field","dataType":"1","type":"CustomObjectField","id":-2},{"name":"sample date field","dataType":"5","type":"CustomObjectField","id":-3}],"page":0,"pageSize":0}
    =============================================
    HTTP/1.1 404 Not Found
    Cache-Control: private
    Content-Length: 748
    Content-Type: text/html; charset=UTF-8
    P3P: CP="IDC DSP COR DEVa TAIa OUR BUS PHY ONL UNI COM NAV CNT STA",
    X-Powered-By: ASP.NET
    Date: Fri, 23 Nov 2012 13:36:37 GMT
    <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"><Code><Value>Receiver</Value><Subcode><Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</Value></Subcode></Code><Reason><Text xml:lang="en-US">The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the &lt;serviceDebug&gt; configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.</Text></Reason></Fault>

  • Event Bubbling Custom Object not inheriting from control

    One of the new things flash flex and xaml have are ways which
    the event easily bubbles up to a parent that knows how to handle
    the event. Similar to exceptions travel up until someone catches
    it.
    My goal is to use the frameworks event system on custom
    objects. My custom objects are:
    ApplicationConfiguration
    through composition contains:
    SecurityCollection which contains many or no SecurityElements
    and
    FileSystemCollection.cs which contains many or no
    FileSystemElement objects
    ect ect basically defining the following xml file with custom
    objects.
    [code]
    <ApplicationConfiguration>
    <communication>
    <hardwareinterface type="Ethernet">
    <ethernet localipaddress="192.168.1.2" localport="5555"
    remoteipaddress="192.168.1.1" remoteport="5555" />
    <serial baudrate="115200" port="COM1" />
    </hardwareinterface>
    <timing type="InternalClock" />
    </communication>
    <filesystem>
    <add id="location.scriptfiles" value="c:\\" />
    <add id="location.logfiles" value="c:\\" />
    <add id="location.configurationfiles" value="c:\\" />
    </filesystem>
    <security>
    <add id="name1" value="secret1" />
    <add id="name2" value="secret2" />
    </security>
    <logging EnableLogging="true"
    LogApplicationExceptions="true" LogInvalidMessages="true"
    CreateTranscript="true" />
    </ApplicationConfiguration>
    [/code]
    basically these custom objects abstract the xml details of
    accessing attributes, writing content out of the higher application
    layers.
    These custom objects hold the application configuration which
    contains the users options. The gui application uses these
    parameters across various windows forms, modal dialog boxes ect.
    The gui has a modal dialog that allows the user to modify these
    parameters during runtime.
    basically i manage: load, store, new, edit, delete of these
    configuration files using my custom objects.
    Where would event propagation help in custom objects like
    described above?
    ConfigurationSingleton.getInstance().ApplicationConfiguration.CommunicationElement.Hardwar eInterfaceElement.EthernetElement.RemoteIPAddress
    =
    System.Net.IPAddress.Parse(this.textBoxRemoteEthernetIpAddress.Text);
    The EthernetElement should propagate a changed event up to
    the parent ApplicationConfiguration which would persist this to the
    registry, db, file or whatever backend.
    currently this logic is maintained else where. I serialize
    the root node which compositely serializing the nested nodes and i
    check of the serialization is different from that in the backend
    … This tells me if the dom was modified. It works but i would
    like an event driven system.
    how should i implement bubbling using custom objects?
    3 implementation ideas:
    1) A simple way is to implement a singleton event manager:
    EventManager.RegisterRoutedEvent
    http://msdn2.microsoft.com/en-us/library/ms742806.aspx
    I like this idea but how can you tell which object is nested
    in who… this way the event can be stopped and discontinue
    propagation?
    2) If i use binders as discussed in Apress’s book:
    Event-Based
    Programming Taking Events to the Limit
    basically a binder connects the events between seperate
    objects together… although it would work for my app, I would
    like a more generalized approach so i can reuse the event system on
    future project.
    3) how does flash flex handle this..
    objectproxy.as?
    http://www.gamejd.com/resource/apollo_alpha1_docs/apiReference/combined/mx/utils/ObjectPro xy.html#getComplexProperty()
    >Provides a place for subclasses to override how a complex
    property that needs to be either proxied or daisy chained for event
    bubbling is managed.
    how does these systems all work....? Reflection ?
    this way i can simulate this on my own custom classes.
    Thanks!

    I have a strong sensation that the OSMF project is quite dead.
    no new submits since 2010, the contact form on the offical OSMF
    project website http://www.opensourcemediaframework.com/
    returns a PHP error.
    and many unanswered questions about OSMF in this forum.
    i think it would be wise to not use OSMF if possible, although
    I'm also stuck with it since we are utilizing HDS/PHDS
    protocols which are utilized in the framework.
    otherwise its quite a head-ache.
    I'm unable to get to a video element coming from a proxied element
    that is being produced via an HDS connection.
    and haven't found any solution that works.

  • I can't seem to get individual elements when comparing 2 arrays using Compare-Object

    My backup software keeps track of servers with issues using a 30 day rolling log, which it emails to me once a week in CSV format. What I want to do is create a master list of servers, then compare that master list against the new weekly lists to identify
    servers that are not in the master list, and vice versa. That way I know what servers are new problem and which ones are pre-existing and which ones dropped off the master list. At the bottom is the entire code for the project. I know it's a bit much
    but I want to provide all the information, hopefully making it easier for you to help me :)
    Right now the part I am working on is in the Compare-NewAgainstMaster function, beginning on line 93. After putting one more (fake) server in the master file, the output I get looks like this
    Total entries (arrMasterServers): 245
    Total entries (arrNewServers): 244
    Comparing new against master
    There are 1 differences.
    InputObject SideIndicator
    @{Agent= Virtual Server in vCenterServer; Backupse... <=
    What I am trying to get is just the name of the server, which should be $arrDifferent[0] or possibly $arrDifferent.Client. Once I have the name(s) of the servers that are different, then I can do stuff with that. So either I am not accessing the array
    right, building the array right, or using Compare-Object correctly.
    Thank you!
    Sample opening lines from the report
    " CommCells > myComCellServer (Reports) >"
    " myComCellServer -"
    " 30 day SLA"
    CommCell Details
    " Client"," Agent"," Instance"," Backupset"," Subclient"," Reason"," Last Job Id"," Last Job End"," Last Job Status"
    " myServerA"," vCenterServer"," VMware"," defaultBackupSet"," default"," No Job within SLA Period"," 496223"," Nov 17, 2014"," Killed"
    " myServerB"," Oracle Database"," myDataBase"," default"," default"," No Job within SLA Period"," 0"," N/A"," N/A"
    Entire script
    # things to add
    # what date was server entered in list
    # how many days has server been on list
    # add temp.status = pre-existing, new, removed from list
    # copy sla_master before making changes. Copy to archive folder, automate rolling 90 days?
    ## 20150114 Created script ##
    #declare global variables
    $global:arrNewServers = @()
    $global:arrMasterServers = @()
    $global:countNewServers = 1
    function Get-NewServers
    Param($path)
    Write-Host "Since we're skipping the 1st 6 lines, create test to check for opening lines of report from CommVault."
    write-host "If not original report, break out of script"
    Write-Host ""
    #skip 5 to include headers, 6 for no headers
    (Get-Content -path $path | Select-Object -Skip 6) | Set-Content $path
    $sourceNewServers = get-content -path $path
    $global:countNewServers = 1
    foreach ($line in $sourceNewServers)
    #declare array to hold object temporarily
    $temp = @{}
    $tempLine = $line.Split(",")
    #get and assign values
    $temp.Client = $tempLine[0].Substring(2, $tempLine[0].Length-3)
    $temp.Agent = $tempLine[1].Substring(2, $tempLine[1].Length-3)
    $temp.Backupset = $tempLine[3].Substring(2, $tempLine[3].Length-3)
    $temp.Reason = $tempLine[5].Substring(2, $tempLine[5].Length-3)
    #write temp object to array
    $global:arrNewServers += New-Object -TypeName psobject -Property $temp
    #increment counter
    $global:countNewServers ++
    Write-Host ""
    $exportYN = Read-Host "Do you want to export new servers to new master list?"
    $exportYN = $exportYN.ToUpper()
    if ($exportYN -eq "Y")
    $exportPath = Read-Host "Enter full path to export to"
    Write-Host "Exporting to $($exportPath)"
    foreach ($server in $arrNewServers)
    $newtext = $Server.Client + ", " + $Server.Agent + ", " + $Server.Backupset + ", " + $Server.Reason
    Add-Content -Path $exportPath -Value $newtext
    function Get-MasterServers
    Param($path)
    $sourceMaster = get-content -path $path
    $global:countMasterServers = 1
    foreach ($line in $sourceMaster)
    #declare array to hold object temporarily
    $temp = @{}
    $tempLine = $line.Split(",")
    #get and assign values
    $temp.Client = $tempLine[0]
    $temp.Agent = $tempLine[1]
    $temp.Backupset = $tempLine[2]
    $temp.Reason = $tempLine[3]
    #write temp object to array
    $global:arrMasterServers += New-Object -TypeName psobject -Property $temp
    #increment counter
    $global:countMasterServers ++
    function Compare-NewAgainstMaster
    Write-Host "Total entries (arrMasterServers): $($countMasterServers)"
    Write-Host "Total entries (arrNewServers): $($countNewServers)"
    Write-Host "Comparing new against master"
    #Compare-Object $arrMasterServers $arrNewServers
    $arrDifferent = @(Compare-Object $arrMasterServers $arrNewServers)
    Write-Host "There are $($arrDifferent.Count) differences."
    foreach ($item in $arrDifferent)
    $item
    ## BEGIN CODE ##
    cls
    $getMasterServersYN = Read-Host "Do you want to get master servers?"
    $getMasterServersYN = $getMasterServersYN.ToUpper()
    if ($getMasterServersYN -eq "Y")
    $filePathMaster = Read-Host "Enter full path and file name to master server list"
    $temp = Test-Path $filePathMaster
    if ($temp -eq $false)
    Read-Host "File not found ($($filePathMaster)), press any key to exit script"
    exit
    Get-MasterServers -path $filePathMaster
    $getNewServersYN = Read-Host "Do you want to get new servers?"
    $getNewServersYN = $getNewServersYN.ToUpper()
    if ($getNewServersYN -eq "Y")
    $filePathNewServers = Read-Host "Enter full path and file name to new server list"
    $temp = Test-Path $filePathNewServers
    if ($temp -eq $false)
    Read-Host "File not found ($($filePath)), press any key to exit script"
    exit
    Get-NewServers -path $filePathNewServers
    #$global:arrNewServers | format-table client, agent, backupset, reason -AutoSize
    #Write-Host ""
    #Write-Host "Total entries (arrNewServers): $($countNewServers)"
    #Write-Host ""
    #$global:arrMasterServers | format-table client, agent, backupset, reason -AutoSize
    #Write-Host ""
    #Write-Host "Total entries (arrMasterServers): $($countMasterServers)"
    #Write-Host ""
    Compare-NewAgainstMaster

    do not do this:
    $arrDifferent = @(Compare-Object $arrMasterServers $arrNewServers)
    Try this:
    $arrDifferent = Compare-Object $arrMasterServers $arrNewServers -PassThru
    ¯\_(ツ)_/¯
    This is what made the difference. I guess you don't have to declare arrDifferent as an array, it is automatically created as an array when Compare-Object runs and fills it with the results of the compare operation. I'll look at that "pass thru" option
    in a little more detail. Thank you very much!
    Yes - this is the way PowerShell works.  You do not need to write so much code once you understand what PS can and is doing.
    ¯\_(ツ)_/¯

  • Array of class objects

    I was wondering how would you declare an array of class objects. Here is my situation:
    I'm working on a project dealing with bank accounts. Each customer has a specific ID and a balance. I have to handle transactions for each customer at different times, so I was thinking that I need an array of class objects; however, I dont know how to initialize them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz

    I was wondering how would you declare an array of
    class objects. Here is my situation:
    I'm working on a project dealing with bank accounts.
    Each customer has a specific ID and a balance. I have
    to handle transactions for each customer at different
    times, so I was thinking that I need an array of
    class objects; however, I dont know how to initialize
    them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz
    HAI
    Use the hashtable
    and store the classObject of each customer with the corresponding Id in it
    and whenever u want to recover a class match the Id and get the corresponding class
    that is the best way to solve ur problem
    Regards
    kamal

  • Array of cfc object help

    I just picked up coldfusion about a month ago, so my
    coldfusion lingo sucks. I have been programming in C++ for over 5
    years now and will be using a lot of C++ terminology to help avoid
    any confusion. I am writing a cfc function that preforms web
    servicing. This function needs to return an object/class that is
    defined in another coldfusion function. I can do this without a
    problem if I only need to return one instance of this object.
    However, I cannot seem to return an array of this object (I need to
    return multiple instances of this object, kind of like a query, but
    for programming purposes it needs to stay as an object).
    It seems that the webservicing function hates my return type.
    If I try to make an array of the object, it does not like array or
    the object as the return type. However, when I take this function
    out of the cfc, and make it a cfm, it gets the array of objects
    just fine. So, I think I am having issues with the return type on
    the <cffunction> tag. So I came up with the idea of creating
    another object which will hold an array of the first object and
    using the second object as the return type. Here is some psuedo
    code of the function I am working on:
    <cffunction name="SelectGames" access="remote"
    returntype="ArrayOfGames" output="false">
    <!-- arguments --->
    <!--- query --->
    <cfobject component = "myArray" name>
    <cfobject component="games" name="test">
    <cfset counter = 0>
    <cfloop query="getevents">
    <cfset counter = counter + 1>
    <cfset test.Game_id = event_id>
    <cfset test.gameDate = eventdate>
    <cfset test.Starttime = starttime>
    <cfset test.Place = place>
    <cfset test.Level = level>
    <cfset test.Sport = sport>
    <cfset test.Gender = division>
    <cfset test.Opponent = opponent_id>
    <cfset test.Type = type>
    <cfset test.Link = spec_name>
    <cfset myArray.gamesArray[counter] = test>
    </cfloop>
    <cfreturn myArray>
    </cffunction>
    It keeps telling me that it does not recognize the return
    type.
    Here are examples of the two objects I am using from the 2
    dif. cfc files:
    <cfcomponent>
    <cfproperty name="gamesArray" type="array">
    </cfcomponent>
    <cfcomponent>
    <cfproperty name="Game_id" type="numeric">
    <cfproperty name="gameDate" type="date">
    <cfproperty name="Starttime" type="string">
    <cfproperty name="Place" type="string">
    <cfproperty name="Level" type="string">
    <cfproperty name="Sport" type="string">
    <cfproperty name="Gender" type="string">
    <cfproperty name="Opponent" type="string">
    <cfproperty name="Type" type="string">
    <cfproperty name="Link" type="string">
    </cfcomponent>
    Feel free to post any questions to clear anything up, I know
    this is confusing and I probably did a poor job of explaining my
    problem. Also, if I throw this code into a cfm and try to make an
    array of games, it works, this is the code I got it to work with:
    <cfset myArray = newArray(1)>
    <cfloop query="getevents">
    <cfset counter = counter + 1>
    <cfset test.Game_id = event_id>
    <cfset test.gameDate = eventdate>
    <cfset test.Starttime = starttime>
    <cfset test.Place = place>
    <cfset test.Level = level>
    <cfset test.Sport = sport>
    <cfset test.Gender = division>
    <cfset test.Opponent = opponent_id>
    <cfset test.Type = type>
    <cfset test.Link = spec_name>
    <cfset myArray[counter] = test>
    </cfloop>
    I guess my problem is I do not know how to specify a type for
    an array.

    The return type of this FUNCTION would be returnType="array".
    No matter
    what kind of data the array contained.
    That's what I get for fast proofing.
    Ian Skinner wrote:
    > I would have to play with your code more if this does
    not clear it up
    > for you, but lets start with this simple concept first.
    >
    > You mentioned "typing the array" several times.
    ColdFusion is typeless,
    > you don't type an array, it is just array. An array of
    strings is the
    > same as an array of integers which is the same as an
    array of objects.
    >
    > So if you had a function something like this.
    >
    > <cffunction returnType="array" ...>
    > <cfset theArray = arrayNew()>
    >
    > <cfloop ...>
    > <cfset arrayAppend(theArray, newObject)>
    > </cfloop>
    >
    > <cfreturn theArray>
    > </cffunction>
    >
    > The return type of this function would be
    returnType="array". No matter what
    > kind of data the array contained.
    >
    > mwiley63 wrote:
    >> I just picked up coldfusion about a month ago, so my
    coldfusion lingo
    >> sucks. I have been programming in C++ for over 5
    years now and will
    >> be using a lot of C++ terminology to help avoid any
    confusion. I am
    >> writing a cfc function that preforms web servicing.
    This function
    >> needs to return an object/class that is defined in
    another coldfusion
    >> function. I can do this without a problem if I only
    need to return
    >> one instance of this object. However, I cannot seem
    to return an
    >> array of this object (I need to return multiple
    instances of this
    >> object, kind of like a query, but for programming
    purposes it needs to
    >> stay as an object).
    >> It seems that the webservicing function hates my
    return type. If I
    >> try to make an array of the object, it does not like
    array or the
    >> object as the return type. However, when I take this
    function out of
    >> the cfc, and make it a cfm, it gets the array of
    objects just fine.
    >> So, I think I am having issues with the return type
    on the
    >> <cffunction> tag. So I came up with the idea
    of creating another
    >> object which will hold an array of the first object
    and using the
    >> second object as the return type. Here is some
    psuedo code of the
    >> function I am working on:
    >>
    >> <cffunction name="SelectGames" access="remote"
    >> returntype="ArrayOfGames" output="false">
    >> <!-- arguments --->
    >> <!--- query --->
    >> <cfobject component = "myArray" name>
    >> <cfobject component="games" name="test">
    >> <cfset counter = 0>
    >> <cfloop query="getevents">
    >> <cfset counter = counter + 1>
    >> <cfset test.Game_id = event_id>
    >> <cfset test.gameDate = eventdate>
    >> <cfset test.Starttime = starttime>
    >> <cfset test.Place = place>
    >> <cfset test.Level = level>
    >> <cfset test.Sport = sport>
    >> <cfset test.Gender = division>
    >> <cfset test.Opponent = opponent_id>
    >> <cfset test.Type = type>
    >> <cfset test.Link = spec_name>
    >> <cfset myArray.gamesArray[counter] = test>
    >> </cfloop>
    >> <cfreturn myArray>
    >> </cffunction>
    >>
    >> It keeps telling me that it does not recognize the
    return type.
    >> Here are examples of the two objects I am using from
    the 2 dif. cfc
    >> files:
    >> <cfcomponent>
    >> <cfproperty name="gamesArray" type="array">
    >> </cfcomponent>
    >> <cfcomponent>
    >> <cfproperty name="Game_id" type="numeric">
    >> <cfproperty name="gameDate" type="date">
    >> <cfproperty name="Starttime" type="string">
    >> <cfproperty name="Place" type="string">
    >> <cfproperty name="Level" type="string">
    >> <cfproperty name="Sport" type="string">
    >> <cfproperty name="Gender" type="string">
    >> <cfproperty name="Opponent" type="string">
    >> <cfproperty name="Type" type="string">
    >> <cfproperty name="Link" type="string">
    >> </cfcomponent>
    >>
    >> Feel free to post any questions to clear anything
    up, I know this is
    >> confusing and I probably did a poor job of
    explaining my problem.
    >> Also, if I throw this code into a cfm and try to
    make an array of
    >> games, it works, this is the code I got it to work
    with:
    >> <cfset myArray = newArray(1)>
    >> <cfloop query="getevents">
    >> <cfset counter = counter + 1>
    >> <cfset test.Game_id = event_id>
    >> <cfset test.gameDate = eventdate>
    >> <cfset test.Starttime = starttime>
    >> <cfset test.Place = place>
    >> <cfset test.Level = level>
    >> <cfset test.Sport = sport>
    >> <cfset test.Gender = division>
    >> <cfset test.Opponent = opponent_id>
    >> <cfset test.Type = type>
    >> <cfset test.Link = spec_name>
    >> <cfset myArray[counter] = test>
    >> </cfloop>
    >>
    >> I guess my problem is I do not know how to specify a
    type for an array.
    >>

  • Importing to Custom Object 1 to blank-out information

    Hi Everyone,
    We recently started using Custom Object 1 and during our initial import there was a field has the wrong information that needs to be overwritten.
    The new field will does not have have information on evey row in the import CSV file, and when we import it, only the rows have information are overwirtten and the blank rows are left with the old info.
    <strong>Original import:</strong>
    <u>Object 1 ID Field 1</u>
    1 aaa
    2 aaa
    3 aaa
    <strong>Second import:</strong>
    <u>Object 1 ID Field 1</u>
    1 bbb
    2 bbb
    3 bbb
    <strong>RESULTS:</strong>
    <u>Object 1 ID Field 1</u>
    1 bbb
    2 aaa
    3 bbb
    Has anyone else experienced this problem? Have you been able to fix it?
    Thanks, Margo

    Margo,
    Have you tried putting a space or a . into your excel spreadsheet and importing that? also a mass update may clear the information?
    regards
    Alex

  • Custom object - data loader issue

    Hello guys.
    I've just attempted to upload a CSV file in order to insert new records to a custom object.
    after some tweaking I've managed to get it to work, the log stated 100% success but no new records appeared.
    I've ran the data loader for "ordinary" objects (account, parts) with full success.
    Any thoughts?
    Thanks,
    Adi Smulian
    [email protected]

    The dataloader will often state 100% this does not mean that all the records were imported correctly. You will need to go to the data import queue to retrieve the findings of the import this will then tell you if you have any errors.

  • Return value of Custom object in HashMap

    I have created a custom object (TableValue) that should represent the key value in aHashMap. When reading data from a file, the custom object should be either a String or a Double. I want the custom object to return the proper type. That is, I am trying to avoid the use of an Object as a key value in the HashMap. However, I want TableValue to return the proper value. Some example code is listed below. My question is this, how do I get TableValue to return the proper type?
    Thanks
    import java.util.HashMap;
    public class Table {
    HashMap<TableValue,Frequency>table=new HashMap<TableValue,Frequency>();
         public void count(TableValue aElement){
              Frequency fq=table.get(aElement);
              if(fq==null){
                   fq=new Frequency();
                   table.put(aElement, fq);
              }else{
                   fq.add();
         public double getCount(TableValue aElement){
              Frequency fq=table.get(aElement);
              if(fq==null){
                   return 0.0;
              }else{
                   return fq.getFrequency();
         public static void main(String[] args) {
              Table tab=new Table();
              tab.count(new TableValue("s"));
              tab.count(new TableValue(5.0));
    public class TableValue {
         private double dValue;
         private String sValue;
         private boolean isDouble=false;
         public TableValue(Object o){
              try{
                   if(o.getClass().getName().equals("java.lang.String")){
                        sValue=(String)o;
                   }else if(o.getClass().getName().equals("java.lang.Double")){
                        dValue=(Double)o;
              }catch(ClassCastException ex){
            //next two methods not correct, can not overload like this
         public double getValue(){
              //want to return a double
              return dValue;
         public String getValue(){
              //want to returna string
              return sValue;
    public class Frequency {
         private double total, cummulativeFrequency;
         public Frequency(){
              total = 1.0;
              cummulativeFrequency = 0.0;
         public void add(){
              total++;
              cummulativeFrequency++;
         public void addCummulativeFrequency(double aLowerCount){
              cummulativeFrequency += aLowerCount;
         public double getFrequency(){
              return total;
         public double getCummulativeFrequency(){
              return cummulativeFrequency;
    }

    OK, thanks to everyone for your help. Here is what I have done. I added equals(), hashCode(), and compareTo().
    My compareTo() method seems a bit sloppy. Basically, I want Strings to appear before Doubles in a sort. Is there a better way to do this?
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.Iterator;
    public class Table {
         HashMap<TableValue,Frequency>table=new HashMap<TableValue,Frequency>();
         public void count(TableValue aElement){
              Frequency fq=table.get(aElement);
              if(fq==null){
                   fq=new Frequency();
                   table.put(aElement, fq);
              }else{
                   fq.add();
         public double getCount(TableValue aElement){
              Frequency fq=table.get(aElement);
              if(fq==null){
                   return 0.0;
              }else{
                   return fq.getFrequency();
         public Object[] getKeyArray(boolean sorted){
              TableValue[] keys=new TableValue[table.size()];
              int i=0;
              for(Iterator iter=table.keySet().iterator();iter.hasNext(); ){
                   keys[i++]=(TableValue)iter.next();
              if(sorted){
                   Arrays.sort(keys);
              return keys;
         public static void main(String[] args) {
              Table tab=new Table();
              tab.count(new TableValue("a"));
              tab.count(new TableValue("a"));
              tab.count(new TableValue("d"));
              tab.count(new TableValue(5.3));
              tab.count(new TableValue(6.123));
              Object[] keys = tab.getKeyArray(true);
              System.out.println("count " + tab.getCount((TableValue)keys[0]));
    public class TableValue implements Comparable{
         private Double dValue;
         private String sValue;
         public TableValue(String sValue){
              this.sValue=sValue;
         public TableValue(double dValue){
              this.dValue=dValue;
         public Double getDoubleValue(){
              return dValue;
         public String getStringValue(){
              return sValue;
         public boolean isDouble(){
              if(dValue!=null) return false;
              return true;
         public boolean equals(Object o) {
              return o.equals(sValue) || o.equals(dValue);
         public int hashCode(){
              int hash=0;
              hash += (null == dValue ? 0 : dValue.hashCode());
              hash += (null == sValue ? 0 : sValue.hashCode());
              return hash;
           public int compareTo(Object anotherTableValue) throws ClassCastException{
                if(!(anotherTableValue instanceof TableValue))
                     throw new ClassCastException("TableValue object expected.");
                //compareTo for two Doubles
                if(((TableValue)anotherTableValue).getDoubleValue()!=null &&
                          this.getDoubleValue()!=null){
                     System.out.println("yes" +((TableValue)anotherTableValue).getDoubleValue()!=null &&
                               this.getDoubleValue()!=null);
                     Double anotherDouble=((TableValue)anotherTableValue).getDoubleValue();
                     return this.dValue.compareTo(anotherDouble);
                //compareTo for two Strings
                if(((TableValue)anotherTableValue).getStringValue()!=null &&
                          this.getStringValue()!=null){
                     String anotherString=((TableValue)anotherTableValue).getStringValue();
                     return this.sValue.compareTo(anotherString);
                //sort Strings before Doubles
                if(((TableValue)anotherTableValue).getStringValue()!=null &&
                          this.getStringValue()==null){
                     return 1;
                //sort Strings before Doubles
                return -1;
           public String toString(){
                if(dValue==null){
                     return sValue;
                return dValue.toString();
    }

Maybe you are looking for