Example #1
0
        public void createAlert(notificationType type)
        {
            notification = type;
            switch (type)
            {
            case notificationType.success:
                pictureBox1.Image = ımageList1.Images["success"];
                this.BackColor    = Color.FromName("Green");
                label1.Text       = "Process complete";
                break;

            case notificationType.info:
                pictureBox1.Image = ımageList1.Images["info"];
                this.BackColor    = Color.FromName("Gray");
                label1.Text       = "Process have info";
                break;

            case notificationType.warning:
                pictureBox1.Image = ımageList1.Images["warning"];
                this.BackColor    = Color.FromArgb(255, 128, 0);
                label1.Text       = "Process have warning";
                break;

            case notificationType.error:
                pictureBox1.Image = ımageList1.Images["error"];
                this.BackColor    = Color.FromName("Red");
                label1.Text       = "Process have some errors";
                break;

            default:
                MessageBox.Show("Error when opening form !", "Error");
                break;
            }
        }
Example #2
0
 public Alert(Form1 frm, notificationType type)
 {
     form1 = frm;
     InitializeComponent();
     FillImageList();
     createAlert(type);
 }
Example #3
0
        void sendNotificationType(byte[] payLoad, notificationType type)
        {
            //通过Http Post方式发送消息
            HttpWebRequest sendNotificationRequest = (HttpWebRequest)WebRequest.Create(textBox1.Text);
            sendNotificationRequest.Method = WebRequestMethods.Http.Post;

            //X-MessageID头必须是一个唯一的字符床
            sendNotificationRequest.Headers["X-MessageID"] = Guid.NewGuid().ToString();

            if (type == notificationType.raw)
            {

                // 设置raw通知
                sendNotificationRequest.ContentType = "text/xml; charset=utf-8";
                sendNotificationRequest.Headers.Add("X-NotificationClass", "3");
                // 3: 表示马上发送
                // 13:表示450秒内发送
                // 23:表示900秒内发送
            }
            else if (type == notificationType.tokens)
            {
                // 设置Tile通知
                sendNotificationRequest.ContentType = "text/xml; charset=utf-8";
                sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "token");
                sendNotificationRequest.Headers.Add("X-NotificationClass", "1");
                // 1: 表示马上发送
                // 11:表示450秒内发送
                // 21:表示900秒内发送
            }
            else if (type == notificationType.toast)
            {
                // 设置toast通知
                sendNotificationRequest.ContentType = "text/xml; charset=utf-8";
                sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "toast");
                sendNotificationRequest.Headers.Add("X-NotificationClass", "2");
                // 2:表示马上发送
                // 12:表示450秒内发送
                // 22:表示900秒内发送
            }
            sendNotificationRequest.ContentLength = payLoad.Length;
            byte[] notificationMessage = payLoad;
            // 发送通知
            using (Stream requestStream = sendNotificationRequest.GetRequestStream())
            {
                requestStream.Write(notificationMessage, 0, notificationMessage.Length);
            }
            // 获取推送通知的响应状态
            HttpWebResponse response = (HttpWebResponse)sendNotificationRequest.GetResponse();
            string notificationStatus = response.Headers["X-NotificationStatus"];
            string notificationChannelStatus = response.Headers["X-SubscriptionStatus"];
            string deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];
            label4.Text = String.Format("通知状态:{0},管道状态:{1},设备状态:{2}",
                notificationStatus, notificationChannelStatus, deviceConnectionStatus);

        }
Example #4
0
        internal IAsyncResult BeginSendNotification(IEnumerable <agentType> agentsAddedOrModified,
                                                    IEnumerable <string> agentsRemoved,
                                                    IEnumerable <participantType> participantsAddedOrModified,
                                                    IEnumerable <string> participantsRemoved,
                                                    string sessionId,
                                                    AsyncCallback callback, object state)
        {
            notificationType notification = new notificationType();

            notification.sessionId = sessionId;

            if (agentsAddedOrModified != null)
            {
                List <agentType> updatedAgents = new List <agentType>(agentsAddedOrModified);
                notification.agentinfos = updatedAgents.ToArray();
            }

            if (agentsRemoved != null)
            {
                List <string> removedAgents = new List <string>(agentsRemoved);
                notification.agentsremoved = removedAgents.ToArray();
            }

            if (participantsAddedOrModified != null)
            {
                List <participantType> updatedParticipants = new List <participantType>(participantsAddedOrModified);
                notification.participantinfos = updatedParticipants.ToArray();
            }

            if (participantsRemoved != null)
            {
                List <string> removedParticipants = new List <string>(participantsRemoved);
                notification.partcicipantsremoved = removedParticipants.ToArray();
            }

            string serializedData;

            XmlSerializer serializer = new XmlSerializer(notification.GetType());

            using (TextWriter writer = new StringWriter())
            {
                serializer.Serialize(writer, notification);
                serializedData = writer.ToString();
            }

            Console.WriteLine(serializedData);

            return(m_innerChannel.BeginSendData(new System.Net.Mime.ContentType(WireHelpers.Notification), System.Text.Encoding.UTF8.GetBytes(serializedData),
                                                callback, state));
        }
Example #5
0
 public static function addNotification(userID, activityID, notificationType, isNew = 1)
 {
     global db;
     
     db.insertFromArray(TABLE_MAIN_NOTIFICATIONS, array("userID" => userID, "activityID" => activityID, "notificationType" => notificationType, "isNew" => isNew, "createdDate" => time())); 
 }