Esempio n. 1
0
        public static void HandleTrigger(SCNotification Notification)
        {
            Thread     gothread;
            string     path = GetCurrentFileName();
            OpenMember member;

            switch (Notification.nmhdr.code)
            {
            case (uint)NppMsg.NPPN_READY:
                break;

            case (uint)SciMsg.SCN_MODIFIED:
                break;

            case (uint)NppMsg.NPPN_FILEBEFOREOPEN:
                break;

            case (uint)NppMsg.NPPN_FILEOPENED:
                break;

            case (uint)NppMsg.NPPN_FILESAVED:
                member = OpenMembers.GetMember(path);
                if (member != null)
                {
                    gothread = new Thread((ThreadStart) delegate {
                        if (member.IsEditable())
                        {
                            if (member.GetSystemName() == IBMi.GetConfig("system"))
                            {
                                bool UploadResult = IBMiUtilities.UploadMember(member.GetLocalFile(), member.GetLibrary(), member.GetObject(), member.GetMember());
                                if (UploadResult == false)
                                {
                                    System.Windows.Forms.MessageBox.Show("Failed to upload to " + member.GetMember() + " on " + member.GetSystemName() + ".");
                                }
                            }
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("Unable to upload to " + member.GetMember() + ". You must be connected to " + member.GetSystemName() + " in order to save this file.");
                            }
                            if (Main.CommandWindow != null)
                            {
                                Main.CommandWindow.loadNewOutput();
                            }
                        }
                    });
                    gothread.Start();
                }
                break;

            case (uint)NppMsg.NPPN_FILEBEFORECLOSE:
                if (OpenMembers.Contains(path))
                {
                    OpenMembers.RemoveMember(path);
                    File.Delete(path);
                }
                break;
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Please note that saving to the member will overwrite any changes that you have not picked up since you last opened the member.", "Notice", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

            if (result == DialogResult.OK)
            {
                bool UploadResult = IBMiUtilities.UploadMember(this._Member.GetLocalFile(), this._Member.GetLibrary(), this._Member.GetObject(), this._Member.GetMember());

                if (UploadResult)
                {
                    this.Close();
                }
                else
                {
                    if (Main.CommandWindow != null)
                    {
                        Main.CommandWindow.loadNewOutput();
                    }
                    MessageBox.Show("Failed to save " + this._Member.GetMember() + ". Please check the Command Entry output.");
                }
            }
        }