void WaitOnline_timer_Tick(object sender, EventArgs e) { waitOnline_timer.Stop(); if (Internet.CheckInternetAndProcess(m_Guid, m_Storage, m_Process, m_Site, m_PlacePath, "wait_timer") != "") { return; } MessageBox.Show(String.Format(MMUtils.GetString("internet.maponline.message"), doc.Name), MMUtils.GetString("internet.maponline.caption")); string _lastfile = Directory.GetFiles(m_PlacePath, "*.mmap").Last().ToString(); long placemap_time = Convert.ToInt64(Path.GetFileNameWithoutExtension(_lastfile)); DocumentStorage.closeMap = true; doc.Close(); File.SetAttributes(m_LocalPath, System.IO.FileAttributes.Normal); // Get last copy from Place if (placemap_time > m_FrozenTime) { File.Copy(_lastfile, m_LocalPath, true); } // Or return frozen file else { File.Copy(m_FrozenPath, m_LocalPath, true); } DocumentStorage.openMap = true; MMUtils.MindManager.AllDocuments.Open(m_LocalPath); doc = MMUtils.ActiveDocument; m_Status = "online"; GetOnlineUsers(); DocumentStorage.Sync(doc, true, m_PlacePath); // subscribe map Watchers WW = new Watchers(m_PlacePath + "share", m_PlacePath, "") // TODO project path! { doc = doc, aMapGuid = m_Guid }; Maps.MapsGroup.WATCHERS.Add(WW); SUtils.GetChanges(doc); saveMap_timer.Start(); checkOnlineUsers_timer.Start(); refreshIndicator_timer.Start(); if (doc == MMUtils.ActiveDocument) { refresh = true; } }
static void m_documentEventAfter_Fire(int eventFlag, MmEventTime time, object pSource, ref object pExtra) { Document _doc = pSource as Document; Maps.MapsGroup.dlgUsersOnline.Visible = false; if (_doc == null || !_doc.HasAttributesNamespace[SUtils.SYNERGYNAMESPACE]) { return; } string mapGuid = SUtils.SynergyMapGuid(_doc); if ((eventFlag & EventDocumentActivated) != 0) { foreach (DocumentStorage item in SDocs) { if (item.MGuid == mapGuid) // map was opened before { foreach (Timers _item in Maps.MapsGroup.TIMERS) { if (_item.m_Guid == mapGuid) { Maps.MapUsersDlg.status = _item.m_Status; Maps.MapUsersDlg.users = _item.UsersOnline; Maps.MapUsersDlg.blocker = _item.MapBlocker; Maps.MapsGroup.dlgUsersOnline.Show(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd)); break; } } break; } } //else - map is opening, handle it in EventDocumentOpened _doc = null; } if ((eventFlag & EventDocumentOpened) != 0) { if (openMap) { openMap = false; _doc = null; return; } if (MapsGroup.LOGIN.logged == false) // user not logged in Synergy yet { if (System.Windows.Forms.MessageBox.Show(MMUtils.GetString("maps.openmapnosynergy.message"), MMUtils.GetString("maps.synergywarning.caption"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MapsGroup.LOGIN.m_cmdLogin_Click(); } if (MapsGroup.LOGIN.logged == false) { reopentimer = false; docToClose = _doc; _doc = null; closeMap_timer.Start(); // we can't close document within this event return; } } bool mapnotfound = false; using (MapsDB _db = new MapsDB()) { DataTable _dt = _db.ExecuteQuery("select * from MAPS where MAPGUID='" + mapGuid + "'"); if (_dt.Rows.Count == 0) { MessageBox.Show(String.Format(MMUtils.GetString("maps.openmapillegal.message"), _doc.Name), MMUtils.GetString("maps.synergywarning.caption"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); mapnotfound = true; } else // map found in MapsDB { docToClose = _doc; docToOpen = _dt.Rows[0]["LOCALPATH"].ToString(); docToCopy = _dt.Rows[0]["PATHTOPLACE"].ToString(); File.SetAttributes(docToOpen, System.IO.FileAttributes.Normal); } } if (mapnotfound) { _doc = null; return; } try { docToCopy = Directory.GetFiles(docToCopy, "*.mmap").Last().ToString(); } catch // can't access to _pathtofolder { docToCopy = ""; } if (docToCopy != "" && reopenmap == true) { long localmap_lastwrite = Convert.ToInt64(File.GetLastWriteTimeUtc(docToOpen).ToString("yyyyMMddHHmmssfff")); long placemap_time = Convert.ToInt64(Path.GetFileNameWithoutExtension(docToCopy)); // reopen map to get last map copy from its Place if (placemap_time > localmap_lastwrite) { reopentimer = true; closeMap_timer.Start(); // we can't close document within this event _doc = null; return; // for reopen map } } if (reopenmap == false) { reopenmap = true; } docToClose = null; string fail = SUtils.ProcessMap(_doc); if (fail == "") // don't get changes if map offline { SUtils.GetChanges(_doc); } _doc = null; } _doc = null; }