Esempio n. 1
0
        protected void UpdateFeedback(object sender, EventArgs e)
        {
            Model.Distribution      distribution = new Model.Distribution();
            BLL.DistributionManager manager      = new DistributionManager();

            BLL.AdminManager adminManager1 = new BLL.AdminManager();
            Model.Admin      admin1        = adminManager1.GetModel1(Session["SadminID"].ToString());
            string           handlers      = DropDownList_Distribution.SelectedItem.Text;


            Model.Feedback      feedback = new Model.Feedback();
            BLL.FeedbackManager Fmanager = new FeedbackManager();

            feedback.feedbackID = Convert.ToInt32(Labeltest.Text.Trim());
            feedback.handler    = handlers;
            string Str1 = "handler='" + handlers + "'";
            string Str2 = "feedbackID='" + Labeltest.Text.Trim() + "'";
            bool   bo2  = Fmanager.UpdateHandler(Str1, Str2);

            if (bo2 == true)
            {
                Response.Write("<script language=javascript>alert('修改成功!')</script>");
                BindY();
                BindN();
            }
        }
Esempio n. 2
0
        protected void Btn_Distribution_Click(object sender, EventArgs e)
        {
            Model.Distribution      distribution  = new Model.Distribution();
            BLL.DistributionManager manager       = new DistributionManager();
            BLL.AdminManager        adminManager1 = new BLL.AdminManager();
            Model.Admin             admin1        = adminManager1.GetModel1(Session["SadminID"].ToString());
            int s = Convert.ToInt32(admin1.adminID);



            distribution.feedbackID  = Convert.ToInt32(Labeltest.Text);
            distribution.description = txtDistribution.Text.Trim();
            distribution.adminID     = Convert.ToInt32(DropDownList_Distribution.SelectedValue.ToString());
            distribution.assignerID  = s;
            distribution.state       = "待处理";
            bool bo = manager.Add(distribution);

            if (bo == true)
            {
                Response.Write("<script language=javascript>alert('分配成功!')</script>");
                txtDistribution.Text = "";
                DropDownList_Distribution.SelectedIndex = 0;
                UpdateFeedback(sender, e);
                BindY();
                BindN();
            }
            else
            {
                Response.Write("<script language=javascript>alert('分配失败!请重试')");
            }
        }
        private ParameterViewModel(ParameterInfo info, ConstructorViewModel owner, DoubleRange range, double value)
        {
            bool isInteger = info.ParameterType == typeof(int);

            double min = range.Min;
            double max = range.Max;

            if (min < -1e+5)
            {
                min = -1e+5;
            }

            if (max > 1e+5)
            {
                max = 1e+5;
            }

            double step = 0.1;

            if (isInteger)
            {
                step = 1;
            }

            Min        = min;
            Max        = max;
            Step       = step;
            Value      = value;
            Name       = DistributionManager.Normalize(info.Name);
            Owner      = owner;
            Parameter  = info;
            IsDiscrete = isInteger;
        }
 // Update is called once per frame
 void Update()
 {
     if (StateManager.simState == StateManager.SimState.Menu)
     {
         IEnumerator <Toggle> toggleEnum = toggleGroup.ActiveToggles().GetEnumerator();
         toggleEnum.MoveNext();
         toggle = toggleEnum.Current;
         if (toggle.name == "normalDistribution")
         {
             DistributionManager.setNormal();
         }
         else if (toggle.name == "triangularDistribution")
         {
             DistributionManager.setTriangle();
         }
         else if (toggle.name == "erlangDistribution")
         {
             DistributionManager.setErlang();
         }
         else if (toggle.name == "equalUniform")
         {
             DistributionManager.setUniform();
         }
     }
 }
Esempio n. 5
0
        public List <ProjectCompletionOdds> Post([FromBody] List <PertInput> pertInputs)
        {
            //Todo: Some creational pattern here?
            distributionManager = new DistributionManager(pertInputs);
            List <ProjectCompletionOdds> projOdds = distributionManager.GetProjectCompletionOdds();

            return(projOdds);
        }
Esempio n. 6
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="GoodnessOfFitViewModel"/> class.
        /// </summary>
        ///
        /// <param name="gof">The goodness-of-fits results against a particular distribution.</param>
        ///
        public GoodnessOfFitViewModel(GoodnessOfFit gof)
        {
            this.Name = DistributionManager.Normalize(gof.Distribution.GetType().Name);

            // Transform the rank to ordinal positions
            // i.e. 0 to "1st", 1 to "2nd", 2 to "3rd"
            this.Rank = suffix(gof.ChiSquareRank + 1);

            this.ChiSquare         = gof.ChiSquare;
            this.KolmogorovSmirnov = gof.KolmogorovSmirnov;
        }
Esempio n. 7
0
    private void Awake()
    {
        m_moneyManager        = FindObjectOfType <MoneyManager>();
        m_housingManager      = FindObjectOfType <HousingManager>();
        m_distributionManager = FindObjectOfType <DistributionManager>();
        m_researchManager     = FindObjectOfType <ResearchManager>();
        m_fabricatorManager   = FindObjectOfType <FabricatorManager>();

        m_saveManager = FindObjectOfType <SaveManager>();
        m_saveManager.OnDataLoaded += OnDataLoaded;
    }
Esempio n. 8
0
    // Switch for distribute in grid functions
    public static void DistributeInGrid(Transform activeTransform, Transform[] userSelection)
    {
        Undo.RegisterUndo(userSelection, "Distribute In Grid");
        Vector3 gridVector = AlignEditor.gridSize;

        if (AlignEditor.autoSize)
        {
            gridVector = Vector3.one * AlignEditor.calculatedGridSize;
        }
        DistributionManager.DistributePositionInGrid(activeTransform, userSelection, gridVector);
    }
        /// <summary>
        ///   Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        ///
        public MainViewModel()
        {
            this.Estimate = new EstimateViewModel(this);
            this.Analysis = new AnalysisViewModel();

            // Create ViewModels for each statistical distribution
            var distributions = DistributionManager.GetDistributions(this);

            this.Distributions             = new ObservableCollection <DistributionViewModel>(distributions);
            this.SelectedDistributionIndex = distributions.Find(x => x.Name == "Normal")[0];
        }
Esempio n. 10
0
    private void Awake()
    {
        m_distributionManager = FindObjectOfType <DistributionManager>();
        m_moneyManager        = FindObjectOfType <MoneyManager>();
        m_housingManager      = FindObjectOfType <HousingManager>();
        m_fabricatorManager   = FindObjectOfType <FabricatorManager>();
        m_researchManager     = FindObjectOfType <ResearchManager>();

        m_mainFilePath     = Path.Combine(Application.persistentDataPath, FILE_NAME);
        m_vehiclesSavePath = Path.Combine(Application.persistentDataPath, VEHICLES_FILE_NAME);
        m_housesSavePath   = Path.Combine(Application.persistentDataPath, HOUSES_FILE_NAME);
        m_researchSavePath = Path.Combine(Application.persistentDataPath, RESEARCH_FILE_NAME);
    }
Esempio n. 11
0
        static void MainOLD()
        {
            Employees employees = new Employees();

            Employee jesse = new DistributionManager();
            Employee walt  = new Cook();

            IVisitor payRise       = new IncomeVisitor();
            IVisitor extraVacation = new VacationVisitor();

            employees.Add(jesse);
            employees.Add(walt);

            employees.Accept(payRise);
            walt.Accept(extraVacation);
        }
Esempio n. 12
0
 // Switch for distribute functions
 static void Distribute()
 {
     if (AlignEditor.ScaleTool)
     {
         Undo.RegisterUndo(Selection.transforms, "Distribute Scale");
         DistributionManager.DistributeScale(Selection.activeTransform, Selection.transforms, AlignEditor.sortBy, AlignEditor.Axis [(int)AlignEditor.axis]);
     }
     else if (AlignEditor.RotationTool)
     {
         Undo.RegisterUndo(Selection.transforms, "Distribute Rotation");
         DistributionManager.DistributeRotation(Selection.activeTransform, Selection.transforms, AlignEditor.sortBy, AlignEditor.Axis [(int)AlignEditor.axis]);
     }
     else
     {
         Undo.RegisterUndo(Selection.transforms, "Distribute Position");
         DistributionManager.DistributePosition(Selection.activeTransform, Selection.transforms, AlignEditor.sortBy, AlignEditor.Axis [(int)AlignEditor.axis]);
     }
 }
Esempio n. 13
0
        public static void Cache()
        {
            _cacheprogress?.Wait();

            _cacheprogress = Tasky.Run(() => {
                var l = new List <Task>();
                foreach (var dist in DistributionManager.GetDistributers(false))
                {
                    l.Add(Tasky.Run(() => {
                        foreach (var d in dist.Distributables())
                        {
                            _randlocdb.Add(d);
                        }
                    }));
                }
                Tasky.WhenAll(l.ToArray()).Wait();
                _cacheprogress = null;
            });
        }
Esempio n. 14
0
    // Use this for initialization
    void Start()
    {
        /*First Example
         * We have 10 lootboxes, when user open one, he can win:
         * 10 coins : chance - 50%
         * 25 coins : chance - 25%
         * 50 coins : chance - 15%
         * 75 coins : chance - 10%
         */
        float[] chances = new float[4] {
            .5f, .25f, .15f, .1f
        };
        float[] values = new float[4] {
            10, 25, 50, 75
        };
        int amountOfLootboxes = 10;

        float[] lootboxWin = DistributionManager.PolinomialSample(chances, values, amountOfLootboxes);
        for (int i = 0; i < lootboxWin.Length; i++)
        {
            //CoinManager.AddCoins(lootbosWin[i]);
            Debug.Log(lootboxWin[i] + " Win of " + (i + 1).ToString() + " lootbox");
        }
        //End of first Example

        /* Example #2
         * Again lootboxes (my poor imagination)
         * You have values & chances, and need to know how much user will win at average
         */
        //I will use same chances and values, as in first example
        int amountOfSimulations = 10000;

        float[] lootboxWins = DistributionManager.PolinomialSample(chances, values, amountOfSimulations);
        float   averageWin  = DistributionManager.SampleMean(lootboxWin);

        Debug.Log(averageWin + " Average Win");

        //End of Example #2
    }
        public void HandleEvent(OrderPayedEventData eventData)
        {
            if (eventData.Order is ProductOrder)
            {
                ProductOrder order = eventData.Order as ProductOrder;

                //Distribution and ChannelAgency Rebate
                if ((DistributionWhen)Enum.Parse(typeof(DistributionWhen), SettingManager.GetSettingValue(ShopSettings.Distribution.DistributionWhen)) == DistributionWhen.Payed)
                {
                    AsyncHelper.RunSync(async() =>
                    {
                        List <OrderDistribution> orderDistributions   = await DistributionManager.TryAndCreateOrderDistributionAsync(order);
                        List <ChannelAgentRebate> channelAgentRebates = await ChannelAgentManager.TryAndCreateOrderChannelAgentRebatesAsync(order);

                        List <long> userList = new List <long>();

                        foreach (OrderDistribution orderDistribution in orderDistributions)
                        {
                            if (!userList.Contains(orderDistribution.UserId))
                            {
                                userList.Add(orderDistribution.UserId);
                            }
                        }
                        foreach (ChannelAgentRebate channelAgentRebate in channelAgentRebates)
                        {
                            if (!userList.Contains(channelAgentRebate.UserId))
                            {
                                userList.Add(channelAgentRebate.UserId);
                            }
                        }

                        foreach (long userId in userList)
                        {
                            WalletManager.WithdrawAllBalanceAsync(new UserIdentifier(order.TenantId, userId));
                        }
                    });
                }
            }
        }
        /// <summary>
        ///   Attempts to create a constructor's parameter. If the parameter doesn't
        ///   qualify as a valid parameter to be used in the automatic distribution
        ///   construction, the method fails and returns false.
        /// </summary>
        ///
        /// <param name="info">The parameter's reflection information.</param>
        /// <param name="owner">The constructor that should own this parameter.</param>
        /// <param name="parameter">The created distribution parameter.</param>
        ///
        /// <returns>True if the parameter could be created; false otherwise.</returns>
        ///
        public static bool TryParse(ParameterInfo info, ConstructorViewModel owner, out ParameterViewModel parameter)
        {
            parameter = null;

            DoubleRange range;

            if (!DistributionManager.TryGetRange(info, out range))
            {
                return(false);
            }

            double value;

            if (!DistributionManager.TryGetDefault(info, out value))
            {
                return(false);
            }

            parameter = new ParameterViewModel(info, owner, range, value);

            return(true);
        }
Esempio n. 17
0
 IEnumerator InstantiateNewPerson()
 {
     while (true)
     {
         if (DistributionManager.getDistrib())
         {
             numberOfPersonsTotal++;
             if (persons.Count < personsInsideLimit)
             {
                 GameObject newPerson     = Instantiate(PersonPrefab, Locations.Instance().getNewSpawnLocation(), Quaternion.identity) as GameObject;
                 GameObject currentPerson = GameObject.Find("Person(Clone)");
                 persons.Add(currentPerson);
                 currentPerson.name = "Person " + (persons.Count) as string;
             }
             else
             {
                 numberOfPersonsNotSpawned++;
             }
         }
         yield return(new WaitForSeconds(spawnTimeInterval));
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Attempts to create a new DistributionViewModel from a given type.
        /// </summary>
        public static bool TryParse(MainViewModel owner, Type type, Dictionary <string, DocumentationViewModel> doc, out DistributionViewModel distribution)
        {
            distribution = new DistributionViewModel(owner);

            if (!typeof(IUnivariateDistribution).IsAssignableFrom(type) || !doc.ContainsKey(type.Name))
            {
                return(false);
            }


            string name = DistributionManager.GetDistributionName(type);


            // Extract all properties with return value of double
            //
            var properties = new List <PropertyViewModel>();

            foreach (PropertyInfo prop in type.GetProperties())
            {
                PropertyViewModel property;
                if (PropertyViewModel.TryParse(prop, distribution, out property))
                {
                    properties.Add(property);
                }
            }

            // Extract buildable constructors. A constructor is
            // considered buildable if we can extract valid ranges
            // and default values from all of its parameters
            //
            var list = new List <ConstructorViewModel>();

            foreach (var ctor in type.GetConstructors())
            {
                ConstructorViewModel constructor;
                if (ConstructorViewModel.TryParse(ctor, distribution, out constructor))
                {
                    list.Add(constructor);
                }
            }

            if (list.Count == 0)
            {
                return(false);
            }

            // For the time being, just consider the buildable
            // constructor with the largest number of parameters.
            //
            var main = list.OrderByDescending(x => x.Parameters.Count).First();



            // Extract some documentation
            var documentation = doc[type.Name];

            documentation.Name = name;

            distribution.Constructor   = main;
            distribution.Properties    = new ObservableCollection <PropertyViewModel>(properties);
            distribution.Parameters    = main.Parameters;
            distribution.Type          = type;
            distribution.Name          = name;
            distribution.Documentation = documentation;


            foreach (var parameter in distribution.Constructor.Parameters)
            {
                parameter.ValueChanged += distribution.distribution_OnParameterChanged;
            }

            distribution.Options = DistributionManager.GetFittingOptions(distribution.Type);

            return(true);
        }
 private PropertyViewModel(PropertyInfo prop, DistributionViewModel distribution)
 {
     this.Property = prop;
     this.Owner    = distribution;
     this.Name     = DistributionManager.Normalize(prop.Name);
 }
Esempio n. 20
0
 public EngineTest()
 {
     distributionManager = new DistributionManager(pertInputs);
 }
 public RebateProductOrderPayedEventHandler(DistributionManager distributionManager)
 {
     DistributionManager = distributionManager;
 }
Esempio n. 22
0
        public MapReduceTask(CacheBase parent, TaskCallback callback,
                             IMapper mapper,
                             ICombinerFactory combiner,
                             IReducerFactory reducer,
                             MapReduceInput inputProvider,
                             MapReduceOutput outputProvider,
                             Filter filter, CacheRuntimeContext context, int chunkSize, int maxExceps)
        {
            this._parent       = parent;
            this.Callback      = callback;
            this._context      = context;
            this.maxExceptions = maxExceps;

            this.mapperTask = new MapperTask(mapper, inputProvider, filter != null ? filter.KeyFilter : null, this);

            if (reducer != null)
            {
                ReducerConfigured = true;
                this.reducerTask  = new ReducerTask(reducer, this);
            }
            else
            {
                ReducerConfigured = true;
                this.reducerTask  = new ReducerTask(new IdentityReducerFactory(), this);
            }
            if (combiner != null)
            {
                CombinerConfigured = true;
                this.combinerTask  = new CombinerTask(combiner, this);
            }

            throttlingMgr       = new MapReduceThrottlingManager(chunkSize, this);
            this.outputProvider = outputProvider;

            if (_parent != null && _parent is LocalCacheImpl)
            {
                isLocal      = true;
                participants = new Hashtable();
                participants.Add(new Address(_parent.Context.Render.IPAddress, _parent.Context.Render.Port), new NodeTaskStatus());
            }
#if !CLIENT
            if (_parent != null && _parent is ClusterCacheBase)
            {
                ArrayList   list = ((ClusterCacheBase)_parent).ActiveServers;
                IEnumerator it   = list.GetEnumerator();
                participants = new Hashtable();
                while (it.MoveNext())
                {
                    participants.Add(it.Current, new NodeTaskStatus());
                }

                if (parent is PartitionedServerCache)
                {
                    distributionMgr = ((PartitionedServerCache)parent).DistributionMgr;
                }
            }
#endif

            //Queue itialization and synchronization
            Queue syncQueue = Queue.Synchronized(reducerDataQueue);
            this.reducerDataQueue = syncQueue;
        }
Esempio n. 23
0
    protected override void Awake()
    {
        base.Awake();

        m_distributionManager = FindObjectOfType <DistributionManager>();
    }
        public void CalculateOrderShops()
        {
            int             totalLocations = 10;
            List <Location> locations      = new List <Location>();
            List <Road>     roads          = new List <Road>();
            List <Location> shops          = new List <Location>();
            List <Location> warehouses     = new List <Location>();


            //create a random amount of locations
            //for (int i = 0; i < totalLocations; i++)
            //{
            //    Location temp = new Location(rgn.Next(0, 100), rgn.Next(0, 100));
            //    locations.Add(temp);
            //}

            // I put IDs in the new locations because thats what the constructor was exptecting (Gave an error)
            Location temp = new Location(1, 0, 100);

            locations.Add(temp);
            Location temp2 = new Location(2, 10, 90);

            locations.Add(temp2);
            Location temp3 = new Location(3, 20, 80);

            locations.Add(temp3);
            Location temp4 = new Location(4, 34, 70);

            locations.Add(temp4);
            Location temp5 = new Location(5, 47, 60);

            locations.Add(temp5);
            Location temp6 = new Location(6, 55, 50);

            locations.Add(temp6);
            Location temp7 = new Location(7, 63, 40);

            locations.Add(temp7);
            //create a random amount of roads
            foreach (Location l1 in locations)
            {
                foreach (Location l2 in locations)
                {
                    if (l1 != l2)
                    {
                        Road tempi = new Road(l1, l2);
                        roads.Add(tempi);
                    }
                }
            }

            //populate the new locations with buildings
            foreach (var l in locations)
            {
                int        id            = l.LocationID;
                PictureBox picBox        = new PictureBox();
                PictureBox picBox1       = new PictureBox();
                Point      ImagePosition = new Point((l.Index.Column * Cell.CellSize) + 4, (l.Index.Row * Cell.CellSize) + 4);
                picBox.Location = ImagePosition;
                picBox.Size     = new Size(Cell.CellSize - 1, Cell.CellSize - 1);
                picBox.SizeMode = PictureBoxSizeMode.StretchImage;
                if (l == temp && l == temp4 && l == temp7)
                {
                    l.Building = new Shop(picBox, 19, 20);
                    shops.Add(l);

                    //lbLocationLog.Text = "Location #: " + id + " has been set to a Shop";
                    //  Console.WriteLine("Location #: " + id + " has been set to a Shop");
                }
                if (l == temp6)
                {
                    l.Building = new Warehouse(picBox);


                    Vehicle vehicle  = new Vehicle(picBox1);
                    Vehicle vehicle2 = new Vehicle(picBox1);

                    ((Warehouse)l.Building).AddVehicle(vehicle);
                    ((Warehouse)l.Building).AddVehicle(vehicle2);
                    warehouses.Add(l);
                }
            }

            // create a new distribution manager to test, it is supposed to make 3 deliveries for 3 shops that i created
            Dijkstra            d  = new Dijkstra(roads);
            DistributionManager dm = new DistributionManager(d, warehouses, shops);

            //Commented this out because it is giving an error.
            //dm.nextTick();

            Assert.Equal(3, dm.CreatedDeliveries.Count);
        }
Esempio n. 25
0
 private void Awake()
 {
     m_distributionManager = FindObjectOfType <DistributionManager>();
 }