Exemple #1
0
        public async Task DeleteSessionAsync(SessionIdentifier id)
        {
            _dataStoreBlock.Post(new DeleteSessionFromDataStoreRequest(id));

            var t = _spectraServiceBlock.ReceiveAsync();
            await t.ConfigureAwait(false);
        }
Exemple #2
0
 /// <summary>
 /// Constructor for load object from DB
 /// It must be used ONLY by EntityObjectFactory inherited class
 /// </summary>
 /// <param name="sessionId">Session identifier</param>
 /// <param name="objectId">Object identifier</param>
 public DomainObject(SessionIdentifier sessionId, ObjectIdentifier objectId)
 {
     // Save session identifier
     Session = sessionId;
     // Save object identifier
     ObjectId = objectId;
 }
Exemple #3
0
        public async Task PostDataAsync(SessionIdentifier id, Data data)
        {
            _dataStoreBlock.Post(new PostDataToSessionRequest(id, data));

            var t = _spectraServiceBlock.ReceiveAsync();
            await t.ConfigureAwait(false);
        }
        public SessionIdentifier Initialize(int age)
        {
            var id = new SessionIdentifier(CalculateNextId());

            TheData[id] = new BedId(TheData.Values.Any() ? TheData.Values.Max(v => v.Id) + 10 : 10);

            return(id);
        }
        public void SessionIdentifier_CreateNew_CreatesIdOfLengthLessThanOrEqualTo32()
        {
            // Given / when
            SessionIdentifier sessionIdentifier = this._sessionIdentifierService.CreateNew();

            // Then
            Assert.That(sessionIdentifier.StringId, Has.Length.LessThanOrEqualTo(32), $"Id {sessionIdentifier} is not valid");
        }
        public BedId Lookup(SessionIdentifier key)
        {
            if (TheData.ContainsKey(key))
            {
                return(TheData[key]);
            }

            return(BedId.None);
        }
 private void PlayerIdentified(SessionIdentifier obj)
 {
     PlayerData = new PSLPlayerData()
     {
         MatchId  = obj.gameInstanceID,
         PlayerId = obj.playerID,
         NickName = obj.playerNickName
     };
     Debug.Log("Set Player Id");
 }
Exemple #8
0
        internal Preview(SessionIdentifier session, string objectCode, DataTable table)
        {
            Session = session;
            ObjectCode = objectCode;

            Rows = new PreviewRowCollection(table.Rows.Count);
            foreach (DataRow row in table.Rows)
            {
                Rows.AddRow(new PreviewRow(ObjectCode, row));
            }
        }
Exemple #9
0
        BedId LookupBedIdFromSessionId(SessionIdentifier id)
        {
            var bed = _dataStore.Lookup(id);

            if (bed.Equals(BedId.None))
            {
                System.Diagnostics.Trace.WriteLine($"WARN - Session Id {id} was not found!");
            }

            return(bed);
        }
        public void SessionIdentifier_CreateNew_CreatesValidId()
        {
            // Given
            SessionIdentifier sessionIdentifier = this._sessionIdentifierService.CreateNew();

            // When
            bool isValid = this._sessionIdentifierService.IsValid(sessionIdentifier.StringId);

            // Then
            Assert.IsTrue(isValid, $"Id {sessionIdentifier} is not valid");
        }
        public ObjectRepository(SessionIdentifier session, DomainObjectInquiry objectInquiry)
        {
            m_link = new Dictionary<DomainLinkKey, DomainLink>(objectInquiry.ALinks.Count);

            foreach (DomainLinkConfig linkConfig in objectInquiry.ALinks)
            {
                DomainLinkKey key = new DomainLinkKey(linkConfig);
                DomainLink link = new DomainLink(linkConfig, session);

                m_link.Add(key, link);
            }
        }
        public void SessionIdentifier_CreateNew_ReturnsRandomId()
        {
            // Given
            var generatedIds = new HashSet <string>(1000);

            // When / then
            for (int count = 1000; count > 0; count--)
            {
                SessionIdentifier identifier = this._sessionIdentifierService.CreateNew();

                Assert.That(generatedIds.Add(identifier.StringId), Is.True, $"Non-unique identifier created: {identifier}");
            }
        }
Exemple #13
0
        /// <summary>
        /// Constructor for create new object
        /// </summary>
        /// <param name="sessionId">Session identifier</param>
        /// <param name="objectCode">Object code in config inquiry</param>
        public DomainObject(SessionIdentifier sessionId, string objectCode)
        {
            // Save session identifier
            Session = sessionId;
            // Get new object identifier
            ObjectId = DomainObjectManager.Instance.GetNewId(objectCode);
            // Get default properties for this object type
            Properties = DomainObjectManager.Instance.GetEmptyProperties(sessionId, ObjectId);
            AssignPropertyEvents();
            // Set object state to New
            State = eObjectState.New;

            DocumentManager.Instance.AddObject(this);
        }
Exemple #14
0
        public Uri GenerateUrlToPokerSessionLobby(SessionIdentifier urlId)
        {
            if (urlId == null)
            {
                throw new ArgumentNullException(nameof(urlId));
            }

            var uriBuilder = new UriBuilder(this._siteUrlDetectionService.GetSiteUrl())
            {
                Path = $"/pokertime-session/{urlId.StringId}/join"
            };

            return(uriBuilder.Uri);
        }
Exemple #15
0
        public AudioSession(AudioSessionControl session)
        {
            Session = session;
            Session.RegisterEventClient(this);

            SessionIdentifier = Session.GetSessionIdentifier;

            IsSystemSound = Session.IsSystemSoundsSession || Session.GetProcessID == 0;
            string appId = SessionIdentifier.ExtractAppPath();

            Id = IsSystemSound ? int.MinValue : appId.GetHashCode();

            UpdateDisplayName();
        }
Exemple #16
0
        private void LockObject(SessionIdentifier session, ObjectIdentifier objectId)
        {
            LocalObjectLockInfo objectLock = null;
            if (lockedObjectStorage.TryGetValue(objectId, out objectLock))
            {
                if (session != objectLock.Session)
                {
                    throw new DomainException(String.Format("Объект c OID = {0} заблокирован в сессии {1} {2:HH.mm dd MMMM yyyy}", objectId, objectLock.Session, objectLock.BeginLockDate));
                }

                return;
            }

            lockedObjectStorage.Add(objectId, new LocalObjectLockInfo(session, objectId, DateTime.Now));
        }
        public DomainObject BeginGetObject(ObjectIdentifier objectId, SessionIdentifier sessionId)
        {
            DomainObject tempResult = null;
            bool needCloneObject = true;
            object lockObject = null;

            lock (m_sharedObjRepositoryLock)
            {
                tempResult = m_sharedObjRepository.GetObject(objectId);
                if (tempResult != null)
                    return CloneObject(tempResult, sessionId);

                // сюда мы попадем если только объект еще не загружен
                lock (m_getObjectLock)
                {
                    if (!m_getObjectLock.TryGetValue(objectId, out lockObject))
                    {
                        // если объект не заблокирован другим документом, то
                        lockObject = new object();
                        m_getObjectLock.Add(objectId, lockObject);

                        needCloneObject = false;
                        Monitor.Enter(lockObject);
                    }
                }
            }

            if (needCloneObject)
                Monitor.Enter(lockObject);

            // сюда потоки попадут в том порядке в котором они одновременно пытаются запросить объект с одним и тем же Id

            // если этот поток первый запрашивает объект, то ничего не возвращаем
            if (!needCloneObject)
                return null;

            Monitor.Exit(lockObject);
            // после того как объект материтализовался в другом документе(потоке) возвращаем его
            lock (m_sharedObjRepositoryLock)
            {
                // получаем объект из расшаренной сессии
                tempResult = m_sharedObjRepository.GetObject(objectId);
                // клонируем объект
                return CloneObject(tempResult, sessionId);
            }
        }
Exemple #18
0
 /// <summary>
 /// Deside appropriate name for an audio session which can identify the session
 /// </summary>
 /// <returns>Appropriate name</returns>
 public string MakeName()
 {
     if (IsSystemSoundSession)
     {
         return("System Sound");
     }
     else if (SessionIdentifier.EndsWith("{5E081B13-649D-48BC-9F67-4DBF51759BD8}"))
     {
         return("Windows Shell Experience Host");
     }
     else if (SessionIdentifier.EndsWith("{ABC33D23-135D-4C00-B1BF-A9FA4C7916D4}"))
     {
         return("Microsoft Edge");
     }
     else if (!string.IsNullOrWhiteSpace(DisplayName))
     {
         return(DisplayName);
     }
     //else if (!string.IsNullOrWhiteSpace(MainWindowTitle)) { return MainWindowTitle; }
     else if (!string.IsNullOrWhiteSpace(ProcessName))
     {
         return(ProcessName);
     }
     else
     {
         string name = SessionIdentifier;
         int    startidx = name.IndexOf("|"), endidx = name.IndexOf("%b");
         name = name.Substring(startidx, endidx - startidx + 2);
         if (name == "|#%b")
         {
             name = "System";
         }
         else
         {
             startidx = name.LastIndexOf("\\") + 1; endidx = name.IndexOf("%b");
             name     = name.Substring(startidx, endidx - startidx);
             if (name.EndsWith(".exe"))
             {
                 name = name.Substring(0, name.LastIndexOf(".exe"));
             }
         }
         return(name);
     }
 }
Exemple #19
0
        public AudioSession(AudioSessionControl session)
        {
            Session = session;
            Session.RegisterAudioSessionNotification(_events);

            _session2    = Session.QueryInterface <AudioSessionControl2>();
            _simpleAudio = Session.QueryInterface <SimpleAudioVolume>();

            _events.StateChanged        += OnStateChanged;
            _events.SimpleVolumeChanged += OnVolumeChanged;

            SessionIdentifier = _session2.SessionInstanceIdentifier;

            IsSystemSound = _session2.IsSystemSoundSession || _session2.ProcessID == 0 || _session2.Process == null;
            string appId = SessionIdentifier.ExtractAppId();

            Id = IsSystemSound ? int.MinValue : appId.GetHashCode();

            UpdateDisplayName();
        }
        /// <summary>
        /// Method for generating and looking up session Identifiers by type.
        /// </summary>
        /// <param name="sessionType">Type of session.</param>
        /// <returns>Identifier unique to the supplied type of session.</returns>
        internal static SessionIdentifier GetIdentifier(Type sessionType)
        {
            // If we previously did a check, pull value from cache.
            if (sessionIdentifiers.ContainsKey(sessionType))
            {
                return(sessionIdentifiers[sessionType]);
            }

            // get the base type
            var baseType = sessionType.GetTypeInfo().BaseType;

            // get the base type key
            var baseTypeKey = baseType == typeof(SessionBase)
                ? (ulong)0
                              // Recursively get all base typse ensureing that our all base types
                              // have a key and that our hierarchy is complete.
                : GetIdentifier(baseType).Hierarchy;

            // get the current session-only type key
            ulong sessionOnly = nextIdentifierToBeIssued;

            nextIdentifierToBeIssued <<= 1;

            // 'or' the base type key with the current key
            ulong identifier = baseTypeKey | sessionOnly;

            // create a session identifier
            var sessionIdentifier = new SessionIdentifier()
            {
                sessionOnly = sessionOnly,
                Hierarchy   = identifier,
            };

            // cache the session identifier for future lookups.
            sessionIdentifiers.Add(sessionType, sessionIdentifier);

            // return the identifier
            return(sessionIdentifier);
        }
Exemple #21
0
 protected FetchIdFromDataStoreRequest(SessionIdentifier id)
 {
     Id = id;
 }
Exemple #22
0
 public DeleteSessionFromDataStoreRequest(SessionIdentifier id) : base(id)
 {
 }
        public DomainPropertyCollection GetEmptyProperties(SessionIdentifier sessionId, ObjectIdentifier parentId)
        {
            DomainObjectConfig obj = m_inquiry.AObject[parentId.Code];
            DomainPropertyCollection result = new DomainPropertyCollection();

            foreach (DomainPropertyConfig prop in obj.Property)
            {
                DomainProperty newProperty = new DomainProperty(sessionId, parentId, prop.Code, prop.DefaultValue);
                result.Add(newProperty);
            }

            return result;
        }
 private DomainProperty CloneProperty(DomainProperty property, SessionIdentifier newSession)
 {
     return new DomainProperty(newSession, property.m_parentId, property.Code, property.Value);
 }
 public LocalObjectLockInfo(SessionIdentifier session, ObjectIdentifier objectId, DateTime lockDate)
 {
     Session = session;
     ObjectId = objectId;
     BeginLockDate = lockDate;
 }
Exemple #26
0
 internal Document(SessionIdentifier sid, DomainObjectInquiry inquiry)
 {
     Session = sid;
     m_objRepository = new ObjectRepository(Session, inquiry);
 }
 public abstract DomainObject CreateDomainObject(SessionIdentifier sessionId, ObjectIdentifier objectId);
Exemple #28
0
        public void Execute(SessionIdentifier session)
        {
            throw new NotImplementedException();

            //DbCommonCommand command = new DbCommonCommand(Source, Connection);
            //foreach (DbCommonCommandParameter param in m_parameter.Values)
            //    command.AddParameter(param.Code, param.DataType, param.IsCollection, param.Value);

            //command.ExecuteNonQuery(session);
        }
        public virtual int ExecuteNonQuery(SessionIdentifier session, bool allowDeferredExecution = false)
        {
            CheckConnection();

            if (Connection.SupportBatchQueries)
            {
                string sql = GetPreparedSql();

                if (allowDeferredExecution)
                {
                    return ExecuteNonQuery(session, sql, allowDeferredExecution);
                }

                return ExecuteNonQuery(session, sql);
            }
            else
            {
                List<string> sqlList = GetQueryList();

                if (sqlList.Count == 0)
                    throw new DomainException(Resources.CanNotExecuteEmptyQuery);

                int lastResult = -1;

                foreach (string currentQuery in sqlList)
                {
                    lastResult = ExecuteNonQuery(session, currentQuery, allowDeferredExecution);
                }

                return lastResult;
            }
        }
 public void DeleteSession(SessionIdentifier key)
 {
     TheData.Remove(key);
 }
        private static void SaveObject(SessionIdentifier session, IGrouping<string, DomainObject> objGroup, DbCommonCommand saveCommand)
        {
            foreach (var obj in objGroup)
            {
                saveCommand[DomainObjectBroker.ObjectIdField].Value = obj.ObjectId.Id;

                foreach (DomainProperty objProperty in obj.Properties)
                {
                    saveCommand[objProperty.Code].Value = objProperty.Value;
                }

                saveCommand.ExecuteNonQuery(session, true);
            }
        }
        private void LoadLinkedObjects(SessionIdentifier sessionId, ObjectIdentifier objectId)
        {
            string objCode = objectId.Code;

            DomainObjectBroker broker = GetObjectBroker(objCode);

            long[] idList = new long[] { objectId.Id };

            DbCommonCommand command = broker.LoadLinkedItemsCommand;
            command["ID"].Value = idList;

            using (IDbCommonDataReader reader = command.ExecuteReader(sessionId))
            {
                while (reader.Read())
                {
                    long leftId = reader.GetValue<long>(0);
                    long rightId = reader.GetValue<long>(1);
                    string linkCode = reader.GetValue<string>(2);

                    DomainLinkConfig linkConfig = broker.GetLinkConfig(linkCode);
                    DomainLinkKey linkKey = new DomainLinkKey(linkConfig);
                    //DomainLink link = SharedRepository.GetLink(linkKey);
                    DomainLink link = DocumentManager.Instance.GetLink(sessionId, linkKey);

                    link.Init(leftId, rightId);
                }

                reader.Close();
            }
        }
 public NoOpServiceRequestWithId(SessionIdentifier id)
 {
     Id = id;
 }
        private void SateToDB(SessionIdentifier session, ObjectRepository objRepository)
        {
            foreach (IGrouping<string, DomainObject> newObjGroup in objRepository.NewObjectGroup)
            {
                string objCode = newObjGroup.Key;

                DomainObjectBroker objBroker = GetObjectBroker(objCode);
                DbCommonCommand saveCommand = objBroker.NewItemCommand;

                SaveObject(session, newObjGroup, saveCommand);
            }

            foreach (IGrouping<string, DomainObject> saveObjGroup in objRepository.OldChangedObjects)
            {
                string objCode = saveObjGroup.Key;

                DomainObjectBroker objBroker = GetObjectBroker(objCode);
                DbCommonCommand saveCommand = objBroker.SaveItemCommand;

                SaveObject(session, saveObjGroup, saveCommand);
            }

            foreach (IGrouping<string, DomainObject> deleteObjGroup in objRepository.DeletedObjects)
            {
                string objCode = deleteObjGroup.Key;

                DomainObjectBroker objBroker = GetObjectBroker(objCode);
                DbCommonCommand deleteCommand = objBroker.DeleteItemsCommand;

                deleteCommand[DomainObjectBroker.ObjectIdField].Value = deleteObjGroup;
                deleteCommand.ExecuteNonQuery(session, true);
            }

            foreach (KeyValuePair<DomainLink, IEnumerable<DomainLinkNode>> link in objRepository.NewLinks)
            {
                DomainLinkBroker linkBroker = GetLinkBroker(link.Key.Key);
                DbCommonCommand dbCommand = linkBroker.NewItemCommand;

                SaveLink(session, link, dbCommand);
            }

            foreach (KeyValuePair<DomainLink, IEnumerable<DomainLinkNode>> link in objRepository.DeletedLinks)
            {
                DomainLinkBroker linkBroker = GetLinkBroker(link.Key.Key);
                DbCommonCommand dbCommand = linkBroker.DeleteItemCommand;

                SaveLink(session, link, dbCommand);
            }

            m_connection.Commit(session);
        }
        private static void SaveLink(SessionIdentifier session, KeyValuePair<DomainLink, IEnumerable<DomainLinkNode>> link, DbCommonCommand saveCommand)
        {
            foreach (DomainLinkNode node in link.Value)
            {
                saveCommand[DomainLinkBroker.LeftObjectIdParam].Value = node.LeftObjectId.Id;
                saveCommand[DomainLinkBroker.RightObjectIdParam].Value = node.RightObjectId.Id;

                saveCommand.ExecuteNonQuery(session, true);
            }
        }
        /// <summary>
        /// Load object from DB
        /// </summary>
        /// <param name="sessionId">Session identifier</param>
        /// <param name="objectId">Object identifier</param>
        /// <returns></returns>
        public DomainObject Materialize(SessionIdentifier sessionId, ObjectIdentifier objectId)
        {
            // load object properties from DB
            DomainPropertyCollection properties = LoadProperties(sessionId, objectId);
            // load linked objects identifiers
            LoadLinkedObjects(sessionId, objectId);
            // Create object by Factory
            DomainObject result = ObjectFactory.CreateDomainObject(sessionId, objectId);
            // Save properties to object and mark internal object state to Old
            result.Init(properties);
            //
            SharedRepository.EngGetObject(result);

            return result;
        }
        public DataTable ExecuteTable(SessionIdentifier session)
        {
            CheckConnection();

            return Connection.ExecuteTable(session, GetPreparedSql());
        }
Exemple #38
0
 public void PostFetalData(SessionIdentifier id, Data d) => { }
 protected int ExecuteNonQuery(SessionIdentifier session, string sql, bool allowDeferredExecution = false)
 {
     if (allowDeferredExecution)
     {
         Connection.AddDeferredQuery(session, sql);
         return -1;
     }
     else
     {
         DbCommand dbCommand = Connection.GetSqlCommand(session, sql);
         return dbCommand.ExecuteNonQuery();
     }
 }
        private DomainObject CloneObject(DomainObject obj, SessionIdentifier newSession)
        {
            DomainPropertyCollection propertyCollection = new DomainPropertyCollection();
            //EntityLinkCollection linkCollection = new EntityLinkCollection();

            foreach (DomainProperty property in obj.Properties)
            {
                DomainProperty newProperty = CloneProperty(property, newSession);
                propertyCollection.Add(newProperty);
            }

            //foreach (EntityLink link in obj.Links)
            //{
            //    EntityLink newLink = CloneLink(link, newSession);
            //    linkCollection.Add(newLink);
            //}

            DomainObject result = m_objectFactory.CreateDomainObject(newSession, obj.ObjectId);
            result.Init(propertyCollection);

            return result;
        }
 protected Object ExecuteScalar(SessionIdentifier session, string sql)
 {
     DbCommand dbCommand = Connection.GetSqlCommand(session, sql);
     return dbCommand.ExecuteScalar();
 }
        //private void UnlockAllObjectInSession(SessionIdentifier session)
        //{
        //    List<ObjectIdentifier> unlockList = new List<ObjectIdentifier>();
        //    lock (lockedObjectStorage)
        //    {
        //        foreach (LocalObjectLockInfo info in lockedObjectStorage.Values)
        //        {
        //            if (info.Session == session)
        //            {
        //                unlockList.Add(info.ObjectId);
        //            }
        //        }
        //        foreach (ObjectIdentifier oid in unlockList)
        //        {
        //            UnlockObject(session, oid);
        //        }
        //    }
        //}
        /// <summary>
        /// Разблокировать объект
        /// </summary>
        /// <param name="session"></param>
        /// <param name="objectId"></param>
        private void UnlockObject(SessionIdentifier session, ObjectIdentifier objectId)
        {
            //LocalObjectLockInfo objectLock = null;
            //if (!lockedObjectStorage.TryGetValue(objectId, out objectLock))
            //{
            //    throw new DomainException(String.Format("Попытка разблокировать не заблокированный объект {0},{1}", session, objectId));
            //}

            //if (objectLock.Session != session)
            //{
            //    throw new DomainException(String.Format("Попытка разблокировать объект {0},{1} из сессии", objectLock.Session, objectLock.ObjectId, session));
            //}

            //lockedObjectStorage.Remove(objectId);
        }
Exemple #43
0
 public void LinkModified(SessionIdentifier session, ObjectIdentifier objectId)
 {
     LockObject(session, objectId);
 }
Exemple #44
0
 public PostDataToSessionRequest(SessionIdentifier id, Data fetalData) : base(id)
 {
     FetalData = fetalData;
 }
Exemple #45
0
 public void PropertyModified(SessionIdentifier session, ObjectIdentifier objectId)
 {
     LockObject(session, objectId);
 }
Exemple #46
0
 public FetchIdForRetrievingAnalyticsDataStoreRequest(SessionIdentifier id) : base(id)
 {
 }
        public void SaveRepository(SessionIdentifier session, ObjectRepository objRepository)
        {
            SateToDB(session, objRepository);

            // Скопировать данные в глобальный репозиторий
            SharedRepository.SaveRepositoryChanges(objRepository);

            // DocumentManager.Instance.

            // Сбросить состояния объектов
            objRepository.ResetObjectState();
            // Сбросить состояния ссылок
            objRepository.ResetLinkState();

            //m_documentManager.SaveDocument(this);

            //// Записать в глобальный кеш новые объект
            //foreach (ObjectIdentifier objectId in NewObject)
            //{
            //    EntityObject obj = objectStorage[objectId];
            //}
            //// очистить коллекции созданных объектов
            //NewObject.Clear();

            //// Список id объектов уже перезаписанных в кеше
            //List<ObjectIdentifier> unlockList = new List<ObjectIdentifier>();
            //// добавить измененный объект (свойства) в список для снятия блокировки
            //foreach (ObjectIdentifier oid in ChangedObjectProperty)
            //{
            //    unlockList.Add(oid);
            //    EntityObject obj = objectStorage[oid];
            //}
            //ChangedObjectProperty.Clear();

            //// добавить измененный объект (свойства) в список для снятия блокировки
            //foreach (ObjectIdentifier oid in ChangedObjectLink)
            //{
            //    if (!unlockList.Contains(oid))
            //    {
            //        unlockList.Add(oid);
            //        EntityObject obj = objectStorage[oid];
            //    }
            //}
            //ChangedObjectLink.Clear();

            //// очистить из хранилища удаленные объекты
            //foreach (List<ObjectIdentifier> list in m_removeObjectList.Values)
            //{
            //    foreach (ObjectIdentifier oid in list)
            //    {
            //        objectStorage.Remove(oid);
            //    }
            //}
            //m_removeObjectList.Clear();
        }
Exemple #48
0
        public async Task <object> FetchAnalyticsAsync(SessionIdentifier id)
        {
            _dataStoreBlock.Post(new FetchIdForRetrievingAnalyticsDataStoreRequest(id));

            return(await _spectraServiceBlock.ReceiveAsync());
        }
Exemple #49
0
 public CreatePokerSessionCommandResponse(SessionIdentifier identifier, QrCode qrCode, string location)
 {
     this.Identifier = identifier;
     this.QrCode     = qrCode;
     this.Location   = location;
 }
        public IDbCommonDataReader ExecuteReader(SessionIdentifier session)
        {
            CheckConnection();

            DbCommand dbCommand = Connection.GetSqlCommand(session, GetPreparedSql());
            DbDataReader dbReader = dbCommand.ExecuteReader();
            return Connection.GetSqlDataReader(dbReader);
        }
        private DomainPropertyCollection LoadProperties(SessionIdentifier sessionId, ObjectIdentifier objectId)
        {
            string objCode = objectId.Code;

            DomainObjectConfig objConfig = m_inquiry.AObject[objCode];
            DomainObjectBroker broker = GetObjectBroker(objCode);

            long[] idList = new long[] { objectId.Id };

            DbCommonCommand command = broker.LoadItemsCommand;
            command["ID"].Value = idList;

            DomainPropertyCollection result = null;
            using (IDbCommonDataReader reader = command.ExecuteReader(sessionId))
            {
                if (!reader.Read())
                {
                    reader.Close();
                    throw new DomainException(String.Format("Объект {0} не найден в БД", objectId));
                }

                result = new DomainPropertyCollection();
                foreach (DomainPropertyConfig prop in objConfig.Property)
                {
                    object value = reader.GetValue(reader.GetOrdinal(prop.Code), prop.DataType);
                    DomainProperty newProperty = new DomainProperty(sessionId, objectId, prop.Code, value);
                    result.Add(newProperty);
                }
                reader.Close();
            }

            return result;
        }
Exemple #52
0
        public Preview GetPreview(SessionIdentifier session)
        {
            throw new NotImplementedException();

            //DbCommonCommand command = new DbCommonCommand(Source, Connection);
            //foreach (DbCommonCommandParameter param in m_parameter.Values)
            //    command.AddParameter(param.Code, param.DataType, param.IsCollection, param.Value);

            //return new Preview(session, ObjectType, command.ExecuteTable(session));
        }
        public Object ExecuteScalar(SessionIdentifier session)
        {
            CheckConnection();

            if (Connection.SupportBatchQueries)
            {
                string sql = GetPreparedSql();
                return ExecuteScalar(session, sql);
            }
            else
            {
                List<string> sqlList = GetQueryList();

                if (sqlList.Count == 0)
                    throw new DomainException(Resources.CanNotExecuteEmptyQuery);

                object lastResult = null;

                foreach (string currentQuery in sqlList)
                {
                    lastResult = ExecuteScalar(session, currentQuery);
                }

                return lastResult;
            }
        }