예제 #1
0
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            string At = "SKU Library";

            try
            {
                if (!properties.ListTitle.Contains("SKU Library"))
                {
                    //TODO  [pr4-3435] Item add event - selective handling mechanism. http://itrserver/Bugs/BugDetail.aspx?bid=3435
                    base.ItemAdded(properties);
                    return;
                }
                this.EventFiringEnabled = false;
                if (properties.ListItem.File == null)
                {
                    throw new System.ArgumentException("Import of SKU xml message failed because the file is empty.", "File");
                }
                At = "using";
                using (Stream _strm = properties.ListItem.File.OpenBinaryStream())
                    using (Entities edc = new Entities(properties.WebUrl))
                    {
                        String message = String.Format("Import of the SKU message {0} starting.", properties.ListItem.File.Name);
                        ActivityLogCT.WriteEntry(edc, m_Title, message);
                        At = "ImportDocument";
                        SKUXml xml = SKUXml.ImportDocument(_strm);
                        At = "GetAtIndex";
                        Document entry = Element.GetAtIndex <Document>(edc.SKULibrary, properties.ListItem.ID);
                        At = "GetXmlContent";
                        SKUGetFromXML.GetXmlContent(xml, edc, entry, (object obj, ProgressChangedEventArgs progres) => { At = (string)progres.UserState; });
                        ActivityLogCT.WriteEntry(edc, m_Title, String.Format("Import of the sku message {0} finished", properties.ListItem.File.Name));
                    }
            }
            catch (InputDataValidationException _ioex)
            {
                _ioex.ReportActionResult(properties.WebUrl, properties.ListItem.File.Name);
                string _fileName = GetFileName(properties);
                ActivityLogCT.WriteEntry(m_Title, String.Format("SKU message {0} import has been stoped because of errors.", _fileName), properties.WebUrl);
            }
            catch (Exception ex)
            {
                string _pattern  = @"SKU message {2} import has been stoped because of an unexpected fatal error <b>{0}</b> at: <b>{1}</b>";
                string _fileName = GetFileName(properties);
                ActivityLogCT.WriteEntry(m_Title, String.Format(_pattern, ex.Message, At, _fileName), properties.WebUrl);
            }
            finally
            {
                this.EventFiringEnabled = true;
            }
            base.ItemAdded(properties);
        }
예제 #2
0
        private static SKUCutfiller SKUCutfiller(CutfillerMaterialxML xmlDocument, Document parent, Entities edc, List <String> warnings)
        {
            SKUCutfiller _ret = new SKUCutfiller()
            {
                ProductType  = ProductType.Cutfiller,
                BlendPurpose = String.IsNullOrEmpty(xmlDocument.BlendPurpose) ? String.Empty : xmlDocument.BlendPurpose
            };

            if (!_ret.ProcessData(String.Empty, String.Empty, edc, warnings))
            {
                return(null);
            }
            SKUGetFromXML.UpdateSKUCommonPart(_ret, xmlDocument, parent);
            return(_ret);
        }
예제 #3
0
        private static SKUCigarette SKUCigarette(CigarettesMaterialxML xmlDocument, Document parent, Entities edc, List <String> warnings)
        {
            bool         _menthol = xmlDocument.IsMenthol;
            SKUCigarette _ret     = new SKUCigarette()
            {
                ProductType     = ProductType.Cigarette,
                Brand           = xmlDocument.Brand_Description,
                Family          = xmlDocument.Family_Des,
                Menthol         = xmlDocument.Menthol,
                MentholMaterial = _menthol,
                PrimeMarket     = xmlDocument.Prime_Market,
            };

            if (!_ret.ProcessData(xmlDocument.Cigarette_Length, xmlDocument.Filter_Segment_Length, edc, warnings))
            {
                return(null);
            }
            SKUGetFromXML.UpdateSKUCommonPart(_ret, xmlDocument, parent);
            return(_ret);
        }