private void timerSync_Tick(object sender, EventArgs e) { this.barButtonItemSync.Enabled = (m_Shelp == null || m_Shelp.ResultProcessed); if (m_Shelp != null && m_Shelp.SyncFinished && !m_Shelp.ResultProcessed) { m_Shelp.End(); if (m_Shelp.Result) { _DeviSincronizzareIn = false; _DeviSincronizzareOut = false; syncReason = string.Empty; if (this.xtraTabControlMain.SelectedTabPage == this.xtraTabPageWaitSync) { this.xtraTabControlMain.SelectedTabPage = this.xtraTabPageHomePage; Set(this.ribbonPageReport, true); } } else { DevExpress.XtraBars.Alerter.AlertInfo info = new DevExpress.XtraBars.Alerter.AlertInfo("ERRORE", "ERRORE di sincronizzazione con il server. Contattare l'assistenza tecnica se il problema persiste.", Properties.Resources.delete); this.alertControlInfo.Show(this, info); } // refresh AggiornaGriglie(); StaticInfo.DataAgg(barStaticItemInfo); } }
private static void ConnectToDatabase() { // generazione sequenziale dei GUID XpoDefault.GuidGenerationMode = GuidGenerationMode.UuidCreateSequential; string conn = string.Empty; if (StaticInfo.NoSync()) { string[] info = StaticInfo.NoSyncInfo(); conn = MSSqlConnectionProvider.GetConnectionString(info[0], info[1], info[2], info[3]); } else { conn = MSSqlConnectionProvider.GetConnectionString("(local)\\SQLEXPRESS", "MuseiXafRev1locale"); } if (StaticInfo.UpdateSchema()) { // update schema: try { IDataLayer dl = XpoDefault.GetDataLayer(conn, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema); using (Session session = new Session(dl)) { System.Reflection.Assembly[] assemblies = new System.Reflection.Assembly[] { typeof(Ingresso).Assembly }; session.UpdateSchema(assemblies); session.CreateObjectTypeRecords(assemblies); } } catch (Exception ex) { MessageBox.Show(string.Format("Unable to update database schema: {0}", ex.Message)); } } IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.None); if (conn.EndsWith(".asmx")) { store = new DevExpress.Xpo.DB.DataCacheNode(new DevExpress.Xpo.DB.DataCacheRoot(store)); } XpoDefault.DataLayer = new SimpleDataLayer(store); XpoDefault.Session = null; }
private void backgroundWorkerPush_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Program.ProceduraDiServizioPostLogon(); while (!this.backgroundWorkerPush.CancellationPending) { //for (int i = 0; i < 180; i++) //{ // Thread.Sleep(1000); // if (this.backgroundWorkerPush.CancellationPending) return; //} //if (EsistonoMieiBigliettiSulServer(Program.Postazione.SyncSuccess.AddMinutes(-30))) // _DeviSincronizzareIn = true; for (int i = 0; i < 180; i++) { Thread.Sleep(1000); if (this.backgroundWorkerPush.CancellationPending) { return; } } if (BigliettiPerAltriMuseiDopoIl(Program.Postazione.SyncSuccess)) { _DeviSincronizzareOut = true; } // per la seconda postazione del castello estense, nosync, ma controlla se il principale e' sincronizzato if (StaticInfo.NoSync()) { var info = StaticInfo.NoSyncInfo(); if (!string.IsNullOrEmpty(info[4])) { using (UnitOfWork uow = new UnitOfWork()) { var master = uow.FindObject <Postazione>(new BinaryOperator("MachineName", info[4])); if (master == null || master.SyncSuccess < DateTime.Now.AddMinutes(-25)) { backgroundWorkerPush.ReportProgress(30, "Master non sincronizzato!"); } } } } } }
private bool BigliettiPerAltriMuseiDopoIl(DateTime dateTime) { return(false); // basta, e la manutenzione e' onerosa ... sync ogni 12 minuti // dovrebbe garantire lo scambio corretto. if (StaticInfo.NoSync()) { return(false); } try { using (Session session = new Session()) { GroupOperator newGroupOperator = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] { new BinaryOperator("Stampa.Vendita.Struttura.Oid", Program.Postazione.Struttura.Oid), new BinaryOperator("Stampa.Vendita.DataOraStampa", dateTime, BinaryOperatorType.Greater) }); GroupOperator ingressi = new GroupOperator(GroupOperatorType.Or); foreach (Ingresso ingresso in Program.Postazione.IngressiControllatiDaAltrePostazioni()) { ingressi.Operands.Add(new BinaryOperator("Ingresso.Oid", ingresso.Oid)); } newGroupOperator.Operands.Add(ingressi); using (XPCollection <RigaStampaIngresso> righe = new XPCollection <RigaStampaIngresso>(session) { TopReturnedObjects = 1, Criteria = newGroupOperator }) { syncReason = string.Format("ho {0} RigaStampaIngresso per altre postazioni", righe.Count); return(righe.Count > 0); } } } catch (Exception ex) { this.backgroundWorkerPush.ReportProgress(20, ex.Message); return(false); } }
public RibbonFormDashBoard() { InitializeComponent(); SkinHelper.InitSkinGallery(ribbonGalleryBarItemSkin, true, true); CriteriaOperator criteria1 = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] { new BinaryOperator("Data", DateTime.Now.Date.AddMonths(-4), BinaryOperatorType.GreaterOrEqual), new BinaryOperator("Data", DateTime.Now.Date.AddDays(1), BinaryOperatorType.Less) }); CriteriaOperator criteria2 = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] { new BinaryOperator("Data", DateTime.Now.Date.AddMonths(-4), BinaryOperatorType.GreaterOrEqual), new BinaryOperator("Autore.Oid", Program.UtenteCollegato.Oid, BinaryOperatorType.Equal) }); CriteriaOperator criteria = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { criteria1, criteria2 }); this.xpCollectionMessaggi.Criteria = criteria; this.xpCollectionPostazioni.Criteria = new BinaryOperator("SyncSuccess", DateTime.Now.AddDays(-100), BinaryOperatorType.GreaterOrEqual); //new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[]{ //new BinaryOperator("Tipologia", EnumTipoMessaggio.MessaggioInformativo), //new BinaryOperator("Tipologia", EnumTipoMessaggio.Eliminazione), //new BinaryOperator("Tipologia", EnumTipoMessaggio.EliminazioneConPrenotazione), //new BinaryOperator("Tipologia", EnumTipoMessaggio.Ristampa)}); timerMessaggi_Tick(null, null); StaticInfo.DataAgg(barStaticItemInfo); this.backgroundWorkerPush.RunWorkerAsync(); try { this.Text = String.Format("Win Ticket Next ({0})", Program.UtenteCollegato.FullName); string sw = MostraVersione(); this.barStaticItemInfo1.Caption = sw; this.barStaticItemInfo2.Caption = Program.Postazione.Nome; this.barStaticItemInfo3.Caption = Program.UtenteCollegato.FullName; Program.Postazione.Reload(); if (Program.Postazione.SoftwareVersion != sw || Program.Postazione.Utente != Program.UtenteCollegato.FullName) { Program.Postazione.SoftwareVersion = sw; Program.Postazione.Utente = Program.UtenteCollegato.FullName; Program.Postazione.Save(); } } catch (Exception ex) { XtraMessageBox.Show("Errore: " + ex.Message, "ERRORE2", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (!Program.UtenteCollegato.Autorizzato(Utente.OperazioneRiepiloghi)) { this.barButtonItemPivotRiga.Enabled = false; this.barButtonItemPivotEntrate.Enabled = false; this.barButtonItemPivotVendite.Enabled = false; } if (!Program.UtenteCollegato.Autorizzato(Utente.OperazioneRiepiloghiGenerali)) { this.barButtonItemReport03.Enabled = false; this.barButtonItemReport03b.Enabled = false; this.barButtonItemReport06.Enabled = false; this.barButtonItemReport07.Enabled = false; this.barButtonItemReportBv1.Enabled = false; this.barButtonItemReportBv2.Enabled = false; } VisualizzaMessaggi(); Stampa.SetProgressivoMinimo(this.unitOfWork1, Program.Postazione.Oid); }
private bool EsistonoMieiBigliettiSulServer(DateTime dateTime) { return(false); // basta, e la manutenzione e' onerosa ... sync ogni 12 minuti // dovrebbe garantire lo scambio corretto. if (StaticInfo.NoSync()) { return(false); } try { IDataStore store = XpoDefault.GetConnectionProvider("http://webdals.winticket.xpsoft.it/WebServiceConnection001.asmx", AutoCreateOption.None); using (IDataLayer layer = new SimpleDataLayer(store)) { using (Session session = new Session(layer)) { GroupOperator newGroupOperator = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] { new BinaryOperator("Stampa.Vendita.Postazione.Oid", Program.Postazione.Oid, BinaryOperatorType.NotEqual), new BinaryOperator("Stampa.Vendita.DataOraStampa", dateTime, BinaryOperatorType.Greater) }); GroupOperator ingressi = new GroupOperator(GroupOperatorType.Or); foreach (PostazioneIngresso postazioneIngresso in Program.Postazione.Ingressi) { ingressi.Operands.Add(new BinaryOperator("Ingresso.Oid", postazioneIngresso.Ingresso.Oid)); } if (ingressi.Operands.Count == 0) { return(false); } newGroupOperator.Operands.Add(ingressi); XPView vista = new XPView(session, typeof(RigaStampaIngresso)); vista.Criteria = newGroupOperator; vista.Properties.Add(new ViewProperty("Oid", SortDirection.None, "Oid", false, true)); if (vista.Count > 0) { using (Session localSession = new Session()) { //this.backgroundWorkerPush.ReportProgress(10, string.Format("la vista ha {0} record", vista.Count)); foreach (ViewRecord viewRecord in vista) { Guid oid = (Guid)viewRecord[0]; if (localSession.GetObjectByKey <RigaStampaIngresso>(oid) == null) { syncReason = string.Format("mi manca RigaStampaIngresso {0} (la vista contiene {1} record)", oid, vista.Count); return(true); } } } } return(false); } } } catch (Exception ex) { this.backgroundWorkerPush.ReportProgress(10, ex.Message); // silente return(false); } }