AyaNova service management & work order software
AyaNova Support Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Retrieving, Editing and Saving the contents... Expand / Collapse
Author
Message
Posted 11/27/2009 9:10:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/30/2009 6:58:00 AM
Posts: 8, Visits: 55
John

Using the information in response to post 4902 I was able to create an AyaFileList of all the embedded files from a selected client’s WiKi page. However, the list created with the AyaFileList method “GetList(Guid)” is only returning the AyaFileListInfo Structure data. This information does not contain a Guid ID for the file that I want to access.

Without the desired files ID how do I read embedded files content?

If I assume I can get a files ID and gain access to the file object using the AyaFile Class; how should I process to read and write to the file?

The “GetContent” method of the AyaFile Class has the type “MemoryStream”. Do I need to create a MemoryStream object to work with the content of embedded WiKi page files?

Your help is appreciated.
Post #4925
Posted 11/27/2009 10:01:43 AM
AyaNova Development & Support

AyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & Support

Group: Administrators
Last Login: 2/11/2010 12:27:00 PM
Posts: 140, Visits: 493
GLENN_OVIS (11/27/2009)
John

Using the information in response to post 4902 I was able to create an AyaFileList of all the embedded files from a selected client’s WiKi page. However, the list created with the AyaFileList method “GetList(Guid)” is only returning the AyaFileListInfo Structure data. This information does not contain a Guid ID for the file that I want to access.

Without the desired files ID how do I read embedded files content?

If I assume I can get a files ID and gain access to the file object using the AyaFile Class; how should I process to read and write to the file?

The “GetContent” method of the AyaFile Class has the type “MemoryStream”. Do I need to create a MemoryStream object to work with the content of embedded WiKi page files?

Your help is appreciated.


Hi Glen, AyaFile object is not a direct store you can read and write to like a disk, it's purpose is only to retrieve the file from the database and store it to the database. You can modify the file in memory in your app using a memorystream or you can work with it on disk in your app or others using the static method to write the file to disk. In either case you then need to use the SetContent method (and save of course) to update the file to database.


AyaFileListInfo contains a field called: LT_O_AyaFile which is of type GridNameValueCellItem which contains both a Display value for grids and an internal ID Value Guid field for doing things with it. See the API reference http://api.ayanova.com/ scroll down the left to GridNameValueCellItem it's commonly used for all read only lists in AyaNova api that are displayed in grids.

The AyaFile ID is in the Value field of the LT_O_AyaFile field.

If you want to work with an AyaFile on disk you can save it to disk using the AyaFile static method GetAndWriteFileToDisk also documented in the api under AyaFile. Provide it with the file Guid and a path and optional new file name and it's done.

If you want to work with it in memory inside your app in code then use the GetContent which returns the file in a memorystream.

To update an existing AyaFile use the method SetContent which accepts a generic stream so you can set it from a file or from a memorystream or from any stream based source.


Example:
AyaFileList afl = AyaFileList.GetList(TheWikiPage.ID);
foreach (AyaFileList.AyaFileListInfo i in afl)
{
//Do it in memory way
AyaFile af = AyaFile.GetItem(i.LT_O_AyaFile.Value);
MemoryStream ms = af.GetContent();
//do something with the content
af.SetContent(ms);
af.Save();

//OR

//Do it on disk way
//like this if you just need to write it out once
AyaFile.GetAndWriteFileToDisk(i.LT_O_AyaFile.Value, "c:\\temp\\", "OptionalNewFilename.tmp");

//or like this if you want to write it out then save it back later
AyaFile af = AyaFile.GetItem(i.LT_O_AyaFile.Value);
af.WriteToDisk("c:\\temp\\", "OptionalNewFilename.tmp");
//work with the file on disk until ready to store it back in AyaFile..
af.SetContent(File.ReadAllBytes("c:\\temp\\whateverthenameofthefileis.xxx"));
af.Save();

}
Post #4926
Posted 11/30/2009 6:18:44 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/30/2009 6:58:00 AM
Posts: 8, Visits: 55
John

The examples you provided helped a lot. Sometimes an example can bridge the gap between what the API documentation is saying and what I am understanding. With this, I think I have all the pieces to complete my puzzle (project). Thanks Glenn
Post #4930
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: AyaNova Sales & Support, John

Permissions Expand / Collapse

All times are GMT -8:00, Time now is 2:35pm

Powered by InstantForum.NET v4.1.4 © 2010
Execution: 0.031. 9 queries. Compression Disabled.