Hi Adrian,

Thanks for the code you gave.  It is something which could probably help me out.

You mentioned that you have web service calls which returns a dataset and you 
are casting directly into an arrayCollection. Would you care to show some 
examples?  I am still quite new to Flex and it would extremely be helpful on my 
learning if you could show me some sample codes of achieving this?

I am already on the horizon thinking of a .NET webservice call, returning a 
dataset.  The dataset is casted into an ArrayCollection on Flex.  The same 
arraycollection is then modified (processed) on Flex app, and returned to the 
Webservice.  The web service then converts back the arraycollection sent by the 
flex app into a dataset. The dataset can then be processed by the web service 
to check if updates/deletes have been made and the necessary CRUD operations 
can then be performed based on the underlying data. Quite straightforward. Is 
this possible?

Thanks.

Regards,
Angelo


________________________________
From: Adrian Williams <[email protected]>
To: [email protected]
Sent: Monday, 8 June, 2009 21:12:05
Subject: Re: [flexcoders] Flex and .NET





Hi there...

    We have a rather large RIA using C#.Net as the backend...and we have a 
large number of arrayCollections and dataGrids/advancedD ataGrids. ...

    We don't massage any of the data that we are passing with our web 
services...we literally pass as as it's created...i. e. as an Array or as a 
Object...

    For example, we may have an AdvancedDataGridtha t is asking for data from 
our web service...in our .net code we'd simply have something like:

    public List<MainClass> BuildTheArray( string Group, string Admin)
    {
          List<MainClass> configs = new List<MainClass>();

          SqlParameters[ ] sqlParams = new SqlParameters[ 2];

          sqlParams[0] = new SqlParameter( "@Group", Group);
          sqlParams[1] = new SqlParameter( "@Admin", Admin);

          try
          {
                using (SqlDataReader dr = (SqlDataReader) DB.Instance( 
).ExecuteReader( "main_stored_ procedure" , sqlParams))
                {
                    while (dr != null && dr.Read())
                    {
                        configs.Add( new MainClass(
                            Convert.ToString( dr["Name" ]),
                            Convert.ToString( dr["Email" ]),
                            etc...
                    }
                }
          }
          return configs;
    }

    Then in our Flex webservice def, we are defining the result as "Object" 
(which I've seen a number of folks sugges E4X, but I've not delved into the 
pros/cons of this).  

        <mx:operation name="GetConfigs" resultFormat= "object" 
result="getConfigsR esult(event) " />

    Now, since it's an object, in our web service result handler, you can cast 
it a number of ways, but for the list as created above on the .net side and 
since we are putting this data in an AdvancedDataGrid, we simply say:
            
            private function getConfigsResult( event:ResultEven t):void
            {
                configs = event.result as ArrayCollection;
                ourDataGrid. dataProvider = configs;
            }
    
    Generally speaking, out of the 100+ web service calls we have, any that 
return any kind of dataset we cast directly as an Array, ArrayCollection or 
Object.  

    Now that said, we have seen something that is aggravating. ..with large 
datasets, we see a lag in the transport time over our web service.  For 
example, we have a data set that returns 5000 rows of 125 columns of data...our 
T-SQL stored proc generates the data set in 6 seconds or less but then it still 
takes anywhere from 45s to 1.5m to transport that dataset to the client 
side...and that's over a fast connection.. .then, once it's in the client side, 
depending on how much custom rendering we are doing, it takes up to 10-15 sec's 
to render the data.  So we have a bottleneck in our web service that causes a 
lengthy delay on large data sets....we are still researching on why this is 
happening and the fix but just wanted to let you know as a heads up.

-HTH
-adrian
   
          

Sam Lai wrote: 
Considering the time required for serialization/ deserialization, using
something like webORB would improve parsing time, as it uses a binary
format which can be parsed more easily than a text format. But unless
you're using large datasets/doing lots of web service calls, the
advantages are probably negligible.

Are you transmitting everything in the array collection back to the
web service, or just the IDs of the selected rows? Transferring
everything including the row data would remove the need for another
database hit, but for large datasets, that could be quite a bit of
traffic. I'd say it would be better just to transmit the IDs back to
the webservice, and let the webservice hit the database for the row
data (some caching on the server-side would help too).

2009/6/8 Angelo Anolin <angelo_anolin@ yahoo.com>:
>
>
>
> Hi Sam,
>
> Thanks for your reply.
>
> As of now, I actually prefer to utilize what I know on .NET and what I am
> learning on Flex. Adding another utility (Web Orb) in my learning process
> may complicate things a bit.  I might consult this later if I feel that the
> needs for is getting tremendous.
>
> Anyway, I am actually able to generate the report from what I am currently
> doing (no error encountered) , where the ArrayCollection I am parsing into a
> delimited string, passing the string to the webservice call, and letting the
> webservice de-serialize the string to populate a Crystal report document
> which I subsequentlt display in another browser window which I call from the
> Flex application.
>
> I mentioned that I did not feel it is the "BEST" way because I am literally
> storing all datagrid (report) information in a string variable.  Assuming
> for example that the data displayed in the datagrid is quite huge, then
> creating the delimited string would take some time and additional processing
> time could also be consumbed by the back end web service to parse the string
> and populate the report.
>
> As of now, this is what the application does.
> 1. Flex App calls a webservice to retrieve data.
> 2. WebService responds by sending back a dataset which is returned as a
> string (via Dataset.GetXML method of .NET).
> 3. Flex App gets the service response, converts the string into an XML.
> 4. Flex App converts the XML data into an ArrayCollection which is bound to
> the datagrid.
> * Please note that I used array collection here for the search/filter
> functionality of the datagrid.
> 5. When generating print out of the data displayed in the datagrid, Flex
> would then serialize the ArrayCollection into a delimited string and send it
> to the web service.
> 6. Web Service would then de-serialize (or parse) the string, populate a
> .NET dataset which is the datasource for the Crystal report.
> 7. Crystal report is bound and PDF report is generated.
> 8. Flex displays via external javascript call the PDF report generated.
>
> Is there a better way for the ArrayCollection to be sent to the webservice,
> the webservice in turn would just convert it to dataset and the dataset is
> immediately bound to the Crystal report?
>
> Thanks.
>
> Regards,
>
> Angelo
> ____________ _________ _________ __
> From: Sam Lai <samuel....@gmail. com>
> To: flexcod...@yahoogro ups.com
> Sent: Monday, 8 June, 2009 8:49:36
> Subject: Re: [flexcoders] Flex and .NET
>
> 2009/6/8 Angelo Anolin <angelo_anolin@ yahoo.com>:
>
>> I feel that this is probably not the "BEST" way of doing this.  I tried
>> initially to pass an XML delimmited string, but .NET seems to read XML
>> differently( ?) from Flex.
>
> I'd say XML would be a good way of doing it. What kind of errors are
> you getting, and how are you making the web service call?
>
> The other option is to use AMF, a native messaging format for
> Flash/Flex. This I believe would save you the effort of serializing
> and deserializing - it does it for you, among other things.
>
> http://www.themidni ghtcoders. com/products/ weborb-for- net/overview. html
>
>
>
> 




      

Reply via email to