public async void OnDuplicateBtnClicked(object sender, EventArgs e)
        {
            string name = await DisplayPromptAsync(
                Resx.TextResource.Common_AskTitle,
                Resx.TextResource.New_AskDuplicatePrompt,
                Resx.TextResource.Common_OK,
                Resx.TextResource.Common_Cancel,
                initialValue : Item.HostName + " 1");

            if (name == null)
            {
                return;
            }

            if (hostsModel.DataStore.HasHost(name))
            {
                await DisplayAlert(
                    Resx.TextResource.Common_ErrorTitle,
                    string.Format(Resx.TextResource.New_HostHasBeenAdded, name),
                    Resx.TextResource.Common_OK);

                return;
            }

            var newItem = Item.Duplicate(name);

            newItem.LoadBalance.Clear();
            newItem.LoadBalance.AddRange(LoadBalance);
            LoadBalance.Clear();
            MessagingCenter.Send(this, "AddItem", newItem);
            await Navigation.PopModalAsync();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //Step 2: Create 'vps' object and call 'Providers' method. Run the program to see the output.
            Vps vps = new Vps();

            vps.Providers();

            //Step 4: Create 'loadBalance' object and call 'Providers' method. Run the program to see the output.
            LoadBalance loadBalance = new LoadBalance();

            loadBalance.Providers();

            //Step 6: Create 'loadBalance2' object and call both 'Providers' & 'Providers2' methods.
            //Run the program to see the output.
            LoadBalance2 loadBalance2 = new LoadBalance2();

            loadBalance2.Providers();
            loadBalance2.Providers2();

            //Step 8: Create 'cdn' object and call 'CdnProviders' method. Run the program to see the output.
            Cdn cdn = new Cdn();

            cdn.CdnProviders();

            //Step 10: Create 'dns' object and call 'CdnProviders' method. Run the program to see the output.
            Dns dns = new Dns();

            dns.CdnProviders();
        }
Exemplo n.º 3
0
        public async void Save_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Item.HostName))
            {
                await DisplayAlert(
                    Resx.TextResource.Common_ErrorTitle,
                    Resx.TextResource.New_HostErrorNeedName,
                    Resx.TextResource.Common_OK);

                return;
            }

            if (addedOrEdit)
            {
                if (hostsModel.DataStore.HasHost(Item.HostName))
                {
                    await DisplayAlert(
                        Resx.TextResource.Common_ErrorTitle,
                        string.Format(Resx.TextResource.New_HostHasBeenAdded, Item.HostName),
                        Resx.TextResource.Common_OK);

                    return;
                }
            }
            else
            {
                Item.LoadBalance.Clear();
                Item.LoadBalance.AddRange(LoadBalance);
                MessagingCenter.Send(this, "UpdateItem", Item);
                await Navigation.PopModalAsync();

                return;
            }

            if (!Item.IsValid())
            {
                await DisplayAlert(
                    Resx.TextResource.Common_ErrorTitle,
                    string.Format(Resx.TextResource.New_ErrorAttributes, Item.HostName),
                    Resx.TextResource.Common_OK);

                return;
            }

            Item.LoadBalance.Clear();
            Item.LoadBalance.AddRange(LoadBalance);
            LoadBalance.Clear();
            MessagingCenter.Send(this, "AddItem", Item);
            await Navigation.PopModalAsync();
        }
Exemplo n.º 4
0
        public Puller(string subject, string consumerGroup, bool isBroadcast, TagType tagType, string[] tags, ConsumeMode consumeMode, PullController controller, PullStrategy pullStrategy, LoadBalance loadBalance)
        {
            _subject       = subject;
            _originSubject = RetrySubjectUtils.RealSubject(_subject);
            _consumerGroup = consumerGroup;
            _isBroadcast   = isBroadcast;
            _consumeMode   = consumeMode;
            _tagType       = (_tags == null || _tags.Length == 0) ? (byte)0 : (byte)tagType;
            _tags          = tags;

            _controller = controller;

            _pullStrategy = pullStrategy;
            _loadBalance  = loadBalance;
        }
Exemplo n.º 5
0
        public async void OnDeleteLoadbalanceClicked(object sender, EventArgs e)
        {
            var layout   = (BindableObject)sender;
            var hostName = layout.BindingContext as string;

            bool response = await DisplayAlert(
                Resx.TextResource.Common_AskTitle,
                string.Format(Resx.TextResource.New_LoadBalanceDelHostAsk, hostName),
                Resx.TextResource.Common_Yes,
                Resx.TextResource.Common_No);

            if (response)
            {
                LoadBalance.Remove(hostName);
            }
        }
Exemplo n.º 6
0
        public async void OnAddLoadbalanceClicked(object sender, EventArgs e)
        {
            List <string> hosts = null;

            if (addedOrEdit)
            {
                hosts = hostsModel.Items
                        .Where(h => h.EnablePipeline &&
                               !LoadBalance.Contains(h.HostName))
                        .Select(h => h.HostName)
                        .ToList();
            }
            else
            {
                hosts = hostsModel.Items
                        .Where(h => h.EnablePipeline &&
                               !LoadBalance.Contains(h.HostName) &&
                               !h.HostName.Equals(Item.HostName))
                        .Select(h => h.HostName)
                        .ToList();
            }

            if (hosts.Count == 0)
            {
                await DisplayAlert(
                    Resx.TextResource.Common_ErrorTitle,
                    Resx.TextResource.New_LoadBalanceHost_Error,
                    Resx.TextResource.Common_Yes);

                return;
            }

            string action = await DisplayActionSheet(
                Resx.TextResource.New_LoadBalanceHost_Title,
                Resx.TextResource.Common_Cancel,
                null,
                hosts.ToArray());

            if (hosts.Contains(action))
            {
                LoadBalance.Add(action);
            }
        }
Exemplo n.º 7
0
        public HostEditPage(HostsViewModel viewModel, HostModel editHost)
        {
            InitializeComponent();

            hostsModel  = viewModel;
            addedOrEdit = editHost == null;
            Item        = editHost ?? new HostModel()
            {
                SSLVerify = true
            };
            ShowDeleteBtn      = !addedOrEdit;
            EnableEditHostName = addedOrEdit;

            foreach (var h in Item.LoadBalance)
            {
                LoadBalance.Add(h);
            }

            BindingContext = this;
        }
Exemplo n.º 8
0
 private void MessagePopupForm_Load(object sender, EventArgs e)
 {
     MySmartThreadPool.InstanceLoadModel().QueueWorkItem(() =>
     {
         try
         {
             LoadBalance.Ini(INIHelper.ReadInteger("AiBaseConfig", "LoadModelNum", 0, Application.StartupPath + "/config.ini"));
             this.DialogResult = DialogResult.OK;
         }
         catch (System.AccessViolationException er)
         {
             LogHelper.WriteLog("AI初始化失败", er);
             this.DialogResult = DialogResult.No;
         }
         finally
         {
             this.BeginInvoke((Action)(() =>
             {
                 this.Close();
             }));
         }
     });
 }
Exemplo n.º 9
0
        /// <summary>
        /// 动态调用WebService主函数
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static ESB.Core.Schema.务响应 DynamicalCallWebService(
            Boolean needResponse
            , ESB.Core.Schema.务请求 request
            , List <BindingTemplate> bindings
            , Int32 version
            , EsbView_ServiceConfig serviceConfig
            , AdvanceInvokeParam invokeParam)
        {
            //--记录接收时间并放在请求结束时间中,用于判读ESB在接到请求到开始调用的耗时
            DateTime receiveDateTime = DateTime.Now;

            //--验证并预处理请求参数
            InvalidRequest(request);

            //--获取跟踪上下文
            ESBTraceContext esbTraceContext = GetEsbTraceContext();

            //--获取到请求对应服务的绑定
            BindingTemplate binding = LoadBalance.GetBinding(bindings, serviceConfig.HBPolicy);

            //--构造调用参数
            CallState state = new CallState()
            {
                Binding          = binding,
                ServiceConfig    = serviceConfig,
                InvokeParam      = invokeParam,
                Request          = request,
                RequestBeginTime = request.请求时间,
                RequestEndTime   = receiveDateTime,
                TraceContext     = esbTraceContext,
                ServiceVersion   = version,
                MessageID        = Guid.NewGuid().ToString()
            };

            return(CallService(state));
        }
Exemplo n.º 10
0
        public static void SaveOutputDataInPi(Outputs UnitOutputTags, IList <PIPoint> points, eRCM_KernelControl objACIkernal, Service unit)
        {
            IList <AFValue> valuesToWrite = new List <AFValue>();
            List <Tag>      lstTagResult  = new List <Tag>();
            var             LoadArray     = objACIkernal.LoadArray(unit.LoadStep);
            //Load Step
            object IdealLS        = UnitOutputTags.LoadStep.Ideal.Value;
            object IdealLSDetails = UnitOutputTags.LoadStep.IdealDetails.Value;
            var    loadStep       = LoadSteps.GetLoadSteps(objACIkernal, UnitOutputTags.LoadStep);

            //lstTagResult.Add(loadStep.Current);
            //lstTagResult.Add(loadStep.CurrentDetails);
            //lstTagResult.Add(loadStep.Ideal);
            //lstTagResult.Add(loadStep.IdealDetails);
            lstTagResult.Add(loadStep.NextDown);
            lstTagResult.Add(loadStep.NextUp);
            //Load Prediction
            //var loadPredictionResult = LoadPrediction.GetLoadPrediction(objACIkernal, UnitOutputTags.LoadPrediction);
            //lstTagResult.Add(loadPredictionResult.Current);
            //lstTagResult.Add(loadPredictionResult.Ideal);
            //Flow Prediction
            //var flowPredictionResult = FlowPrediction.GetFlowPrediction(objACIkernal, UnitOutputTags.FlowPrediction);
            //lstTagResult.Add(flowPredictionResult.Current);
            //lstTagResult.Add(flowPredictionResult.Ideal);
            //Meachinical Efficiency
            UnitOutputTags.MechanicalEfficiency.Value = objACIkernal.MechanicalEfficiency;
            lstTagResult.Add(UnitOutputTags.MechanicalEfficiency);
            //Current Torque
            UnitOutputTags.CurrentTorque.Value = objACIkernal.CurrentTorque;
            lstTagResult.Add(UnitOutputTags.CurrentTorque);
            //Max Load
            UnitOutputTags.MaxLoad.Value = objACIkernal.MaxAllowedLoad;
            lstTagResult.Add(UnitOutputTags.MaxLoad);
            //ErroCode objERCM.FullEnglishErrors(objERCM.ErrorArray(objERCM.CurrentLoadStep), 0)
            //UnitOutputTags.ErrorCode.Value = objACIkernal.FullEnglishErrors(objACIkernal.ErrorArray(objACIkernal.CurrentLoadStep), 0);
            //UnitOutputTags.ErrorCode.Value = objACIkernal.ErrorArray(objACIkernal.CurrentLoadStep);
            //lstTagResult.Add(UnitOutputTags.ErrorCode);
            //Rated Load
            UnitOutputTags.RatedLoad.Value = objACIkernal.RatedLoad;
            lstTagResult.Add(UnitOutputTags.RatedLoad);
            //Rated Speed
            UnitOutputTags.RatedSpeed.Value = objACIkernal.RatedSpeed;
            lstTagResult.Add(UnitOutputTags.RatedSpeed);
            //Min Load/Flow Change Allowed
            UnitOutputTags.MinChangeAllowed.Value = objACIkernal.MinLoadFlowChangeAllowed;
            lstTagResult.Add(UnitOutputTags.MinChangeAllowed);
            //Max Load Change Allowed
            UnitOutputTags.MaxChangeAllowed.Value = objACIkernal.MaxLoadChangeAllowed;
            lstTagResult.Add(UnitOutputTags.MaxChangeAllowed);
            //Min Speed
            UnitOutputTags.MinSpeed.Value = objACIkernal.MinSpeedCurrentLS();
            lstTagResult.Add(UnitOutputTags.MinSpeed);
            //Max Speed
            UnitOutputTags.MaxSpeed.Value = objACIkernal.MaxSpeedCurrentLS();
            lstTagResult.Add(UnitOutputTags.MaxSpeed);
            //Stage Info
            var stageInfoResult = StageInfo.GetStageInfoList(objACIkernal, UnitOutputTags.StageInfo, unit);

            foreach (var stage in stageInfoResult)
            {
                // Trace.WriteLine("StageNumber:" + stage.StageNumber);
                lstTagResult.Add(stage.CompressionRatio);
                lstTagResult.Add(stage.DischargePressureAtFlange);
                lstTagResult.Add(stage.DischargePressureAtGadge);
                lstTagResult.Add(stage.DischargeTemperature);
                lstTagResult.Add(stage.Load);
                lstTagResult.Add(stage.RatioActualVsTheoriticalPressure);
                lstTagResult.Add(stage.RatioActualVsTheoriticalTemperature);
            }
            //Load Balance
            var lbResult = LoadBalance.GetLoadBalance(objACIkernal, UnitOutputTags.LoadBalance);

            foreach (var stage in lbResult)
            {
                // Trace.WriteLine("StageNumber:" + stage.Stages);
                lstTagResult.Add(stage.Ratio);
            }
            //Head End Info
            var headEndResult = HeadEndInfo.GetHeadEndInfo(objACIkernal, UnitOutputTags.HeadEndInfo);

            foreach (var headEndCylinder in headEndResult)
            {
                lstTagResult.Add(headEndCylinder.DischargeVE);
                lstTagResult.Add(headEndCylinder.Flow);
                lstTagResult.Add(headEndCylinder.Load);
                lstTagResult.Add(headEndCylinder.SuctionVE);
            }
            //Crank End
            var crankEndResult = CrankEndInfo.GetHeadEndInfo(objACIkernal, UnitOutputTags.CrankEndInfo);

            foreach (var crankEndCylinder in crankEndResult)
            {
                lstTagResult.Add(crankEndCylinder.DischargeVE);
                lstTagResult.Add(crankEndCylinder.Flow);
                lstTagResult.Add(crankEndCylinder.Load);
                lstTagResult.Add(crankEndCylinder.SuctionVE);
                lstTagResult.Add(crankEndCylinder.EstimatedDischargeTemperature);
            }
            //Compression Forces
            var compForcesResults = CompressionForces.GetCompressionForces(objACIkernal, UnitOutputTags.CompressionForces);

            foreach (var throws in compForcesResults)
            {
                lstTagResult.Add(throws.Force);
            }
            //Tension Forces
            var tensForcesResults = TensionForces.GetTensionForces(objACIkernal, UnitOutputTags.TensionForces);

            foreach (var throws in tensForcesResults)
            {
                lstTagResult.Add(throws.Force);
            }
            //Fuel Rate
            //var fuelRatesResult = FuelRates.GetFuelRates(objACIkernal, UnitOutputTags.FuelRate, unit);
            //lstTagResult.Add(fuelRatesResult.Current);
            //lstTagResult.Add(fuelRatesResult.Ideal);
            lstTagResult.Add(UnitOutputTags.MaxAllowedDischargePressure);
            lstTagResult.Add(UnitOutputTags.IdealFlow90T);
            lstTagResult.Add(UnitOutputTags.IdealFuelRate90T);
            lstTagResult.Add(UnitOutputTags.IdealLoad90T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStep90T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStepDetail90T);
            lstTagResult.Add(UnitOutputTags.IdealFlow95T);
            lstTagResult.Add(UnitOutputTags.IdealFuelRate95T);
            lstTagResult.Add(UnitOutputTags.IdealLoad95T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStep95T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStepDetail95T);
            UnitOutputTags.LoadStep.Ideal.Value = IdealLS;
            lstTagResult.Add(UnitOutputTags.LoadStep.Ideal);
            UnitOutputTags.LoadStep.IdealDetails.Value = IdealLSDetails;
            lstTagResult.Add(UnitOutputTags.LoadStep.IdealDetails);
            lstTagResult.Add(UnitOutputTags.LoadPrediction.Ideal);
            lstTagResult.Add(UnitOutputTags.FlowPrediction.Ideal);
            lstTagResult.Add(UnitOutputTags.FuelRate.Ideal);
            lstTagResult.Add(UnitOutputTags.LoadStep.Current);
            lstTagResult.Add(UnitOutputTags.LoadStep.CurrentDetails);
            lstTagResult.Add(UnitOutputTags.LoadPrediction.Current);
            lstTagResult.Add(UnitOutputTags.FlowPrediction.Current);
            lstTagResult.Add(UnitOutputTags.FuelRate.Current);
            lstTagResult.Add(UnitOutputTags.ErrorCode);

            foreach (var pipoint in points)
            {
                var     tagValue     = lstTagResult.Where(x => x.Name == pipoint.Name).Select(x => x.Value).FirstOrDefault();
                AFValue afValueFloat = new AFValue(tagValue, DateTime.Now)
                {
                    PIPoint = pipoint
                };
                valuesToWrite.Add(afValueFloat);
            }

            piServer.UpdateValues(valuesToWrite, AFUpdateOption.InsertNoCompression, AFBufferOption.BufferIfPossible);
            Console.WriteLine("Pi Values Added for " + unit.UnitName + " at" + DateTime.Now + " Successfully");
        }