示例#1
0
 public static void SendActivateItemMessage(OID itemId, long objectId)
 {
     ActivateItemMessage message = new ActivateItemMessage();
     message.ItemId = itemId;
     message.ObjectId = objectId;
     Client.Instance.NetworkHelper.SendMessage(message);
 }
 /// <param name="oid"> The Oid of the object to be inserted </param>
 /// <param name="nnoi"> The object meta representation The object to be inserted in the database </param>
 /// <param name="isNewObject"> To indicate if object is new </param>
 /// <returns> The position of the inserted object </returns>
 public OID InsertNonNativeObject(OID oid, NonNativeObjectInfo nnoi, bool isNewObject)
 {
     var ci = nnoi.GetClassInfo();
     var @object = nnoi.GetObject();
     // First check if object is already being inserted
     // This method returns -1 if object is not being inserted
     var cachedOid = _session.GetCache().IdOfInsertingObject(@object);
     if (cachedOid != null)
         return cachedOid;
     // Then checks if the class of this object already exist in the
     // meta model
     ci = _objectWriter.AddClass(ci, true);
     // Resets the ClassInfo in the objectInfo to be sure it contains all
     // updated class info data
     nnoi.SetClassInfo(ci);
     // Mark this object as being inserted. To manage cyclic relations
     // The oid may be equal to -1
     // Later in the process the cache will be updated with the right oid
     _session.GetCache().StartInsertingObjectWithOid(@object, oid);
     // false : do not write data in transaction. Data are always written
     // directly to disk. Pointers are written in transaction
     var newOid = WriteNonNativeObjectInfo(oid, nnoi, -1, false, isNewObject);
     if (!Equals(newOid, StorageEngineConstant.NullObjectId))
         _session.GetCache().AddObject(newOid, @object, nnoi.GetHeader());
     
     return newOid;
 }
示例#3
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            var candidate = values[AttributeName];

            if (candidate is OID)
            {
                var candidateOid = (OID)candidate;
                candidate = _query.GetQueryEngine().GetObjectFromOid(candidateOid);
            }

            if (!(candidate is IList || candidate is string))
                throw new OdbRuntimeException(
                    NDatabaseError.UnsupportedOperation.AddParameter("Size() with string or collection as the argument"));

            var candidateAsString = candidate as string;
            if (candidateAsString != null)
            {
                _size = candidateAsString.Length;
            }
            else
            {
                var list = (IList)candidate;
                _size = list.Count;    
            }
        }
示例#4
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            var candidate = values[AttributeName];

            if (candidate is OID)
            {
                var candidateOid = (OID)candidate;
                candidate = _query.GetQueryEngine().GetObjectFromOid(candidateOid);
            }

            var l = ((IEnumerable)candidate).Cast<object>().ToList();
            var localFromIndex = _fromIndex;
            var localEndIndex = _fromIndex + _size;

            // If not throw exception, we must implement 
            // Index Out Of Bound protection
            if (!_throwExceptionIfOutOfBound)
            {
                // Check from index
                if (localFromIndex > l.Count - 1)
                    localFromIndex = 0;

                // Check end index
                if (localEndIndex > l.Count)
                    localEndIndex = l.Count;
            }

            _sublist = new LazySimpleListOfAoi<object>(GetInstanceBuilder(), ReturnInstance());
            var count = localEndIndex - localFromIndex;
            var sublist = l.GetRange(localFromIndex, count);

            _sublist.AddAll(sublist);
        }
示例#5
0
 public override bool BeforeUpdate(IObjectRepresentation oldObjectRepresentation, object newObject, OID oid)
 {
     var so = (SimpleObject) newObject;
     // just add 1
     so.SetId(so.GetId() + 1);
     return true;
 }
示例#6
0
 public ObjectInfoHeader()
 {
     _position = -1;
     _oid = null;
     _objectVersion = 1;
     _creationDate = OdbTime.GetCurrentTimeInTicks();
 }
示例#7
0
        public override int CompareTo(OID oid)
        {
            if (oid == null || !(oid is ObjectOID))
                return -1000;

            var otherOid = oid;
            return (int) (ObjectId - otherOid.ObjectId);
        }
        protected override bool MatchObjectWithOid(OID oid, bool returnObject, bool inMemory)
        {
            CurrentOid = oid;
            var tmpCache = Session.GetTmpCache();
            try
            {
                ObjectInfoHeader objectInfoHeader;

                if (!Query.HasCriteria())
                {
                    // true, false = use cache, false = do not return object
                    // TODO Warning setting true to useCache will put all objects in the cache
                    // This is not a good idea for big queries!, But use cache=true
                    // resolves when object have not been committed yet!
                    // for big queries, user should use a LazyCache!
                    if (inMemory)
                    {
                        CurrentNnoi = ObjectReader.ReadNonNativeObjectInfoFromOid(ClassInfo, CurrentOid, true,
                                                                                  returnObject);
                        if (CurrentNnoi.IsDeletedObject())
                            return false;
                        CurrentOid = CurrentNnoi.GetOid();
                        NextOID = CurrentNnoi.GetNextObjectOID();
                    }
                    else
                    {
                        objectInfoHeader = ObjectReader.ReadObjectInfoHeaderFromOid(CurrentOid, false);
                        NextOID = objectInfoHeader.GetNextObjectOID();
                    }
                    return true;
                }

                // Gets a map with the values with the fields involved in the query
                var attributeValues = ObjectReader.ReadObjectInfoValuesFromOID(ClassInfo, CurrentOid, true,
                                                                               _involvedFields, _involvedFields, 0);

                // Then apply the query on the field values
                var objectMatches = Query.Match(attributeValues);

                if (objectMatches)
                {
                    // Then load the entire object
                    // true, false = use cache
                    CurrentNnoi = ObjectReader.ReadNonNativeObjectInfoFromOid(ClassInfo, CurrentOid, true, returnObject);
                    CurrentOid = CurrentNnoi.GetOid();
                }

                objectInfoHeader = attributeValues.GetObjectInfoHeader();
                // Stores the next position
                NextOID = objectInfoHeader.GetNextObjectOID();
                return objectMatches;
            }
            finally
            {
                tmpCache.ClearObjectInfos();
            }
        }
        public IdentityEvaluation(object theObject, string attributeName, IQuery query) 
            : base(theObject, attributeName)
        {
            if (IsNative())
                throw new ArgumentException("Constrain object cannot be native object.");

            // For non native object, we just need the oid of it
            _oid = ((IInternalQuery)query).GetQueryEngine().GetObjectId(theObject, false);
        }
示例#10
0
        public EqualsEvaluation(object theObject, string attributeName, IQuery query)
            : base(theObject, attributeName)
        {
            if (IsNative() || theObject == null)
                return;

            // For non native object, we just need the oid of it
            _oid = ((IInternalQuery)query).GetQueryEngine().GetObjectId(theObject, false);
        }
示例#11
0
        public NonNativeObjectInfo GetObjectInfoByOid(OID oid)
        {
            if (oid == null)
                throw new OdbRuntimeException(NDatabaseError.CacheNullOid);

            NonNativeObjectInfo value;
            _readingObjectInfo.TryGetValue(oid, out value);

            return value;
        }
示例#12
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            var number = Convert.ToDecimal(values[AttributeName]);
            var bd = ValuesUtil.Convert(number);
            if (bd.CompareTo(_maxValue) <= 0)
                return;

            _oidOfMaxValues = oid;
            _maxValue = bd;
        }
示例#13
0
        public ContainsEvaluation(object theObject, string attributeName, IQuery query) 
            : base(theObject, attributeName)
        {
            _query = (IInternalQuery) query;

            if (IsNative())
                return;

            // For non native object, we just need the oid of it
            _oid = _query.GetQueryEngine().GetObjectId(TheObject, false);
        }
示例#14
0
        public void StartReadingObjectInfoWithOid(OID oid, NonNativeObjectInfo objectInfo)
        {
            if (oid == null)
                throw new OdbRuntimeException(NDatabaseError.CacheNullOid);

            NonNativeObjectInfo nnoi;
            var success = _readingObjectInfo.TryGetValue(oid, out nnoi);

            if (!success)
                _readingObjectInfo[oid] = objectInfo;
        }
示例#15
0
        public override void Execute(OID oid, AttributeValuesMap values)
        {
            _value = values[AttributeName];
            if (!(_value is ICollection || IsGenericCollection(_value.GetType())))
                return;

            // For collection,we encapsulate it in an lazy load list that will create objects on demand
            var c = ((IEnumerable) _value).Cast<object>().ToList();
            var l = new LazySimpleListOfAoi<object>(GetInstanceBuilder(), ReturnInstance());
            l.AddRange(c);
            _value = l;
        }
示例#16
0
文件: Loot.cs 项目: zukeru/ageofasura
 public void OnEvent(AtavismEventData eData)
 {
     if (eData.eventType == "LOOT_UPDATE") {
         // Update
         loot = ClientAPI.ScriptObject.GetComponent<Inventory>().Loot;
         lootTarget = ClientAPI.ScriptObject.GetComponent<Inventory>().LootTarget;
         if (loot.Count > 0 && !open)
             ToggleOpen();
         else if (loot.Count == 0 && open)
             ToggleOpen();
     }
 }
示例#17
0
 public ObjectInfoHeader(long position, OID previousObjectOID, OID nextObjectOID, OID classInfoId,
                         long[] attributesIdentification, int[] attributeIds)
 {
     _position = position;
     _oid = null;
     _previousObjectOID = previousObjectOID;
     _nextObjectOID = nextObjectOID;
     _classInfoId = classInfoId;
     _attributesIdentification = attributesIdentification;
     _attributeIds = attributeIds;
     _objectVersion = 1;
     _creationDate = OdbTime.GetCurrentTimeInTicks();
 }
        public override void AfterSelect(object @object, OID oid)
        {
            var type = @object.GetType();
            var oidField = OidFields.GetOrAdd(type, SearchOidSupportableField);

            if (oidField == null)
                return;

            if (oidField.FieldType == typeof (OID))
                oidField.SetValue(@object, oid);
            else
                oidField.SetValue(@object, oid.ObjectId);
        }
示例#19
0
        /// <param name="objectWriter"> The object writer </param>
        /// <param name="objectReader"> The object reader </param>
        /// <param name="currentIdBlock">Current Id block data </param>
        public IdManager(IObjectWriter objectWriter, IObjectReader objectReader, CurrentIdBlockInfo currentIdBlock)
        {
            _objectWriter = objectWriter;
            _objectReader = objectReader;
            _currentBlockIdPosition = currentIdBlock.CurrentIdBlockPosition;
            _currentBlockIdNumber = currentIdBlock.CurrentIdBlockNumber;
            _maxId = new ObjectOID((long)currentIdBlock.CurrentIdBlockNumber * StorageEngineConstant.NbIdsPerBlock);
            _nextId = new ObjectOID(currentIdBlock.CurrentIdBlockMaxOid.ObjectId + 1);

            _lastIds = new OID[IdBufferSize];
            for (var i = 0; i < IdBufferSize; i++)
                _lastIds[i] = StorageEngineConstant.NullObjectId;

            _lastIdPositions = new long[IdBufferSize];
            _lastIdIndex = 0;
        }
		public virtual void AddObject(object o, OID oid)
		{
			if (o == null)
			{
				return;
			}
			// throw new
			// ODBRuntimeException(NeoDatisError.CACHE_NULL_OBJECT.addParameter(object));
			try
			{
				objects.Add(o, oid);
			}
			catch (System.ArgumentNullException)
			{
			}
		}
示例#21
0
        public override void SetParent(IBTreeNode node)
        {
            _parent = node;

            if (_parent != null)
            {
                if (_parent.GetId() == null)
                    Btree.GetPersister().SaveNode(_parent);

                _parentOid = (OID) _parent.GetId();
            }
            else
            {
                _parentOid = null;
            }
        }
        protected override bool MatchObjectWithOid(OID oid, bool returnObject, bool inMemory)
        {
            CurrentOid = oid;

            // Gets a map with the values with the fields involved in the query
            _values = ObjectReader.ReadObjectInfoValuesFromOID(ClassInfo, CurrentOid, true, _involvedFields,
                                                               _involvedFields, 0);

            var objectMatches = true;
            if (!_sodaQuery.IsForSingleOid())
            {
                // Then apply the query on the field values
                objectMatches = _sodaQuery.Match(_values);
            }

            var objectInfoHeader = _values.GetObjectInfoHeader();
            // Stores the next position
            NextOID = objectInfoHeader.GetNextObjectOID();
            return objectMatches;
        }
示例#23
0
        public virtual void T1estC1()
        {
            test.DeleteBase("acid1");

            simpleObject = true;

            using (var odb = test.Open("acid1"))
            {
                var size = 5;
                var oids = new OID[size];
                for (var i = 0; i < size; i++)
                    oids[i] = odb.Store(GetInstance("f" + i));
                for (var i = 0; i < size; i++)
                    odb.DeleteObjectWithId(oids[i]);
            }

            using (var odb = test.Open("acid1"))
            {
                var query = odb.Query<VO.Login.Function>();
                AssertEquals(0, query.Execute<VO.Login.Function>().Count);
            }
        }
示例#24
0
 public override void AfterSelect(object @object, OID oid)
 {
     nbCalls++;
     Console.Out.WriteLine("Select on object with oid " + oid);
 }
示例#25
0
 public void SetOid(OID oid)
 {
     _oid = oid;
 }
示例#26
0
 /// <summary>
 /// Action which will happen after delete
 /// </summary>
 /// <param name="object">Deleted object</param>
 /// <param name="oid">Oid of deleted object</param>
 public abstract void AfterDelete(object @object, OID oid);
示例#27
0
 public void SetPreviousObjectOID(OID previousObjectOID)
 {
     _previousObjectOID = previousObjectOID;
 }
示例#28
0
 internal void SetBasedOn(CIZoneInfo zoneInfo)
 {
     NbObjects = zoneInfo.NbObjects;
     First     = zoneInfo.First;
     Last      = zoneInfo.Last;
 }
示例#29
0
 public void AddOid(OID oid)
 {
     _oids.Add(oid);
 }
示例#30
0
 public void SetOid(OID oid)
 {
     _oid = oid;
 }
示例#31
0
 /// <summary>
 ///   Delete an object from the database with the id
 /// </summary>
 /// <param name="oid"> The object id to be deleted </param>
 public void DeleteObjectWithId(OID oid)
 {
     _storageEngine.DeleteObjectWithOid(oid);
 }
示例#32
0
 public void SetNextObjectOID(OID nextObjectOID)
 {
     _nextObjectOID = nextObjectOID;
 }
示例#33
0
 void _HandleQuestOfferResponse(Dictionary<string, object> props)
 {
     // update the information about the quests on offer from this npc
     questsOffered.Clear ();
     int numQuests = (int)props ["numQuests"];
     npcID = (OID)props ["npcID"];
     for (int i = 0; i < numQuests; i++) {
         QuestLogEntry logEntry = new QuestLogEntry ();
         questsOffered.Add (logEntry);
         logEntry.Title = (string)props ["title" + i];
         logEntry.QuestId = (OID)props ["questID" + i];
         logEntry.NpcId = npcID;
         logEntry.Description = (string)props ["description" + i];
         logEntry.Objective = (string)props ["objective" + i];
         //logEntry.Objectives.Clear ();
         //LinkedList<string> objectives = (LinkedList<string>)props ["objectives"];
         //foreach (string objective in objectives)
         //	logEntry.Objectives.Add (objective);
         logEntry.gradeCount = (int)props ["grades" + i];
         logEntry.gradeInfo = new List<QuestGradeEntry> ();
         //ClientAPI.Write("Quest grades: %s" % logEntry.grades)
         for (int j = 0; j < (logEntry.gradeCount + 1); j++) {
             QuestGradeEntry gradeEntry = new QuestGradeEntry ();
             List<QuestRewardEntry> gradeRewards = new List<QuestRewardEntry> ();
             int numRewards = (int)props ["rewards" + i + " " + j];
             for (int k = 0; k < numRewards; k++) {
                 //id, name, icon, count = item;
                 QuestRewardEntry entry = new QuestRewardEntry ();
                 entry.id = (int)props ["rewards" + i + "_" + j + "_" + k];
                 AtavismInventoryItem item = gameObject.GetComponent<Inventory> ().GetItemByTemplateID (entry.id);
                 if (item != null) {
                     entry.name = item.name;
                     entry.icon = item.icon;
                 }
                 entry.count = (int)props ["rewards" + i + "_" + j + "_" + k + "Count"];
                 gradeRewards.Add (entry);
                 //ClientAPI.Write("Reward: %s" % entry)
             }
             gradeEntry.rewardItems = gradeRewards;
             // Items to choose from
             List<QuestRewardEntry> gradeRewardsToChoose = new List<QuestRewardEntry> ();
             numRewards = (int)props ["rewardsToChoose" + i + " " + j];
             for (int k = 0; k < numRewards; k++) {
                 //id, name, icon, count = item;
                 QuestRewardEntry entry = new QuestRewardEntry ();
                 entry.id = (int)props ["rewardsToChoose" + i + "_" + j + "_" + k];
                 AtavismInventoryItem item = gameObject.GetComponent<Inventory> ().GetItemByTemplateID (entry.id);
                 if (item != null) {
                     entry.name = item.name;
                     entry.icon = item.icon;
                 }
                 entry.count = (int)props ["rewardsToChoose" + i + "_" + j + "_" + k + "Count"];
                 gradeRewardsToChoose.Add (entry);
                 //ClientAPI.Write("Reward to choose: %s" % entry)
             }
             gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;
             logEntry.gradeInfo.Add (gradeEntry);
         }
     }
     // dispatch a ui event to tell the rest of the system
     gameObject.GetComponent<NpcInteraction> ().NpcId = npcID;
     string[] args = new string[1];
     AtavismEventSystem.DispatchEvent ("QUEST_OFFERED_UPDATE", args);
 }
示例#34
0
 /// <summary>
 /// Action which will happen before update
 /// </summary>
 /// <param name="oldObjectRepresentation">Object representation</param>
 /// <param name="newObject">Updated object</param>
 /// <param name="oid">Oid of updated object</param>
 /// <returns>True if updated, in other case false</returns>
 public abstract bool BeforeUpdate(IObjectRepresentation oldObjectRepresentation, object newObject, OID oid);
示例#35
0
 protected override void Init()
 {
     _childrenOids = new OID[MaxNbChildren];
     _parentOid    = null;
     _parent       = null;
 }
示例#36
0
 public override void SetId(object id)
 {
     _oid = (OID)id;
 }
示例#37
0
 public void SetClassInfoId(OID classInfoId2)
 {
     _classInfoId = classInfoId2;
 }
示例#38
0
        void UpdateNameDisplay(bool showName)
        {
            if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.Equals(ClientAPI.Instance.characterSceneName))
            {
                return;
            }
            string ownerName = "";

            if (node != null)
            {
                if (node.PropertyExists("nameDisplay") && !node.CheckBooleanProperty("nameDisplay"))
                {
                    showName = false;
                }
                if (node.PropertyExists("pet") && node.CheckBooleanProperty("pet"))
                {
                    if (node.PropertyExists("petOwner"))
                    {
                        OID owner = (OID)node.GetProperty("petOwner");
                        ownerName = " (" + ClientAPI.GetObjectNode(owner.ToLong()).Name + ")";
                    }
                }
            }
            string text = "";

            if (showName && node != null)
            {
                // Display a mobs SubTile if one is set in Mob Editor plugin.
                string SubTitle = "";
                if (node.PropertyExists("subTitle"))
                {
                    SubTitle = (string)node.GetProperty("subTitle");
                }
                if (SubTitle != null && SubTitle != "")
                {
                    SubTitle = "\n<" + SubTitle + ">";
                }
                string title = "";
                if (showTitle)
                {
                    if (node.PropertyExists("title"))
                    {
                        title = (string)node.GetProperty("title");
                    }
                    if (title != null && title != "")
                    {
                        title = "\n<" + title + ">";
                    }
                }
                string species = "";
                if (node.PropertyExists("species"))
                {
                    species = (string)node.GetProperty("species");
                }
                if (species != null && species != "")
                {
                    species = "\n" + species + "";
                }
                // Display GuildName
                string guildName = "";
                if (node.PropertyExists("guildName"))
                {
                    guildName = (string)node.GetProperty("guildName");
                }
                if (guildName != null && guildName != "")
                {
                    guildName = "\n<" + guildName + ">";
                }

                text = "<#ffff00>";
                if (node.PropertyExists("reaction"))
                {
                    int targetType = (int)node.GetProperty("reaction");
                    if (node.PropertyExists("aggressive"))
                    {
                        if ((bool)node.GetProperty("aggressive"))
                        {
                            targetType = -1;
                        }
                    }
                    if (targetType < 0)
                    {
                        text = "<#ff0000>";
                    }
                    else if (targetType > 0)
                    {
                        text = "<#00ff00>";
                    }
                }

                if (nameOnSelf && node != null && node.Oid.Equals(ClientAPI.GetPlayerOid()))
                {
                    text = "<#00ff00>";
                }
                text = text + mName + ownerName + "</color>" + SubTitle + title + guildName;
                if (mobName != null && node.PropertyExists("reaction"))
                {
                    mobName.GetComponent <TextMeshPro>().text = text;
                }
            }
            else
            {
                text = "<#00ff00>" + textfield + "</color>";
            }

            if (nameOnSelf || node != null && !node.Oid.Equals(ClientAPI.GetPlayerOid()))
            {
                if (mobName != null && mobName.GetComponent <TextMeshPro>() != null)
                {
                    mobName.GetComponent <TextMeshPro>().text = text;
                }
            }
            else
            {
                if (mobName != null && mobName.GetComponent <TextMeshPro>() != null)
                {
                    mobName.GetComponent <TextMeshPro>().text = "";
                }
            }
        }
示例#39
0
        public ICVBuilder AddCodingScheme(OID codingScheme)
        {
            _value.CodingScheme = codingScheme;

            return(this);
        }
示例#40
0
 public new void AddOid(OID oid)
 {
     throw new OdbRuntimeException(NDatabaseError.InternalError.AddParameter("Add Oid not implemented "));
 }
示例#41
0
 public ObjectReference(NonNativeObjectInfo nnoi) : base(OdbType.NonNativeId)
 {
     _id   = null;
     _nnoi = nnoi;
 }
示例#42
0
 public ExternalObjectOID(OID oid, IDatabaseId databaseId) : base(oid.ObjectId)
 {
     _databaseId = databaseId;
 }
示例#43
0
 internal void Reset()
 {
     First     = null;
     Last      = null;
     NbObjects = 0;
 }
示例#44
0
 public PendingReading(int id, ClassInfo ci, OID attributeOID)
 {
     _id           = id;
     _ci           = ci;
     _attributeOID = attributeOID;
 }
 protected override void Because()
 {
     _objectClassName = SubjectUnderTest.GetObjectClassName();
     _oid             = SubjectUnderTest.GetOid();
 }
示例#46
0
文件: IdManager.cs 项目: Myvar/Eclang
        public void UpdateIdStatus(OID id, byte newStatus)
        {
            var idPosition = GetIdPosition(id);

            _objectWriter.FileSystemProcessor.UpdateStatusForIdWithPosition(idPosition, newStatus, true);
        }
示例#47
0
 /// <summary>
 /// Action which will happen before delete
 /// </summary>
 /// <param name="object">Deleted object</param>
 /// <param name="oid">Oid of deleted object</param>
 /// <returns>True if object was deleted, false if not</returns>
 public abstract bool BeforeDelete(object @object, OID oid);
示例#48
0
文件: IdManager.cs 项目: Myvar/Eclang
        public void UpdateObjectPositionForOid(OID oid, long objectPosition, bool writeInTransaction)
        {
            var idPosition = GetIdPosition(oid);

            _objectWriter.FileSystemProcessor.UpdateObjectPositionForObjectOIDWithPosition(idPosition, objectPosition, writeInTransaction);
        }
示例#49
0
 public void SetNextObjectOID(OID nextObjectOID)
 {
     _nextObjectOID = nextObjectOID;
 }
示例#50
0
文件: IdManager.cs 项目: Myvar/Eclang
 public long GetObjectPositionWithOid(OID oid, bool useCache)
 {
     return(_objectReader.GetObjectPositionFromItsOid(oid, useCache, true));
 }
示例#51
0
 public ObjectInfoHeader(long position, OID previousObjectOID, OID nextObjectOID, OID classInfoId,
                         long[] attributesIdentification, int[] attributeIds)
 {
     _position                 = position;
     _oid                      = null;
     _previousObjectOID        = previousObjectOID;
     _nextObjectOID            = nextObjectOID;
     _classInfoId              = classInfoId;
     _attributesIdentification = attributesIdentification;
     _attributeIds             = attributeIds;
     _objectVersion            = 1;
     _creationDate             = OdbTime.GetCurrentTimeInTicks();
 }
示例#52
0
        static void Main(string[] args)
        {
            try
            {
                string connectionString = "URL=corbaloc::1.2@andrewsalko:11301/AccessRoot;Login=Деловод;Password=123;AuthenticationAlgorithm=FossDoc;";

                using (ISession session = (ISession)Foss.FossDoc.ApplicationServer.Connection.Connector.Connect(connectionString))
                {
                    var obj = session.ObjectDataManager;
                    var msg = session.MessagingManager;

                    //Цей приклад аналізує "Звіт про доставку", та знаходить листа, до якого цей звіт відноситься.
                    //Якщо вам необхідно програмно відправити лист, див.приклад у проекті send.email.

                    //Для тестування прикладу:
                    //1) вам потрібні два користувача, з скриньками пошти (FossMail)
                    //2) користувач Діловод надсилає листа (з опцією звіта про доставку та прочитання) - через клієнт FossDoc
                    //3) інший користувач отримує листа, читає його
                    //4) транспорт доставляє Діловоду звіти

                    //5) цей приклад "читає" звіти з папки Вхідні Діловода, та знаходить у папці "Віправлені" лист-оригінал

                    //Папка "Вхідні" поточного користувача - там будемо шукати звіти про доставку (нові, які ми ще не прочитали)
                    OID inboxFolderID = msg.GetSpecialMessagingFolder(SpecialMessagingFolder.Inbox);

                    //Папка "Відправлені" (там будемо шукати наші листи)
                    OID sentFolderID = msg.GetSpecialMessagingFolder(SpecialMessagingFolder.SentMessages);

                    //У звіта є своя "категорія" (тип об'єкту)
                    //Звіт про доставку листа - Foss.FossDoc.ApplicationServer.Messaging.Schema.DeliveryReport.Category.OID
                    //Звіт про не доставку листа -  Foss.FossDoc.ApplicationServer.Messaging.Schema.NondeliveryReport.Category.OID
                    //Звіт про читання листа - Foss.FossDoc.ApplicationServer.Messaging.Schema.ReadReport.Category.OID

                    //Класс PropertyRestrictionHelper дозволяє побудувати "фільтр"
                    //Тег ObjectCategoryOID == DeliveryReport.Category.OID (перевірка "дорівнує" - relopEQ)
                    PropertyRestrictionHelper propCategory = new PropertyRestrictionHelper(Foss.FossDoc.ApplicationServer.ObjectDataManagment.Schema.PropertyTags.ObjectCategoryOID, Foss.FossDoc.ApplicationServer.Messaging.Schema.DeliveryReport.Category.OID, DS.relopEQ.ConstVal);
                    TableRestrictionHelper    tblCategory  = new TableRestrictionHelper(DS.resProperty.ConstVal, propCategory);

                    //також нам потрібно знайти не усі звіти, а лише ті, що ми "не читали". Властивість "Прочитано" (bool) може не бути встановлена, а також бути false.
                    OID userID = session.AccessControlManager.RoleManager.ActAsUserOID;
                    ExistRestrictionHelper ex               = new ExistRestrictionHelper(Foss.FossDoc.ApplicationServer.ObjectDataManagment.Schema.PropertyTags.ObjectReaded, userID);
                    TableRestrictionHelper tlbEx            = new TableRestrictionHelper(DS.resExist.ConstVal, ex);
                    TableRestrictionHelper tblReadNotExists = new TableRestrictionHelper(DS.resNOT.ConstVal, tlbEx);

                    //також класичне "ObjectReaded == false"
                    PropertyRestrictionHelper propReadIsFalse = new PropertyRestrictionHelper(Foss.FossDoc.ApplicationServer.ObjectDataManagment.Schema.PropertyTags.ObjectReaded, false, DS.relopEQ.ConstVal);
                    TableRestrictionHelper    tblReadFalse    = new TableRestrictionHelper(DS.resProperty.ConstVal, propReadIsFalse);

                    //блок умов:
                    TableRestrictionHelper tblOR  = new TableRestrictionHelper(DS.resOR.ConstVal, tblReadFalse, tblReadNotExists);
                    TableRestrictionHelper tblAND = new TableRestrictionHelper(DS.resAND.ConstVal, tblCategory, tblOR);

                    OID[] foundReports = obj.GetChildren(new OID[] { inboxFolderID }, new TPropertyTag[] { Foss.FossDoc.ApplicationServer.Messaging.Schema.MessagesFolder.PR_CONTAINER_CONTENTS }, tblAND);
                    if (foundReports != null && foundReports.Length == 0)
                    {
                        _Log("Нових звітів доставки не знайдено");
                        return;
                    }

                    foreach (var reportID in foundReports)
                    {
                        _Log("Знайдено новий звіт:{0}", reportID.ToStringRepresentation());

                        //У звіта отримуємо властивість PR_REPORT_TAG (бінарна властивість, зазвичай не дуже велика (наприклад 20 байт) де зберігається ідентифікатор повідомлення,
                        //до якого йде звіт. Це як унікальний ключ, який можна використати для пошуку оригінального листа (який ми надіслали)
                        //0x00310102

                        var reportProps = obj.GetProperties(reportID, Foss.FossDoc.ApplicationServer.Messaging.Schema.Report.Attributes.PR_REPORT_TAG.Tag);
                        if (reportProps != null && reportProps[0].PropertyTag.IsEquals(Foss.FossDoc.ApplicationServer.Messaging.Schema.Report.Attributes.PR_REPORT_TAG.Tag))
                        {
                            //тепер шукаємо у папці "Відправлені" наш лист
                            //З технічного боку ми шукаємо "за бінарною властивістю" яка зараз у структурі ObjectProperty (reportProps[0].Value.GetbinVal())
                            PropertyRestrictionHelper propReportTag    = new PropertyRestrictionHelper(Foss.FossDoc.ApplicationServer.Messaging.Schema.Report.Attributes.PR_REPORT_TAG.Tag, reportProps[0], DS.relopEQ.ConstVal);
                            TableRestrictionHelper    tblPropReportTag = new TableRestrictionHelper(DS.resProperty.ConstVal, propReportTag);

                            OID[] sentMessagesIDs = obj.GetChildren(new OID[] { sentFolderID }, new TPropertyTag[] { Foss.FossDoc.ApplicationServer.Messaging.Schema.MessagesFolder.PR_CONTAINER_CONTENTS }, tblPropReportTag);
                            if (sentMessagesIDs != null && sentMessagesIDs.Length > 0)
                            {
                                //у нас тут буде лише 1 лист, який ми знайшли
                                _Log("Знайдено оригінальний лист: {0}", sentMessagesIDs[0].ToStringRepresentation());

                                //На цьому приклад завершено. Ви знайшли лист, який "було доставлено" успішно. Тепер ви можете зчитати з нього будь-які дані (Тема, файли..або інше)
                            }
                            else
                            {
                                _Log("Для цього звіта листа не знайдено. Можливо його було видалено з папки Відправлені.");
                            }
                        }

                        //робимо його "прочитаним"
                        msg.SetReadFlag(new OID[] { reportID }, true);
                    }

                    _Log("Завершення роботи");
                }                //using
            }
            catch (Exception ex)
            {
                _Log(ex.ToString());
            }
        }
示例#53
0
 public void SetClassInfoId(OID classInfoId2)
 {
     _classInfoId = classInfoId2;
 }
示例#54
0
 public object GetObjectFromId(OID id)
 {
     return(_storageEngine.GetObjectFromOid(id));
 }
示例#55
0
 /// <summary>
 /// Action which will happen after update
 /// </summary>
 /// <param name="oldObjectRepresentation">Object representation</param>
 /// <param name="newObject">Updated object</param>
 /// <param name="oid">Oid of updated object</param>
 public abstract void AfterUpdate(IObjectRepresentation oldObjectRepresentation, object newObject, OID oid);
        public void ManageUpdateTriggerAfter(Type type, NonNativeObjectInfo oldNnoi, object newObject, OID oid)
        {
            if (!HasUpdateTriggersFor(type))
            {
                return;
            }

            foreach (UpdateTrigger trigger in GetListOfUpdateTriggersFor(type))
            {
                if (trigger.Odb == null)
                {
                    trigger.Odb = DependencyContainer.Resolve <IOdbForTrigger>(_storageEngine);
                }

                try
                {
                    var classInfoProvider = ((IClassInfoProvider)trigger.Odb).GetClassInfoProvider();
                    trigger.AfterUpdate(new ObjectRepresentation(oldNnoi, classInfoProvider), newObject, oid);
                }
                catch (Exception e)
                {
                    var warning =
                        NDatabaseError.AfterUpdateTriggerHasThrownException.AddParameter(trigger.GetType().FullName).
                        AddParameter(e.ToString());

                    throw new OdbRuntimeException(warning, e);
                }
            }
        }
示例#57
0
 public void SetPreviousObjectOID(OID previousObjectOID)
 {
     _previousObjectOID = previousObjectOID;
 }
示例#58
0
 public MaxValueAction(string attributeName, string alias) : base(attributeName, alias, false)
 {
     _maxValue       = new Decimal(long.MinValue);
     _oidOfMaxValues = null;
 }
示例#59
0
 void _HandleQuestProgressInfo(Dictionary<string, object> props)
 {
     /// update the information about the quests in progress from this npc
     questsInProgress.Clear ();
     int numQuests = (int)props ["numQuests"];
     npcID = (OID)props ["npcID"];
     for (int i = 0; i < numQuests; i++) {
         QuestLogEntry logEntry = new QuestLogEntry ();
         questsInProgress.Add (logEntry);
         logEntry.Title = (string)props ["title" + i];
         logEntry.QuestId = (OID)props ["questID" + i];
         logEntry.NpcId = npcID;
         //logEntry.Description = (string)props ["description" + i];
         logEntry.ProgressText = (string)props ["progress" + i];
         logEntry.Complete = (bool)props ["complete" + i];
         logEntry.Objective = (string)props ["objective" + i];
         logEntry.gradeCount = (int)props ["grades" + i];
         logEntry.gradeInfo = new List<QuestGradeEntry> ();
         //ClientAPI.Write("Quest grades: %s" % logEntry.grades)
         for (int j = 0; j < (logEntry.gradeCount + 1); j++) {
             QuestGradeEntry gradeEntry = new QuestGradeEntry ();
             List<QuestRewardEntry> gradeRewards = new List<QuestRewardEntry> ();
             int numRewards = (int)props ["rewards" + i + " " + j];
             for (int k = 0; k < numRewards; k++) {
                 //id, name, icon, count = item;
                 QuestRewardEntry entry = new QuestRewardEntry ();
                 entry.id = (int)props ["rewards" + i + "_" + j + "_" + k];
                 AtavismInventoryItem item = gameObject.GetComponent<Inventory> ().GetItemByTemplateID (entry.id);
                 entry.name = item.name;
                 entry.icon = item.icon;
                 entry.count = (int)props ["rewards" + i + "_" + j + "_" + k + "Count"];
                 gradeRewards.Add (entry);
                 //ClientAPI.Write("Reward: %s" % entry)
             }
             gradeEntry.rewardItems = gradeRewards;
             // Items to choose from
             List<QuestRewardEntry> gradeRewardsToChoose = new List<QuestRewardEntry> ();
             numRewards = (int)props ["rewardsToChoose" + i + " " + j];
             for (int k = 0; k < numRewards; k++) {
                 //id, name, icon, count = item;
                 QuestRewardEntry entry = new QuestRewardEntry ();
                 entry.id = (int)props ["rewardsToChoose" + i + "_" + j + "_" + k];
                 AtavismInventoryItem item = gameObject.GetComponent<Inventory> ().GetItemByTemplateID (entry.id);
                 entry.name = item.name;
                 entry.icon = item.icon;
                 entry.count = (int)props ["rewardsToChoose" + i + "_" + j + "_" + k + "Count"];
                 gradeRewardsToChoose.Add (entry);
                 //ClientAPI.Write("Reward to choose: %s" % entry)
             }
             gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;
             gradeEntry.completionText = (string)props ["completion" + i + "_" + j];
             logEntry.gradeInfo.Add (gradeEntry);
         }
     }
     //
     // dispatch a ui event to tell the rest of the system
     //
     gameObject.GetComponent<NpcInteraction> ().NpcId = npcID;
     string[] args = new string[1];
     AtavismEventSystem.DispatchEvent ("QUEST_PROGRESS_UPDATE", args);
 }
示例#60
0
        }        //Main

        static OID _CreateEmail(IObjectDataManager obj, Foss.FossDoc.ApplicationServer.Messaging.IManager msg, string subject)
        {
            //Щоб надіслати лист, треба спочатку його створити (на сервері). Ми будемо створювати у папці "Вихідні".
            //отримаємо папку "Вихідні" поточного користувача:
            OID folderID = msg.GetSpecialMessagingFolder(SpecialMessagingFolder.Outbox);

            //propsForMessage - тут властивості нового листа, який буде створено у папці:
            List <ObjectProperty> propsForMessage = new List <ObjectProperty>
            {
                //категорія - "Вихідний лист" (email)
                Converters.Properties.ObjectPropertyBuilder.Create(Foss.FossDoc.ApplicationServer.Messaging.Schema.OutboundMessage.CategoryOID, Foss.FossDoc.ApplicationServer.ObjectDataManagment.Schema.PropertyTags.ObjectCategoryOID),
                //тема листа
                Converters.Properties.ObjectPropertyBuilder.Create(subject, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_SUBJECT),
                //Важливість (0 - низька, 1- нормальна, 2 - висока)
                Converters.Properties.ObjectPropertyBuilder.Create(1, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_IMPORTANCE),
                //"IPM.Note" класс повідомлення
                Converters.Properties.ObjectPropertyBuilder.Create("IPM.Note", Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_MESSAGE_CLASS)
            };

            //кодування тіла
            Encoding enc = Encoding.UTF8;

            propsForMessage.Add(Converters.Properties.ObjectPropertyBuilder.Create(enc.CodePage, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_INTERNET_CPID));

            string emailBody = "Короткий опис листа";

            byte[] bodyBytes = enc.GetBytes(emailBody);
            //тіло йде у бінарному вигляді
            propsForMessage.Add(Converters.Properties.ObjectPropertyBuilder.Create(bodyBytes, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_BODY));

            //Додаємо властивості відправника:
            //Якщо у користувача кілька облікових записів пошти, беремо за замовчуванням:

            var defaultAddr = msg.GetCurrentUserDefaultAddressDescription();

            if (defaultAddr == null)
            {
                //беремо тільки адреси користувача, а не делегованих йому:
                var allAddrDescr = msg.GetCurrentUserAddressDescriptions(Foss.FossDoc.ApplicationServer.Messaging.UserAddresses.User);
                if (allAddrDescr != null)
                {
                    //за допомогою linq знайдемо лише перший обл.запис де тип адреси "FMAIL" (наш приклад для пошти FossMail)
                    //Якщо ви шукаєте звичайний email, то вкажіть SMTP.
                    defaultAddr = allAddrDescr.FirstOrDefault(item => (item.Type != null && item.Type == "FMAIL"));
                }
            }

            if (defaultAddr == null)
            {
                throw new ApplicationException("Помилка, у користувача не знайдено облікових записів для роботи з поштою");
            }

            //властивості відправника:
            propsForMessage.Add(Converters.Properties.ObjectPropertyBuilder.Create(defaultAddr.Address, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_SENDER_EMAIL_ADDRESS));
            propsForMessage.Add(Converters.Properties.ObjectPropertyBuilder.Create(defaultAddr.Type, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_SENDER_ADDRTYPE));
            propsForMessage.Add(Converters.Properties.ObjectPropertyBuilder.Create(defaultAddr.Name, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_SENDER_NAME));

            //якщо необхідно отримати звіти про доставку або прочитання листа:
            //Звіт про доставку потрібен
            propsForMessage.Add(Converters.Properties.ObjectPropertyBuilder.Create(true, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED));
            //Звіт про прочитання потрібен
            propsForMessage.Add(Converters.Properties.ObjectPropertyBuilder.Create(true, Foss.FossDoc.ApplicationServer.Messaging.Schema.Message.PR_READ_RECEIPT_REQUESTED));

            OID emailMessageID = obj.CreateObject(folderID, Foss.FossDoc.ApplicationServer.Messaging.Schema.MessagesFolder.PR_CONTAINER_CONTENTS, propsForMessage.ToArray());

            return(emailMessageID);
        }