예제 #1
0
        /// <summary>
        /// Load mails list from specified page and number of records.
        /// </summary>
        /// <param name="pageNumber">Page number.</param>
        /// <param name="limit">Limit.</param>
        /// <typeparam name="T">Type of returned objects.</typeparam>
        public static void Load <T> (eMailList listType, long idRecipient, long idSender, long idGroup, int pageNumber, int limit, System.Action <T[], int, int, string> callback) where T : Mail, new()
        {
            var form = CombuManager.instance.CreateForm();

            form.AddField("action", "list");
            form.AddField("Type", ((int)listType).ToString());
            form.AddField("IdRecipient", idRecipient.ToString());
            form.AddField("IdSender", idSender.ToString());
            form.AddField("IdGroup", idGroup.ToString());
            form.AddField("Limit", limit.ToString());
            form.AddField("Page", pageNumber.ToString());
            CombuManager.instance.CallWebservice(CombuManager.instance.GetUrl("mail.php"), form, (string text, string error) => {
                List <T> mails = new List <T>();
                int count      = 0, pagesCount = 0;
                if (string.IsNullOrEmpty(error))
                {
                    Hashtable result = text.hashtableFromJson();
                    if (result != null && result.ContainsKey("total"))
                    {
                        count          = int.Parse(result["total"].ToString());
                        pagesCount     = int.Parse(result["pages"].ToString());
                        ArrayList list = (ArrayList)result["results"];
                        if (list != null)
                        {
                            foreach (Hashtable data in list)
                            {
                                // Create a new object from the result
                                T article = new T();
                                article.FromHashtable(data);
                                // Add to the list
                                mails.Add(article);
                            }
                        }
                    }
                }
                if (callback != null)
                {
                    callback(mails.ToArray(), count, pagesCount, error);
                }
            });
        }
예제 #2
0
 public static void Load(eMailList listType, long idRecipient, long idSender, long idGroup, int pageNumber, int limit, System.Action <Mail[], int, int, string> callback)
 {
     Load <Mail>(listType, idRecipient, idSender, idGroup, pageNumber, limit, callback);
 }
예제 #3
0
 public static void Load(eMailList listType, int pageNumber, int limit, System.Action <Mail[], int, int, string> callback)
 {
     Load <Mail>(listType, 0, 0, 0, pageNumber, limit, callback);
 }