bool TryToAddSideBuilding(Allotment newAllotment, Vector2 position, Vector2 side, float direction, float halfRoadWidth, float density)
    {
        Vector2 center = position + side * (newAllotment.Height * 0.5f + distanceFromRoad + halfRoadWidth);

        newAllotment.UpdateCenterAndDirection(center, direction);
        bool addBuilding = false;

        for (int i = 0; i < Config.allotmentPlacementLoopLimit; i++)
        {
            int     c = 0;
            Vector2 offset;
            var     colliders = roadNetwork.Quadtree.Retrieve(newAllotment.GetCollider().GetAABB());
            for (int j = 0; j < colliders.Count && (c == 0 || i < Config.allotmentPlacementLoopLimit - 1); j++)
            {
                if (newAllotment.GetCollider().Collide(((ICollidable)colliders[j].reference).GetCollider(), out offset))
                {
                    c++;
                    newAllotment.Center = (newAllotment.Center + offset);
                }
            }
            if (c == 0)
            {
                addBuilding = true;
                break;
            }
        }
        if (!addBuilding)
        {
            return(false);
        }
        allotments.Add(Tuple.Create(density, newAllotment));
        roadNetwork.Quadtree.Insert(newAllotment);
        return(true);
    }
示例#2
0
        public void editGarden(Allotment allotment)
        {
            Allotment myallotment = GetAllotment(allotment.gardenId);

            myallotment.size     = allotment.size;
            myallotment.postCode = allotment.postCode;

            _context.SaveChanges();
        }
示例#3
0
    public GameObject Build(Allotment allotment, IHeightmap heightmap)
    {
        GameObject allotmentGO = new GameObject("Allotment");
        float      z           = heightmap.GetHeight(allotment.Center.x, allotment.Center.y);

        allotmentGO.AddComponent <MeshFilter>().mesh       = StandardGeometry.CreateCubeMesh(allotment.Corners, height, z);
        allotmentGO.AddComponent <MeshRenderer>().material = material;
        return(allotmentGO);
    }
示例#4
0
        public ActionResult AddGardentoLocation(Allotment allotment)
        {
            try
            {
                // Adds a new garden to an allotment
                _gardenService.addGardentoAllotment(allotment);

                //Allocates the most recent garden
                _gardenService.AllocateGarden();

                return(RedirectToAction("Gardens", new { controller = "Garden" }));
            }
            catch (Exception ex)
            {
                //  Might be worth looking at redirection to an error page
                ViewBag.Exception = ex;
                return(View());
            }
        }
示例#5
0
    void Generate()
    {
        foreach (GameObject allotmentGO in allotments)
        {
            Destroy(allotmentGO);
        }
        allotments.Clear();
        var allotment = new Allotment(default(Vector2),
                                      0,
                                      UnityEngine.Random.Range(Config.allotmentMinHalfDiagonal, Config.allotmentMaxHalfDiagonal),
                                      UnityEngine.Random.Range(Config.allotmentMinAspect, Config.allotmentMaxAspect));

        foreach (var allotmentBuilder in allotmentBuilders)
        {
            GameObject allotmentGO = allotmentBuilder.Build(allotment, heightmap);
            Vector3    position    = allotmentGO.transform.position;
            allotmentGO.transform.position = position;
            allotments.Add(allotmentGO);
        }
    }
示例#6
0
        /// <summary>
        /// This method will find the best fit rooms for all the exams in a session
        /// </summary>
        /// <param name="session">The session for which rooms have to be alloted</param>
        /// <param name="roomsAvailable">The rooms available for allotment</param>
        /// <param name="allotments">The previous allotments</param>
        private List <Allotment> AllotStudentsForSession(Session session, List <Room> roomsAvailable, List <Allotment> allotments)
        {
            int studentsToAllot = session.Exams.Sum(x => x.Students.Count());

            do
            {
                foreach (var exam in session.Exams.ToList())
                {
                    Allotment allotment = FindBestFitForExam(exam, roomsAvailable, allotments);

                    if (allotment != null)
                    {
                        allotment.Room.Exams.Add(allotment.Exam);
                        allotments.Add(allotment);
                        studentsToAllot -= allotment.NumberOfStudents;
                    }
                }
            } while (studentsToAllot > 0);

            return(allotments);
        }
示例#7
0
        public ActionResult EditGarden(string pcode, GardenViewModel gardenViewModel, Allotment allotment)
        {
            try
            {
                Allotment myAllotment = new Allotment
                {
                    gardenId = gardenViewModel.gardenId,
                    size     = gardenViewModel.size,
                    postCode = gardenViewModel.postCode
                };

                _gardenService.editGarden(myAllotment);

                return(RedirectToAction("Gardens", new { controller = "Garden" }));
            }
            catch (Exception ex)
            {
                //Might be worth looking at redirection to an error page
                ViewBag.Exception = ex;
                return(View());
            }
        }
示例#8
0
 public void addGardentoAllotment(Allotment allotment)
 {
     _context.Allotment.Add(allotment);
     _context.SaveChanges();
 }
示例#9
0
 public void addGardenLocation(GardenLocation gardenLocation, Allotment allotment)
 {
     _context.GardenLocation.Add(gardenLocation);
     _context.Allotment.Add(allotment);
     _context.SaveChanges();
 }
示例#10
0
 public void addGardentoAllotment(Allotment allotment)
 {
     _gardenDAO.addGardentoAllotment(allotment);
 }
示例#11
0
 public void addGardenLocation(GardenLocation gardenLocation, Allotment allotment)
 {
     _gardenDAO.addGardenLocation(gardenLocation, allotment);
 }
示例#12
0
 public void editGarden(Allotment allotment)
 {
     _gardenDAO.editGarden(allotment);
 }
示例#13
0
        public Allotment GetAllotmentRecord(string recordID, string UserSNo)
        {
            Allotment     allotment = new Allotment();
            SqlDataReader dr        = null;

            try
            {
                SqlParameter[] Parameters = { new SqlParameter("@SNo", recordID), new SqlParameter("@UserID", Convert.ToInt32(UserSNo)) };
                dr = SqlHelper.ExecuteReader(DMLConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordAllotment", Parameters);
                if (dr.Read())
                {
                    allotment.SNo                     = Convert.ToInt32(dr["SNo"]);
                    allotment.IsSector                = Convert.ToInt32(dr["IsSector"]);
                    allotment.Sector                  = dr["Sector"].ToString();
                    allotment.OriginSNo               = String.IsNullOrEmpty(dr["OriginSNo"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["OriginSNo"]);
                    allotment.Text_OriginSNo          = dr["Text_OriginSNo"].ToString();
                    allotment.DestinationSNo          = String.IsNullOrEmpty(dr["DestinationSNo"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["DestinationSNo"]);
                    allotment.Text_DestinationSNo     = dr["Text_DestinationSNo"].ToString();
                    allotment.FlightNo                = String.IsNullOrEmpty(dr["ScheduleTransSNo"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["ScheduleTransSNo"]);
                    allotment.Text_FlightNo           = dr["Text_FlightNo"].ToString();
                    allotment.TotalGross              = dr["TotalGross"].ToString();
                    allotment.TotalVolume             = dr["TotalVolume"].ToString();
                    allotment.ReserveGross            = dr["ReserveGross"].ToString();
                    allotment.ReserveVolume           = dr["ReserveVolume"].ToString();
                    allotment.TotalGrossUnit          = dr["TotalGrossUnit"].ToString();
                    allotment.TotalVolumeUnit         = dr["TotalVolumeUnit"].ToString();
                    allotment.ReserveGrossUnit        = dr["ReserveGrossUnit"].ToString();
                    allotment.ReserveVolumeUnit       = dr["ReserveVolumeUnit"].ToString();
                    allotment.AllotmentType           = Convert.ToInt32(dr["AllotmentType"]);
                    allotment.Text_AllotmentType      = dr["Text_AllotmentType"].ToString();
                    allotment.OfficeSNo               = String.IsNullOrEmpty(dr["OfficeSNo"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["OfficeSNo"]);
                    allotment.Text_OfficeSNo          = String.IsNullOrEmpty(dr["Text_OfficeSNo"].ToString()) == true ? "" : dr["Text_OfficeSNo"].ToString();
                    allotment.AccountSNo              = String.IsNullOrEmpty(dr["AccountSNo"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["AccountSNo"]);
                    allotment.Text_AccountSNo         = String.IsNullOrEmpty(dr["Text_AccountSNo"].ToString()) == true ? "" : dr["Text_AccountSNo"].ToString();
                    allotment.ShipperAccountSNo       = String.IsNullOrEmpty(dr["ShipperAccountSNo"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["ShipperAccountSNo"]);
                    allotment.Text_ShipperAccountSNo  = String.IsNullOrEmpty(dr["Text_ShipperAccountSNo"].ToString()) == true ? "" : dr["Text_ShipperAccountSNo"].ToString();
                    allotment.GrossWeightType         = Convert.ToInt32(dr["GrossWeightType"]);
                    allotment.Text_GrossWeightType    = dr["Text_GrossWeightType"].ToString();
                    allotment.GrossWeight             = Convert.ToDecimal(dr["GrossWeight"]);
                    allotment.VolumeWeightType        = Convert.ToInt32(dr["VolumeWeightType"]);
                    allotment.Text_VolumeWeightType   = dr["Text_VolumeWeightType"].ToString();
                    allotment.VolumeWeight            = Convert.ToDecimal(dr["VolumeWeight"]);
                    allotment.ValidFrom               = Convert.ToDateTime(dr["ValidFrom"]);
                    allotment.ValidTo                 = Convert.ToDateTime(dr["ValidTo"]);
                    allotment.CommodityType           = String.IsNullOrEmpty(dr["CommodityType"].ToString()) == true ? (Int32?)null : Convert.ToInt32(dr["CommodityType"]);
                    allotment.Text_CommodityType      = dr["Text_CommodityType"].ToString();
                    allotment.Commodity               = dr["Commodity"].ToString();
                    allotment.Text_Commodity          = dr["Text_Commodity"].ToString();
                    allotment.ProductType             = String.IsNullOrEmpty(dr["ProductType"].ToString()) == true? (Int32?)null : Convert.ToInt32(dr["ProductType"]);
                    allotment.Text_ProductType        = dr["Text_ProductType"].ToString();
                    allotment.ProductSNo              = dr["ProductSNo"].ToString();
                    allotment.Text_ProductSNo         = dr["Text_ProductSNo"].ToString();
                    allotment.Days                    = dr["Days"].ToString();
                    allotment.Text_Days               = dr["Text_Days"].ToString();
                    allotment.IsActive                = Convert.ToBoolean(dr["IsActive"]);
                    allotment.Active                  = dr["Active"].ToString();
                    allotment.CreatedBy               = dr["CreatedUser"].ToString();
                    allotment.UpdatedBy               = dr["UpdatedUser"].ToString();
                    allotment.AllotmentCode           = dr["AllotmentCode"].ToString();
                    allotment.FlightValidFrom         = dr["FlightValidFrom"].ToString();
                    allotment.FlightValidTo           = dr["FlightValidTo"].ToString();
                    allotment.IsUsed                  = dr["IsUsed"].ToString();
                    allotment.SHC                     = dr["SHC"].ToString();
                    allotment.Text_SHC                = dr["Text_SHC"].ToString();
                    allotment.SHCType                 = String.IsNullOrEmpty(dr["SHCType"].ToString()) ? (Int32?)null : Convert.ToInt32(dr["SHCType"]);
                    allotment.Text_SHCType            = dr["Text_SHCType"].ToString();
                    allotment.FlightDaysOfOps         = dr["FlightDaysOfOps"].ToString();
                    allotment.GrossWeightVariance_P   = Convert.ToInt32(dr["GrossWeightVariance_P"]);
                    allotment.GrossWeightVariance_N   = Convert.ToInt32(dr["GrossWeightVariance_N"]);
                    allotment.VolumeVariance_P        = Convert.ToInt32(dr["VolumeVariance_P"]);
                    allotment.VolumeVariance_N        = Convert.ToInt32(dr["VolumeVariance_N"]);
                    allotment.AllotmentReleaseTime    = dr["AllotmentReleaseTime"].ToString();
                    allotment.AllotmentReleaseTimeHr  = Convert.ToInt32(dr["AllotmentReleaseTimeHr"]);
                    allotment.AllotmentReleaseTimeMin = Convert.ToInt32(dr["AllotmentReleaseTimeMin"]);
                    allotment.AirlineSNo              = Convert.ToInt32(dr["AirlineSNo"]);
                    allotment.Text_AirlineSNo         = dr["Text_AirlineSNo"].ToString();
                    allotment.IsMandatory             = Convert.ToBoolean(dr["IsMandatory"]);
                    allotment.Mandatory               = dr["Mandatory"].ToString();
                }
            }
            catch (Exception ex)// (Exception e)
            {
                dr.Close();
            }
            dr.Close();
            return(allotment);
        }
    void Start()
    {
        if (roadNetwork == null)
        {
            Debug.LogError("RoadDensityBasedSettlementSpawner needs a reference to a RoadNetwork");
            return;
        }

        if (!roadNetwork.Finished)
        {
            Debug.LogError("RoadDensityBasedSettlementSpawner script can only execute after RoadNetwork (Configure execution order that in Edit > Project Settings > Script Execution Order)");
            return;
        }

        if (roadDensityMap == null)
        {
            Debug.LogError("RoadDensityBasedSettlementSpawner needs a reference to a RoadDensityMap");
            return;
        }

        if (!roadDensityMap.Finished())
        {
            Debug.LogError("RoadDensityBasedSettlementSpawner script can only execute after RoadDensityMap (Configure execution order that in Edit > Project Settings > Script Execution Order)");
            return;
        }

        if (heightmapGameObject != null)
        {
            heightmap = UnityEngineHelper.GetInterface <IHeightmap>(heightmapGameObject);
        }

        if (heightmap == null)
        {
            Debug.LogError("RoadDensityBasedSettlementSpawner needs a reference to a game object containing at least one component that implements IHeightmap");
            return;
        }

        if (!heightmap.Finished())
        {
            Debug.LogError("RoadDensityBasedSettlementSpawner script can only execute after the components that implements IHeightmap (Configure execution order that in Edit > Project Settings > Script Execution Order)");
            return;
        }

        List <IAllotmentBuilder> allotmentBuilders = null;

        if (allotmentBuilderGameObject != null)
        {
            allotmentBuilders = UnityEngineHelper.GetInterfaces <IAllotmentBuilder>(allotmentBuilderGameObject);
        }
        if (allotmentBuilders == null)
        {
            Debug.LogError("RoadDensityBasedSettlementSpawner needs a reference to a game object containing at least one component that implements IAllotmentBuilder");
            return;
        }

        {
            float minThreshold = -float.MaxValue;
            foreach (var densityTier in densityTiers)
            {
                if (densityTier.threshold < minThreshold)
                {
                    Debug.LogError("Density tier has a threshold smaller than it's predecessor");
                    return;
                }
                minThreshold = densityTier.threshold;
            }
        }

        minAllotmentWidth = Allotment.GetWidth(Config.allotmentMinHalfDiagonal, Config.allotmentMinAspect);

        allotments = new List <Tuple <float, Allotment> >();
        HashSet <Segment> visited = new HashSet <Segment>();

        foreach (var segment in roadNetwork.Segments)
        {
            RoadNetworkTraversal.PreOrder(segment, SegmentVisitor, roadNetwork.Mask, ref visited);
        }
        if (maxNumAllotments > 0 && allotments.Count > maxNumAllotments)
        {
            allotments.Sort((a, b) => b.Item1.CompareTo(a.Item1));
            allotments = allotments.GetRange(0, maxNumAllotments);
        }
        GameObject allotmentsGO = new GameObject("Allotments");

        allotmentsGO.transform.parent = transform;
        {
            foreach (var allotment in allotments)
            {
                foreach (var allotmentBuilder in allotmentBuilders)
                {
                    GameObject allotmentGO = allotmentBuilder.Build(allotment.Item2, heightmap);
                    allotmentGO.transform.parent = allotmentsGO.transform;
                }
            }
        }
        Debug.Log(allotments.Count + " allotments spawned");
    }
        protected void grButton_Click(object sender, EventArgs e)
        {
            int[] r         = (int[])Application["round"];
            int   programno = Int32.Parse(progDropDownList.SelectedValue);
            int   roundno   = r[programno - 1];

            try
            {
                admissionEntities ae = new admissionEntities();
                Round             r1 = ae.Rounds.Where(s => s.round_id == roundno && s.program_id == programno).FirstOrDefault <Round>();
                if (r1 != null && r1.end_date != null)
                {
                    DateTime today   = DateTime.Now;
                    int      compare = DateTime.Compare((DateTime)r1.end_date, today);
                    if (compare >= 0)
                    {
                        string message = "Round Is Not Yet Completed";
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append("<script type = 'text/javascript'>");
                        sb.Append("window.onload=function(){");
                        sb.Append("alert('");
                        sb.Append(message);
                        sb.Append("')};");
                        sb.Append("</script>");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                    }
                    else
                    {
                        string resultstatus = r1.result_generated;
                        if (resultstatus != null && resultstatus.Equals("yes"))
                        {
                            string message = "Result is alredy generated";
                            System.Text.StringBuilder sb = new System.Text.StringBuilder();
                            sb.Append("<script type = 'text/javascript'>");
                            sb.Append("window.onload=function(){");
                            sb.Append("alert('");
                            sb.Append(message);
                            sb.Append("')};");
                            sb.Append("</script>");
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                        }
                        else
                        {
                            var choicelist = from y in ae.Available_Choice where y.program_id == programno select y;
                            int size       = choicelist.Count();
                            Dictionary <int, int> genlist = new Dictionary <int, int>(size);
                            Dictionary <int, int> obclist = new Dictionary <int, int>(size);
                            Dictionary <int, int> sclist  = new Dictionary <int, int>(size);
                            Dictionary <int, int> stlist  = new Dictionary <int, int>(size);
                            foreach (var cl in choicelist)
                            {
                                genlist.Add(cl.choice_id, (int)cl.gen);
                                obclist.Add(cl.choice_id, (int)cl.obc);
                                sclist.Add(cl.choice_id, (int)cl.sc);
                                stlist.Add(cl.choice_id, (int)cl.st);
                            }

                            var studentlist = from c in ae.StudentDetails where c.program == programno orderby c.rank select c;
                            foreach (var sl in studentlist)
                            {
                                string sid = sl.std_id;
                                var    sc  = from x in ae.Student_Choice where x.std_id == sid orderby x.preference_no select x;
                                var    cat = from b in ae.StudentDetails
                                             where b.std_id == sid
                                             select b.std_category;
                                int category = 0;
                                foreach (var cat1 in cat)
                                {
                                    category = cat1.Value;
                                    break;
                                }
                                Boolean   addflag = false;
                                Allotment al      = ae.Allotments.Where(s => s.std_id == sid).FirstOrDefault <Allotment>();
                                if (al == null)
                                {
                                    al        = new Allotment();
                                    addflag   = true;
                                    al.std_id = sid;
                                }
                                Boolean okflag = false;
                                foreach (var sc1 in sc)
                                {
                                    int pref = (int)sc1.preference_no;
                                    int cid  = sc1.choice_id;
                                    int noofseats;
                                    switch (category)
                                    {
                                    case 1:
                                        noofseats = genlist[cid];
                                        if (noofseats > 0)
                                        {
                                            genlist[cid]--;
                                            al.alloted_choice_id = cid;
                                            al.preference_no     = pref;
                                            al.confirm_status    = 0;
                                            al.round_no          = roundno;
                                            if (addflag)
                                            {
                                                ae.Allotments.Add(al);
                                            }
                                            okflag = true;
                                        }
                                        break;

                                    case 2:
                                        noofseats = obclist[cid];
                                        if (noofseats > 0)
                                        {
                                            obclist[cid]--;
                                            al.alloted_choice_id = cid;
                                            al.preference_no     = pref;
                                            al.confirm_status    = 0;
                                            if (addflag)
                                            {
                                                ae.Allotments.Add(al);
                                            }
                                            okflag = true;
                                        }
                                        break;

                                    case 3:
                                        noofseats = sclist[cid];
                                        if (noofseats > 0)
                                        {
                                            sclist[cid]--;
                                            al.alloted_choice_id = cid;
                                            al.preference_no     = pref;
                                            al.confirm_status    = 0;
                                            if (addflag)
                                            {
                                                ae.Allotments.Add(al);
                                            }
                                            okflag = true;
                                        }
                                        break;

                                    case 4:
                                        noofseats = stlist[cid];
                                        if (noofseats > 0)
                                        {
                                            stlist[cid]--;
                                            al.alloted_choice_id = cid;
                                            al.preference_no     = pref;
                                            al.confirm_status    = 0;
                                            if (addflag)
                                            {
                                                ae.Allotments.Add(al);
                                            }
                                            okflag = true;
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                    if (okflag)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                r1.result_generated = "yes";
                ae.SaveChanges();
            }
            catch (Exception err)
            {
            }
        }