public static string GetPlaceFile(string _pathtofolder) { try { return(Directory.GetFiles(_pathtofolder, "*.mmap").Last().ToString()); } catch // can't access to _pathtofolder { while (System.Windows.Forms.MessageBox.Show( String.Format(MMUtils.GetString("synergy.placepathnotfound.message"), _pathtofolder), MMUtils.GetString("synergy.placepathnotfound.caption"), System.Windows.Forms.MessageBoxButtons.RetryCancel, System.Windows.Forms.MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Retry) { try { return(Directory.GetFiles(_pathtofolder, "*.mmap").Last().ToString()); } catch { } } } System.Windows.Forms.MessageBox.Show( MMUtils.GetString("synergy.mapviewer.message"), MMUtils.GetString("synergy.mapviewer.caption")); return(""); }
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; } }
public InternetCheckDlg() { InitializeComponent(); //timer = new Timer(); //timer.Interval = 40; //timer.Tick += timer_Tick; this.Location = new System.Drawing.Point(MMUtils.MindManager.Left + 200, MMUtils.MindManager.Top + MMUtils.MindManager.Height - 22); lblInternet.Text = MMUtils.GetString("internet.check.text"); }
public override void CreateDatabase() { base.CreateDatabase(); m_db.ExecuteNonQuery("BEGIN EXCLUSIVE"); m_db.ExecuteNonQuery("CREATE TABLE STORAGES(STORAGENAME text, PROCESS text, SITE text, TYPE text," + "reserved1 text, reserved2 text, reserved3 integer, reserved4 integer);"); AddStorageToDB(MMUtils.GetString("storage1.text"), "OneDrive", "https://onedrive.live.com", "cloud"); AddStorageToDB(MMUtils.GetString("storage2.text"), "googledrivesync", "https://drive.google.com", "cloud"); AddStorageToDB(MMUtils.GetString("storage3.text"), "Dropbox", "https://www.dropbox.com", "cloud"); AddStorageToDB(MMUtils.GetString("storage4.text"), "box", "https://www.box.com", "cloud"); // TODO site m_db.ExecuteNonQuery("END"); }
static void SetOfflineStatus(string _guid, string _cause) // TODO { Document _doc = null; foreach (Watchers _item in Maps.MapsGroup.WATCHERS) { if (_item.aMapGuid == _guid) { _doc = _item.doc; _item.Dispose(); Maps.MapsGroup.WATCHERS.Remove(_item); break; } } DocumentStorage.Sync(_doc, false); // Unsubscribe this map foreach (Timers item in Maps.MapsGroup.TIMERS) { if (_guid == item.m_Guid) { item.m_Status = "offline"; item.m_FrozenTime = Convert.ToInt64(SUtils.modtime); //item.m_OfflineCause += _cause; item.saveMap_timer.Stop(); item.checkOnlineUsers_timer.Stop(); System.IO.File.Copy(item.m_LocalPath, item.m_FrozenPath, true); string docName = item.doc.Name; string messageSite = MMUtils.GetString("internet.sitefailed.message"); string messageProcess = MMUtils.GetString("internet.processfailed.message"); string messagePlace = MMUtils.GetString("internet.placefail.message"); string endMessage = MMUtils.GetString("internet.failed.endmessage"); string _message = "", arg = ""; if (_cause == "process") { _message = messageProcess; arg = item.m_Storage; } else if (_cause == "place") { _message = messagePlace; arg = item.m_PlacePath; } else if (_cause == "site") { _message = messageSite; arg = item.m_Site; } System.Windows.Forms.MessageBox.Show( String.Format(_message, arg) + endMessage, String.Format(MMUtils.GetString("internet.failed.caption"), item.doc.Name), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); System.IO.File.SetAttributes(item.m_LocalPath, System.IO.FileAttributes.ReadOnly); if (item.doc == MMUtils.ActiveDocument) { item.refresh = true; // for refreshIndicator_timer } break; } } }
void m_afterObjectChanged_Fire(int eventFlag, MmEventTime time, object pSource, ref object pExtra) { if (received) { return; } if (extracase == "deleteimage") { extracase = ""; // отбиваем таймер удаления картинки } // TODO при добавлении связи может быть _what "AutoRoute"! И выходит исключение string _what = "", _extra = ""; if (pExtra is Array) { Array _pExtraAsArray = pExtra as Array; if (_pExtraAsArray.GetLength(0) > 0 && eventFlag == DocumentStorage.EventObjectModified) { _what = _pExtraAsArray.GetValue(0).ToString().ToLower(); } if (_pExtraAsArray.GetLength(0) > 1) { _extra = _pExtraAsArray.GetValue(1).ToString(); } } // TODO если выбран не топик, не граница и не связь, то выбран фоновой объект! if (_what == "collapsed" || _what == "selection") { return; } //if (paste && _what == "oneimage") //{ // extraTopic = null; // return; //} if (objectAdded) { if (_what != "offset") // все оффсетные события нахер { objectAdded = false; } return; } string sMessage = MMBase.SynergyMessage(m_document); //// Message sent from m_beforeObjectChanged_Fire when image deleted //if (sMessage == "deleteimage" && _what != "oneimage") //{ // MMBase.SendMessage("", m_document); // _what = "oneimage"; // pSource = extraTopic; //} //extraTopic = null; if (paste && sMessage != "paste") // отбиваем все пасты, которые не от копипаста или драгдропа ТОПИКОВ { paste = false; } if (paste && _what == "offset") { return; } //if (paste && !_topic.IsCentralTopic) // учитываем только paste, который пришел от message // return; if (_extra == SUtils.SYNERGYNAMESPACE) // отбиваются synergy-изменения в атрибутах объекта { return; } Topic _topic = pSource as Topic; if (_what == "custom" && _topic != null) // TODO (addins only?) addins: Synergy, Numbering, Rollup(Gantt) { if (_topic.IsCentralTopic && _extra == SUtils.SYNERGYMESSAGE) //SendMessage went off { if (sMessage == "paste") // SendMessage was emited from m_afterObjectAdded_Fire at starting paste copied objects { // so, paste events now is ended, we can process pasted objects foreach (MMBase _parent in DocumentStorage.m_parent) { _parent.onAfterPasteBase(new MMEventArgs(pSource, _what, _extra, this)); } paste = false; copypast = false; } //else if (sMessage == "received") // SendMessage was emited from ReceiveChanges // received = false; // прием закончен m_document.CentralTopic.get_Attributes(SUtils.SYNERGYMESSAGE).DeleteAll(); _topic = null; return; } if (_extra == SUtils.SYNERGYNAMESPACE && rollup) // all subtopics already skipped, rollup operation finished { rollup = false; _topic = null; return; } } if (rollup) // skip all rollup subtopics, change only parent { _topic = null; return; } if (_what == "task") // TODO впадает в цикл, если изменять Duration, Effort и ресурсы через панель Task Info { if (Changes.SaveChanges._topicxml == MMUtils.getCleanTopicXML(_topic.Xml)) { _topic = null; return; } } if (_topic != null) { // TODO надо как-то уловить последний оффсет для них и процессировать if ((_topic.IsFloatingTopic || _topic.IsCalloutTopic) && _what == "offset") { _topic = null; return; // number of offsets = number of floating topics in the map } if (_what == "task" && _extra == "") { // если при запуске карты выбран топик с задачей, то почему-то сразу срабатывает событие на task _topic = null; return; } //if (_what == "task" && _topic.Task.IsEmpty) // return; // при запуске карты может быть такое, если выбрано несколько топиков, один из который задача if (_extra == SUtils.numberinguri) { _what = "numbering"; } _extra = Changes.PortraitGet.TopicPortrait(_topic, ref _what, _extra, mc_MapFolderPath); //System.Windows.Forms.Clipboard.SetText(_extra); if (_extra == SUtils.rollupuri) { System.Windows.Forms.MessageBox.Show("'Комбинировать информацию о задании' пока не поддерживается, другие пользователи не получат это изменение", MMUtils.GetString("maps.synergywarning.caption")); return; } if (_extra == "queue") { System.Windows.Forms.MessageBox.Show("Произведенное изменение пока не поддерживается в Synergy, другие пользователи не получат это изменение", MMUtils.GetString("maps.synergywarning.caption")); return; } } foreach (MMBase _parent in DocumentStorage.m_parent) { _parent.onAfterObjectChangedBase(new MMEventArgs(pSource, _what, _extra, this)); } }
// Event handler for MapFolder private void mfOnChanged(object source, FileSystemEventArgs e) { string _username = Path.GetFileNameWithoutExtension(e.FullPath); string _whathappen = e.ChangeType.ToString().ToLower(); // "created" or "deleted" or "changed" FileInfo f = new FileInfo(e.FullPath); if (f.Extension.Equals(".online")) { string _conflict = MMUtils.GetString("cloud.conflict.text"); if (_username.ToLower().IndexOf(_conflict) != -1) { f.Delete(); f = null; return; } if (_whathappen == "created") { foreach (Timers _item in Maps.MapsGroup.TIMERS) { if (_item.m_Guid == aMapGuid) { if (!_item.UsersOnline.Contains(_username)) { _item.UsersOnline.Add(_username); } string rr = MMUtils.ActiveDocument.FullName; string ss = doc.FullName; if (rr == ss) // active map { _item.refresh = true; //_item.refreshIndicator_timer.Start(); } break; } } } if (_whathappen == "deleted") { foreach (Timers _item in Maps.MapsGroup.TIMERS) { if (_item.m_Guid == aMapGuid) { if (_item.UsersOnline.Contains(_username)) { _item.UsersOnline.Remove(_username); } string rr = MMUtils.ActiveDocument.FullName; string ss = doc.FullName; if (rr == ss) // active map { Maps.MapUsersDlg.users = _item.UsersOnline; _item.refresh = true; //_item.refreshIndicator_timer.Start(); } break; } } } } if (f.Extension.Equals(".locker")) { } f = null; }
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; }