private void SendNotifys(WF_WORKFLOW_INST mainRow, IUnitOfData source)
        {
            try
            {
                INotifyAction notifyAction;
                if (!NotifyActions.IsNotEmpty())
                {
                    NotifyActions.Add("DefaultNotifyAction");
                }
                //if (NotifyActions.IndexOf("NotifyAction") < 0 )
                //{
                //    NotifyActions.Add("NotifyAction");
                //}

                foreach (var notify in NotifyActions)
                {
                    notifyAction = notify.CodePlugIn <INotifyAction>();
                    notifyAction.DoPush(QuoteIdList.LoadFromString(mainRow.WI_RECEIVE_LIST), null, mainRow, source);
                    //DoActionDelegate doActionDelegate = new DoActionDelegate(notifyAction.DoAction);
                    foreach (var userID in QuoteIdList.LoadFromString(mainRow.WI_RECEIVE_LIST))
                    {
                        notifyAction.DoAction(userID, mainRow, null, source);
                        //doActionDelegate.BeginInvoke(userID, mainRow, WorkflowInstUtil.CreateContent(mainRow), source, null, null);
                    }
                }

                //----------
            }
            catch (Exception ex)
            {
                string str = "工作流触发异常:" + ex.Message;
                AtawAppContext.Current.Logger.Debug(str);
                AtawTrace.WriteFile(LogType.Error, str);
            }
        }
Beispiel #2
0
        public async Task <List <PuckUser> > UsersToNotify(string path, NotifyActions action)
        {
            //var user = HttpContext.Current.User.Identity.Name;
            var strAction = action.ToString();
            var metas     = repo.GetPuckMeta()
                            .Where(x => x.Name.Contains(":" + strAction /*+ ":"*/))
                            .Where(
                x => x.Key.Equals(path) && x.Name.Contains(":.:")
                ||
                x.Key.StartsWith(path) && x.Name.Contains(":*:")
                )
                            .ToList();
            var usernames = metas.Select(x => x.Value).ToList();
            var users     = new List <PuckUser>();

            foreach (var username in usernames)
            {
                var user = await userManager.FindByNameAsync(username);

                if (user != null)
                {
                    users.Add(user);
                }
            }
            return(users);
        }
        public static string EmailTransform(string template, BaseModel model, NotifyActions action)
        {
            string date    = DateTime.Now.ToShortDateString();
            string time    = DateTime.Now.ToShortTimeString();
            string user    = "";
            string editUrl = "";

            try {
                var hcontext = HttpContext.Current;
                user = hcontext?.User?.Identity?.Name ?? "";
                var uri = hcontext?.Request?.GetUri() ?? PuckCache.FirstRequestUrl;
                editUrl = uri.Scheme + "://"
                          + uri.Host
                          + (uri.Port != 80 ?(":" + uri.Port):"")
                          + "/puck?hash="
                          + HttpUtility.UrlEncode("content?id=" + model.Id.ToString() + "&variant=" + model.Variant);
            }
            catch (Exception ex) {
                PuckCache.PuckLog.Log(ex);
            }
            template = template
                       .Replace("<!--Id-->", model.Id.ToString())
                       .Replace("<!--NodeName-->", model.NodeName)
                       .Replace("<!--LastEditedBy-->", model.LastEditedBy)
                       .Replace("<!--CreatedBy-->", model.CreatedBy)
                       .Replace("<!--Path-->", model.Path)
                       .Replace("<!--Created-->", model.Created.ToString("dd/MM/yyyy hh:mm:ss"))
                       .Replace("<!--Updated-->", model.Updated.ToString("dd/MM/yyyy hh:mm:ss"))
                       .Replace("<!--Revision-->", model.Revision.ToString())
                       .Replace("<!--Variant-->", model.Variant)
                       .Replace("<!--Published-->", model.Published.ToString())
                       .Replace("<!--SortOrder-->", model.SortOrder.ToString())
                       .Replace("<!--TemplatePath-->", model.TemplatePath)
                       .Replace("<!--TypeChain-->", model.TypeChain)
                       .Replace("<!--Type-->", model.Type)
                       .Replace("<!--__Verb__", action.ToString())
                       .Replace("<!--EditUrl-->", editUrl)
                       .Replace("<!--Date-->", date)
                       .Replace("<!--Time-->", time)
                       .Replace("<!--User-->", user)
            ;
            return(template);
        }
Beispiel #4
0
        protected bool ReadXmlInternal(XmlReader reader, string password = null)
        {
            bool changed = false;

            decimal version;

            if (decimal.TryParse(reader.GetAttribute("version"), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out version) == true)
            {
                Version = version;

                if (version > WinAuthConfig.CURRENTVERSION)
                {
                    // ensure we don't overwrite a newer config
                    throw new WinAuthInvalidNewerConfigException(string.Format(strings.ConfigIsNewer, version));
                }
            }

            string encrypted = reader.GetAttribute("encrypted");

            this.PasswordType = Authenticator.DecodePasswordTypes(encrypted);
            if (this.PasswordType != Authenticator.PasswordTypes.None)
            {
                // read the encrypted text from the node
                string data = reader.ReadElementContentAsString();
                // decrypt
                YubiKey yubi = null;
                if ((this.PasswordType & (Authenticator.PasswordTypes.YubiKeySlot1 | Authenticator.PasswordTypes.YubiKeySlot2)) != 0 /* && this.Yubi == null */)
                {
                    yubi = YubiKey.CreateInstance();
                }
                data = Authenticator.DecryptSequence(data, this.PasswordType, password, yubi);

                using (MemoryStream ms = new MemoryStream(Authenticator.StringToByteArray(data)))
                {
                    reader  = XmlReader.Create(ms);
                    changed = ReadXml(reader, password);
                }

                this.PasswordType = Authenticator.DecodePasswordTypes(encrypted);
                this.Password     = password;
                this.Yubi         = yubi;

                return(changed);
            }

            reader.MoveToContent();
            if (reader.IsEmptyElement)
            {
                reader.Read();
                return(changed);
            }

            bool   defaultAutoRefresh = true;
            bool   defaultAllowCopy   = false;
            bool   defaultCopyOnCode  = false;
            bool   defaultHideSerial  = true;
            string defaultSkin        = null;

            reader.Read();
            while (reader.EOF == false)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "config":
                        changed = ReadXmlInternal(reader, password) || changed;
                        break;

                    // 3.2 has new layout
                    case "data":
                    {
                        encrypted         = reader.GetAttribute("encrypted");
                        this.PasswordType = Authenticator.DecodePasswordTypes(encrypted);
                        if (this.PasswordType != Authenticator.PasswordTypes.None)
                        {
                            string md5 = reader.GetAttribute("md5");
                            // read the encrypted text from the node
                            string data = reader.ReadElementContentAsString();

                            using (var hasher = new MD5CryptoServiceProvider())
                            {
                                hasher.ComputeHash(Authenticator.StringToByteArray(data));
                            }

                            // decrypt
                            YubiKey yubi = null;
                            if ((this.PasswordType & (Authenticator.PasswordTypes.YubiKeySlot1 | Authenticator.PasswordTypes.YubiKeySlot2)) != 0 /* && this.Yubi == null */)
                            {
                                yubi = YubiKey.CreateInstance();
                            }
                            data = Authenticator.DecryptSequence(data, this.PasswordType, password, yubi);
                            byte[] plain = Authenticator.StringToByteArray(data);

                            using (MemoryStream ms = new MemoryStream(plain))
                            {
                                var datareader = XmlReader.Create(ms);
                                changed = ReadXmlInternal(datareader, password) || changed;
                            }

                            this.PasswordType = Authenticator.DecodePasswordTypes(encrypted);
                            this.Password     = password;
                            this.Yubi         = yubi;
                        }
                    }
                    break;

                    case "alwaysontop":
                        _alwaysOnTop = reader.ReadElementContentAsBoolean();
                        break;

                    case "usetrayicon":
                        _useTrayIcon = reader.ReadElementContentAsBoolean();
                        break;

                    case "notifyaction":
                        string s = reader.ReadElementContentAsString();
                        if (string.IsNullOrEmpty(s) == false)
                        {
                            try {
                                _notifyAction = (NotifyActions)Enum.Parse(typeof(NotifyActions), s, true);
                            }
                            catch (Exception) { }
                        }
                        break;

                    case "startwithwindows":
                        _startWithWindows = reader.ReadElementContentAsBoolean();
                        break;

                    case "autosize":
                        _autoSize = reader.ReadElementContentAsBoolean();
                        break;

                    case "left":
                        _position.X = reader.ReadElementContentAsInt();
                        break;

                    case "top":
                        _position.Y = reader.ReadElementContentAsInt();
                        break;

                    case "width":
                        _width = reader.ReadElementContentAsInt();
                        break;

                    case "height":
                        _height = reader.ReadElementContentAsInt();
                        break;

                    case "shadowtype":
                        _shadowType = reader.ReadElementContentAsString();
                        break;

                    case "pgpkey":
                        _pgpKey = reader.ReadElementContentAsString();
                        break;

                    case "settings":
                        XmlSerializer serializer = new XmlSerializer(typeof(setting[]), new XmlRootAttribute()
                        {
                            ElementName = "settings"
                        });
                        _settings = ((setting[])serializer.Deserialize(reader)).ToDictionary(e => e.Key, e => e.Value);
                        break;

                    // previous setting used as defaults for new
                    case "autorefresh":
                        defaultAutoRefresh = reader.ReadElementContentAsBoolean();
                        break;

                    case "allowcopy":
                        defaultAllowCopy = reader.ReadElementContentAsBoolean();
                        break;

                    case "copyoncode":
                        defaultCopyOnCode = reader.ReadElementContentAsBoolean();
                        break;

                    case "hideserial":
                        defaultHideSerial = reader.ReadElementContentAsBoolean();
                        break;

                    case "skin":
                        defaultSkin = reader.ReadElementContentAsString();
                        break;

                    case "WinAuthAuthenticator":
                        var wa = new WinAuthAuthenticator();
                        changed = wa.ReadXml(reader, password) || changed;
                        this.Add(wa);
                        if (this.CurrentAuthenticator == null)
                        {
                            this.CurrentAuthenticator = wa;
                        }
                        break;

                    // for old 2.x configs
                    case "authenticator":
                        var waold = new WinAuthAuthenticator();
                        waold.AuthenticatorData = Authenticator.ReadXmlv2(reader, password);
                        if (waold.AuthenticatorData is BattleNetAuthenticator)
                        {
                            waold.Name = "Battle.net";
                        }
                        else if (waold.AuthenticatorData is GuildWarsAuthenticator)
                        {
                            waold.Name = "GuildWars 2";
                        }
                        else if (waold.AuthenticatorData is GuildWarsAuthenticator)
                        {
                            waold.Name = "Authenticator";
                        }
                        this.Add(waold);
                        this.CurrentAuthenticator = waold;
                        waold.AutoRefresh         = defaultAutoRefresh;
                        waold.AllowCopy           = defaultAllowCopy;
                        waold.CopyOnCode          = defaultCopyOnCode;
                        waold.HideSerial          = defaultHideSerial;
                        break;

                    // old 2.x auto login script
                    case "autologin":
                        var hks = new HoyKeySequence();
                        hks.ReadXml(reader, password);
                        if (hks.HotKey != 0)
                        {
                            if (this.CurrentAuthenticator.HotKey == null)
                            {
                                this.CurrentAuthenticator.HotKey = new HotKey();
                            }
                            HotKey hotkey = this.CurrentAuthenticator.HotKey;
                            hotkey.Action    = HotKey.HotKeyActions.Inject;
                            hotkey.Key       = hks.HotKey;
                            hotkey.Modifiers = hks.Modifiers;
                            if (hks.WindowTitleRegex == true && string.IsNullOrEmpty(hks.WindowTitle) == false)
                            {
                                hotkey.Window = "/" + Regex.Escape(hks.WindowTitle);
                            }
                            else if (string.IsNullOrEmpty(hks.WindowTitle) == false)
                            {
                                hotkey.Window = hks.WindowTitle;
                            }
                            else if (string.IsNullOrEmpty(hks.ProcessName) == false)
                            {
                                hotkey.Window = hks.ProcessName;
                            }
                            if (hks.Advanced == true)
                            {
                                hotkey.Action   = HotKey.HotKeyActions.Advanced;
                                hotkey.Advanced = hks.AdvancedScript;
                            }
                        }
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }

            return(changed);
        }