public System.Tuples.Tuple <ActiveUp.Net.Mail.Message, string, int, string> GetMessageById(string id) { System.Tuples.Tuple <Message, string, int, string> tuple = null; try { using (var dbcontext = new FAXPECContext()) { MAIL_INBOX inbox = dbcontext.MAIL_INBOX.Where(x => x.ID_MAIL == int.Parse(id)).FirstOrDefault(); tuple = AutoMapperConfiguration.MapToMailTuple(inbox); } if (tuple == null) { Message msg = GetById(id, null, "2"); if (msg != null) { tuple = new System.Tuples.Tuple <Message, string, int, string>(); tuple.Element1 = msg; tuple.Element2 = msg.FolderId.ToString() + msg.FolderTipo; tuple.Element3 = -1; tuple.Element4 = "2"; } } } catch (Exception e) { if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nel metodo GetMessageById(string id). Dettaglio: " + e.Message, "E005", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); _log.Error(err); } } return(tuple); }
/// <summary> /// MODIFICATA PER GESTIONE FOLDERS /// </summary> /// <param name="dr"></param> /// <returns></returns> internal static System.Tuples.Tuple <ActiveUp.Net.Mail.Message, string, int, string> MapToMessageTuple(IDataRecord dr) { System.Tuples.Tuple <ActiveUp.Net.Mail.Message, string, int, string> tuple = new System.Tuples.Tuple <ActiveUp.Net.Mail.Message, string, int, string>(); ActiveUp.Net.Mail.Message mex = new ActiveUp.Net.Mail.Message(); if (!dr.IsDBNull("ID_MAIL")) { mex.Id = (int)dr.GetInt64("ID_MAIL"); } mex.Uid = dr.GetString("MAIL_SERVER_ID"); long lobSize = dr.GetChars(dr.GetOrdinal("MAIL_FILE"), 0, null, 0, 0); char[] fileChars = new char[lobSize]; dr.GetChars(dr.GetOrdinal("MAIL_FILE"), 0, fileChars, 0, fileChars.Length); mex.OriginalData = Encoding.UTF8.GetBytes(fileChars); tuple.Element1 = mex; tuple.Element2 = dr.GetDecimal("FOLDERID").ToString(); tuple.Element4 = dr.GetString("FOLDERTIPO").ToString(); if (!dr.IsDBNull("FLG_RATING")) { tuple.Element3 = dr.GetInt32("FLG_RATING"); } return(tuple); }