Пример #1
0
        public XElement GetLoginData(IPpsPrivateDataContext ctx = null)
        {
            if (ctx == null)
            {
                ctx = DEScope.GetScopeService <IPpsPrivateDataContext>(true);
            }

            // basic login data
            var xLoginData = new XElement("user",
                                          new XAttribute("userId", ctx.UserId),
                                          new XAttribute("displayName", ctx.UserName)
                                          );

            // update optional values
            if (ctx.TryGetProperty <long>(UserContextKtKtId, out var ktktId))
            {
                xLoginData.SetAttributeValue(UserContextKtKtId, ktktId.ChangeType <string>());
            }
            if (ctx.TryGetProperty <long>(UserContextPersId, out var persId))
            {
                xLoginData.SetAttributeValue(UserContextPersId, persId.ChangeType <string>());
            }
            if (ctx.TryGetProperty(UserContextFullName, out var fullName))
            {
                xLoginData.SetAttributeValue(UserContextFullName, fullName);
            }
            if (ctx.TryGetProperty(UserContextInitials, out var initials))
            {
                xLoginData.SetAttributeValue(UserContextInitials, initials);
            }

            // execute script based extensions
            var t = new LuaTable();

            CallMemberDirect("OnExtentLogin", new object[] { ctx, t }, ignoreNilFunction: true);
            foreach (var kv in t.Members)
            {
                xLoginData.SetAttributeValue(kv.Key, kv.Value);
            }

            return(xLoginData);
        }         // func GetLoginData
Пример #2
0
        }         // ctor

        /// <summary>Create a connection for the current active user.</summary>
        /// <param name="userContext">User context of the current active user (to not create any reference on it).</param>
        /// <param name="throwException">If the connection could not created it throws an exception.</param>
        /// <returns></returns>
        public abstract IPpsConnectionHandle CreateConnection(IPpsPrivateDataContext userContext, bool throwException = true);
Пример #3
0
            }             // func FindPooledConnection

            internal IPpsConnectionHandle GetOrCreatePooledConnection(PpsDataSource dataSource, IPpsPrivateDataContext userData, bool throwException)
            {
                lock (pooledConnections)
                {
                    var pooled = FindPooledConnection(dataSource);
                    if (pooled == null)
                    {
                        var handle = dataSource.CreateConnection(userData, throwException);
                        if (handle == null)
                        {
                            return(null);
                        }

                        pooledConnections.Add(new PooledConnection(handle));

                        Log.Info("New pooled connection: {0}", dataSource.Name);
                        return(handle);
                    }
                    else
                    {
                        //Log.Info("Reuse pooled connection: {0}", dataSource.Name);
                        return(pooled.Handle);
                    }
                }
            }             // func GetOrCreatePooledConnection
Пример #4
0
        }         // ctor

        /// <summary></summary>
        /// <param name="userData"></param>
        /// <param name="throwException"></param>
        /// <returns></returns>
        public override IPpsConnectionHandle CreateConnection(IPpsPrivateDataContext userData, bool throwException = true)
        => new PpsSysConnectionHandle(this, userData.Identity);