Beispiel #1
0
        public void Save()
        {
            Member MemberInfo = (Member)this.Tag;

            if (MemberInfo.IsEditable())
            {
                if (!MemberInfo._IsBeingSaved)
                {
                    MemberInfo._IsBeingSaved = true;

                    Editor.TheEditor.SetStatus("Saving " + MemberInfo.GetMember() + "..");
                    Thread gothread = new Thread((ThreadStart) delegate
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            File.WriteAllText(MemberInfo.GetLocalFile(), this.GetText(), textEditor.Encoding);
                        });

                        MemberCache.EditsAdd(MemberInfo.GetLibrary(), MemberInfo.GetObject(), MemberInfo.GetMember());

                        bool UploadResult = IBMiUtils.UploadMember(MemberInfo.GetLocalFile(), MemberInfo.GetLibrary(), MemberInfo.GetObject(), MemberInfo.GetMember());
                        if (UploadResult == false)
                        {
                            //MessageBox.Show("Failed to upload to " + MemberInfo.GetMember() + ".");
                        }
                        else
                        {
                            this.Invoke((MethodInvoker) delegate
                            {
                                if (GetParent().Text.EndsWith("*"))
                                {
                                    GetParent().Text = GetParent().Text.Substring(0, GetParent().Text.Length - 1);
                                }
                            });
                        }

                        this.Invoke((MethodInvoker) delegate
                        {
                            Editor.TheEditor.SetStatus(MemberInfo.GetMember() + " " + (UploadResult ? "" : "not ") + "saved.");
                        });

                        MemberInfo._IsBeingSaved = false;
                    });

                    gothread.Start();
                }
            }
            else
            {
                MessageBox.Show("This file is readonly.");
            }
        }
Beispiel #2
0
        public void Save()
        {
            RemoteSource SourceInfo   = (RemoteSource)this.Tag;
            bool         UploadResult = true;

            if (SourceInfo != null)
            {
                if (SourceInfo.IsEditable())
                {
                    if (!SourceInfo._IsBeingSaved)
                    {
                        SourceInfo._IsBeingSaved = true;

                        Editor.TheEditor.SetStatus("Saving " + SourceInfo.GetName() + "..");
                        Thread gothread = new Thread((ThreadStart) delegate
                        {
                            MemberCache.EditsAdd(SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                            this.Invoke((MethodInvoker) delegate
                            {
                                File.WriteAllText(SourceInfo.GetLocalFile(), this.GetText(), textEditor.Encoding);
                            });

                            switch (SourceInfo.GetFS())
                            {
                            case FileSystem.QSYS:
                                UploadResult = IBMiUtils.UploadMember(SourceInfo.GetLocalFile(), SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                                break;

                            case FileSystem.IFS:
                                UploadResult = IBMiUtils.UploadFile(SourceInfo.GetLocalFile(), SourceInfo.GetRemoteFile());
                                break;
                            }
                            if (UploadResult == false)
                            {
                            }
                            else
                            {
                                this.Invoke((MethodInvoker) delegate
                                {
                                    if (GetParent().Text.EndsWith("*"))
                                    {
                                        GetParent().Text = GetParent().Text.Substring(0, GetParent().Text.Length - 1);
                                    }
                                });
                            }

                            this.Invoke((MethodInvoker) delegate
                            {
                                Editor.TheEditor.SetStatus(SourceInfo.GetName() + " " + (UploadResult ? "" : "not ") + "saved.");
                            });

                            SourceInfo._IsBeingSaved = false;
                        });

                        gothread.Start();
                    }
                }
                else
                {
                    MessageBox.Show("This file is readonly.");
                }
            }
            else
            {
                File.WriteAllText(this.LocalPath, this.GetText(), textEditor.Encoding);
                if (GetParent().Text.EndsWith("*"))
                {
                    GetParent().Text = GetParent().Text.Substring(0, GetParent().Text.Length - 1);
                }
                Editor.TheEditor.SetStatus("File saved locally.");
            }
        }
Beispiel #3
0
        private void Save()
        {
            RemoteSource SourceInfo   = (RemoteSource)this.Tag;
            bool         UploadResult = true;

            if (SourceInfo != null)
            {
                if (SourceInfo.IsEditable())
                {
                    if (!CurrentSaving)
                    {
                        CurrentSaving = true;

                        Editor.TheEditor.SetStatus("Saving " + SourceInfo.GetName() + "..");
                        Thread gothread = new Thread((ThreadStart) delegate
                        {
                            MemberCache.EditsAdd(SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                            this.Invoke((MethodInvoker) delegate
                            {
                                File.WriteAllText(SourceInfo.GetLocalFile(), this.GetText(), textEditor.Encoding);
                            });

                            switch (SourceInfo.GetFS())
                            {
                            case FileSystem.QSYS:
                                UploadResult = IBMiUtils.UploadMember(SourceInfo.GetLocalFile(), SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                                break;

                            case FileSystem.IFS:
                                UploadResult = IBMiUtils.UploadFile(SourceInfo.GetLocalFile(), SourceInfo.GetRemoteFile());
                                break;
                            }
                            if (UploadResult == false)
                            {
                            }
                            else
                            {
                                this.Invoke((MethodInvoker) delegate
                                {
                                    if (this.Text.EndsWith("*"))
                                    {
                                        this.Text = this.Text.Substring(0, this.Text.Length - 1);
                                    }
                                });
                                DoAction(EditorAction.ParseCode);
                                DoAction(EditorAction.OutlineUpdate);
                            }

                            this.Invoke((MethodInvoker) delegate
                            {
                                Editor.TheEditor.SetStatus(SourceInfo.GetName() + " " + (UploadResult ? "" : "not ") + "saved.");
                            });

                            CurrentSaving = false;
                        });

                        gothread.Start();
                    }
                    else
                    {
                        Editor.TheEditor.SetStatus("Please wait until previous save has finished.");
                    }
                }
                else
                {
                    MessageBox.Show("This file is readonly.");
                }
            }
            else
            {
                File.WriteAllText(this.LocalPath, this.GetText(), textEditor.Encoding);
                if (this.Text.EndsWith("*"))
                {
                    this.Text = this.Text.Substring(0, this.Text.Length - 1);
                }
                Editor.TheEditor.SetStatus("File saved locally.");
            }
        }