Ejemplo n.º 1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string aStorage     = "";                  // name of Storage
            string aProjectPath = "";
            string aPlaceName   = comboPlaces.Text;    // name of selected Place
            string aPlacePath   = "";
            string aProjectName = txtProjectName.Text; // project to which we have to save the map

            using (ProjectsDB _db = new ProjectsDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PROJECTS where PROJECTNAME='" + aProjectName + "' and PLACENAME='" + aPlaceName + "'");
                if (_dt.Rows.Count > 0) // project with this name already exists
                {
                    lblProjectNameError.Text = MMUtils.GetString("createprojectdlg.projectexists.text");
                    return;
                }
            }

            // project name not entered
            if (aProjectName == "")
            {
                lblProjectNameError.Text = MMUtils.GetString("createprojectdlg.projectnameempty.text");
                return;
            }

            using (PlacesDB _db = new PlacesDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PLACES where PLACENAME='" + aPlaceName + "'");
                aStorage   = _dt.Rows[0]["STORAGE"].ToString();
                aPlacePath = _dt.Rows[0]["PLACEPATH"].ToString();
            }

            aProjectPath = aPlacePath + "$$" + aProjectName;
            string _localPath = MMUtils.m_SynergyLocalPath + aPlaceName + "\\" + aProjectName;

            try
            {
                System.IO.Directory.CreateDirectory(_localPath);
                System.IO.Directory.CreateDirectory(aProjectPath); // in the Place
            }
            catch (Exception _e)                                   // TODO cause!!! read-only, etc...
            {
                MessageBox.Show(this, "Error " + _e.Message, "title", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.Cancel; // TODO
            }

            ProjectsDB.AddProjectToDB(aStorage, aPlaceName, aProjectName, aProjectPath, _localPath);

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 2
0
        void GetProjects()
        {
            using (ProjectsDB _db = new ProjectsDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PROJECTS where PLACENAME=`" + comboMyPlaces.Text + "` order by PROJECTNAME");
                if (_dt.Rows.Count != 0)
                {
                    foreach (DataRow _row in _dt.Rows)
                    {
                        comboMyProjects.Items.Add(_row["PROJECTNAME"]);
                    }

                    comboMyProjects.Enabled = true;
                    chBoxSingleMap.Checked  = false;
                }
                else
                {
                    comboMyProjects.Enabled = false;
                    chBoxSingleMap.Checked  = true;
                }
            }
        }
Ejemplo n.º 3
0
        private void BtnOK_Click(object sender, EventArgs e)
        {
            string _docName     = publishDoc.Name;
            string aPlaceName   = comboMyPlaces.Text;
            string aGuid        = publishDoc.Guid;
            string aLocalPath   = "";
            string aPath        = ""; // full path to published map
            string aSite        = ""; // website to check for Internet connection
            string aProcess     = ""; // cloud app process to check if started
            string _projectName = "";
            string aStorage     = ""; // name of cloud app
            string aProjectPath = "";
            bool   singleMap    = chBoxSingleMap.Checked;

            if (!singleMap)
            {
                _projectName = comboMyProjects.Text;
            }

            // Single Maps
            if (singleMap)
            {
                using (PlacesDB _db = new PlacesDB())
                {
                    DataTable _dt = _db.ExecuteQuery("select * from PLACES where PLACENAME='" + aPlaceName + "'");
                    aProjectPath = _dt.Rows[0]["PLACEPATH"].ToString();
                    aStorage     = _dt.Rows[0]["STORAGE"].ToString();
                    aLocalPath   = MMUtils.m_SynergyLocalPath + aPlaceName + "\\";
                }
            }
            // Projects
            else
            {
                using (ProjectsDB _db = new ProjectsDB())
                {
                    DataTable _dt = _db.ExecuteQuery(
                        "select * from PROJECTS where PROJECTNAME='" + _projectName + "' and PLACENAME='" + aPlaceName + "'");
                    aProjectPath = _dt.Rows[0]["PROJECTPATH"].ToString();
                    aStorage     = _dt.Rows[0]["STORAGE"].ToString();
                    aLocalPath   = MMUtils.m_SynergyLocalPath + aPlaceName + "\\" + _projectName + "\\";
                }
            }

            if (publishDoc.Path == "") // new map not saved yet
            {
                using (NewMapDlg _dlg = new NewMapDlg())
                {
                    if (_dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd)) == DialogResult.Cancel)
                    {
                        return;
                    }
                    _docName = _dlg.textBox_MapName.Text + ".mmap";
                }
            }

            aLocalPath = aLocalPath + _docName;

            using (StoragesDB _db = new StoragesDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from STORAGES where STORAGENAME='" + aStorage + "'");
                aProcess = _dt.Rows[0]["PROCESS"].ToString();
                aSite    = _dt.Rows[0]["SITE"].ToString();
            }

            // Full path to map in Place
            aPath = Path.Combine(aProjectPath, _docName);

            // TODO предложить выбрать сохранение под другим именем
            if (Directory.Exists(aPath)) // map with this name is stored already in this place
            {
                System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(
                    MMUtils.GetString("publishmapdlg.mapexists.message"),
                    MMUtils.GetString("publishmapdlg.mapexists.caption"),
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                return;
            }

            string fail = "";

            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.endpubmessage");

            while ((fail = Internet.CheckInternetAndProcess(aGuid, aStorage, aProcess, aSite, "", "publish")) != "")
            {
                string _message = "", arg = "";

                if (fail == "processfail")
                {
                    _message = messageProcess; arg = aStorage;
                }
                else if (fail == "placefail")
                {
                    _message = messagePlace; arg = aPath;
                }
                else if (fail == "sitefail")
                {
                    _message = messageSite; arg = aSite;
                }

                if (System.Windows.Forms.MessageBox.Show(
                        String.Format(_message, arg) + endMessage,
                        String.Format(MMUtils.GetString("internet.failed.caption"), _docName),
                        System.Windows.Forms.MessageBoxButtons.RetryCancel, System.Windows.Forms.MessageBoxIcon.Exclamation)
                    == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.DialogResult = DialogResult.Cancel;
                    publishDoc        = null;
                    return;
                }

                if (fail == "sitefail")
                {
                    System.Diagnostics.Process.Start(arg); // launch website
                }
            }

            try // Save map to Local
            {
                publishDoc.SaveAs(aLocalPath);
            }
            catch (Exception _e) // TODO cause!!! read-only, etc... имя файла уже исключено выше
            {
                MessageBox.Show("Error: " + _e.Message, "PublishMapDlg", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.Cancel;
                publishDoc        = null;
                return;
            }

            //// Publish Map = set attributes to map, topics, relationships and boundaries and process links ////
            SUtils.singleMap = singleMap;

            Mindjet.MindManager.Interop.Transaction _tr = publishDoc.NewTransaction("");
            _tr.IsUndoable = false;
            _tr.Execute   += new Mindjet.MindManager.Interop.ITransactionEvents_ExecuteEventHandler(SUtils.PublishMap);
            _tr.Start();
            ///////////////////////////////////////////////////////////////////////////////////

            publishDoc.Save();

            if (SUtils.links.Count > 0)
            {
                using (LinkedFilesDlg _dlg = new LinkedFilesDlg(SUtils.links, publishDoc))
                {
                    DialogResult result = _dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd));
                    SUtils.links.Clear();
                    if (result == DialogResult.Cancel)
                    {
                        this.DialogResult = DialogResult.Cancel;
                        publishDoc        = null;
                        return;
                    }
                }
            }

            aPath = aPath + "\\"; // Map folder
            string mapFile = SUtils.modtime + ".mmap";

            try // save map to Place
            {
                Directory.CreateDirectory(aPath + "share");
                File.Copy(aLocalPath, aPath + mapFile); // copy as file!!!

                StreamWriter sw = new StreamWriter(File.Create(aPath + "info.ini"));
                sw.WriteLine(aStorage);     // чтобы если нет Интернета или Процесса, выдать сообщение с именем хранилища
                sw.WriteLine(_projectName); // чтобы находить карту из Места в локальной папке Synergy
                sw.WriteLine(aGuid);
                sw.WriteLine(aProcess);     // чтобы проверить Интернет и Процесс
                sw.WriteLine(aSite);        // чтобы проверить Интернет и Процесс
                sw.Close();
            }
            catch (Exception _e) // TODO cause!!! read-only, etc...
            {
                MessageBox.Show(this, "Error " + _e.Message, "title", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.Cancel;
                publishDoc        = null;
                return;
            }

            MapsDB.AddMapToDB(
                aStorage,
                aPlaceName,
                _projectName,
                aGuid, _docName,
                aPath,  // aPath - map directory in Place, with backslash
                aLocalPath,
                DateTime.UtcNow.ToString() + ";" + SUtils.currentUserName + ";" + SUtils.currentUserEmail
                );

            MapsGroup.m_UpdateOpenMap = true; // update Open Map submenu

            SUtils.ProcessMap(publishDoc);

            // Share map
            using (ShareMapDlg _dlg = new ShareMapDlg(MMUtils.ActiveDocument.Name, aPath))
            {
                _dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd));
            }

            this.DialogResult = DialogResult.OK;
            publishDoc        = null;
        }
Ejemplo n.º 4
0
        public void m_cmdOpenMaps_UpdateState(ref bool pEnabled, ref bool pChecked)
        {
            pEnabled = true;
            pChecked = false;

            if (!m_UpdateOpenMap)
            {
                return;
            }

            m_UpdateOpenMap = false;
            int a = 1;

            List <string> aProjects   = new List <string>();
            List <string> aSingleMaps = new List <string>();

            if (OpenButtons.Count != 0)
            {
                foreach (SubMenus item in OpenButtons)
                {
                    item.Destroy();
                }

                for (int i = 0; i < Labels.Count; i++)
                {
                    Labels[i].Delete(); Marshal.ReleaseComObject(Labels[i]); Labels[i] = null;
                }
            }
            OpenButtons.Clear();
            Labels.Clear();

            using (ProjectsDB _db = new ProjectsDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PROJECTS order by PROJECTNAME");
                foreach (DataRow _row in _dt.Rows)
                {
                    aProjects.Add(_row["PROJECTNAME"].ToString());
                }
            }

            using (PlacesDB _db = new PlacesDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PLACES order by PLACENAME");
                foreach (DataRow _row in _dt.Rows)
                {
                    aSingleMaps.Add(_row["PLACENAME"].ToString());
                }
            }

            using (MapsDB _db = new MapsDB())
            {
                bool    _label  = true;
                Control m_label = null;

                // Get maps by projects
                foreach (string _project in aProjects)
                {
                    DataTable _dt = _db.ExecuteQuery("select * from MAPS where PROJECTNAME=`" + _project + "` order by MAPNAME");

                    foreach (DataRow _row in _dt.Rows)
                    {
                        if (_label)
                        {
                            m_label = m_ctrlOpenMaps.Controls.AddLabel(_project);
                            _label  = false;
                            Labels.Add(m_label);
                        }

                        m_menus = new SubMenus();
                        OpenButtons.Add(m_menus);
                        m_menus.AddMapToOpenMenu(_row["MAPGUID"].ToString(), _row["MAPNAME"].ToString(), "map" + a++);
                    }
                    _label = true;
                }

                //_label = true;
                // Get single maps
                foreach (string _place in aSingleMaps)
                {
                    DataTable _dt = _db.ExecuteQuery("select * from MAPS where PROJECTNAME = `" + "" + "` and PLACENAME=`" + _place + "` order by MAPNAME");
                    //DataTable __dt = _db.ExecuteQuery("select * from MAPS");
                    foreach (DataRow _row in _dt.Rows)
                    {
                        if (_label)
                        {
                            m_label = m_ctrlOpenMaps.Controls.AddLabel(_place + ": " + SUtils.SingleMaps);
                            _label  = false;
                            Labels.Add(m_label);
                        }

                        m_menus = new SubMenus();
                        OpenButtons.Add(m_menus);
                        m_menus.AddMapToOpenMenu(_row["MAPGUID"].ToString(), _row["MAPNAME"].ToString(), "map" + a++);
                    }
                    _label = true;
                }

                aProjects.Clear();
                aSingleMaps.Clear();
            }
        }
Ejemplo n.º 5
0
        public MapReceivedDlg()
        {
            InitializeComponent();

            aHelpProvider.HelpNamespace = MMUtils.instPath + "\\Synergy.chm";
            aHelpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            aHelpProvider.SetHelpKeyword(this, "receive.htm");

            Text                       = MMUtils.GetString("receivedmapdlg.dlgtitle.text");
            lblPlace.Text              = MMUtils.GetString("receivedmapdlg.lblPlace.text");
            linkNewPlace.Text          = MMUtils.GetString("receivedmapdlg.linkNewPlace.text");
            lblReceivedFolderPath.Text = MMUtils.GetString("receivedmapdlg.lblReceivedFolderPath.text");
            rbtnPlace.Text             = MMUtils.GetString("receivedmapdlg.rbtnPlace.text");
            rbtnProject.Text           = MMUtils.GetString("receivedmapdlg.rbtnProject.text");
            btnCancel.Text             = MMUtils.GetString("buttonCancel.text");

            using (PlacesDB _db = new PlacesDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PLACES");
                foreach (DataRow _row in _dt.Rows)
                {
                    comboPlaces.Items.Add(_row["PLACENAME"]);
                }
                aStorage   = _dt.Rows[0]["STORAGE"].ToString();
                aPlacePath = _dt.Rows[0]["PLACEPATH"].ToString();
            }
            comboPlaces.SelectedIndex = 0;

            rbtnPlace.Checked = true;

            string LeaveInPlace = MMUtils.GetString("receivedmapdlg.rbtnLeaveInPlace.text");

            if (aStorage == "OneDrive")
            {
                LeaveInPlace             = LeaveInPlace + MMUtils.GetString("receivedmapdlg.LeaveInPlaceRec.text");
                rbtnLeaveInPlace.Checked = true;
            }
            rbtnLeaveInPlace.Text = LeaveInPlace;

            using (ProjectsDB _db = new ProjectsDB())
            {
                DataTable _dt = _db.ExecuteQuery("select * from PROJECTS where PLACENAME=`" + comboPlaces.Text + "` order by PROJECTNAME");
                foreach (DataRow _row in _dt.Rows)
                {
                    comboProjects.Items.Add(_row["PROJECTNAME"]);
                }
            }

            if (comboProjects.Items.Count == 0)
            {
                comboProjects.Items.Add(MMUtils.GetString("receivedmapdlg.noprojects"));
                comboProjects.Enabled = false;
                rbtnProject.Enabled   = false;
            }

            comboProjects.SelectedIndex = 0;

            // For FolderBrowser dialog
            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(aPlacePath).Parent;
            initfolder = dir.FullName.ToString();
        }