private void Invia() { bool TuttoRiempito = false; try { if (eOggetto.Text.Length > 3) { if (eTesto.Text.Length > 3) { if (cbGiudizio.SelectedIndex > -1) { TuttoRiempito = true; } } } } catch { TuttoRiempito = false; } if (TuttoRiempito) { bool ok = false; string r = ""; this.Enabled = false; try { string t = cGB.UtenteConnesso.UserName + " [" + cGB.UtenteConnesso.Email + "] :" + Environment.NewLine + eTesto.Text; using (maionemikyWS.EmailSending e = new maionemikyWS.EmailSending()) r = e.MandaMail(eOggetto.Text + " [" + cbGiudizio.Text + "]", t, "*****@*****.**"); ok = r.Equals("OK", StringComparison.OrdinalIgnoreCase); } catch (Exception ex) { cGB.MsgBox(ex.Message, MessageBoxIcon.Error); } this.Enabled = true; if (ok) { cGB.MsgBox("Inviato !", MessageBoxIcon.Information); ChiudiScheda(); } else { cGB.MsgBox(r, MessageBoxIcon.Exclamation); } } else { cGB.MsgBox("Si prega di riempire tutti i campi!", MessageBoxIcon.Exclamation); } }
public static bool ControllaDBSulServer() { var ok = false; try { var cUte = new DB.DataWrapper.cUtente(UtenteConnesso.ID); using (var e = new maionemikyWS.EmailSending()) { var yyyyMMddHHmmss = cUte.UltimoAggiornamentoDB.ToString("yyyyMMddHHmmss"); var yyyyMMddHHmmss_WEB = e.VersioneDB(UtenteConnesso.Email, UtenteConnesso.Psw); var comparazione = e.ComparaDBRC(yyyyMMddHHmmss, UtenteConnesso.Email, UtenteConnesso.Psw); if (comparazione == maionemikyWS.Comparazione.Server) { using (var fdbd = new UI.Forms.fDBDate(cUte.UltimoAggiornamentoDB, yyyyMMddHHmmss_WEB)) if (fdbd.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { ok = ScaricaUltimoDBDalWeb(e, yyyyMMddHHmmss, UtenteConnesso.PathDB, UtenteConnesso.Email, UtenteConnesso.Psw, false); } } } } catch (Exception ex) { if (MsgBox("Errore: " + ex.Message + Environment.NewLine + "Riprovo?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { ok = ControllaDBSulServer(); } } return(ok); }
private bool MandaIlFile(string yyyyMMddHHmmss) { //TODO: [M] GB.CompattaDB(); var okko = false; var Zipped = false; var s = MettiDBInTempPath(PathDB); try { var zs = ZippaDB(s); if (!string.IsNullOrEmpty(zs)) { if (System.IO.File.Exists(zs)) { s = zs; Zipped = true; } } } catch { s = PathDB; } try { if (Zipped) { okko = UploadFile(yyyyMMddHHmmss, s); if (okko) { using (var dez = new maionemikyWS.EmailSending()) okko = dez.DeZippaDBRC(Email + ".zip"); } } else { okko = UploadFile(yyyyMMddHHmmss, s); } } catch { okko = false; } if (okko) { cGB.MsgI("Sincronizzazione completata!"); } else { cGB.MsgBox("Non sono riuscito a sincronizzare il DataBase!", System.Windows.Forms.MessageBoxIcon.Exclamation); } return(okko); }
private bool MandaDBSulSito__(string yyyyMMddHHmmss) { var ok = false; cGB.MsgI("Sincronizzazione in corso..."); try { using (var c = new maionemikyWS.EmailSending()) { //NON FATE I CAZZONI ! IO IL SITO LO PAGO E IL SERVIZIO LO OFFRO GRATUITAMENTE var resu = c.ControllaCredenzialiRC(Credenziali); switch (resu) { case maionemikyWS.CredenzialiRisultato.Assente: if (cGB.MsgBox("Il nome utente non è presente nell'archivio! Vuoi crearlo?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { if (c.CreaDBPerRC(Credenziali)) { var tyy = "Adesso puoi accedere ai tuoi dati direttamente dal cellulare da questa pagina http://www.maionemiky.it/mLogin.aspx con le seguenti credenziali:"; tyy += Environment.NewLine + "Utente: " + Email; tyy += Environment.NewLine + "Password: "******"RationesCurare7", tyy, Email); ok = MandaDBSulSito(yyyyMMddHHmmss); } else { cGB.MsgBox("Non sono riuscito a creare il nuovo utente! Riprovare!", System.Windows.Forms.MessageBoxIcon.Exclamation); return(false); } } break; case maionemikyWS.CredenzialiRisultato.Errore: cGB.MsgBox("Non riesco a collegarmi al sito!", System.Windows.Forms.MessageBoxIcon.Exclamation); break; case maionemikyWS.CredenzialiRisultato.TuttoOK: ok = MandaIlFile(yyyyMMddHHmmss); break; case maionemikyWS.CredenzialiRisultato.Presente_PasswordErrata: cGB.MsgBox("Nome utente o password non validi!", System.Windows.Forms.MessageBoxIcon.Exclamation); break; } } } catch { cGB.MsgBox("Non riesco a collegarmi al sito!", System.Windows.Forms.MessageBoxIcon.Exclamation); } return(ok); }
private void bOK_Click(object sender, EventArgs e) { using (var ema = new maionemikyWS.EmailSending()) { var r = ema.ControllaCredenzialiRC_simple(eEmail.Text, ePassword.Text); switch (r) { case maionemikyWS.CredenzialiRisultato.TuttoOK: using (var fd = new FolderBrowserDialog() { Description = "Cartella dove creare il DB dell'utente", ShowNewFolderButton = true }) if (fd.ShowDialog() == DialogResult.OK) { Psw_ = ePassword.Text; FileSelezionato_ = System.IO.Path.Combine(fd.SelectedPath, eEmail.Text + ".rqd8"); var ok = cGB.ScaricaUltimoDBDalWeb(ema, "19000101000000", FileSelezionato, eEmail.Text, ePassword.Text, true); if (ok) { this.DialogResult = DialogResult.OK; } } break; case maionemikyWS.CredenzialiRisultato.Presente_PasswordErrata: cGB.MsgBox("Password errata!", MessageBoxIcon.Exclamation); break; case maionemikyWS.CredenzialiRisultato.Assente: cGB.MsgBox("Questo utente non esiste!", MessageBoxIcon.Exclamation); break; case maionemikyWS.CredenzialiRisultato.Errore: cGB.MsgBox("Errore, riprovare.", MessageBoxIcon.Error); break; case maionemikyWS.CredenzialiRisultato.ProgrammaNonAutorizzato: cGB.MsgBox("Programma non autorizzato!", MessageBoxIcon.Error); break; } } }
public static void RegistraUtenteSito() { try { using (var e = new maionemikyWS.EmailSending()) e.AggiornaUtente( new maionemikyWS.UtenteProgramma() { Programma = "RationesCurare7", Utente = UtenteConnesso.UserName, Versione = MyProductVersion } ); } catch { //no connection } }
public bool MandaDBSulSito(string yyyyMMddHHmmss, bool Force = false) { var ok = false; if ((DB.cDB.UltimaModifica > DateTime.MinValue) || Force) { using (var e = new maionemikyWS.EmailSending()) { var comparazione = e.ComparaDBRC(yyyyMMddHHmmss, Email, Psw); if (comparazione == maionemikyWS.Comparazione.Server) { if (cGB.MsgBox("Il database sul server è più aggiornato di quello locale; Vuoi sovrascrivere quello sul server?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) { return(false); } } } while (!ok) { cGB.CreaIcona("Sincronizzazione del DataBase"); ok = MandaDBSulSito__(yyyyMMddHHmmss); if (!ok) { if (cGB.MsgBox("Riprovo?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) { break; } } } } cGB.MyNotifyIcon.Visible = false; return(ok); }
private void bRecupera_Click(object sender, EventArgs ea) { this.Enabled = false; try { using (maionemikyWS.EmailSending e = new maionemikyWS.EmailSending()) if (e.RecuperaPswRC_Six(PswC, Email)) { cGB.MsgBox("Ti ho inviato la password via email!"); } else { cGB.MsgBox("Invio non riuscito!", MessageBoxIcon.Exclamation); } } catch (Exception ex) { cGB.MsgBox("Errore : " + ex.Message, MessageBoxIcon.Exclamation); } this.Enabled = true; }
public static bool ScaricaUltimoDBDalWeb(maionemikyWS.EmailSending e, string yyyyMMddHHmmss, string PathDB, string email_, string psw, bool CreaNuovo) { var ok = false; var db_path = System.IO.Path.GetDirectoryName(PathDB); var zip_path = System.IO.Path.Combine(db_path, email_ + ".zip"); try { var db_bytes = e.OttieniUltimoDBRC(yyyyMMddHHmmss, email_, psw); if ((db_bytes?.Length ?? 0) > 0) { System.IO.File.WriteAllBytes(zip_path, db_bytes); if (System.IO.File.Exists(zip_path)) { var guid = System.IO.Path.Combine(db_path, Guid.NewGuid().ToString()); try { if (!CreaNuovo) { System.IO.File.Move(PathDB, guid); } try { var zip = new ICSharpCode.SharpZipLib.Zip.ZipFile(zip_path); foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry zipEntry in zip) { if (!zipEntry.IsFile) { continue; // Ignore directories } var entryFileName = System.IO.Path.GetFileName(zipEntry.Name); var buffer = new byte[4096]; // 4K is optimum var zipStream = zip.GetInputStream(zipEntry); // Manipulate the output filename here as desired. var fullZipToPath = System.IO.Path.Combine(db_path, entryFileName); using (var streamWriter = System.IO.File.Create(fullZipToPath)) { Copy(zipStream, streamWriter, buffer); streamWriter.Close(); } } zip.Close(); System.IO.File.Delete(guid); System.IO.File.Delete(zip_path); ok = true; } catch (Exception ex4) { System.IO.File.Move(guid, PathDB); MsgBox(ex4); } } catch (Exception ex3) { MsgBox(ex3); } } } } catch (Exception ex2) { MsgBox(ex2); } return(ok); }
private bool UploadFile(string yyyyMMddHHmmss, string filename) { var b = false; try { var strFile = System.IO.Path.GetFileName(filename); using (var srv = new maionemikyWS.EmailSending()) { var fInfo = new System.IO.FileInfo(filename); var numBytes = fInfo.Length; try { using (var fStream = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)) using (var br = new System.IO.BinaryReader(fStream)) { var data = br.ReadBytes(Convert.ToInt32(numBytes)); br.Close(); fStream.Close(); var R = srv.UploadFileRC(Credenziali, data, strFile); try { switch (R) { case maionemikyWS.CredenzialiRisultato.TuttoOK: return(true); case maionemikyWS.CredenzialiRisultato.FileInviato: return(true); case maionemikyWS.CredenzialiRisultato.Presente_PasswordErrata: throw new Exception("Password errata!"); case maionemikyWS.CredenzialiRisultato.Assente: throw new Exception("DB assente!"); case maionemikyWS.CredenzialiRisultato.Errore: throw new Exception("Errore!"); case maionemikyWS.CredenzialiRisultato.ProgrammaNonAutorizzato: throw new Exception("Programma non autorizzato!"); case maionemikyWS.CredenzialiRisultato.DBSulServerEPiuRecente: throw new Exception("DB sul server è più recente!"); } } catch (Exception exv1) { cGB.MsgBox(exv1.Message, System.Windows.Forms.MessageBoxIcon.Error); } } } catch { //error b = false; } } } catch { // display an error message to the user b = false; } return(b); }