Example #1
0
        private static void GetXmlContent
            (MaterialXml[] material, Entities edc, Document parent, CreateMaterialXml creator, ProgressChangedEventHandler progressChanged)
        {
            List <SKUCommonPart> entities = new List <SKUCommonPart>();
            List <string>        warnings = new List <string>();
            int _entries    = 0;
            int _newEntries = 0;

            foreach (MaterialXml item in material)
            {
                try
                {
                    _entries++;
                    progressChanged(null, new ProgressChangedEventArgs(1, "Processing: " + item.GetMaterial()));
                    SKUCommonPart entity = SKUCommonPart.Find(edc, item.GetMaterial());
                    if (entity != null)
                    {
                        continue;
                    }
                    SKUCommonPart sku = creator(item, parent, edc, warnings);
                    if (sku != null)
                    {
                        _newEntries++;
                        entities.Add(sku);
                    }
                }
                catch (Exception ex)
                {
                    string message = String.Format("Cannot create: {0}:{1} because of the error: {2}", item.GetMaterial(), item.GetMaterialDescription(), ex.Message);
                    ActivityLogCT.WriteEntry(edc, "SKU entry error", message);
                }
            }
            if (entities.Count > 0)
            {
                edc.SKU.InsertAllOnSubmit(entities);
                progressChanged(null, new ProgressChangedEventArgs(1, "Submiting Changes"));
                edc.SubmitChanges();
            }
            if (warnings.Count > 0)
            {
                throw new InputDataValidationException("SKU message import errors.", "XML import", new ErrorsList(warnings, true));
            }
            string _pattern = "Finished content analysis, there are {0} entries, {1} new entries, {2} erroneous entries";

            ActivityLogCT.WriteEntry("SKU Message Import", String.Format(_pattern, _entries, _newEntries, warnings.Count), edc.Web);
        }
Example #2
0
 private static void UpdateSKUCommonPart(SKUCommonPart skuCommonPart, MaterialXml xml, Document parent)
 {
     skuCommonPart.SKULibraryIndex = parent;
     skuCommonPart.SKU             = xml.GetMaterial();
     skuCommonPart.Title           = xml.GetMaterialDescription();
 }