Exemplo n.º 1
0
        public IList <TrainType> GetTrainStandardTypeInfo(int postID, int flag)
        {
            IList <TrainType> trainTypeList = new List <TrainType>();

            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_TRAIN_TYPE_G";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "p_traintype_id", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "p_post_id", DbType.Int32, postID);
            db.AddInParameter(dbCommand, "p_flag", DbType.Int32, flag);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    TrainType trainType = CreateModelObject(dataReader);

                    trainTypeList.Add(trainType);
                }
            }

            return(trainTypeList);
        }
Exemplo n.º 2
0
        private void BindGrid2()
        {
            CoursewareBLL coursewareBLL = new CoursewareBLL();
            IList <RailExam.Model.Courseware> coursewareList = new List <RailExam.Model.Courseware>();

            if (!string.IsNullOrEmpty(Request.QueryString.Get("id")))
            {
                TrainTypeBLL trainTypeBLL = new TrainTypeBLL();
                TrainType    trainType    = trainTypeBLL.GetTrainTypeInfo(Convert.ToInt32(ViewState["TrainAimID"].ToString()));
                coursewareList = coursewareBLL.GetCoursewaresByTrainTypeIDPath(trainType.IDPath, 1);
            }
            else
            {
                coursewareList = coursewareBLL.GetCoursewaresByCoursewareTypeOnline(PrjPub.CurrentLoginUser.StationOrgID,
                                                                                    Convert.ToInt32(ViewState["TrainAimID"].ToString()), "%", true,
                                                                                    5);
            }

            if (coursewareList.Count > 0)
            {
                foreach (RailExam.Model.Courseware courseware in coursewareList)
                {
                    if (courseware.CoursewareName.Length <= 15)
                    {
                        courseware.CoursewareName = "<a onclick=EditCourseware(" + courseware.CoursewareID + ") href=# title=" + courseware.CoursewareName + " > " + courseware.CoursewareName + " </a>";
                    }
                    else
                    {
                        courseware.CoursewareName = "<a onclick=EditCourseware(" + courseware.CoursewareID + ") href=# title=" + courseware.CoursewareName + " > " + courseware.CoursewareName.Substring(0, 15) + "..." + " </a>";
                    }
                }
                gvCourse.DataSource = coursewareList;
                gvCourse.DataBind();
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TrainEmployeeBLL objTrainEmployeeBll = new TrainEmployeeBLL();

            string str = Request.QueryString.Get("id");

            if (str != null && str != "")
            {
                ViewState["TrainTypeID"] = str;
            }
            else
            {
                if (PrjPub.StudentID == null)
                {
                    Response.Write("<script>alert('已超时,请注销后重新登录!');window.close();</script>");
                    return;
                }
                ViewState["TrainTypeID"] = objTrainEmployeeBll.GetTrainEmployeeByEmployeeID(PrjPub.CurrentStudent.EmployeeID).TrainTypeID.ToString();
            }

            if (ViewState["TrainTypeID"].ToString() == "0")
            {
                Response.Write("<script>alert('请选择培训类别!');window.close();</script>");
                return;
            }

            TrainTypeBLL objTrainTypeBll = new TrainTypeBLL();
            TrainType    objTrainType    = objTrainTypeBll.GetTrainTypeInfo(Convert.ToInt32(ViewState["TrainTypeID"].ToString()));

            lblDescription.Text = objTrainType.Description;
            lblMemo.Text        = objTrainType.Memo;

            BindGrid1();
            BindGrid2();
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,Name,Capacity,IsActive")] TrainType trainType, List <TrainTypeTravelClass> trainTypeTravelClasses)
        {
            if (ModelState.IsValid)
            {
                //check capacity
                if (trainTypeTravelClasses != null)
                {
                    int travelClassesCount = trainTypeTravelClasses.Sum(x => x.NumberOfSeats).Value;
                    if (travelClassesCount > trainType.Capacity)
                    {
                        ModelState.AddModelError("Capacity", "The sum of travel class seats should not exceed the capacity");
                        var travelClasses = db.TravelClasses.AsEnumerable <TravelClass>();
                        ViewBag.TravelClasses = travelClasses;
                        return(View(trainType));
                    }
                }
                db.TrainTypes.Add(trainType);
                db.SaveChanges();

                //Set TrainTypeId in trainTypeTravelClasses
                foreach (var item in trainTypeTravelClasses)
                {
                    item.TrainTypeId = trainType.Id;
                }

                db.TrainTypeTravelClasses.AddRange(trainTypeTravelClasses);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(trainType));
        }
Exemplo n.º 5
0
        public static void AssertDefaultTrains(this Opt testSubject, TrainType trainType, TrainAlgo trainAlgo)
        {
            AssertDefaults(testSubject);
            testSubject.Mode.Should().Be((int)OptMode.Train);

            testSubject.Type.Should().Be(trainType.GetDescription());
            testSubject.Algo.Should().Be(trainAlgo.GetDescription());
        }
Exemplo n.º 6
0
        public PartialViewResult GetScheduleTravelClassEdit(Schedule schedule)
        {
            TrainType trainType = schedule.TrainType;

            ViewBag.ScheduleTravelClasses = schedule.ScheduleTravelClasses.AsEnumerable();

            return(PartialView("_ScheduleTravelClassEdit", trainType));
        }
 /// <param name="origin">API response that was processed to make this statement</param>
 /// <param name="id">Identifies the train</param>
 /// <param name="from">Identifies the train</param>
 /// <param name="to">Station the train arrives to</param>
 /// <param name="type">Type of the train on this subrelation</param>
 public TrainSubrelationStatement(APIResponse origin, TrainIdStatement id, StationIdStatement from, StationIdStatement to, TrainType type)
     : base(origin)
 {
     Id   = id;
     From = from;
     To   = to;
     Type = type;
 }
Exemplo n.º 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            TrainType trainType = db.TrainTypes.Find(id);

            //db.TrainTypes.Remove(trainType);
            db.Entry(trainType).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 9
0
        private void BeginTrain(TrainItem[] trainItems, int group, int wordsCount, TrainType type)
        {
            this.trainItems = trainItems;
            this.group      = group;
            this.wordsCount = wordsCount;
            this.type       = type;

            index = 0;
            state = TrainState.Training;
        }
Exemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "Id,Name,Capacity,IsActive")] TrainType trainType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trainType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(trainType));
 }
 public ExerciseTypeStepanovAndRecentMemory(TrainType locType)
 {
     if (locType != TrainType.RecentMemory && locType != TrainType.Stepanov)
     {
         this.type = TrainType.None;
     }
     else
     {
         this.type = locType;
     }
 }
Exemplo n.º 12
0
        public TrainerCPU(TrainType trainType, IOptimizer optimizer)
        {
            TrainOptimizer   = optimizer;
            RandomSeed       = 12;
            TrainTypeSetting = trainType;
            BatchSize        = batchSize;
            random           = new Random(RandomSeed);

            L1Regularization = 0;
            L2Regularization = 0;
        }
Exemplo n.º 13
0
        public TrainerCPU(TrainType trainType)
        {
            TrainOptimizer   = new Optimizers.RMSProp();
            RandomSeed       = 12;
            TrainTypeSetting = trainType;
            BatchSize        = batchSize;
            random           = new Random(RandomSeed);

            L1Regularization = 0;
            L2Regularization = 0;
        }
Exemplo n.º 14
0
 // Trains
 public void SteamTrainPressed()
 {
     if (trainSelected != TrainType.Steam || !isTrain)
     {
         hidePrevious();
         isBuilding = false;
         isTrack    = false;
     }
     trainSelected     = TrainType.Steam;
     isTrain           = true;
     currentlyBuilding = true;
 }
Exemplo n.º 15
0
        private bool _trainStatShared(short id, TrainType type)
        {
            if (!m_client.ConnectedAndInitialized || !Initialized)
            {
                return(false);
            }

            Packet pkt = new Packet(PacketFamily.StatSkill, PacketAction.Add);

            pkt.AddChar((byte)type);
            pkt.AddShort(id);

            return(m_client.SendPacket(pkt));
        }
Exemplo n.º 16
0
        // GET: TrainTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TrainType trainType = db.TrainTypes.Find(id);

            if (trainType == null)
            {
                return(HttpNotFound());
            }
            return(View(trainType));
        }
Exemplo n.º 17
0
 public Vlak(string cisloVlaku, TrainType typ, JizdniRad cesta, string kolej, string nastupiste, Company drazniFirma, string aktualniStanice, string nazev)
 {
     cislo           = cisloVlaku;
     druh            = typ;
     jizda           = cesta;
     kolejVlaku      = kolej;
     nastupisteVlaku = nastupiste;
     firma           = drazniFirma;
     if (cilVlaku == null)
     {
         cilVlaku = jizda.trasa[jizda.trasa.Length - 1];
     }
     cas        = cesta.casy[aktualniStanice].casOdjezdu;
     nazevVlaku = nazev;
 }
Exemplo n.º 18
0
 public Train(GameWorld world, TrainSpawn trainSpawn)
 {
     this.world              = world;
     this.tile               = world.GetTile(trainSpawn.X, trainSpawn.Y) ?? throw new Exception($"Train at invalid position: [{trainSpawn.X}, {trainSpawn.Y}]");
     this.spawnTile          = tile;
     this.progressInsideTile = 0.5f;
     this.direction          = trainSpawn.Direction;
     this.tileEnterDirection = direction.Opposite();
     this.positionHistory    = new PositionStateHistory(1000, GetSnapshot());
     this.type               = trainSpawn.Type;
     this.color              = trainSpawn.Color;
     this.cars               = trainSpawn.InitialCars;
     this.initialCars        = this.cars;
     this.speed              = trainSpawn.Type.GetSpeed();
 }
Exemplo n.º 19
0
        protected void tvTrainTypeChangeCallBack_Callback(object sender, CallBackEventArgs e)
        {
            TrainTypeBLL objTrainType = new TrainTypeBLL();
            TrainType    traintype    = objTrainType.GetTrainTypeInfo(int.Parse(e.Parameters[0]));
            int          cout         = traintype.ParentID == 0 ? tvTrainType.Nodes.Count : tvTrainType.FindNodeById(traintype.ParentID.ToString()).Nodes.Count;

            if (e.Parameters[1] == "MoveUp")
            {
                if (traintype.OrderIndex <= cout && traintype.OrderIndex >= 2)
                {
                    traintype.OrderIndex--;
                    objTrainType.UpdateTrainType(traintype);

                    traintype = objTrainType.GetTrainTypeInfo(int.Parse(tvTrainType.FindNodeById(e.Parameters[0]).PreviousSibling.ID));
                    traintype.OrderIndex++;
                    objTrainType.UpdateTrainType(traintype);
                }
            }
            if (e.Parameters[1] == "MoveDown")
            {
                if (traintype.OrderIndex <= cout - 1 && traintype.OrderIndex >= 1)
                {
                    traintype.OrderIndex++;
                    objTrainType.UpdateTrainType(traintype);

                    traintype = objTrainType.GetTrainTypeInfo(int.Parse(tvTrainType.FindNodeById(e.Parameters[0]).NextSibling.ID));
                    traintype.OrderIndex--;
                    objTrainType.UpdateTrainType(traintype);
                }
            }

            if (e.Parameters[1] == "Insert")
            {
                IList <RailExam.Model.TrainType> objList = objTrainType.GetTrainTypeByWhereClause("1=1", "Train_Type_ID desc");
                hfMaxID.Value = objList[0].TrainTypeID.ToString();
                hfMaxID.RenderControl(e.Output);
            }
            else if (e.Parameters[1] == "Delete")
            {
                hfMaxID.Value = e.Parameters[2];
                hfMaxID.RenderControl(e.Output);
            }

            tvTrainType.Nodes.Clear();
            BindTrainTypeTree();

            tvTrainType.RenderControl(e.Output);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of <see cref="MetroLinkDetails"/>
 /// </summary>
 /// <param name="lineEndTime">line end time</param>
 /// <param name="lineStartTime">line start time</param>
 /// <param name="trainType">Train type</param>
 /// <param name="lineImage">line image</param>
 /// <param name="name">Line name</param>
 /// <param name="destinationStation">Destination station</param>
 /// <param name="sourceStation">Source station</param>
 /// <param name="saturdayService">Saturday service</param>
 /// <param name="sundayService">Sunday service</param>
 /// <param name="yearOfOperation">Year of Operation</param>
 public MetroLinkDetails(DateTime lineEndTime,
                         DateTime lineStartTime,
                         TrainType trainType,
                         LineImage lineImage,
                         string name,
                         string destinationStation,
                         string sourceStation,
                         bool saturdayService,
                         bool sundayService,
                         int yearOfOperation) : base(name, destinationStation, sourceStation, saturdayService, sundayService, yearOfOperation)
 {
     LineEndTime   = lineEndTime;
     LineImage     = lineImage;
     TrainType     = trainType;
     LineStartTime = lineStartTime;
 }
Exemplo n.º 21
0
        public ExerciseAttempt(TrainType type, DateTime dateStart, double time, bool autoCheck, string question, string answer, bool answerIsRight, string userAnswer)
        {
            this.type            = type;
            this.DateStart       = dateStart;
            this.Time            = time;
            this.AutoAnswerCheck = autoCheck;

            this.Question      = question;
            this.Answer        = answer;
            this.answerIsRight = answerIsRight;

            if (!answerIsRight)
            {
                this.UserAnswer = userAnswer;
            }
        }
Exemplo n.º 22
0
        public IList <TrainType> GetTrainTypeInfo(int trainTypeID,
                                                  int parentID,
                                                  int levelNum,
                                                  string iDPath,
                                                  int orderIndex,
                                                  string typeName,
                                                  string description,
                                                  bool isTemplate,
                                                  bool isPromotion,
                                                  string Memo,
                                                  int startRowIndex,
                                                  int maximumRows,
                                                  string orderBy)
        {
            IList <TrainType> trainTypeList = new List <TrainType>();

            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_TRAIN_TYPE_S";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            if (isTemplate == true)
            {
                db.AddInParameter(dbCommand, "p_is_template", DbType.Int32, 1);
            }
            if (parentID != 0)
            {
                db.AddInParameter(dbCommand, "p_parent_id", DbType.Int32, parentID);
            }

            db.AddInParameter(dbCommand, "p_start_row_index", DbType.Int32, startRowIndex);
            db.AddInParameter(dbCommand, "p_page_size", DbType.Int32, maximumRows);
            db.AddInParameter(dbCommand, "p_order_by", DbType.String, GetMappingOrderBy(orderBy));
            db.AddOutParameter(dbCommand, "p_count", DbType.Int32, 4);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    TrainType trainType = CreateModelObject(dataReader);

                    trainTypeList.Add(trainType);
                }
            }

            return(trainTypeList);
        }
Exemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (PrjPub.CurrentLoginUser == null)
                {
                    Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!");
                    return;
                }
                if (!string.IsNullOrEmpty(Request.QueryString.Get("id")))
                {
                    ViewState["TrainAimID"] = Request.QueryString.Get("id");
                    TrainTypeBLL trainTypeBLL = new TrainTypeBLL();
                    TrainType    trainType    = trainTypeBLL.GetTrainTypeInfo(Convert.ToInt32(ViewState["TrainAimID"].ToString()));

                    lblDescription.Text = trainType.Description;
                    lblMemo.Text        = trainType.Memo;
                }
                else
                {
                    ViewState["TrainAimID"] = Request.QueryString.Get("id1");
                    PostBLL postBll = new PostBLL();
                    Post    post    = postBll.GetPost(Convert.ToInt32(ViewState["TrainAimID"].ToString()));
                    lblDescription.Text = post.Description;
                    lblMemo.Text        = post.Memo;
                }

                BindGrid1();
                BindGrid2();
            }

            string strRefresh = Request.Form.Get("Refresh");

            if (!string.IsNullOrEmpty(strRefresh))
            {
                BindGrid1();
                BindGrid2();
            }

            //string strDeleteID = Request.Form.Get("DeleteID");
            //if (strDeleteID != null & strDeleteID != "")
            //{
            //    DeleteExercise(strDeleteID);
            //    BindGrid1();
            //    BindGrid2();
            //}
        }
Exemplo n.º 24
0
        /// <summary>
        /// Инструмент обучения.
        /// </summary>
        /// <param name="dataSet">Обучающая выборка.</param>
        /// <param name="trainType">Тип обучения.</param>
        /// <param name="hyperParameters">Гиперпараметры.</param>
        /// <param name="topology">Топология сети.</param>
        public TrainUtil(DataSet dataSet, TrainType trainType,
                         HyperParameters hyperParameters, Topology topology)
        {
            if (!trainType.Equals(TrainType.Backpropagation))
            {
                throw new NotImplementedException();
            }

            if (!topology.IsClosed)
            {
                throw new Exception("Топология сети не замкнута! Обучение невозможно!");
            }

            _trainType       = trainType;
            _dataSet         = dataSet;
            _hyperParameters = hyperParameters;
            _topology        = topology;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Создание экземпляра попытки по XmlNode.
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        public static ExerciseAttempt CreateFromXml(XmlNode xmlNode)
        {
            ExerciseAttempt result = new ExerciseAttempt();

            XmlAttribute attr;

            attr = xmlNode.Attributes[xmlFieldTrainType];

            if (attr != null && !string.IsNullOrEmpty(attr.Value))
            {
                TrainType type = (TrainType)Enum.Parse(typeof(TrainType), attr.Value);

                switch (type)
                {
                case TrainType.Date:
                    result = new ExerciseAttemptDate();
                    break;

                case TrainType.NetTrain:
                    result = new ExerciseAttemptNetTrain();
                    break;

                case TrainType.ConsecutiveAssociations:
                    result = new ExerciseAttemptAssociationsСonsecutive();
                    break;

                case TrainType.NumberAssociations:
                    result = new ExerciseAttemptAssociationsNumber();
                    break;

                case TrainType.AssociationsPair:
                    result = new ExerciseAttemptAssociationsPair();
                    break;

                default:
                    result = new ExerciseAttempt();
                    break;
                }
            }

            result.LoadAttributesFromXml(xmlNode);

            return(result);
        }
Exemplo n.º 26
0
    public void AddSegement(bool[] trains, TrainType[] Types, bool[] CoinsValues, int [] bonus)
    {
        bool[]      TrainsConfirmed    = new bool[RoadLenght];
        TrainType[] TypeConfirmed      = new TrainType[RoadLenght];
        bool[]      CoinValueConfirmed = new bool[RoadLenght];
        int[]       BonusConfirmed     = new int[RoadLenght];

        for (int i = 0; i < RoadLenght; i++)
        {
            TrainsConfirmed[i]    = trains[i];
            TypeConfirmed[i]      = Types[i];
            CoinValueConfirmed[i] = CoinsValues[i];
            BonusConfirmed[i]     = bonus[i];
        }

        TrainConfirmed.Add(TrainsConfirmed);
        trainTypes.Add(TypeConfirmed);
        CoinsConfirmed.Add(CoinValueConfirmed);
        this.BonusConfirmed.Add(BonusConfirmed);
    }
Exemplo n.º 27
0
        public IList <TrainType> GetTrainTypeByWhereClause(string whereClause, string orderby)
        {
            IList <TrainType> trainTypeList = new List <TrainType>();
            Database          db            = DatabaseFactory.CreateDatabase();
            DbCommand         dbCommand     = db.GetStoredProcCommand("USP_TrainType_WhereClause");

            db.AddInParameter(dbCommand, "p_sql", DbType.String, whereClause);
            db.AddInParameter(dbCommand, "p_order_by", DbType.String, orderby);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    TrainType trainType = CreateModelObject(dataReader);

                    trainTypeList.Add(trainType);
                }
            }

            return(trainTypeList);
        }
Exemplo n.º 28
0
        public IList <TrainType> GetTrainTypes()
        {
            IList <TrainType> trainTypeList = new List <TrainType>();
            Database          db            = DatabaseFactory.CreateDatabase();
            DbCommand         dbCommand     = db.GetStoredProcCommand("USP_GET_ALL");

            db.AddInParameter(dbCommand, "p_table_name", DbType.String, "TRAIN_TYPE");
            db.AddInParameter(dbCommand, "p_order_by", DbType.String, "LEVEL_NUM, ORDER_INDEX ASC");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    TrainType trainType = CreateModelObject(dataReader);

                    trainTypeList.Add(trainType);
                }
            }

            return(trainTypeList);
        }
Exemplo n.º 29
0
        private string GetTrainTypeNames(string strName, int nID)
        {
            string strTrainTypeName = string.Empty;

            if (nID != 0)
            {
                TrainTypeDAL trainTypeDAL = new TrainTypeDAL();
                TrainType    trainType    = trainTypeDAL.GetTrainTypeInfo(nID);

                if (trainType.ParentID != 0)
                {
                    strTrainTypeName = GetTrainTypeNames("/" + trainType.TypeName, trainType.ParentID) + strName;
                }
                else
                {
                    strTrainTypeName = trainType.TypeName + strName;
                }
            }

            return(strTrainTypeName);
        }
Exemplo n.º 30
0
        private string GetType(string strName, int nID)
        {
            string str = "";

            if (nID != 0)
            {
                TrainTypeBLL objTrainTypeBll = new TrainTypeBLL();
                TrainType    objTrainType    = objTrainTypeBll.GetTrainTypeInfo(nID);

                if (objTrainType.ParentID != 0)
                {
                    str = GetType(" - " + objTrainType.TypeName, objTrainType.ParentID) + strName;
                }
                else
                {
                    str = objTrainType.TypeName + strName;
                }
            }

            return(str);
        }
Exemplo n.º 31
0
 public Train(TrainType type)
 {
     Type = type;
 }
Exemplo n.º 32
0
		private bool _trainStatShared(short id, TrainType type)
		{
			if (!m_client.ConnectedAndInitialized || !Initialized)
				return false;

			Packet pkt = new Packet(PacketFamily.StatSkill, PacketAction.Add);
			pkt.AddChar((byte)type);
			pkt.AddShort(id);

			return m_client.SendPacket(pkt);
		}