Esempio n. 1
0
        public void CreateRouteFromMultiLineString(DJ_TourGroup group, string multiLineString, out string errMsg)
        {
            errMsg = string.Empty;
            group.Routes.Clear();
            IList<DJ_Route> allRoutes = new List<DJ_Route>();
            string[] arrSingleLine = multiLineString.Split(Environment.NewLine.ToCharArray()).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();

            Dictionary<EnterpriseType, IList<String>> entDicts = new Dictionary<EnterpriseType, IList<string>>();

            for (int i = 1; i <= arrSingleLine.Length; i++)
            {
                int dayNo = i;
                string currentLine = arrSingleLine[i - 1];
                string[] diffEnts = currentLine.Split(new char[] { ';', ';' });
                if (diffEnts.Length > 2 || diffEnts.Length == 0)
                {
                    errMsg = "格式错误:请用分号将景点和宾馆隔开." + currentLine;
                    return;
                }
                List<string> entNames = diffEnts[0].Split(new char[] { '\\', '\', '、' }).Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
                entDicts.Add(EnterpriseType.景点, entNames);
                List<string> entHotels = new List<string>();
                if (diffEnts.Length == 2)
                {
                    entHotels = diffEnts[1].Split(new char[] { '\\', '\', '、' }).Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
                    entDicts.Add(EnterpriseType.宾馆, entNames);
                }

                IList<DJ_Route> dayRoutes = CreateRouteFromNameList(dayNo, entDicts, out errMsg).Cast<DJ_Route>().ToList();
                allRoutes = allRoutes.Concat(dayRoutes).ToList();
            }
            foreach (DJ_Route r in allRoutes)
            {
                group.Routes.Add(r);
            }
            // group.Routes = allRoutes;
            // return allRoutes;
        }