Example #1
0
 private void SaveState(string origState, string state)
 {
     if (_nodb)
     {
         State = state;
     }
     else
     {
         ZbuKeyValueStore.SetValue("Zbu.Yol.Manager." + _name + ".State", origState, state);
     }
 }
Example #2
0
        internal void Execute(HttpApplication umbracoApplication, ApplicationContext applicationContext)
        {
            if (umbracoApplication == null)
            {
                throw new ArgumentNullException("umbracoApplication");
            }
            if (applicationContext == null)
            {
                throw new ArgumentNullException("applicationContext");
            }

            // temp for compat
            if (!_nodb)
            {
                var state = ZbuKeyValueStore.GetValue("Zbu.Yol.Manager." + _name + ".State");
                if (string.IsNullOrWhiteSpace(state) && !string.IsNullOrWhiteSpace(_statePath))
                {
                    try
                    {
                        state = File.ReadAllText(_statePath);
                    }
                    catch (Exception)
                    {
                        state = null;
                    }
                    if (!string.IsNullOrWhiteSpace(state))
                    {
                        LogHelper.Info <YolManager>("Copying state from file to database.");
                        ZbuKeyValueStore.SetValue("Zbu.Yol.Manager." + _name + ".State", state);
                    }
                }
            }

            ValidateTransitions();

            // impersonate and run - in a using() block to ensure we terminate properly impersonation,
            // whatever happens when executing transitions.
            using (Security.Impersonate(umbracoApplication, applicationContext, _login))
            {
                ExecuteInternal();
            }
        }