Example #1
0
    public static byte[] GetProductImage(long goodID, int viewID, bool useCache)
    {
        if (useCache && prodPhotoCache.ContainsKey(goodID))
        {
            return(prodPhotoCache[goodID]);
        }

        byte[] bytes = DiskCache.GetImage(goodID, 0, viewID);
        if (bytes != null)
        {
            return(bytes);
        }
        else
        {
            bytes = ImageUtility.GetNoImageStub();
        }

        Hashtable pars = new Hashtable();

        pars["ProductIds"] = new long[] { goodID };
        XmlDocument         doc   = UltimaWebService.GetXmlResponse("GetProductPhotos", pars);
        XmlNamespaceManager nsmgr = doc.NsMan();

        try
        {
            if (doc.DocumentElement.ChildNodes.Count > 0)
            {
                string data = doc.DocumentElement.SelectSingleNode(String.Format("{0}:GetProductPhotosResponse/{0}:Content", doc.GetPrefix()), nsmgr).InnerText;
                viewID = Convert.ToInt32(doc.DocumentElement.SelectSingleNode(String.Format("{0}:GetProductPhotosResponse/{0}:ViewId", doc.GetPrefix()), nsmgr).InnerText);

                bytes = Convert.FromBase64String(data);
                if (bytes != null)
                {
                    DiskCache.WriteImage(bytes, goodID, 0, viewID);
                }
            }
        }
        catch (Exception ex)
        {
            throw new Exception("Error Getting Image", ex);
        }

        if (useCache)
        {
            prodPhotoCache[goodID] = bytes;
        }

        return(bytes);
    }
Example #2
0
    public static int ReloadProductsPrices()
    {
        XmlDocument doc;

        Hashtable pars = new Hashtable();

        pars["CategoryIds"] = new long[] { 1 };
        pars["ZoneIds"]     = new long[] { 1 };
        doc = UltimaWebService.GetXmlResponse("GetProductPrices", pars);
        XmlNamespaceManager nsmgr = doc.NsMan();

        foreach (XmlNode node in doc.DocumentElement.SelectNodes(String.Format("{0}:GetProductPricesResponse", doc.GetPrefix()), nsmgr))
        {
            prodPricesCache[Convert.ToInt64(node.SelectSingleNode(doc.Prefixed("ProductId"), nsmgr).InnerText)] = Convert.ToDecimal(node.SelectSingleNode(doc.Prefixed("Value"), nsmgr).InnerText);
        }

        return(prodPricesCache.Count);
    }
Example #3
0
    public static string GetProductInfo(long goodID, string dataField, bool useCache)
    {
        XmlDocument doc;

        if (prodInfoCache.ContainsKey(goodID) && useCache)
        {
            doc = prodInfoCache[goodID];
        }
        else
        {
            Hashtable pars = new Hashtable();
            pars["ProductsIds"] = new long[] { goodID };
            doc = UltimaWebService.GetXmlResponse("GetProducts", pars);
            prodInfoCache[goodID] = doc;
        }
        XmlNamespaceManager nsmgr = doc.NsMan();

        return(doc.DocumentElement.SelectSingleNode(String.Format("{0}:GetProductsResponse/{0}:{1}", doc.GetPrefix(), dataField), nsmgr).InnerText);
    }
Example #4
0
    public static byte[] GetProductImage(long goodID, bool useCache)
    {
        if (prodPhotoCache.ContainsKey(goodID) && useCache)
        {
            return(prodPhotoCache[goodID]);
        }

        Hashtable pars = new Hashtable();

        pars["ProductIds"] = new long[] { goodID };
        XmlDocument         doc   = UltimaWebService.GetXmlResponse("GetProductPhotos", pars);
        XmlNamespaceManager nsmgr = doc.NsMan();

        byte[] bytes = GetNoImageStub();
        try
        {
            string data = doc.DocumentElement.SelectSingleNode(String.Format("{0}:GetProductPhotosResponse/{0}:Content", doc.GetPrefix()), nsmgr).InnerText;
            bytes = Convert.FromBase64String(data);
        }
        catch { }

        prodPhotoCache[goodID] = bytes;
        return(bytes);
    }