Ejemplo n.º 1
0
        /// <summary>
        /// Get a UUID string
        /// <return>uuid</return>
        /// </summary>
        public static Guid GetUuid(string alias, bool currentPartition)
        {
            var optionhandler = new OptionManager();
            int id            = 0;
            var uuid          = new Guid();
            var partition     = String.Empty;

            if (optionhandler.GetOptionId(alias) != null)
            {
                id = optionhandler.GetOptionId(alias).Value;
            }

            var listCompany = AuthenticationInfoProvider.Current.Manager.GetAllAvailableCompanies(new CompanySpecBuilder());

            if (listCompany.Count != 0 && currentPartition)
            {
                partition = listCompany[0].Partition;
            }
            else
            {
                partition = listCompany[1].Partition;
            }

            uuid = UuidUtil.BuildOptionGuid(Convert.ToUInt32(id), Convert.ToUInt32(partition));
            return(uuid);
        }
Ejemplo n.º 2
0
        public async Task <GetOptionResponse> Handle(PrivateSession session, GetOptionRequest request, Func <PrivateConnection> connectionFactory)
        {
            var companyId = (await session.CallAsync(MetaData.MetaDataRequest.GetAccountInfo(HrbcAccountInfoProperty.CompanyId))).CompanyId;

            using (var connection = connectionFactory().ApiName(ApiName).Method(PrivateConnectionMethod.Read))
            {
                try
                {
                    using (var response = await connection.SendAsync(
                               new Json.GetSchemaOptionRequest {
                        Ids = request.Ids.Select(id => UuidUtil.BuildOptionGuid((ulong)id, companyId)).ToList(), Select = request.Select.Select(x => x.ToString().ToLower()).ToList()
                    }))
                    {
                        var responseData = await response.ReadAsync <Json.GetSchemaOptionResponse>();

                        var optionCollection = responseData.Values.Select(
                            optionModelEntry => new OptionDataCollection(
                                request.Select.Append(OptionField.Id).ToDictionary(
                                    optionField => optionField.ToField(),
                                    optionField => GetValueByOptionField(optionModelEntry, optionField))));

                        return(new GetOptionResponse(optionCollection));
                    }
                }
                catch (ConnectionResponseException e)
                {
                    throw e.ToRequestException("Could not get options", request);
                }
            }
        }
        private static Guid GetUuid(int id)
        {
            var optionhandler = new OptionManager();
            var uuid          = new Guid();
            var listCompany   = AuthenticationInfoProvider.Current.Manager.GetAllAvailableCompanies(new CompanySpecBuilder());

            if (listCompany.Count != 0)
            {
                var partition = listCompany[0].Partition;
                uuid = UuidUtil.BuildOptionGuid(Convert.ToUInt32(id.ToString()), Convert.ToUInt32(partition));
            }
            return(uuid);
        }