Esempio n. 1
0
        /// <summary>
        /// Parse CSV file that is a Catalog File, a Store File or a combination of Catalog and Store File.
        /// Upload created Catalog and Store Files to Twofish returning the XML results form Twofish.
        /// </summary>
        /// <param name="itemInfo">ItemsInfo, used for the for the the IP Address.</param>
        /// <param name="fileData">PostFile The CSV file</param>
        /// <param name="commmonKeyValue">CommmonKeyValues</param>
        /// <param name="baseAddress">BaseAddress</param>
        /// <returns>An XML document containing the response from Catalog and or Store uploads as returned by Twofish.</returns>
        public XmlDocument UploadCatalogStore(ItemsInfo itemInfo, PostFile fileData, CommmonKeyValues commmonKeyValue, BaseAddress baseAddress)
        {
            XmlDocument response = null;

            try
            {
                response = new XmlDocument();
                response.LoadXml("<response></response>");

                fileData.RemoveLeadingSpacesAndLines();

                PostFile catalogFile = CreateCatalogUpload(fileData);
                if (catalogFile.FileData != null)
                {
                    Catalog     catalogCommand  = new Catalog();
                    XmlDocument catalogResponse = catalogCommand.CreateCatalog(itemInfo, catalogFile, commmonKeyValue, baseAddress);
                    AddToResponse(response, "/response", "Catalog", catalogResponse);
                }

                StoreInfo storeInfo = new StoreInfo();
                storeInfo.IpAddress = itemInfo.IPAddress;

                string[] storeNameArray = FindStoreNames(fileData);

                if (storeNameArray != null)
                {
                    foreach (string storeName in storeNameArray)
                    {
                        Store       storeCommand  = new Store();
                        PostFile    storeFile     = CreateStoreUpload(fileData, storeName);
                        XmlDocument storeResponse = storeCommand.StoreBulkLoad(storeInfo, storeFile, commmonKeyValue, baseAddress);
                        AddToResponse(response, "/response", storeName, storeResponse);
                    }
                }
            }

            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("UploadCatalogStore", ex);
            }

            return(response);
        }
Esempio n. 2
0
        /// <summary>
        /// Parse CSV file that is a Catalog File, a Store File or a combination of Catalog and Store File.
        /// This is to be able to review (create, test) the files to uploaded without doing the upload.
        /// </summary>
        /// <param name="fileData">PostFile CSV file</param>
        /// <returns>Ouputs a XML document containing the Catalog and or Store upload files.</returns>
        public XmlDocument GetUploadCatalogStoreFile(PostFile fileData)
        {
            XmlDocument response = null;

            try
            {
                response = new XmlDocument();
                response.LoadXml("<response></response>");

                fileData.RemoveLeadingSpacesAndLines();

                PostFile catalogFile = CreateCatalogUpload(fileData);
                if (catalogFile != null)
                {
                    AddXmlNodeFromFileData(response, "/response", "Catalog", catalogFile.FileData.ToArray());
                }

                string[] storeNameArray = FindStoreNames(fileData);

                if (storeNameArray != null)
                {
                    foreach (string storeName in storeNameArray)
                    {
                        PostFile storeFile = CreateStoreUpload(fileData, storeName);
                        AddXmlNodeFromFileData(response, "/response", storeName, storeFile.FileData.ToArray());
                    }
                }
            }

            catch (Exception ex)
            {
                response = CreateErrorDoc(ex.Message);
                logError("GetUploadCatalogStoreFile", ex);
            }

            return(response);
        }