Highlighted
kamayd2
1 Nickel

Error -10006 Wrong parameter detected when reading from Centera.

I'm having issues when reading from Centera. What I am doing wrong? Thanks.

public static void StoreContent()

        {

            try

            {

                int fileSize;

                if (File.Exists(fileName))

                {

                    fileSize = (int)new FileInfo(fileName).Length;

                }

                else

                {

                    Console.WriteLine("The file does not exits");

                    return;

                }

                FPPool.EmbeddedBlobThreshold = fileSize;

                FPPool thePool = new FPPool(defaultCluster);

                // Create the clip

                FPClip clipRef = new FPClip(thePool, fileName);

                clipRef.RetentionExpiry = DateTime.Now.AddDays(10);

                clipRef.SetAttribute("OriginalFilename", fileName);

                FPTag fileTag = clipRef.AddTag("StoreContentObject");

                fileTag.SetAttribute("filename", fileName);

                // Write the content of the file to the Centera

                FPStream streamRef = new FPStream(fileName, fileSize);

                fileTag.BlobWrite(streamRef, FPMisc.OPTION_CLIENT_CALCID);

                streamRef.Close();

                fileTag.Close();

                fileTag = clipRef.AddTag("TestTag");

                fileTag.SetAttribute("fileCabinetGuid", "52d9cf57-7261-472a-b6d9-a8cdd30d1d27");

                fileTag.SetAttribute("attr2", "a second attribute");

                fileTag.SetAttribute("anotherattr", "the third attribute");

                fileTag.Close();

                WriteIdToFile(clipRef.Write());

              

                clipRef.Close();

                thePool.Close();

            }

            catch (FPLibraryException e)

            {

                ErrorInfo err = e.errorInfo;

                FPLogger.ConsoleMessage("\nException thrown in FP Library: Error " + err.error + " " + err.message);

            }

        }

        public static void RetrieveContent()

        {

            try

            {

                String clipID = GetLastIDStoredIfAny();

                if (clipID == null) return;

                FPPool thePool = new FPPool(defaultCluster);

               FPClip clipRef = new FPClip(thePool, clipID, FPMisc.OPEN_ASTREE);// The Exception is thrown here!! Error -10006 Wrong parameter detected. The id is something like this 50R23H3160SJ2Re8K7DE934G318BHqBTnKQVA9F0bYEKsFROK9zYN4

                FPLogger.ConsoleMessage("\nThe clip retention expires on " + clipRef.RetentionExpiry);

                // Iterate across the  clip metadata

                foreach (FPAttribute attr in clipRef.Attributes)

                {

                    FPLogger.ConsoleMessage(attr.ToString() + "\n");

                }

                // Iterate across the Tag (and their Attr) collections

                foreach (FPTag tg in clipRef.Tags)

                {

                    FPLogger.ConsoleMessage(tg.ToString() + "\n");

                    foreach (FPAttribute a in tg.Attributes)

                    {

                        FPLogger.ConsoleMessage(a.ToString() + "\n");

                    }

                }

                FPTag t = (FPTag)clipRef.Tags[0];

                if (t.ToString() == "StoreContentObject")

                {

                    String outfile = clipRef.ClipID + ".Tag." + 0;

                    FPStream streamRef = new FPStream(outfile, "wb");

                    t.BlobRead(streamRef, FPMisc.OPTION_DEFAULT_OPTIONS);

                    streamRef.Close();

                    FPLogger.ConsoleMessage("\nThe Blob has been stored into " + outfile);

                    t.Close();

                    t = (FPTag)clipRef.Tags[1];

                    //Do the same for the second tag

                    outfile = clipRef.ClipID + ".Tag." + 1;

                    streamRef = new FPStream(outfile, "wb");

                    t.BlobRead(streamRef, FPMisc.OPTION_DEFAULT_OPTIONS);

                    streamRef.Close();

                    FPLogger.ConsoleMessage("\nThe Blob has been stored into " + outfile);

                    FPLogger.ConsoleMessage("\nThe CDF has been saved to " + clipRef.ClipID + ".xml");

                    streamRef = new FPStream(clipRef.ClipID + ".xml", "wb");

                    clipRef.RawRead(streamRef);

                    // We could retrieve the blob into a buffer - we know we stored

                    // a string in the StoreContent sample so let's get it back..

                    int blobSize = (int)t.BlobSize;

                    UTF8Encoding converter = new UTF8Encoding();

                    byte[] buffer = new byte[blobSize];

                    IntPtr source = Marshal.AllocHGlobal(blobSize);

                    streamRef = new FPStream(source, blobSize, FPStream.StreamDirection.OutputFromCentera);

                    t.BlobRead(streamRef);

                    Marshal.Copy(source, buffer, 0, blobSize);

                    Marshal.FreeHGlobal(source);

                    FPLogger.ConsoleMessage("\n" + converter.GetString(buffer));

                    streamRef.Close();

                }

                else

                    FPLogger.ConsoleMessage("\nApplication Error: Not A C-Clip Created By StoreContent Example");

            }

            catch (FPLibraryException e)

            {

                ErrorInfo err = e.errorInfo;

                FPLogger.ConsoleMessage("\nException thrown in FP Library: Error " + err.error + " " + err.message);

            }

        }

        public static string GetLastIDStoredIfAny() //helper method

        {

            String clipID = null;

            string fileNameClip = fileName + ".clipID";

            if (File.Exists(fileNameClip))

            {

                System.IO.StreamReader file = new StreamReader(fileNameClip);

                string line = "";

                while ((line = file.ReadLine()) != null)

                {

                    clipID = line;

                    break;

                }

                file.Close();

            }

            else Console.WriteLine("File no found at '" + fileNameClip + "'");

            return clipID;

        }

        public static void WriteIdToFile(string clipID)  //helper method

        {

            /* Write the Clip ID to the output file, "inputFileName.clipID" */

            String outFileName = fileName + ".clipID";

            FPLogger.ConsoleMessage("\nThe C-Clip ID of the content is " + clipID);

            FileStream outFile = new FileStream(outFileName, FileMode.Create);

            BinaryWriter outWriter = new BinaryWriter(outFile);

            outWriter.Write(clipID);

            outWriter.Close();

            outFile.Close();

        }

0 Kudos
4 Replies
pinnas
2 Iron

Re: Error -10006 Wrong parameter detected when reading from Centera.

Hi,

You may refer to KB no "000173350" for this issue.

0 Kudos
kamayd2
1 Nickel

Re: Re: Error -10006 Wrong parameter detected when reading from Centera.

What does that mean? Sorry, I am not following. refer to KB no 000173350?

0 Kudos
kamayd2
1 Nickel

Re: Re: Error -10006 Wrong parameter detected when reading from Centera.

I am trying to find the article following this KB articles. but without success.

0 Kudos
kamayd2
1 Nickel

Re: Error -10006 Wrong parameter detected when reading from Centera.

I was thinking that the clipID was a valid one but that was not the case. I change the code to use StreamWriter/StreamReader when saving the Id and It is working fine now. Sorry about this.

0 Kudos