コード例 #1
0
        /// <summary>
        /// 增减外键引用计数值
        /// </summary>
        internal async ValueTask AddEntityRefAsync(EntityRefModel entityRef,
                                                   ApplicationModel fromApp, Entity fromEntity, int diff)
        {
            Debug.Assert(diff != 0);
            Debug.Assert(fromEntity.Id.RaftGroupId != 0);

            var targetId = fromEntity.GetEntityId(entityRef.FKMemberIds[0]);

            if (targetId == null || targetId.IsEmpty)
            {
                return;
            }
            ulong targetModelId = entityRef.IsAggregationRef ? fromEntity.GetUInt64(entityRef.TypeMemberId) : entityRef.RefModelIds[0];
            var   targetModel   = await RuntimeContext.Current.GetModelAsync <EntityModel>(targetModelId);

            var targetAppId = IdUtil.GetAppIdFromModelId(targetModelId);
            var targetApp   = await RuntimeContext.Current.GetApplicationModelAsync(targetAppId);

            //注意编码
            uint fromTableId = KeyUtil.EncodeTableId(fromApp.StoreId, entityRef.Owner.TableId);

            var item = new RefFromItem()
            {
                TargetEntityId  = targetId,
                FromTableId     = fromTableId,
                FromRaftGroupId = fromEntity.Id.RaftGroupId
            };

            lock (this)
            {
                if (refs == null)
                {
                    item.Diff = diff;
                    refs      = new List <RefFromItem> {
                        item
                    };
                }
                else
                {
                    for (int i = 0; i < refs.Count; i++)
                    {
                        if (refs[i].TargetEntityId == targetId && refs[i].FromRaftGroupId == fromEntity.Id.RaftGroupId)
                        {
                            item.Diff = refs[i].Diff + diff;
                            refs[i]   = item;
                            return;
                        }
                    }

                    //未找到
                    item.Diff = diff;
                    refs.Add(item);
                }
            }
        }
コード例 #2
0
        protected InterfaceDescription(
            string remotedInterfaceKindName,
            Type remotedInterfaceType,
            MethodReturnCheck methodReturnCheck = MethodReturnCheck.EnsureReturnsTask)
        {
            EnsureNotGeneric(remotedInterfaceKindName, remotedInterfaceType);

            this.remotedInterfaceType = remotedInterfaceType;
            this.interfaceId          = IdUtil.ComputeId(remotedInterfaceType);
            this.methods = GetMethodDescriptions(remotedInterfaceKindName, remotedInterfaceType, methodReturnCheck);
        }
コード例 #3
0
        /// <summary>
        /// 根据模型类型及标识号获取相应的节点
        /// </summary>
        internal ModelNode FindModelNode(ModelType modelType, ulong modelId)
        {
            var appId         = IdUtil.GetAppIdFromModelId(modelId);
            var modelRootNode = FindModelRootNode(appId, modelType);

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

            return(modelRootNode.FindModelNode(modelId));
        }
コード例 #4
0
        private int GetAndEnsureEventId(Type eventInterfaceType)
        {
            if (this.eventIdToDispatchersMap != null)
            {
                var eventId = IdUtil.ComputeId(eventInterfaceType);
                if (this.eventIdToDispatchersMap.ContainsKey(eventId))
                {
                    return(eventId);
                }
            }

            throw new ArgumentException();
        }
コード例 #5
0
        /// <summary>
        /// Call this overload to display location suggestions as POST links. The LocationChosen event handler
        /// is called when a location is chosen.
        /// </summary>
        public void DisplaySuggestions(IList <NamedLocation> suggestions)
        {
            if (LocationChosen == null)
            {
                throw new ApplicationException("You must attach an event handler to the LocationChosen event before"
                                               + " calling this overload of DisplaySuggestions().");
            }

            SetSuggestions(suggestions);

            // Store in a hidden field so they can be reloaded on postback.
            hidSuggestionIds.Value = IdUtil.GetIdList <NamedLocation, int>(",", suggestions);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: thunklife/RavenGallery
        public static void Main(string[] args)
        {
            Flickr flickr = new Flickr();

            var documentStore = new EmbeddableDocumentStore
            {
                Configuration = new RavenConfiguration
                {
                    DataDirectory = RAVENPATH,
                }
            };

            documentStore.Initialize();

            using (var session = documentStore.OpenSession())
            {
                PerformInitialSetup(session);

                session.Advanced.DatabaseCommands.DeleteByIndex("Raven/DocumentsByEntityName",
                                                                new Raven.Database.Data.IndexQuery()
                {
                    Query = "Tag:Images"
                }, true);

                FlickrImporter importer = new FlickrImporter(session,
                                                             new ImageUploaderService(
                                                                 new RavenFileStorageService(documentStore),
                                                                 new ImageRepository(session)),
                                                             new UserRepository(session));

                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "dog");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "swan");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "computer");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "megaman");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "rainbow");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "sunset");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "raven");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "coffee");
                importer.ImportSearchResults(flickr, IdUtil.CreateUserId("robashton"), "jumper");
            }

            while (documentStore.DocumentDatabase.Statistics.StaleIndexes.Length > 0)
            {
                Thread.Sleep(1000);
                Console.WriteLine("Waiting for indexing to complete");
            }
        }
コード例 #7
0
ファイル: ServiceHelper.cs プロジェクト: Gentofte/STSOrgSync
        internal static void OrgUnitStartUsingItSystem(string orgUnitUuid, string itSystemUuid, DateTime timestamp)
        {
            List <string> orgFunctions = organisationFunktionStub.SoegAndGetUuids(UUIDConstants.ORGFUN_IT_USAGE, null, null, itSystemUuid);

            // ensure that there is an OrgFunction
            if (orgFunctions == null || orgFunctions.Count == 0)
            {
                List <string> itSystem = new List <string>()
                {
                    itSystemUuid
                };

                string uuid = IdUtil.GenerateUuid();
                organisationFunktionStub.Importer(new OrgFunctionData()
                {
                    Uuid             = uuid,
                    ShortKey         = IdUtil.GenerateShortKey(),
                    Name             = "IT-Usage",
                    FunctionTypeUuid = UUIDConstants.ORGFUN_IT_USAGE,
                    OrgUnits         = null,
                    Users            = null,
                    ItSystems        = itSystem,
                    Addresses        = null,
                    Timestamp        = timestamp
                });

                orgFunctions = new List <string>()
                {
                    uuid
                };
            }

            log.Debug("Starting relationship between itSystem " + itSystemUuid + " and orgUnit " + orgUnitUuid);

            OrgFunctionData orgFunction = new OrgFunctionData()
            {
                Timestamp = timestamp,
                Uuid      = orgFunctions[0], // there will ever only be one OrgFunction, but even if there are more, we just pick the first one (any will do)
                OrgUnits  = new List <string>()
                {
                    orgUnitUuid
                }
            };

            organisationFunktionStub.Ret(orgFunction, UpdateIndicator.NONE, UpdateIndicator.ADD, UpdateIndicator.NONE);
        }
コード例 #8
0
ファイル: FindUsages.cs プロジェクト: enjoycode/appbox.clr
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var refType       = (ModelReferenceType)args.GetInt32();
            var modelIDString = args.GetString();
            var memberName    = args.GetString();
            var modelId       = ulong.Parse(modelIDString);

            ModelType modelType = IdUtil.GetModelTypeFromModelId(modelId);
            var       modelNode = hub.DesignTree.FindModelNode(modelType, modelId);

            if (modelNode == null)
            {
                throw new Exception("Can't find model");
            }

            return(await RefactoringService.FindUsagesAsync(hub, refType,
                                                            modelNode.AppNode.Model.Name, modelNode.Model.Name, memberName));
        }
コード例 #9
0
ファイル: ServiceHelper.cs プロジェクト: Gentofte/STSOrgSync
        internal static string CreateContactPlace(OrgUnitRegistration orgUnit, DTO.V1_1.ContactPlace contactPlace)
        {
            string uuid = IdUtil.GenerateUuid();

            organisationFunktionStub.Importer(new OrgFunctionData()
            {
                Uuid             = uuid,
                Name             = "Henvendelsessted",
                FunctionTypeUuid = UUIDConstants.ORGFUN_CONTACT_UNIT,
                OrgUnits         = new List <string>()
                {
                    contactPlace.OrgUnitUuid
                },
                Tasks     = contactPlace.Tasks,
                Timestamp = orgUnit.Timestamp
            });

            return(uuid);
        }
コード例 #10
0
        private MethodDescription(
            MethodInfo methodInfo,
            MethodArgumentDescription[] arguments,
            bool hasCancellationToken,
            bool useCRCIdGeneration)
        {
            this.MethodInfo         = methodInfo;
            this.useCRCIdGeneration = useCRCIdGeneration;
            if (this.useCRCIdGeneration)
            {
                this.Id = IdUtil.ComputeIdWithCRC(methodInfo);
            }
            else
            {
                this.Id = IdUtil.ComputeId(methodInfo);
            }

            this.Arguments            = arguments;
            this.HasCancellationToken = hasCancellationToken;
        }
コード例 #11
0
        private MethodDescription(
            MethodInfo methodInfo,
            MethodArgumentDescription[] arguments,
            bool hasCancellationToken, bool useCRCIdGeneration)
        {
            this.methodInfo         = methodInfo;
            this.useCRCIdGeneration = useCRCIdGeneration;
            if (this.useCRCIdGeneration)
            {
                this.methodId = IdUtil.ComputeIdWithCRC(methodInfo);
                //This is needed for backward compatibility support to V1 Stack like ActorEventproxy where Code-gen happens only once.
                this.methodIdV1 = IdUtil.ComputeId(methodInfo);
            }
            else
            {
                this.methodId = IdUtil.ComputeId(methodInfo);
            }

            this.arguments            = arguments;
            this.hasCancellationToken = hasCancellationToken;
        }
        public string InsertHisErpCorpMapSQL(DataRow inRow, string inUserId, string MapOrgId)
        {
            StringBuilder sb       = new StringBuilder();
            string        GlobalID = IdUtil.GetGlobalId();

            sb.Append("insert into gpo_corp_map( ");
            sb.Append("ID,MAP_ORGTYPE,MAP_ORGID,ORG_ID,CODE,FULL_NAME,EASY_NAME,");
            sb.Append("MODIFY_USERID,MODIFY_DATE,SYNC_STATE,Process_Flag) values ");
            sb.Append("('").Append(GlobalID).Append("',");
            sb.Append(" '2',");
            sb.Append("'").Append(MapOrgId).Append("',");
            sb.Append("'").Append(inRow["org_id"].ToString()).Append("',");
            sb.Append("'").Append(inRow["sender_code"].ToString()).Append("',");
            sb.Append("'").Append(inRow["sender_name"].ToString()).Append("',");
            sb.Append("'").Append(inRow["sender_name"].ToString()).Append("',");
            sb.Append("'").Append(inUserId).Append("',");
            sb.Append("'").Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Append("',");
            sb.Append("'0',");
            sb.Append("'").Append(inRow["process_flag"].ToString().Equals("true") ? "1" : "0").Append("')");

            return(sb.ToString());
        }
コード例 #13
0
        protected InterfaceDescription(
            string remotedInterfaceKindName,
            Type remotedInterfaceType,
            bool useCRCIdGeneration,
            MethodReturnCheck methodReturnCheck = MethodReturnCheck.EnsureReturnsTask)
        {
            EnsureNotGeneric(remotedInterfaceKindName, remotedInterfaceType);

            this.remotedInterfaceType = remotedInterfaceType;
            this.useCRCIdGeneration   = useCRCIdGeneration;
            if (this.useCRCIdGeneration)
            {
                this.interfaceId = IdUtil.ComputeIdWithCRC(remotedInterfaceType);
                //This is needed for backward compatibility support to V1 Stack like ActorEventproxy
                this.interfaceIdV1 = IdUtil.ComputeId(remotedInterfaceType);
            }
            else
            {
                this.interfaceId = IdUtil.ComputeId(remotedInterfaceType);
            }

            this.methods = GetMethodDescriptions(remotedInterfaceKindName, remotedInterfaceType, methodReturnCheck, useCRCIdGeneration);
        }
コード例 #14
0
        public static void AddMethodsForProxyOrService(IEnumerable <Type> interfaces, Type baseInterfaceType)
        {
            foreach (Type interfaceType in interfaces)
            {
                if (!baseInterfaceType.IsAssignableFrom(interfaceType) || interfaceType == baseInterfaceType)
                {
                    continue;
                }

                int interfaceIdv1 = IdUtil.ComputeId(interfaceType);
                int interfaceIdv2 = IdUtil.ComputeIdWithCRC(interfaceType);

                // Add if it's not there, don't add if it's there already
                if (!idToMethodNameMap.TryGetValue(interfaceIdv1, out InterfaceEntry ifc))
                {
                    // Since idToMethodNameMap can be accessed by multiple threads, it is important to make sure
                    // the inner dictionary has everything added, before this is added to idToMethodNameMap. The
                    // inner dictionary will never be thread safe and it doesn't need to be, as long as it always
                    // is effectively "read-only". If the order is reverse, you risk having another thread trying
                    // to fetch a method from it prematurely.
                    ifc = new InterfaceEntry(interfaceType);
                    foreach (MethodInfo method in interfaceType.GetMethods())
                    {
                        int methodIdv1 = IdUtil.ComputeId(method);
                        int methodIdv2 = IdUtil.ComputeIdWithCRC(method);

                        ifc.Methods[methodIdv1] = new MethodEntry(method);
                        ifc.Methods[methodIdv2] = new MethodEntry(method);
                    }

                    // If multiple threads are trying to set this entry, the last one wins, and this is ok to have
                    // since this method map should always look the same once it's constructed.
                    idToMethodNameMap[interfaceIdv1] = ifc;
                    idToMethodNameMap[interfaceIdv2] = ifc;
                }
            }
        }
コード例 #15
0
ファイル: ServiceHelper.cs プロジェクト: Gentofte/STSOrgSync
        internal static string EnsurePayoutUnitFunctionExists(string payoutUnitUuid, DateTime timestamp)
        {
            // if there is an existing function, just return the uuid
            List <string> existingFunctions = organisationFunktionStub.SoegAndGetUuids(UUIDConstants.ORGFUN_PAYOUT_UNIT, null, payoutUnitUuid, null);

            if (existingFunctions != null && existingFunctions.Count > 0)
            {
                return(existingFunctions[0]);
            }

            // otherwise create a new function
            OrgFunctionData orgFunction = new OrgFunctionData();

            orgFunction.FunctionTypeUuid = UUIDConstants.ORGFUN_PAYOUT_UNIT;
            orgFunction.Name             = "PayoutUnitFunction";
            orgFunction.OrgUnits.Add(payoutUnitUuid);
            orgFunction.ShortKey  = IdUtil.GenerateShortKey();
            orgFunction.Timestamp = timestamp;
            orgFunction.Uuid      = IdUtil.GenerateUuid();

            organisationFunktionStub.Importer(orgFunction);

            return(orgFunction.Uuid);
        }
        /// <summary>
        /// 增加对照医院SQL
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string InsertHisErpCorpMapSQL(Gpo_Hosptail_MapModel input)
        {
            StringBuilder sb       = new StringBuilder();
            string        GlobalID = IdUtil.GetGlobalId();

            sb.Append("insert into gpo_corp_map( \r\n\t\t\t\t\t");
            sb.Append("ID,MAP_ORGTYPE,MAP_ORGID,ORG_ID,CODE,FULL_NAME,EASY_NAME,\r\n");
            sb.Append("MODIFY_USERID,MODIFY_DATE,SYNC_STATE,Process_Flag,ISMAP) values \r\n");
            sb.Append("('").Append(GlobalID).Append("',");
            sb.Append(" '2',");
            sb.Append("'").Append(input.MapOrgId).Append("',");
            sb.Append("'").Append(input.CorpId).Append("',");
            sb.Append("'").Append(input.CorpCode).Append("',");
            sb.Append("'").Append(input.CorpName).Append("',");
            sb.Append("'").Append(input.CorpAbbr).Append("',");
            sb.Append("'").Append(input.ModifyUserId).Append("',");
            sb.Append("'").Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Append("',");
            sb.Append("'0',");
            sb.Append("'").Append(input.Process).Append("',");
            sb.Append("'").Append(input.IsMap).Append("')");


            return(sb.ToString());
        }
コード例 #17
0
 public void SignIn(string username, bool persistent)
 {
     FormsAuthentication.SetAuthCookie(IdUtil.CreateUserId(username), persistent);
 }
コード例 #18
0
 public void ValidIdTest()
 {
     Assert.True(IdUtil.IsValid("cat"));
 }
コード例 #19
0
 public void InvalidIdEmptyTest()
 {
     Assert.False(IdUtil.IsValid(" "));
 }
 static ActorMessageDispatch()
 {
     InterfaceId   = IdUtil.ComputeId("IActorCommunication", "Microsoft.ServiceFabric.Actors.Communication");
     InterfaceIdV2 = IdUtil.ComputeIdWithCRC("Microsoft.ServiceFabric.Actors.Communication.IActorCommunication");
 }
コード例 #21
0
 public void InvalidIdNullTest()
 {
     Assert.False(IdUtil.IsValid(null));
 }
コード例 #22
0
 public IdentifiableBase()
     : this(IdUtil.GetNextUniqueId())
 {
 }
コード例 #23
0
 public void CreateBookCollectionNameNullTest()
 {
     Assert.Equal("", IdUtil.CreateBookCollectionName(null));
 }
コード例 #24
0
 public void CreateBookCollectionNameEmptyTest()
 {
     Assert.Equal("", IdUtil.CreateBookCollectionName(new List <string>()));
 }
コード例 #25
0
 public void CreateBookCollectionNameTest()
 {
     Assert.Equal("cat_dog", IdUtil.CreateBookCollectionName(new List <string>(new string[] { "cat", "dog" })));
 }
コード例 #26
0
        public void IdAddedEmptyTest()
        {
            var testList = new List <string>(new string[] {});

            Assert.False(IdUtil.IdAlreadyAdded("cat", testList));
        }
コード例 #27
0
 /// <summary>
 /// 取得客户端高位id
 /// </summary>
 /// <returns></returns>
 public string GetHighID()
 {
     return(IdUtil.GetNewId());
 }
コード例 #28
0
 protected virtual ID GenerateItemId(Item accountItem, MediaServiceEntityData mediaData)
 {
     return(IdUtil.GenerateItemId(accountItem, mediaData));
 }
コード例 #29
0
ファイル: SqlModelStore.cs プロジェクト: enjoycode/appbox.clr
        /// <summary>
        /// 加载指定App的所有模型包,用于导出
        /// </summary>
        /// <param name="appName">eg: erp</param>
        internal static async Task LoadToAppPackage(uint appId, string appName, Server.IAppPackage pkg)
        {
            var db        = SqlStore.Default;
            var esc       = db.NameEscaper;
            var appPrefix = $"{appName}.";

            using var conn = await db.OpenConnectionAsync();

            using var cmd    = db.MakeCommand();
            cmd.Connection   = conn;
            cmd.CommandText  = $"Select meta,id,data From {esc}sys.Meta{esc} Where meta<{Meta_View_Router} And model<>10";
            using var reader = await cmd.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                // 根据不同类型判断是否属于当前App
                var metaType = reader.GetInt16(0);
                var id       = reader.GetString(1);
                switch (metaType)
                {
                case Meta_Application:
                {
                    if (uint.Parse(id) == appId)
                    {
                        var appModel = (ApplicationModel)DeserializeModel((byte[])reader.GetValue(2));         //TODO: use GetStream
                        pkg.Application = appModel;
                    }
                }
                break;

                case Meta_Model:
                {
                    ulong modelId = ulong.Parse(id);
                    if (IdUtil.GetAppIdFromModelId(modelId) == appId)
                    {
                        var model = (ModelBase)DeserializeModel((byte[])reader.GetValue(2));         //TODO:同上
                        model.AcceptChanges();
                        pkg.Models.Add(model);
                    }
                }
                break;

                case Meta_Code:
                {
                    ulong modelId = ulong.Parse(id);
                    if (IdUtil.GetAppIdFromModelId(modelId) == appId)
                    {
                        pkg.SourceCodes.Add(modelId, (byte[])reader.GetValue(2));
                    }
                }
                break;

                case Meta_Folder:
                {
                    var  dotIndex    = id.AsSpan().IndexOf('.');
                    uint folderAppId = uint.Parse(id.AsSpan(0, dotIndex));
                    if (folderAppId == appId)
                    {
                        var folder = (ModelFolder)DeserializeModel((byte[])reader.GetValue(2));         //TODO:同上
                        pkg.Folders.Add(folder);
                    }
                }
                break;

                case Meta_Service_Assembly:
                {
                    if (id.AsSpan().StartsWith(appPrefix))
                    {
                        pkg.ServiceAssemblies.Add(id, (byte[])reader.GetValue(2));
                    }
                }
                break;

                case Meta_View_Assembly:
                {
                    if (id.AsSpan().StartsWith(appPrefix))
                    {
                        pkg.ViewAssemblies.Add(id, (byte[])reader.GetValue(2));
                    }
                }
                break;

                default:
                    Log.Warn($"Load unknown meta type: {metaType}");
                    break;
                }
            }
        }
コード例 #30
0
        protected virtual ID GenerateItemId(ClientPipelineArgs args, Item accountItem)
        {
            var mediaData = this.GetMediaData(args);

            return(IdUtil.GenerateItemId(accountItem, mediaData));
        }