示例#1
0
        public void ReportNewOrderItemUpdate(OrderItemModel orderItem)
        {
            // get the NotificationHub
            var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            // Extract the real chillin order status id from the umbraco id.
            int      chillinOrderStatusId = 0;
            var      ds = new Umbraco.Core.Services.DataTypeService();
            PreValue iter;

            foreach (DictionaryEntry pv in _umbraco.GetPreValues(ConfigurationManager.AppSettings["umbracoOrderStatusDataTypeDefinitionName"]))
            {
                iter = ((PreValue)pv.Value);
                if (iter.Id == orderItem.StatusId)
                {
                    chillinOrderStatusId = Convert.ToInt32(iter.Value.Split(':').First());
                    break;
                }
            }

            // create a notication object to send to the clients
            var n = new OrderItemNotification
            {
                NodeId             = orderItem.NodeId,
                EditedBy           = orderItem.EditedBy,
                EditedByMemberName = orderItem.EditedByMemberName,
                SignificantUpdate  = true,
                IsPending          = chillinOrderStatusId == 1 || chillinOrderStatusId == 2 || chillinOrderStatusId == 9 || (chillinOrderStatusId > 2 && chillinOrderStatusId <5 && DateTime.Now> orderItem.FollowUpDate),
                UpdateFromMail     = false
            };

            // this calls the javascript method updateStream(message) in all connected browsers
            context.Clients.All.updateStream(n);
        }
示例#2
0
        private void PopulateCacheWithDataTypePreValues()
        {
            var c  = System.Web.HttpContext.Current.Cache;
            var ds = new Umbraco.Core.Services.DataTypeService();

            foreach (var dtd in ds.GetAllDataTypeDefinitions())
            {
                c.Insert(dtd.Name, PreValues.GetPreValues(dtd.Id));
            }
        }
示例#3
0
        public static string GetSettingFromPropertyEditor(string alias)
        {
            var dts = new Umbraco.Core.Services.DataTypeService();
            var datatype = dts.GetDataTypeDefinitionByPropertyEditorAlias("NW.PieMan").First();
            var settings = dts.GetPreValuesByDataTypeId(datatype.Id).ToList()[0];

            var o = JsonConvert.DeserializeObject<ConfigSettings>(settings);

            if (alias == "ClientId")
                return o.client_id;
            else if (alias == "ClientSecret")
                return o.client_secret;
            else if (alias == "RefreshToken")
                return o.refresh_token;

            return string.Empty;
        }
示例#4
0
        public static void SetTokenFromPropertyEditor(string value)
        {
            var dts = new Umbraco.Core.Services.DataTypeService();
            var datatype = dts.GetDataTypeDefinitionByPropertyEditorAlias("NW.PieMan").First();
            var settings = dts.GetPreValuesByDataTypeId(datatype.Id).ToList();

            var o = JsonConvert.DeserializeObject<ConfigSettings>(settings.First());
            o.refresh_token = value;

            var prevalue = new PreValue(JsonConvert.SerializeObject(o));

            var dict = new Dictionary<string, Umbraco.Core.Models.PreValue>();
            dict.Add("settings", prevalue);
            dict.Add("account", new PreValue(settings[1]));
            dict.Add("profile", new PreValue(settings[2]));

            dts.SaveDataTypeAndPreValues(datatype, dict);
        }
示例#5
0
        public static Dictionary <int, string> GetAllAllowedDataTypes()
        {
            //uLocate.Constants includes the text-based list of allowed PropertyEditors

            Dictionary <int, string> ReturnDict = new Dictionary <int, string>();

            foreach (var PropEditor in uLocate.Constants.AllowedPropertyEditors)
            {
                var dtService = new Umbraco.Core.Services.DataTypeService();

                var ResultList = dtService.GetDataTypeDefinitionByPropertyEditorAlias(PropEditor);

                foreach (var DataType in ResultList)
                {
                    ReturnDict.Add(DataType.Id, DataType.Name);
                }
            }

            return(ReturnDict);
        }
示例#6
0
        /// <summary>
        /// Get all the prevalues for a given data type.
        /// </summary>
        /// <param name="dataTypeName">The name of the data type.</param>
        /// <returns>A sorted list with the prevalues.</returns>
        public SortedList GetPreValues(string dataTypeName)
        {
            // Get a sorted list of all prevalues from the cache
            var        c           = System.Web.HttpContext.Current.Cache;
            SortedList statusTypes = c.Get(dataTypeName) as SortedList;

            if (statusTypes == null)
            {
                // Connect to Umbraco DataTypeService
                var ds = new Umbraco.Core.Services.DataTypeService();

                // Get the Definition Id
                int dataTypeDefinitionId = ds.GetAllDataTypeDefinitions().First(x => x.Name == dataTypeName).Id;

                // Get a sorted list of all prevalues and store it in the cache
                statusTypes = PreValues.GetPreValues(dataTypeDefinitionId);
                c.Insert(dataTypeName, statusTypes);
            }

            return(statusTypes);
        }
示例#7
0
        public static Dictionary<int, string> GetAllAllowedDataTypes()
        {
            //uLocate.Constants includes the text-based list of allowed PropertyEditors

            Dictionary<int, string> ReturnDict = new Dictionary<int, string>();

            foreach (var PropEditor in uLocate.Constants.AllowedPropertyEditors)
            {
                var dtService = new Umbraco.Core.Services.DataTypeService();

                var ResultList = dtService.GetDataTypeDefinitionByPropertyEditorAlias(PropEditor);

                foreach (var DataType in ResultList)
                {
                    ReturnDict.Add(DataType.Id, DataType.Name);
                }
            }

            return ReturnDict;
        }