コード例 #1
0
        /**
         * 添加音乐播放
         *
         * @param teamName
         * @param musicName
         * @return
         */

        public bool addNewMusic(String musicName)
        {
            bool flag = false;

            //MusicLength ml = new MusicLength();
            //int sumTime = ml.getAudioPlayTime("D:\\musiclist\\" + musicName+".mp3");// 获取音乐长度
            try
            {
                SyncEntity ms = new SyncEntity();
                ms.teamName      = teamName;
                ms.musicName     = musicName;
                ms.startDateTime = DateTime.Now;
                ms.pauseTime     = -1;
                ms.playState     = 1;
                db.MusicSync.Add(ms);
                db.SaveChanges();
                flag = true;

                setSyncIdFromTeamName(teamName);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write(e.ToString());
            }
            return(flag);
        }
コード例 #2
0
        private void GetEntityAttribute(XPathNavigator Nav, SyncEntity Entity)
        {
            XPathNodeIterator XpathFrom = Nav.Select(Nav.Compile("Input"));

            XpathFrom.MoveNext();
            Entity.From = XpathFrom.Current.SelectSingleNode("From").Value;

            XPathNodeIterator XpathEntity = Nav.Select("Input/Entity");

            XpathEntity.MoveNext();

            Entity.Name = XpathEntity.Current.GetAttribute("name", "");
            XpathEntity.Current.MoveToChild("Action", "");
            switch (XpathEntity.Current.Value.ToLower())
            {
            case "insert":

                Entity.OperationAction = Entity.OperationAction = Entity.OperationAction;;
                break;
            }

            XpathEntity.Current.MoveToParent();
            XpathEntity.Current.MoveToChild("PKSourceField", "");
            Entity.PKSourceID        = XpathEntity.Current.Value;
            Entity.PKSourceFieldName = XpathEntity.Current.GetAttribute("name", "");
            XpathEntity.Current.MoveToParent();
            XpathEntity.Current.MoveToChild("PKDestinationField", "");
            Entity.PKDestinationFieldName = XpathEntity.Current.GetAttribute("name", "");
            Entity.PKDestinationID        = XpathEntity.Current.Value;
        }
コード例 #3
0
        private void AddOrReplaceWebPageInLocalItem(UserConnection userConnection, LocalItem localItem,
                                                    Guid mainRecordId, string webPageValue)
        {
            IEnumerable <SyncEntity> webPageEntities = localItem.Entities["ContactCommunication"].Where(e =>
                                                                                                        e.State != SyncState.New && e.State != SyncState.Deleted &&
                                                                                                        e.Entity.GetTypedColumnValue <Guid>("CommunicationTypeId") ==
                                                                                                        Guid.Parse(CommunicationTypeConsts.WebId));

            if (webPageEntities.Any())
            {
                SyncEntity webPageSyncEntity = webPageEntities.First();
                if (string.IsNullOrEmpty(webPageValue))
                {
                    webPageSyncEntity.Action = SyncAction.Delete;
                }
                else
                {
                    webPageSyncEntity.Entity.SetColumnValue("Number", webPageValue);
                    webPageSyncEntity.Action = SyncAction.Update;
                }
            }
            else if (!string.IsNullOrEmpty(webPageValue))
            {
                AddOrReplaceWebPageInstance(userConnection, webPageValue, mainRecordId, localItem);
            }
        }
コード例 #4
0
        private string GetWebPageForRemoteItem(LocalItem localItem, UserConnection userConnection, Guid contactId)
        {
            string result = string.Empty;
            IEnumerable <SyncEntity> webPageEntities = localItem.Entities["ContactCommunication"].Where(e =>
                                                                                                        e.State != SyncState.New && e.State != SyncState.Deleted &&
                                                                                                        e.Entity.GetTypedColumnValue <Guid>("CommunicationTypeId") ==
                                                                                                        Guid.Parse(CommunicationTypeConsts.WebId));

            if (webPageEntities.Any())
            {
                SyncEntity webPageSyncEntity = webPageEntities.First();
                result = webPageSyncEntity.Entity.GetTypedColumnValue <string>("Number");
            }
            else
            {
                Guid id = TryFindWebPageDetailInLocalStore(userConnection, contactId);
                if (id == Guid.Empty)
                {
                    return(result);
                }
                EntitySchema schema   = userConnection.EntitySchemaManager.GetInstanceByName("ContactCommunication");
                var          instance = (ContactCommunication)schema.CreateEntity(userConnection);
                if (instance.FetchFromDB(id, false))
                {
                    localItem.AddOrReplace(schema.Name, SyncEntity.CreateNew(instance));
                    result = instance.Number;
                }
            }
            return(result);
        }
コード例 #5
0
 public void AddTask(SyncEntity Task)
 {
     lock (objLock)
     {
         taskQueue.Enqueue(Task);
     }
 }
コード例 #6
0
        private void RunTask()
        {
            while (true)
            {
                if (this.CanTrigger())
                {
                    isRunning = true;
                    Guid BatchGuid;
                    BatchGuid = Guid.NewGuid();
                    List <SyncEntity> Tasks     = new List <SyncEntity>();
                    SyncEntity        FirstTask = null;
                    lock (objLock)
                    {
                        FirstTask         = taskQueue.Dequeue();
                        FirstTask.BatchID = BatchGuid;
                        Tasks.Add(FirstTask);

                        while (taskQueue.Count > 0 && Tasks.Count <= batchSize && taskQueue.Peek().CompareTo(FirstTask) == 1)
                        {
                            SyncEntity QueueTask = taskQueue.Dequeue();
                            QueueTask.BatchID = BatchGuid;
                            Tasks.Add(QueueTask);
                        }
                    }
                    myProcessor.ProcessData(Tasks);
                    lastTriggeredOn = DateTime.Now;
                    Thread.Sleep(200);
                    isRunning = false;
                }
                Thread.Sleep(200);
            }
        }
コード例 #7
0
        private void CreateScriptHeader()
        {
            int i = 0;

            DMEEditor.ETL.script = new SyncDataSource();
            DMEEditor.ETL.script.scriptSource = Srcds.DatasourceName;
            List <EntityStructure> ls = new List <EntityStructure>();

            Srcds.GetEntitesList();
            foreach (string item in Srcds.EntitiesNames)
            {
                ls.Add(Srcds.GetEntityStructure(item, true));
            }
            var progress = new Progress <PassedArgs>(percent =>
            {
                update();
            });

            // DMEEditor.ETL.GetCreateEntityScript(Srcds, ls,progress,token);
            foreach (var item in ls)
            {
                SyncEntity upscript = new SyncEntity();
                upscript.sourcedatasourcename       = item.DataSourceID;
                upscript.sourceentityname           = item.EntityName;
                upscript.sourceDatasourceEntityName = item.DatasourceEntityName;

                upscript.destinationDatasourceEntityName = item.EntityName;
                upscript.destinationentityname           = item.EntityName;
                upscript.destinationdatasourcename       = Srcds.DatasourceName;
                upscript.scriptType = DDLScriptType.CopyData;
                DMEEditor.ETL.script.Entities.Add(upscript);
                i += 1;
            }
        }
コード例 #8
0
ファイル: Entity.cs プロジェクト: aowchina/HolyTech
 // Update is called once per frame
 void Update()
 {
     if (SyncEntity != null)
     {
         SyncEntity.OnUpdate();                        //状态更新
         EntityAttribute.AttribbuteUpdate(SyncEntity); //战斗属性更新
     }
 }
コード例 #9
0
 // Update is called once per frame
 void Update()
 {
     if (SyncEntity != null)
     {
         SyncEntity.OnUpdate();//Iselfplayer和Iplayer的onUpdate都会被执行??
         EntityAttribute.AttribbuteUpdate(SyncEntity);
     }
 }
コード例 #10
0
        public void Valid()
        {
            var model = new SyncEntity();

            var result = model.Validate();

            Assert.False(result.Any());
        }
コード例 #11
0
ファイル: Entity.cs プロジェクト: mengtest/MMORPG-4
 // Update is called once per frame
 void Update()
 {
     if (SyncEntity != null)
     {
         SyncEntity.OnUpdate();
         EntityAttribute.AttribbuteUpdate(SyncEntity);
     }
 }
コード例 #12
0
ファイル: Entity.cs プロジェクト: zhangtaibo123/thanos-client
 // Update is called once per frame
 void Update()
 {
     if (SyncEntity != null)
     {
         SyncEntity.OnUpdate();          //状态更新
         mEntityData.Update(SyncEntity); //战斗属性更新
     }
 }
コード例 #13
0
        static void Main(string[] args)
        {
            ProcessManager.ProcessManager.GetCurrentInstance();
            string     datas    = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Input><From>Source CRM</From><Entity name=\"opportunity\"><Action>Update</Action><PKSourceField name=\"opportunityid\">4a7b0cf9-dc0b-e111-aac0-001cc4a9ce7c</PKSourceField><PKDestinationField name=\"new_sfdcsalesopportunityid\">0065000000IsUqAAAV</PKDestinationField><Data><Field name=\"new_clientquotenumber\">QuoteNo2</Field><Field name=\"IsTransForm\">false</Field><Field name=\"OwnerID\"></Field><Field name=\"StageName\">Contacted</Field></Data></Entity></Input>";
            XMLParsing ParseXml = new XMLParsing(datas);
            SyncEntity Entity   = ParseXml.Entity;

            DoTask(ParseXml.Entity);
        }
コード例 #14
0
        public void CreateTombstone_PrimaryKeyShouldHaveKeySchemToNone()
        {
            var entities            = new EntityInfoCollection();
            var factory             = new Mock <IFieldPropertyFactory>();
            var entityInfo          = EntityInfo.Create(factory.Object, entities, typeof(EntitySync));
            var entitySync          = SyncEntity.Create(entityInfo);
            var tombstoneEntityInfo = entitySync.CreateEntityTombstone();

            Assert.AreEqual(KeyScheme.None, tombstoneEntityInfo.PrimaryKey.KeyScheme);
        }
コード例 #15
0
        public void FillQuery()
        {
            var paramTest = "@SyncId|@TableName";
            var model     = new SyncEntity()
            {
                SyncId    = "Test",
                TableName = "Test"
            }.FillQuery(paramTest);

            Assert.Equal("'Test'|'TEST'", model);
        }
コード例 #16
0
        public void ValidSyncAttribute()
        {
            var entityInfo     = Desktop.DataStore.Entities.ElementAt(1);
            var syncableEntity = SyncEntity.Create(entityInfo);

            Assert.AreEqual("entity", syncableEntity.GetNameInStore());
            Assert.AreEqual("created_at", syncableEntity.CreationTrackingColumn);
            Assert.AreEqual("updated_at", syncableEntity.UpdateTrackingColumn);
            Assert.AreEqual("last_sync_at", syncableEntity.LastSyncTrackingColumn);
            Assert.AreEqual("deleted_at", syncableEntity.EntityTombstoneInfo.DeletionTrackingColumn);
            Assert.AreEqual("entity_tombstone", syncableEntity.EntityTombstoneInfo.GetNameInStore());
        }
コード例 #17
0
 public IErrorsInfo RunScript(SyncEntity dDLScripts)
 {
     if (ds.ConnectionStatus == ConnectionState.Open)
     {
         ds = DMEEditor.GetDataSource(DatasourceName);
         return(ds.RunScript(dDLScripts));
     }
     else
     {
         DMEEditor.AddLogMessage("Error", "$Could not Find DataSource {DatasourceName}", DateTime.Now, 0, DatasourceName, Errors.Failed);
         return(null);
     }
 }
コード例 #18
0
        public XMLParsing(string Xml)
        {
            XmlDocument Doc = new XmlDocument();

            Doc.LoadXml(Xml);
            Entity = new SyncEntity();
            XPathNavigator Nav = Doc.CreateNavigator();

            GetEntityAttribute(Nav, Entity);
            GetFields(Nav, Entity);
            GetChild(Nav, Entity);
            //return Entity;
        }
コード例 #19
0
        public void GetChild(XPathNavigator Nav, SyncEntity Entity)
        {
            XPathExpression Expr;

            Expr = Nav.Compile("Input/Entity/Childs/Child");
            XPathNodeIterator Fiterator = Nav.Select(Expr);

            while (Fiterator.MoveNext())
            {
                SyncEntity ScnChild = new SyncEntity();
                GetChildEntityAttribute(Fiterator.Current, ScnChild);
                Entity.ChildEntity.Add(ScnChild);
            }
        }
コード例 #20
0
ファイル: MergeResolution.cs プロジェクト: sGeeK44/OpenNet
        public static MergeResolution Create(IEntityInfo entityInfo, OperationTypes operationType, IEntity entity)
        {
            var entitySync = SyncEntity.Create(entityInfo);

            if (entitySync.Direction == SyncDirection.UploadOnly)
            {
                return(null);
            }

            return(new MergeResolution
            {
                OperationType = operationType,
                Entity = EntityChange.Create(entityInfo, entity)
            });
        }
コード例 #21
0
ファイル: SyncDatastore.cs プロジェクト: sGeeK44/OpenNet
        protected override IEntityInfo AddTypeSafe(Type entityType)
        {
            var entity = base.AddTypeSafe(entityType);

            if (entity == null)
            {
                return(null);
            }

            var syncEntity = SyncEntity.Create(entity);

            if (syncEntity != null)
            {
                AddTypeSafe(syncEntity.EntityTombstoneType);
            }
            return(entity);
        }
コード例 #22
0
ファイル: SyncManager.cs プロジェクト: myloran/BBSNetwork
 SyncEntity GetEntity(Entity entity, int actorId, int networkId)
 {
     if (!Entities.TryGetValue(entity, out SyncEntity syncEntity))
     {
         syncEntity = new SyncEntity()
         {
             Id = new EntityId()
             {
                 ActorId   = actorId,
                 NetworkId = networkId,
             }
         };
         SyncEntities.Entities.Add(syncEntity);
         Entities[entity] = syncEntity;
     }
     return(syncEntity);
 }
コード例 #23
0
        /// <summary>Returns activity instance for exchange appointment, in case of changed remote id.</summary>
        /// <param name="context">Synchronization context.</param>
        /// <param name="exchangeItem">Exchange item in external storage.</param>
        /// <param name="storedId">Id of bpm activity, stored in external property of exchange item.</param>
        /// <param name="localItem">Local storage item.</param>
        /// <returns>Activity instance.</returns>
        protected Entity GetSyncedActivityWithChangedRemoteId(SyncContext context, Exchange.Item exchangeItem, Guid storedId, LocalItem localItem)
        {
            Entity instance;
            var    syncValueName = localItem.Schema.SyncValueName;
            var    schema        = context.UserConnection.EntitySchemaManager.GetInstanceByName("Activity");

            instance = schema.CreateEntity(context.UserConnection);
            if (!localItem.Entities["Activity"].Any(se => se.EntityId.Equals(storedId)) &&
                instance.FetchFromDB(storedId))
            {
                SyncEntity syncEntity         = SyncEntity.CreateNew(instance);
                var        isCurrentUserOwner = context.UserConnection.CurrentUser.ContactId == instance.GetTypedColumnValue <Guid>("OwnerId");
                syncEntity.Action = isCurrentUserOwner ? SyncAction.Update : SyncAction.None;
                context.LogInfo(SyncAction.None, SyncDirection.DownloadAndUpload,
                                "GetSyncedActivityWithChangedRemoteId set action {0} for {1}",
                                syncEntity.Action, GetDisplayName());
                localItem.AddOrReplace("Activity", syncEntity);
                if (syncValueName == ExchangeConsts.ExchangeAppointmentClassName)
                {
                    context.LogInfo(SyncAction.None, SyncDirection.DownloadAndUpload,
                                    "GetSyncedActivityWithChangedRemoteId ExchangeAppointmentClassName action update for {0}",
                                    GetDisplayName());
                    Action            = SyncAction.Update;
                    syncEntity.Action = SyncAction.Update;
                }
                else
                {
                    Action = isCurrentUserOwner ? SyncAction.Update : SyncAction.None;
                    context.LogInfo(SyncAction.None, SyncDirection.DownloadAndUpload,
                                    "GetSyncedActivityWithChangedRemoteId action {0} for {1}", Action, GetDisplayName());
                    if (isCurrentUserOwner)
                    {
                        ActualizeOldMetadata(context, storedId, Id);
                    }
                }
            }
            else
            {
                context.LogInfo(SyncAction.None, SyncDirection.DownloadAndUpload,
                                "GetSyncedActivityWithChangedRemoteId not found entity action {0} for {1}",
                                Action, GetDisplayName());
                instance = GetEntityInstance <Entity>(context, localItem, "Activity");
            }
            return(instance);
        }
コード例 #24
0
        /**
         * 删除所有这个舞队信息
         *
         * @param teamName
         * @return
         */
        public bool deleteTeam()
        {
            bool flag = false;

            try
            {
                SyncEntity ms = new SyncEntity();
                ms.teamName = teamName;
                db.MusicSync.Attach(ms);
                db.MusicSync.Remove(ms);
                db.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
            }
            return(flag);
        }
コード例 #25
0
        private void GetChildFields(XPathNavigator Nav, SyncEntity Entity)
        {
            Nav.MoveToParent();
            XPathExpression XPathExpr;

            XPathExpr = Nav.Compile("Data/Field");
            XPathNodeIterator Fiterator = Nav.Select(XPathExpr);

            while (Fiterator.MoveNext())
            {
                XPathNavigator CurrentField = Fiterator.Current.Clone();
                Field          TempField    = new Field();
                TempField.Value = CurrentField.Value;
                TempField.Name  = CurrentField.GetAttribute("name", "");
                //tempField.IsChildline = Convert.ToBoolean(currentField.GetAttribute("IsChildLine", ""));
                Entity.Fields.Add(TempField);
            }
        }
コード例 #26
0
        public static void CleanEntities(IDataStore dataStore, DateTime now)
        {
            foreach (var entity in dataStore.Entities.Reverse())
            {
                var syncableEntity = SyncEntity.Create(entity);
                if (syncableEntity == null || !syncableEntity.ShouldBeCleannedOnClient())
                {
                    continue;
                }

                var createdAt     = dataStore.ToColumnValue(entity, syncableEntity.CreationTrackingColumn);
                var retentionDate = now.AddDays(-1 * syncableEntity.ClientRetentionTime);
                var createdBeforeRetentionLimit = dataStore.Condition(createdAt, retentionDate, FilterOperator.LessThanOrEqual);
                var legacyRow = dataStore.Condition(createdAt, null, FilterOperator.Equals);
                dataStore.Select(entity.EntityType)
                .Where(createdBeforeRetentionLimit.Or(legacyRow))
                .Delete();
            }
        }
コード例 #27
0
        protected static T GetEntityInstance <T>(SyncContext context, LocalItem localItem, string schemaName)
            where T : Terrasoft.Core.Entities.Entity
        {
            T instance;

            if (localItem.Entities[schemaName].Count == 0)
            {
                var schema = context.UserConnection.EntitySchemaManager.GetInstanceByName(schemaName);
                instance = (T)schema.CreateEntity(context.UserConnection);
                instance.SetDefColumnValues();
                localItem.AddOrReplace(schemaName, SyncEntity.CreateNew(instance));
            }
            else
            {
                var instanceSync = localItem.Entities[schemaName][0];
                instanceSync.Action = SyncAction.Update;
                instance            = (T)instanceSync.Entity;
            }
            return(instance);
        }
コード例 #28
0
ファイル: Conflict.cs プロジェクト: sGeeK44/OpenNet
        public IdentityChange Resolve(IDataStore localDataStore)
        {
            if (_alreadyMerge)
            {
                return(null);
            }

            var syncableEntity = SyncEntity.Create(_entityInfo);
            var solver         = syncableEntity.GetSolver() as IEntityConflictSolver ?? new DefaultEntitySolver <ISyncable>();

            solver.SyncSessionInfo = _syncSessionInfo;

            var serializer   = _entityInfo.GetSerializer();
            var localEntity  = serializer.Deserialize(_local);
            var remoteEntity = serializer.Deserialize(_remote);

            RemoteMergeResolution = solver.Merge(localDataStore, localEntity, remoteEntity);
            _alreadyMerge         = true;
            return(RemoteMergeResolution.GetIdentityChange());
        }
コード例 #29
0
        /// <summary>
        /// Creates o replaces <c>Web</c> <see cref="ContactCommunication"/> instance, using <paramref name="value"/>,
        /// in <paramref name="localItem"/> sync entities collection.
        /// </summary>
        /// <param name="userConnection">User connection instance.</param>
        /// <param name="contactId"><see cref="Contact"/> unique id.</param>
        /// <param name="value">ContactCommunication value.</param>
        /// <param name="localItem">Local storage synchronization element.</param>
        private static void AddOrReplaceWebPageInstance(UserConnection userConnection, string value,
                                                        Guid contactId, LocalItem localItem)
        {
            EntitySchema schema   = userConnection.EntitySchemaManager.GetInstanceByName("ContactCommunication");
            var          instance = (ContactCommunication)schema.CreateEntity(userConnection);
            Guid         id       = TryFindWebPageDetailInLocalStore(userConnection, contactId, value);

            if (id == Guid.Empty)
            {
                instance.SetDefColumnValues();
            }
            else if (!instance.FetchFromDB(id, false))
            {
                instance.SetDefColumnValues();
            }
            instance.SetColumnValue("Number", value);
            instance.SetColumnValue("CommunicationTypeId", CommunicationTypeConsts.WebId);
            instance.SetColumnValue("ContactId", contactId);
            localItem.AddOrReplace(schema.Name, SyncEntity.CreateNew(instance));
        }
コード例 #30
0
 public override void UpdateFrom(SyncEntity other)
 {
     base.UpdateFrom(((Patient)other));
     Partner          = ((Patient)other).Partner;
     Estimateddob     = ((Patient)other).Estimateddob;
     Idtype           = ((Patient)other).Idtype;
     Enrollmenttime   = ((Patient)other).Enrollmenttime;
     Enrollmentdate   = ((Patient)other).Enrollmentdate;
     Kinrelationother = ((Patient)other).Kinrelationother;
     Kinrelation      = ((Patient)other).Kinrelation;
     Kinphone         = ((Patient)other).Kinphone;
     Kin          = ((Patient)other).Kin;
     Contactphone = ((Patient)other).Contactphone;
     Clientcode   = ((Patient)other).Clientcode;
     Dob          = ((Patient)other).Dob;
     Sex          = ((Patient)other).Sex;
     Lastname     = ((Patient)other).Lastname;
     Middlename   = ((Patient)other).Middlename;
     Firstname    = ((Patient)other).Firstname;
     PartnerUuid  = ((Patient)other).PartnerUuid;
 }