Home.cs 292 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using OASystem.Domain.Dtos.CRM;
  4. using OASystem.Domain.Dtos.QiYeWeChat;
  5. using OASystem.Domain.Entities.Groups;
  6. using OASystem.Domain.Entities.Resource;
  7. using OASystem.Domain.Enums;
  8. using OpenAI.GPT3.ObjectModels;
  9. using SqlSugar;
  10. using System.Data;
  11. using System.Net;
  12. using System.Text.RegularExpressions;
  13. using static QRCoder.PayloadGenerator;
  14. using System.Windows.Forms;
  15. using Microsoft.Data.SqlClient;
  16. using OASystem.Domain.Entities.Customer;
  17. using Aspose.Words;
  18. using Bookmark = Aspose.Words.Bookmark;
  19. using OASystem.Domain.ViewModels.QiYeWeChat;
  20. using NPOI.SS.UserModel;
  21. using System.Collections;
  22. namespace OpWin
  23. {
  24. public partial class Home : Form
  25. {
  26. static List<Grp_DelegationInfo> soure = null;
  27. const string OA2023DB = "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2023DB;MultipleActiveResultSets=True;";
  28. SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
  29. {
  30. ConfigId = DBEnum.OA2023DB,
  31. ConnectionString = OA2023DB,
  32. DbType = SqlSugar.DbType.SqlServer,
  33. IsAutoCloseConnection = true
  34. });
  35. public Home()
  36. {
  37. InitializeComponent();
  38. }
  39. string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  40. private void Home_Load(object sender, EventArgs e)
  41. {
  42. comb_Delegation.ValueMember = "Id";
  43. comb_Delegation.DisplayMember = "TeamName";
  44. soure = Db.Queryable<Grp_DelegationInfo>().Where(x=>x.IsDel == 0).ToList();
  45. comb_Delegation.Items.AddRange(soure.ToArray());
  46. comb_Delegation.DropDownHeight = 200;
  47. }
  48. private void btnOutput_Click(object sender, EventArgs e)
  49. {
  50. lblOutputResult.Text = "文件正在导出...";
  51. lblOutputResult.ForeColor = Color.Black;
  52. //数据源
  53. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  54. int diid = 0;
  55. try
  56. {
  57. var dele = (comb_Delegation.SelectedItem as Grp_DelegationInfo);
  58. diid = dele.Id;
  59. }
  60. catch (Exception)
  61. {
  62. lblOutputResult.Text = "请选择正确的团组!";
  63. lblOutputResult.ForeColor = Color.Black;
  64. MessageBox.Show("请选择正确的团组!");
  65. return;
  66. }
  67. DataTable dtBlack = null;
  68. try
  69. {
  70. dtBlack = GetTableByBlackCode(diid);
  71. }
  72. catch (Exception)
  73. {
  74. lblOutputResult.Text = "机票黑屏代码有误!";
  75. lblOutputResult.ForeColor = Color.Black;
  76. MessageBox.Show("机票黑屏代码有误!");
  77. return;
  78. }
  79. Grp_DelegationInfo di = Db.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  80. if (di == null)
  81. {
  82. lblOutputResult.Text = "请选择正确的团组!";
  83. lblOutputResult.ForeColor = Color.Black;
  84. MessageBox.Show("请选择正确的团组!");
  85. return;
  86. }
  87. string CityStr1 = "";
  88. List<string> countriesList = new List<string>();
  89. List<string> cityList = new List<string>();
  90. string countriesIntroduction = "";
  91. string cityIntroduction = "";
  92. string timeDifference = "";
  93. string currExchangeRate = "";
  94. string txt_itemPrepare = "";
  95. string txt_specialReminder = "";
  96. string txt_cGPrecautions = "";
  97. string txt_yGCG = "";
  98. string txt_conduct = "";
  99. string txt_commonEnglish = "";
  100. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  101. {
  102. //提示
  103. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  104. }
  105. else
  106. {
  107. //创建三字码示例
  108. Res_ThreeCode t = new Res_ThreeCode();
  109. //城市缓存
  110. string city = "";
  111. //出访城市
  112. for (int i = 0; i < dtBlack.Rows.Count; i++)
  113. {
  114. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  115. {
  116. continue;
  117. }
  118. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  119. {
  120. //出发城市
  121. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  122. t = Db.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0 );
  123. if (t != null)
  124. {
  125. city = city + "/" + t.City;
  126. }
  127. else
  128. {
  129. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  130. }
  131. if (i == dtBlack.Rows.Count - 1)
  132. {
  133. //抵达城市
  134. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  135. t = Db.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  136. if (t != null)
  137. {
  138. city = city + "/" + t.City;
  139. }
  140. else
  141. {
  142. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  143. }
  144. }
  145. }
  146. }
  147. if (city != "" && city != null)
  148. {
  149. string[] cityStr2 = city.Split('/');
  150. string[] strs = cityStr2.Distinct().ToArray(); ;
  151. string str = "";
  152. foreach (var s in strs)
  153. {
  154. str += s + "/";
  155. }
  156. str = str.TrimStart('/');
  157. str = str.TrimEnd('/');
  158. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  159. CityStr1 = city.TrimStart('/');
  160. }
  161. //opitineraryService opitservice = new opitineraryService();
  162. ////城市不为空
  163. //if (!string.IsNullOrEmpty(city))
  164. //{
  165. // cityList = city.TrimStart('/').Split('/').ToList();
  166. // if (cityList.Count > 1)
  167. // {
  168. // cityList.RemoveAt(0);
  169. // }
  170. // opitinerarydata cityData = opitservice.getDaFirstData(cityList[0]);
  171. // cityIntroduction = cityData.Introduction;
  172. // timeDifference = cityData.TimeDifference;
  173. // currExchangeRate = cityData.CurrExchangeRate.ToString();
  174. //}
  175. ////国家不为空
  176. //if (!string.IsNullOrEmpty(di.VisitCountry))
  177. //{
  178. // countriesList = di.VisitCountry.Split(' ').ToList();
  179. // opitinerarydata Country = opitservice.getDaFirstData(countriesList[0]);
  180. // countriesIntroduction = Country.Introduction == null ? "" : Country.Introduction;
  181. //}
  182. ////取出固定标语
  183. //opitineraryfixed fixedData = opitservice.getFiFirstData();
  184. ////if (!string.IsNullOrEmpty(fixedData.Tid.ToString()))
  185. ////{
  186. ////}
  187. //txt_cGPrecautions = fixedData.CGPrecautions;
  188. //txt_commonEnglish = fixedData.CommonEnglish;
  189. //txt_conduct = fixedData.Conduct;
  190. //txt_itemPrepare = fixedData.ItemPrepare;
  191. //txt_specialReminder = fixedData.SpecialReminder;
  192. //txt_yGCG = fixedData.YGCG;
  193. // 行程repeater
  194. if (GetByDiid(diid).Count > 0)
  195. {
  196. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  197. }
  198. else
  199. {
  200. //生成该时间段日期
  201. List<string> timeList = GetTimeListByDataTable(dtBlack);
  202. if (timeList != null)
  203. {
  204. string[] str = new string[timeList.Count];
  205. //rpData.DataSource = str;
  206. //rpData.DataBind();
  207. }
  208. }
  209. }
  210. //创建数据源Table
  211. DataTable dtSource = new DataTable();
  212. dtSource.Columns.Add("Days", typeof(string));
  213. dtSource.Columns.Add("Date", typeof(string));
  214. dtSource.Columns.Add("Week", typeof(string));
  215. dtSource.Columns.Add("Traffic", typeof(string));
  216. dtSource.Columns.Add("Trip", typeof(string));
  217. //获取数据,放到datatable
  218. foreach (var item in _travelList)
  219. {
  220. DataRow dr = dtSource.NewRow();
  221. dr["Days"] = item.Days;
  222. dr["Date"] = item.Date;
  223. dr["Week"] = item.WeekDay;
  224. dr["Traffic"] = item.Traffic_First
  225. + "\r\n"
  226. + item.Traffic_Second;
  227. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  228. {
  229. item.Trip += @"
  230. 08:00 早餐于酒店;
  231. 09:00 公务活动;
  232. 10:30 公务活动;
  233. 12:00 午餐于当地餐厅;
  234. 14:00 公务活动;
  235. 16:00 公务活动;
  236. 18:00 晚餐于当地餐厅;
  237. 19:00 入住酒店休息;";
  238. }
  239. dr["Trip"] = item.Trip;
  240. dtSource.Rows.Add(dr);
  241. }
  242. //lblTeamName.Text = di.TourCode;
  243. //lblVisitDays.Text = di.VisitDays.ToString();
  244. //lblVisitDays2.Text = di.VisitDays.ToString();
  245. //lblPNumber.Text = di.VisitPNumber.ToString();
  246. //lblGroup.Text = di.TeamName.ToString();
  247. Dictionary<string, string> dic = new Dictionary<string, string>();
  248. dic.Add("Dele", di.TeamName.ToString() + GetNum(di.VisitDays.ToString()));
  249. dic.Add("City", CityStr1);
  250. dic.Add("Days", di.VisitDays.ToString());
  251. dic.Add("DeleCode", di.TourCode);
  252. dic.Add("Pnum", di.VisitPNumber.ToString());
  253. dic.Add("Pnum2", di.VisitPNumber.ToString());
  254. List<Crm_DeleClient> leader = GetByDiidClient(di.Id);
  255. if (leader != null && leader.Count > 0)
  256. {
  257. dic.Add("Leader", GetByDiidClient(di.Id)[0].LastName + GetByDiidClient(di.Id)[0].FirstName);
  258. }
  259. else
  260. {
  261. dic.Add("Leader", "");
  262. }
  263. dic.Add("Pnum3", di.VisitPNumber.ToString());
  264. int UserId = 253;
  265. dic.Add("OP", "");
  266. dic.Add("OPTel", "");
  267. //dic.Add("OP", "OP姓名");
  268. //dic.Add("OPTel", "OP手机号码");
  269. string countriesStr = "";
  270. countriesList.ForEach(s => countriesStr += s + "、");
  271. countriesStr = countriesStr.TrimEnd('、');
  272. string cityStr = "";
  273. cityList.ForEach(s => cityStr += s + "、");
  274. cityStr = cityStr.TrimEnd('、');
  275. //下方数据
  276. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  277. dic.Add("selCity", cityStr == null ? "" : cityStr);
  278. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  279. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  280. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  281. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  282. dic.Add("temperature", "");
  283. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  284. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  285. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  286. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  287. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  288. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  289. //模板路径
  290. string tempPath = @"C:\日行程3.docx";
  291. //载入模板
  292. Document doc = null;
  293. DocumentBuilder builder = null;
  294. try
  295. {
  296. //载入模板
  297. doc = new Document(tempPath);
  298. builder = new DocumentBuilder(doc);
  299. }
  300. catch (Exception)
  301. {
  302. //载入模板
  303. doc = new Document(@"D:\日行程3.docx");
  304. builder = new DocumentBuilder(doc);
  305. }
  306. foreach (var key in dic.Keys)
  307. {
  308. Bookmark bookmark = doc.Range.Bookmarks[key];
  309. if (bookmark != null)
  310. {
  311. builder.MoveToBookmark(key);
  312. builder.Write(dic[key]);
  313. }
  314. }
  315. //获取word里所有表格
  316. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  317. //获取所填表格的序数
  318. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  319. try
  320. {
  321. //循环赋值
  322. for (int i = 0; i < dtSource.Rows.Count; i++)
  323. {
  324. builder.MoveToCell(0, i + 1, 0, 0);
  325. builder.Write(dtSource.Rows[i]["Days"].ToString());
  326. builder.MoveToCell(0, i + 1, 1, 0);
  327. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  328. builder.MoveToCell(0, i + 1, 2, 0);
  329. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  330. var trip = dtSource.Rows[i]["Trip"].ToString();
  331. builder.MoveToCell(0, i + 1, 3, 0);
  332. builder.Write(trip);
  333. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  334. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  335. // 获取特定索引的段落
  336. Paragraph paragraph = (Paragraph)paragraphs[0];
  337. Run run = paragraph.Runs[0];
  338. Aspose.Words.Font font = run.Font;
  339. font.Name = "黑体";
  340. //设置双休红色
  341. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  342. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  343. paragraph = (Paragraph)paragraphs[1];
  344. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  345. {
  346. run = paragraph.Runs[0];
  347. font = run.Font;
  348. font.Color = Color.Red;
  349. }
  350. }
  351. }
  352. catch (Exception ex)
  353. {
  354. }
  355. //删除多余行
  356. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  357. {
  358. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  359. }
  360. string savePath = "C:\\OP行程单\\";
  361. if (!Directory.Exists(savePath))
  362. {
  363. try
  364. {
  365. Directory.CreateDirectory(savePath);
  366. }
  367. catch
  368. {
  369. }
  370. }
  371. string strFileName = savePath + di.TeamName + "出访日程.docx";
  372. try
  373. {
  374. doc.Save(strFileName, Aspose.Words.SaveFormat.Doc);
  375. lblOutputResult.Text = "文件导出完成";
  376. lblOutputResult.ForeColor = Color.Green;
  377. System.Diagnostics.Process.Start("Explorer.exe", "/select," + strFileName);
  378. }
  379. catch (Exception)
  380. {
  381. lblOutputResult.Text = "请重试!";
  382. lblOutputResult.ForeColor = Color.Green;
  383. }
  384. //doc.Save(HttpUtility.UrlEncode(strFileName, Encoding.UTF8), Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
  385. }
  386. private void btnImport_Click(object sender, EventArgs e)
  387. {
  388. lblImport.Text = "";
  389. lblImport.Text = "正在导入数据";
  390. int comb_Diid = 0;
  391. try
  392. {
  393. var dele = (comb_Delegation.SelectedItem as Grp_DelegationInfo);
  394. comb_Diid = dele.Id;
  395. }
  396. catch (Exception)
  397. {
  398. lblImport.Text = "请正确的选择团组!";
  399. lblImport.ForeColor = Color.Black;
  400. MessageBox.Show("请正确的选择团组!");
  401. return;
  402. }
  403. int UserId = 253;
  404. //下拉框团组对象实例
  405. //Grp_DelegationInfo di = dis.GetDelegationInfoByID(comb_Diid);
  406. Grp_DelegationInfo di = Db.Queryable<Grp_DelegationInfo>().First(x => x.Id == comb_Diid && x.IsDel == 0);
  407. if (di == null)
  408. {
  409. lblImport.Text = "请正确的选择团组!";
  410. lblImport.ForeColor = Color.Black;
  411. MessageBox.Show("请正确的选择团组!");
  412. return;
  413. }
  414. DataTable dt = null;
  415. try
  416. {
  417. //获取机票黑屏代码信息,生成datatable表
  418. dt = GetTableByBlackCode(di.Id);
  419. }
  420. catch (Exception)
  421. {
  422. lblImport.Text = "请正确的选择团组!";
  423. lblImport.ForeColor = Color.Black;
  424. MessageBox.Show("机票黑屏代码有误!");
  425. return;
  426. }
  427. Del(di.Id);
  428. //通过datatable表里的第一个字段的信息来判断是否有黑屏代码
  429. //没有则提示未录入
  430. if (dt.Rows[0]["Day"] == null || dt.Rows[0]["Day"].ToString() == "")
  431. {
  432. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  433. lblImport.Text = "黑屏代码未录入";
  434. }
  435. else//成功获取黑屏代码
  436. {
  437. //根据黑屏代码生成日期段
  438. List<string> timeList = GetTimeListByDataTable(dt);
  439. //本团车导地接信息
  440. //List<CarTouristGuideGroundReservations> listctg = ctgs.GetCarTouristGuideGroundReservationsByDIID(di.Id);
  441. List<Grp_CarTouristGuideGroundReservations> listctg = Db.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == di.Id && x.IsDel == 0).ToList();
  442. //本团酒店信息
  443. //List<HotelReservations> listht = htrs.GetByDIId(di.Id);
  444. List<Grp_HotelReservations> listht = Db.Queryable<Grp_HotelReservations>().Where(x => x.DiId == di.Id && x.IsDel == 0).ToList();
  445. //本团行程单数据
  446. //List<Grp_TravelList> listTravel = tls.GetByDiid(di.Id);
  447. List<Grp_TravelList> listTravel = Db.Queryable<Grp_TravelList>().Where(x => x.Diid == di.Id && x.IsDel == 0).ToList();
  448. try
  449. {
  450. if (listTravel != null && listTravel.Count > 0)//若本团已存行程,则合并/更新;同时因为机票行程的变化或行程详情的变化,会导致行程更改
  451. {
  452. if (timeList.Count > listTravel.Count)//1.改版后黑屏代码天数>已存在行程的天数
  453. {
  454. //1.1替换日期和星期
  455. for (int i = 0; i < listTravel.Count; i++)
  456. {
  457. //日期转换星期
  458. string weekday = weekdays[(int)new DateTime(
  459. Convert.ToInt32(timeList[i].Split('-')[0]),
  460. Convert.ToInt32(timeList[i].Split('-')[1]),
  461. Convert.ToInt32(timeList[i].Split('-')[2])).DayOfWeek];
  462. // 日期去掉0
  463. string monthStr = "Unknown", dayStr = "Unknown";
  464. if (!string.IsNullOrEmpty(timeList[i]))
  465. {
  466. DateTime dateTime = new DateTime();
  467. bool convertResult = DateTime.TryParse(timeList[i], out dateTime);
  468. if (convertResult)
  469. {
  470. monthStr = dateTime.Month.ToString();
  471. dayStr = dateTime.Day.ToString();
  472. }
  473. }
  474. //日期
  475. listTravel[i].Date = monthStr + "月" + dayStr + "日";
  476. //listTravel[i].Date = timeList[i].Substring(5, 2) + "月" + timeList[i].Substring(8, 2) + "日";
  477. listTravel[i].WeekDay = weekday;
  478. listTravel[i].CreateUserId = UserId;
  479. listTravel[i].CreateTime = GetBeijingTime();
  480. listTravel[i].IsDel = 0;
  481. //tls.EditTravelList(listTravel[i]);
  482. Db.Updateable<Grp_TravelList>(listTravel[i]).ExecuteCommand();
  483. }
  484. //1.2添加未有行程
  485. //航班号标识
  486. //string flightcode_Sign = "";
  487. //三字码标识
  488. //string citycode_Sign = "";
  489. #region 城市数据 20210823 贾文滔
  490. List<CityInDate> CityInDateList = GetCityByDataTable(dt);
  491. #endregion
  492. //生成行程
  493. for (int i = listTravel.Count; i < timeList.Count; i++)
  494. {
  495. //实、例化一个temp
  496. Grp_TravelList tlTemp = new Grp_TravelList();
  497. //团号
  498. tlTemp.Diid = di.Id;
  499. //天数序号
  500. tlTemp.Days = i + 1;
  501. //日期
  502. tlTemp.Date = timeList[i].Substring(5, 2) + "月" + timeList[i].Substring(8, 2) + "日";
  503. //日期转换星期
  504. string weekday = weekdays[(int)new DateTime(
  505. Convert.ToInt32(timeList[i].Split('-')[0]),
  506. Convert.ToInt32(timeList[i].Split('-')[1]),
  507. Convert.ToInt32(timeList[i].Split('-')[2])).DayOfWeek];
  508. tlTemp.WeekDay = weekday;
  509. //行程
  510. string trip = "";
  511. //历经城市
  512. string city = "";
  513. #region 机票数据
  514. //根据航班信息推出抵达机场的位置信息
  515. string AirPort = "";
  516. //根据航班时间前后推进入机场或离开机场的时间
  517. string GoAirportTime = "", leaveAirPortTime = "";
  518. //飞机标识
  519. bool airSign = false;
  520. //查询该日期下的航班信息
  521. //resultRows字段顺序为:航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间,整理后的起飞日期,整理后的到达日期
  522. DataRow[] resultRows = dt.Select("Day like '%" + timeList[i] + "%'");
  523. if (resultRows.Count() > 0)
  524. {
  525. //修改标识
  526. airSign = true;
  527. }
  528. //同一天只有一条数据走正常判定
  529. if (resultRows.Count() == 1)
  530. {
  531. #region 三字码
  532. string _citycode = resultRows[0]["Three"].ToString();
  533. //起飞城市三字码
  534. Res_ThreeCode font_threecode = null;
  535. string font_citycode = _citycode.Replace("/", string.Empty).Substring(0, 3);
  536. //抵达城市
  537. string font_City = "";
  538. //起飞城市机场
  539. string font_Airport = "";
  540. //抵达城市三字码
  541. Res_ThreeCode back_threecode = null;
  542. string end_citycode = _citycode.Replace("/", string.Empty).Substring(3, 3);
  543. //抵达城市机场
  544. string back_Airport = "";
  545. //抵达城市
  546. string back_City = "";
  547. font_threecode = getByThree(font_citycode);
  548. //验证是否存在三字码
  549. if (font_threecode == null)
  550. {
  551. city = city + "【此三字码" + font_citycode + "未收录,请机票同事录入】" + "一";
  552. font_Airport = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  553. font_City = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  554. }
  555. else
  556. {
  557. city = city + "/" + font_threecode.City;
  558. font_Airport = font_threecode.AirPort;
  559. font_City = font_threecode.City; ;
  560. }
  561. back_threecode = getByThree(end_citycode);
  562. if (back_threecode == null)
  563. {
  564. city = city + "【此三字码" + end_citycode + "未收录,请机票同事录入】" + "一";
  565. back_Airport = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  566. back_City = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  567. }
  568. else
  569. {
  570. city = city + "/" + back_threecode.City;
  571. //部分黄热病国家,需要提醒打疫苗
  572. string result = GetCountryInfo(back_threecode.Country);
  573. if (result.Contains("3"))
  574. {
  575. city += "(此地区为黄热病地区,请注意打疫苗)";
  576. }
  577. back_Airport = back_threecode.AirPort;
  578. back_City = back_threecode.City;
  579. //查询酒店路线要用
  580. AirPort = back_threecode.AirPort;
  581. }
  582. //行程里加入城市
  583. #endregion
  584. #region 信息准备
  585. trip = city.TrimStart('/');
  586. //起飞航站楼
  587. string _StartBuilding = resultRows[0]["StartBuilding"].ToString();
  588. //转机航站楼
  589. string _EndBuilding = resultRows[0]["EndBuilding"].ToString();
  590. //起飞时刻
  591. string _startTime = resultRows[0]["StartTime"].ToString();
  592. //飞行时刻
  593. string _flightTime = resultRows[0]["FlightTime"].ToString();
  594. _flightTime = _flightTime.Contains("H") ? _flightTime.Split('H')[0] + "小时" + _flightTime.Split('H')[1].Split('M')[0] + "分钟" : _flightTime.Split('M')[0] + "分钟";
  595. //到达时刻
  596. string _endTime = resultRows[0]["EndTime"].ToString();
  597. //航班号
  598. string _flightcode = resultRows[0]["Fliagtcode"].ToString();
  599. //航司
  600. //Res_AirCompany aircompany = acs.getByShortCode(_flightcode.Substring(0, 2));
  601. Res_AirCompany aircompany = getByShortCode(_flightcode.Substring(0, 2));
  602. string _aircompany_Name = "";
  603. if (aircompany == null)
  604. {
  605. _aircompany_Name = "【此航司" + resultRows[0]["Fliagtcode"].ToString().Substring(0, 2) + "未收录,请机票同事录入】";
  606. }
  607. else
  608. {
  609. _aircompany_Name = aircompany.CnName;
  610. }
  611. //机型判断
  612. string airModel = resultRows[0]["AirModel"].ToString();
  613. airModel = GetLonger(airModel.Substring(0, 1)) + airModel;
  614. #endregion
  615. #region trip编辑
  616. //若本行抵达时间包含"+1",则本行为母版行,仅提示登机
  617. if (resultRows[0]["Sign"].ToString() == "0" && _endTime.Contains("+"))
  618. {
  619. //根据航班信息推算进入机场的时间
  620. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前两小时
  621. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前三小时
  622. if (result.Contains("2"))
  623. {
  624. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  625. }
  626. if (temp < 0)
  627. {
  628. temp = temp + 24;
  629. }
  630. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  631. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  632. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  633. if (i > 0)
  634. {
  635. #region 酒店
  636. foreach (var h in listht)
  637. {
  638. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  639. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))
  640. {
  641. //利用谷歌API计算路线
  642. if (AirPort != "")
  643. {
  644. GoogleMapApiResult g = null;
  645. if (g != null)
  646. {
  647. //计算“酒店到机场”的时间
  648. string CheckoutHotelTime;
  649. //处理时间格式
  650. string hours = "", mins = "";
  651. if (g.Time.Contains("hour"))
  652. {
  653. g.Time = g.Time.Replace("hour", "h");
  654. }
  655. else if (g.Time.Contains("hours"))
  656. {
  657. g.Time = g.Time.Replace("hours", "h");
  658. }
  659. g.Time = g.Time.Replace("mins", "m");
  660. if (g.Time.Contains("h"))
  661. {
  662. hours = g.Time.Split('h')[0].Trim();
  663. }
  664. else if (!g.Time.Contains("h"))
  665. {
  666. mins = g.Time.Split('m')[0].Trim();
  667. }
  668. int hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  669. int min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  670. min = min - Convert.ToInt32(mins);
  671. if (min < 0)
  672. {
  673. min = min + 60;
  674. hour = hour - 1;
  675. }
  676. if (hours != "")
  677. {
  678. hour = hour - Convert.ToInt32(hours);
  679. }
  680. if (hour < 0)
  681. {
  682. hour = hour + 24;
  683. }
  684. CheckoutHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  685. CheckoutHotelTime = CheckoutHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  686. trip = trip + "\r\n"
  687. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  688. }
  689. else
  690. {
  691. try
  692. {
  693. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  694. //计算“抵达酒店办理入住手续”的时间
  695. string CheckoutHotelTime;
  696. //处理时间格式
  697. string Gtime = "", hours = "", mins = "";
  698. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  699. {
  700. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  701. }
  702. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  703. {
  704. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  705. }
  706. Gtime = Gtime.Replace("mins", "m");
  707. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  708. {
  709. hours = Gtime.Split('h')[0].Trim();
  710. }
  711. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  712. {
  713. mins = Gtime.Split('m')[0].Trim();
  714. }
  715. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  716. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  717. min = min - Convert.ToInt32(mins);
  718. if (min < 0)
  719. {
  720. min = min + 60;
  721. hour = hour - 1;
  722. }
  723. if (hours != "")
  724. {
  725. hour = hour + Convert.ToInt32(hours);
  726. }
  727. if (hour < 0)
  728. {
  729. hour = hour + 24;
  730. }
  731. CheckoutHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  732. CheckoutHotelTime = CheckoutHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  733. trip = trip + "\r\n"
  734. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  735. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  736. gtemp.Diid = di.Id;
  737. gtemp.Date = "";
  738. gtemp.Moment = "";
  739. gtemp.StartAddress = AirPort;
  740. gtemp.EndAddress = h.HotelAddress;
  741. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  742. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  743. //gmrs.Add(gtemp);
  744. }
  745. catch
  746. {
  747. trip = trip + "\r\n"
  748. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  749. }
  750. }
  751. }
  752. }
  753. }
  754. #endregion
  755. }
  756. //行程
  757. trip = trip
  758. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  759. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  760. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");";
  761. //标记本行为母版行
  762. //flightcode_Sign = resultRows[0]["Fliagtcode"].ToString();
  763. //citycode_Sign = resultRows[0]["Three"].ToString();
  764. }
  765. //与前一行航班号,三字码相同且本行抵达时间不包含"+1",则本行是被生成的重复行,仅提示抵达
  766. else if (resultRows[0]["Sign"].ToString() == "1") /* && (!_endTime.Contains("+"))&&(_flightcode == flightcode_Sign)&&(_citycode == citycode_Sign)*/
  767. {
  768. //行程
  769. trip = trip
  770. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  771. //根据航班信息推算离开机场的时间
  772. int temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  773. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  774. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  775. if (i == timeList.Count - 1)//如果本日是行程的最后一天,则提醒“行程圆满结束”
  776. {
  777. trip = trip + " ,圆满结束此次访问之行!";
  778. }
  779. else //如果本日不是行程的最后一天,正常提醒
  780. {
  781. //trip += pushTrip(leaveAirPortTime, back_Airport, city,out leaveAirPortTime);
  782. trip = trip + ";\r\n" + leaveAirPortTime + " 搭乘专车前往酒店,抵达后办理入住;";
  783. }
  784. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  785. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  786. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  787. min = min + 10;
  788. if (min > 59)
  789. {
  790. min = min - 60;
  791. hour = hour + 1;
  792. }
  793. if (hour > 23)
  794. {
  795. hour = hour - 24;
  796. }
  797. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  798. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  799. }
  800. //正常提示
  801. else
  802. {
  803. //根据航班信息推算进入机场的时间
  804. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前2小时
  805. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前3小时
  806. if (result.Contains("2"))
  807. {
  808. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  809. }
  810. if (temp < 0)
  811. {
  812. temp = temp + 24;
  813. }
  814. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  815. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  816. //根据航班信息推算离开机场的时间
  817. temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  818. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  819. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  820. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  821. if (i > 0)
  822. {
  823. #region 酒店
  824. foreach (var h in listht)
  825. {
  826. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  827. && Convert.ToDateTime(h.CheckOutDate) >= Convert.ToDateTime(timeList[i]))
  828. {
  829. //利用谷歌API计算路线
  830. if (AirPort != "")
  831. {
  832. GoogleMapApiResult g = null;
  833. if (g != null)
  834. {
  835. //计算“酒店到机场”的时间
  836. string CheckoutHotelTime;
  837. //处理时间格式
  838. string hours = "0", mins = "0";
  839. if (g.Time.Contains("hour"))
  840. {
  841. g.Time = g.Time.Replace("hour", "h");
  842. }
  843. else if (g.Time.Contains("hours"))
  844. {
  845. g.Time = g.Time.Replace("hours", "h");
  846. }
  847. g.Time = g.Time.Replace("mins", "m");
  848. if (g.Time.Contains("h"))
  849. {
  850. hours = g.Time.Split('h')[0].Trim();
  851. }
  852. else if (!g.Time.Contains("h"))
  853. {
  854. mins = g.Time.Split('m')[0].Trim();
  855. }
  856. int _hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  857. int _min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  858. _min = _min - Convert.ToInt32(mins);
  859. if (_min < 0)
  860. {
  861. _min = _min + 60;
  862. _hour = _hour - 1;
  863. }
  864. if (hours != "")
  865. {
  866. _hour = _hour - Convert.ToInt32(hours);
  867. }
  868. if (_hour < 0)
  869. {
  870. _hour = _hour + 24;
  871. }
  872. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  873. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  874. trip = trip + "\r\n"
  875. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  876. }
  877. else
  878. {
  879. try
  880. {
  881. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  882. //计算“抵达酒店办理入住手续”的时间
  883. string CheckoutHotelTime;
  884. //处理时间格式
  885. string Gtime = "", hours = "0", mins = "0";
  886. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  887. {
  888. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  889. }
  890. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  891. {
  892. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  893. }
  894. Gtime = Gtime.Replace("mins", "m");
  895. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  896. {
  897. hours = Gtime.Split('h')[0].Trim();
  898. }
  899. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  900. {
  901. mins = Gtime.Split('m')[0].Trim();
  902. }
  903. int _hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  904. int _min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  905. _min = _min - Convert.ToInt32(mins);
  906. if (_min < 0)
  907. {
  908. _min = _min + 60;
  909. _hour = _hour - 1;
  910. }
  911. if (hours != "")
  912. {
  913. _hour = _hour + Convert.ToInt32(hours);
  914. }
  915. if (_hour < 0)
  916. {
  917. _hour = _hour + 24;
  918. }
  919. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  920. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  921. trip = trip + "\r\n"
  922. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  923. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  924. gtemp.Diid = di.Id;
  925. gtemp.Date = "";
  926. gtemp.Moment = "";
  927. gtemp.StartAddress = AirPort;
  928. gtemp.EndAddress = h.HotelAddress;
  929. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  930. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  931. //gmrs.Add(gtemp);
  932. }
  933. catch
  934. {
  935. trip = trip + "\r\n"
  936. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  937. }
  938. }
  939. }
  940. }
  941. }
  942. #endregion
  943. }
  944. trip = trip
  945. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  946. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  947. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  948. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  949. if (i == timeList.Count - 1)//如果本日是行程的最后一天,先增加酒店到机场的距离时间,再在末尾提醒“行程圆满结束”
  950. {
  951. trip = trip + ",圆满结束此次访问之行!";
  952. }
  953. else //如果本日不是行程的最后一天,正常提醒
  954. {
  955. trip += pushTrip(leaveAirPortTime, back_Airport, city, out leaveAirPortTime);
  956. trip = trip + ";\r\n" + leaveAirPortTime + "搭乘专车前往酒店,抵达后办理入住;";
  957. }
  958. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  959. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  960. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  961. min = min + 10;
  962. if (min > 59)
  963. {
  964. min = min - 60;
  965. hour = hour + 1;
  966. }
  967. if (hour > 23)
  968. {
  969. hour = hour - 24;
  970. }
  971. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  972. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  973. }
  974. #endregion
  975. }
  976. //同一天多条数据走分类讨论
  977. else
  978. {
  979. for (int n = 0; n < resultRows.Count(); n++)
  980. {
  981. city = "";
  982. #region 三字码
  983. string _citycode = resultRows[n]["Three"].ToString();
  984. //起飞城市三字码
  985. Res_ThreeCode font_threecode = null;
  986. string font_citycode = _citycode.Replace("/", string.Empty).Substring(0, 3);
  987. //抵达城市
  988. string font_City = "";
  989. //起飞城市机场
  990. string font_Airport = "";
  991. //抵达城市三字码
  992. Res_ThreeCode back_threecode = null;
  993. string end_citycode = _citycode.Replace("/", string.Empty).Substring(3, 3);
  994. //抵达城市机场
  995. string back_Airport = "";
  996. //抵达城市
  997. string back_City = "";
  998. font_threecode = getByThree(font_citycode);
  999. //验证是否存在三字码
  1000. if (font_threecode == null)
  1001. {
  1002. city = city + "【此三字码" + font_citycode + "未收录,请机票同事录入】" + "一";
  1003. font_Airport = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  1004. font_City = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  1005. }
  1006. else
  1007. {
  1008. city = city + "/" + font_threecode.City;
  1009. font_Airport = font_threecode.AirPort;
  1010. font_City = font_threecode.City; ;
  1011. }
  1012. back_threecode = getByThree(end_citycode);
  1013. if (back_threecode == null)
  1014. {
  1015. city = city + "【此三字码" + end_citycode + "未收录,请机票同事录入】" + "一";
  1016. back_Airport = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  1017. back_City = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  1018. }
  1019. else
  1020. {
  1021. city = city + "/" + back_threecode.City;
  1022. //部分黄热病国家,需要提醒打疫苗
  1023. string result = GetCountryInfo(back_threecode.Country);
  1024. if (result.Contains("3"))
  1025. {
  1026. city += "(此地区为黄热病地区,请注意打疫苗)";
  1027. }
  1028. back_Airport = back_threecode.AirPort;
  1029. back_City = back_threecode.City;
  1030. //查询酒店路线要用
  1031. AirPort = back_threecode.AirPort;
  1032. }
  1033. //行程里加入城市
  1034. if (trip == "")
  1035. {
  1036. trip = city.TrimStart('/');
  1037. }
  1038. else
  1039. {
  1040. trip = trip + "\r\n"
  1041. + city.TrimStart('/');
  1042. }
  1043. //起飞航站楼
  1044. string _StartBuilding = resultRows[n]["StartBuilding"].ToString();
  1045. //转机航站楼
  1046. string _EndBuilding = resultRows[n]["EndBuilding"].ToString();
  1047. //起飞时刻
  1048. string _startTime = resultRows[n]["StartTime"].ToString();
  1049. //飞行时刻
  1050. string _flightTime = resultRows[n]["FlightTime"].ToString();
  1051. _flightTime = _flightTime.Contains("H") ? _flightTime.Split('H')[0] + "小时" + _flightTime.Split('H')[1].Split('M')[0] + "分钟" : _flightTime.Split('M')[0] + "分钟";
  1052. //到达时刻
  1053. string _endTime = resultRows[n]["EndTime"].ToString();
  1054. //航班号
  1055. string _flightcode = resultRows[n]["Fliagtcode"].ToString();
  1056. //航司
  1057. Res_AirCompany aircompany = getByShortCode(_flightcode.Substring(0, 2));
  1058. string _aircompany_Name = "";
  1059. if (aircompany == null)
  1060. {
  1061. _aircompany_Name = "【此航司" + resultRows[n]["Fliagtcode"].ToString().Substring(0, 2) + "未收录,请机票同事录入】";
  1062. }
  1063. else
  1064. {
  1065. _aircompany_Name = aircompany.CnName;
  1066. }
  1067. //机型判断
  1068. string airModel = resultRows[n]["AirModel"].ToString();
  1069. airModel = GetLonger(airModel.Substring(0, 1)) + airModel;
  1070. #endregion
  1071. //Sign字段为标识,string类型,含义:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1072. //目前存在两种情况:同一天的多条数据标识为“0->0”或“1->0”
  1073. //如下示例
  1074. //Day ArrivedDate Sign
  1075. //10 10 0
  1076. //10 11 0
  1077. //11 11 1
  1078. //11 12 0
  1079. //12 12 1
  1080. if (n == 0)
  1081. {
  1082. //原生机票代码
  1083. if (resultRows[n]["Sign"].ToString() == "0")
  1084. {
  1085. #region trip编辑
  1086. //根据航班信息推算进入机场的时间
  1087. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前两小时
  1088. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前三小时
  1089. if (result.Contains("2"))
  1090. {
  1091. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  1092. }
  1093. if (temp < 0)
  1094. {
  1095. temp = temp + 24;
  1096. }
  1097. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  1098. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  1099. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  1100. if (i > 0)
  1101. {
  1102. #region 酒店
  1103. foreach (var h in listht)
  1104. {
  1105. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  1106. && Convert.ToDateTime(h.CheckOutDate) >= Convert.ToDateTime(timeList[i]))
  1107. {
  1108. //利用谷歌API计算路线
  1109. if (AirPort != "")
  1110. {
  1111. GoogleMapApiResult g = null;
  1112. if (g != null)
  1113. {
  1114. //计算“酒店到机场”的时间
  1115. string CheckoutHotelTime;
  1116. //处理时间格式
  1117. string hours = "0", mins = "0";
  1118. if (g.Time.Contains("hour"))
  1119. {
  1120. g.Time = g.Time.Replace("hour", "h");
  1121. }
  1122. else if (g.Time.Contains("hours"))
  1123. {
  1124. g.Time = g.Time.Replace("hours", "h");
  1125. }
  1126. g.Time = g.Time.Replace("mins", "m");
  1127. if (g.Time.Contains("h"))
  1128. {
  1129. hours = g.Time.Split('h')[0].Trim();
  1130. }
  1131. else if (!g.Time.Contains("h"))
  1132. {
  1133. mins = g.Time.Split('m')[0].Trim();
  1134. }
  1135. int _hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  1136. int _min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  1137. _min = _min - Convert.ToInt32(mins);
  1138. if (_min < 0)
  1139. {
  1140. _min = _min + 60;
  1141. _hour = _hour - 1;
  1142. }
  1143. if (hours != "")
  1144. {
  1145. _hour = _hour - Convert.ToInt32(hours);
  1146. }
  1147. if (_hour < 0)
  1148. {
  1149. _hour = _hour + 24;
  1150. }
  1151. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  1152. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  1153. trip = trip + "\r\n"
  1154. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  1155. }
  1156. else
  1157. {
  1158. try
  1159. {
  1160. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  1161. //计算“抵达酒店办理入住手续”的时间
  1162. string CheckoutHotelTime;
  1163. //处理时间格式
  1164. string Gtime = "", hours = "0", mins = "0";
  1165. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  1166. {
  1167. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  1168. }
  1169. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  1170. {
  1171. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  1172. }
  1173. Gtime = Gtime.Replace("mins", "m");
  1174. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  1175. {
  1176. hours = Gtime.Split('h')[0].Trim();
  1177. }
  1178. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  1179. {
  1180. mins = Gtime.Split('m')[0].Trim();
  1181. }
  1182. int _hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  1183. int _min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  1184. _min = _min - Convert.ToInt32(mins);
  1185. if (_min < 0)
  1186. {
  1187. _min = _min + 60;
  1188. _hour = _hour - 1;
  1189. }
  1190. if (hours != "")
  1191. {
  1192. _hour = _hour + Convert.ToInt32(hours);
  1193. }
  1194. if (_hour < 0)
  1195. {
  1196. _hour = _hour + 24;
  1197. }
  1198. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  1199. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  1200. trip = trip + "\r\n"
  1201. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  1202. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  1203. gtemp.Diid = di.Id;
  1204. gtemp.Date = "";
  1205. gtemp.Moment = "";
  1206. gtemp.StartAddress = AirPort;
  1207. gtemp.EndAddress = h.HotelAddress;
  1208. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  1209. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  1210. //gmrs.Add(gtemp);
  1211. }
  1212. catch
  1213. {
  1214. trip = trip + "\r\n"
  1215. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  1216. }
  1217. }
  1218. }
  1219. }
  1220. }
  1221. #endregion
  1222. }
  1223. trip = trip
  1224. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  1225. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  1226. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  1227. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,提取行李;";
  1228. #endregion
  1229. }
  1230. //"+1"生成的机票代码
  1231. else if (resultRows[n]["Sign"].ToString() == "1")
  1232. {
  1233. #region trip编辑
  1234. //行程
  1235. trip = trip
  1236. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,提取行李;";
  1237. #endregion
  1238. }
  1239. }
  1240. else if (n > 0)
  1241. {
  1242. //若前行是原生的,则本行判定为转机
  1243. if (resultRows[n - 1]["Sign"].ToString() == "0")
  1244. {
  1245. #region trip编辑
  1246. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 1;//一般提前提前2小时
  1247. if (temp < 0)
  1248. {
  1249. temp = temp + 24;
  1250. }
  1251. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  1252. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  1253. trip = trip
  1254. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  1255. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  1256. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  1257. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  1258. //若为最后一行,则计算后备等时间
  1259. if (n == resultRows.Count() - 1)
  1260. {
  1261. //根据航班信息推算离开机场的时间
  1262. temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  1263. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  1264. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  1265. if (i == timeList.Count - 1)//如果本日是行程的最后一天,先增加酒店到机场的距离时间,再在末尾提醒“行程圆满结束”
  1266. {
  1267. trip = trip + ",圆满结束此次访问之行!";
  1268. }
  1269. else //如果本日不是行程的最后一天,正常提醒
  1270. {
  1271. trip += pushTrip(leaveAirPortTime, back_Airport, city, out leaveAirPortTime);
  1272. trip = trip + ";\r\n" + leaveAirPortTime + "搭乘专车前往酒店,抵达后办理入住;";
  1273. }
  1274. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  1275. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  1276. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  1277. min = min + 10;
  1278. if (min > 59)
  1279. {
  1280. min = min - 60;
  1281. hour = hour + 1;
  1282. }
  1283. if (hour > 23)
  1284. {
  1285. hour = hour - 24;
  1286. }
  1287. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  1288. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  1289. }
  1290. #endregion
  1291. }
  1292. //若前行是生成的,则本行判定为新出发
  1293. else if (resultRows[n - 1]["Sign"].ToString() == "1")
  1294. {
  1295. #region trip编辑
  1296. //根据航班信息推算进入机场的时间
  1297. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前2小时
  1298. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前3小时
  1299. if (result.Contains("2"))
  1300. {
  1301. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  1302. }
  1303. if (temp < 0)
  1304. {
  1305. temp = temp + 24;
  1306. }
  1307. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  1308. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  1309. //根据航班信息推算离开机场的时间
  1310. temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  1311. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  1312. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  1313. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  1314. if (i > 0)
  1315. {
  1316. #region 酒店
  1317. foreach (var h in listht)
  1318. {
  1319. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  1320. && Convert.ToDateTime(h.CheckOutDate) >= Convert.ToDateTime(timeList[i]))
  1321. {
  1322. //利用谷歌API计算路线
  1323. if (AirPort != "")
  1324. {
  1325. GoogleMapApiResult g = null;
  1326. if (g != null)
  1327. {
  1328. //计算“酒店到机场”的时间
  1329. string CheckoutHotelTime;
  1330. //处理时间格式
  1331. string hours = "0", mins = "0";
  1332. if (g.Time.Contains("hour"))
  1333. {
  1334. g.Time = g.Time.Replace("hour", "h");
  1335. }
  1336. else if (g.Time.Contains("hours"))
  1337. {
  1338. g.Time = g.Time.Replace("hours", "h");
  1339. }
  1340. g.Time = g.Time.Replace("mins", "m");
  1341. if (g.Time.Contains("h"))
  1342. {
  1343. hours = g.Time.Split('h')[0].Trim();
  1344. }
  1345. else if (!g.Time.Contains("h"))
  1346. {
  1347. mins = g.Time.Split('m')[0].Trim();
  1348. }
  1349. int _hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  1350. int _min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  1351. _min = _min - Convert.ToInt32(mins);
  1352. if (_min < 0)
  1353. {
  1354. _min = _min + 60;
  1355. _hour = _hour - 1;
  1356. }
  1357. if (hours != "")
  1358. {
  1359. _hour = _hour - Convert.ToInt32(hours);
  1360. }
  1361. if (_hour < 0)
  1362. {
  1363. _hour = _hour + 24;
  1364. }
  1365. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  1366. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  1367. trip = trip + "\r\n"
  1368. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  1369. }
  1370. else
  1371. {
  1372. try
  1373. {
  1374. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  1375. //计算“抵达酒店办理入住手续”的时间
  1376. string CheckoutHotelTime;
  1377. //处理时间格式
  1378. string Gtime = "", hours = "0", mins = "0";
  1379. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  1380. {
  1381. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  1382. }
  1383. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  1384. {
  1385. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  1386. }
  1387. Gtime = Gtime.Replace("mins", "m");
  1388. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  1389. {
  1390. hours = Gtime.Split('h')[0].Trim();
  1391. }
  1392. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  1393. {
  1394. mins = Gtime.Split('m')[0].Trim();
  1395. }
  1396. int _hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  1397. int _min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  1398. _min = _min - Convert.ToInt32(mins);
  1399. if (_min < 0)
  1400. {
  1401. _min = _min + 60;
  1402. _hour = _hour - 1;
  1403. }
  1404. if (hours != "")
  1405. {
  1406. _hour = _hour + Convert.ToInt32(hours);
  1407. }
  1408. if (_hour < 0)
  1409. {
  1410. _hour = _hour + 24;
  1411. }
  1412. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  1413. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  1414. trip = trip + "\r\n"
  1415. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  1416. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  1417. gtemp.Diid = di.Id;
  1418. gtemp.Date = "";
  1419. gtemp.Moment = "";
  1420. gtemp.StartAddress = AirPort;
  1421. gtemp.EndAddress = h.HotelAddress;
  1422. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  1423. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  1424. //gmrs.Add(gtemp);
  1425. }
  1426. catch
  1427. {
  1428. trip = trip + "\r\n"
  1429. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  1430. }
  1431. }
  1432. }
  1433. }
  1434. }
  1435. #endregion
  1436. }
  1437. trip = trip
  1438. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  1439. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  1440. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  1441. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  1442. if (i == timeList.Count - 1)//如果本日是行程的最后一天,先增加酒店到机场的距离时间,再在末尾提醒“行程圆满结束”
  1443. {
  1444. trip = trip + ",圆满结束此次访问之行!";
  1445. }
  1446. else //如果本日不是行程的最后一天,正常提醒
  1447. {
  1448. trip += pushTrip(leaveAirPortTime, back_Airport, city, out leaveAirPortTime);
  1449. trip = trip + ";\r\n" + leaveAirPortTime + "搭乘专车前往酒店,抵达后办理入住;";
  1450. }
  1451. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  1452. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  1453. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  1454. min = min + 10;
  1455. if (min > 59)
  1456. {
  1457. min = min - 60;
  1458. hour = hour + 1;
  1459. }
  1460. if (hour > 23)
  1461. {
  1462. hour = hour - 24;
  1463. }
  1464. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  1465. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  1466. #endregion
  1467. }
  1468. }
  1469. }
  1470. }
  1471. #endregion
  1472. #region 行程和城市赋值
  1473. if (trip == "" || trip == " " || city == "" || city == " ")
  1474. {
  1475. //city = CityInDateList.Find(cid => cid.Date == timeList[i]).City;
  1476. city = CityInDateList[i].City;
  1477. //部分黄热病国家,需要提醒打疫苗
  1478. string result = GetCountryInfo(getByCity(city)[0].Country);
  1479. if (result.Contains("3"))
  1480. {
  1481. city += "(此地区为黄热病地区,请注意打疫苗)";
  1482. }
  1483. trip = city;
  1484. }
  1485. #endregion
  1486. #region 公务 20210820 贾文滔
  1487. string OATemp = "";//暂存公务活动
  1488. //根据团号和日期获取公务数据
  1489. List<Res_OfficialActivities> listoa = getByDiidAndDate(comb_Diid, timeList[i]);
  1490. //若listoa存在公务数据,进行排序,再进行导入
  1491. if (listoa != null && listoa.Count > 0)
  1492. {
  1493. //利用datatable存放公务活动数据
  1494. DataTable OA_DataTable = new DataTable();
  1495. OA_DataTable.Columns.Add("StartTime", typeof(string)); //activity开始时刻
  1496. OA_DataTable.Columns.Add("EndTime", typeof(string)); //activity结束时刻
  1497. OA_DataTable.Columns.Add("Client", typeof(string)); //activity单位
  1498. OA_DataTable.Columns.Add("Address", typeof(string)); //activity地址
  1499. OA_DataTable.Columns.Add("Contact", typeof(string)); //activity联系人
  1500. OA_DataTable.Columns.Add("Tel", typeof(string)); //activity联系人电话
  1501. OA_DataTable.Columns.Add("Dresscode", typeof(string)); //activity着装要求
  1502. OA_DataTable.Columns.Add("isTranslate", typeof(bool));//是否需要翻译人员
  1503. OA_DataTable.Columns.Add("Language", typeof(string));//是否需要翻译人员
  1504. //处理公务数据
  1505. for (int b = 0; b < listoa.Count; b++)
  1506. {
  1507. //起止时间
  1508. string[] time = new string[2];
  1509. if (listoa[b].Time.Contains('—'))
  1510. {
  1511. time = listoa[b].Time.Split('—');
  1512. }
  1513. else if (listoa[b].Time.Contains('-'))
  1514. {
  1515. time = listoa[b].Time.Split('-');
  1516. }
  1517. //添加数据
  1518. if (time.Length >= 2)
  1519. {
  1520. OA_DataTable.Rows.Add(time[0], time[1], listoa[b].Client, listoa[b].Address, listoa[b].Contact, listoa[b].Tel, listoa[b].Dresscode, listoa[b].IsNeedTrans, listoa[b].Language);
  1521. }
  1522. else
  1523. {
  1524. //PublicCode.GetAlertMsg(this, GetType(), timeList[i] + "的公务数据有误,请检查");
  1525. }
  1526. }
  1527. //排序
  1528. OA_DataTable.DefaultView.Sort = "StartTime asc";
  1529. OA_DataTable = OA_DataTable.DefaultView.ToTable();
  1530. //导入信息
  1531. for (int index = 0; index < OA_DataTable.Rows.Count; index++)
  1532. {
  1533. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  1534. {
  1535. if (OATemp != "")
  1536. {
  1537. OATemp = OATemp + "\r\n"
  1538. + OA_DataTable.Rows[index]["StartTime"].ToString()
  1539. + "-"
  1540. + OA_DataTable.Rows[index]["EndTime"].ToString()
  1541. + " 拜访" + OA_DataTable.Rows[index]["Client"].ToString()
  1542. + ",联系人:" + OA_DataTable.Rows[index]["Contact"].ToString()
  1543. + ",电话:" + OA_DataTable.Rows[index]["Tel"].ToString()
  1544. + ",地址:" + OA_DataTable.Rows[index]["Address"].ToString()
  1545. + ",着装要求:" + OA_DataTable.Rows[index]["Dresscode"].ToString()
  1546. + ",是否需要翻译:" + (bool.Parse(OA_DataTable.Rows[index]["isTranslate"].ToString()) ? "需要翻译人员" + "翻译语种为" + OA_DataTable.Rows[index]["Language"].ToString() : "不需要翻译人员")
  1547. + ",议题:-";
  1548. }
  1549. else
  1550. {
  1551. OATemp = OA_DataTable.Rows[index]["StartTime"].ToString()
  1552. + "-"
  1553. + OA_DataTable.Rows[index]["EndTime"].ToString()
  1554. + " 拜访" + OA_DataTable.Rows[index]["Client"].ToString()
  1555. + ",联系人:" + OA_DataTable.Rows[index]["Contact"].ToString()
  1556. + ",电话:" + OA_DataTable.Rows[index]["Tel"].ToString()
  1557. + ",地址:" + OA_DataTable.Rows[index]["Address"].ToString()
  1558. + ",着装要求:" + OA_DataTable.Rows[index]["Dresscode"].ToString()
  1559. + ",是否需要翻译:" + (bool.Parse(OA_DataTable.Rows[index]["isTranslate"].ToString()) ? "需要翻译人员" + "翻译语种为" + OA_DataTable.Rows[index]["Language"].ToString() : "不需要翻译人员")
  1560. + ",议题:-";
  1561. }
  1562. }
  1563. else
  1564. {
  1565. //导入公务
  1566. trip = trip + "\r\n"
  1567. + OA_DataTable.Rows[index]["StartTime"].ToString()
  1568. + "-"
  1569. + OA_DataTable.Rows[index]["EndTime"].ToString()
  1570. + " 拜访" + OA_DataTable.Rows[index]["Client"].ToString()
  1571. + ",联系人:" + OA_DataTable.Rows[index]["Contact"].ToString()
  1572. + ",电话:" + OA_DataTable.Rows[index]["Tel"].ToString()
  1573. + ",地址:" + OA_DataTable.Rows[index]["Address"].ToString()
  1574. + ",着装要求:" + OA_DataTable.Rows[index]["Dresscode"].ToString()
  1575. + ",是否需要翻译:" + (bool.Parse(OA_DataTable.Rows[index]["isTranslate"].ToString()) ? "需要翻译人员" + "翻译语种为" + OA_DataTable.Rows[index]["Language"].ToString() : "不需要翻译人员")
  1576. + ",议题:-";
  1577. }
  1578. //当天第一个公务或许都是从酒店出发,因此可计算酒店到公务地址的距离和时间
  1579. if (index == 0)
  1580. {
  1581. #region 酒店
  1582. foreach (var h in listht)
  1583. {
  1584. if (Convert.ToDateTime(h.CheckInDate) <= Convert.ToDateTime(timeList[i])
  1585. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))
  1586. {
  1587. //利用谷歌API计算路线
  1588. GoogleMapApiResult g = null;
  1589. if (g != null)
  1590. {
  1591. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  1592. {
  1593. OATemp = OATemp + "。 (" + g.Distance + "," + g.Time + ")";
  1594. }
  1595. else
  1596. {
  1597. trip = trip + "。 (" + g.Distance + "," + g.Time + ")";
  1598. }
  1599. }
  1600. else
  1601. {
  1602. try
  1603. {
  1604. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, OA_DataTable.Rows[0]["Address"].ToString());
  1605. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  1606. {
  1607. OATemp = OATemp + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  1608. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  1609. }
  1610. else
  1611. {
  1612. trip = trip + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  1613. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  1614. }
  1615. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  1616. gtemp.Diid = di.Id;
  1617. gtemp.Date = "";
  1618. gtemp.Moment = "";
  1619. gtemp.StartAddress = h.HotelAddress;
  1620. gtemp.EndAddress = OA_DataTable.Rows[0]["Address"].ToString();
  1621. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  1622. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  1623. //gmrs.Add(gtemp);
  1624. }
  1625. catch
  1626. {
  1627. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  1628. {
  1629. OATemp = OATemp + "。 (谷歌接口异常,无法测算路程时间)";
  1630. }
  1631. else
  1632. {
  1633. trip = trip + "。 (谷歌接口异常,无法测算路程时间)";
  1634. }
  1635. }
  1636. }
  1637. }
  1638. }
  1639. #endregion
  1640. }
  1641. //第二个公务是由中午的餐厅前往公务地址,具有随机性,因此不计算此方向距离时间;但可计算由公务地址回酒店的信息
  1642. else
  1643. {
  1644. #region 酒店
  1645. foreach (var h in listht)
  1646. {
  1647. if (Convert.ToDateTime(h.CheckInDate) <= Convert.ToDateTime(timeList[i])
  1648. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))
  1649. {
  1650. //利用谷歌API计算路线
  1651. GoogleMapApiResult g = null;
  1652. if (g != null)
  1653. {
  1654. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  1655. {
  1656. OATemp = OATemp + "。 (" + g.Distance + "," + g.Time + ")";
  1657. }
  1658. else
  1659. {
  1660. trip = trip + "。 (" + g.Distance + "," + g.Time + ")";
  1661. }
  1662. }
  1663. else
  1664. {
  1665. try
  1666. {
  1667. JObject Result = GetDirectionByGoogleApi(OA_DataTable.Rows[index]["Address"].ToString(), h.HotelAddress);
  1668. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  1669. {
  1670. OATemp = OATemp + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  1671. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  1672. }
  1673. else
  1674. {
  1675. trip = trip + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  1676. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  1677. }
  1678. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  1679. gtemp.Diid = di.Id;
  1680. gtemp.Date = "";
  1681. gtemp.Moment = "";
  1682. gtemp.StartAddress = OA_DataTable.Rows[0]["Address"].ToString();
  1683. gtemp.EndAddress = h.HotelAddress;
  1684. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  1685. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  1686. //gmrs.Add(gtemp);
  1687. }
  1688. catch
  1689. {
  1690. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  1691. {
  1692. OATemp = OATemp + "。 (谷歌接口异常,无法测算路程时间)";
  1693. }
  1694. else
  1695. {
  1696. trip = trip + "。 (谷歌接口异常,无法测算路程时间)";
  1697. }
  1698. }
  1699. }
  1700. }
  1701. }
  1702. #endregion
  1703. }
  1704. }
  1705. }
  1706. #endregion
  1707. #region 酒店
  1708. foreach (var h in listht)
  1709. {
  1710. if (Convert.ToDateTime(h.CheckInDate) <= Convert.ToDateTime(timeList[i])
  1711. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))//不去“》=”的原因是行程最后一天一般不会有酒店
  1712. {
  1713. //利用谷歌API计算路线
  1714. if (AirPort != "")
  1715. {
  1716. GoogleMapApiResult g = null;
  1717. if (g != null)
  1718. {
  1719. trip = trip + "\r\n"
  1720. + leaveAirPortTime + " 乘车前往酒店:(" + g.Distance + "," + g.Time + ")";
  1721. //计算“抵达酒店办理入住手续”的时间
  1722. string CheckInHotelTime;
  1723. //处理时间格式
  1724. string hours = "", mins = "";
  1725. if (g.Time.Contains("hour"))
  1726. {
  1727. g.Time = g.Time.Replace("hour", "h");
  1728. }
  1729. else if (g.Time.Contains("hours"))
  1730. {
  1731. g.Time = g.Time.Replace("hours", "h");
  1732. }
  1733. g.Time = g.Time.Replace("mins", "m");
  1734. if (g.Time.Contains("h"))
  1735. {
  1736. hours = g.Time.Split('h')[0].Trim();
  1737. }
  1738. else if (!g.Time.Contains("h"))
  1739. {
  1740. mins = g.Time.Split('m')[0].Trim();
  1741. }
  1742. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  1743. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  1744. min = min + Convert.ToInt32(mins);
  1745. if (min > 59)
  1746. {
  1747. min = min - 60;
  1748. hour = hour + 1;
  1749. }
  1750. if (hours != "")
  1751. {
  1752. hour = hour + Convert.ToInt32(hours);
  1753. }
  1754. if (hour > 23)
  1755. {
  1756. hour = hour - 24;
  1757. }
  1758. CheckInHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  1759. CheckInHotelTime = CheckInHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  1760. trip = trip + "\r\n"
  1761. + CheckInHotelTime + " 抵达酒店办理入住手续";
  1762. }
  1763. else
  1764. {
  1765. try
  1766. {
  1767. JObject Result = GetDirectionByGoogleApi(AirPort, h.HotelAddress);
  1768. trip = trip + "\r\n"
  1769. + leaveAirPortTime + " 乘车前往酒店:(" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  1770. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  1771. //计算“抵达酒店办理入住手续”的时间
  1772. string CheckInHotelTime;
  1773. //处理时间格式
  1774. string Gtime = "", hours = "", mins = "";
  1775. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  1776. {
  1777. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  1778. }
  1779. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  1780. {
  1781. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  1782. }
  1783. Gtime = Gtime.Replace("mins", "m");
  1784. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  1785. {
  1786. hours = Gtime.Split('h')[0].Trim();
  1787. }
  1788. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  1789. {
  1790. mins = Gtime.Split('m')[0].Trim();
  1791. }
  1792. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  1793. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  1794. min = min + Convert.ToInt32(mins);
  1795. if (min > 59)
  1796. {
  1797. min = min - 60;
  1798. hour = hour + 1;
  1799. }
  1800. if (hours != "")
  1801. {
  1802. hour = hour + Convert.ToInt32(hours);
  1803. }
  1804. if (hour > 23)
  1805. {
  1806. hour = hour - 24;
  1807. }
  1808. CheckInHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  1809. CheckInHotelTime = CheckInHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  1810. trip = trip + "\r\n"
  1811. + CheckInHotelTime + " 抵达酒店办理入住手续";
  1812. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  1813. gtemp.Diid = di.Id;
  1814. gtemp.Date = "";
  1815. gtemp.Moment = "";
  1816. gtemp.StartAddress = AirPort;
  1817. gtemp.EndAddress = h.HotelAddress;
  1818. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  1819. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  1820. //gmrs.Add(gtemp);
  1821. }
  1822. catch
  1823. {
  1824. trip = trip + "\r\n"
  1825. + " (谷歌接口异常,无法测算的路程时间)";
  1826. }
  1827. }
  1828. }
  1829. trip = trip + "\r\n"
  1830. + " 酒店名称:" + h.HotelName + "\r\n"
  1831. + " 酒店地址:" + h.HotelAddress + "\r\n"
  1832. + " 酒店电话:" + h.HotelTel + " 酒店传真:" + (h.HotelFax == "" ? "-" : h.HotelFax);
  1833. if (i == 0 && !string.IsNullOrEmpty(OATemp))
  1834. {
  1835. trip = trip + "\r\n" + OATemp;
  1836. }
  1837. }
  1838. }
  1839. #endregion
  1840. #region 当天交通工具赋值
  1841. //一般行程第一天都是先乘坐飞机后乘坐汽车
  1842. if (i == 0)
  1843. {
  1844. tlTemp.Traffic_First = "飞机";
  1845. tlTemp.Traffic_Second = "汽车";
  1846. }
  1847. else
  1848. {
  1849. // 根据车导地接表数据判断交通工具:汽车
  1850. List<Grp_CarTouristGuideGroundReservations> ListCar = listctg.FindAll(c => Convert.ToDateTime(c.ServiceStartTime) <= Convert.ToDateTime(timeList[i])
  1851. && Convert.ToDateTime(c.ServiceEndTime) >= Convert.ToDateTime(timeList[i]));
  1852. //交通工具:汽车
  1853. if (ListCar.Count > 0)
  1854. {
  1855. tlTemp.Traffic_First = "汽车";
  1856. //交通工具:飞机
  1857. if (airSign == true)
  1858. {
  1859. tlTemp.Traffic_Second = "飞机";
  1860. }
  1861. else
  1862. {
  1863. tlTemp.Traffic_Second = "";
  1864. }
  1865. }
  1866. else
  1867. {
  1868. tlTemp.Traffic_First = "汽车";
  1869. //交通工具:飞机
  1870. if (airSign == true)
  1871. {
  1872. tlTemp.Traffic_Second = "飞机";
  1873. }
  1874. else
  1875. {
  1876. tlTemp.Traffic_Second = "";
  1877. }
  1878. }
  1879. }
  1880. #endregion
  1881. tlTemp.Trip = trip;
  1882. tlTemp.CreateUserId = di.Id;
  1883. tlTemp.CreateTime = GetBeijingTime();
  1884. tlTemp.Issel = 1;
  1885. tlTemp.Diffgroup = 1;
  1886. tlTemp.IsDel = 0;
  1887. AddTravelList(tlTemp);
  1888. }
  1889. }
  1890. else if (timeList.Count < listTravel.Count)//2改版天数<原版天数
  1891. {
  1892. //2.1替换日期
  1893. for (int i = 0; i < timeList.Count; i++)
  1894. {
  1895. //日期转换星期
  1896. string weekday = weekdays[(int)new DateTime(
  1897. Convert.ToInt32(timeList[i].Split('-')[0]),
  1898. Convert.ToInt32(timeList[i].Split('-')[1]),
  1899. Convert.ToInt32(timeList[i].Split('-')[2])).DayOfWeek];
  1900. //日期去掉0
  1901. string monthStr = "Unknown", dayStr = "Unknown";
  1902. if (!string.IsNullOrEmpty(timeList[i]))
  1903. {
  1904. DateTime dateTime = new DateTime();
  1905. bool convertResult = DateTime.TryParse(timeList[i], out dateTime);
  1906. if (convertResult)
  1907. {
  1908. monthStr = dateTime.Month.ToString();
  1909. dayStr = dateTime.Day.ToString();
  1910. }
  1911. }
  1912. //日期
  1913. listTravel[i].Date = monthStr + "月" + dayStr + "日";
  1914. //listTravel[i].Date = timeList[i].Substring(5, 2) + "月" + timeList[i].Substring(8, 2) + "日";
  1915. listTravel[i].WeekDay = weekday;
  1916. listTravel[i].CreateUserId = UserId;
  1917. listTravel[i].CreateTime = GetBeijingTime();
  1918. listTravel[i].IsDel = 0;
  1919. EditTravelList(listTravel[i]);
  1920. }
  1921. //2.2删除多余行程
  1922. DelOld(comb_Diid, listTravel[timeList.Count - 1].Id, listTravel[listTravel.Count - 1].Id);
  1923. }
  1924. else//3改版天数=原版天数
  1925. {
  1926. //3.1替换日期
  1927. for (int i = 0; i < timeList.Count; i++)
  1928. {
  1929. //日期去掉0
  1930. string monthStr = "Unknown", dayStr = "Unknown";
  1931. if (!string.IsNullOrEmpty(timeList[i]))
  1932. {
  1933. DateTime dateTime = new DateTime();
  1934. bool convertResult = DateTime.TryParse(timeList[i], out dateTime);
  1935. if (convertResult)
  1936. {
  1937. monthStr = dateTime.Month.ToString();
  1938. dayStr = dateTime.Day.ToString();
  1939. }
  1940. }
  1941. //日期
  1942. listTravel[i].Date = monthStr + "月" + dayStr + "日";
  1943. //日期转换星期
  1944. string weekday = weekdays[(int)new DateTime(
  1945. Convert.ToInt32(timeList[i].Split('-')[0]),
  1946. Convert.ToInt32(timeList[i].Split('-')[1]),
  1947. Convert.ToInt32(timeList[i].Split('-')[2])).DayOfWeek];
  1948. listTravel[i].WeekDay = weekday;
  1949. listTravel[i].CreateUserId = UserId;
  1950. listTravel[i].CreateTime = GetBeijingTime();
  1951. listTravel[i].IsDel = 0;
  1952. EditTravelList(listTravel[i]);
  1953. }
  1954. }
  1955. }
  1956. else //若本团不存行程,则生成行程。 包含机票、酒店、车导地接等数据
  1957. {
  1958. //航班号标识
  1959. //string flightcode_Sign = "";
  1960. //三字码标识
  1961. //string citycode_Sign = "";
  1962. #region 城市数据 20210823 贾文滔
  1963. List<CityInDate> CityInDateList = GetCityByDataTable(dt);
  1964. #endregion
  1965. //生成行程
  1966. for (int i = 0; i < timeList.Count; i++)
  1967. {
  1968. //实、例化一个temp
  1969. Grp_TravelList tlTemp = new Grp_TravelList();
  1970. //团号
  1971. tlTemp.Diid = di.Id;
  1972. //天数序号
  1973. tlTemp.Days = i + 1;
  1974. //日期去掉0
  1975. var datetime1 = timeList[i];
  1976. string monthStr = "Unknown", dayStr = "Unknown";
  1977. if (!string.IsNullOrEmpty(datetime1))
  1978. {
  1979. DateTime dateTime = new DateTime();
  1980. bool convertResult = DateTime.TryParse(datetime1, out dateTime);
  1981. if (convertResult)
  1982. {
  1983. monthStr = dateTime.Month.ToString();
  1984. dayStr = dateTime.Day.ToString();
  1985. }
  1986. }
  1987. //日期
  1988. tlTemp.Date = monthStr + "月" + dayStr + "日";
  1989. //日期
  1990. //tlTemp.Date = timeList[i].Substring(5, 2) + "月" + timeList[i].Substring(8, 2) + "日";
  1991. //日期转换星期
  1992. string weekday = weekdays[(int)new DateTime(
  1993. Convert.ToInt32(timeList[i].Split('-')[0]),
  1994. Convert.ToInt32(timeList[i].Split('-')[1]),
  1995. Convert.ToInt32(timeList[i].Split('-')[2])).DayOfWeek];
  1996. tlTemp.WeekDay = weekday;
  1997. //行程
  1998. string trip = "";
  1999. //历经城市
  2000. string city = "";
  2001. #region 机票数据
  2002. //根据航班信息推出抵达机场的位置信息
  2003. string AirPort = "";
  2004. //根据航班时间前后推进入机场或离开机场的时间
  2005. string GoAirportTime = "", leaveAirPortTime = "";
  2006. //飞机标识
  2007. bool airSign = false;
  2008. //查询该日期下的航班信息
  2009. //resultRows字段顺序为:航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间,整理后的起飞日期,整理后的到达日期
  2010. DataRow[] resultRows = dt.Select("Day like '%" + timeList[i] + "%'");
  2011. if (resultRows.Count() > 0)
  2012. {
  2013. //修改标识
  2014. airSign = true;
  2015. }
  2016. //同一天只有一条数据走正常判定
  2017. if (resultRows.Count() == 1)
  2018. {
  2019. #region 三字码
  2020. string _citycode = resultRows[0]["Three"].ToString();
  2021. //起飞城市三字码
  2022. Res_ThreeCode font_threecode = null;
  2023. string font_citycode = _citycode.Replace("/", string.Empty).Substring(0, 3);
  2024. //抵达城市
  2025. string font_City = "";
  2026. //起飞城市机场
  2027. string font_Airport = "";
  2028. //抵达城市三字码
  2029. Res_ThreeCode back_threecode = null;
  2030. string end_citycode = _citycode.Replace("/", string.Empty).Substring(3, 3);
  2031. //抵达城市机场
  2032. string back_Airport = "";
  2033. //抵达城市
  2034. string back_City = "";
  2035. font_threecode = getByThree(font_citycode);
  2036. //验证是否存在三字码
  2037. if (font_threecode == null)
  2038. {
  2039. city = city + "【此三字码" + font_citycode + "未收录,请机票同事录入】" + "一";
  2040. font_Airport = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  2041. font_City = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  2042. }
  2043. else
  2044. {
  2045. city = city + "/" + font_threecode.City;
  2046. font_Airport = font_threecode.AirPort;
  2047. font_City = font_threecode.City; ;
  2048. }
  2049. back_threecode = getByThree(end_citycode);
  2050. if (back_threecode == null)
  2051. {
  2052. city = city + "【此三字码" + end_citycode + "未收录,请机票同事录入】" + "一";
  2053. back_Airport = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  2054. back_City = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  2055. }
  2056. else
  2057. {
  2058. city = city + "/" + back_threecode.City;
  2059. //部分黄热病国家,需要提醒打疫苗
  2060. string result = GetCountryInfo(back_threecode.Country);
  2061. if (result.Contains("3"))
  2062. {
  2063. city += "(此地区为黄热病地区,请注意打疫苗)";
  2064. }
  2065. back_Airport = back_threecode.AirPort;
  2066. back_City = back_threecode.City;
  2067. //查询酒店路线要用
  2068. AirPort = back_threecode.AirPort;
  2069. }
  2070. //行程里加入城市
  2071. #endregion
  2072. #region 信息准备
  2073. trip = city.TrimStart('/');
  2074. //起飞航站楼
  2075. string _StartBuilding = resultRows[0]["StartBuilding"].ToString();
  2076. //转机航站楼
  2077. string _EndBuilding = resultRows[0]["EndBuilding"].ToString();
  2078. //起飞时刻
  2079. string _startTime = resultRows[0]["StartTime"].ToString();
  2080. //飞行时刻
  2081. string _flightTime = resultRows[0]["FlightTime"].ToString();
  2082. _flightTime = _flightTime.Contains("H") ? _flightTime.Split('H')[0] + "小时" + _flightTime.Split('H')[1].Split('M')[0] + "分钟" : _flightTime.Split('M')[0] + "分钟";
  2083. //到达时刻
  2084. string _endTime = resultRows[0]["EndTime"].ToString();
  2085. //航班号
  2086. string _flightcode = resultRows[0]["Fliagtcode"].ToString();
  2087. //航司
  2088. Res_AirCompany aircompany = getByShortCode(_flightcode.Substring(0, 2));
  2089. string _aircompany_Name = "";
  2090. if (aircompany == null)
  2091. {
  2092. _aircompany_Name = "【此航司" + resultRows[0]["Fliagtcode"].ToString().Substring(0, 2) + "未收录,请机票同事录入】";
  2093. }
  2094. else
  2095. {
  2096. _aircompany_Name = aircompany.CnName;
  2097. }
  2098. //机型判断
  2099. string airModel = resultRows[0]["AirModel"].ToString();
  2100. airModel = GetLonger(airModel.Substring(0, 1)) + airModel;
  2101. #endregion
  2102. #region trip编辑
  2103. //若本行抵达时间包含"+1",则本行为母版行,仅提示登机
  2104. if (resultRows[0]["Sign"].ToString() == "0" && _endTime.Contains("+"))
  2105. {
  2106. //根据航班信息推算进入机场的时间
  2107. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前两小时
  2108. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前三小时
  2109. if (result.Contains("2"))
  2110. {
  2111. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  2112. }
  2113. if (temp < 0)
  2114. {
  2115. temp = temp + 24;
  2116. }
  2117. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2118. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  2119. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  2120. if (i > 0)
  2121. {
  2122. #region 酒店
  2123. foreach (var h in listht)
  2124. {
  2125. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  2126. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))
  2127. {
  2128. //利用谷歌API计算路线
  2129. if (AirPort != "")
  2130. {
  2131. GoogleMapApiResult g = null;
  2132. if (g != null)
  2133. {
  2134. //计算“酒店到机场”的时间
  2135. string CheckoutHotelTime;
  2136. //处理时间格式
  2137. string hours = "", mins = "";
  2138. if (g.Time.Contains("hour"))
  2139. {
  2140. g.Time = g.Time.Replace("hour", "h");
  2141. }
  2142. else if (g.Time.Contains("hours"))
  2143. {
  2144. g.Time = g.Time.Replace("hours", "h");
  2145. }
  2146. g.Time = g.Time.Replace("mins", "m");
  2147. if (g.Time.Contains("h"))
  2148. {
  2149. hours = g.Time.Split('h')[0].Trim();
  2150. }
  2151. else if (!g.Time.Contains("h"))
  2152. {
  2153. mins = g.Time.Split('m')[0].Trim();
  2154. }
  2155. int hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  2156. int min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  2157. min = min - Convert.ToInt32(mins);
  2158. if (min < 0)
  2159. {
  2160. min = min + 60;
  2161. hour = hour - 1;
  2162. }
  2163. if (hours != "")
  2164. {
  2165. hour = hour - Convert.ToInt32(hours);
  2166. }
  2167. if (hour < 0)
  2168. {
  2169. hour = hour + 24;
  2170. }
  2171. CheckoutHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  2172. CheckoutHotelTime = CheckoutHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  2173. trip = trip + "\r\n"
  2174. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  2175. }
  2176. else
  2177. {
  2178. try
  2179. {
  2180. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  2181. //计算“抵达酒店办理入住手续”的时间
  2182. string CheckoutHotelTime;
  2183. //处理时间格式
  2184. string Gtime = "", hours = "", mins = "";
  2185. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  2186. {
  2187. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  2188. }
  2189. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  2190. {
  2191. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  2192. }
  2193. Gtime = Gtime.Replace("mins", "m");
  2194. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  2195. {
  2196. hours = Gtime.Split('h')[0].Trim();
  2197. }
  2198. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  2199. {
  2200. mins = Gtime.Split('m')[0].Trim();
  2201. }
  2202. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2203. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2204. min = min - Convert.ToInt32(mins);
  2205. if (min < 0)
  2206. {
  2207. min = min + 60;
  2208. hour = hour - 1;
  2209. }
  2210. if (hours != "")
  2211. {
  2212. hour = hour + Convert.ToInt32(hours);
  2213. }
  2214. if (hour < 0)
  2215. {
  2216. hour = hour + 24;
  2217. }
  2218. CheckoutHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  2219. CheckoutHotelTime = CheckoutHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  2220. trip = trip + "\r\n"
  2221. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  2222. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  2223. gtemp.Diid = di.Id;
  2224. gtemp.Date = "";
  2225. gtemp.Moment = "";
  2226. gtemp.StartAddress = AirPort;
  2227. gtemp.EndAddress = h.HotelAddress;
  2228. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  2229. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  2230. //gmrs.Add(gtemp);
  2231. }
  2232. catch
  2233. {
  2234. trip = trip + "\r\n"
  2235. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  2236. }
  2237. }
  2238. }
  2239. }
  2240. }
  2241. #endregion
  2242. }
  2243. //行程
  2244. trip = trip
  2245. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  2246. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  2247. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");";
  2248. //标记本行为母版行
  2249. //flightcode_Sign = resultRows[0]["Fliagtcode"].ToString();
  2250. //citycode_Sign = resultRows[0]["Three"].ToString();
  2251. }
  2252. //与前一行航班号,三字码相同且本行抵达时间不包含"+1",则本行是被生成的重复行,仅提示抵达
  2253. else if (resultRows[0]["Sign"].ToString() == "1") /* && (!_endTime.Contains("+"))&&(_flightcode == flightcode_Sign)&&(_citycode == citycode_Sign)*/
  2254. {
  2255. //行程
  2256. trip = trip
  2257. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  2258. //根据航班信息推算离开机场的时间
  2259. int temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  2260. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2261. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  2262. if (i == timeList.Count - 1)//如果本日是行程的最后一天,则提醒“行程圆满结束”
  2263. {
  2264. trip = trip + ",圆满结束此次访问之行!";
  2265. }
  2266. else //如果本日不是行程的最后一天,正常提醒
  2267. {
  2268. trip += pushTrip(leaveAirPortTime, back_Airport, city, out leaveAirPortTime);
  2269. trip = trip + ";\r\n" + leaveAirPortTime + "搭乘专车前往酒店,抵达后办理入住;";
  2270. }
  2271. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  2272. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2273. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2274. min = min + 10;
  2275. if (min > 59)
  2276. {
  2277. min = min - 60;
  2278. hour = hour + 1;
  2279. }
  2280. if (hour > 23)
  2281. {
  2282. hour = hour - 24;
  2283. }
  2284. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  2285. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  2286. }
  2287. //正常提示
  2288. else
  2289. {
  2290. //根据航班信息推算进入机场的时间
  2291. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前2小时
  2292. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前3小时
  2293. if (result.Contains("2"))
  2294. {
  2295. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  2296. }
  2297. if (temp < 0)
  2298. {
  2299. temp = temp + 24;
  2300. }
  2301. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2302. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  2303. //根据航班信息推算离开机场的时间
  2304. temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  2305. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2306. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  2307. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  2308. if (i > 0)
  2309. {
  2310. #region 酒店
  2311. foreach (var h in listht)
  2312. {
  2313. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  2314. && Convert.ToDateTime(h.CheckOutDate) >= Convert.ToDateTime(timeList[i]))
  2315. {
  2316. //利用谷歌API计算路线
  2317. if (AirPort != "")
  2318. {
  2319. GoogleMapApiResult g = null;
  2320. if (g != null)
  2321. {
  2322. //计算“酒店到机场”的时间
  2323. string CheckoutHotelTime;
  2324. //处理时间格式
  2325. string hours = "0", mins = "0";
  2326. if (g.Time.Contains("hour"))
  2327. {
  2328. g.Time = g.Time.Replace("hour", "h");
  2329. }
  2330. else if (g.Time.Contains("hours"))
  2331. {
  2332. g.Time = g.Time.Replace("hours", "h");
  2333. }
  2334. g.Time = g.Time.Replace("mins", "m");
  2335. if (g.Time.Contains("h"))
  2336. {
  2337. hours = g.Time.Split('h')[0].Trim();
  2338. }
  2339. else if (!g.Time.Contains("h"))
  2340. {
  2341. mins = g.Time.Split('m')[0].Trim();
  2342. }
  2343. int _hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  2344. int _min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  2345. _min = _min - Convert.ToInt32(mins);
  2346. if (_min < 0)
  2347. {
  2348. _min = _min + 60;
  2349. _hour = _hour - 1;
  2350. }
  2351. if (hours != "")
  2352. {
  2353. _hour = _hour - Convert.ToInt32(hours);
  2354. }
  2355. if (_hour < 0)
  2356. {
  2357. _hour = _hour + 24;
  2358. }
  2359. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  2360. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  2361. trip = trip + "\r\n"
  2362. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  2363. }
  2364. else
  2365. {
  2366. try
  2367. {
  2368. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  2369. //计算“抵达酒店办理入住手续”的时间
  2370. string CheckoutHotelTime;
  2371. //处理时间格式
  2372. string Gtime = "", hours = "0", mins = "0";
  2373. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  2374. {
  2375. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  2376. }
  2377. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  2378. {
  2379. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  2380. }
  2381. Gtime = Gtime.Replace("mins", "m");
  2382. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  2383. {
  2384. hours = Gtime.Split('h')[0].Trim();
  2385. }
  2386. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  2387. {
  2388. mins = Gtime.Split('m')[0].Trim();
  2389. }
  2390. int _hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2391. int _min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2392. _min = _min - Convert.ToInt32(mins);
  2393. if (_min < 0)
  2394. {
  2395. _min = _min + 60;
  2396. _hour = _hour - 1;
  2397. }
  2398. if (hours != "")
  2399. {
  2400. _hour = _hour + Convert.ToInt32(hours);
  2401. }
  2402. if (_hour < 0)
  2403. {
  2404. _hour = _hour + 24;
  2405. }
  2406. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  2407. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  2408. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  2409. gtemp.Diid = di.Id;
  2410. gtemp.Date = "";
  2411. gtemp.Moment = "";
  2412. gtemp.StartAddress = AirPort;
  2413. gtemp.EndAddress = h.HotelAddress;
  2414. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  2415. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  2416. //gmrs.Add(gtemp);
  2417. trip = trip + "\r\n"
  2418. + CheckoutHotelTime + " 乘车前往机场:(" + gtemp.Distance + "," + gtemp.Time + ")";
  2419. }
  2420. catch
  2421. {
  2422. trip = trip + "\r\n"
  2423. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  2424. }
  2425. }
  2426. }
  2427. }
  2428. }
  2429. #endregion
  2430. }
  2431. trip = trip
  2432. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  2433. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  2434. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  2435. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  2436. if (i == timeList.Count - 1)//如果本日是行程的最后一天,先增加酒店到机场的距离时间,再在末尾提醒“行程圆满结束”
  2437. {
  2438. trip = trip + ",圆满结束此次访问之行!";
  2439. }
  2440. else //如果本日不是行程的最后一天,正常提醒
  2441. {
  2442. trip += pushTrip(leaveAirPortTime, back_Airport, city, out leaveAirPortTime);
  2443. trip = trip + "\r\n" + leaveAirPortTime + " 搭乘专车前往酒店,抵达后办理入住;";
  2444. }
  2445. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  2446. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2447. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2448. min = min + 10;
  2449. if (min > 59)
  2450. {
  2451. min = min - 60;
  2452. hour = hour + 1;
  2453. }
  2454. if (hour > 23)
  2455. {
  2456. hour = hour - 24;
  2457. }
  2458. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  2459. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  2460. }
  2461. #endregion
  2462. }
  2463. //同一天多条数据走分类讨论
  2464. else
  2465. {
  2466. for (int n = 0; n < resultRows.Count(); n++)
  2467. {
  2468. city = "";
  2469. #region 三字码
  2470. string _citycode = resultRows[n]["Three"].ToString();
  2471. //起飞城市三字码
  2472. Res_ThreeCode font_threecode = null;
  2473. string font_citycode = _citycode.Replace("/", string.Empty).Substring(0, 3);
  2474. //抵达城市
  2475. string font_City = "";
  2476. //起飞城市机场
  2477. string font_Airport = "";
  2478. //抵达城市三字码
  2479. Res_ThreeCode back_threecode = null;
  2480. string end_citycode = _citycode.Replace("/", string.Empty).Substring(3, 3);
  2481. //抵达城市机场
  2482. string back_Airport = "";
  2483. //抵达城市
  2484. string back_City = "";
  2485. font_threecode = getByThree(font_citycode);
  2486. //验证是否存在三字码
  2487. if (font_threecode == null)
  2488. {
  2489. city = city + "【此三字码" + font_citycode + "未收录,请机票同事录入】" + "一";
  2490. font_Airport = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  2491. font_City = "【此三字码" + font_citycode + "未收录,请机票同事录入】";
  2492. }
  2493. else
  2494. {
  2495. city = city + "/" + font_threecode.City;
  2496. font_Airport = font_threecode.AirPort;
  2497. font_City = font_threecode.City; ;
  2498. }
  2499. back_threecode = getByThree(end_citycode);
  2500. if (back_threecode == null)
  2501. {
  2502. city = city + "【此三字码" + end_citycode + "未收录,请机票同事录入】" + "一";
  2503. back_Airport = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  2504. back_City = "【此三字码" + end_citycode + "未收录,请机票同事录入】";
  2505. }
  2506. else
  2507. {
  2508. city = city + "/" + back_threecode.City;
  2509. //部分黄热病国家,需要提醒打疫苗
  2510. string result = GetCountryInfo(back_threecode.Country);
  2511. if (result.Contains("3"))
  2512. {
  2513. city += "(此地区为黄热病地区,请注意打疫苗)";
  2514. }
  2515. back_Airport = back_threecode.AirPort;
  2516. back_City = back_threecode.City;
  2517. //查询酒店路线要用
  2518. AirPort = back_threecode.AirPort;
  2519. }
  2520. //行程里加入城市
  2521. if (trip == "")
  2522. {
  2523. trip = city.TrimStart('/');
  2524. }
  2525. else
  2526. {
  2527. trip = trip + "\r\n"
  2528. + city.TrimStart('/');
  2529. }
  2530. //起飞航站楼
  2531. string _StartBuilding = resultRows[n]["StartBuilding"].ToString();
  2532. //转机航站楼
  2533. string _EndBuilding = resultRows[n]["EndBuilding"].ToString();
  2534. //起飞时刻
  2535. string _startTime = resultRows[n]["StartTime"].ToString();
  2536. //飞行时刻
  2537. string _flightTime = resultRows[n]["FlightTime"].ToString();
  2538. _flightTime = _flightTime.Contains("H") ? _flightTime.Split('H')[0] + "小时" + _flightTime.Split('H')[1].Split('M')[0] + "分钟" : _flightTime.Split('M')[0] + "分钟";
  2539. //到达时刻
  2540. string _endTime = resultRows[n]["EndTime"].ToString();
  2541. //航班号
  2542. string _flightcode = resultRows[n]["Fliagtcode"].ToString();
  2543. //航司
  2544. Res_AirCompany aircompany = getByShortCode(_flightcode.Substring(0, 2));
  2545. string _aircompany_Name = "";
  2546. if (aircompany == null)
  2547. {
  2548. _aircompany_Name = "【此航司" + resultRows[n]["Fliagtcode"].ToString().Substring(0, 2) + "未收录,请机票同事录入】";
  2549. }
  2550. else
  2551. {
  2552. _aircompany_Name = aircompany.CnName;
  2553. }
  2554. //机型判断
  2555. string airModel = resultRows[n]["AirModel"].ToString();
  2556. airModel = GetLonger(airModel.Substring(0, 1)) + airModel;
  2557. #endregion
  2558. //Sign字段为标识,string类型,含义:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2559. //目前存在两种情况:同一天的多条数据标识为“0->0”或“1->0”
  2560. //如下示例
  2561. //Day ArrivedDate Sign
  2562. //10 10 0
  2563. //10 11 0
  2564. //11 11 1
  2565. //11 12 0
  2566. //12 12 1
  2567. if (n == 0)
  2568. {
  2569. //原生机票代码
  2570. if (resultRows[n]["Sign"].ToString() == "0")
  2571. {
  2572. #region trip编辑
  2573. //根据航班信息推算进入机场的时间
  2574. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前两小时
  2575. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前三小时
  2576. if (result.Contains("2"))
  2577. {
  2578. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  2579. }
  2580. if (temp < 0)
  2581. {
  2582. temp = temp + 24;
  2583. }
  2584. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2585. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  2586. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  2587. if (i > 0)
  2588. {
  2589. #region 酒店
  2590. foreach (var h in listht)
  2591. {
  2592. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  2593. && Convert.ToDateTime(h.CheckOutDate) >= Convert.ToDateTime(timeList[i]))
  2594. {
  2595. //利用谷歌API计算路线
  2596. if (AirPort != "")
  2597. {
  2598. GoogleMapApiResult g = null;
  2599. if (g != null)
  2600. {
  2601. //计算“酒店到机场”的时间
  2602. string CheckoutHotelTime;
  2603. //处理时间格式
  2604. string hours = "0", mins = "0";
  2605. if (g.Time.Contains("hour"))
  2606. {
  2607. g.Time = g.Time.Replace("hour", "h");
  2608. }
  2609. else if (g.Time.Contains("hours"))
  2610. {
  2611. g.Time = g.Time.Replace("hours", "h");
  2612. }
  2613. g.Time = g.Time.Replace("mins", "m");
  2614. if (g.Time.Contains("h"))
  2615. {
  2616. hours = g.Time.Split('h')[0].Trim();
  2617. }
  2618. else if (!g.Time.Contains("h"))
  2619. {
  2620. mins = g.Time.Split('m')[0].Trim();
  2621. }
  2622. int _hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  2623. int _min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  2624. _min = _min - Convert.ToInt32(mins);
  2625. if (_min < 0)
  2626. {
  2627. _min = _min + 60;
  2628. _hour = _hour - 1;
  2629. }
  2630. if (hours != "")
  2631. {
  2632. _hour = _hour - Convert.ToInt32(hours);
  2633. }
  2634. if (_hour < 0)
  2635. {
  2636. _hour = _hour + 24;
  2637. }
  2638. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  2639. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  2640. trip = trip + "\r\n"
  2641. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  2642. }
  2643. else
  2644. {
  2645. try
  2646. {
  2647. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  2648. //计算“抵达酒店办理入住手续”的时间
  2649. string CheckoutHotelTime;
  2650. //处理时间格式
  2651. string Gtime = "", hours = "0", mins = "0";
  2652. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  2653. {
  2654. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  2655. }
  2656. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  2657. {
  2658. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  2659. }
  2660. Gtime = Gtime.Replace("mins", "m");
  2661. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  2662. {
  2663. hours = Gtime.Split('h')[0].Trim();
  2664. }
  2665. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  2666. {
  2667. mins = Gtime.Split('m')[0].Trim();
  2668. }
  2669. int _hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2670. int _min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2671. _min = _min - Convert.ToInt32(mins);
  2672. if (_min < 0)
  2673. {
  2674. _min = _min + 60;
  2675. _hour = _hour - 1;
  2676. }
  2677. if (hours != "")
  2678. {
  2679. _hour = _hour + Convert.ToInt32(hours);
  2680. }
  2681. if (_hour < 0)
  2682. {
  2683. _hour = _hour + 24;
  2684. }
  2685. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  2686. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  2687. trip = trip + "\r\n"
  2688. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  2689. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  2690. gtemp.Diid = di.Id;
  2691. gtemp.Date = "";
  2692. gtemp.Moment = "";
  2693. gtemp.StartAddress = AirPort;
  2694. gtemp.EndAddress = h.HotelAddress;
  2695. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  2696. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  2697. //gmrs.Add(gtemp);
  2698. }
  2699. catch
  2700. {
  2701. trip = trip + "\r\n"
  2702. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  2703. }
  2704. }
  2705. }
  2706. }
  2707. }
  2708. #endregion
  2709. }
  2710. trip = trip
  2711. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  2712. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  2713. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  2714. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,提取行李;";
  2715. #endregion
  2716. }
  2717. //"+1"生成的机票代码
  2718. else if (resultRows[n]["Sign"].ToString() == "1")
  2719. {
  2720. #region trip编辑
  2721. //行程
  2722. trip = trip
  2723. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,提取行李;";
  2724. #endregion
  2725. }
  2726. }
  2727. else if (n > 0)
  2728. {
  2729. //若前行是原生的,则本行判定为转机
  2730. if (resultRows[n - 1]["Sign"].ToString() == "0")
  2731. {
  2732. #region trip编辑
  2733. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 1;//一般提前提前2小时
  2734. if (temp < 0)
  2735. {
  2736. temp = temp + 24;
  2737. }
  2738. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2739. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  2740. trip = trip
  2741. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  2742. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  2743. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  2744. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  2745. //若为最后一行,则计算后备等时间
  2746. if (n == resultRows.Count() - 1)
  2747. {
  2748. //根据航班信息推算离开机场的时间
  2749. temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  2750. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2751. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  2752. if (i == timeList.Count - 1)//如果本日是行程的最后一天,先增加酒店到机场的距离时间,再在末尾提醒“行程圆满结束”
  2753. {
  2754. trip = trip + ",圆满结束此次访问之行!";
  2755. }
  2756. else //如果本日不是行程的最后一天,正常提醒
  2757. {
  2758. trip += pushTrip(leaveAirPortTime, back_Airport, city, out leaveAirPortTime);
  2759. trip = trip + ";\r\n" + leaveAirPortTime + "搭乘专车前往酒店,抵达后办理入住;";
  2760. }
  2761. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  2762. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2763. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2764. min = min + 10;
  2765. if (min > 59)
  2766. {
  2767. min = min - 60;
  2768. hour = hour + 1;
  2769. }
  2770. if (hour > 23)
  2771. {
  2772. hour = hour - 24;
  2773. }
  2774. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  2775. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  2776. }
  2777. #endregion
  2778. }
  2779. //若前行是生成的,则本行判定为新出发
  2780. else if (resultRows[n - 1]["Sign"].ToString() == "1")
  2781. {
  2782. #region trip编辑
  2783. //根据航班信息推算进入机场的时间
  2784. int temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 2;//一般提前提前2小时
  2785. string result = GetCountryInfo(back_threecode.Country);//美国或者欧洲国家提前3小时
  2786. if (result.Contains("2"))
  2787. {
  2788. temp = Convert.ToInt32(_startTime.Substring(0, 2)) - 3;//提前3小时
  2789. }
  2790. if (temp < 0)
  2791. {
  2792. temp = temp + 24;
  2793. }
  2794. GoAirportTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2795. GoAirportTime = GoAirportTime + ":" + _startTime.Substring(2, _startTime.Length - 2);
  2796. //根据航班信息推算离开机场的时间
  2797. temp = Convert.ToInt32(_endTime.Substring(0, 2)) + 1;
  2798. leaveAirPortTime = temp < 10 ? "0" + temp.ToString() : temp.ToString();
  2799. leaveAirPortTime = leaveAirPortTime + ":" + _endTime.Substring(2, _endTime.Length - 2);
  2800. //第一天之后的行程可以加上“酒店出发到机场”的距离和时间
  2801. if (i > 0)
  2802. {
  2803. #region 酒店
  2804. foreach (var h in listht)
  2805. {
  2806. if (Convert.ToDateTime(h.CheckInDate) < Convert.ToDateTime(timeList[i])
  2807. && Convert.ToDateTime(h.CheckOutDate) >= Convert.ToDateTime(timeList[i]))
  2808. {
  2809. //利用谷歌API计算路线
  2810. if (AirPort != "")
  2811. {
  2812. GoogleMapApiResult g = null;
  2813. if (g != null)
  2814. {
  2815. //计算“酒店到机场”的时间
  2816. string CheckoutHotelTime;
  2817. //处理时间格式
  2818. string hours = "0", mins = "0";
  2819. if (g.Time.Contains("hour"))
  2820. {
  2821. g.Time = g.Time.Replace("hour", "h");
  2822. }
  2823. else if (g.Time.Contains("hours"))
  2824. {
  2825. g.Time = g.Time.Replace("hours", "h");
  2826. }
  2827. g.Time = g.Time.Replace("mins", "m");
  2828. if (g.Time.Contains("h"))
  2829. {
  2830. hours = g.Time.Split('h')[0].Trim();
  2831. }
  2832. else if (!g.Time.Contains("h"))
  2833. {
  2834. mins = g.Time.Split('m')[0].Trim();
  2835. }
  2836. int _hour = Convert.ToInt32(GoAirportTime.Substring(0, 2));
  2837. int _min = Convert.ToInt32(GoAirportTime.Substring(3, 2));
  2838. _min = _min - Convert.ToInt32(mins);
  2839. if (_min < 0)
  2840. {
  2841. _min = _min + 60;
  2842. _hour = _hour - 1;
  2843. }
  2844. if (hours != "")
  2845. {
  2846. _hour = _hour - Convert.ToInt32(hours);
  2847. }
  2848. if (_hour < 0)
  2849. {
  2850. _hour = _hour + 24;
  2851. }
  2852. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  2853. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  2854. trip = trip + "\r\n"
  2855. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  2856. }
  2857. else
  2858. {
  2859. try
  2860. {
  2861. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, font_Airport);
  2862. //计算“抵达酒店办理入住手续”的时间
  2863. string CheckoutHotelTime;
  2864. //处理时间格式
  2865. string Gtime = "", hours = "0", mins = "0";
  2866. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  2867. {
  2868. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  2869. }
  2870. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  2871. {
  2872. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  2873. }
  2874. Gtime = Gtime.Replace("mins", "m");
  2875. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  2876. {
  2877. hours = Gtime.Split('h')[0].Trim();
  2878. }
  2879. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  2880. {
  2881. mins = Gtime.Split('m')[0].Trim();
  2882. }
  2883. int _hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2884. int _min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2885. _min = _min - Convert.ToInt32(mins);
  2886. if (_min < 0)
  2887. {
  2888. _min = _min + 60;
  2889. _hour = _hour - 1;
  2890. }
  2891. if (hours != "")
  2892. {
  2893. _hour = _hour + Convert.ToInt32(hours);
  2894. }
  2895. if (_hour < 0)
  2896. {
  2897. _hour = _hour + 24;
  2898. }
  2899. CheckoutHotelTime = _hour < 10 ? "0" + _hour.ToString() : _hour.ToString();
  2900. CheckoutHotelTime = CheckoutHotelTime + ":" + (_min < 10 ? "0" + _min.ToString() : _min.ToString());
  2901. trip = trip + "\r\n"
  2902. + CheckoutHotelTime + " 乘车前往机场:(" + g.Distance + "," + g.Time + ")";
  2903. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  2904. gtemp.Diid = di.Id;
  2905. gtemp.Date = "";
  2906. gtemp.Moment = "";
  2907. gtemp.StartAddress = AirPort;
  2908. gtemp.EndAddress = h.HotelAddress;
  2909. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  2910. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  2911. //gmrs.Add(gtemp);
  2912. }
  2913. catch
  2914. {
  2915. trip = trip + "\r\n"
  2916. + " 乘车前往机场:(谷歌接口异常,无法测算的路程时间)";
  2917. }
  2918. }
  2919. }
  2920. }
  2921. }
  2922. #endregion
  2923. }
  2924. trip = trip
  2925. + "\r\n" + GoAirportTime + " 抵达" + font_Airport + _StartBuilding + "航站楼,办理登机手续:"
  2926. + "\r\n" + _startTime.Substring(0, 2) + ":" + _startTime.Substring(2, _startTime.Length - 2) + " 搭乘" + _aircompany_Name + "航空公司" + _flightcode + "航班,由" + font_City + "飞往" + back_City + ";"
  2927. + "\r\n" + " (" + font_Airport + "/" + back_Airport + " 机型:" + airModel + " 飞行时间" + (_flightTime) + ");"
  2928. + "\r\n" + _endTime.Substring(0, 2) + ":" + _endTime.Substring(2, _endTime.Length - 2) + " 抵达" + back_Airport + _EndBuilding + "航站楼,办理入境手续,之后前往提取行李";
  2929. if (i == timeList.Count - 1)//如果本日是行程的最后一天,先增加酒店到机场的距离时间,再在末尾提醒“行程圆满结束”
  2930. {
  2931. trip = trip + ",圆满结束此次访问之行!";
  2932. }
  2933. else //如果本日不是行程的最后一天,正常提醒
  2934. {
  2935. trip += pushTrip(leaveAirPortTime, back_Airport, city, out leaveAirPortTime);
  2936. trip = trip + ";\r\n" + leaveAirPortTime + " 搭乘专车前往酒店,抵达后办理入住;";
  2937. }
  2938. //整理离开机场的时间 +10分钟为"乘车前往酒店"的时刻
  2939. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  2940. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  2941. min = min + 10;
  2942. if (min > 59)
  2943. {
  2944. min = min - 60;
  2945. hour = hour + 1;
  2946. }
  2947. if (hour > 23)
  2948. {
  2949. hour = hour - 24;
  2950. }
  2951. leaveAirPortTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  2952. leaveAirPortTime = leaveAirPortTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  2953. #endregion
  2954. }
  2955. }
  2956. }
  2957. }
  2958. #endregion
  2959. #region 行程和城市赋值
  2960. if (trip == "" || trip == " " || city == "" || city == " ")
  2961. {
  2962. city = CityInDateList.Find(cid => cid.Date == timeList[i]).City;
  2963. //部分黄热病国家,需要提醒打疫苗
  2964. string result = GetCountryInfo(getByCity(city)[0].Country);
  2965. if (result.Contains("3"))
  2966. {
  2967. city += "(此地区为黄热病地区,请注意打疫苗)";
  2968. }
  2969. trip = city;
  2970. }
  2971. #endregion
  2972. #region 公务 20210820 贾文滔
  2973. string OATemp = "";//暂存公务活动
  2974. //根据团号和日期获取公务数据
  2975. List<Res_OfficialActivities> listoa = getByDiidAndDate(comb_Diid, timeList[i]);
  2976. //若listoa存在公务数据,进行排序,再进行导入
  2977. if (listoa != null && listoa.Count > 0)
  2978. {
  2979. //利用datatable存放公务活动数据
  2980. DataTable OA_DataTable = new DataTable();
  2981. OA_DataTable.Columns.Add("StartTime", typeof(string)); //activity开始时刻
  2982. OA_DataTable.Columns.Add("EndTime", typeof(string)); //activity结束时刻
  2983. OA_DataTable.Columns.Add("Client", typeof(string)); //activity单位
  2984. OA_DataTable.Columns.Add("Address", typeof(string)); //activity地址
  2985. OA_DataTable.Columns.Add("Contact", typeof(string)); //activity联系人
  2986. OA_DataTable.Columns.Add("Tel", typeof(string)); //activity联系人电话
  2987. OA_DataTable.Columns.Add("Dresscode", typeof(string)); //activity着装要求
  2988. OA_DataTable.Columns.Add("isTranslate", typeof(bool));//是否需要翻译人员
  2989. OA_DataTable.Columns.Add("Language", typeof(string));//是否需要翻译人员
  2990. //处理公务数据
  2991. for (int b = 0; b < listoa.Count; b++)
  2992. {
  2993. //起止时间
  2994. string[] time = new string[2];
  2995. if (listoa[b].Time.Contains('—'))
  2996. {
  2997. time = listoa[b].Time.Split('—');
  2998. }
  2999. else if (listoa[b].Time.Contains('-'))
  3000. {
  3001. time = listoa[b].Time.Split('-');
  3002. }
  3003. //添加数据
  3004. if (time.Length >= 2)
  3005. {
  3006. OA_DataTable.Rows.Add(time[0], time[1], listoa[b].Client, listoa[b].Address, listoa[b].Contact, listoa[b].Tel, listoa[b].Dresscode, listoa[b].IsNeedTrans, listoa[b].Language);
  3007. }
  3008. else
  3009. {
  3010. //PublicCode.GetAlertMsg(this, GetType(), timeList[i] + "的公务数据有误,请检查");
  3011. }
  3012. }
  3013. //排序
  3014. OA_DataTable.DefaultView.Sort = "StartTime asc";
  3015. OA_DataTable = OA_DataTable.DefaultView.ToTable();
  3016. //导入信息
  3017. for (int index = 0; index < OA_DataTable.Rows.Count; index++)
  3018. {
  3019. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  3020. {
  3021. if (OATemp != "")
  3022. {
  3023. OATemp = OATemp + "\r\n"
  3024. + OA_DataTable.Rows[index]["StartTime"].ToString()
  3025. + "-"
  3026. + OA_DataTable.Rows[index]["EndTime"].ToString()
  3027. + " 拜访" + OA_DataTable.Rows[index]["Client"].ToString()
  3028. + ",联系人:" + OA_DataTable.Rows[index]["Contact"].ToString()
  3029. + ",电话:" + OA_DataTable.Rows[index]["Tel"].ToString()
  3030. + ",地址:" + OA_DataTable.Rows[index]["Address"].ToString()
  3031. + ",着装要求:" + OA_DataTable.Rows[index]["Dresscode"].ToString()
  3032. + ",是否需要翻译:" + (bool.Parse(OA_DataTable.Rows[index]["isTranslate"].ToString()) ? "需要翻译人员" + "翻译语种为" + OA_DataTable.Rows[index]["Language"].ToString() : "不需要翻译人员")
  3033. + ",议题:-";
  3034. }
  3035. else
  3036. {
  3037. OATemp = OA_DataTable.Rows[index]["StartTime"].ToString()
  3038. + "-"
  3039. + OA_DataTable.Rows[index]["EndTime"].ToString()
  3040. + " 拜访" + OA_DataTable.Rows[index]["Client"].ToString()
  3041. + ",联系人:" + OA_DataTable.Rows[index]["Contact"].ToString()
  3042. + ",电话:" + OA_DataTable.Rows[index]["Tel"].ToString()
  3043. + ",地址:" + OA_DataTable.Rows[index]["Address"].ToString()
  3044. + ",着装要求:" + OA_DataTable.Rows[index]["Dresscode"].ToString()
  3045. + ",是否需要翻译:" + (bool.Parse(OA_DataTable.Rows[index]["isTranslate"].ToString()) ? "需要翻译人员" + "翻译语种为" + OA_DataTable.Rows[index]["Language"].ToString() : "不需要翻译人员")
  3046. + ",议题:-";
  3047. }
  3048. }
  3049. else
  3050. {
  3051. //导入公务
  3052. trip = trip + "\r\n"
  3053. + OA_DataTable.Rows[index]["StartTime"].ToString()
  3054. + "-"
  3055. + OA_DataTable.Rows[index]["EndTime"].ToString()
  3056. + " 拜访" + OA_DataTable.Rows[index]["Client"].ToString()
  3057. + ",联系人:" + OA_DataTable.Rows[index]["Contact"].ToString()
  3058. + ",电话:" + OA_DataTable.Rows[index]["Tel"].ToString()
  3059. + ",地址:" + OA_DataTable.Rows[index]["Address"].ToString()
  3060. + ",着装要求:" + OA_DataTable.Rows[index]["Dresscode"].ToString()
  3061. + ",是否需要翻译:" + (bool.Parse(OA_DataTable.Rows[index]["isTranslate"].ToString()) ? "需要翻译人员" + "翻译语种为" + OA_DataTable.Rows[index]["Language"].ToString() : "不需要翻译人员")
  3062. + ",议题:-";
  3063. }
  3064. //当天第一个公务或许都是从酒店出发,因此可计算酒店到公务地址的距离和时间
  3065. if (index == 0)
  3066. {
  3067. #region 酒店
  3068. foreach (var h in listht)
  3069. {
  3070. if (Convert.ToDateTime(h.CheckInDate) <= Convert.ToDateTime(timeList[i])
  3071. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))
  3072. {
  3073. //利用谷歌API计算路线
  3074. GoogleMapApiResult g = null;
  3075. if (g != null)
  3076. {
  3077. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  3078. {
  3079. OATemp = OATemp + "。 (" + g.Distance + "," + g.Time + ")";
  3080. }
  3081. else
  3082. {
  3083. trip = trip + "。 (" + g.Distance + "," + g.Time + ")";
  3084. }
  3085. }
  3086. else
  3087. {
  3088. try
  3089. {
  3090. JObject Result = GetDirectionByGoogleApi(h.HotelAddress, OA_DataTable.Rows[0]["Address"].ToString());
  3091. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  3092. {
  3093. OATemp = OATemp + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  3094. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  3095. }
  3096. else
  3097. {
  3098. trip = trip + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  3099. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  3100. }
  3101. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  3102. gtemp.Diid = di.Id;
  3103. gtemp.Date = "";
  3104. gtemp.Moment = "";
  3105. gtemp.StartAddress = h.HotelAddress;
  3106. gtemp.EndAddress = OA_DataTable.Rows[0]["Address"].ToString();
  3107. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  3108. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  3109. //gmrs.Add(gtemp);
  3110. }
  3111. catch
  3112. {
  3113. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  3114. {
  3115. OATemp = OATemp + "。 (谷歌接口异常,无法测算路程时间)";
  3116. }
  3117. else
  3118. {
  3119. trip = trip + "。 (谷歌接口异常,无法测算路程时间)";
  3120. }
  3121. }
  3122. }
  3123. }
  3124. }
  3125. #endregion
  3126. }
  3127. //第二个公务是由中午的餐厅前往公务地址,具有随机性,因此不计算此方向距离时间;但可计算由公务地址回酒店的信息
  3128. else
  3129. {
  3130. #region 酒店
  3131. foreach (var h in listht)
  3132. {
  3133. if (Convert.ToDateTime(h.CheckInDate) <= Convert.ToDateTime(timeList[i])
  3134. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))
  3135. {
  3136. //利用谷歌API计算路线
  3137. GoogleMapApiResult g = null;
  3138. if (g != null)
  3139. {
  3140. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  3141. {
  3142. OATemp = OATemp + "。 (" + g.Distance + "," + g.Time + ")";
  3143. }
  3144. else
  3145. {
  3146. trip = trip + "。 (" + g.Distance + "," + g.Time + ")";
  3147. }
  3148. }
  3149. else
  3150. {
  3151. try
  3152. {
  3153. JObject Result = GetDirectionByGoogleApi(OA_DataTable.Rows[index]["Address"].ToString(), h.HotelAddress);
  3154. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  3155. {
  3156. OATemp = OATemp + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  3157. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  3158. }
  3159. else
  3160. {
  3161. trip = trip + "。 (" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  3162. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  3163. }
  3164. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  3165. gtemp.Diid = di.Id;
  3166. gtemp.Date = "";
  3167. gtemp.Moment = "";
  3168. gtemp.StartAddress = OA_DataTable.Rows[0]["Address"].ToString();
  3169. gtemp.EndAddress = h.HotelAddress;
  3170. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  3171. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  3172. //gmrs.Add(gtemp);
  3173. }
  3174. catch
  3175. {
  3176. if (i == 0)//行程第一天的公务放在酒店后面,所以先暂存在一个变量里
  3177. {
  3178. OATemp = OATemp + "。 (谷歌接口异常,无法测算路程时间)";
  3179. }
  3180. else
  3181. {
  3182. trip = trip + "。 (谷歌接口异常,无法测算路程时间)";
  3183. }
  3184. }
  3185. }
  3186. }
  3187. }
  3188. #endregion
  3189. }
  3190. }
  3191. }
  3192. #endregion
  3193. #region 酒店
  3194. foreach (var h in listht)
  3195. {
  3196. if (Convert.ToDateTime(h.CheckInDate) <= Convert.ToDateTime(timeList[i])
  3197. && Convert.ToDateTime(h.CheckOutDate) > Convert.ToDateTime(timeList[i]))//不去“》=”的原因是行程最后一天一般不会有酒店
  3198. {
  3199. //利用谷歌API计算路线
  3200. if (AirPort != "")
  3201. {
  3202. GoogleMapApiResult g = null;
  3203. if (g != null)
  3204. {
  3205. trip = trip + "\r\n"
  3206. + leaveAirPortTime + " 乘车前往酒店:(" + g.Distance + "," + g.Time + ")";
  3207. //计算“抵达酒店办理入住手续”的时间
  3208. string CheckInHotelTime;
  3209. //处理时间格式
  3210. string hours = "", mins = "";
  3211. if (g.Time.Contains("hour"))
  3212. {
  3213. g.Time = g.Time.Replace("hour", "h");
  3214. }
  3215. else if (g.Time.Contains("hours"))
  3216. {
  3217. g.Time = g.Time.Replace("hours", "h");
  3218. }
  3219. g.Time = g.Time.Replace("mins", "m");
  3220. if (g.Time.Contains("h"))
  3221. {
  3222. hours = g.Time.Split('h')[0].Trim();
  3223. }
  3224. else if (!g.Time.Contains("h"))
  3225. {
  3226. mins = g.Time.Split('m')[0].Trim();
  3227. }
  3228. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  3229. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  3230. min = min + Convert.ToInt32(mins);
  3231. if (min > 59)
  3232. {
  3233. min = min - 60;
  3234. hour = hour + 1;
  3235. }
  3236. if (hours != "")
  3237. {
  3238. hour = hour + Convert.ToInt32(hours);
  3239. }
  3240. if (hour > 23)
  3241. {
  3242. hour = hour - 24;
  3243. }
  3244. CheckInHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  3245. CheckInHotelTime = CheckInHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  3246. trip = trip + "\r\n"
  3247. + CheckInHotelTime + " 抵达酒店办理入住手续";
  3248. }
  3249. else
  3250. {
  3251. try
  3252. {
  3253. JObject Result = GetDirectionByGoogleApi(AirPort, h.HotelAddress);
  3254. trip = trip + "\r\n"
  3255. + leaveAirPortTime + " 乘车前往酒店:(" + Result["routes"][0]["legs"][0]["distance"]["text"].ToString() + ","
  3256. + Result["routes"][0]["legs"][0]["duration"]["text"].ToString() + ")";
  3257. //计算“抵达酒店办理入住手续”的时间
  3258. string CheckInHotelTime;
  3259. //处理时间格式
  3260. string Gtime = "", hours = "", mins = "";
  3261. if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hour"))
  3262. {
  3263. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hour", "h");
  3264. }
  3265. else if (Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Contains("hours"))
  3266. {
  3267. Gtime = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace("hours", "h");
  3268. }
  3269. Gtime = Gtime.Replace("mins", "m");
  3270. if (!string.IsNullOrEmpty(Gtime) && Gtime.Contains("h"))
  3271. {
  3272. hours = Gtime.Split('h')[0].Trim();
  3273. }
  3274. else if (!string.IsNullOrEmpty(Gtime) && !Gtime.Contains("h"))
  3275. {
  3276. mins = Gtime.Split('m')[0].Trim();
  3277. }
  3278. int hour = Convert.ToInt32(leaveAirPortTime.Substring(0, 2));
  3279. int min = Convert.ToInt32(leaveAirPortTime.Substring(3, 2));
  3280. if (mins != "")
  3281. min = min + Convert.ToInt32(mins);
  3282. if (min > 59)
  3283. {
  3284. min = min - 60;
  3285. hour = hour + 1;
  3286. }
  3287. if (hours != "")
  3288. {
  3289. hour = hour + Convert.ToInt32(hours);
  3290. }
  3291. if (hour > 23)
  3292. {
  3293. hour = hour - 24;
  3294. }
  3295. CheckInHotelTime = hour < 10 ? "0" + hour.ToString() : hour.ToString();
  3296. CheckInHotelTime = CheckInHotelTime + ":" + (min < 10 ? "0" + min.ToString() : min.ToString());
  3297. trip = trip + "\r\n"
  3298. + CheckInHotelTime + " 抵达酒店办理入住手续";
  3299. GoogleMapApiResult gtemp = new GoogleMapApiResult();
  3300. gtemp.Diid = di.Id;
  3301. gtemp.Date = "";
  3302. gtemp.Moment = "";
  3303. gtemp.StartAddress = AirPort;
  3304. gtemp.EndAddress = h.HotelAddress;
  3305. gtemp.Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  3306. gtemp.Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  3307. //gmrs.Add(gtemp);
  3308. }
  3309. catch
  3310. {
  3311. trip = trip + "\r\n"
  3312. + " (谷歌接口异常,无法测算的路程时间)";
  3313. }
  3314. }
  3315. }
  3316. trip = trip + "\r\n"
  3317. + " 酒店名称:" + h.HotelName + "\r\n"
  3318. + " 酒店地址:" + h.HotelAddress + "\r\n"
  3319. + " 酒店电话:" + h.HotelTel + " 酒店传真:" + (h.HotelFax == "" ? "-" : h.HotelFax);
  3320. if (i == 0 && !string.IsNullOrEmpty(OATemp))
  3321. {
  3322. trip = trip + "\r\n" + OATemp;
  3323. }
  3324. }
  3325. }
  3326. #endregion
  3327. #region 当天交通工具赋值
  3328. //一般行程第一天都是先乘坐飞机后乘坐汽车
  3329. if (i == 0)
  3330. {
  3331. tlTemp.Traffic_First = "飞机";
  3332. tlTemp.Traffic_Second = "汽车";
  3333. }
  3334. else
  3335. {
  3336. // 根据车导地接表数据判断交通工具:汽车
  3337. List<Grp_CarTouristGuideGroundReservations> ListCar = listctg.FindAll(c => Convert.ToDateTime(c.ServiceStartTime) <= Convert.ToDateTime(timeList[i])
  3338. && Convert.ToDateTime(c.ServiceEndTime) >= Convert.ToDateTime(timeList[i]));
  3339. //交通工具:汽车
  3340. if (ListCar.Count > 0)
  3341. {
  3342. tlTemp.Traffic_First = "汽车";
  3343. //交通工具:飞机
  3344. if (airSign == true)
  3345. {
  3346. tlTemp.Traffic_Second = "飞机";
  3347. }
  3348. else
  3349. {
  3350. tlTemp.Traffic_Second = "";
  3351. }
  3352. }
  3353. else
  3354. {
  3355. tlTemp.Traffic_First = "汽车";
  3356. //交通工具:飞机
  3357. if (airSign == true)
  3358. {
  3359. tlTemp.Traffic_Second = "飞机";
  3360. }
  3361. else
  3362. {
  3363. tlTemp.Traffic_Second = "";
  3364. }
  3365. }
  3366. }
  3367. #endregion
  3368. tlTemp.Trip = trip;
  3369. tlTemp.CreateUserId = di.Id;
  3370. tlTemp.CreateTime = DateTime.Now;
  3371. //tlTemp.OPdate = PublicCode.GetBeijingTime().ToString("yyyy-MM-dd hh:mm:ss");
  3372. tlTemp.Issel = 1;
  3373. tlTemp.Diffgroup = 1;
  3374. tlTemp.IsDel = 0;
  3375. AddTravelList(tlTemp);
  3376. }
  3377. }
  3378. }
  3379. catch (Exception ex)
  3380. {
  3381. //Response.Write(ex.Message.ToString());
  3382. lblImport.Text = ex.Message;
  3383. }
  3384. lblImport.Text = "数据录入完成";
  3385. }
  3386. }
  3387. private string pushTrip(string timeStr, string startAddress, string endAddress, out string timeOut)
  3388. {
  3389. startAddress = startAddress.Trim().Replace("(此地区为黄热病地区,请注意打疫苗)", "");
  3390. endAddress = endAddress.Trim().Replace("(此地区为黄热病地区,请注意打疫苗)", "");
  3391. decimal conversion = 1.61M;
  3392. DateTime tripTime = DateTime.Now;
  3393. try
  3394. {
  3395. tripTime = DateTime.Parse(timeStr).AddHours(-1);
  3396. }
  3397. catch (Exception e)
  3398. { }
  3399. endAddress = endAddress.TrimStart('/');
  3400. string CheckoutHotelTime = string.Empty;
  3401. string endCity = string.Empty;
  3402. if (endAddress.Contains("/"))
  3403. {
  3404. endCity = endAddress.Split('/')[1] + "市区";
  3405. }
  3406. else
  3407. {
  3408. endCity = endAddress + "市区";
  3409. }
  3410. string Time = string.Empty;
  3411. string Distance = string.Empty;
  3412. int GetGoogleResult = 0;
  3413. JObject Result = null;
  3414. try
  3415. {
  3416. Result = GetDirectionByGoogleApi(startAddress, endCity);
  3417. Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString();
  3418. Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString();
  3419. if (Time.Contains("hours"))
  3420. {
  3421. Time = Time.Replace("hours", "小时");
  3422. }
  3423. else if (Time.Contains("hour"))
  3424. {
  3425. Time = Time.Replace("hour", "小时");
  3426. }
  3427. Time = Time.Replace("mins", "分钟");
  3428. if (Time.Contains("小时"))
  3429. {
  3430. GetGoogleResult = int.Parse(Regex.Split(Regex.Split(Time, "小时")[1], "分钟")[0]);
  3431. }
  3432. else if (Time.Contains("分钟"))
  3433. {
  3434. GetGoogleResult = int.Parse(Regex.Split(Time, "分钟")[0]);
  3435. }
  3436. if (Distance.Contains("mi"))
  3437. {
  3438. var distSp = Regex.Split(Distance, "mi");
  3439. if (distSp.Length > 0)
  3440. {
  3441. Distance = (decimal.Parse(distSp[0]) * conversion).ToString("#0.00") + " 公里";
  3442. }
  3443. }
  3444. else if (Distance.Contains("km"))
  3445. {
  3446. Distance = Distance.Replace("km", "公里");
  3447. }
  3448. Time = Time.Replace(" ", "");
  3449. Distance = Distance.Replace(" ", "");
  3450. }
  3451. catch (Exception e)
  3452. {
  3453. Time = "未知!";
  3454. Distance = "未知!";
  3455. }
  3456. string trip = string.Empty;
  3457. if (timeStr.Contains(":"))
  3458. {
  3459. int H = tripTime.Hour;
  3460. int M = tripTime.Minute;
  3461. if (H < 12)
  3462. {
  3463. tripTime = tripTime.AddMinutes(90);
  3464. CheckoutHotelTime = tripTime.ToString("HH:mm");
  3465. trip += $"\r\n{CheckoutHotelTime} 搭乘专车前往市区";
  3466. trip += $"({startAddress} - {endCity} 路程{Distance},耗时{Time})";
  3467. if (H <= 13)
  3468. {
  3469. tripTime = tripTime.AddMinutes(GetGoogleResult);
  3470. trip += $"\r\n{tripTime.ToString("HH:mm")} 午餐于当地餐厅;";
  3471. }
  3472. }
  3473. else if (H == 12 && M <= 30)
  3474. {
  3475. tripTime = tripTime.AddMinutes(90);
  3476. CheckoutHotelTime = tripTime.ToString("HH:mm");
  3477. trip += $"\r\n{CheckoutHotelTime} 搭乘专车前往市区";
  3478. trip += $"({startAddress} - {endCity} 路程{Distance},耗时{Time})";
  3479. if (H <= 13)
  3480. {
  3481. tripTime = tripTime.AddMinutes(GetGoogleResult);
  3482. trip += $"\r\n{tripTime.ToString("HH:mm")} 午餐于当地餐厅;";
  3483. }
  3484. }
  3485. else if (H >= 14)
  3486. {
  3487. tripTime = tripTime.AddMinutes(90);
  3488. CheckoutHotelTime = tripTime.ToString("HH:mm");
  3489. trip += $"\r\n{CheckoutHotelTime} 搭乘专车前往市区;";
  3490. trip += $"({startAddress} - {endCity} 路程{Distance},耗时{Time})";
  3491. tripTime = DateTime.Parse(CheckoutHotelTime).AddMinutes(GetGoogleResult);
  3492. trip += $"\r\n{tripTime.ToString("HH:mm")} 晚餐于当地餐厅;";
  3493. }
  3494. }
  3495. timeOut = tripTime.AddMinutes(60).ToString("HH:mm");
  3496. return trip;
  3497. }
  3498. /// <summary>
  3499. /// 利用谷歌地图API查询国外两地之间距离
  3500. /// </summary>
  3501. /// <param name="Origin">出发地</param>
  3502. /// <param name="Destination">目的地</param>
  3503. /// <returns>返回Json格式</returns>
  3504. public JObject GetDirectionByGoogleApi(string Origin, string Destination)
  3505. {
  3506. string appkey = "AIzaSyBdLf8u8DinXQWVPLEkdrxOJpClXSqEnho";
  3507. string url = "https://maps.googleapis.com/maps/api/directions/json?origin=" + Origin
  3508. + "&destination=" + Destination + "&key=" + appkey;
  3509. JObject result = null;
  3510. try
  3511. {
  3512. #region 利用HttpWebRequest访问API
  3513. ////创建Web访问对象
  3514. //HttpWebRequest req = HttpWebRequest.Create(url) as HttpWebRequest;
  3515. //req.Method = "GET";
  3516. //req.ContentType = "application/json";
  3517. ////创建web响应对象
  3518. //HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
  3519. ////通过响应内容流创建StreamReader对象,因为StreamReader更高级更快
  3520. //StreamReader reader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
  3521. ////如果有编码问题就用这个方法
  3522. ////string returnXml = HttpUtility.UrlDecode(reader.ReadToEnd());
  3523. ////利用StreamReader就可以从响应内容从头读到尾
  3524. //string returnJson = reader.ReadToEnd();
  3525. ////反序列化
  3526. //result = JsonConvert.DeserializeObject(returnJson) as JObject;
  3527. #endregion
  3528. #region 利用HttpClient访问API
  3529. HttpClient myHttpClient = new HttpClient();
  3530. HttpResponseMessage response = myHttpClient.GetAsync(url).Result;
  3531. //var content = response.Content.ReadAsAsync<object>().Result;
  3532. var content = response.Content.ReadAsStringAsync().Result;
  3533. result = JObject.Parse(content);
  3534. #endregion
  3535. return result;
  3536. }
  3537. catch (Exception e)
  3538. {
  3539. string error = e.Message.ToString();
  3540. result = JsonConvert.DeserializeObject(error) as JObject;
  3541. return result;
  3542. }
  3543. }
  3544. /// <summary>
  3545. ///根据机票黑屏代码整理DataTable
  3546. /// </summary>
  3547. /// <param name="diid"></param>
  3548. /// <returns></returns>
  3549. public DataTable GetTableByBlackCode(int diid)
  3550. {
  3551. //黑屏代码信息
  3552. List<Air_TicketBlackCode> listcode = Db.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  3553. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  3554. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  3555. DataTable dt = new DataTable();
  3556. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  3557. dt.Columns.Add("Date", typeof(string));//起飞日期
  3558. dt.Columns.Add("Three", typeof(string));//三字码
  3559. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  3560. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  3561. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  3562. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  3563. dt.Columns.Add("AirModel", typeof(string)); //机型
  3564. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  3565. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  3566. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  3567. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  3568. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  3569. //判断是否录入黑屏代码
  3570. if (listcode.Count() == 0 || listcode == null)
  3571. {
  3572. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  3573. }
  3574. else
  3575. {
  3576. //读取单段黑屏代码
  3577. for (int i = 0; i < listcode.Count; i++)
  3578. {
  3579. //去除序号
  3580. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  3581. //去除多余空格,方法一Linq扩展方法
  3582. CodeList = CodeList.Where(str => str != "").ToArray();
  3583. CodeList = CodeList.Where(str => str != " ").ToArray();
  3584. //年
  3585. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  3586. //读取单条黑屏代码
  3587. for (int j = 0; j < CodeList.Count(); j++)
  3588. {
  3589. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  3590. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  3591. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3592. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  3593. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3594. //去除多余空格
  3595. Info = Info.Where(str => str != "").ToArray();
  3596. Info = Info.Where(str => str != " ").ToArray();
  3597. //判断黑屏代码是否正确拆分; 理应拆成9段
  3598. if (Info.Count() < 9)
  3599. {
  3600. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  3601. }
  3602. else
  3603. {
  3604. try
  3605. {
  3606. //月
  3607. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  3608. //日
  3609. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  3610. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  3611. if (j > 0)
  3612. {
  3613. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  3614. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3615. Temp = Temp.Where(str => str != "").ToArray();
  3616. Temp = Temp.Where(str => str != " ").ToArray();
  3617. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  3618. // 如果相邻月份之差小于0,则证明次一条年份需+1
  3619. if (month - monthTemp < 0)
  3620. {
  3621. year = year + 1;
  3622. }
  3623. //如果相邻代码三字码不顶真,提醒
  3624. string FootThree = Temp[2].Substring(3, 3);
  3625. string HeadThree = Info[2].Substring(0, 3);
  3626. if (FootThree != HeadThree)
  3627. {
  3628. //DelegationInfoService s = new DelegationInfoService();
  3629. //UsersService us = new UsersService();
  3630. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  3631. //77 行程
  3632. List<Grp_GroupsTaskAssignment> list2 = Db.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  3633. foreach (var temp in list2)
  3634. {
  3635. //if (temp.UId != 21)
  3636. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  3637. // "黑屏代码提醒",
  3638. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  3639. }
  3640. //85 机票预订
  3641. List<Grp_GroupsTaskAssignment> list6 = Db.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  3642. foreach (var temp in list6)
  3643. {
  3644. //if (temp.UId != 21)
  3645. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  3646. // "黑屏代码提醒",
  3647. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  3648. }
  3649. }
  3650. }
  3651. #endregion
  3652. #region 判断到达日期是否需要加1
  3653. if (Info[4].Contains("+"))
  3654. {
  3655. //日期+1
  3656. day = day + 1;
  3657. //判断是否进入下一月
  3658. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  3659. {
  3660. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  3661. month = month + 1;
  3662. //判断是否进入下一年
  3663. if (month > 12)
  3664. {
  3665. month = month - 12;
  3666. year = year + 1;
  3667. }
  3668. }
  3669. //月份整理格式
  3670. string monthTemp = month.ToString();
  3671. if (month < 10)
  3672. {
  3673. monthTemp = "0" + monthTemp;
  3674. }
  3675. //日期整理格式
  3676. string daytemp = day.ToString();
  3677. if (day < 10)
  3678. {
  3679. daytemp = "0" + daytemp;
  3680. }
  3681. string temp = Info[4].Split('+')[0];
  3682. //添加起飞数据
  3683. dt.Rows.Add(Info[0],
  3684. Info[1],
  3685. Info[2],
  3686. Info[3],
  3687. temp,
  3688. Info[5],
  3689. Info[6],
  3690. Info[7],
  3691. Info[8],
  3692. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  3693. year + "-" + monthTemp + "-" + daytemp,
  3694. "",
  3695. "0");
  3696. //加1天,添加到达数据
  3697. dt.Rows.Add(Info[0],
  3698. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  3699. Info[2],
  3700. Info[3],
  3701. temp,
  3702. Info[5],
  3703. Info[6],
  3704. Info[7],
  3705. Info[8],
  3706. year + "-" + monthTemp + "-" + daytemp,
  3707. year + "-" + monthTemp + "-" + daytemp,
  3708. "",
  3709. "1");
  3710. }
  3711. else
  3712. {
  3713. //月份整理格式
  3714. string monthTemp = month.ToString();
  3715. if (month < 10)
  3716. {
  3717. monthTemp = "0" + monthTemp;
  3718. }
  3719. //日期整理格式
  3720. string daytemp = day.ToString();
  3721. if (day < 10)
  3722. {
  3723. daytemp = "0" + daytemp;
  3724. }
  3725. dt.Rows.Add(Info[0],
  3726. Info[1],
  3727. Info[2],
  3728. Info[3],
  3729. Info[4],
  3730. Info[5],
  3731. Info[6],
  3732. Info[7],
  3733. Info[8],
  3734. year + "-" + monthTemp + "-" + daytemp,
  3735. year + "-" + monthTemp + "-" + daytemp,
  3736. "",
  3737. "0");
  3738. }
  3739. #endregion
  3740. }
  3741. catch (Exception ex)
  3742. {
  3743. string exstr = ex.Message.ToString();
  3744. }
  3745. }
  3746. }
  3747. //排序
  3748. dt.DefaultView.Sort = "Day asc";
  3749. dt = dt.DefaultView.ToTable();
  3750. }
  3751. }
  3752. return dt;
  3753. }
  3754. /// <summary>
  3755. /// 根据星期,月份的缩写,转换成数字或者全称
  3756. /// 根据币种中文名称返回币种代码
  3757. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  3758. /// 20210903贾文滔
  3759. /// </summary>
  3760. /// <param name="startDate"></param>
  3761. /// <param name="endDate"></param>
  3762. /// <returns></returns>
  3763. public string GetLonger(string temp)
  3764. {
  3765. string str = "";
  3766. switch (temp.ToUpper())
  3767. {
  3768. case "美元":
  3769. str = "USD";
  3770. break;
  3771. case "日元":
  3772. str = "JPY";
  3773. break;
  3774. case "英镑":
  3775. str = "GBP";
  3776. break;
  3777. case "欧元":
  3778. str = "EUR";
  3779. break;
  3780. case "港币":
  3781. str = "HKD";
  3782. break;
  3783. case "MO":
  3784. str = "星期一";
  3785. break;
  3786. case "TU":
  3787. str = "星期二";
  3788. break;
  3789. case "WE":
  3790. str = "星期三";
  3791. break;
  3792. case "TH":
  3793. str = "星期四";
  3794. break;
  3795. case "FR":
  3796. str = "星期五";
  3797. break;
  3798. case "SA":
  3799. str = "星期六";
  3800. break;
  3801. case "SU":
  3802. str = "星期天";
  3803. break;
  3804. case "JAN":
  3805. str = "01";
  3806. break;
  3807. case "FEB":
  3808. str = "02";
  3809. break;
  3810. case "MAR":
  3811. str = "03";
  3812. break;
  3813. case "APR":
  3814. str = "04";
  3815. break;
  3816. case "MAY":
  3817. str = "05";
  3818. break;
  3819. case "JUN":
  3820. str = "06";
  3821. break;
  3822. case "JUL":
  3823. str = "07";
  3824. break;
  3825. case "AUG":
  3826. str = "08";
  3827. break;
  3828. case "SEP":
  3829. str = "09";
  3830. break;
  3831. case "OCT":
  3832. str = "10";
  3833. break;
  3834. case "NOV":
  3835. str = "11";
  3836. break;
  3837. case "DEC":
  3838. str = "12";
  3839. break;
  3840. case "MONDAY":
  3841. str = "星期一";
  3842. break;
  3843. case "TUESDAY":
  3844. str = "星期二";
  3845. break;
  3846. case "WEDNESDAY":
  3847. str = "星期三";
  3848. break;
  3849. case "THURSDAY":
  3850. str = "星期四";
  3851. break;
  3852. case "FRIDAY":
  3853. str = "星期五";
  3854. break;
  3855. case "SATURDAY":
  3856. str = "星期六";
  3857. break;
  3858. case "SUNDAY":
  3859. str = "星期日";
  3860. break;
  3861. case "01":
  3862. str = "JAN";
  3863. break;
  3864. case "02":
  3865. str = "FEB";
  3866. break;
  3867. case "03":
  3868. str = "MAR";
  3869. break;
  3870. case "04":
  3871. str = "APR";
  3872. break;
  3873. case "05":
  3874. str = "MAY";
  3875. break;
  3876. case "06":
  3877. str = "JUN";
  3878. break;
  3879. case "07":
  3880. str = "JUL";
  3881. break;
  3882. case "08":
  3883. str = "AUG";
  3884. break;
  3885. case "09":
  3886. str = "SEP";
  3887. break;
  3888. case "10":
  3889. str = "OCT";
  3890. break;
  3891. case "11":
  3892. str = "NOV";
  3893. break;
  3894. case "12":
  3895. str = "DEC";
  3896. break;
  3897. case "2":
  3898. str = "空客A";
  3899. break;
  3900. case "3":
  3901. str = "空客A";
  3902. break;
  3903. case "7":
  3904. str = "波音";
  3905. break;
  3906. }
  3907. return str;
  3908. }
  3909. /// <summary>
  3910. /// 1、查询该国家礼拜日是否为周五周六;系统标红礼拜日为这两天
  3911. /// 2、查询该国家是否位于美国或者欧洲;需要提前3小时到机场
  3912. /// 3、查询该国家是否为黄热病地区;系统提醒一下要打疫苗
  3913. /// 20210824 贾文滔
  3914. /// </summary>
  3915. /// <param name="Country">查询国家</param>
  3916. /// <returns>返回结果:1为礼拜日查询;2为欧洲或美国查询;3为黄热病地区查询</returns>
  3917. public string GetCountryInfo(string Country)
  3918. {
  3919. //礼拜日为周5、6的城市地区;系统标红礼拜日为这两天
  3920. string[] CountryOne = {"阿联酋","United Arab Emirates","巴林","Bahrain","卡塔尔","Qatar","沙特阿拉伯","Saudi Arabia","阿曼","Oman","科威特","Kuwait","埃及","Egypt",
  3921. "约旦","Jordan","伊朗","Iran","伊拉克","Iraq","叙利亚","Syria","黎巴嫩","Lebanon","巴勒斯坦","Palestine","加沙","也门","Yemen"};
  3922. //欧洲或美国;需要提前3小时到机场
  3923. string[] CountryTwo = {"芬兰","瑞典","挪威","冰岛","丹麦","法罗群岛(丹)","爱沙尼亚","拉脱维亚","立陶宛","白俄罗斯","俄罗斯","乌克兰","摩尔多瓦","波兰","捷克","斯洛伐克",
  3924. "匈牙利","德国","奥地利","瑞士","列支敦士登","英国","爱尔兰","荷兰","比利时","卢森堡","法国","摩纳哥","罗马尼亚","保加利亚","塞尔维亚","马其顿",
  3925. "阿尔巴尼亚","希腊","斯洛文尼亚","克罗地亚","波斯尼亚和墨塞哥维那","意大利","梵蒂冈","圣马力诺","马耳他","西班牙","葡萄牙","安道尔","美国" };
  3926. //黄热病;系统提醒一下要打疫苗
  3927. string[] CountryThree = {"安哥拉","布隆迪","贝宁","布基纳法索","喀麦隆","中非共和国","乍得","刚果","赤道几内亚","埃塞俄比亚","冈比亚","加蓬","几内亚","几内亚比绍",
  3928. "加纳","象牙海岸","科特迪瓦","肯尼亚","利比里亚","马里","尼日尔","尼日利亚","塞内加尔","塞拉利昂","苏丹","南苏丹","多哥","乌干达","毛里塔尼亚",
  3929. "刚果民主共和国","玻利维亚","巴西","厄瓜多尔","苏里南","秘鲁","法属圭亚那","法属圭巴拿马","委内瑞拉","巴拉圭","阿根廷","特立尼达和多巴哥" };
  3930. string result = "";
  3931. if (CountryOne.Contains(Country))
  3932. result += "1";
  3933. if (CountryTwo.Contains(Country))
  3934. result += "2";
  3935. if (CountryThree.Contains(Country))
  3936. result += "3";
  3937. return result;
  3938. }
  3939. /// <summary>
  3940. /// 20210816
  3941. /// 根据datatable生成某一时间段的日期
  3942. /// </summary>
  3943. /// <param name="dt">黑屏代码生成的datatable</param>
  3944. /// <returns></returns>
  3945. public List<string> GetTimeListByDataTable(DataTable dt)
  3946. {
  3947. if (dt.Rows[0]["Day"].ToString() != "")
  3948. {
  3949. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  3950. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  3951. List<string> timeList = new List<string>();
  3952. while (datestart <= dateend)
  3953. {
  3954. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  3955. datestart = datestart.AddDays(1);
  3956. }
  3957. return timeList;
  3958. }
  3959. return null;
  3960. }
  3961. /// <summary>
  3962. /// 返回网络时间 --北京时间
  3963. /// </summary>
  3964. /// <returns></returns>
  3965. public DateTime GetBeijingTime()
  3966. {
  3967. WebRequest request = null;
  3968. WebResponse response = null;
  3969. WebHeaderCollection headerCollection = null;
  3970. string datetime = string.Empty;
  3971. try
  3972. {
  3973. request = WebRequest.Create("https://www.baidu.com");
  3974. request.Timeout = 3000;
  3975. request.Credentials = CredentialCache.DefaultCredentials;
  3976. response = request.GetResponse();
  3977. headerCollection = response.Headers;
  3978. foreach (var h in headerCollection.AllKeys)
  3979. {
  3980. if (h == "Date")
  3981. {
  3982. datetime = headerCollection[h];
  3983. }
  3984. }
  3985. return Convert.ToDateTime(datetime);
  3986. }
  3987. catch (Exception)
  3988. {
  3989. return DateTime.Now;
  3990. }
  3991. finally
  3992. {
  3993. if (request != null)
  3994. {
  3995. request.Abort();
  3996. }
  3997. if (response != null)
  3998. {
  3999. response.Close();
  4000. }
  4001. if (headerCollection != null)
  4002. {
  4003. headerCollection.Clear();
  4004. }
  4005. }
  4006. }
  4007. /// <summary>
  4008. /// 根据月份返回天数
  4009. /// </summary>
  4010. /// <param name="temp"></param>
  4011. /// <returns></returns>
  4012. public static string GetDaysByMonth(string Month, int year)
  4013. {
  4014. string str = "";
  4015. //判断是否是闰年
  4016. if (DateTime.IsLeapYear(year) == false)
  4017. {
  4018. switch (Month.ToUpper())
  4019. {
  4020. case "JAN":
  4021. str = "31";
  4022. break;
  4023. case "FEB":
  4024. str = "28";
  4025. break;
  4026. case "MAR":
  4027. str = "31";
  4028. break;
  4029. case "APR":
  4030. str = "30";
  4031. break;
  4032. case "MAY":
  4033. str = "31";
  4034. break;
  4035. case "JUN":
  4036. str = "30";
  4037. break;
  4038. case "JUL":
  4039. str = "31";
  4040. break;
  4041. case "AUG":
  4042. str = "31";
  4043. break;
  4044. case "SEP":
  4045. str = "30";
  4046. break;
  4047. case "OCT":
  4048. str = "31";
  4049. break;
  4050. case "NOV":
  4051. str = "30";
  4052. break;
  4053. case "DEC":
  4054. str = "31";
  4055. break;
  4056. case "01":
  4057. str = "31";
  4058. break;
  4059. case "02":
  4060. str = "28";
  4061. break;
  4062. case "03":
  4063. str = "31";
  4064. break;
  4065. case "04":
  4066. str = "30";
  4067. break;
  4068. case "05":
  4069. str = "31";
  4070. break;
  4071. case "06":
  4072. str = "30";
  4073. break;
  4074. case "07":
  4075. str = "31";
  4076. break;
  4077. case "08":
  4078. str = "31";
  4079. break;
  4080. case "09":
  4081. str = "30";
  4082. break;
  4083. case "10":
  4084. str = "31";
  4085. break;
  4086. case "11":
  4087. str = "30";
  4088. break;
  4089. case "12":
  4090. str = "31";
  4091. break;
  4092. }
  4093. }
  4094. else
  4095. {
  4096. switch (Month.ToUpper())
  4097. {
  4098. case "JAN":
  4099. str = "31";
  4100. break;
  4101. case "FEB":
  4102. str = "29";
  4103. break;
  4104. case "MAR":
  4105. str = "31";
  4106. break;
  4107. case "APR":
  4108. str = "30";
  4109. break;
  4110. case "MAY":
  4111. str = "31";
  4112. break;
  4113. case "JUN":
  4114. str = "30";
  4115. break;
  4116. case "JUL":
  4117. str = "31";
  4118. break;
  4119. case "AUG":
  4120. str = "31";
  4121. break;
  4122. case "SEP":
  4123. str = "30";
  4124. break;
  4125. case "OCT":
  4126. str = "31";
  4127. break;
  4128. case "NOV":
  4129. str = "30";
  4130. break;
  4131. case "DEC":
  4132. str = "31";
  4133. break;
  4134. case "01":
  4135. str = "31";
  4136. break;
  4137. case "02":
  4138. str = "29";
  4139. break;
  4140. case "03":
  4141. str = "31";
  4142. break;
  4143. case "04":
  4144. str = "30";
  4145. break;
  4146. case "05":
  4147. str = "31";
  4148. break;
  4149. case "06":
  4150. str = "30";
  4151. break;
  4152. case "07":
  4153. str = "31";
  4154. break;
  4155. case "08":
  4156. str = "31";
  4157. break;
  4158. case "09":
  4159. str = "30";
  4160. break;
  4161. case "10":
  4162. str = "31";
  4163. break;
  4164. case "11":
  4165. str = "30";
  4166. break;
  4167. case "12":
  4168. str = "31";
  4169. break;
  4170. }
  4171. }
  4172. return str;
  4173. }
  4174. /// <summary>
  4175. /// 城市日期,PublicCode内部类
  4176. /// </summary>
  4177. public class CityInDate
  4178. {
  4179. public int Id { get; set; }
  4180. //城市
  4181. public string City { get; set; }
  4182. //日期
  4183. public string Date { get; set; }
  4184. }
  4185. /// <summary>
  4186. /// 20210823
  4187. /// 根据datatable生成行程里每一天所在的城市
  4188. /// </summary>
  4189. /// <param name="dt">黑屏代码生成的datatable</param>
  4190. /// <returns></returns>
  4191. public List<CityInDate> GetCityByDataTable(DataTable dt)
  4192. {
  4193. //城市日期键值对
  4194. List<CityInDate> list = new List<CityInDate>();
  4195. //ThreeCodeServices tcs = new ThreeCodeServices();
  4196. int id = 0;
  4197. for (int i = 1; i < dt.Rows.Count; i++)
  4198. {
  4199. //i-1行的三字码
  4200. string Pre_citycode = dt.Rows[i - 1]["Three"].ToString();
  4201. if (string.IsNullOrWhiteSpace(Pre_citycode))
  4202. {
  4203. continue;
  4204. }
  4205. Pre_citycode = Pre_citycode.Replace("/", string.Empty).Substring(3, 3);
  4206. string city = "";
  4207. //查询该三字码所对应城市的数据
  4208. //ThreeCode Pre_TC = tcs.getByThree(Pre_citycode);
  4209. Res_ThreeCode Pre_TC = Db.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == Pre_citycode.ToUpper() && x.IsDel == 0 );
  4210. //验证是否存在三字码
  4211. if (Pre_TC == null)
  4212. city = "【此三字码" + Pre_citycode + "未收录,请机票同事录入】";
  4213. else
  4214. city = Pre_TC.City;
  4215. //生成日期
  4216. DateTime datestart = Convert.ToDateTime(dt.Rows[i - 1]["Day"].ToString());
  4217. DateTime dateend = Convert.ToDateTime(dt.Rows[i]["Day"].ToString());
  4218. List<string> timeList = new List<string>();
  4219. while (datestart < dateend)
  4220. {
  4221. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  4222. datestart = datestart.AddDays(1);
  4223. }
  4224. if (i == dt.Rows.Count - 1)
  4225. timeList.Add(dt.Rows[i]["Day"].ToString());
  4226. for (int j = 0; j < timeList.Count; j++)
  4227. {
  4228. CityInDate cid = new CityInDate() { };
  4229. cid.Id = id;
  4230. cid.City = city;
  4231. cid.Date = timeList[j];
  4232. list.Add(cid);
  4233. id++;
  4234. }
  4235. }
  4236. return list;
  4237. }
  4238. Res_ThreeCode getByThree(string three)
  4239. {
  4240. return Db.Queryable<Res_ThreeCode>().First(x => x.Three == three && x.IsDel == 0 );
  4241. }
  4242. Res_AirCompany getByShortCode(string ShortCode)
  4243. {
  4244. //return this.excuteType("select * from AirCompany where Isdel=0 and ShortCode=@ShortCode", new SqlParameter("@ShortCode", ShortCode.ToUpper()));
  4245. return Db.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == ShortCode.ToUpper() && x.IsDel == 0);
  4246. }
  4247. public class GoogleMapApiResult
  4248. {
  4249. int id;
  4250. /// <summary>
  4251. /// 标识
  4252. /// </summary>
  4253. public int Id { get => id; set => id = value; }
  4254. int diid;
  4255. /// <summary>
  4256. /// 团组ID
  4257. /// </summary>
  4258. public int Diid { get => diid; set => diid = value; }
  4259. string date;
  4260. /// <summary>
  4261. /// 日期
  4262. /// </summary>
  4263. public string Date { get => date; set => date = value; }
  4264. string moment;
  4265. /// <summary>
  4266. /// 时刻
  4267. /// </summary>
  4268. public string Moment { get => moment; set => moment = value; }
  4269. string startAddress;
  4270. /// <summary>
  4271. /// 出发地址
  4272. /// </summary>
  4273. public string StartAddress { get => startAddress; set => startAddress = value; }
  4274. string endAddress;
  4275. /// <summary>
  4276. /// 到达地址
  4277. /// </summary>
  4278. public string EndAddress { get => endAddress; set => endAddress = value; }
  4279. string time;
  4280. /// <summary>
  4281. /// 耗时
  4282. /// </summary>
  4283. public string Time { get => time; set => time = value; }
  4284. string distance;
  4285. /// <summary>
  4286. /// 距离
  4287. /// </summary>
  4288. public string Distance { get => distance; set => distance = value; }
  4289. }
  4290. List<Res_ThreeCode> getByCity(string city)
  4291. {
  4292. //return this.excuteSql("select * from ThreeCode w" +
  4293. // "here Isdel=0 and City='" + city + "'");
  4294. return Db.Queryable<Res_ThreeCode>().Where(x => x.City == city && x.IsDel == 0).ToList();
  4295. }
  4296. public List<Res_OfficialActivities> getByDiidAndDate(int diid, string date)
  4297. {
  4298. //return excuteSql("select * from OfficialActivities where Isdel=0" +
  4299. // " and Diid=@diid and IsSubmitApproval=0 and Date=@Date " +
  4300. // "order by Date", new SqlParameter("@diid", diid),
  4301. // new SqlParameter("@Date", date));
  4302. return Db.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diid
  4303. && x.Date == date).ToList();
  4304. }
  4305. bool AddTravelList(Grp_TravelList data)
  4306. {
  4307. return Db.Insertable<Grp_TravelList>(data).ExecuteCommand() > 0;
  4308. }
  4309. bool EditTravelList(Grp_TravelList hd)
  4310. {
  4311. //string sql = "update TravelList set Diid=@Diid,Days = @Days,Date = @Date,WeekDay = @WeekDay,Traffic_First = @Traffic_First,"
  4312. // + "Traffic_Second = @Traffic_Second,Trip = @Trip,OPer = @OPer,OPdate = @OPdate,Isdel = @Isdel where Id = @Id";
  4313. //SqlParameter[] parameter = new SqlParameter[]{
  4314. // new SqlParameter("@Diid",hd.Diid),
  4315. // new SqlParameter("@Days",hd.Days),
  4316. // new SqlParameter("@Date",hd.Date),
  4317. // new SqlParameter("@WeekDay",hd.WeekDay),
  4318. // new SqlParameter("@Traffic_First",hd.Traffic_First),
  4319. // new SqlParameter("@Traffic_Second",hd.Traffic_Second),
  4320. // new SqlParameter("@Trip",hd.Trip),
  4321. // new SqlParameter("@OPer",hd.OPer),
  4322. // new SqlParameter("@OPdate",hd.OPdate),
  4323. // new SqlParameter("@Isdel",hd.Isdel),
  4324. // new SqlParameter("@Id",hd.Id)
  4325. //};
  4326. //if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  4327. // return true;
  4328. //return false;
  4329. return Db.Updateable<Grp_TravelList>(hd).ExecuteCommand() > 0;
  4330. }
  4331. bool DelOld(int Diid, int start, int end)
  4332. {
  4333. //if (SqlHelper.ExecuteNonQuery("delete from TravelList where Diid=" + Diid + " and ( Id>=" + start + " and Id<=" + end + ")", CommandType.Text) > 0)
  4334. // return true;
  4335. //return false;
  4336. return Db.Deleteable<Grp_TravelList>().Where(x => x.Diid == Diid && x.Id >= start && x.Id <= end).ExecuteCommand() > 0;
  4337. }
  4338. /// <summary>
  4339. /// 根据团组编号查询信息
  4340. /// </summary>
  4341. /// <returns>返回空或者对象信息</returns>
  4342. List<Grp_TravelList> GetByDiid(int Diid)
  4343. {
  4344. //调用获取单个对象的方法
  4345. return Db.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  4346. }
  4347. public List<Crm_DeleClient> GetByDiidClient(int DIID)
  4348. {
  4349. return Db.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  4350. }
  4351. /// <summary>
  4352. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  4353. /// </summary>
  4354. /// <param name="num"></param>
  4355. /// <returns></returns>
  4356. public string GetNum(string num)
  4357. {
  4358. string str = "";
  4359. switch (num)
  4360. {
  4361. case "1":
  4362. str = "一";
  4363. break;
  4364. case "2":
  4365. str = "二";
  4366. break;
  4367. case "3":
  4368. str = "三";
  4369. break;
  4370. case "4":
  4371. str = "四";
  4372. break;
  4373. case "5":
  4374. str = "五";
  4375. break;
  4376. case "6":
  4377. str = "六";
  4378. break;
  4379. case "7":
  4380. str = "七";
  4381. break;
  4382. case "8":
  4383. str = "八";
  4384. break;
  4385. case "9":
  4386. str = "九";
  4387. break;
  4388. case "10":
  4389. str = "十";
  4390. break;
  4391. case "11":
  4392. str = "十一";
  4393. break;
  4394. case "12":
  4395. str = "十二";
  4396. break;
  4397. case "一":
  4398. str = "1";
  4399. break;
  4400. case "二":
  4401. str = "2";
  4402. break;
  4403. case "三":
  4404. str = "3";
  4405. break;
  4406. case "四":
  4407. str = "4";
  4408. break;
  4409. case "五":
  4410. str = "5";
  4411. break;
  4412. case "六":
  4413. str = "6";
  4414. break;
  4415. case "七":
  4416. str = "7";
  4417. break;
  4418. case "八":
  4419. str = "8";
  4420. break;
  4421. case "九":
  4422. str = "9";
  4423. break;
  4424. case "十":
  4425. str = "10";
  4426. break;
  4427. case "十一":
  4428. str = "11";
  4429. break;
  4430. case "十二":
  4431. str = "12";
  4432. break;
  4433. }
  4434. return str;
  4435. }
  4436. public bool Del(int diid)
  4437. {
  4438. return Db.Updateable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).SetColumns(x => new Grp_TravelList { IsDel = 1, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd") }).ExecuteCommand() > 0;
  4439. }
  4440. private void comb_Delegation_TextUpdate(object sender, EventArgs e)
  4441. {
  4442. ComboBox cb = (ComboBox)sender;
  4443. cb.DataSource = null;
  4444. cb.Items.Clear();
  4445. string s = cb.Text;
  4446. var bindList = soure.Where(item => item.TeamName != null && item.TeamName.Contains(s)).ToList();
  4447. if (bindList.Count >= 1) // 存在符合条件的内容
  4448. {
  4449. this.comb_Delegation.Items.AddRange(bindList.ToArray());
  4450. }
  4451. else
  4452. {
  4453. this.comb_Delegation.Items.Add(new Grp_DelegationInfo { TeamName = "", Id = -1 });
  4454. }
  4455. cb.SelectionStart = cb.Text.Length; // 设置光标位置,若不设置:光标位置始终保持在第一列,造成输入关键词的倒序排列
  4456. cb.Cursor = Cursors.Default; //保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置
  4457. cb.MaxDropDownItems = 8; // 自动弹出下拉框
  4458. }
  4459. private void comb_Delegation_MouseClick(object sender, MouseEventArgs e)
  4460. {
  4461. comb_Delegation.Text = "";
  4462. comb_Delegation_TextUpdate(sender, e);
  4463. comb_Delegation.DropDownHeight = 200;
  4464. comb_Delegation.DroppedDown = true;
  4465. }
  4466. }
  4467. }