예제 #1
0
 public int Add(XE xe)
 {
     using (QLXeKhachEntities context = new QLXeKhachEntities())
     {
         var user = HttpContext.Current.Session[GlobalConstant.USER];
         if (user != null)
         {
             NHANVIEN currentUser = (NHANVIEN)user;
             xe.createUser     = currentUser.MaNV;
             xe.lastupdateUser = currentUser.MaNV;
         }
         DateTime current = DateTime.Now;
         xe.createDate     = current;
         xe.lastupdateDate = current;
         var result = context.XEs.Add(xe);
         context.SaveChanges();
         LOAIXE loaiXe = context.LOAIXEs.Find(xe.LoaiXe);
         for (int i = 0; i < loaiXe.SLGhe; i++)
         {
             GHE ghe = new GHE();
             ghe.createDate     = DateTime.Now;
             ghe.lastupdateDate = DateTime.Now;
             ghe.MaGhe          = i + 1;
             ghe.MaXe           = xe.MaXe;
             context.GHEs.Add(ghe);
             context.SaveChanges();
         }
         return(1);
     }
 }
        private static void StripNamespacesFromXml(XDocument xml)
        {
            foreach (XElement XE in xml.Root.DescendantsAndSelf())
            {
                // Stripping the namespace by setting the name of the element to it's localname only

                if (XE.Name.Namespace.NamespaceName.Equals("http://schemas.microsoft.com/msus/2002/12/BaseApplicabilityRules"))
                {
                    XE.Name = $"b.{XE.Name.LocalName}";
                }
                else if (XE.Name.Namespace.NamespaceName.Equals("http://schemas.microsoft.com/msus/2002/12/MsiApplicabilityRules"))
                {
                    XE.Name = $"m.{XE.Name.LocalName}";
                }
                else if (XE.Name.Namespace.NamespaceName.Equals("http://schemas.microsoft.com/msus/2002/12/UpdateHandlers/WindowsDriver"))
                {
                    XE.Name = $"d.{XE.Name.LocalName}";
                }
                else
                {
                    XE.Name = XE.Name.LocalName;
                }
                // replacing all attributes with attributes that are not namespaces and their names are set to only the localname
                XE.ReplaceAttributes((from xattrib in XE.Attributes().Where(xa => !xa.IsNamespaceDeclaration) select new XAttribute(xattrib.Name.LocalName, xattrib.Value)));
            }
        }
예제 #3
0
        public static XDocument Serialize <T>(T value, bool useDataContract = false)
        {
            XDocument doc = new XDocument(new XDeclaration("1.0", "UTF-8", "no"));

            if (!useDataContract)
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
                using (var writer = doc.CreateWriter())
                    xmlSerializer.Serialize(writer, value);
            }
            else
            {
                DataContractSerializer xmlSerializer = new DataContractSerializer(typeof(T));

                using (var writer = doc.CreateWriter())
                    xmlSerializer.WriteObject(writer, value);
            }

            foreach (XElement XE in doc.Root.DescendantsAndSelf())
            {
                // Stripping the namespace by setting the name of the element to it's localname only
                XE.Name = XE.Name.LocalName;
                // replacing all attributes with attributes that are not namespaces and their names are set to only the localname
                XE.ReplaceAttributes((from xattrib in XE.Attributes().Where(xa => !xa.IsNamespaceDeclaration) select new XAttribute(xattrib.Name.LocalName, xattrib.Value)));
            }

            return(doc);
        }
예제 #4
0
        private void WriteFeedFile(XmlWriter xmlWriter, FeedGenerationFileInstruction fileInstruction)
        {
            var countRec = new Tuple <int, int, int>(0, 0, 0);

            xmlWriter.WriteStartDocument();
            xmlWriter.WriteDocType("product_catalog_data", null, DocTypeSystemId, null);
            xmlWriter.WriteStartElement("product_catalog_data");
            var header = new XE("header");

            header.Add(new XE("cid", Cid));
            header.Add(new XE("subid", SubId));
            //header.Add(new XE("datefmt", DateFormatString));
            header.Add(new XE("processtype", (_isIncrementalRun) ? "UPDATE" : "OVERWRITE"));
            header.Add(new XE("aid", fileInstruction.Aid));

            header.WriteTo(xmlWriter);

            //<feedGenerationFileLineItem isIncluded="true" catalog="books" storedProcedureName="uspCJFeedBooks" catalogattributesection="booksattributes" ranges="00-04;05-09" />
            foreach (var fileComponent in fileInstruction.LineItems)
            {
                WriteFileComponent(xmlWriter, fileComponent, ref countRec);
            }

            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();
        }
예제 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            XE xE = db.XEs.Find(id);

            db.XEs.Remove(xE);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "MaXe,LoaiXe,BienSoXe,HangXe,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] XE xE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(xE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(xE));
 }
예제 #7
0
        public ActionResult Create([Bind(Include = "MaXe,LoaiXe,BienSoXe,HangXe,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] XE xE)
        {
            if (ModelState.IsValid)
            {
                db.XEs.Add(xE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(xE));
        }
예제 #8
0
 public static string GetBienSo(int?maxe)
 {
     using (QLXeKhachEntities context = new QLXeKhachEntities())
     {
         XE x = context.XEs.Find(maxe);
         if (x != null)
         {
             return(x.BienSoXe);
         }
         return("");
     }
 }
예제 #9
0
        public void UpdateXe(XE xe)
        {
            var query = (from c in _dataContext.XEs
                         where c.MaXe == xe.MaXe
                         select c).Single();

            query.BienSoXe  = xe.BienSoXe;
            query.MaLoaiXe  = xe.MaLoaiXe;
            query.MaTaiXe   = xe.MaTaiXe;
            query.NgayNhap  = xe.NgayNhap;
            query.TinhTrang = xe.TinhTrang;

            _dataContext.SubmitChanges();
        }
예제 #10
0
        // GET: XEs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            XE xE = db.XEs.Find(id);

            if (xE == null)
            {
                return(HttpNotFound());
            }
            return(View(xE));
        }
예제 #11
0
        public ActionResult Create([Bind(Include = "MaXe,LoaiXe,BienSoXe,HangXe,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] XE xE)
        {
            string thuocXe = Request.Form["xeDropList"];

            if (ModelState.IsValid)
            {
                xE.isDeleted = 0;
                xE.LoaiXe    = Int32.Parse(thuocXe);
                service.Add(xE);
                return(RedirectToAction("Index"));
            }

            return(View(xE));
        }
예제 #12
0
        public void ThatShit()
        {
            //string input = Input.Text.Trim().Replace("&", "&amp;");
            string        input          = Input.Text.Trim();
            List <string> activationList = new List <string>();

            while (true)
            {
                int startIndex = input.IndexOf("<ACTIVATION_CODE>");
                if (startIndex < 0)
                {
                    break;
                }
                int endIndex = input.IndexOf("</ACTIVATION_CODE>");
                int length   = endIndex - (startIndex + 17);
                activationList.Add(input.Substring(startIndex + 17, length));
                input = input.Remove(startIndex, length + 35);
            }

            try
            {
                XElement str = XElement.Parse(input);
                // find specific tag
                foreach (XElement XE in str.Elements("ITEM_DETAILS"))
                {
                    string number = XE.Descendants("ITEM_NUMBER").FirstOrDefault()?.Value;
                    string xmltag = XE.Descendants("XML_TAG").FirstOrDefault()?.Value;
                    itemNumbers.Add(number);
                }
                Output.Text += "Item Numbers found:" + Environment.NewLine;
                foreach (string item in itemNumbers)
                {
                    Output.Text += item + Environment.NewLine;
                }
                Output.Text += "End of item numbers found." + Environment.NewLine + Environment.NewLine;
                Output.Text += "Start of activation code list." + Environment.NewLine;
                foreach (string act in activationList)
                {
                    Output.Text += act + Environment.NewLine;
                }
                Output.Text += "End of activation code list." + Environment.NewLine;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception thrown when parsing. Message: " + ex.Message.ToString());
            }
        }
        private void AddRootNode()
        {
            _catFeedXml  = new XD(new XDeclaration("1.0", "utf-8", null));
            _feedElement = new XE(_gNsAtom + "feed", new object[]
            {
                new XA(XN.Xmlns + "g", _gNsG),
                new XA(XN.Xmlns + "c", _gNsC),
                new XA(XN.Xmlns + "gd", _gNs)
            });
            var titleElement  = new XE(_gNsAtom + "title", "Category Feed XML");
            var nameElement   = new XE(_gNsAtom + "name", "TEST Feed");
            var authorElement = new XE(_gNsAtom + "author", nameElement);
            var idElement     = new XE(_gNsAtom + "id",
                                       string.Format("tag:indigo.ca,{0}:/support/products", DateTime.Now.ToString(DateTime.Now.ToString("yy-MM-dd"))));

            _feedElement.Add(new object[] { titleElement, authorElement, idElement });
        }
예제 #14
0
        public static string Convert(string xml)
        {
            var doc = XDocument.Parse(xml);

            doc.Declaration = null;
            foreach (XElement XE in doc.Root.DescendantsAndSelf())
            {
                XE.Name = XE.Name.LocalName;
                XE.ReplaceAttributes((from xattrib in XE.Attributes().Where(xa => !xa.IsNamespaceDeclaration) select new XAttribute(xattrib.Name.LocalName, xattrib.Value)));
            }
            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(doc.ToString());
            var json = JsonConvert.SerializeXmlNode(xmlDocument);

            return(Regex.Replace(json, "(?<=\")(@)(?!.*\":\\s )", string.Empty, RegexOptions.IgnoreCase));
        }
예제 #15
0
        // GET: TRAMXEs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IList <XE> xE = service.Detail(id);
            XE         xe = new XE();

            ViewBag.loaixe = xE[0].LOAIXE1.TenLoai;
            if (xE == null)
            {
                return(HttpNotFound());
            }
            xe = xE[0];
            return(View(xe));
        }
예제 #16
0
        public void Delete(XE xe)
        {
            var user = HttpContext.Current.Session[GlobalConstant.USER];

            if (user != null)
            {
                NHANVIEN currentUser = (NHANVIEN)user;
                xe.lastupdateUser = currentUser.MaNV;
            }
            DateTime current = DateTime.Now;

            xe.lastupdateDate = current;
            using (QLXeKhachEntities context = new QLXeKhachEntities())
            {
                context.Entry(xe).State = EntityState.Modified;
                context.SaveChanges();
            }
        }
예제 #17
0
 public static void GetDataFileZilla(string PathFZ, string SaveFile, string RS = "RecentServers", string Serv = "Server")
 {
     try
     {
         if (File.Exists(PathFZ))
         {
             try
             {
                 var xf = new XmlDocument();
                 xf.Load(PathFZ);
                 foreach (XmlElement XE in ((XmlElement)xf.GetElementsByTagName(RS)[0]).GetElementsByTagName(Serv))
                 {
                     var Host = XE.GetElementsByTagName("Host")[0].InnerText;
                     var Port = XE.GetElementsByTagName("Port")[0].InnerText;
                     var User = XE.GetElementsByTagName("User")[0].InnerText;
                     var Pass = (Encoding.UTF8.GetString(Convert.FromBase64String(XE.GetElementsByTagName("Pass")[0].InnerText)));
                     if (!string.IsNullOrEmpty(Host) && !string.IsNullOrEmpty(Port) && !string.IsNullOrEmpty(User) && !string.IsNullOrEmpty(Pass))
                     {
                         SB.AppendLine($"Host: {Host}");
                         SB.AppendLine($"Port: {Port}");
                         SB.AppendLine($"User: {User}");
                         SB.AppendLine($"Pass: {Pass}\r\n");
                         count++;
                     }
                     else
                     {
                         break;
                     }
                 }
                 if (SB.Length > 0)
                 {
                     try
                     {
                         File.AppendAllText(SaveFile, SB.ToString());
                     }
                     catch { }
                 }
             }
             catch { }
         }
     }
     catch { }
 }
예제 #18
0
        public ActionResult Edit([Bind(Include = "MaXe,LoaiXe,BienSoXe,HangXe,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] XE xE)
        {
            int thuocXe;

            int.TryParse(Request.Form["xeDropList"], out thuocXe);

            if (ModelState.IsValid)
            {
                ILoaiXeService loaiXeService = new LoaiXeService();
                LOAIXE         lx            = loaiXeService.Detail(thuocXe);
                IList <XE>     xe            = service.Detail(xE.MaXe);
                xe[0].LoaiXe   = thuocXe;
                xe[0].LOAIXE1  = lx;
                xe[0].BienSoXe = xE.BienSoXe;
                xe[0].HangXe   = xE.HangXe;
                service.Update(xe[0]);
                return(RedirectToAction("Index"));
            }
            return(View(xE));
        }
예제 #19
0
        private static XE GetDeletedElement(DeletedProductInfo deletedProductInfo)
        {
            var entry = new XE("product");

            var name = new XE("name", deletedProductInfo.Name);

            entry.Add(name);

            var keywords = new XE("keywords", deletedProductInfo.Keywords);

            entry.Add(keywords);

            var description = new XE("description", deletedProductInfo.Description);

            entry.Add(description);

            var gaId = new XE("sku", deletedProductInfo.Pid);

            entry.Add(gaId);

            var buyUrl = new XE("buyurl", deletedProductInfo.BuyUrl);

            entry.Add(buyUrl);

            var available = new XE("available", deletedProductInfo.IsAvailable);

            entry.Add(available);

            var price = new XE("price", deletedProductInfo.Price);

            entry.Add(price);

            var merchandiseType = new XE("merchandisetype", ZeroCommissionListName);

            entry.Add(merchandiseType);

            return(entry);
        }
예제 #20
0
        public ActionResult Themxe(XE xe, FormCollection fc, HttpPostedFileBase fileUpload)
        {
            ViewBag.MaLX = new SelectList(data.LOAIXEs.ToList().OrderBy(n => n.MALOAIXE), "MALOAIXE", "TENLOAIXE");

            if (fileUpload == null)
            {
                ViewBag.Thongbao = "Vui lòng chọn ảnh bìa";
                return(View());
            }
            else
            {
                if (ModelState.IsValid)
                {
                    var fileName = Path.GetFileName(fileUpload.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Content/Hinhxe"), fileName);
                    if (System.IO.File.Exists(path))
                    {
                        ViewBag.Thongbao = "Hình ảnh đã tồn tại";
                        return(View());
                    }
                    else
                    {
                        xe.HINHXE = fileName;

                        xe.MATINHTRANG = 1;
                        xe.MALOAIXE    = Convert.ToInt32(fc["MaLX"]);
                        xe.HANBAOHIEM  = Convert.ToDateTime(fc["hanbaohiem"]);
                        xe.HANBAOHIEM  = Convert.ToDateTime(fc["hanluuhanh"]);
                        data.XEs.Add(xe);
                        data.SaveChanges();
                        fileUpload.SaveAs(path);
                    }
                }
                return(RedirectToAction("Thongtinxe"));
            }
        }
예제 #21
0
 public void InsertXe(XE xe)
 {
     _dataContext.XEs.InsertOnSubmit(xe);
     _dataContext.SubmitChanges();
 }
        private void AddNodeToFeed(string parentId, XContainer node)
        {
            //Get node values
            var idAttribute = node.XPathSelectElement("./DVAL/DVAL_ID").Attribute("ID");

            if (idAttribute == null)
            {
                return;
            }
            var id          = idAttribute.Value;
            var displayName = node.XPathSelectElement("./DVAL/SYN[@DISPLAY='TRUE']").Value;

            foreach (var synonym in node.XPathSelectElements("./DVAL/SYN[@DISPLAY='FALSE'][@CLASSIFY='TRUE']"))
            {
                if (synonym.Value == id)
                {
                    continue;
                }
                if (_synonymsDict.Keys.Contains(synonym.Value))
                {
                    _synonymsDict[synonym.Value] = new Category(displayName, id);
                }
                else
                {
                    _synonymsDict.Add(synonym.Value, new Category(displayName, id));
                }
            }

            //Create node
            var current      = new XE(_gNsAtom + DefaultNodeName);
            var idElement    = new XE(_gNsAtom + "id", id);
            var titleElement = new XE(_gNsAtom + "title", displayName);
            //link?? - is it mandatory?
            var linkElement = new XE(_gNsAtom + "link");
            var linkAttr    = new XA("href", _indigoLink);

            linkElement.Add(linkAttr);
            var parentsElement = new XE(_gNsG + "parents", parentId);
            var groupElement   = new XE(_gNsG + "group", _taxonomyVersionName);

            current.Add(new object[] { idElement, titleElement, linkElement, parentsElement, groupElement });

            //Add node to the feed
            _feedElement.Add(current);

            // Add the node info to the breadcrumbs list
            if (_categoryBreadcrumbs.ContainsKey(parentId))
            {
                _categoryBreadcrumbs.Add(id, _categoryBreadcrumbs[parentId] + " > " + displayName);
            }
            else
            {
                _categoryBreadcrumbs.Add(id, "{TOP_LEVEL}");
            }

            //Add childrens as well
            foreach (var child in node.Elements("DIMENSION_NODE"))
            {
                AddNodeToFeed(id, child);
            }
        }
예제 #23
0
        private void Deserialize_Click(object sender, EventArgs e)
        {
            try
            {
                if (rslt2 == null || rslt2.Reports == null || rslt2.Reports.Report == null || rslt2.Reports.Report[0].FileContent == null)
                {
                    // Error OAC response or member is null
                    LogBox.Text += "Error: OAC response or member is null.." + Environment.NewLine;
                    return;
                }

                // File content contains base 64 encoded xml to retrieve info
                string encoded = rslt2.Reports.Report[0].FileContent;

                LogBox.Text += "File Content: " + Environment.NewLine;
                LogBox.Text += encoded + Environment.NewLine + Environment.NewLine;

                // Decode the message into byte array
                var decoded = Convert.FromBase64String(encoded);

                // Convert byte array to string
                string xmlMessage = Encoding.Default.GetString(decoded);
                if (xmlMessage.Trim() == "")
                {
                    LogBox.Text += "**** xml message is empty ****" + Environment.NewLine;
                }
                LogBox.Text += "xml message decoded is: " + Environment.NewLine;
                LogBox.Text += xmlMessage + Environment.NewLine + Environment.NewLine;

                while (true)
                {
                    int startIndex = xmlMessage.IndexOf("<ACTIVATION_CODE>");
                    if (startIndex < 0)
                    {
                        break;
                    }
                    int endIndex = xmlMessage.IndexOf("</ACTIVATION_CODE>");
                    int length   = endIndex - (startIndex + 17);
                    xmlMessage = xmlMessage.Remove(startIndex, length + 35);
                }
                itemNumbers.Clear();
                // Parse the message (in XML) MAKE SURE xmlMessage is NOT NULL
                try
                {
                    XElement str = XElement.Parse(xmlMessage);
                    LogBox.Text += "xml parsed." + Environment.NewLine;
                    //itemNumbers.Clear();
                    // find specific tag
                    foreach (XElement XE in str.Elements("ITEM_DETAILS"))
                    {
                        string number = XE.Descendants("OPTION_CODE").FirstOrDefault()?.Value;
                        string xmltag = XE.Descendants("XML_TAG").FirstOrDefault()?.Value;
                        if (xmltag != "SWOPT")
                        {
                            if (!itemNumbers.Contains(number))
                            {
                                itemNumbers.Add(number);
                            }
                        }
                        else
                        {
                            string opt = XE.Descendants("OPTION_NAME").FirstOrDefault()?.Value;
                            if (opt.Contains("Vivid"))
                            {
                                string[] pns = number.Split(',');
                                foreach (string pn in pns)
                                {
                                    if (!itemNumbers.Contains(pn))
                                    {
                                        itemNumbers.Add(pn);
                                    }
                                }
                            }
                        }
                    }

                    txtResponse.Text += "Item numbers found: " + (itemNumbers.Count == 0 ? "None" : "") + Environment.NewLine;
                    foreach (string item in itemNumbers)
                    {
                        txtResponse.Text += item + Environment.NewLine;
                    }
                }
                catch (Exception ex)
                {
                    LogBox.Text += Environment.NewLine + "Exception thrown when parsing. Message: " + ex.Message.ToString() + Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception when deserializing. Message: " + ex.Message.ToString());
            }
        }
예제 #24
0
        private XE EntryAttribute(string catalog, IDataReader reader, StringDictionary dict
                                  , string gId
                                  , string sanitizedTitle
                                  , string linkCatalog
                                  , string linkSku
                                  , string gPrice
                                  , string gAdjustedPrice
                                  , string gAvailability
                                  , string gBrandName,
                                  string publisherName,
                                  XE contributors,
                                  string breadcrumb, bool isZeroCommissionProduct, string merchandiseType, IRuleEvaluationResult promotionalTextEvaluationResult, string description)
        {
            //entry
            var entry = new XE("product");

            sanitizedTitle = GetCjString(sanitizedTitle, MaxTitleLength);
            var name = new XE("name", sanitizedTitle);

            entry.Add(name);

            var keywordsValue = string.Empty;

            // First get the major contributor text
            if (!string.IsNullOrWhiteSpace(gBrandName))
            {
                keywordsValue = gBrandName;
            }
            else if (contributors != null)
            {
                keywordsValue = contributors.Value;
            }

            // Now add the breadcrumb
            if (!string.IsNullOrWhiteSpace(keywordsValue))
            {
                keywordsValue += ", ";
            }

            keywordsValue += string.Join(", ", breadcrumb.Split(new[] { BreadcrumbTrailSplitter }, StringSplitOptions.RemoveEmptyEntries)) + ", ";
            keywordsValue += sanitizedTitle;
            var keywords = new XE("keywords", GetCjString(keywordsValue, MaxKeywordLength));

            entry.Add(keywords);

            var descriptionValue = GetCjString(FeedUtils.RemoveHtmlTags(description), MaxDescriptionLength);

            if (string.IsNullOrWhiteSpace(descriptionValue))
            {
                descriptionValue = sanitizedTitle;
            }
            var descriptionXe = new XE("description", descriptionValue);

            entry.Add(descriptionXe);

            var gaId = new XE("sku", gId);

            entry.Add(gaId);

            var aLink = FeedEntryLink(GetFeedEntryLinkValue(reader, linkCatalog, linkSku));

            entry.Add(aLink);

            var available = new XE("available", "Yes");

            entry.Add(available);

            var aImgLink = EntryImageLink(reader, linkSku);

            entry.Add(aImgLink);

            Decimal price;
            bool    isSpecial = false;

            if (DisplaySalePriceInfo)
            {
                if (Decimal.TryParse(gPrice, out price))
                {
                    var gaPrice = new XE("price", price.ToString("F", CultureInfo.InvariantCulture));
                    entry.Add(gaPrice);

                    Decimal salePrice;
                    if (!string.IsNullOrWhiteSpace(gAdjustedPrice) && Decimal.TryParse(gAdjustedPrice, out salePrice) && salePrice != price)
                    {
                        isSpecial = true;
                        var gaSalePrice = new XE("saleprice", salePrice.ToString("F", CultureInfo.InvariantCulture));
                        entry.Add(gaSalePrice);
                    }
                }
            }
            else
            {
                price = Decimal.Parse(gAdjustedPrice);
                var gaPrice = new XE("price", price.ToString("F", CultureInfo.InvariantCulture));
                entry.Add(gaPrice);
            }

            entry.Add(new XE("currency", "CAD"));

            // CJ expects the optional xml nodes in a certain order
            var isBook = catalog.Equals("books", StringComparison.OrdinalIgnoreCase);

            if (!isBook && (linkSku.Length == 12 || linkSku.Length == 13))
            {
                entry.Add(new XE("upc", linkSku));
            }

            if (promotionalTextEvaluationResult.HasMatch)
            {
                if (!promotionalTextEvaluationResult.IsDefaultMatch)
                {
                    isSpecial = true;
                }

                var promoTextValue = GetCjString(promotionalTextEvaluationResult.MatchingRulePayLoads.First(), MaxPromotionalTextLength);
                entry.Add(new XE("promotionaltext", promoTextValue));
            }

            var advertiserCategoryText = breadcrumb.Replace(BreadcrumbTrailSplitter, ">");

            entry.Add(new XE("advertisercategory", GetCjString(advertiserCategoryText, MaxAdvertiserCategoryLength)));

            if (!string.IsNullOrWhiteSpace(gBrandName))
            {
                var manufacturer = GetCjString(gBrandName, MaxManufacturerLength);
                entry.Add(new XE("manufacturer", manufacturer));
                entry.Add(new XE("manufacturerid", linkSku));
            }

            if (isBook)
            {
                entry.Add(new XE("isbn", linkSku));

                if (contributors != null)
                {
                    entry.Add(new XE("author", GetCjString(contributors.Value, MaxManufacturerLength)));
                }

                if (!string.IsNullOrWhiteSpace(publisherName))
                {
                    entry.Add(new XE("publisher", GetCjString(publisherName, MaxManufacturerLength)));
                }
            }
            else
            {
                if (contributors != null)
                {
                    entry.Add(new XE("artist", GetCjString(contributors.Value, MaxManufacturerLength)));
                }
            }

            entry.Add(new XE("title", sanitizedTitle));

            if (!isBook)
            {
                if (!string.IsNullOrWhiteSpace(publisherName))
                {
                    entry.Add(new XE("label", GetCjString(publisherName, MaxManufacturerLength)));
                }

                if (dict.ContainsKey("format"))
                {
                    var format = reader[dict["format"]].ToString();
                    if (!string.IsNullOrWhiteSpace(format))
                    {
                        entry.Add(new XE("format", format));
                    }
                }
            }

            entry.Add(new XE("special", (isSpecial) ? "Yes" : "No"));

            if (catalog.Equals("generalmerchandise", StringComparison.OrdinalIgnoreCase))
            {
                entry.Add(new XE("gift", "Yes"));
            }

            entry.Add(new XE("instock", (string.IsNullOrWhiteSpace(gAvailability)) ? "No" : "Yes"));
            entry.Add(new XE("condition", "New"));

            if (!string.IsNullOrWhiteSpace(DefaultShippingCost))
            {
                entry.Add(new XE("standardshippingcost", DefaultShippingCost));
            }

            if (string.IsNullOrWhiteSpace(merchandiseType))
            {
                entry.Add(new XE("merchandisetype", ZeroCommissionListName));
            }
            else
            {
                if (isZeroCommissionProduct)
                {
                    entry.Add(new XE("merchandisetype", ZeroCommissionListName));
                    // If the merchandise type has a different value and it's not equal to zero commission list
                    // and if we're putting the item on the zero commission list, add it to the list of items to be
                    // updated inside the
                    if (!merchandiseType.Equals(ZeroCommissionListName, StringComparison.OrdinalIgnoreCase))
                    {
                        _updatedMerchandiseTypeProductPids.Add(decimal.Parse(gId));
                    }

                    Log.DebugFormat("Product {0} was put in zero commission list.", gId);
                }
                else
                {
                    entry.Add(new XE("merchandisetype", merchandiseType));
                }
            }

            return(entry);
        }
예제 #25
0
 public void InsertXe(XE xe)
 {
     _xeDao.InsertXe(xe);
 }
예제 #26
0
 public void UpdateXe(XE xe)
 {
     _xeDao.UpdateXe(xe);
 }
예제 #27
0
        public static IProductData GetProductData(StringDictionary dict, IDataReader reader, string sku, string catalog, string brandName, XE contributorElement, IIndigoBreadcrumbCategory defaultCategory)
        {
            var    browseCategories = new List <int>();
            string secondarySku     = null;
            string author           = null;

            if (dict.ContainsKey("gProductType"))
            {
                var browseCategoriesValue = reader[dict["gProductType"]];
                if (browseCategoriesValue != null)
                {
                    browseCategories.AddRange(browseCategoriesValue.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse));
                }
            }

            // For books and ebooks, set the secondary sku too
            if (catalog.Equals("books", StringComparison.InvariantCultureIgnoreCase) ||
                catalog.Equals("ebooks", StringComparison.InvariantCultureIgnoreCase))
            {
                secondarySku = reader[dict["secondarySku"]].ToString();
                if (contributorElement != null)
                {
                    author = contributorElement.Value;
                }
            }

            return(IndigoBreadcrumbRepositoryUtils.GetProductData(sku, secondarySku, brandName, author, defaultCategory, browseCategories));
        }