public static CClientInfo GetClientInfo(bool forceRenew)
    {
        CClientInfo clientInfo = null;

        if (forceRenew)
        {
            try
            {
                clientInfo = UltimaWebService.GetClientInfo();
            }
            catch (Exception ex)
            {
                SessionErrors.Add(ex.Message);
                SignOut();
            }

            SetClientInfo(clientInfo);
        }
        else
        {
            clientInfo = (CClientInfo)HttpContext.Current.Session["ClientInfo"];
        }

        if (clientInfo == null && HttpContext.Current.User.Identity.IsAuthenticated)
        {
            SignOut();
        }

        return(clientInfo);
    }
示例#2
0
    public static CCatalog GetCatalog(int langid, int?CategoryId, string SortField, string SortOrder, int PageSize, int PageNo,
                                      string SearchQuery, int?[] BrandId, string[] BrandNames, decimal?PriceFrom, decimal?PriceTo, string Availablity, List <CRequestFilter> filter, DateTime?DateAdded = null)
    {
        try
        {
            Hashtable pars = new Hashtable();
            pars["langid"]       = langid;
            pars["CategoryId"]   = CategoryId;
            pars["SortField"]    = SortField;
            pars["SortOrder"]    = SortOrder;
            pars["PageSize"]     = PageSize;
            pars["PageNo"]       = PageNo;
            pars["SearchQuery"]  = SearchQuery;
            pars["BrandId"]      = BrandId;
            pars["PriceFrom"]    = PriceFrom;
            pars["PriceTo"]      = PriceTo;
            pars["Availability"] = Availablity;
            pars["Filter"]       = filter;
            pars["BrandNames"]   = BrandNames;
            pars["DateAdded"]    = DateAdded;

            CCatalog cat = GetObject <CCatalog>("GetCatalog", pars);

            return(cat);
        }
        catch (Exception ex)
        {
            SessionErrors.Add(ex);
            throw;
        }
    }
示例#3
0
    public static void Reset()
    {
        SessionErrors err = Current;

        lock (err.lockObj)
        {
            err.ErrorsList = new List <string>();
            HttpContext.Current.Session.Remove(Key);
        }
    }
示例#4
0
 public static void Add(string error)
 {
     if (Allowed)
     {
         SessionErrors err = Current;
         lock (err.lockObj)
         {
             err.ErrorsList.Add(error);
             err.Update();
         }
     }
 }
示例#5
0
 public static void Add(Exception ex)
 {
     if (Allowed)
     {
         SessionErrors err = Current;
         lock (err.lockObj)
         {
             err.ErrorsList.Add(ex.Message + Environment.NewLine + ex.StackTrace);
             err.Update();
         }
     }
 }
示例#6
0
    static string Log(Exception ex, string requestUri, string paramString)
    {
        string msg = "Ultima Server error: " + ex.Message + ", " + requestUri + ", param: " + paramString;

        if (ex is WebException)
        {
            HttpWebResponse res = (HttpWebResponse)((WebException)ex).Response;
            if (res != null)
            {
                msg = "Ultima Server error: " + WebUtility.UrlDecode((res == null? " - " : res.Headers["UltimaErrorText"]) + " (" + ex.Message + ", " + requestUri + ", param: " + paramString + "), StatusCode: " + (int)res.StatusCode);
            }
        }
        SessionErrors.Add(msg);
        Umbraco.Core.Logging.LogHelper.Info(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, msg.Replace("{", "{{").Replace("}", "}}"));
        return(msg);
    }
示例#7
0
    public static COrder CreateReserve(long agentId, long addressId, string comments)
    {
        try
        {
            Dictionary <string, string> res = new Dictionary <string, string>();

            var basket = SessionBasket.GetBasket();

            ArticleInfo[] prodInfo = new ArticleInfo[basket.Where(x => x.Key > 0).Count()];

            int i = 0;
            foreach (var key in basket.Keys)
            {
                if (key > 0)
                {
                    prodInfo[i] = new ArticleInfo(key, basket[key]);
                    i++;
                }
            }

            DeliveryInfo delInfo = new DeliveryInfo(addressId, comments);

            Hashtable pars = new Hashtable();
            pars["Articles"] = prodInfo;
            pars["Delivery"] = delInfo;
            //pars["AgentId"] = agentId; // agentid will be taken from session by the server! do not use this field!
            pars["ReserveOfficeId"] = 1;
            pars["ObtainMethod"]    = "delivery";          // ownStorePickup, simplified_shipping - some magic hardcoded values in ultima2c..
            //pars["ShippingAddress"] = address;

            COrder order = GetObject <COrder>("CreateReserve", pars);

            return(order);
        }
        catch (Exception ex)
        {
            SessionErrors.Add(ex);
            throw;
        }
    }
示例#8
0
    public static decimal GetDeliveryCost(long addressId)
    {
        try
        {
            Dictionary <string, string> res = new Dictionary <string, string>();

            var basket = SessionBasket.GetBasket();

            ArticleInfo[] prodInfo = new ArticleInfo[basket.Where(x => x.Key > 0).Count()];

            int i = 0;
            foreach (var key in basket.Keys)
            {
                if (key > 0)
                {
                    prodInfo[i] = new ArticleInfo(key, basket[key]);
                    i++;
                }
            }

            DeliveryInfo delInfo = new DeliveryInfo(addressId, string.Empty);

            Hashtable pars = new Hashtable();
            pars["Articles"]        = prodInfo;
            pars["Delivery"]        = delInfo;
            pars["ReserveOfficeId"] = 1;

            ValueValue order = GetObject <ValueValue>("GetDeliveryCost", pars);

            return(order.Value);
        }
        catch (Exception ex)
        {
            SessionErrors.Add(ex);
            throw ex;
        }
    }
    public static List <CDeliveryAddress> GetDeliveryAddresses(bool forceRenew)
    {
        List <CDeliveryAddress> deliveryAddresses = null;

        if (forceRenew || deliveryAddresses == null)
        {
            try
            {
                deliveryAddresses = UltimaWebService.GetDeliveryAddresses();
            }
            catch (Exception ex)
            {
                SessionErrors.Add(ex.Message);
            }

            SetDeliveryAddresses(deliveryAddresses);
        }
        else
        {
            deliveryAddresses = (List <CDeliveryAddress>)HttpContext.Current.Session["DeliveryAddresses"];
        }

        return(deliveryAddresses);
    }
示例#10
0
 /// <summary>
 /// Adds error to <see cref="SessionErrors"/>.
 /// </summary>
 public static void AddError(Exception ex)
 {
     SessionErrors.Add(ex);
 }