예제 #1
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (HasCreationDateTime)
                    {
                        hash ^= CreationDateTime.GetHashCode();
                    }
                    if (HasStartDateTime)
                    {
                        hash ^= StartDateTime.GetHashCode();
                    }
                    if (HasCompletionDateTime)
                    {
                        hash ^= CompletionDateTime.GetHashCode();
                    }
                    if (HasEstimatedCompletionRatio)
                    {
                        hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(EstimatedCompletionRatio);
                    }
                    if (HasOperationCount)
                    {
                        hash ^= OperationCount.GetHashCode();
                    }
                    if (HasExecutedOperationCount)
                    {
                        hash ^= ExecutedOperationCount.GetHashCode();
                    }
                    if (_unknownFields != null)
                    {
                        hash ^= _unknownFields.GetHashCode();
                    }
                    return(hash);
                }
예제 #2
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (creationDateTime_ != null)
                    {
                        hash ^= CreationDateTime.GetHashCode();
                    }
                    if (completionDateTime_ != null)
                    {
                        hash ^= CompletionDateTime.GetHashCode();
                    }
                    if (estimatedCompletionRatio_ != null)
                    {
                        hash ^= pbc::ProtobufEqualityComparers.BitwiseNullableDoubleEqualityComparer.GetHashCode(EstimatedCompletionRatio);
                    }
                    if (operationCount_ != null)
                    {
                        hash ^= OperationCount.GetHashCode();
                    }
                    if (executedOperationCount_ != null)
                    {
                        hash ^= ExecutedOperationCount.GetHashCode();
                    }
                    if (_unknownFields != null)
                    {
                        hash ^= _unknownFields.GetHashCode();
                    }
                    return(hash);
                }
예제 #3
0
        public void TestLnmVnetPublishingScenario()
        {
            using (var cancellationSource = new CancellationTokenSource())
            {
                var operationCount = new OperationCount();
                var cancel         = cancellationSource.Token;
                var threads        = Enumerable.Range(0, threadCount)
                                     .Select(n => new Thread(() => this.MockLnmThread(cancel, n, operationCount)))
                                     .ToArray();
                Parallel.ForEach(threads, t => t.Start());

                Task.Run(async() =>
                {
                    var lastCount = operationCount.CreateCount;

                    while (!cancel.IsCancellationRequested)
                    {
                        await Task.Delay(1000);
                        var delta = operationCount.CreateCount - lastCount;
                        lastCount = operationCount.CreateCount;

                        log($"{DateTime.Now} createCount={operationCount.CreateCount} +{delta} dataSize={operationCount.DataSize}");
                    }
                });

                Thread.Sleep(100 * 1000);
                cancellationSource.Cancel();
                Parallel.ForEach(threads, t => t.Join());
                log($"CreateCount = {operationCount.CreateCount} SetCount = {operationCount.SetCount} Failures = {operationCount.FailureCount}");
            }
        }
예제 #4
0
        /// <summary>
        /// Thread to mock a NSM / LNM which is publishing VNET data
        /// </summary>
        /// <param name="cancel">Cancellation token</param>
        /// <param name="threadId">Thread sequence number</param>
        /// <param name="operationCount">Object to store operation statistics</param>
        private void MockLnmThread(CancellationToken cancel, int threadId, OperationCount operationCount)
        {
            using (var client = new RingMasterClient(serverAddress, null, null, 10000))
            {
                var rnd = new Random();

                while (!cancel.IsCancellationRequested)
                {
                    Task.Run(async() =>
                    {
                        try
                        {
                            var vnet = $"/mud/vnets/{CreateSpanningVnetId(threadId)}";
                            var stat = await client.Exists(vnet, null, true);
                            var ops  = new List <Op>();

                            if (stat == null)
                            {
                                ops.Add(Op.Create($"{vnet}/mappings/v4ca", null, null, CreateMode.PersistentAllowPathCreation));
                                ops.Add(Op.Create($"{vnet}/lnms/thread-{threadId}", null, null, CreateMode.PersistentAllowPathCreation));

                                await client.Multi(ops, true);
                                ops.Clear();

                                operationCount.AddCreate(2);
                            }

                            var mappingCount = rnd.Next(1, 1024 * 8);
                            for (int i = 0; i < mappingCount; i++)
                            {
                                ops.Add(Op.Create($"{vnet}/mappings/v4ca/{i}", null, null, CreateMode.PersistentAllowPathCreation));
                                operationCount.AddCreate(1);
                            }

                            await client.Multi(ops, true);
                            ops.Clear();

                            for (int i = 0; i < mappingCount; i++)
                            {
                                var data = new byte[rnd.Next(minPayloadSize, maxPayloadSize)];
                                ops.Add(Op.SetData($"{vnet}/mappings/v4ca/{i}", data, -1));
                                operationCount.AddSet(1);
                                operationCount.AddData(data.Length);
                            }

                            await client.Multi(ops, true);
                            ops.Clear();
                        }
                        catch (Exception ex)
                        {
                            operationCount.IncrementFailure();

                            // Ignore and keep going
                            log($"FAIL in {threadId}: {ex.Message}");
                        }
                    }).GetAwaiter().GetResult();
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Use this method to record the duration for an operation.
        /// </summary>
        /// <param name="duration">Number of ticks for the operation.</param>
        public void RecordOperation(long duration)
        {
            CheckIsInitializedForRuntime();

            OperationCount.Increment();
            OperationsPerSecond.Increment();
            AverageOperationTime.IncrementBy(duration);
            AverageOperationTimeBase.Increment();
        }
        public OperationCount GetOperationQuanty()
        {
            OperationCount count = new OperationCount();

            count.FirstClassCount  = 562;
            count.SecondClassCount = 493;
            count.ThirdClassCount  = 713;
            count.ForthClassCount  = 251;
            count.FifthClassCount  = 253;

            return(count);
        }
        public void ProcessRequest(HttpContext context)
        {
            var container = new UnityContainer();

            //container.RegisterType<IPatientsExperenceService, PatientsExperenceService>();
            //container.RegisterType<IOutpatientService, OutpatientService>();
            container.LoadConfiguration();
            var homeInformation  = container.Resolve <IHomeInformation>();
            var operationSercice = container.Resolve <IOperationService>();
            //在此处写入您的处理程序实现。
            String type = context.Request["type"];

            var serializer = new JavaScriptSerializer();

            serializer.MaxJsonLength = Int32.MaxValue;
            String input = "";

            //System.Web.HttpContext.Current.Server.UrlDecode(context.Request["content"]);
            switch (type)
            {
                #region 手术相关
            case HomeRequestType.OperatingRoomDetailedInformation:    //获取手术室详情
                string oprationState, searchType, area, operationType, content;
                string sDate, eDate;
                oprationState = context.Request["oprationState"].ToString();
                searchType    = context.Request["searchType"].ToString();
                area          = context.Request["area"].ToString();
                if (!string.IsNullOrEmpty(context.Request["operationType"]))
                {
                    operationType = context.Request["operationType"].ToString();
                }
                else
                {
                    operationType = string.Empty;
                }
                sDate = context.Request["sDate"].ToString();
                eDate = context.Request["eDate"].ToString();
                context.Request.ContentEncoding = Encoding.UTF8;
                //content = System.Web.HttpContext.Current.Server.UrlDecode(context.Request["content"]);
                content = System.Web.HttpUtility.UrlDecode(context.Request["content"]);
                // content = System.Web.HttpContext.Current.Server.UrlDecode(context.Request.Querystring["content"]);
                //Request.Querystring["Name"]
                // HttpUtility.UrlEncode(query, System.Text.Encoding.GetEncoding("GB2312"));
                //content = context.Request["content"].ToString();
                input = serializer.Serialize(operationSercice.GetSurgeryDetailedInformation(oprationState, searchType, area, operationType, sDate, eDate, content));
                break;

            case HomeRequestType.OperationQuanty:    //获取手术数量
                OperationCount dateSet = operationSercice.GetOperationQuanty();
                input = JsonConvert.SerializeObject(dateSet);
                break;

            case HomeRequestType.OperationSearchRate:    //获取手术查询信息
                string searchContent  = context.Request["searchContent"].ToString();
                string searchRateType = context.Request["searchRateType"].ToString();
                input = JsonConvert.SerializeObject(operationSercice.GetOperationSearchRate(searchContent, searchRateType));
                break;

                #endregion
            }
            context.Response.Write(input);
        }
        public OperationCount GetOperationQuanty()
        {
            var count = new OperationCount();

            return(count);
            //#region sql
            //String command = @"select total,oneTypeOperation,twoTypeOperation,threeTypeOperation,fourTypeOperation,fiveTypeOperation from
            //        (
            //        select count(*) as total
            //          from sss_sstzd a
            //          join sss_sstzd_ssss b
            //            on a.tzdid = b.tzdid
            //         where a.mzss = '0'
            //           and a.ztbz in ('4', '5')
            //           and a.sskssj >= to_date('{0}', 'yyyy-MM-dd')
            //           ) a,
            //           (
            //        select count(*) as oneTypeOperation
            //          from sss_sstzd a
            //          join sss_sstzd_ssss b
            //            on a.tzdid = b.tzdid
            //         where a.mzss = '0'
            //           and a.ztbz in ('4', '5')
            //           and b.sslb=1
            //           and a.sskssj >= to_date('{0}', 'yyyy-MM-dd')
            //           ) b,
            //           (
            //        select count(*) as twoTypeOperation
            //          from sss_sstzd a
            //          join sss_sstzd_ssss b
            //            on a.tzdid = b.tzdid
            //         where a.mzss = '0'
            //           and a.ztbz in ('4', '5')
            //           and b.sslb=2
            //           and a.sskssj >= to_date('{0}', 'yyyy-MM-dd')
            //           ) c,
            //         (  select count(*) threeTypeOperation
            //          from sss_sstzd a
            //          join sss_sstzd_ssss b
            //            on a.tzdid = b.tzdid
            //         where a.mzss = '0'
            //           and a.ztbz in ('4', '5')
            //           and b.sslb=3
            //           and a.sskssj >= to_date('{0}', 'yyyy-MM-dd')
            //           ) d,
            //          ( select count(*) fourTypeOperation
            //          from sss_sstzd a
            //          join sss_sstzd_ssss b
            //            on a.tzdid = b.tzdid
            //         where a.mzss = '0'
            //           and a.ztbz in ('4', '5')
            //           and b.sslb=4
            //           and a.sskssj >= to_date('{0}', 'yyyy-MM-dd')
            //           ) e,
            //           ( select count(*) fiveTypeOperation
            //          from sss_sstzd a
            //          join sss_sstzd_ssss b
            //            on a.tzdid = b.tzdid
            //         where a.mzss = '0'
            //           and a.ztbz in ('4', '5')
            //           and b.sslb=5
            //           and a.sskssj >= to_date('{0}', 'yyyy-MM-dd')
            //           ) f";
            //DateTime startTime = DateTime.Now.Date.AddMonths(-1);
            //command = string.Format(command, startTime.ToString("yyyy-MM-dd"));
            //#endregion
            //DbCommand queryCommand = db.GetSqlStringCommand(command);

            //DataSet dateSet = db.ExecuteDataSet(queryCommand);
            //return dateSet;
        }