예제 #1
0
        public void CreateSequentialStopInfo(long stationCodeF, long stationCodeS)
        {
            string exception      = "";
            bool   foundException = false;

            try
            {
                //goodCode
            }
            catch (Exception ex)
            {
                exception     += ex.Message;
                foundException = true;
            }
            try
            {
                //goodCode
            }
            catch (Exception ex)
            {
                exception     += ex.Message;
                foundException = true;
            }
            if (foundException)
            {
                throw new Exception(exception);
            }
            Stop               stopA                = GetStop(stationCodeF);
            Stop               stopB                = GetStop(stationCodeS);
            double             distance             = GteDistance(stopA.Latitude, stopA.Longitude, stopB.Latitude, stopB.Longitude);
            SequentialStopInfo SequentialStopInfoBO = new SequentialStopInfo(stationCodeF, stationCodeS, distance, TimeSpan.FromSeconds(distance / 50));  //@@@@ /

            DO.SequentialStopInfo SequentialStopInfoDO = SequentialStopInfoBO.GetPropertiesFrom <DO.SequentialStopInfo, BO.SequentialStopInfo>();
            dal.CreateSequentialStopInfo(SequentialStopInfoDO);
        }
예제 #2
0
 public void DeleteSequentialStopInfo(SequentialStopInfo sequentialStopInfo)
 {
     if (sequentialStopInfo.stationCodeF != null && sequentialStopInfo.stationCodeS != null)
     {
         DataSource.Sequential_Stop_InfoList.Remove(sequentialStopInfo);
     }
     else
     {
         throw new Exception("sequentialStopInfo doesn't exist!!");
     }
 }
        /// <summary>
        /// request a SequentialStopInfo according to a predicate
        /// </summary>
        /// <param name="firstId"></param>
        /// <param name="secondId"></param>
        /// <returns></returns>
        public SequentialStopInfo RequestSequentialStopInfo(Predicate <SequentialStopInfo> pr)
        {
            SequentialStopInfo ret = DataSource.SequentialStopInfoList.Find(seqStop => pr(seqStop));

            if (ret == null)
            {
                throw new Exception("no seqStop that meets these conditions!");
            }
            if (ret.Valid == false)
            {
                throw new Exception("seqStop that meets these conditions is not valid");
            }
            return(ret.GetPropertiesFrom <SequentialStopInfo, SequentialStopInfo>());
        }
예제 #4
0
        public void UpdateSequentialStopInfo(SequentialStopInfo sequentialStopInfo)
        {
            int indLine;

            if (sequentialStopInfo.stationCodeF != null && sequentialStopInfo.stationCodeS != null)
            {
                indLine = DataSource.Sequential_Stop_InfoList.FindIndex(s => s.stationCodeF == sequentialStopInfo.stationCodeF && s.stationCodeS == sequentialStopInfo.stationCodeS);
                DataSource.Sequential_Stop_InfoList[indLine] = sequentialStopInfo;
            }
            else
            {
                throw new Exception("sequentialStopInfo doesn't exist!!");
            }
        }
 /// <summary>
 /// add new sequentialStopInfo to database
 /// </summary>
 /// <param name="sequentialStopInfo"></param>
 public void CreateSequentialStopInfo(SequentialStopInfo sequentialStopInfo)
 {
     sequentialStopInfo.Valid = true;
     try
     {
         GetSequentialStopInfo(sequentialStopInfo.StationCodeF, sequentialStopInfo.StationCodeS);
     }
     catch (Exception ex)
     {
         if (ex.Message == "no seqStop that meets these conditions!")
         {
             DataSource.SequentialStopInfoList.Add(sequentialStopInfo);
         }
         else if (ex.Message == "SequentialStopInfoList is not valid!!")
         {
             DataSource.SequentialStopInfoList.Find(seqStopInf => seqStopInf.StationCodeF == sequentialStopInfo.StationCodeF && seqStopInf.StationCodeS == sequentialStopInfo.StationCodeS).Valid = true;
         }
         return;
     }
     throw new Exception("Sequential stop already exists!!!");
 }
        public void CreateSequentialStopInfo(SequentialStopInfo sequentialStopInfo)
        {
            XElement userRootElem = XMLTools.LoadListFromXMLElement(sequentialStopInfoPath);

            sequentialStopInfo.Valid = true;

            try
            {
                GetSequentialStopInfo(sequentialStopInfo.StationCodeF, sequentialStopInfo.StationCodeS);
            }

            catch (Exception ex)
            {
                if (ex.Message == "no SequentialStopInfo with such license number!!")
                {
                    XElement sequentialStopInfoElem = new XElement("SequentialStopInfo",
                                                                   new XElement("Valid", sequentialStopInfo.Valid.ToString()),
                                                                   new XElement("StationCodeF", sequentialStopInfo.StationCodeF),
                                                                   new XElement("StationCodeS", sequentialStopInfo.StationCodeS),
                                                                   new XElement("Distance", sequentialStopInfo.Distance),
                                                                   new XElement("AverageTime", ""),
                                                                   new XElement("TravelTime", XmlConvert.ToString(sequentialStopInfo.TravelTime)));

                    userRootElem.Add(sequentialStopInfoElem);
                    XMLTools.SaveListToXMLElement(userRootElem, sequentialStopInfoPath);
                }
                else if (ex.Message == "SequentialStopInfoList is not valid!!")
                {
                    XElement per = (from temSeq in userRootElem.Elements()
                                    where temSeq.Element("StationCodeF").Value == sequentialStopInfo.StationCodeF.ToString() && temSeq.Element("StationCodeS").Value == sequentialStopInfo.StationCodeS.ToString()
                                    select temSeq).FirstOrDefault();

                    per.Element("Valid").Value = sequentialStopInfo.Valid.ToString();

                    XMLTools.SaveListToXMLElement(userRootElem, sequentialStopInfoPath);
                }
                return;
            }
            throw new Exception("sequentialStopInfo already exists!!!");
        }
예제 #7
0
 public void CreateSequentialStopInfo(SequentialStopInfo sequentialStopInfo)
 {
     DataSource.Sequential_Stop_InfoList.Add(sequentialStopInfo);
 }