示例#1
0
文件: Alerts2.cs 项目: 0anion0/IBN
        internal static void SendBroadcastMessage(int messageId, string text)
        {
            if (!AlertsEnabled)
                return;

            ArrayList users = new ArrayList();
            using (IDataReader reader = DbAlert2.GetBroadcastRecipients(messageId))
            {
                while (reader.Read())
                {
                    UserInfo ui = new UserInfo();

                    ui.ImId = (int)reader["ImId"];
                    ui.Locale = reader["Locale"].ToString();

                    users.Add(ui);
                }
            }

            ArrayList vars = new ArrayList();
            AddVariableInitiatedBy(vars);
            vars.Add(new VariableInfo(new AlertVariable(Variable.Text), text, true));

            Hashtable messages = new Hashtable();
            foreach (UserInfo ui in users)
            {
                string message = (string)messages[ui.Locale];
                if (message == null)
                {
                    string subject, body;
                    AlertTemplate.GetTemplate(AlertTemplateTypes.Special, ui.Locale, SpecialMessageType.BroadcastMessage.ToString(), true, out subject, out body);
                    Message msg = GetMessage(subject, body, ui, vars, -1, -1, null);
                    message = msg.Body;
                    messages[ui.Locale] = message;
                }

                try
                {
                    SendMessage(DeliveryType.IBN, ui.GetAddress(DeliveryType.IBN), message, null);
                }
                catch (Exception ex)
                {
                    Log.WriteError(ex.ToString());
                }
            }
        }
示例#2
0
文件: Alerts2.cs 项目: 0anion0/IBN
        internal static void SendForgottenPassword(int userId, string logonLink)
        {
            if (!AlertsEnabled)
                return;

            UserInfo ui = new UserInfo();
            ui.Load(userId);

            ArrayList vars = new ArrayList();
            vars.Add(new VariableInfo(new AlertVariable(Variable.LogonLink, true, false), logonLink));

            string subject, body;
            AlertTemplate.GetTemplate(AlertTemplateTypes.Special, ui.Locale, SpecialMessageType.ForgottenPassword.ToString(), true, out subject, out body);
            Message msg = GetMessage(subject, body, ui, vars, -1, -1, null);

            try
            {
                SendMessage(DeliveryType.Email, ui.GetAddress(DeliveryType.Email), msg.Body, msg.Subject);
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
                throw;
            }
        }
示例#3
0
文件: Alerts2.cs 项目: 0anion0/IBN
        private static void SendBatch(UserInfo ui, DeliveryType deliveryType, Message msg)
        {
            try
            {
                //Attachment[] attachments = null;
                //if (deliveryType == DeliveryType.Email)
                //    attachments = (Attachment[])msg.Attachments.ToArray(typeof(Attachment));

                using (DbTransaction tran = DbTransaction.Begin())
                {
                    SendMessage(deliveryType, ui.EmailFrom, ui.GetAddress(deliveryType), msg.Body, msg.Subject/*, attachments*/);
                    foreach (RecipientInfo ri in ui.Recipients)
                    {
                        DBSystemEvents.RecipientUpdateSent(ri.RecipientId, (int)deliveryType, true);
                    }
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
            }
        }