Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Error with IPortableError with IPortable's Import Module
Previous
 
Next
New Post
11/22/2006 9:53 AM
 
Hello, all.

I'm attempting to create my first DotNetNuke module in C#.  I based my module (a parent/child database app) on the C# Survey Module example, and have enjoyed great success in adding and modifying both parent and child records.

However, when I go to import XML data (which I obtained from an existing PHP module and patterned after my DNN module's export file), I get an unextremely unhelpful "An error occurred during the import" message.  Additionally, I am returned to the "import module" dialog where the XML file is now listed twice in the drop down box.

Below is an excerpt of my XML data file:

<?xml version="1.0" encoding="UTF-8" ?><content type="Rga" version="01.00.00"><Rgas>
  <Rga>
    <CreatedByUser>???</CreatedByUser>
    <CreatedDate>???</CreatedDate>
    <Customer>???</Customer>
    <ShipToCustomer>???</ShipToCustomer>
    <Phone>???</Phone>
    <RgaNumber>???</RgaNumber>
    <IssueDate>???</IssueDate>
    <AcquisitionDate>???</AcquisitionDate>
    <DispositionDate>???</DispositionDate>
    <RgaParts>
      <RgaPart>
        <PartNumber>???</PartNumber>
        <QtyReceived>???</QtyReceived>
        <QtyRga>???</QtyRga>
        <Comments>???</Comments>
        <Action>???</Action>
      </RgaPart>
    </RgaParts>
  </Rga>
</Rgas></content>

Each RGA will have certain parent fields, such as customer info and dates.  Additionally, each parent record may include one or more "child" RgaParts.

Here is the IPortable members that I have altered from the C# Survey module.

        #region IPortable Members

        string DotNetNuke.Entities.Modules.IPortable.ExportModule(int ModuleID)
        {
            StringBuilder strXML = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.OmitXmlDeclaration = true;
            XmlWriter Writer = XmlWriter.Create(strXML, settings);

            // Outer Loop - To build the Rgas
            List<RgaInfo> colRgas = GetRgas(ModuleID);
            if ((colRgas.Count > 0))
            {
                Writer.WriteStartElement("Rgas");

                foreach (RgaInfo colRgaInfo in colRgas)
                {
                    Writer.WriteStartElement("Rga");
                   
                    Writer.WriteElementString("CreatedByUser", colRgaInfo.CreatedByUser.ToString());
                    Writer.WriteElementString("CreatedDate", colRgaInfo.CreatedDate.ToShortDateString());
                    Writer.WriteElementString("Customer", colRgaInfo.Customer);
                    Writer.WriteElementString("ShipToCustomer", colRgaInfo.ShipToCustomer);
                    Writer.WriteElementString("Phone", colRgaInfo.Phone);
                    Writer.WriteElementString("RgaNumber", colRgaInfo.RgaNumber.ToString());
                    Writer.WriteElementString("IssueDate", colRgaInfo.IssueDate.ToShortDateString());
                    Writer.WriteElementString("AcquisitionDate", colRgaInfo.AcquisitionDate.ToShortDateString());
                    Writer.WriteElementString("DispositionDate", colRgaInfo.DispositionDate.ToShortDateString());

                    // Inner Loop - To build the Parts for each Rga
                    List<RgaPartInfo> colRgaParts = RgaPartController.GetRgaParts(colRgaInfo.RgaId);
                    if ((colRgaParts.Count > 0))
                    {
                        Writer.WriteStartElement("RgaParts");
                       
                        foreach (RgaPartInfo colRgaPartInfo in colRgaParts)
                        {
                            Writer.WriteStartElement("RgaPart");
                                                       
                            Writer.WriteElementString("PartNumber", colRgaPartInfo.PartNumber);
                            Writer.WriteElementString("QtyReceived", colRgaPartInfo.QtyReceived.ToString());
                            Writer.WriteElementString("QtyRga", colRgaPartInfo.QtyRga.ToString());
                            Writer.WriteElementString("Comments", colRgaPartInfo.Comments);
                            Writer.WriteElementString("Action", colRgaPartInfo.Action);

                            Writer.WriteEndElement();
                        }                       
                       
                        Writer.WriteEndElement();
                    }
                   
                    Writer.WriteEndElement();
                }

                Writer.WriteEndElement();

                Writer.Close();
            }
            else
            {
                //  There is nothing to export
                return String.Empty;
            }
            return strXML.ToString();
        }

        void DotNetNuke.Entities.Modules.IPortable.ImportModule(int ModuleID, string Content, string Version, int UserID)
        {
            //Outer Loop - To insert the Rgas           
            XmlNode xmlRgas = DotNetNuke.Common.Globals.GetContent(Content, "Rgas");           
            foreach (XmlNode xmlRga in xmlRgas)
            {
                RgaInfo colRgaInfo = new RgaInfo();

                colRgaInfo.ModuleId = ModuleID;
                colRgaInfo.CreatedByUser = Convert.ToInt32(xmlRga["CreatedByUser"].InnerText);
                colRgaInfo.CreatedDate = Convert.ToDateTime(xmlRga["CreatedDate"].InnerText);
                colRgaInfo.Customer = xmlRga["Customer"].InnerText;
                colRgaInfo.ShipToCustomer = xmlRga["ShipToCustomer"].InnerText;
                colRgaInfo.Phone = xmlRga["Phone"].InnerText;
                colRgaInfo.RgaNumber = xmlRga["RgaNumber"].InnerText;
                colRgaInfo.IssueDate = Convert.ToDateTime(ConvertNullInteger(xmlRga["IssueDate"].InnerText));
                colRgaInfo.AcquisitionDate = Convert.ToDateTime(ConvertNullInteger(xmlRga["AcquisitionDate"].InnerText));
                colRgaInfo.DispositionDate = Convert.ToDateTime(ConvertNullInteger(xmlRga["DispositionDate"].InnerText));

                int intCurrentRga = AddRga(colRgaInfo);

                //Inner Loop - To insert the Rga Parts
                XmlNode xmlRgaParts = xmlRga.SelectSingleNode("RgaParts");
                foreach (XmlNode xmlRgaPart in xmlRgaParts)
                {
                    RgaPartInfo RgaPartInfo = new RgaPartInfo();
                   
                    RgaPartInfo.RgaId = intCurrentRga;
                    RgaPartInfo.PartNumber = xmlRgaPart["PartNumber"].InnerText;
                    RgaPartInfo.QtyReceived = Convert.ToInt32(xmlRgaPart["QtyReceived"].InnerText);
                    RgaPartInfo.QtyRga = Convert.ToInt32(xmlRgaPart["QtyRga"].InnerText);
                    RgaPartInfo.Comments = xmlRgaPart["Comments"].InnerText;
                    RgaPartInfo.Action = xmlRgaPart["Action"].InnerText;
                   
                    RgaPartController.AddRgaPart(RgaPartInfo);
                }
            }
        }

        #endregion

Can someone please clue me in on what I'm doing wrong?

Thank you in advance,

~Josh
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Error with IPortableError with IPortable's Import Module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out