public AMSNotificationPack() { to = new List <string>(); notification = new AMSNotificationConfig(); priority = "high"; content_available = true; }
private static List <AMSNotificationPack> ConvertDataTableToNotificationPacks(DataTable table) { List <AMSNotificationPack> notificationPacks = new List <AMSNotificationPack>(); if (table.Rows.Count > 0) { DataColumnCollection columns = table.Columns; foreach (DataRow row in table.Rows) { Dictionary <string, object> dataCollection = new Dictionary <string, object>(); AMSNotificationPack notificationPack = new AMSNotificationPack(); AMSNotificationConfig notification = notificationPack.notification; notificationPack.data = dataCollection; notificationPacks.Add(notificationPack); foreach (DataColumn column in columns) { string cName = column.ColumnName; string cValue = row[cName].ToString(); switch (cName) { case "REGISTRATION_ID": string[] arrValue = cValue.Split('|'); foreach (string val in arrValue) { notificationPack.to.Add(val.Trim()); } break; case "TITLE": notification.title = cValue; break; case "BODY": notification.body = cValue; break; case "ICON": notification.icon = cValue; break; case "SOUND": notification.sound = cValue; break; case "BADGE": notification.badge = cValue; break; default: dataCollection.Add(cName, cValue); break; } } } } else { throw new Exception("ไม่มี Data สำหรับส่ง Notification"); } return(notificationPacks); }