Exemplo n.º 1
0
        public ActionResult SearchOutlet(string city)
        {
            // List<String> outletPhone= new List<String>();
            String outletPhone = null;

            System.Collections.Generic.IEnumerable <System.Xml.Linq.XElement> stores;
            System.Xml.Linq.XDocument xmlDoc = System.Xml.Linq.XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("~/Outlets/Outlets.xml"));
            stores = from o in xmlDoc.Descendants("City") select o;
            Boolean flag = false;

            foreach (var entry in stores)
            {
                string tempCity = entry.Element("Name").Value;

                if (string.Equals(tempCity, city, StringComparison.OrdinalIgnoreCase) == true)
                {
                    flag        = true;
                    outletPhone = "Call: " + entry.Element("Phone").Value;
                    break;
                }
            }
            if (flag == false)
            {
                outletPhone = "Sorry! No phone number of our outlet found in your city. Call the Pizzeria toll free number 555-0100.";
            }
            return(Content(outletPhone));
        }
        public ActionResult MovieRatings()
        {
            System.Xml.Linq.XDocument xmlDoc = System.Xml.Linq.XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("~/MovieRatings/MovieRating.xml"));

            var movies = from m in xmlDoc.Descendants("Movie")
                         select m;
            string strResponse = "<table style='width:100%; padding:30px;'>";

            foreach (var mov in movies)
            {
                strResponse += getRow("Movie Name", mov.Element("Name").Value);
                strResponse += getRow("Director", mov.Element("Director").Value);
                strResponse += getRow("Producer", mov.Element("Producer").Value);
                strResponse += getRow("Cast", mov.Element("Cast").Value);
                string rating = "";
                for (int i = 0; i < Convert.ToInt32(mov.Element("Rating").Value); i++)
                {
                    //rating += "<img src=\"" + System.Web.HttpContext.Current.Server.MapPath("~/Images/Star.png") + "\" style='height:20px; width:20px;'/>";
                    rating += "<img src='../../Images/Star.png' style='height:20px; width:20px;'/>";
                }
                strResponse += getRow("Rating", rating);
                //to insert blank row after each movie rating record
                strResponse += getRow("<br/>", "<br/>");
            }
            strResponse         += "</table>";
            ViewBag.movieRatings = strResponse;
            return(View());
        }
        public decimal getDiscountedPrice(String promoCode, decimal price)

        {
            decimal discountedPrice = 0.0M;

            System.Collections.Generic.IEnumerable <System.Xml.Linq.XElement> discounts;
            System.Xml.Linq.XDocument xmlDoc = System.Xml.Linq.XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("~/PromoCode/PromoCode.xml"));
            discounts = from c in xmlDoc.Descendants("Discount") select c;


            Boolean flag = false;

            foreach (var entry in discounts)
            {
                string code = entry.Element("PromoCode").Value;
                if (string.Equals(code, promoCode, StringComparison.OrdinalIgnoreCase) == true)
                {
                    decimal discount = Convert.ToDecimal(entry.Element("DiscountPercentage").Value) / 100;
                    discountedPrice = price - (price * discount);
                    flag            = true;
                    break;
                }
            }
            if (flag == false)
            {
                discountedPrice = price;
            }
            return(discountedPrice);
        }
Exemplo n.º 4
0
        public static async System.Threading.Tasks.Task <IQueryable <IndicativeExchangeRates.Model.Currency> > GetData()
        {
            string responseBody = string.Empty;

            using (System.Net.Http.HttpResponseMessage response = await ServiceClient.GetHttpResponse())
            {
                if (response.IsSuccessStatusCode)
                {
                    using (System.Net.Http.HttpContent content = response.Content)
                    {
                        responseBody = await content.ReadAsStringAsync();
                    }
                }
                else
                {
                    Log.Logger.Instance.Error(new Exception($"UserName:{Authentication.AuthService.UserName} - Exchange rate data is not available. Response is {response.StatusCode.ToString()}"));
                    throw new Exception("No data available!");
                }
            }


            if (responseBody.EndsWith(@"</Tarih_Date"))
            {
                responseBody = responseBody.Replace("</Tarih_Date", "</Tarih_Date>");
            }

            System.Xml.Linq.XDocument document = System.Xml.Linq.XDocument.Parse(responseBody);

            var resultSet = (from result in document.Descendants("Currency")

                             .Where(result => result.Descendants("Isim").Any())
                             .Where(result => result.Descendants("CurrencyName").Any())
                             .Where(result => result.LastAttribute != null)
                             .Where(result => result.Descendants("ForexBuying").Any())
                             .Where(result => result.Descendants("ForexSelling").Any())
                             .Where(result => result.Descendants("BanknoteBuying").Any())
                             .Where(result => result.Descendants("BanknoteSelling").Any())

                             select
                             new IndicativeExchangeRates.Model.Currency
            {
                Tarih = document.Root.Attribute("Tarih").Value.Trim(),
                Date = document.Root.Attribute("Date").Value.Trim(),
                Bulten_No = document.Root.Attribute("Bulten_No").Value.Trim(),
                CrossOrder = result.Attribute("CrossOrder").Value.Trim(),
                Kod = result.Attribute("Kod").Value.Trim(),
                CurrencyCode = result.Attribute("CurrencyCode").Value.Trim(),
                Unit = Convert.ToByte(result.Element("Unit").Value.Trim()),
                Isim = result.Element("Isim").Value.Trim(),
                CurrencyName = result.Element("CurrencyName").Value.Trim(),
                ForexBuying = (!string.IsNullOrWhiteSpace(result.Element("ForexBuying").Value.Trim()) ? Convert.ToDecimal(result.Element("ForexBuying").Value.Trim()) : default(decimal?)),
                ForexSelling = (!string.IsNullOrWhiteSpace(result.Element("ForexSelling").Value.Trim()) ? Convert.ToDecimal(result.Element("ForexSelling").Value.Trim()) : default(decimal?)),
                BanknoteBuying = (!string.IsNullOrWhiteSpace(result.Element("BanknoteBuying").Value.Trim()) ? Convert.ToDecimal(result.Element("BanknoteBuying").Value.Trim()) : default(decimal?)),
                BanknoteSelling = (!string.IsNullOrWhiteSpace(result.Element("BanknoteSelling").Value.Trim()) ? Convert.ToDecimal(result.Element("BanknoteSelling").Value.Trim()) : default(decimal?)),
                CrossRateUSD = (!string.IsNullOrWhiteSpace(result.Element("CrossRateUSD").Value.Trim()) ? Convert.ToDecimal(result.Element("CrossRateUSD").Value.Trim()) : default(decimal?)),
                CrossRateOther = (!string.IsNullOrWhiteSpace(result.Element("CrossRateOther").Value.Trim()) ? Convert.ToDecimal(result.Element("CrossRateOther").Value.Trim()) : default(decimal?))
            }).AsQueryable();

            return(resultSet);
        }
Exemplo n.º 5
0
        public decimal GetRate(string code)
        {
            string url  = string.Empty;
            var    date = DateTime.Now;

            if (date.Date == DateTime.Today)
            {
                url = "http://www.tcmb.gov.tr/kurlar/today.xml";
            }
            else
            {
                url = string.Format("http://www.tcmb.gov.tr/kurlar/{0}{1}/{2}{1}{0}.xml", date.Year, addZero(date.Month), addZero(date.Day));
            }

            System.Xml.Linq.XDocument   document = System.Xml.Linq.XDocument.Load(url);
            Dictionary <string, string> dic      = new Dictionary <string, string>();
            var result = document.Descendants("Currency")
                         .Where(v => v.Element("ForexBuying") != null && v.Element("ForexBuying").Value.Length > 0)
                         .Select(v => new Currency
            {
                Code = v.Attribute("Kod").Value,
                Rate = decimal.Parse(v.Element("ForexBuying").Value)
            }).ToList();

            return(result.FirstOrDefault(s => s.Code == code).Rate);
        }
Exemplo n.º 6
0
        public static List <SceneUnderstandingObjects.Element> ParseObjXml(string xml)
        {
            System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Load(xml);

            var queriedData = doc.Descendants("Element").Select(i => new SceneUnderstandingObjects.Element()
            {
                tag         = i.Element("tag").Value,
                id          = System.Convert.ToInt32(i.Element("id").Value),
                objfilename = i.Element("objfilename").Value,
                cldfilename = i.Element("cldfilename").Value,
                position    = i.Descendants("position").Select(j => new Vector3()
                {
                    x = (float)j.Element("x"), y = (float)j.Element("y"), z = (float)j.Element("z")
                }).ToList(),
                forward = i.Elements("forward").Select(j => new Vector3()
                {
                    x = (float)j.Element("x"), y = (float)j.Element("y"), z = (float)j.Element("z")
                }).FirstOrDefault(),
                bBoxMinPoint = i.Elements("bBoxMinPoint").Select(j => new Vector3()
                {
                    x = (float)j.Element("x"), y = (float)j.Element("y"), z = (float)j.Element("z")
                }).FirstOrDefault(),
                bBoxMaxPoint = i.Elements("bBoxMaxPoint").Select(j => new Vector3()
                {
                    x = (float)j.Element("x"), y = (float)j.Element("y"), z = (float)j.Element("z")
                }).FirstOrDefault()
            }).ToList();

            return(queriedData);
        }
Exemplo n.º 7
0
        private static void AddValueToHtForSingleNode(System.Xml.Linq.XDocument xDoc, System.Xml.Linq.XNamespace msbuild, string element)
        {
            var des = xDoc.Descendants(msbuild + element).FirstOrDefault();

            if (des != null)
            {
                htCheck.Add(element, string.IsNullOrEmpty(des.Value) ? null : des.Value);
            }
        }
Exemplo n.º 8
0
        //http://msdn.microsoft.com/en-us/library/dn189154.aspx
        public static void UpdatePlayReadyConfigurationXMLFile(Guid keyId, string contentKeyB64)
        {
            System.Xml.Linq.XNamespace xmlns = "http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#";
            string keyDeliveryServiceUriStr  = "http://playready.directtaps.net/pr/svc/rightsmanager.asmx";
            Uri    keyDeliveryServiceUri     = new Uri(keyDeliveryServiceUriStr);

            string xmlFileName = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\..\..", @"MediaEncryptor_PlayReadyProtection.xml");

            // Prepare the encryption task template
            System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Load(xmlFileName);

            var licenseAcquisitionUrlEl = doc
                                          .Descendants(xmlns + "property")
                                          .Where(p => p.Attribute("name").Value == "licenseAcquisitionUrl")
                                          .FirstOrDefault();
            var contentKeyEl = doc
                               .Descendants(xmlns + "property")
                               .Where(p => p.Attribute("name").Value == "contentKey")
                               .FirstOrDefault();
            var keyIdEl = doc
                          .Descendants(xmlns + "property")
                          .Where(p => p.Attribute("name").Value == "keyId")
                          .FirstOrDefault();

            // Update the "value" property for each element.
            if (licenseAcquisitionUrlEl != null)
            {
                licenseAcquisitionUrlEl.Attribute("value").SetValue(keyDeliveryServiceUri);
            }

            if (contentKeyEl != null)
            {
                contentKeyEl.Attribute("value").SetValue(contentKeyB64);
            }

            if (keyIdEl != null)
            {
                keyIdEl.Attribute("value").SetValue(keyId);
            }

            doc.Save(xmlFileName);
        }
Exemplo n.º 9
0
        public (string asin, int price) GetAmazonUsingAPI(string toyName)
        {
            try
            {
                var keyword = toyName.Replace(" ", " ");
                var helper  = new Helper.SignedRequestHelper(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY, DESTINATION, ASSOCIATE_TAG);

                IDictionary <string, string> request = new Dictionary <string, String>
                {
                    ["Service"]       = "AWSECommerceService",
                    ["Operation"]     = "ItemSearch",
                    ["SearchIndex"]   = "All",
                    ["ResponseGroup"] = "Medium",
                    ["Keywords"]      = keyword
                };
                var requestUrl = helper.Sign(request);
                System.Xml.Linq.XDocument xml = System.Xml.Linq.XDocument.Load(requestUrl);

                System.Xml.Linq.XNamespace ns = xml.Root.Name.Namespace;
                var errorMessageNodes         = xml.Descendants(ns + "Message").ToList();
                if (errorMessageNodes.Any())
                {
                    var message = errorMessageNodes[0].Value;
                    return(null, 0);
                }
                var item         = xml.Descendants(ns + "Item").FirstOrDefault();
                var asin         = item?.Descendants(ns + "ASIN").FirstOrDefault()?.Value;
                var offerSummary = item?.Descendants(ns + "OfferSummary").FirstOrDefault();
                var price        = offerSummary?.Descendants(ns + "LowestNewPrice").FirstOrDefault()?.Descendants(ns + "Amount").FirstOrDefault()?.Value;

                return(asin, price != null ? Convert.ToInt32(price) : 0);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Task.Delay(Delay).Wait();
            }
        }
Exemplo n.º 10
0
        public string GetDataFromXml(string value, string attributeName)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(string.Empty);
            }

            System.Xml.Linq.XDocument document = System.Xml.Linq.XDocument.Parse(value);
            // get the Element with the attribute name specified
            System.Xml.Linq.XElement element = document.Descendants().Where(ele => ele.Attributes().Any(attr => attr.Name == attributeName)).FirstOrDefault();
            return(element == null ? string.Empty : element.Value);
        }
Exemplo n.º 11
0
        public static Book GetBook(string repo_path)
        {
            System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Load(repo_path);

            var bks = from books in doc.Descendants("book")
                      select new Book
            {
                Folder = (string)books.Attribute("folder"),
                Pages  = (from pages in doc.Descendants("page")
                          select new Page
                {
                    Src = String.Format(
                        "{0}/{1}",
                        (string)books.Attribute("folder"),
                        (string)pages.Attribute("src")
                        )
                }).ToList()
            };

            return(bks.ToList().First());
        }
Exemplo n.º 12
0
        public StateMachine(System.Xml.Linq.XDocument document)
        {
            BeginState = document.Root.Attribute("beginState").Value;
            string endState = document.Root.Attribute("endState").Value;

            EndStates.Add(endState);
            States = new List <State>();
            //States = (from x in document.Descendants("State")

            //           select new State() { Name = x.Attribute("name").Value, Display = x.Attribute("display").Value }).ToList();
            foreach (var x in document.Descendants("State"))
            {
                var state = new State()
                {
                    Name = x.Attribute("name").Value, Display = x.Attribute("display").Value
                };
                var isnav = x.Attribute("isNavigate");
                if (isnav != null && Boolean.TryParse(isnav.Value, out bool isNav))
                {
                    state.IsNavigate = isNav;
                    var order = x.Attribute("order");
                    if (order != null && Int32.TryParse(order.Value, out int i))
                    {
                        state.SortOrder = i;
                    }
                }
                States.Add(state);
            }

            Transitions = (from x in document.Descendants("Transition")
                           select new Transition()
            {
                Name = x.Attribute("name").Value,
                OriginState = x.Attribute("origin").Value,
                DestinationState = x.Attribute("destination").Value,
                SortOrder = Convert.ToInt32(x.Attribute("order").Value)
            }).ToList();
        }
Exemplo n.º 13
0
        public ActionResult Index()
        {
            var pizzas = GetItems(12);

            System.Collections.Generic.IEnumerable <System.Xml.Linq.XElement> discounts;
            System.Xml.Linq.XDocument xmlDoc = System.Xml.Linq.XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("~/PromoCode/PromoCode.xml"));
            discounts = from c in xmlDoc.Descendants("Discount") select c;

            foreach (var entry in discounts)
            {
                @ViewBag.Code     = entry.Element("PromoCode").Value;
                @ViewBag.Discount = entry.Element("DiscountPercentage").Value;
            }

            return(View(pizzas));
        }
        public async Task <ActionResult <string> > GetStockAsync()
        {
            try
            {
                string result = await _stockClient.GetStringAsync(_stockProviderUrl);

                //convert to XML to extract the stock value
                System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Parse(result.Trim('\"'));
                var price = doc.Descendants("LastPrice").FirstOrDefault();

                return(price.Value);
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 15
0
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                Conductor updateConductor = Conductor.GetConductorFromNode(element);
                System.Xml.Linq.XElement conductorNode = element.Element(Constants.Conductor.conductorElement);
                if (conductorNode == null)
                {
                    continue;
                }

                object newValue = conductorNode.GetXElement(tagName);
                BsoArchiveEntities.UpdateObject(updateConductor, newValue, columnName);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Updates the existing database Instrument on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Artist.artistElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                Instrument updateInstrument = Instrument.GetInstrumentFromNode(element);

                if (updateInstrument == null)
                {
                    continue;
                }

                object newValue = element.GetXElement(tagName);

                BsoArchiveEntities.UpdateObject(updateInstrument, newValue, columnName);
            }
        }
Exemplo n.º 17
0
        public ActionResult ImportEmployees(string tbFilePath)
        {
            string strResponse;

            strResponse = "<font style='font-size:18pt;'><b>Entered employees are .... </b><br><br><br></font>";


            if (!string.IsNullOrEmpty(tbFilePath))
            {
                try
                {
                    System.Xml.Linq.XDocument xmlDoc = System.Xml.Linq.XDocument.Load(tbFilePath);

                    var emps = from e in xmlDoc.Descendants("Employee")
                               select e;

                    foreach (var emp in emps)
                    {
                        Employee.Models.Employee newEmployee = new Employee.Models.Employee();

                        newEmployee.Employee_Name     = emp.Element("Name").Value;
                        newEmployee.EmployeeManagerID = Convert.ToInt32(emp.Element("Manager").Value);
                        newEmployee.Salary            = Convert.ToInt32(emp.Element("Salary").Value);
                        db.Employees.Add(newEmployee);
                        db.SaveChanges();
                    }
                    strResponse = "<font style='font-size:18pt;'><b>Employee name added successfully in the database.</b><br><br><br></font>";
                }
                catch (System.Exception exx)
                {
                    Console.WriteLine(exx.Message);
                    strResponse = exx.Message;
                    strResponse = exx.Source + " " + exx.StackTrace;
                    // strResponse = exx.StackTrace;
                    //   strResponse = "<font style='font-size:18pt;color:red;'><b>Invalid file path.</b><br><br><br></font>";
                }
            }
            else
            {
                strResponse = "<font style='font-size:18pt;color:red;'><b>Please specify a valid file path.</b><br><br><br></font>";
            }
            ViewBag.response = strResponse;
            return(View());
        }
Exemplo n.º 18
0
        public ImportResult Import(System.IO.Stream fileStream)
        {
            string contentXml = GetContentXml(fileStream);

            ImportResult result = new ImportResult();

            System.Xml.Linq.XDocument doc =
                System.Xml.Linq.XDocument.Parse(contentXml);

            System.Collections.Generic.IEnumerable <System.Xml.Linq.XElement> rows =
                doc.Descendants("{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table-row").Skip(1);

            foreach (System.Xml.Linq.XElement row in rows)
            {
                ImportRow(row, result); //, companyId, year, result);
            }

            return(result);
        }
        public static List <ProductDetail> GetProductDetailsData()
        {
            string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString() + "\\Configuration\\ProductsDetail.xml";

            if (System.IO.File.Exists(path))
            {
                System.Xml.Linq.XDocument xdoc = System.Xml.Linq.XDocument.Load(path);
                return((from lv1 in xdoc.Descendants("Product")
                        select new ProductDetail()
                {
                    productcode = lv1.Descendants("ProductCode").FirstOrDefault().Value.Replace(" ", ""),
                    CertName = lv1.Descendants("ProductName").FirstOrDefault().Value.Replace(" ", ""),
                    URL = lv1.Descendants("URL").FirstOrDefault() != null ? lv1.Descendants("URL").FirstOrDefault().Value.Replace(" ", "") : string.Empty,
                    MobileFriendly = Convert.ToBoolean(lv1.Descendants("MobileFriendly").FirstOrDefault().Value.Replace(" ", "")),
                    InstantDelivery = Convert.ToBoolean(lv1.Descendants("InstantDelivery").FirstOrDefault().Value.Replace(" ", "")),
                    DocSigning = Convert.ToBoolean(lv1.Descendants("DocSigning").FirstOrDefault().Value.Replace(" ", "")),
                    ScanProduct = Convert.ToBoolean(lv1.Descendants("ScanProduct").FirstOrDefault().Value.Replace(" ", "")),
                    BusinessValid = Convert.ToBoolean(lv1.Descendants("BusinessValid").FirstOrDefault().Value.Replace(" ", "")),
                    SanSupport = Convert.ToBoolean(lv1.Descendants("SanSupport").FirstOrDefault().Value.Replace(" ", "")),
                    WildcardSupport = Convert.ToBoolean(lv1.Descendants("WildcardSupport").FirstOrDefault().Value.Replace(" ", "")),
                    GreenBar = Convert.ToBoolean(lv1.Descendants("GreenBar").FirstOrDefault().Value.Replace(" ", "")),
                    IssuanceTime = lv1.Descendants("IssuanceTime").FirstOrDefault().Value.Replace(" ", ""),
                    Warranty = lv1.Descendants("Warranty").FirstOrDefault().Value.Replace(" ", ""),
                    SiteSeal = lv1.Descendants("SiteSeal").FirstOrDefault().Value.Replace(" ", ""),
                    StarRating = lv1.Descendants("StarRating").FirstOrDefault().Value.Replace(" ", ""),
                    SealInSearch = Convert.ToBoolean(lv1.Descendants("SealInSearch").FirstOrDefault().Value.Replace(" ", "")),
                    VulnerabilityAssessment = Convert.ToBoolean(lv1.Descendants("VulnerabilityAssessment").FirstOrDefault().Value.Replace(" ", "")),
                    ValidationType = lv1.Descendants("ValidationType").FirstOrDefault().Value.Replace(" ", ""),
                    ServerLicense = lv1.Descendants("ServerLicense").FirstOrDefault().Value.Replace(" ", ""),
                    ShortDesc = lv1.Descendants("ShortDesc").FirstOrDefault() != null ? lv1.Descendants("ShortDesc").FirstOrDefault().Value.Replace(" ", "") : string.Empty,
                    LongDesc = lv1.Descendants("LongDesc").FirstOrDefault() != null ? lv1.Descendants("LongDesc").FirstOrDefault().Value.Replace(" ", "") : string.Empty,
                    ProductDatasheetUrl = lv1.Descendants("ProductDatasheetUrl").FirstOrDefault() != null ? lv1.Descendants("ProductDatasheetUrl").FirstOrDefault().Value.Replace(" ", "") : string.Empty,
                    VideoUrl = lv1.Descendants("VideoUrl").FirstOrDefault() != null ? lv1.Descendants("VideoUrl").FirstOrDefault().Value.Replace(" ", "") : string.Empty,
                    SimilarProducts = lv1.Descendants("SimilarProducts").FirstOrDefault() != null ? lv1.Descendants("SimilarProducts").FirstOrDefault().Value.Replace(" ", "") : string.Empty,
                    SealType = lv1.Descendants("SealType").FirstOrDefault() != null ? lv1.Descendants("SealType").FirstOrDefault().Value.Replace(" ", "") : string.Empty
                }).ToList());
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Updates the existing database Venue on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                Venue updateVenue = Venue.GetVenueFromNode(element);

                if (updateVenue == null)
                {
                    continue;
                }

                System.Xml.Linq.XElement venueNode = element.Element(Constants.Venue.venueElement);

                object newValue = (string)venueNode.GetXElement(tagName);

                BsoArchiveEntities.UpdateObject(updateVenue, newValue, columnName);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Updates the existing database TypeGroup on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                EventTypeGroup updateTypeGroup = EventTypeGroup.GetEventTypeGroupFromNode(element);

                if (updateTypeGroup == null)
                {
                    continue;
                }

                System.Xml.Linq.XElement typeGroupNode = element.Element(Constants.EventTypeGroup.typeGroupElement);

                object newValue = typeGroupNode.GetXElement(tagName);

                BsoArchiveEntities.UpdateObject(updateTypeGroup, newValue, columnName);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Updates the existing database Project on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                Project updateProject = Project.GetProjectFromNode(element);

                if (updateProject == null)
                {
                    continue;
                }

                System.Xml.Linq.XElement projectNode = element.Element(Constants.Project.projectElement);

                object newValue = projectNode.GetXElement(tagName);

                BsoArchiveEntities.UpdateObject(updateProject, newValue, columnName);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Updates the existing database Orchestra on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                Orchestra updateOrchestra = Orchestra.GetOrchestraFromNode(element);

                if (updateOrchestra == null)
                {
                    continue;
                }

                System.Xml.Linq.XElement orchestraNode = element.Element(Constants.Orchestra.orchestraElement);

                object newValue = orchestraNode.GetXElement(tagName);

                BsoArchiveEntities.UpdateObject(updateOrchestra, newValue, columnName);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Updates the existing database Season on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                Season updateSeason = Season.GetSeasonFromNode(element);

                if (updateSeason == null)
                {
                    continue;
                }

                System.Xml.Linq.XElement seasonNode = element.Element(Constants.Season.seasonElement);

                object newValue = seasonNode.GetXElement(tagName);

                BsoArchiveEntities.UpdateObject(updateSeason, newValue, columnName);
            }
        }
        public static List <PageUrl> GetProductDetailSlugs()
        {
            string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString() + "\\Configuration\\pageconfiguration.xml";

            if (System.IO.File.Exists(path))
            {
                System.Xml.Linq.XDocument xdoc = System.Xml.Linq.XDocument.Load(path);
                return((from lv1 in xdoc.Descendants("ProductPage")
                        select new PageUrl
                {
                    Description = lv1.Descendants("Description").FirstOrDefault() != null ? lv1.Descendants("Description").FirstOrDefault().Value.Replace("\n", "").Replace("\r", "").Trim() : "",
                    Keywords = lv1.Descendants("Keywords").FirstOrDefault() != null ? lv1.Descendants("Keywords").FirstOrDefault().Value.Replace("\n", "").Replace("\r", "").Trim() : "",
                    SlugUrl = lv1.Descendants("InternalProductCode").Select(x => x.Attribute("data-url").Value.Replace("\n", "").Replace("\r", "").Trim()).FirstOrDefault(),
                    ProductCode = lv1.Descendants("InternalProductCode").FirstOrDefault() != null ? lv1.Descendants("InternalProductCode").FirstOrDefault().Value.Replace("\n", "").Replace("\r", "").Trim() : "",
                    Title = lv1.Descendants("Title").FirstOrDefault() != null ? lv1.Descendants("Title").FirstOrDefault().Value.Replace("\n", "").Replace("\r", "").Trim() : ""
                }).ToList());
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Updates the existing database WorkArtist on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement eventElement in eventElements)
            {
                var workElements = eventElement.Descendants(Constants.Work.workElement);
                foreach (var workElement in workElements)
                {
                    Work workItem = Work.GetWorkFromNode(workElement);

                    IEnumerable <System.Xml.Linq.XElement> workArtistElements = workElement.Descendants(Constants.WorkArtist.workArtistElement);
                    foreach (var workArtistElement in workArtistElements)
                    {
                        int artistID = 0;
                        int.TryParse((string)workArtistElement.GetXElement(Constants.WorkArtist.workArtistIDElement), out artistID);

                        WorkArtist updateWorkArtist = WorkArtist.GetWorkArtistByID(artistID, workItem.WorkID);

                        updateWorkArtist = WorkArtist.BuildWorkArtist(workArtistElement, artistID, updateWorkArtist);

                        if (updateWorkArtist == null)
                        {
                            continue;
                        }

                        object newValue = (string)workArtistElement.GetXElement(tagName);

                        BsoArchiveEntities.UpdateObject(updateWorkArtist, newValue, columnName);

                        BsoArchiveEntities.UpdateObject(updateWorkArtist.Artist, newValue, columnName);

                        BsoArchiveEntities.UpdateObject(updateWorkArtist.Instrument, newValue, columnName);

                        BsoArchiveEntities.Current.Save();
                    }
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Update given column from xml given the tag name
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        /// <remarks>
        /// Read Composer information from OPAS XML and update the Composer Column based upon appropriate tagName
        /// </remarks>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                IEnumerable <System.Xml.Linq.XElement> composerElements = element.Descendants(Constants.Work.workComposerElement);
                foreach (System.Xml.Linq.XElement composer in composerElements)
                {
                    Composer updateComposer = Composer.GetComposerFromNode(composer);

                    if (updateComposer == null)
                    {
                        continue;
                    }

                    object newValue = composer.GetXElement(tagName);

                    BsoArchiveEntities.UpdateObject(updateComposer, newValue, columnName);
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Updates the existing database Work on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement element in eventElements)
            {
                //System.Xml.Linq.XElement workNode = element.Element(Constants.Work.workElement);
                var workNodes = element.Descendants(Constants.Work.workElement);
                foreach (var workNode in workNodes)
                {
                    Work updateWork = Work.GetWorkFromNode(workNode);

                    if (updateWork == null)
                    {
                        continue;
                    }

                    object newValue = (string)workNode.GetXElement(tagName);

                    BsoArchiveEntities.UpdateObject(updateWork, newValue, columnName);
                }
            }
        }
Exemplo n.º 29
0
        public ActionResult ImportJeansItems(string tbFilePath)
        {
            string strResponse;

            if (!string.IsNullOrEmpty(tbFilePath))
            {
                try
                {
                    System.Xml.Linq.XDocument xmlDoc = System.Xml.Linq.XDocument.Load(tbFilePath);

                    var Jeanses = from g in xmlDoc.Descendants("Jeans")
                                  select g;

                    foreach (var Jeans in Jeanses)
                    {
                        Jeans newJeans = new Jeans();
                        newJeans.Details         = Jeans.Element("Details").Value;
                        newJeans.Jeans_Name      = Jeans.Element("Name").Value;
                        newJeans.JeansCategoryID = Convert.ToInt32(Jeans.Element("Category").Value);
                        newJeans.Price           = Convert.ToInt32(Jeans.Element("Price").Value);
                        db.Jeanses.Add(newJeans);
                        db.SaveChanges();
                    }
                    strResponse = "<font style='font-size:18pt;'><b>Jeans items added successfully in the database.</b><br><br><br></font>";
                }
                catch (System.Exception ex)
                {
                    strResponse = "<font style='font-size:18pt;color:red;'><b>Invalid file path.</b><br><br><br></font>";
                }
            }
            else
            {
                strResponse = "<font style='font-size:18pt;color:red;'><b>Please specify a valid file path.</b><br><br><br></font>";
            }
            ViewBag.response = strResponse;
            return(View());
        }
        public void ProcessRequest(HttpContext context)
        {
            string filePath = context.Request.PhysicalPath;

            using (System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open))
            {
                System.Xml.Linq.XDocument xDocument = System.Xml.Linq.XDocument.Load(stream);
                var allUsers = from user in xDocument.Descendants("User")
                               select new
                {
                    FirstName = user.Element("FirstName").Value,
                    LastName  = user.Element("LastName").Value
                };
                context.Response.Write("<html><body><table border='1'>");
                foreach (var user in allUsers)
                {
                    context.Response.Write("<tr>");
                    context.Response.Write("<td>" + user.FirstName + "</td>");
                    context.Response.Write("<td>" + user.LastName + "</td>");
                    context.Response.Write("</tr>");
                }
                context.Response.Write("</table></body></html>");
            }
        }