示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            synchronizationContext = SynchronizationContext.Current;

            // init env
            environment = new PpsEnvironment(lua, this, new PpsEnvironmentInfo("Test")
            {
                Uri = new Uri("http://localhost:8080/ppsn/")
            });
            environment.ContinueCatch(InitEnvironmentAsync());

            cmdEdit.Enabled = environment.IsAuthentificated;
            environment.IsAuthentificatedChanged += (sender, e) => cmdEdit.Enabled = environment.IsAuthentificated;

            joinTextBox.DataBindings.Add(new Binding("Text", listInfo, "Views", true, DataSourceUpdateMode.OnPropertyChanged));
            filterTextBox.DataBindings.Add(new Binding("Text", listInfo, "Filter", true, DataSourceUpdateMode.OnPropertyChanged));
            columnsTextBox.DataBindings.Add(new Binding("Text", listInfo, "Columns", true, DataSourceUpdateMode.OnPropertyChanged));
            listInfo.PropertyChanged += ListInfo_PropertyChanged;

            ////joinTextBox.Text = "views.Betriebsmittelstamm,(views.Werkzeugstamm,views.WkzLebenslauf)";
            //listInfo.Views = "views.Betriebsmittelstamm t=views.Werkzeugstamm t1=views.WkzLebenslauf t2";
            //listInfo.Filter = "t.BMKKID:test";
            //listInfo.Columns = String.Join(Environment.NewLine, "+t.BMKKIDENT", "t.BMKKBEZ", "t.BMKKCRDAT", "t.BMKKCRUSER", "t.BMKKFBERIDENT", "t.FBERNAME", "t.BMKKUPDAT", "t.BMKKUPUSER");
        }         // ctor
示例#2
0
        }         // func FindOrCreateEnvironment

        public PpsEnvironment AuthentificateEnvironment(PpsEnvironment environment)
        {
            if (environment == null)
            {
                return(null);
            }

            if (environment.IsAuthentificated)             // is authentificated
            {
                return(environment);
            }
            else
            {
                switch (environment.Await(environment.LoginAsync(this)))                // try to authentificate the environment
                {
                case PpsLoginResult.Sucess:
                    return(environment);

                case PpsLoginResult.Restart:
                    Application.Quit();
                    return(null);

                default:
                    return(null);
                }
            }
        }         // func AuthentificateEnvironment
示例#3
0
        public ReportInsertForm(PpsEnvironment env)
        {
            this.env = env;

            InitializeComponent();

            // run in background
            env.Spawn(RefreshViewAsync);
        }         // ctor
示例#4
0
        private WeakReference <PpsMasterDataRow> referencedRow = null;        // pointer to the actual row

        /// <summary></summary>
        /// <param name="row"></param>
        /// <param name="column"></param>
        public PpsMasterDataExtendedValue(PpsDataRow row, PpsDataColumnDefinition column)
            : base(row, column)
        {
            this.environment = PpsDataSetDefinitionDesktop.GetEnvironmentFromColumn(column);

            this.masterDataTable = environment.MasterData.GetTable(
                column.Meta.GetProperty <string>("refTable", null)
                ?? throw new ArgumentNullException("refTable", "Meta attribute refTable is not definied.")
                ) ?? throw new ArgumentNullException("refTable");
        }         // ctor
示例#5
0
        }         // func RequestComAddInAutomationService

        #region -- Environment Handling -----------------------------------------------

        private PpsEnvironment FindOrCreateEnvironment(PpsEnvironmentInfo info)
        {
            var env = GetEnvironmentFromInfo(info);

            if (env == null)
            {
                env = new PpsEnvironment(lua, this, info);
                openEnvironments.Add(env);
            }
            return(env);
        }         // func FindOrCreateEnvironment
示例#6
0
        }         // proc ActivateEnvironment

        public void DeactivateEnvironment(PpsEnvironment environment = null)
        {
            environment = environment ?? currentEnvironment;
            if (environment != null)
            {
                environment.ClearCredentials();

                if (currentEnvironment == environment)
                {
                    SetCurrentEnvironment(null);
                }
            }
        }         // proc DeactivateCurrentEnvironment
        /// <summary></summary>
        /// <param name="environment"></param>
        /// <param name="dialogMode"></param>
        public PpsSingleWindow(PpsEnvironment environment, bool dialogMode)
        {
            this.environment  = environment ?? throw new ArgumentNullException(nameof(environment));
            this.IsDialogMode = dialogMode;

            InitializeComponent();

            if (dialogMode)
            {
                if (Owner != null)
                {
                    WindowStartupLocation = WindowStartupLocation.CenterOwner;
                }
                else
                {
                    WindowStartupLocation = WindowStartupLocation.CenterScreen;
                }

                if (Height > SystemParameters.VirtualScreenHeight)
                {
                    Height = SystemParameters.VirtualScreenHeight - 75;
                }
                if (Width > SystemParameters.VirtualScreenWidth)
                {
                    Width = SystemParameters.VirtualScreenWidth - 75;
                }
            }
            else
            {
                if (Owner != null)
                {
                    WindowStartupLocation = WindowStartupLocation.CenterOwner;
                }
                else
                {
                    WindowStartupLocation = WindowStartupLocation.CenterScreen;
                }

                if (Height > SystemParameters.VirtualScreenHeight)
                {
                    Height = SystemParameters.VirtualScreenHeight - 75;
                }
                if (Width > SystemParameters.VirtualScreenWidth)
                {
                    Width = SystemParameters.VirtualScreenWidth - 75;
                }
            }
        }         // ctor
示例#8
0
        }         // func AuthentificateEnvironment

        public PpsEnvironment FindEnvironment(string name, Uri uri)
        {
            return((PpsEnvironment)waitForm.Invoke(new Func <PpsEnvironment>(() =>
            {
                PpsEnvironment envByName = null;
                PpsEnvironmentInfo infoByName = null;
                PpsEnvironmentInfo infoByUri = null;

                foreach (var oe in openEnvironments)
                {
                    if (oe.Info.Name == name)
                    {
                        envByName = oe;
                        break;
                    }
                }

                if (envByName != null)
                {
                    return AuthentificateEnvironment(envByName);
                }

                foreach (var info in PpsEnvironmentInfo.GetLocalEnvironments())
                {
                    if (info.Name == name)
                    {
                        infoByName = info;
                        break;
                    }
                    else if (info.Uri == uri)
                    {
                        infoByUri = info;
                    }
                }

                return AuthentificateEnvironment(FindOrCreateEnvironment(infoByName ?? infoByUri)) ?? CurrentEnvironment;
            })));
        }         // func FindEnvironment
示例#9
0
        }         // func GetActiveXlObjects

        /// <summary>Create Table</summary>
        /// <param name="environment"></param>
        /// <param name="range"></param>
        /// <param name="reportId"></param>
        /// <param name="reportName"></param>
        internal async Task ImportTableAsync(PpsEnvironment environment, Excel.Range range, string reportId, string reportName)
        {
            GetActiveXlObjects(out var worksheet, out var workbook);

            // prepare target
            if (range == null)
            {
                range = Globals.ThisAddIn.Application.Selection;
            }
            if (range is null)
            {
                throw new ExcelException("Keine Tabellen-Ziel (Range) definiert.");
            }
            if (range.ListObject != null)
            {
                throw new ExcelException("Tabelle darf nicht innerhalb einer anderen Tabelle eingefügt werden.");
            }

            using (var progress = CreateProgress())
            {
                progress.Report(String.Format("Importiere '{0}'...", reportName));
                await PpsListObject.NewAsync(environment, range, reportId);
            }
        }         // func ImportTableAsync
示例#10
0
 /// <summary></summary>
 /// <param name="environment"></param>
 /// <param name="schema"></param>
 /// <param name="xSchema"></param>
 public PpsDataSetDefinitionDesktop(PpsEnvironment environment, string schema, XElement xSchema)
     : base(environment, schema, xSchema)
 {
 }         // ctor
示例#11
0
 /// <summary></summary>
 /// <param name="row"></param>
 /// <param name="column"></param>
 public PpsLinkedObjectExtendedValue(PpsDataRow row, PpsDataColumnDefinition column)
     : base(row, column)
 {
     this.environment = PpsDataSetDefinitionDesktop.GetEnvironmentFromColumn(column);
     this.dataset     = row.Table.DataSet as IPpsObjectBasedDataSet;
 }         // ctor
        private static async Task <PpsObject> AppendAsync(IPpsAttachments attachments, PpsEnvironment environment, Func <Task <PpsObject> > createObject)
        {
            // every file one transaction, and exception handling
            using (var trans = await environment.MasterData.CreateTransactionAsync(PpsMasterDataTransactionLevel.Write))
            {
                var obj = await createObject();

                attachments.Append(obj);
                trans.Commit();
                return(obj);
            }
        }         // func AppendAsync
示例#13
0
 private static void ImportTableCommand(PpsEnvironment environment, string reportName, string reportId)
 => Globals.ThisAddIn.Run(() => Globals.ThisAddIn.ImportTableAsync(environment, GetTopLeftCell(), reportId, reportName));
 /// <summary>Append a stream to the attachemnts list</summary>
 /// <param name="attachments"></param>
 /// <param name="environment"></param>
 /// <param name="source"></param>
 /// <param name="name"></param>
 /// <param name="mimeType"></param>
 /// <returns></returns>
 public static Task <PpsObject> AppendAsync(this IPpsAttachments attachments, PpsEnvironment environment, Stream source, string name, string mimeType)
 => AppendAsync(attachments, environment, () => environment.CreateNewObjectFromStreamAsync(source, name, mimeType));
        }         // func AppendAsync

        /// <summary>Append a file to the attachments list.</summary>
        /// <param name="attachments"></param>
        /// <param name="environment"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static Task <PpsObject> AppendAsync(this IPpsAttachments attachments, PpsEnvironment environment, string fileName)
        => AppendAsync(attachments, environment, () => environment.CreateNewObjectFromFileAsync(fileName));
示例#16
0
 /// <summary></summary>
 /// <param name="row"></param>
 /// <param name="column"></param>
 public PpsObjectExtendedValue(PpsDataRow row, PpsDataColumnDefinition column)
     : base(row, column)
 {
     this.environment = PpsDataSetDefinitionDesktop.GetEnvironmentFromColumn(column);
     this.dataset     = (row.Table.DataSet as IPpsObjectBasedDataSet) ?? throw new ArgumentException("Dataset does not implement IPpsObjectBasedDataSet.");
 }         // ctor
示例#17
0
 /// <summary></summary>
 /// <param name="env"></param>
 public PpsDataFieldFactory(PpsEnvironment env)
 {
     Environment = env;
 }         // ctor
示例#18
0
        }         // proc DeactivateCurrentEnvironment

        private void SetCurrentEnvironment(PpsEnvironment env)
        {
            currentEnvironment = env;
            CurrentEnvironmentChanged?.Invoke(this, EventArgs.Empty);
        }         // proc SetCurrentEnvironment