public void ValidaMes_DiferenteMes_Verdadero() { var DOCValidarMes = new Mock <IValidarMes>(); DOCValidarMes.Setup(DOC => DOC.ValidaMes(new DateTime(2018, 12, 2), new DateTime(2019, 12, 01))).Returns(true); var SUT = new ValidarMes(); var result = SUT.ValidaMes(new DateTime(2018, 10, 2), new DateTime(2019, 12, 01)); Assert.IsFalse(result); }
public void CalculaMes_MismoDia_MensajeCorrecto() { var DOCCalculaMes = new Mock <IValidarMes>(); DOCCalculaMes.Setup(DOC => DOC.ValidaMes(new DateTime(2019, 12, 2), new DateTime(2019, 12, 01))).Returns(true); var SUT = new CalcularMes(DOCCalculaMes.Object); var result = SUT.CalculaMes(new DateTime(2019, 12, 2), new DateTime(2018, 12, 01)); Assert.AreEqual("ocurre este mes", result); }
public void Validar_ExisteConexion_Verdadero() { var DOCValidarConexion = new Mock <IValidarConexion>(); DOCValidarConexion.Setup(DOC => DOC.Validar(It.IsAny <string>())); var SUT = new ValidarConexion(); SUT.Validar(It.IsAny <string>()); Assert.IsTrue(true); }
public void CalculaAnio_DiferenteAnio_MensajeCorrecto() { var DOCCalculaAnio = new Mock <IValidarAnio>(); DOCCalculaAnio.Setup(DOC => DOC.ValidaAnio(new DateTime(2019, 12, 2), new DateTime(2018, 12, 01))).Returns(true); var SUT = new CalcularAnio(DOCCalculaAnio.Object); var result = SUT.CalculaAnio(new DateTime(2019, 12, 2), new DateTime(2018, 12, 01)); //DOCCalculaAnio.Verify(DOC => DOC.ValidaAnio(new DateTime(2019, 12, 2), new DateTime(2019, 12, 01)), Times.Once); Assert.AreEqual("ocurrió hace 1 año.", result); }
//获取商品列表 public static List <MallGoodsDetail> GetMallGoodsList(long BrandID = 0) { using (var EF = new EF()) { var mallGoodsList = (from goodsInfo in EF.GoodsInfos join goodsBrand in EF.GoodsBrands on goodsInfo.ID equals goodsBrand.GoodsID // into t1 from goodsBrand in t1.DefaultIfEmpty() join goodsPhoto in EF.GoodsPhotos on goodsInfo.ID equals goodsPhoto.GoodsID // into t2 from goodsPhoto in t2.DefaultIfEmpty() where goodsInfo.Enabled == true && goodsInfo.StateID == (int)GoodsState.架 select new MallGoodsDetail { ID = goodsInfo.ID, Name = goodsInfo.Name, Title = goodsInfo.Title, BrandID = goodsBrand.BrandID, PhotoFileIDs = goodsPhoto.FileIDs }).ToList(); if (BrandID > 0) { mallGoodsList = mallGoodsList.Where(i => i.BrandID == BrandID).ToList(); } foreach (var goodsInfo in mallGoodsList) { //图片 goodsInfo.Photos = new List <string>(); if (!string.IsNullOrWhiteSpace(goodsInfo.PhotoFileIDs)) { foreach (var FileID in goodsInfo.PhotoFileIDs.Split(',')) { var fileInfo = DOC.GetFileUploadInfo(long.Parse(FileID)); goodsInfo.Photos.Add(fileInfo.FileInfo.GUID + fileInfo.FileExtName.Name); } } //价格 var specCounter = EF.GoodsCounter.Where(i => i.GoodsSpecID > 0 && i.GoodsID == goodsInfo.ID).ToList(); if (specCounter.Count > 0) { var minPrice = specCounter.Min(i => i.Price); var maxPrice = specCounter.Max(i => i.Price); goodsInfo.Price = minPrice == maxPrice?minPrice.ToString() : minPrice + " - " + maxPrice; } else { var singlePrice = EF.GoodsCounter.FirstOrDefault(i => i.GoodsSpecID == 0 && i.GoodsID == goodsInfo.ID); goodsInfo.Price = (singlePrice == null ? 0.00M : singlePrice.Price).ToString(); } //标签 goodsInfo.Tags = EF.GoodsTags.Where(i => i.GoodsID == goodsInfo.ID).Select(i => i.Title).ToList(); } return(mallGoodsList); } }
public static void InsertLog(MessageBoxIcon LogType, Exception e, string StackTrace = "") { XmlDocument XMLLog = new XmlDocument(); XmlElement DOC; if (File.Exists(GetLogPath())) { using (var old = new StreamReader(GetLogPath())) { var s = old.ReadToEnd(); old.Close(); XMLLog.LoadXml(s); } DOC = XMLLog.DocumentElement; } else { DOC = XMLLog.CreateElement("Log"); XMLLog.AppendChild(DOC); } var LogTypeNode = XMLLog.CreateElement(LogType.ToString()); LogTypeNode.SetAttribute("Message", e.Message); LogTypeNode.SetAttribute("Detail", e.GetExceptionDetail().First()); if (StackTrace == "") { LogTypeNode.SetAttribute("StackTrace", e.StackTrace); } else { LogTypeNode.SetAttribute("StackTrace", StackTrace); } LogTypeNode.SetAttribute("DateTime", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss")); DOC.AppendChild(LogTypeNode); var dir = Path.GetDirectoryName(GetLogPath()); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } XMLLog.Save(GetLogPath()); }
public void SetValue(string key, string value) { XmlNode xnRoot = DOC.DocumentElement; XmlNodeList xe = xnRoot.ChildNodes; for (int j = 0; j < xe.Count; j++) { XmlElement _1 = xe[j] as XmlElement; if (_1 != null && _1.Attributes["key"].Value == key) { _1.Attributes["value"].Value = value; DOC.Save(XmlFilePath); } } }
public void obtenerDatosArchivo_RutaArchivoIncorrecta_Exception() { //Arrange var DOClectorArchivoService = new Mock <ILectorArchivoService>(); DOClectorArchivoService.Setup(DOC => DOC.leerArchivo(It.IsAny <string>())).Throws(new Exception("")); var SUT = new LectorArchivoController(DOClectorArchivoService.Object); // Act try { SUT.obtenerDatosArchivo("Any.cs"); } catch (Exception e) { // Assert StringAssert.Contains(e.Message, "No existe el archivo en la ruta especificada"); return; } Assert.Fail("No se lanzo ninguna excepcion."); }
public void ObtenerEvento_DiaPasado_MensajeCorrecto() { //Arrange var DOCValidarConexion = new Mock <IValidarConexion>(); var DOCCalcularTiemppo = new Mock <ICalcularTiempo>(); var DOCLeerArchivo = new Mock <ILeerArchivoTexto>(); var DOCVisorMensajes = new Mock <IVisorMensajes>(); DOCLeerArchivo.Setup(DOC => DOC.ObtenerDatos(It.IsAny <string>())).Returns(new string[] { "Ayer, 2019/12/01" }); DOCCalcularTiemppo.Setup(DOC => DOC.CalcularMomentoDelTiempo(new DateTime(2019, 12, 2), new DateTime(2019, 12, 01))).Returns("Ayer"); //DOCValidarFecha.Setup(DOC=>DOC.CalcularDia(new DateTime(2019,12,2), new DateTime(2019,12,01))).Returns("Ayer"); DOCVisorMensajes.Setup(DOC => DOC.MostrarMensaje($"El evento Ayer Ayer")); var SUT = new Evento(DOCValidarConexion.Object, DOCLeerArchivo.Object, DOCVisorMensajes.Object, DOCCalcularTiemppo.Object); SUT.dtActual = () => new DateTime(2019, 12, 2); //Act SUT.MostrarInformacion("example.txt"); //Assert DOCVisorMensajes.Verify(DOC => DOC.MostrarMensaje($"El evento Ayer Ayer"), Times.Once); }
//获取详情 private static StoreDetails GetStoreDetails(long StoreID) { using (var EF = new EF()) { var details = (from storeInfo in EF.StoreInfos join storePhoto in EF.StorePhotos on storeInfo.ID equals storePhoto.StoreID into temp1 from storePhoto in temp1.DefaultIfEmpty() join storeDesc in EF.StoreDescs on storeInfo.ID equals storeDesc.StoreID into temp2 from storeDesc in temp2.DefaultIfEmpty() where storeInfo.ID == StoreID select new StoreDetails { StoreFullInfo = new StoreFullInfo { ID = storeInfo.ID, LogoFileID = storeInfo.LogoFileID, Name = storeInfo.Name, Title = storeInfo.Title, Enabled = storeInfo.Enabled, }, PhotoFileIDs = storePhoto.FileIDs, BusinessHours = storeDesc.BusinessHours, Description = storeDesc.Description, }).FirstOrDefault(); var store_exist = EF.StoreInfos.Where(i => i.ID == StoreID).FirstOrDefault(); if (store_exist == null) { return(null); } //LOGO if (store_exist.LogoFileID > 0) { var fileInfo = DOC.GetFileUploadInfo(store_exist.LogoFileID); if (fileInfo != null) { details.StoreFullInfo.FileGUID = fileInfo.FileInfo.GUID; details.StoreFullInfo.FileName = fileInfo.FileInfo.Name; details.StoreFullInfo.FileExtName = fileInfo.FileExtName.Name; } } //联系信息 details.StoreContact = EF.StoreContacts.Where(i => i.StoreID == StoreID).FirstOrDefault(); if (details.StoreContact != null) { details.ContactInfo = EF.ContactInfos.Where(i => i.ID == details.StoreContact.ContactID).FirstOrDefault(); } //图片 details.PhotoUploadInfos = new List <FileUploadInfo>(); if (!string.IsNullOrWhiteSpace(details.PhotoFileIDs)) { foreach (var FileID in details.PhotoFileIDs.Split(',')) { details.PhotoUploadInfos.Add(DOC.GetFileUploadInfo(long.Parse(FileID))); } } //结果 return(details); } }
private string MoneyToString(decimal Amount) { string Resp, Tien, DOC, Dem, Nhom, Chu, So1, So2, So3, Dich; int S; if (Amount == 0) { Resp = "Không đồng"; } else { if (Amount > 999999999999) { Resp = "Số quá lớn"; } else { if (Amount < 0) { Resp = "Trừ"; } else { Resp = string.Empty; } Tien = string.Format("{0:###########0.00}", decimal.Parse(Amount.ToString())); Tien = (Tien.PadLeft(15)); DOC = Dem = string.Empty; DOC = DOC + "trăm mươi tỷ "; DOC = DOC + "trăm mươi triệu "; DOC = DOC + "trăm mươi ngàn "; DOC = DOC + "trăm mươi đồng "; DOC = DOC + "trăm mươi xu "; Dem = Dem + "một hai ba bốn năm "; Dem = Dem + "sáu bảy tám chín"; for (int i = 1; i < 6; i++) { Nhom = Tien.Substring(i * 3 - 3, 3); if (Nhom != "".PadRight(3)) { switch (Nhom) { case "000": Chu = (i == 4 ? "đồng " : ""); break; case ".00": Chu = "chẵn"; break; default: So1 = Nhom.Substring(0, 1); So2 = Nhom.Substring(1, 1); So3 = Nhom.Substring(Nhom.Length > 1 ? Nhom.Length - 1 : 0, 1); Chu = ""; for (int j = 1; j < 4; j++) { Dich = ""; if (int.TryParse(Nhom.Substring(j - 1, 1), out S) == false) { S = -1; } if (S > 0) { Dich = Dem.Substring(S * 5 - 5, 4).Trim() + " "; Dich += DOC.Substring((i - 1) * 18 + j * 6 - 5 - 1, 5) + " "; } switch (j) { case 2: if (S == 1) { Dich = "mười "; } else if (S == 0 && So3 != "0") { if ((int.Parse(So1) >= 1 && int.Parse(So1) <= 9) || (So1 == "0" && i == 4)) { Dich = "lẻ "; } } break; case 3: if (S == 0 && Nhom != "".PadRight(2) + "0") { Dich = DOC.Substring((i - 1) * 18 + j * 6 - 5 - 1, 5).Trim() + "".PadRight(1); } else if (S == 5 && So2 != "".PadRight(1) && So2 != "0") { Dich = "l" + Dich.Substring(1); } break; default: break; } Chu += Dich; } break; } Chu = Chu.Replace(" ", " "); Resp += Chu.Replace("mươi một", "mươi mốt"); } } } } return(Resp.Substring(0, 1).ToUpper() + Resp.Substring(1) + "./."); }
public void Reload() { DOC.Load(XmlFilePath); }
/// <summary> /// Build cargo report. /// Original from https://www.cbp.gov/sites/default/files/documents/cuscar_012_30_3.txt /// </summary> static TSCUSCAR BuildCargoReport(string controlNumber) { var result = new TSCUSCAR(); // Message header result.UNH = new UNH(); result.UNH.MessageReferenceNumber_01 = controlNumber.PadLeft(14, '0'); result.UNH.MessageIdentifier_02 = new S009(); result.UNH.MessageIdentifier_02.MessageType_01 = "CUSCAR"; result.UNH.MessageIdentifier_02.MessageVersionNumber_02 = "D"; result.UNH.MessageIdentifier_02.MessageReleaseNumber_03 = "03B"; result.UNH.MessageIdentifier_02.ControllingAgencyCoded_04 = "UN"; result.BGM = new BGM(); result.BGM.DOCUMENTMESSAGENAME_01 = new C002(); result.BGM.DOCUMENTMESSAGENAME_01.Documentnamecode_01 = "85"; result.BGM.DOCUMENTMESSAGENAME_01.Documentname_04 = "STANDARD"; result.BGM.DOCUMENTMESSAGEIDENTIFICATION_02 = new C106(); result.BGM.DOCUMENTMESSAGEIDENTIFICATION_02.Documentidentifier_01 = "LOCKKH04112206"; result.BGM.Messagefunctioncode_03 = "22"; // Repeating DTM result.DTM = new List <DTM>(); var dtm1 = new DTM(); dtm1.DATETIMEPERIOD_01 = new C507(); dtm1.DATETIMEPERIOD_01.Dateortimeorperiodfunctioncodequalifier_01 = "132"; dtm1.DATETIMEPERIOD_01.Dateortimeorperiodtext_02 = "200412301200"; dtm1.DATETIMEPERIOD_01.Dateortimeorperiodformatcode_03 = "203"; result.DTM.Add(dtm1); // Repeating LOC result.LOC = new List <LOC>(); var loc1 = new LOC(); loc1.Locationfunctioncodequalifier_01 = "60"; loc1.LOCATIONIDENTIFICATION_02 = new C517(); loc1.LOCATIONIDENTIFICATION_02.Locationnamecode_01 = "0901"; loc1.LOCATIONIDENTIFICATION_02.Codelistidentificationcode_02 = "77"; result.LOC.Add(loc1); // Repeating RFF Groups result.RFFLoop = new List <Loop_RFF_CUSCAR>(); // Begin RFF Group var rffLoop1 = new Loop_RFF_CUSCAR(); rffLoop1.RFF = new RFF(); rffLoop1.RFF.REFERENCE_01 = new C506(); rffLoop1.RFF.REFERENCE_01.Referencecodequalifier_01 = "ABO"; rffLoop1.RFF.REFERENCE_01.Referenceidentifier_02 = "ABO04100000"; // End RFF Group result.RFFLoop.Add(rffLoop1); // Repeating RFF Groups result.NADLoop = new List <Loop_NAD_CUSCAR>(); // Begin NAD Group 1 var nadLoop1 = new Loop_NAD_CUSCAR(); nadLoop1.NAD = new NAD(); nadLoop1.NAD.Partyfunctioncodequalifier_01 = "CA"; nadLoop1.NAD.PARTYIDENTIFICATIONDETAILS_02 = new C082(); nadLoop1.NAD.PARTYIDENTIFICATIONDETAILS_02.Partyidentifier_01 = "LOCK"; nadLoop1.NAD.PARTYIDENTIFICATIONDETAILS_02.Codelistidentificationcode_02 = "172"; nadLoop1.NAD.STREET_05 = new C059(); nadLoop1.NAD.STREET_05.Streetandnumberorpostofficeboxidentifier_01 = "11107 SUNSET HILLS ROAD"; nadLoop1.NAD.STREET_05.Streetandnumberorpostofficeboxidentifier_02 = "77705 ARLINGTON ROAD"; nadLoop1.NAD.Cityname_06 = "RESTON"; nadLoop1.NAD.COUNTRYSUBENTITYDETAILS_07 = new C819(); nadLoop1.NAD.COUNTRYSUBENTITYDETAILS_07.Countrysubentitynamecode_01 = "VA"; nadLoop1.NAD.COUNTRYSUBENTITYDETAILS_07.Codelistidentificationcode_02 = "163"; nadLoop1.NAD.Postalidentificationcode_08 = "20190"; // End NAD Group 1 result.NADLoop.Add(nadLoop1); // Begin NAD Group 2 var nadLoop2 = new Loop_NAD_CUSCAR(); nadLoop2.NAD = new NAD(); nadLoop2.NAD.Partyfunctioncodequalifier_01 = "VW"; nadLoop2.NAD.PARTYIDENTIFICATIONDETAILS_02 = new C082(); nadLoop2.NAD.PARTYIDENTIFICATIONDETAILS_02.Partyidentifier_01 = "0000041047"; nadLoop2.NAD.PARTYIDENTIFICATIONDETAILS_02.Codelistidentificationcode_02 = "109"; nadLoop2.NAD.PARTYNAME_04 = new C080(); nadLoop2.NAD.PARTYNAME_04.Partyname_01 = "AADLER"; nadLoop2.NAD.PARTYNAME_04.Partyname_02 = "KEN"; // End NAD Group 2 result.NADLoop.Add(nadLoop2); // Repeating FTX result.FTX = new List <FTX>(); var ftx1 = new FTX(); ftx1.Textsubjectcodequalifier_01 = "INS"; ftx1.TEXTREFERENCE_03 = new C107(); ftx1.TEXTREFERENCE_03.Freetextdescriptioncode_01 = "INSURANCE INFOR"; ftx1.TEXTLITERAL_04 = new C108(); ftx1.TEXTLITERAL_04.Freetext_01 = "NAMESTATE FARM INSURANCE COMPANY"; ftx1.TEXTLITERAL_04.Freetext_02 = "PLCYQO123456789"; ftx1.TEXTLITERAL_04.Freetext_03 = "AMNT100000"; ftx1.TEXTLITERAL_04.Freetext_04 = "YEAR2004"; result.FTX.Add(ftx1); // Repeating TDT Groups result.TDTLoop = new List <Loop_TDT_CUSCAR>(); // Begin TDT Group var tdtLoop1 = new Loop_TDT_CUSCAR(); tdtLoop1.TDT = new TDT(); tdtLoop1.TDT.Transportstagecodequalifier_01 = "11"; tdtLoop1.TDT.MODEOFTRANSPORT_03 = new C220(); tdtLoop1.TDT.MODEOFTRANSPORT_03.Transportmodenamecode_01 = "03"; tdtLoop1.TDT.TRANSPORTMEANS_04 = new C001(); tdtLoop1.TDT.TRANSPORTMEANS_04.Transportmeansdescription_04 = "BT"; tdtLoop1.TDT.Transitdirectionindicatorcode_06 = "I"; tdtLoop1.TDT.TRANSPORTIDENTIFICATION_08 = new C222(); tdtLoop1.TDT.TRANSPORTIDENTIFICATION_08.Codelistidentificationcode_02 = "109"; tdtLoop1.TDT.TRANSPORTIDENTIFICATION_08.Transportmeansidentificationname_04 = "10000324"; // End TDT Group result.TDTLoop.Add(tdtLoop1); // Repeating EQD Groups result.EQDLoop = new List <Loop_EQD_CUSCAR>(); // Begin EQD Group var eqdLoop1 = new Loop_EQD_CUSCAR(); eqdLoop1.EQD = new EQD(); eqdLoop1.EQD.Equipmenttypecodequalifier_01 = "BI"; eqdLoop1.EQD.EQUIPMENTIDENTIFICATION_02 = new C237(); eqdLoop1.EQD.EQUIPMENTIDENTIFICATION_02.Equipmentidentifier_01 = "10000325"; eqdLoop1.EQD.EQUIPMENTIDENTIFICATION_02.Codelistidentificationcode_02 = "109"; // Repeating SEL eqdLoop1.SEL = new List <SEL>(); var selEqd = new SEL(); selEqd.Transportunitsealidentifier_01 = "SEALEQUNO001"; eqdLoop1.SEL.Add(selEqd); // Repeating EQD RFF Groups eqdLoop1.RFFLoop = new List <Loop_RFF_CUSCAR_4>(); // Begin RFF Group var rffEqdLoop1 = new Loop_RFF_CUSCAR_4(); rffEqdLoop1.RFF = new RFF(); rffEqdLoop1.RFF.REFERENCE_01 = new C506(); rffEqdLoop1.RFF.REFERENCE_01.Referencecodequalifier_01 = "ABZ"; rffEqdLoop1.RFF.REFERENCE_01.Referenceidentifier_02 = "EQU123"; // Repeating LOC rffEqdLoop1.LOC = new List <LOC>(); var locRff1 = new LOC(); locRff1.Locationfunctioncodequalifier_01 = "89"; locRff1.LOCATIONIDENTIFICATION_02 = new C517(); locRff1.LOCATIONIDENTIFICATION_02.Locationnamecode_01 = "VA"; locRff1.LOCATIONIDENTIFICATION_02.Codelistidentificationcode_02 = "163"; rffEqdLoop1.LOC.Add(locRff1); // End RFF Group eqdLoop1.RFFLoop.Add(rffEqdLoop1); // End EQD Group result.EQDLoop.Add(eqdLoop1); // Repeating CNI Groups result.CNILoop = new List <Loop_CNI_CUSCAR>(); // Begin CNI Group var cniLoop1 = new Loop_CNI_CUSCAR(); cniLoop1.CNI = new CNI(); cniLoop1.CNI.Consolidationitemnumber_01 = "3741"; cniLoop1.CNI.DOCUMENTMESSAGEDETAILS_02 = new C503(); cniLoop1.CNI.DOCUMENTMESSAGEDETAILS_02.Documentstatuscode_02 = "23"; // Repeating DOC cniLoop1.DOC = new List <DOC>(); var docCni1 = new DOC(); docCni1.DOCUMENTMESSAGENAME_01 = new C002(); docCni1.DOCUMENTMESSAGENAME_01.Documentnamecode_01 = "714"; docCni1.DOCUMENTMESSAGENAME_01.Documentname_04 = "61"; docCni1.DOCUMENTMESSAGEDETAILS_02 = new C503(); docCni1.DOCUMENTMESSAGEDETAILS_02.Documentidentifier_01 = "KH041122106"; docCni1.DOCUMENTMESSAGEDETAILS_02.Documentsourcedescription_03 = "LOCK"; cniLoop1.DOC.Add(docCni1); // Repeating RFF CNI Groups cniLoop1.RFFLoop = new List <Loop_RFF_CUSCAR_2>(); // Begin RFF CNI Group var rffCniLoop1 = new Loop_RFF_CUSCAR_2(); rffCniLoop1.RFF = new RFF(); rffCniLoop1.RFF.REFERENCE_01 = new C506(); rffCniLoop1.RFF.REFERENCE_01.Referencecodequalifier_01 = "AAM"; rffCniLoop1.RFF.REFERENCE_01.Referenceidentifier_02 = "LOCKKH041122106"; // Repeating CNT rffCniLoop1.CNT = new List <CNT>(); var cntRff1 = new CNT(); cntRff1.CONTROL_01 = new C270(); cntRff1.CONTROL_01.Controltotaltypecodequalifier_01 = "58"; cntRff1.CONTROL_01.Controltotalquantity_02 = "158"; rffCniLoop1.CNT.Add(cntRff1); // Repeating LOC rffCniLoop1.LOC = new List <LOC>(); var locRff2 = new LOC(); locRff2.Locationfunctioncodequalifier_01 = "9"; locRff2.LOCATIONIDENTIFICATION_02 = new C517(); locRff2.LOCATIONIDENTIFICATION_02.Locationnamecode_01 = "U0107"; locRff2.LOCATIONIDENTIFICATION_02.Codelistidentificationcode_02 = "78"; rffCniLoop1.LOC.Add(locRff2); // Repeating GEI rffCniLoop1.GEI = new List <GEI>(); var geiRff1 = new GEI(); geiRff1.Processinginformationcodequalifier_01 = "7"; geiRff1.PROCESSINGINDICATOR_02 = new C012(); geiRff1.PROCESSINGINDICATOR_02.Processingindicatordescriptioncode_01 = "135"; rffCniLoop1.GEI.Add(geiRff1); // Repeating TDT RFF Groups rffCniLoop1.TDTLoop = new List <Loop_TDT_CUSCAR_2>(); // Begin TDT RFF Group var tdtRffLoop1 = new Loop_TDT_CUSCAR_2(); tdtRffLoop1.TDT = new TDT(); tdtRffLoop1.TDT.Transportstagecodequalifier_01 = "11"; // Repeating DTM tdtRffLoop1.DTM = new List <DTM>(); var dtmRff1 = new DTM(); dtmRff1.DATETIMEPERIOD_01 = new C507(); dtmRff1.DATETIMEPERIOD_01.Dateortimeorperiodfunctioncodequalifier_01 = "133"; dtmRff1.DATETIMEPERIOD_01.Dateortimeorperiodtext_02 = "20041230"; dtmRff1.DATETIMEPERIOD_01.Dateortimeorperiodformatcode_03 = "102"; tdtRffLoop1.DTM.Add(dtmRff1); // Repeating RFF TDT Groups tdtRffLoop1.RFFLoop = new List <Loop_RFF_CUSCAR_3>(); // Begin RFF TDT Group var rffTdtLoop1 = new Loop_RFF_CUSCAR_3(); rffTdtLoop1.RFF = new RFF(); rffTdtLoop1.RFF.REFERENCE_01 = new C506(); rffTdtLoop1.RFF.REFERENCE_01.Referencecodequalifier_01 = "AWM"; // Repeating TSR rffTdtLoop1.TSR = new List <TSR>(); var tsrRff1 = new TSR(); tsrRff1.CONTRACTANDCARRIAGECONDITION_01 = new C536(); tsrRff1.CONTRACTANDCARRIAGECONDITION_01.Contractandcarriageconditioncode_01 = "9"; rffTdtLoop1.TSR.Add(tsrRff1); // End RFF TDTGroup tdtRffLoop1.RFFLoop.Add(rffTdtLoop1); // End TDT RFF Group rffCniLoop1.TDTLoop.Add(tdtRffLoop1); // Repeating NAD RFF Groups rffCniLoop1.NADLoop = new List <Loop_NAD_CUSCAR_2>(); // Begin NAD RFF Group 1 var nadRffLoop1 = new Loop_NAD_CUSCAR_2(); nadRffLoop1.NAD = new NAD(); nadRffLoop1.NAD.Partyfunctioncodequalifier_01 = "CN"; nadRffLoop1.NAD.PARTYIDENTIFICATIONDETAILS_02 = new C082(); nadRffLoop1.NAD.PARTYIDENTIFICATIONDETAILS_02.Partyidentifier_01 = "65424"; nadRffLoop1.NAD.PARTYIDENTIFICATIONDETAILS_02.Codelistidentificationcode_02 = "109"; nadRffLoop1.NAD.NAMEANDADDRESS_03 = new C058(); nadRffLoop1.NAD.NAMEANDADDRESS_03.Nameandaddressdescription_01 = "1234 MAIN STREET"; nadRffLoop1.NAD.PARTYNAME_04 = new C080(); nadRffLoop1.NAD.PARTYNAME_04.Partyname_01 = "KATHY SMITH"; nadRffLoop1.NAD.Cityname_06 = "BELTSVILLE"; nadRffLoop1.NAD.COUNTRYSUBENTITYDETAILS_07 = new C819(); nadRffLoop1.NAD.COUNTRYSUBENTITYDETAILS_07.Countrysubentitynamecode_01 = "MD"; nadRffLoop1.NAD.COUNTRYSUBENTITYDETAILS_07.Codelistidentificationcode_02 = "163"; nadRffLoop1.NAD.Postalidentificationcode_08 = "20708"; nadRffLoop1.NAD.Countrynamecode_09 = "US"; // Repeating CTA NAD Groups nadRffLoop1.CTALoop = new List <Loop_CTA_CUSCAR>(); // Begin CTA NAD Group var ctaNadLoop1 = new Loop_CTA_CUSCAR(); ctaNadLoop1.CTA = new CTA(); ctaNadLoop1.CTA.Contactfunctioncode_01 = "IC"; // Repeating COM ctaNadLoop1.COM = new List <COM>(); var comCta1 = new COM(); // Repeating C076 comCta1.COMMUNICATIONCONTACT_01 = new List <C076>(); var c076Com1 = new C076(); c076Com1.Communicationaddressidentifier_01 = "8005551212"; c076Com1.Communicationaddresscodequalifier_02 = "TE"; comCta1.COMMUNICATIONCONTACT_01.Add(c076Com1); ctaNadLoop1.COM.Add(comCta1); // End CTA NAD Group nadRffLoop1.CTALoop.Add(ctaNadLoop1); // End NAD RFF Group 1 rffCniLoop1.NADLoop.Add(nadRffLoop1); // Begin NAD RFF Group 2 var nadRffLoop2 = new Loop_NAD_CUSCAR_2(); nadRffLoop2.NAD = new NAD(); nadRffLoop2.NAD.Partyfunctioncodequalifier_01 = "IM"; nadRffLoop2.NAD.PARTYIDENTIFICATIONDETAILS_02 = new C082(); nadRffLoop2.NAD.PARTYIDENTIFICATIONDETAILS_02.Partyidentifier_01 = "00010"; nadRffLoop2.NAD.PARTYIDENTIFICATIONDETAILS_02.Codelistidentificationcode_02 = "109"; nadRffLoop2.NAD.NAMEANDADDRESS_03 = new C058(); nadRffLoop2.NAD.NAMEANDADDRESS_03.Nameandaddressdescription_01 = "1234 MAIN STREET"; nadRffLoop2.NAD.PARTYNAME_04 = new C080(); nadRffLoop2.NAD.PARTYNAME_04.Partyname_01 = "KATHY SMITH"; nadRffLoop2.NAD.Cityname_06 = "BELTSVILLE"; nadRffLoop2.NAD.COUNTRYSUBENTITYDETAILS_07 = new C819(); nadRffLoop2.NAD.COUNTRYSUBENTITYDETAILS_07.Countrysubentitynamecode_01 = "MD"; nadRffLoop2.NAD.COUNTRYSUBENTITYDETAILS_07.Codelistidentificationcode_02 = "163"; nadRffLoop2.NAD.Postalidentificationcode_08 = "20708"; nadRffLoop2.NAD.Countrynamecode_09 = "US"; // Repeating CTA NAD Groups nadRffLoop2.CTALoop = new List <Loop_CTA_CUSCAR>(); // Begin CTA NAD Group var ctaNadLoop2 = new Loop_CTA_CUSCAR(); ctaNadLoop2.CTA = new CTA(); ctaNadLoop2.CTA.Contactfunctioncode_01 = "IC"; // Repeating COM ctaNadLoop2.COM = new List <COM>(); var comCta2 = new COM(); // Repeating C076 comCta2.COMMUNICATIONCONTACT_01 = new List <C076>(); var c076Com2 = new C076(); c076Com2.Communicationaddressidentifier_01 = "8005551212"; c076Com2.Communicationaddresscodequalifier_02 = "TE"; comCta2.COMMUNICATIONCONTACT_01.Add(c076Com2); ctaNadLoop2.COM.Add(comCta2); // End CTA NAD Group nadRffLoop2.CTALoop.Add(ctaNadLoop2); // End NAD RFF Group 2 rffCniLoop1.NADLoop.Add(nadRffLoop2); // Begin NAD RFF Group 3 var nadRffLoop3 = new Loop_NAD_CUSCAR_2(); nadRffLoop3.NAD = new NAD(); nadRffLoop3.NAD.Partyfunctioncodequalifier_01 = "OS"; nadRffLoop3.NAD.PARTYIDENTIFICATIONDETAILS_02 = new C082(); nadRffLoop3.NAD.PARTYIDENTIFICATIONDETAILS_02.Partyidentifier_01 = "27190"; nadRffLoop3.NAD.PARTYIDENTIFICATIONDETAILS_02.Codelistidentificationcode_02 = "109"; nadRffLoop3.NAD.NAMEANDADDRESS_03 = new C058(); nadRffLoop3.NAD.NAMEANDADDRESS_03.Nameandaddressdescription_01 = "1234 MAIN STREET"; nadRffLoop3.NAD.PARTYNAME_04 = new C080(); nadRffLoop3.NAD.PARTYNAME_04.Partyname_01 = "KATHY SMITH"; nadRffLoop3.NAD.Cityname_06 = "BELTSVILLE"; nadRffLoop3.NAD.COUNTRYSUBENTITYDETAILS_07 = new C819(); nadRffLoop3.NAD.COUNTRYSUBENTITYDETAILS_07.Countrysubentitynamecode_01 = "MD"; nadRffLoop3.NAD.COUNTRYSUBENTITYDETAILS_07.Codelistidentificationcode_02 = "163"; nadRffLoop3.NAD.Postalidentificationcode_08 = "20708"; nadRffLoop3.NAD.Countrynamecode_09 = "US"; // Repeating CTA NAD Groups nadRffLoop3.CTALoop = new List <Loop_CTA_CUSCAR>(); // Begin CTA NAD Group var ctaNadLoop3 = new Loop_CTA_CUSCAR(); ctaNadLoop3.CTA = new CTA(); ctaNadLoop3.CTA.Contactfunctioncode_01 = "IC"; // Repeating COM ctaNadLoop3.COM = new List <COM>(); var comCta3 = new COM(); // Repeating C076 comCta3.COMMUNICATIONCONTACT_01 = new List <C076>(); var c076Com3 = new C076(); c076Com3.Communicationaddressidentifier_01 = "8005551212"; c076Com3.Communicationaddresscodequalifier_02 = "TE"; comCta3.COMMUNICATIONCONTACT_01.Add(c076Com2); ctaNadLoop3.COM.Add(comCta3); // End CTA NAD Group nadRffLoop3.CTALoop.Add(ctaNadLoop3); // End NAD RFF Group 3 rffCniLoop1.NADLoop.Add(nadRffLoop3); // Repeating GID RFF Groups rffCniLoop1.GIDLoop = new List <Loop_GID_CUSCAR>(); // Begin GID RFF Group var gidRffLoop1 = new Loop_GID_CUSCAR(); gidRffLoop1.GID = new GID(); gidRffLoop1.GID.Goodsitemnumber_01 = "1"; // Repeating PAC gidRffLoop1.PAC = new List <PAC>(); var pacGid1 = new PAC(); pacGid1.Packagequantity_01 = "158"; pacGid1.PACKAGETYPE_03 = new C202(); pacGid1.PACKAGETYPE_03.Packagetypedescriptioncode_01 = "COL"; gidRffLoop1.PAC.Add(pacGid1); // Repeating FTX gidRffLoop1.FTX = new List <FTX>(); var ftxGid1 = new FTX(); ftxGid1.Textsubjectcodequalifier_01 = "AAA"; ftxGid1.TEXTLITERAL_04 = new C108(); ftxGid1.TEXTLITERAL_04.Freetext_01 = "IRON COIL"; ftxGid1.TEXTLITERAL_04.Freetext_02 = "SHEET METAL"; gidRffLoop1.FTX.Add(ftxGid1); // Repeating MEA gidRffLoop1.MEA = new List <MEA>(); var meaGid1 = new MEA(); meaGid1.Measurementpurposecodequalifier_01 = "AAI"; meaGid1.VALUERANGE_03 = new C174(); meaGid1.VALUERANGE_03.Measurementunitcode_01 = "K"; meaGid1.VALUERANGE_03.Measure_02 = "750"; gidRffLoop1.MEA.Add(meaGid1); // Repeating SGP gidRffLoop1.SGP = new List <SGP>(); var sgpGid1 = new SGP(); sgpGid1.EQUIPMENTIDENTIFICATION_01 = new C237(); sgpGid1.EQUIPMENTIDENTIFICATION_01.Equipmentidentifier_01 = "10000325"; sgpGid1.EQUIPMENTIDENTIFICATION_01.Codelistidentificationcode_02 = "109"; gidRffLoop1.SGP.Add(sgpGid1); // End GID RFF Group rffCniLoop1.GIDLoop.Add(gidRffLoop1); // End RFF CNI Group cniLoop1.RFFLoop.Add(rffCniLoop1); // End CNI Group result.CNILoop.Add(cniLoop1); return(result); }
//获取商品详情 public static MallGoodsDetail GetMallGoodsDetail(long GoodsID) { using (var EF = new EF()) { var mallGoodsDetail = (from goodsInfo in EF.GoodsInfos join goodsBrand in EF.GoodsBrands on goodsInfo.ID equals goodsBrand.GoodsID // into t1 from goodsBrand in t1.DefaultIfEmpty() join goodsPhoto in EF.GoodsPhotos on goodsInfo.ID equals goodsPhoto.GoodsID // into t2 from goodsPhoto in t2.DefaultIfEmpty() join goodsDesc in EF.GoodsDescs on goodsInfo.ID equals goodsDesc.GoodsID into temp3 from goodsDesc in temp3.DefaultIfEmpty() where goodsInfo.Enabled == true && goodsInfo.StateID == (int)GoodsState.架 && goodsInfo.ID == GoodsID select new MallGoodsDetail { ID = goodsInfo.ID, Name = goodsInfo.Name, Title = goodsInfo.Title, BrandID = goodsBrand.BrandID, PhotoFileIDs = goodsPhoto.FileIDs, Description = goodsDesc.Description, }).FirstOrDefault(); //图片 mallGoodsDetail.Photos = new List <string>(); if (!string.IsNullOrWhiteSpace(mallGoodsDetail.PhotoFileIDs)) { foreach (var FileID in mallGoodsDetail.PhotoFileIDs.Split(',')) { var fileInfo = DOC.GetFileUploadInfo(long.Parse(FileID)); mallGoodsDetail.Photos.Add(fileInfo.FileInfo.GUID + fileInfo.FileExtName.Name); } } //价格 var specCounter = EF.GoodsCounter.Where(i => i.GoodsSpecID > 0 && i.GoodsID == mallGoodsDetail.ID).ToList(); if (specCounter.Count > 0) { var minPrice = specCounter.Min(i => i.Price); var maxPrice = specCounter.Max(i => i.Price); mallGoodsDetail.Price = minPrice == maxPrice?minPrice.ToString() : minPrice + " - " + maxPrice; } else { var singlePrice = EF.GoodsCounter.FirstOrDefault(i => i.GoodsSpecID == 0 && i.GoodsID == mallGoodsDetail.ID); mallGoodsDetail.Price = (singlePrice == null ? 0.00M : singlePrice.Price).ToString(); } //标签 mallGoodsDetail.Tags = EF.GoodsTags.Where(i => i.GoodsID == mallGoodsDetail.ID).Select(i => i.Title).ToList(); //单价 mallGoodsDetail.GoodsCounter = EF.GoodsCounter.Where(i => i.GoodsID == GoodsID && i.GoodsSpecID == 0).FirstOrDefault(); //规格 mallGoodsDetail.GoodsSpecsFull = (from goodsSpec in EF.GoodsSpecs join goodsCounter in EF.GoodsCounter on goodsSpec.ID equals goodsCounter.GoodsSpecID into temp1 from goodsCounter in temp1.DefaultIfEmpty() where goodsSpec.GoodsID == GoodsID && goodsSpec.Enabled == true select new GoodsSpecFull { SpecID = goodsSpec.ID, GoodsID = goodsSpec.GoodsID, Enabled = goodsSpec.Enabled, SpecValueIDs = goodsSpec.SpecValueIDs, SpecValues = goodsSpec.SpecValues, CounterID = goodsCounter.ID, SKU = goodsCounter.SKU, UPC = goodsCounter.UPC, EAN = goodsCounter.EAN, JAN = goodsCounter.JAN, ISBN = goodsCounter.ISBN, Price = goodsCounter.Price, Quantity = goodsCounter.Quantity, }).ToList(); if (mallGoodsDetail.GoodsSpecsFull != null) { mallGoodsDetail.SpecValues = new List <SpecValue>(); mallGoodsDetail.SpecInfos = new List <SpecInfo>(); foreach (var goodSpec in mallGoodsDetail.GoodsSpecsFull) { foreach (var specValueID in goodSpec.SpecValueIDs.Split(',')) { var ValueID = long.Parse(specValueID); mallGoodsDetail.SpecValues.Add(EF.SpecValues.Where(i => i.ID == ValueID).FirstOrDefault()); } } mallGoodsDetail.SpecValues = mallGoodsDetail.SpecValues.Distinct().OrderBy(i => i.ID).ToList(); foreach (var specID in mallGoodsDetail.SpecValues.Select(i => i.SpecID).Distinct().ToList()) { mallGoodsDetail.SpecInfos.Add(EF.SpecInfos.Where(i => i.ID == specID).FirstOrDefault()); } mallGoodsDetail.SpecInfos = mallGoodsDetail.SpecInfos.OrderBy(i => i.ID).ToList(); } return(mallGoodsDetail); } }
//获取商品详情 private static GoodsDetail GetGoodsDetails(long GoodsID, bool Enabled = false) { using (var EF = new EF()) { var details = (from goodsInfo in EF.GoodsInfos join goodsBrand in EF.GoodsBrands on goodsInfo.ID equals goodsBrand.GoodsID into temp1 from goodsBrand in temp1.DefaultIfEmpty() join goodsPhoto in EF.GoodsPhotos on goodsInfo.ID equals goodsPhoto.GoodsID into temp2 from goodsPhoto in temp2.DefaultIfEmpty() join goodsDesc in EF.GoodsDescs on goodsInfo.ID equals goodsDesc.GoodsID into temp3 from goodsDesc in temp3.DefaultIfEmpty() where goodsInfo.ID == GoodsID select new GoodsDetail { ID = goodsInfo.ID, Name = goodsInfo.Name, Title = goodsInfo.Title, Enabled = goodsInfo.Enabled, StateID = goodsInfo.StateID, GoodsBrandID = goodsBrand.BrandID, PhotoFileIDs = goodsPhoto.FileIDs, Description = goodsDesc.Description, }).FirstOrDefault(); //补充 if (details != null) { //品牌 if (details.GoodsBrandID != null) { details.BrandFullInfo = Brand.GetBrandFullInfo(details.GoodsBrandID ?? 0); } //品类 details.GoodsKinds = EF.GoodsKinds.Where(i => i.GoodsID == GoodsID).ToList(); if (details.GoodsKinds != null) { List <long> KindIDs = details.GoodsKinds.Select(i => i.KindID).ToList(); details.KindInfos = EF.KindInfos.Where(i => KindIDs.Contains(i.ID)).ToList(); } //标签 details.GoodsTags = EF.GoodsTags.Where(i => i.GoodsID == GoodsID).ToList(); //图片 details.PhotoUploadInfos = new List <FileUploadInfo>(); if (!string.IsNullOrWhiteSpace(details.PhotoFileIDs)) { foreach (var FileID in details.PhotoFileIDs.Split(',')) { details.PhotoUploadInfos.Add(DOC.GetFileUploadInfo(long.Parse(FileID))); } } //规格 var goodsSpecsFull = from goodsSpec in EF.GoodsSpecs join goodsCounter in EF.GoodsCounter on goodsSpec.ID equals goodsCounter.GoodsSpecID into temp1 from goodsCounter in temp1.DefaultIfEmpty() select new GoodsSpecFull { SpecID = goodsSpec.ID, GoodsID = goodsSpec.GoodsID, Enabled = goodsSpec.Enabled, SpecValueIDs = goodsSpec.SpecValueIDs, SpecValues = goodsSpec.SpecValues, SKU = goodsCounter.SKU, UPC = goodsCounter.UPC, EAN = goodsCounter.EAN, JAN = goodsCounter.JAN, ISBN = goodsCounter.ISBN, Price = goodsCounter.Price, Quantity = goodsCounter.Quantity, }; details.GoodsSpecsFull = Enabled ? goodsSpecsFull.Where(i => i.GoodsID == GoodsID && i.Enabled == true).ToList() : goodsSpecsFull.Where(i => i.GoodsID == GoodsID).OrderByDescending(i => i.Enabled).ToList(); if (details.GoodsSpecsFull != null) { details.SpecValues = new List <SpecValue>(); details.SpecInfos = new List <SpecInfo>(); foreach (var goodSpec in details.GoodsSpecsFull) { foreach (var specValueID in goodSpec.SpecValueIDs.Split(',')) { var ValueID = long.Parse(specValueID); details.SpecValues.Add(EF.SpecValues.Where(i => i.ID == ValueID).FirstOrDefault()); } } details.SpecValues = details.SpecValues.Distinct().ToList(); foreach (var specID in details.SpecValues.Select(i => i.SpecID).Distinct().ToList()) { details.SpecInfos.Add(EF.SpecInfos.Where(i => i.ID == specID).FirstOrDefault()); } } //单价 details.GoodsCounter = EF.GoodsCounter.Where(i => i.GoodsID == GoodsID && i.GoodsSpecID == 0).FirstOrDefault(); } return(details); }; }