예제 #1
0
        public static AssetNotification ToNotification(this XmlElement asset)
        {
            AssetNotification a = new AssetNotification();

            try
            {
                a.AssetNumber  = asset.GetAttribute("AssetNumber").Sanitize();
                a.IsNotified   = Convert.ToBoolean(asset.GetAttribute("IsNotified").Sanitize());
                a.LastNotified = DateTime.Parse(asset.GetAttribute("LastNotified").Sanitize());
                a.Time         = DateTime.Parse(asset.GetAttribute("Time").Sanitize());
                var n30 = asset.GetAttribute("Is30day").Sanitize();
                var n15 = asset.GetAttribute("Is15Day").Sanitize();
                a.Is30Day = Convert.ToBoolean(n30);
                a.Is15Day = Convert.ToBoolean(n15);
                XmlNodeList elemList = asset.GetElementsByTagName("Email");
                foreach (XmlElement elem in elemList)
                {
                    EmailAddress em = new EmailAddress();
                    em.Email = asset.GetAttribute("Email").Sanitize();
                    em.Name  = asset.GetAttribute("Name").Sanitize();
                    a.Emails.Add(em);
                }
            }
            catch { }


            return(a);
        }
예제 #2
0
        public static AssetNotification Create(string assetNumber, List <EmailAddress> emails, bool isNotified = false)
        {
            AssetNotification n = new AssetNotification();

            n.Emails = new List <EmailAddress>();
            n.Emails.AddRange(emails);
            n.AssetNumber  = assetNumber;
            n.Time         = DateTime.Now;
            n.LastNotified = DateTime.Now;
            n.IsNotified   = isNotified;
            return(n);
        }