private static void IterazioneComunica(StreamReader sr, StreamWriter sw, TipoStato stato) { while (true) { // lettura richiesta dal client string str = sr.ReadLine(); Console.WriteLine(str); // Elaborazione e invio risposta try { //Divisione messaggio string strMsg = SplitString(str, ref stato); //Creazione messaggio e ingresso e definizione stato Messaggio msg = null; TipoStato statoSuccessivo = CreateMsgIng(strMsg, stato, out msg); //Risposta dal server RispostaServer(msg, stato, statoSuccessivo, sw); if (statoSuccessivo == TipoStato.Q) { Console.WriteLine("Connessione chiusa"); break; } } catch (Exception) { Console.WriteLine("Messaggio sconosciuto"); sw.WriteLine("{0} -ERR", stato.ToString()); } } }
public async Task <ActionResult <Messaggio> > PostMessaggio(Messaggio messaggio) { _context.Messaggio.Add(messaggio); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMessaggio", new { id = messaggio.IDMessaggio }, messaggio)); }
private void creareNuovoEvento() { // Salvo nel database eventiReporitorySrv.addNew(nuovoEvento); eventiReporitorySrv.saveChanges(); // Prima di azzerare l'oggetto, mi prendo il messaggio da visualizzare string testoMsg = "Creato nuovo evento: " + nuovoEvento.descrizione; // Svuoto per nuova creazione istanziaNuovoEvento(); // Avviso l'utente if (dialogProvider != null) { dialogProvider.ShowMessage(testoMsg, "Successo"); } // Invio un messaggio di conferma Messaggio confermaMsg = new Messaggio(this, testoMsg); confermaMsg.showInStatusBar = true; LumenApplication.Instance.bus.Publish(confermaMsg); }
public async Task <IActionResult> OnPostSendMessage() { if (ModelState.IsValid) { var serviceClient = ServiceClient.CreateFromConnectionString( _configuration.GetConnectionString("iothub"), TransportType.Amqp); var messaggioLibrary = new Messaggio(); messaggioLibrary.DeviceId = Input.DeviceId; messaggioLibrary.ColorText = Input.ColorText; messaggioLibrary.Text = Input.text; var json = JsonConvert.SerializeObject(messaggioLibrary); var text = System.Text.UTF8Encoding.UTF8.GetBytes(json); var message = new Message(text); await serviceClient.SendAsync(Input.DeviceId, message); Message = $"Messaggio inviato al dispositivo {Input.DeviceId} con successo"; return(RedirectToPage()); } return(Page()); }
public async Task <IActionResult> GetMessage(HttpResponseModel model) { if (model.IDMes == null) { var md = await _httpResponse.GetAllMessage(); List <Messaggio> msglist = JsonConvert.DeserializeObject <List <Messaggio> >(md.Response); md.ListMessage = msglist; ModelState.Clear(); return(View("Index", md)); } else { var md = await _httpResponse.GetSingleMessage(model.IDMes); if ((int)md.Code != 200) { ModelState.AddModelError("CustomErrorIDMes", "ID messaggio non esistente"); return(View("Index", md)); } Messaggio msglist = JsonConvert.DeserializeObject <Messaggio>(md.Response); List <Messaggio> f = new List <Messaggio> { msglist }; md.ListMessage = f; ModelState.Clear(); return(View("Index", md)); } }
// Se mi arriva il messaggio di cambio volume, memorizzo i dati public override void OnNext(Messaggio messaggio) { if (messaggio is VolumeCambiatoMsg) { VolumeCambiatoMsg vcm = (VolumeCambiatoMsg)messaggio; if (vcm.montato) { // E' stata inserita una flash card (o un disco rimovibile) ultimaChiavettaInserita = creaParamScarica(vcm.nomeVolume); if (ultimaChiavettaInserita.flashCardConfig != null) { Messaggio msg = new Messaggio(this, "E' stata inserita una memory-card"); msg.senderTag = "::OnLetturaFlashCardConfig"; msg.showInStatusBar = true; pubblicaMessaggio(msg); } } else { ultimaChiavettaInserita = null; } } base.OnNext(messaggio); }
/// <summary> /// /// </summary> /// <param name="msg"></param> /// <returns></returns> public static void TranslateDescription(Messaggio AMessage, CacheKeys AKey) { if ((AMessage != null) && (AKey != CacheKeys.NULL)) { ListaDecodificaMessaggi FList = CacheManager <ListaDecodificaMessaggi> .get(AKey, VincoloType.FILESYSTEM); if (FList != null) { ListaDecodificaMessaggi.ErroreRow FRow = FList.Errore.FindBycod(AMessage.Codice); if (FRow != null) { AMessage.Descrizione = FRow.desc; if (AMessage.IsVariable) { foreach (KeyValuePair <string, string[]> item in AMessage.Variabili) { if (item.Value != null) { AMessage.Descrizione = AMessage.Descrizione.Replace("\\" + item.Key + "\\", string.Join("||", item.Value)); } } } } } } }
protected void pubblicaMessaggio(Messaggio messaggio) { try { LumenApplication.Instance.bus.Publish(messaggio); } catch (Exception ee) { _giornale.Error("Impossibile pubblicare messaggio " + messaggio.descrizione, ee); } }
public static bool InviaEmail(Messaggio messaggio) { try { MailMessage oMsg = new MailMessage(); //Imposta il mittente oMsg.From = new MailAddress("*****@*****.**", "www.immobiliaredoroteni.it - Email dal Sito"); //La proprietà .To è una collezione di destinatari, //quindi possiamo addizionare quanti destinatari vogliamo. oMsg.To.Add(new MailAddress("*****@*****.**")); //Imposto oggetto oMsg.Subject = "Email dal sito - " + messaggio.Oggetto; string TemplateName = System.Configuration.ConfigurationManager.AppSettings["EmailTemplate"]; //Imposto contenuto StreamReader sReader = new StreamReader(HttpContext.Current.Server.MapPath(TemplateName)); string htmlTemplate = sReader.ReadToEnd(); htmlTemplate = htmlTemplate.Replace("[DATA]", DateTime.Now.ToShortDateString()); htmlTemplate = htmlTemplate.Replace("[NOME]", messaggio.Nome); htmlTemplate = htmlTemplate.Replace("[TELEFONO]", messaggio.Telefono); htmlTemplate = htmlTemplate.Replace("[EMAIL]", messaggio.Email); htmlTemplate = htmlTemplate.Replace("[OGGETTO]", messaggio.Oggetto); htmlTemplate = htmlTemplate.Replace("[TESTO]", messaggio.Testo); sReader.Close(); oMsg.Body = htmlTemplate; oMsg.IsBodyHtml = true; //Imposto il Server Smtp /* var smtp = new SmtpClient * { * Host = "smtp.immobiliaredoroteni.it", * Port = 25, * DeliveryMethod = SmtpDeliveryMethod.Network, * UseDefaultCredentials = false, * Credentials = new NetworkCredential("*****@*****.**", "Mailsito11") * };*/ SmtpClient oSmtp = new SmtpClient("smtp.immobiliaredoroteni.it"); //Possiamo impostare differenti metodi di spedizione. //Imposta consegna diretta. oSmtp.DeliveryMethod = SmtpDeliveryMethod.Network; //Alcuni Server SMTP richiedono l'accesso autenticato NetworkCredential oCredential = new NetworkCredential("*****@*****.**", "Mailsito11"); oSmtp.UseDefaultCredentials = false; oSmtp.Credentials = oCredential; //Spediamo la mail oSmtp.Send(oMsg); return(true); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); return(false); } finally { Console.WriteLine("Executing finally block."); } }
public void End() { ResultProcessed = true; using (Session session = new Session()) { try { Postazione postazione = session.GetObjectByKey <Postazione>(Program.Postazione.Oid); if (Result) { postazione.SyncResult = EnumSyncResult.Ok; postazione.SyncSuccess = postazione.SyncTry; postazione.Save(); } else { postazione.SyncResult = EnumSyncResult.Error; postazione.Save(); } } catch (Exception) { // possiamo avere un problema sullo schema del database // ignoriamo e proseguiamo l'operazione .. } try { Messaggio msg = new Messaggio(session); msg.Data = DateTime.Now; if (Result) { //msg.Oggetto = String.Format("SYNCOK {0}: {1} sec. Conflitti ({2}/{3}) Modifiche ({4}/{5})", Environment.MachineName, // ResultInfo.Durata(), // ResultInfo.ConflittiSub, ResultInfo.ConflittiPub, ResultInfo.ModificheSub, ResultInfo.ModifichePub); //msg.TestoEsteso = ResultInfo.Info; //msg.Autore = session.GetObjectByKey<Utente>(Program.UtenteCollegato.Oid); //msg.Tipologia = EnumTipoMessaggio.Normale; //msg.Save(); } else { msg.Oggetto = "SYNC_ERR: " + Environment.MachineName; msg.TestoEsteso = ResultInfo.Info; msg.Autore = session.GetObjectByKey <Utente>(Program.UtenteCollegato.Oid); msg.Tipologia = EnumTipoMessaggio.SyncError; msg.Save(); } } catch (Exception) { // possiamo avere un problema sullo schema del database // ignoriamo e proseguiamo l'operazione .. } } }
public async Task <HttpResponseModel> PostMessaggio(Messaggio msg) { await SetToken(); string body = Newtonsoft.Json.JsonConvert.SerializeObject(msg); var md = await CallHttpRequest("Messaggio", HttpMethod.Post, "", body); return(md); }
private static TipoStato CreateMsgIng(string strMsg, TipoStato stato, out Messaggio msg) { msg = MessaggioFactory.Create(strMsg); TipoComando ingresso = (TipoComando)Enum.Parse(typeof(TipoComando), strMsg.Split(' ')[0], true); Ingresso ing = IngressoFactory.Create(ingresso); TipoStato statoSuccessivo = ing.CambiaStato(stato); return(statoSuccessivo); }
public void idrataImmaginiFoto(Fotografia foto, IdrataTarget target, bool forzatamente) { String nomeCompleto = null; try { // if (forzatamente || foto.imgProvino == null) { if ((target & IdrataTarget.Provino) != 0) { nomeCompleto = PathUtil.nomeCompletoProvino(foto); foto.imgProvino = this.load(nomeCompleto); } } // if (forzatamente || foto.imgOrig == null) { if ((target & IdrataTarget.Originale) != 0) { nomeCompleto = PathUtil.nomeCompletoFoto(foto); foto.imgOrig = this.load(nomeCompleto); } } // if (forzatamente || foto.imgRisultante == null) { if ((target & IdrataTarget.Risultante) != 0) { nomeCompleto = PathUtil.nomeCompletoRisultante(foto); // Se mi chiedono idratare tutte le foto, e quella modificata non esiste, non do errore. if (target == IdrataTarget.Tutte && !File.Exists(nomeCompleto)) { // E' possibile che la foto modificata non esista. Mentre le altre devono esistere (provino e originale) } else { foto.imgRisultante = this.load(nomeCompleto); } } } } catch (Exception ee) { // Se non riesco a caricare una immagine, non posso farci niente qui. Devo tirare dritto. _giornale.Warn(ee.Message + " nomeCompleto=" + nomeCompleto, ee); Messaggio msg = new Messaggio(ee.Source); msg.esito = Esito.Errore; msg.descrizione = ee.Message; msg.showInStatusBar = true; pubblicaMessaggio(msg); throw ee; } }
private void btnPeop1_Click(object sender, RoutedEventArgs e) { string peop1 = "peop " + txtPeop1.Text; Messaggio msg = MessaggioFactory.Create(peop1); if (msg == null) { MessageBox.Show("Errore", "Messaggio sconosciuto"); sw.WriteLine("-ERR"); } }
public void showAboutCloud(string title, string msg, int?sleep) { ShowTrayIcon trayIcon = new ShowTrayIcon(); trayIcon.showAboutCloud(title, msg, sleep); Messaggio msgStatusBar = new Messaggio(this); msgStatusBar.descrizione = msg; msgStatusBar.showInStatusBar = true; LumenApplication.Instance.bus.Publish(msgStatusBar); }
private void btnBirtPeop1_Click(object sender, RoutedEventArgs e) { DateTime Birth1 = (DateTime)Birt1.SelectedDate; string date1 = "birth " + Birth1.ToString(); Messaggio msg = MessaggioFactory.Create(date1); if (msg == null) { MessageBox.Show("Errore", "Messaggio sconosciuto"); sw.WriteLine("-ERR"); } }
public async Task <IActionResult> PostMessaggio(HttpResponseModel model) { Messaggio msg = new Messaggio { Email = model.Email, Testo = model.NewMessage, Data = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), IDMessaggio = Guid.NewGuid().ToString() }; var md = await _httpResponse.PostMessaggio(msg); ModelState.Clear(); return(View("Index", md)); }
private static void RispostaServer(Messaggio msg, TipoStato stato, TipoStato statoSuccessivo, StreamWriter sw) { if (msg != null && statoSuccessivo != stato) { Console.WriteLine(msg.GetType().ToString()); sw.WriteLine("{0} +OK", statoSuccessivo.ToString()); } else { Console.WriteLine("Messaggio sconosciuto"); sw.WriteLine("{0} -ERR", stato.ToString()); } }
public override int GetHashCode() { unchecked { var hashCode = (Tag != null ? Tag.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)Priorita; hashCode = (hashCode * 397) ^ (Messaggio != null ? Messaggio.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Timestamp.GetHashCode(); hashCode = (hashCode * 397) ^ (Stazione != null ? Stazione.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Id.GetHashCode(); return(hashCode); } }
protected void SelectNextMessageOk_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "reallowOp();", true); try { Messaggio messaggioSelezionato = (from m in this.NextMessages where m.ID.Equals(this.RblSelectMessage.SelectedValue) select m).FirstOrDefault(); this.InfoSpedizioneSelectMessage.tipoMessaggio = messaggioSelezionato; ScriptManager.RegisterStartupScript(this, this.GetType(), "closeMask", "if (parent.fra_main) {parent.fra_main.closeAjaxModal('SelectNextMessage', 'up');} else {parent.closeAjaxModal('SelectNextMessage', 'up', parent);};", true); } catch (Exception ex) { } }
private void simpleButtonForza_Click(object sender, EventArgs e) { using (Session session = new Session()) { Messaggio msg = new Messaggio(session); msg.Data = DateTime.Now; msg.Oggetto = String.Format("FORZATA CHIUSURA {0}", Program.Postazione.Nome); msg.TestoEsteso = string.Empty; msg.Autore = session.GetObjectByKey <Utente>(Program.UtenteCollegato.Oid); msg.Tipologia = EnumTipoMessaggio.SyncDelay; msg.Save(); } DialogResult = DialogResult.OK; }
public void AddMessage(int codice, int livello) { try { Messaggio m = new Messaggio(codice.ToString(), (LivelloMessaggio)livello); messageList.Add(new message(decodeMapperMessage(m), m.Livello)); } catch (Exception ex) { ErrorLogInfo error = new ErrorLogInfo(); error.freeTextDetails = ex.Message; error.logCode = "ERR_INF_001"; log.Error(error); } }
private void gridControlMessaggi_DoubleClick(object sender, EventArgs e) { Messaggio msg = this.gridViewMessaggi.GetRow(this.gridViewMessaggi.FocusedRowHandle) as Messaggio; if (msg != null) { using (XtraFormMessaggio fmsg = new XtraFormMessaggio()) { fmsg.Init(msg); if (fmsg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { AggiornaGriglie(); } } } }
public void showAbout(string title, string msg, int?sleep) { // Risolto il problema dello STAThread App.Current.Dispatcher.BeginInvoke( new Action(() => { ShowTrayIcon trayIcon = new ShowTrayIcon(); trayIcon.showAbout(title, msg, sleep); } )); Messaggio msgStatusBar = new Messaggio(this); msgStatusBar.descrizione = msg; msgStatusBar.showInStatusBar = true; LumenApplication.Instance.bus.Publish(msgStatusBar); }
/// <summary> /// /// </summary> /// <param name="exm"></param> /// <param name="livello"></param> public void AddMessage(Com.Delta.Logging.ManagedException exm, Com.Delta.Messaging.MapperMessages.LivelloMessaggio livello) { if (exm.Message == null || exm.Message.Equals("")) { Messaggio m = new Messaggio(exm.CodiceEccezione, livello); messageList.Add(new message(decodeMapperMessage(m), livello)); if (exm.EnanchedInfos != null && !exm.EnanchedInfos.Equals("")) { messageList.Add(new message(exm.EnanchedInfos, LivelloMessaggio.DETAILS)); } } else { AddMessage(exm.Message, livello); if (exm.EnanchedInfos != null && !exm.EnanchedInfos.Equals("")) { messageList.Add(new message(exm.EnanchedInfos, LivelloMessaggio.DETAILS)); } } }
static void Comunica(object param) { TcpClient client = (TcpClient)param; Console.WriteLine("Sto avviando la comunicazione"); NetworkStream nsRead = client.GetStream(); NetworkStream nsWrite = client.GetStream(); StreamReader sr = new StreamReader(nsRead); StreamWriter sw = new StreamWriter(nsWrite); sw.AutoFlush = true; try { while (true) { // lettura richiesta dal client string str = sr.ReadLine(); Console.WriteLine(str); // Elaborazione e invio risposta Messaggio msg = MessaggioFactory.Create(str); if (msg != null) { Console.WriteLine(msg.GetType().ToString()); sw.WriteLine("+OK"); } else { Console.WriteLine("Messaggio sconosciuto"); sw.WriteLine("-ERR"); } } } catch (Exception) { Console.WriteLine("Messaggio sconosciuto"); sw.WriteLine("-ERR"); } }
public bool AddMessage(string testo, string email) { string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Messaggio msg = new Messaggio { IDMessaggio = Guid.NewGuid().ToString(), Testo = testo, Data = time, Email = email }; _DbContext.Add(msg); var nUser = _DbContext.Utente.Select(o => o.Email).ToList(); foreach (var z in nUser) { _DbContext.UtenteLikeMessaggio.Add(new UtenteLikeMessaggio { Email = z, IDMessaggio = msg.IDMessaggio, SetLike = 0 });; } _DbContext.SaveChanges(); return(true); }
/// <summary> /// /// </summary> /// <param name="msg"></param> /// <returns></returns> public string decodeMapperMessage(Messaggio msg) { string sRet = string.Empty; sRet = string.Format("Livello:{0}, Codice:{1}, la decodifica del messaggio è assente!", msg.Livello, msg.Codice); if (messaggi != CacheKeys.NULL) { ListaDecodificaMessaggi el = CacheManager <ListaDecodificaMessaggi> .get( messaggi, VincoloType.FILESYSTEM); ListaDecodificaMessaggi.ErroreRow _errorerow = el.Errore.FindBycod(msg.Codice); if (_errorerow != null) { sRet = _errorerow.desc; if (msg.IsVariable) { foreach (KeyValuePair <string, string[]> item in msg.Variabili) { if (item.Value != null) { sRet = sRet.Replace("\\" + item.Key + "\\", string.Join("||", item.Value)); } else { sRet = sRet.Replace("\\" + item.Key + "\\", ""); } } } } } return(sRet); }
public static List <StampanteAbbinata> deserializzaList(String strStampantiAbbinate) { List <StampanteAbbinata> list = new List <StampanteAbbinata>(); if (String.IsNullOrEmpty(strStampantiAbbinate)) { return(list); } String [] righe = strStampantiAbbinate.Split(CHAR_SEP_RIGHE.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); LumenEntities dbContext = UnitOfWorkScope.currentDbContext; List <String> stampantiNonTrovate = new List <String>(); for (int i = 0; i < righe.Length; i++) { string [] campi = righe [i].Split(CHAR_SEP_COLONNE.ToCharArray()); Guid idFormatoCarta = new Guid(campi[0]); String stampante = campi[1]; FormatoCarta formatoCarta = dbContext.FormatiCarta.SingleOrDefault(f => f.id == idFormatoCarta); if (formatoCarta != null) { IStampantiInstallateSrv stampantiInstallateSrv = LumenApplication.Instance.getServizioAvviato <IStampantiInstallateSrv>(); StampanteInstallata stampanteInstallata = stampantiInstallateSrv.getStampanteInstallataByString(stampante); if (stampanteInstallata != null) { list.Add(create(stampanteInstallata, formatoCarta)); } else { stampantiNonTrovate.Add(stampante); } } } if (stampantiNonTrovate.Count > 0) { Messaggio msg = new Messaggio(typeof(StampantiAbbinateUtil)); String stampanti = ""; foreach (String stampante in stampantiNonTrovate) { stampanti += stampante + "\n"; } if (stampantiNonTrovate.Count == 1) { msg.descrizione = "La stampante " + stampanti + " non è stata trovata"; } else { msg.descrizione = "Le stampanti " + stampanti + " non sono state trovate"; } msg.showInStatusBar = true; pubblicaMessaggio(msg); } // Ordino la lista per il valore di ordinamento impostato nel database nel formato carta. list.Sort(StampanteAbbinata.CompareByImportanza); return(list); }
public virtual void OnNext(Messaggio messaggio) { }