public object ResolveFilter(Inquiry inquiry) { RequestedType = inquiry.Key as Type; return(null); }
public InquiryMethod(Inquiry Cdo, InquiryMethods Method, Inquiry_Parameters Parameters) { this.Cdo = Cdo; this.ServiceMethod = Method; this.Parameters = Parameters; }
public void ModeUAfterModeQ() { Inquiry inquiry = TestHelper.CreateInquiry(PTOK, out _sid, out _orderNum); // set CART with one item var cart = new ArrayList(); cart.Add(new CartItem("cart item 0 type", "cart item 0", "cart item 0 description", 10, 1234)); inquiry.SetCart(cart); // get response Response response = inquiry.GetResponse(); // optional getter var errors = response.GetErrors(); if (errors.Count > 0) { Assert.True(false, String.Join(Environment.NewLine, errors)); return; } var sessID = response.GetSessionId(); var tranID = response.GetTransactionId(); var ordNum = response.GetOrderNumber(); // create Update Update update = new Update(); update.SetMode(UpdateTypes.ModeU); update.SetVersion("0695"); update.SetSessionId(sessID); update.SetTransactionId(tranID); update.SetOrderNumber(ordNum); update.SetParameter("PTOK", Khash.HashPaymentToken("5386460135176807")); update.SetPaymentTokenLast4("6807"); update.SetMack('Y'); update.SetAuth('A'); update.SetAvst('M'); update.SetAvsz('M'); update.SetCvvr('M'); response = update.GetResponse(); errors = response.GetErrors(); Assert.True(errors.Count == 0, String.Join(Environment.NewLine, errors, "There are errors in response!")); var mode = response.GetMode(); Assert.True("U".Equals(mode), $"Update failed! Wrong response mode {mode}."); Assert.True(sessID.Equals(response.GetSessionId()), $"Update failed! Wrong session ID {sessID}."); Assert.True(tranID.Equals(response.GetTransactionId()), $"Update failed! Wrong Transaction Id {tranID}."); var ordU = response.GetOrderNumber(); // orderNum is null var auto = response.GetAuto(); Assert.True(auto == null, $"Inquiry failed! Approval status {auto} is not null"); var scor = response.GetScore(); Assert.True(scor == null, $"Inquiry failed! Score {scor} is not null"); var geox = response.GetGeox(); Assert.True(geox == null, $"Inquiry failed! GEOX {geox} is not null"); }
public DeviceInfo(Device dev) { Type = dev.Type; Manufacturer = dev.Manufacturer; Model = dev.Model; Revision = dev.Revision; Serial = dev.Serial; ScsiType = dev.ScsiType; IsRemovable = dev.IsRemovable; IsUsb = dev.IsUsb; UsbVendorId = dev.UsbVendorId; UsbProductId = dev.UsbProductId; UsbDescriptors = dev.UsbDescriptors; UsbManufacturerString = dev.UsbManufacturerString; UsbProductString = dev.UsbProductString; UsbSerialString = dev.UsbSerialString; IsFireWire = dev.IsFireWire; FireWireGuid = dev.FireWireGuid; FireWireModel = dev.FireWireModel; FireWireModelName = dev.FireWireModelName; FireWireVendor = dev.FireWireVendor; FireWireVendorName = dev.FireWireVendorName; IsCompactFlash = dev.IsCompactFlash; IsPcmcia = dev.IsPcmcia; Cis = dev.Cis; switch (dev.Type) { case DeviceType.ATA: { bool sense = dev.AtaIdentify(out byte[] ataBuf, out AtaErrorRegistersChs errorRegisters); if (sense) { DicConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status); DicConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error); DicConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount); DicConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector); DicConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}", errorRegisters.CylinderHigh); DicConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow); DicConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead); DicConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError); break; } if (dev.Error) { DicConsole.ErrorWriteLine("Error {0} querying ATA IDENTIFY", dev.LastError); break; } AtaIdentify = ataBuf; dev.EnableMediaCardPassThrough(out errorRegisters, dev.Timeout, out _); if (errorRegisters.Sector == 0xAA && errorRegisters.SectorCount == 0x55) { AtaMcptError = errorRegisters; } break; } case DeviceType.ATAPI: { bool sense = dev.AtapiIdentify(out byte[] ataBuf, out AtaErrorRegistersChs errorRegisters); if (sense) { DicConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status); DicConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error); DicConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount); DicConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector); DicConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}", errorRegisters.CylinderHigh); DicConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow); DicConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead); DicConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError); break; } if (!dev.Error) { AtapiIdentify = ataBuf; } else { DicConsole.ErrorWriteLine("Error {0} querying ATA PACKET IDENTIFY", dev.LastError); } // ATAPI devices are also SCSI devices goto case DeviceType.SCSI; } case DeviceType.SCSI: { bool sense = dev.ScsiInquiry(out byte[] inqBuf, out byte[] senseBuf); if (sense) { DicConsole.ErrorWriteLine("SCSI error:\n{0}", Sense.PrettifySense(senseBuf)); break; } ScsiInquiryData = inqBuf; ScsiInquiry = Inquiry.Decode(inqBuf); sense = dev.ScsiInquiry(out inqBuf, out senseBuf, 0x00); if (!sense) { ScsiEvpdPages = new Dictionary <byte, byte[]>(); byte[] pages = EVPD.DecodePage00(inqBuf); if (pages != null) { foreach (byte page in pages) { sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if (sense) { continue; } ScsiEvpdPages.Add(page, inqBuf); } } } PeripheralDeviceTypes devType = (PeripheralDeviceTypes)ScsiInquiry.Value.PeripheralDeviceType; sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out _); if (!sense && !dev.Error) { ScsiModeSense10 = modeBuf; } if (sense || dev.Error) { sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _); if (!sense && !dev.Error) { ScsiModeSense10 = modeBuf; } } if (!sense && !dev.Error) { ScsiMode = Modes.DecodeMode10(modeBuf, devType); } bool useMode10 = !(sense || dev.Error || !ScsiMode.HasValue); sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out _); if (!sense && !dev.Error) { ScsiModeSense6 = modeBuf; } if (sense || dev.Error) { sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _); if (!sense && !dev.Error) { ScsiModeSense6 = modeBuf; } } if (sense || dev.Error) { sense = dev.ModeSense(out modeBuf, out senseBuf, 5, out _); if (!sense && !dev.Error) { ScsiModeSense6 = modeBuf; } } if (!sense && !dev.Error && !useMode10) { ScsiMode = Modes.DecodeMode6(modeBuf, devType); } switch (devType) { case PeripheralDeviceTypes.MultiMediaDevice: { sense = dev.GetConfiguration(out byte[] confBuf, out senseBuf, dev.Timeout, out _); if (!sense) { MmcConfiguration = confBuf; } // TODO: DVD drives respond correctly to BD status. // While specification says if no medium is present // it should inform all possible capabilities, // testing drives show only supported media capabilities. /* * byte[] strBuf; * sense = dev.ReadDiscStructure(out strBuf, out senseBuf, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.CapabilityList, 0, dev.Timeout, out _); * * if (!sense) * { * Decoders.SCSI.DiscStructureCapabilities.Capability[] caps = Decoders.SCSI.DiscStructureCapabilities.Decode(strBuf); * if (caps != null) * { * foreach (Decoders.SCSI.DiscStructureCapabilities.Capability cap in caps) * { * if (cap.SDS && cap.RDS) * DicConsole.WriteLine("Drive can READ/SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode); * else if (cap.SDS) * DicConsole.WriteLine("Drive can SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode); * else if (cap.RDS) * DicConsole.WriteLine("Drive can READ DISC STRUCTURE format {0:X2}h", cap.FormatCode); * } * } * } * * sense = dev.ReadDiscStructure(out strBuf, out senseBuf, MmcDiscStructureMediaType.BD, 0, 0, MmcDiscStructureFormat.CapabilityList, 0, dev.Timeout, out _); * * if (!sense) * { * Decoders.SCSI.DiscStructureCapabilities.Capability[] caps = Decoders.SCSI.DiscStructureCapabilities.Decode(strBuf); * if (caps != null) * { * foreach (Decoders.SCSI.DiscStructureCapabilities.Capability cap in caps) * { * if (cap.SDS && cap.RDS) * DicConsole.WriteLine("Drive can READ/SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode); * else if (cap.SDS) * DicConsole.WriteLine("Drive can SEND DISC STRUCTURE format {0:X2}h", cap.FormatCode); * else if (cap.RDS) * DicConsole.WriteLine("Drive can READ DISC STRUCTURE format {0:X2}h", cap.FormatCode); * } * } * } */ #region Plextor if (dev.Manufacturer == "PLEXTOR") { bool plxtSense = true; bool plxtDvd = false; byte[] plxtBuf = null; switch (dev.Model) { case "DVDR PX-708A": case "DVDR PX-708A2": case "DVDR PX-712A": plxtDvd = true; plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout, out _); break; case "DVDR PX-714A": case "DVDR PX-716A": case "DVDR PX-716AL": case "DVDR PX-755A": case "DVDR PX-760A": { plxtBuf = new byte[256 * 4]; for (byte i = 0; i < 4; i++) { plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, out senseBuf, i, 256, dev.Timeout, out _); if (plxtSense) { break; } Array.Copy(plxtBufSmall, 0, plxtBuf, i * 256, 256); } plxtDvd = true; break; } default: { if (dev.Model.StartsWith("CD-R ", StringComparison.Ordinal)) { plxtSense = dev.PlextorReadEepromCdr(out plxtBuf, out senseBuf, dev.Timeout, out _); } break; } } PlextorFeatures = new Plextor { IsDvd = plxtDvd }; if (!plxtSense) { PlextorFeatures.Eeprom = plxtBuf; if (plxtDvd) { PlextorFeatures.Discs = BigEndianBitConverter.ToUInt16(plxtBuf, 0x0120); PlextorFeatures.CdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x0122); PlextorFeatures.CdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x0126); PlextorFeatures.DvdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x012A); PlextorFeatures.DvdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x012E); } else { PlextorFeatures.Discs = BigEndianBitConverter.ToUInt16(plxtBuf, 0x0078); PlextorFeatures.CdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x006C); PlextorFeatures.CdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x007A); } } plxtSense = dev.PlextorGetPoweRec(out senseBuf, out bool plxtPwrRecEnabled, out ushort plxtPwrRecSpeed, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.PoweRec = true; if (plxtPwrRecEnabled) { PlextorFeatures.PoweRecEnabled = true; PlextorFeatures.PoweRecRecommendedSpeed = plxtPwrRecSpeed; plxtSense = dev.PlextorGetSpeeds(out senseBuf, out ushort plxtPwrRecSelected, out ushort plxtPwrRecMax, out ushort plxtPwrRecLast, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.PoweRecSelected = plxtPwrRecSelected; PlextorFeatures.PoweRecMax = plxtPwrRecMax; PlextorFeatures.PoweRecLast = plxtPwrRecLast; } } } // TODO: Check it with a drive plxtSense = dev.PlextorGetSilentMode(out plxtBuf, out senseBuf, dev.Timeout, out _); if (!plxtSense) { if (plxtBuf[0] == 1) { PlextorFeatures.SilentModeEnabled = true; PlextorFeatures.AccessTimeLimit = plxtBuf[1]; PlextorFeatures.CdReadSpeedLimit = plxtBuf[2]; PlextorFeatures.DvdReadSpeedLimit = plxtBuf[3]; PlextorFeatures.CdWriteSpeedLimit = plxtBuf[4]; // TODO: Check which one is each one /* * if(plxtBuf[6] > 0) * DicConsole.WriteLine("\tTray eject speed limited to {0}", * -(plxtBuf[6] + 48)); * if(plxtBuf[7] > 0) * DicConsole.WriteLine("\tTray eject speed limited to {0}", * plxtBuf[7] - 47); */ } } plxtSense = dev.PlextorGetGigaRec(out plxtBuf, out senseBuf, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.GigaRec = true; } plxtSense = dev.PlextorGetSecuRec(out plxtBuf, out senseBuf, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.SecuRec = true; } plxtSense = dev.PlextorGetSpeedRead(out plxtBuf, out senseBuf, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.SpeedRead = true; if ((plxtBuf[2] & 0x01) == 0x01) { PlextorFeatures.SpeedReadEnabled = true; } } plxtSense = dev.PlextorGetHiding(out plxtBuf, out senseBuf, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.Hiding = true; if ((plxtBuf[2] & 0x02) == 0x02) { PlextorFeatures.HidesRecordables = true; } if ((plxtBuf[2] & 0x01) == 0x01) { PlextorFeatures.HidesSessions = true; } } plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, false, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.VariRec = true; } if (plxtDvd) { plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.VariRecDvd = true; } plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, false, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.BitSetting = true; } plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, true, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.BitSettingDl = true; } plxtSense = dev.PlextorGetTestWriteDvdPlus(out plxtBuf, out senseBuf, dev.Timeout, out _); if (!plxtSense) { PlextorFeatures.DvdPlusWriteTest = true; } } } #endregion Plextor if (ScsiInquiry.Value.KreonPresent) { if (!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout, out _)) { KreonFeatures = krFeatures; } } break; } case PeripheralDeviceTypes.SequentialAccess: { sense = dev.ReadBlockLimits(out byte[] seqBuf, out senseBuf, dev.Timeout, out _); if (sense) { DicConsole.ErrorWriteLine("READ BLOCK LIMITS:\n{0}", Sense.PrettifySense(senseBuf)); } else { BlockLimits = seqBuf; } sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, dev.Timeout, out _); if (sense) { DicConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}", Sense.PrettifySense(senseBuf)); } else { DensitySupport = seqBuf; DensitySupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeDensity(seqBuf); } sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, true, false, dev.Timeout, out _); if (sense) { DicConsole.ErrorWriteLine("REPORT DENSITY SUPPORT (MEDIUM):\n{0}", Sense.PrettifySense(senseBuf)); } else { MediumDensitySupport = seqBuf; MediaTypeSupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(seqBuf); } break; } } break; } case DeviceType.MMC: { bool sense = dev.ReadCid(out byte[] mmcBuf, out _, dev.Timeout, out _); if (!sense) { CID = mmcBuf; } sense = dev.ReadCsd(out mmcBuf, out _, dev.Timeout, out _); if (!sense) { CSD = mmcBuf; } sense = dev.ReadOcr(out mmcBuf, out _, dev.Timeout, out _); if (!sense) { OCR = mmcBuf; } sense = dev.ReadExtendedCsd(out mmcBuf, out _, dev.Timeout, out _); if (!sense) { ExtendedCSD = mmcBuf; } } break; case DeviceType.SecureDigital: { bool sense = dev.ReadCid(out byte[] sdBuf, out _, dev.Timeout, out _); if (!sense) { CID = sdBuf; } sense = dev.ReadCsd(out sdBuf, out _, dev.Timeout, out _); if (!sense) { CSD = sdBuf; } sense = dev.ReadSdocr(out sdBuf, out _, dev.Timeout, out _); if (!sense) { OCR = sdBuf; } sense = dev.ReadScr(out sdBuf, out _, dev.Timeout, out _); if (!sense) { SCR = sdBuf; } } break; default: DicConsole.ErrorWriteLine("Unknown device type {0}, cannot get information.", dev.Type); break; } }
protected override async void OnAppearing() { base.OnAppearing(); if (InquiryID == 0) { //check for customer mobile chat inquiry and create if not exist bool busy = false; if (!busy) { try { busy = true; await PopupNavigation.Instance.PushAsync(new LoadingPopup("Loading..")); await Task.Run(async() => { try { //registrationDBModel = getRegistrationDBModel(customerId, _token); inquirisResponseByCustomerId = getInquries(); if (inquirisResponseByCustomerId == null) { addCustomerChatInquery(); } else if (inquirisResponseByCustomerId.Count == 0) { addCustomerChatInquery(); } else { Inquiry customerChatInquiry = null; bool isChatInqueryAvailable = false; foreach (Inquiry i in inquirisResponseByCustomerId) { if (i.Subject == "Customer mobile chat") { isChatInqueryAvailable = true; customerChatInquiry = i; } } if (isChatInqueryAvailable) { updateChatInquiryInformation(Convert.ToInt32(customerChatInquiry.InquiryId)); } else { addCustomerChatInquery(); } } } catch (Exception ex) { await PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message)); } }); } catch (Exception ex) { await PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message)); } finally { busy = false; if (PopupNavigation.Instance.PopupStack.Count == 1) { await PopupNavigation.Instance.PopAllAsync(); } else if (PopupNavigation.Instance.PopupStack.Count > 1) { if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup)) { await PopupNavigation.Instance.PopAllAsync(); } } } } } else { updateChatInquiryInformation((int)InquiryID); } //this.BindingContext = new ChatPageViewModel(); }
public RisValidatorIpAddressTest() { this.inquiry = TestHelper.DefaultInquiry(out _sid, out _orderNum); this.inquiry.SetNoPayment(); }
public void VisitElementB(Inquiry elemB) { }
public Rules(XElement rootRulesNode, XElement rootRulesOrderNode, XElement rootRulesOrderParticipialNode, XElement rootRulesOrderHomogenousNode ) { Lexemes = new Lexemes(); var subsentsNode = rootRulesNode.GetSingleNode("Subsentences"); Subsentences = new Subsentences(subsentsNode); var sentencesNode = rootRulesNode.GetSingleNode("Sentences"); Sentences = new Sentences(sentencesNode); var subordinateSubsentNode = rootRulesNode.GetSingleNode("SubordinateSubsent"); SubordinateSubsent = new SubordinateSubsent(subordinateSubsentNode); var inquiryNode = rootRulesNode.GetSingleNode("Inquiry"); Inquiry = new Inquiry(inquiryNode); UnionOfConcessionAndReversIntoductory = new UnionOfConcessionAndReversIntoductory(rootRulesNode); #region [.Rules by order.] var rulesIdsByOrder = rootRulesOrderNode.GetAttributeNodes("Rule/@id") .Select(_ => _.Value) .ToArray(); _SubsentencesRulesByOrder = (from ruleId in rulesIdsByOrder select Subsentences.AllRules .ToArray() .FirstOrDefault(rule => rule.Id == ruleId) ) .ToArray(); if (_SubsentencesRulesByOrder.Any(rule => rule.IsNull())) { var notexists_rulesId = (from ruleId in rulesIdsByOrder let r = Subsentences.AllRules .FirstOrDefault(rule => rule.Id == ruleId) where (r == null) select ruleId ) .ToArray(); throw (new ArgumentException("In rules-order file exists rules with names, which not exists in main-rules file: " + string.Join(", ", notexists_rulesId).InSingleQuote())); } #endregion #region [.Rules by order 4 participial (Subsents, only 4 types => Participle, DanglingParticiple, Subordinate & some-Default).] var rulesIdsByOrderParticipial = rootRulesOrderParticipialNode.GetAttributeNodes("Rule/@id") .Select(_ => _.Value) .ToArray(); _SubsentencesRulesByOrder4Participial = (from ruleId in rulesIdsByOrderParticipial select Subsentences.AllRules .ToArray() .FirstOrDefault(rule => rule.Id == ruleId) ) .ToArray(); if (_SubsentencesRulesByOrder4Participial.Any(rule => rule.IsNull())) { throw (new ArgumentException("In rules-order-participial file exists rules with names, which not exists in main-rules file.")); } #endregion #region [.Rules by order 4 homogenous-entity.] var rulesIdsByOrderHomogenous = rootRulesOrderHomogenousNode.GetAttributeNodes("Rule/@id") .Select(_ => _.Value) .ToArray(); _SubsentencesRulesByOrder4Homogenous = (from ruleId in rulesIdsByOrderHomogenous select Subsentences.AllRules .ToArray() .FirstOrDefault(rule => rule.Id == ruleId) ) .ToArray(); if (_SubsentencesRulesByOrder4Homogenous.Any(rule => rule.IsNull())) { throw (new ArgumentException("In rules-order-homogenous file exists rules with names, which not exists in main-rules file.")); } #endregion }
public CampaignMaint() { PXDBAttributeAttribute.Activate(this.Caches[typeof(Contact)]); PXDBAttributeAttribute.Activate(Opportunities.Cache); PXUIFieldAttribute.SetEnabled <DAC.Standalone.CRCampaign.leadsGenerated>(CampaignCurrent.Cache, null, false); PXUIFieldAttribute.SetEnabled <DAC.Standalone.CRCampaign.leadsConverted>(CampaignCurrent.Cache, null, false); PXUIFieldAttribute.SetEnabled <DAC.Standalone.CRCampaign.contacts>(CampaignCurrent.Cache, null, false); PXUIFieldAttribute.SetEnabled <DAC.Standalone.CRCampaign.opportunities>(CampaignCurrent.Cache, null, false); PXUIFieldAttribute.SetEnabled <DAC.Standalone.CRCampaign.closedOpportunities>(CampaignCurrent.Cache, null, false); PXUIFieldAttribute.SetEnabled <DAC.Standalone.CRCampaign.opportunitiesValue>(CampaignCurrent.Cache, null, false); PXUIFieldAttribute.SetEnabled <DAC.Standalone.CRCampaign.closedOpportunitiesValue>(CampaignCurrent.Cache, null, false); PXUIFieldAttribute.SetRequired <CRCampaign.startDate>(CampaignCurrent.Cache, true); PXUIFieldAttribute.SetRequired <CRCampaign.status>(CampaignCurrent.Cache, true); var cache = Caches[typeof(Contact)]; PXDBAttributeAttribute.Activate(cache); PXUIFieldAttribute.SetVisible <Contact.title>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.workgroupID>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.firstName>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.midName>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.lastName>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.phone2>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.phone3>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.fax>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.webSite>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.dateOfBirth>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.createdByID>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.createdDateTime>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.lastModifiedByID>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.lastModifiedDateTime>(cache, null, false); PXUIFieldAttribute.SetVisible <Address.addressLine1>(Caches[typeof(Address)], null, false); PXUIFieldAttribute.SetVisible <Address.addressLine2>(Caches[typeof(Address)], null, false); PXUIFieldAttribute.SetVisible <Contact.classID>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.source>(cache, null, false); PXUIFieldAttribute.SetVisible <Contact.status>(cache, null, false); PXUIFieldAttribute.SetVisibility <Contact.contactPriority>(cache, null, PXUIVisibility.Invisible); PXUIFieldAttribute.SetDisplayName <BAccount.acctName>(Caches[typeof(BAccount)], Messages.CustomerName); cache = Caches[typeof(Lead)]; PXUIFieldAttribute.SetVisible <Lead.title>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.firstName>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.midName>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.lastName>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.phone1>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.phone2>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.phone3>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.fax>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.eMail>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.webSite>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.dateOfBirth>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.createdByID>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.createdDateTime>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.lastModifiedByID>(cache, null, false); PXUIFieldAttribute.SetVisible <Lead.lastModifiedDateTime>(cache, null, false); PXUIFieldAttribute.SetEnabled(this.Caches[typeof(Contact)], null, null, false); PXUIFieldAttribute.SetEnabled <Contact.selected>(this.Caches[typeof(Contact)], null, true); Inquiry.AddMenuAction(viewCampaignDocuments); Inquiry.MenuAutoOpen = true; }
private object Resolve(Inquiry inquiry, IHandler composer) { var type = inquiry.Key as Type; return(type == null?Unhandled <object>() : Activator.CreateInstance(type)); }
public string Process(Areas.Chat.Models.UserSession userSession, string input, Extracting.ValidInfo info) { //用户希望系统根据当前句的语义和之前的收集的信息立即推荐一款手机 if (Regex.IsMatch(input, @"推荐")) { userSession.liveTable.Candidates = Inquiry.Screening(userSession.liveTable.Parameter, info); if (userSession.liveTable.Candidates.Count == 0) { return(Answering.NotFound(userSession, info)); } else { // 目前能对多个值已定的属性进行手机推荐 userSession.liveTable.TalkingAbout = userSession.liveTable.Candidates[0]; userSession.liveTable.Candidates.Remove(userSession.liveTable.TalkingAbout); userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.RECOMMEND; return(userSession.liveTable.TalkingAbout.Brand + userSession.liveTable.TalkingAbout.Model + "这款不错,你可以了解一下。"); } } bool isDirect = false; //是不是直接问一款准确的手机型号 bool isPropertyExist = false; //询问的属性是否已经存在于livetable中 List <Models.CellPhone> list = new List <Models.CellPhone>(); foreach (var it in info.items) { if (String.IsNullOrEmpty(info.conflictFeedback) && it.name.Equals("型号")) { if (it.items.Count > 0) { isDirect = true; } } if (userSession.liveTable.Parameter[it.name] != null) { isPropertyExist = true; } } if (!isDirect) { // 针对某一款手机 if (userSession.liveTable.CurrentMode != Areas.Chat.Models.LiveTable.ModeType.DEBUGGING && userSession.liveTable.CurrentMode != Areas.Chat.Models.LiveTable.ModeType.LEARNING && userSession.liveTable.CurrentMode != Areas.Chat.Models.LiveTable.ModeType.START && userSession.liveTable.CurrentMode != Areas.Chat.Models.LiveTable.ModeType.END) { if (userSession.liveTable.TalkingAbout != null) { if (!isPropertyExist) { userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.DETAIL; string answer = ""; for (int i = 0; i < info.items.Count; i++) { string value = userSession.liveTable.TalkingAbout.GetType().GetProperty (Code.GlobalHash.SemanticToEN[info.items[i].name].ToString()).GetValue(userSession.liveTable.TalkingAbout, null).ToString(); if (Regex.IsMatch(info.items[i].items[0].normalData, @"\d+\.*\d+,\d+\.*\d+")) { string[] bounds = info.items[i].items[0].normalData.Split(new char[] { ',' }); if (Convert.ToDouble(bounds[0]) <= Convert.ToDouble(value) && Convert.ToDouble(value) <= Convert.ToDouble(bounds[1])) { answer += Code.Answering.getAnswerStatusFromSentence(userSession, true) + info.items[i].items[0].rawData; } else { answer += Code.Answering.getAnswerStatusFromSentence(userSession, false) + info.items[i].items[0].rawData; } } else { if (value.IndexOf(info.items[i].items[0].normalData) != -1) { answer += Code.Answering.getAnswerStatusFromSentence(userSession, true) + info.items[i].items[0].rawData; } else { answer += Code.Answering.getAnswerStatusFromSentence(userSession, false) + info.items[i].items[0].rawData; } } } if (answer[answer.Length - 1] == '|') { answer = answer.Substring(0, answer.Length - 1) + "。"; } else { answer = answer.Substring(0, answer.Length) + "。"; } return(answer); } else { userSession.liveTable.TalkingAbout.Model = null; List <string> ps = new List <string>(); List <Models.CellPhone> phonelist = Inquiry.Screening(userSession.liveTable.Parameter, info); string answer = ""; if (phonelist.Count > 0) { userSession.liveTable.Candidates = phonelist; answer = "是的,"; for (int i = 0; i < info.items.Count; i++) { ps.Add(info.items[i].name); } answer += Answering.Statement(phonelist[0], ps); if (input.IndexOf("有") != -1) { answer = answer.Replace("是", "有"); answer = answer.Replace("这款", ""); } else if (input.IndexOf("是") != -1) { answer = answer.Replace("有", "是"); answer = answer.Replace("这款", ""); } if (phonelist.Count <= 3) { userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.RECOMMEND; userSession.liveTable.TalkingAbout = phonelist[0]; answer += Answering.Recommand(phonelist[0]); } return(answer); } else { return(Answering.NotFound(userSession, info)); } } } else { List <string> ps = new List <string>(); List <Models.CellPhone> phonelist = Inquiry.Screening(userSession.liveTable.Parameter, info); string answer = ""; if (phonelist.Count > 0) { userSession.liveTable.Candidates = phonelist; answer = "是的,"; for (int i = 0; i < info.items.Count; i++) { ps.Add(info.items[i].name); } answer += Answering.Statement(phonelist[0], ps); if (input.IndexOf("有") != -1) { answer = answer.Replace("是", "有"); answer = answer.Replace("这款", ""); } else if (input.IndexOf("是") != -1) { answer = answer.Replace("有", "是"); answer = answer.Replace("这款", ""); } foreach (string s in Code.GlobalHash.ImportantParameter) { if (!userSession.liveTable.Parameter.ContainsKey(s)) { userSession.liveTable.RelatedParameter = s; userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.ACTIVE; answer += Answering.ActiveLeading(s); break; } } return(answer); } else { return(Answering.NotFound(userSession, info)); } } } } else { string answer = ""; List <string> ps = new List <string>(); list = Inquiry.Screening(userSession.liveTable.Parameter, info); if (list.Count <= 0) { if (info.items.Count < 2) { answer = "亲,不好意思," + "没有" + info.items[0].items[0].rawData; return(answer); } else { answer = "亲,不好意思," + "我们还没收录您提到的这个型号,我们正在努力更新数据~~"; return(answer); } } else { for (int i = 0; i < info.items.Count; i++) { ps.Add(info.items[i].name); } return(Answering.Statement(list[0], ps)); } } return(""); }
internal void LoadData(byte[] scsiInquiryData, Inquiry.SCSIInquiry?scsiInquiry, Dictionary <byte, byte[]> scsiEvpdPages, Modes.DecodedMode?scsiMode, PeripheralDeviceTypes scsiType, byte[] scsiModeSense6, byte[] scsiModeSense10, byte[] mmcConfiguration) { inquiryData = scsiInquiryData; inquiry = scsiInquiry; evpdPages = scsiEvpdPages; mode = scsiMode; type = scsiType; modeSense6 = scsiModeSense6; modeSense10 = scsiModeSense10; configuration = mmcConfiguration; if (inquiryData == null || !inquiry.HasValue) { return; } Visible = true; txtScsiInquiry.Text = Inquiry.Prettify(inquiry); if (mode.HasValue) { tabScsiModeSense.Visible = true; TreeGridItemCollection modePagesList = new TreeGridItemCollection(); treeModeSensePages.Columns.Add(new GridColumn { HeaderText = "Page", DataCell = new TextBoxCell(0) }); treeModeSensePages.AllowMultipleSelection = false; treeModeSensePages.ShowHeader = false; treeModeSensePages.DataStore = modePagesList; modePagesList.Add(new TreeGridItem { Values = new object[] { "Header", Modes.PrettifyModeHeader(mode.Value.Header, type) } }); foreach (Modes.ModePage page in mode.Value.Pages.OrderBy(t => t.Page).ThenBy(t => t.Subpage)) { string pageNumberText = page.Subpage == 0 ? $"MODE {page.Page:X2}h" : $"MODE {page.Page:X2} Subpage {page.Subpage:X2}"; string decodedText; switch (page.Page) { case 0x00: { if (type == PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0) { decodedText = Modes.PrettifyModePage_00_SFF(page.PageResponse); } else { decodedText = "Undecoded"; } break; } case 0x01: { if (page.Subpage == 0) { decodedText = type == PeripheralDeviceTypes.MultiMediaDevice ? Modes.PrettifyModePage_01_MMC(page.PageResponse) : Modes.PrettifyModePage_01(page.PageResponse); } else { goto default; } break; } case 0x02: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_02(page.PageResponse); } else { goto default; } break; } case 0x03: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_03(page.PageResponse); } else { goto default; } break; } case 0x04: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_04(page.PageResponse); } else { goto default; } break; } case 0x05: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_05(page.PageResponse); } else { goto default; } break; } case 0x06: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_06(page.PageResponse); } else { goto default; } break; } case 0x07: { if (page.Subpage == 0) { decodedText = type == PeripheralDeviceTypes.MultiMediaDevice ? Modes.PrettifyModePage_07_MMC(page.PageResponse) : Modes.PrettifyModePage_07(page.PageResponse); } else { goto default; } break; } case 0x08: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_08(page.PageResponse); } else { goto default; } break; } case 0x0A: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_0A(page.PageResponse); } else if (page.Subpage == 1) { decodedText = Modes.PrettifyModePage_0A_S01(page.PageResponse); } else { goto default; } break; } case 0x0B: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_0B(page.PageResponse); } else { goto default; } break; } case 0x0D: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_0D(page.PageResponse); } else { goto default; } break; } case 0x0E: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_0E(page.PageResponse); } else { goto default; } break; } case 0x0F: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_0F(page.PageResponse); } else { goto default; } break; } case 0x10: { if (page.Subpage == 0) { decodedText = type == PeripheralDeviceTypes.SequentialAccess ? Modes.PrettifyModePage_10_SSC(page.PageResponse) : Modes.PrettifyModePage_10(page.PageResponse); } else { goto default; } break; } case 0x11: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_11(page.PageResponse); } else { goto default; } break; } case 0x12: case 0x13: case 0x14: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_12_13_14(page.PageResponse); } else { goto default; } break; } case 0x1A: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_1A(page.PageResponse); } else if (page.Subpage == 1) { decodedText = Modes.PrettifyModePage_1A_S01(page.PageResponse); } else { goto default; } break; } case 0x1B: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_1B(page.PageResponse); } else { goto default; } break; } case 0x1C: { if (page.Subpage == 0) { decodedText = type == PeripheralDeviceTypes.MultiMediaDevice ? Modes.PrettifyModePage_1C_SFF(page.PageResponse) : Modes.PrettifyModePage_1C(page.PageResponse); } else if (page.Subpage == 1) { decodedText = Modes.PrettifyModePage_1C_S01(page.PageResponse); } else { goto default; } break; } case 0x1D: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_1D(page.PageResponse); } else { goto default; } break; } case 0x21: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "CERTANCE") { decodedText = Modes.PrettifyCertanceModePage_21(page.PageResponse); } else { goto default; } break; } case 0x22: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "CERTANCE") { decodedText = Modes.PrettifyCertanceModePage_22(page.PageResponse); } else { goto default; } break; } case 0x24: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "IBM") { decodedText = Modes.PrettifyIBMModePage_24(page.PageResponse); } else { goto default; } break; } case 0x2A: { if (page.Subpage == 0) { decodedText = Modes.PrettifyModePage_2A(page.PageResponse); } else { goto default; } break; } case 0x2F: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "IBM") { decodedText = Modes.PrettifyIBMModePage_2F(page.PageResponse); } else { goto default; } break; } case 0x30: { if (Modes.IsAppleModePage_30(page.PageResponse)) { decodedText = "Drive identifies as Apple OEM drive"; } else { goto default; } break; } case 0x3B: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP") { decodedText = Modes.PrettifyHPModePage_3B(page.PageResponse); } else { goto default; } break; } case 0x3C: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP") { decodedText = Modes.PrettifyHPModePage_3C(page.PageResponse); } else { goto default; } break; } case 0x3D: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "IBM") { decodedText = Modes.PrettifyIBMModePage_3D(page.PageResponse); } else if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP") { decodedText = Modes.PrettifyHPModePage_3D(page.PageResponse); } else { goto default; } break; } case 0x3E: { if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "FUJITSU") { decodedText = Modes.PrettifyFujitsuModePage_3E(page.PageResponse); } else if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP") { decodedText = Modes.PrettifyHPModePage_3E(page.PageResponse); } else { goto default; } break; } default: { decodedText = "Undecoded"; break; } } // TODO: Automatic error reporting if (decodedText == null) { decodedText = "Error decoding page, please open an issue."; } modePagesList.Add(new TreeGridItem { Values = new object[] { pageNumberText, decodedText } }); } } if (evpdPages != null) { tabScsiEvpd.Visible = true; treeEvpdPages.ShowHeader = false; TreeGridItemCollection evpdPagesList = new TreeGridItemCollection(); treeEvpdPages.Columns.Add(new GridColumn { HeaderText = "Page", DataCell = new TextBoxCell(0) }); treeEvpdPages.AllowMultipleSelection = false; treeEvpdPages.ShowHeader = false; treeEvpdPages.DataStore = evpdPagesList; foreach (KeyValuePair <byte, byte[]> page in evpdPages.OrderBy(t => t.Key)) { string evpdPageTitle = ""; string evpdDecodedPage = ""; if (page.Key >= 0x01 && page.Key <= 0x7F) { evpdPageTitle = $"ASCII Page {page.Key:X2}h"; evpdDecodedPage = EVPD.DecodeASCIIPage(page.Value); } else if (page.Key == 0x80) { evpdPageTitle = "Unit Serial Number"; evpdDecodedPage = EVPD.DecodePage80(page.Value); } else if (page.Key == 0x81) { evpdPageTitle = "SCSI Implemented operating definitions"; evpdDecodedPage = EVPD.PrettifyPage_81(page.Value); } else if (page.Key == 0x82) { evpdPageTitle = "ASCII implemented operating definitions"; evpdDecodedPage = EVPD.DecodePage82(page.Value); } else if (page.Key == 0x83) { evpdPageTitle = "SCSI Device identification"; evpdDecodedPage = EVPD.PrettifyPage_83(page.Value); } else if (page.Key == 0x84) { evpdPageTitle = "SCSI Software Interface Identifiers"; evpdDecodedPage = EVPD.PrettifyPage_84(page.Value); } else if (page.Key == 0x85) { evpdPageTitle = "SCSI Management Network Addresses"; evpdDecodedPage = EVPD.PrettifyPage_85(page.Value); } else if (page.Key == 0x86) { evpdPageTitle = "SCSI Extended INQUIRY Data"; evpdDecodedPage = EVPD.PrettifyPage_86(page.Value); } else if (page.Key == 0x89) { evpdPageTitle = "SCSI to ATA Translation Layer Data"; evpdDecodedPage = EVPD.PrettifyPage_89(page.Value); } else if (page.Key == 0xB0) { evpdPageTitle = "SCSI Sequential-access Device Capabilities"; evpdDecodedPage = EVPD.PrettifyPage_B0(page.Value); } else if (page.Key == 0xB1) { evpdPageTitle = "Manufacturer-assigned Serial Number"; evpdDecodedPage = EVPD.DecodePageB1(page.Value); } else if (page.Key == 0xB2) { evpdPageTitle = "TapeAlert Supported Flags Bitmap"; evpdDecodedPage = $"0x{EVPD.DecodePageB2(page.Value):X16}"; } else if (page.Key == 0xB3) { evpdPageTitle = "Automation Device Serial Number"; evpdDecodedPage = EVPD.DecodePageB3(page.Value); } else if (page.Key == 0xB4) { evpdPageTitle = "Data Transfer Device Element Address"; evpdDecodedPage = EVPD.DecodePageB4(page.Value); } else if (page.Key == 0xC0 && StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == "quantum") { evpdPageTitle = "Quantum Firmware Build Information page"; evpdDecodedPage = EVPD.PrettifyPage_C0_Quantum(page.Value); } else if (page.Key == 0xC0 && StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == "seagate") { evpdPageTitle = "Seagate Firmware Numbers page"; evpdDecodedPage = EVPD.PrettifyPage_C0_Seagate(page.Value); } else if (page.Key == 0xC0 && StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == "ibm") { evpdPageTitle = "IBM Drive Component Revision Levels page"; evpdDecodedPage = EVPD.PrettifyPage_C0_IBM(page.Value); } else if (page.Key == 0xC1 && StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == "ibm") { evpdPageTitle = "IBM Drive Serial Numbers page"; evpdDecodedPage = EVPD.PrettifyPage_C1_IBM(page.Value); } else if ((page.Key == 0xC0 || page.Key == 0xC1) && StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == "certance") { evpdPageTitle = "Certance Drive Component Revision Levels page"; evpdDecodedPage = EVPD.PrettifyPage_C0_C1_Certance(page.Value); } else if ((page.Key == 0xC2 || page.Key == 0xC3 || page.Key == 0xC4 || page.Key == 0xC5 || page.Key == 0xC6) && StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == "certance") { switch (page.Key) { case 0xC2: evpdPageTitle = "Head Assembly Serial Number"; break; case 0xC3: evpdPageTitle = "Reel Motor 1 Serial Number"; break; case 0xC4: evpdPageTitle = "Reel Motor 2 Serial Number"; break; case 0xC5: evpdPageTitle = "Board Serial Number"; break; case 0xC6: evpdPageTitle = "Base Mechanical Serial Number"; break; } evpdDecodedPage = EVPD.PrettifyPage_C2_C3_C4_C5_C6_Certance(page.Value); } else if ((page.Key == 0xC0 || page.Key == 0xC1 || page.Key == 0xC2 || page.Key == 0xC3 || page.Key == 0xC4 || page.Key == 0xC5) && StringHandlers .CToString(inquiry.Value.VendorIdentification) .ToLowerInvariant().Trim() == "hp") { switch (page.Key) { case 0xC0: evpdPageTitle = "HP Drive Firmware Revision Levels page:"; break; case 0xC1: evpdPageTitle = "HP Drive Hardware Revision Levels page:"; break; case 0xC2: evpdPageTitle = "HP Drive PCA Revision Levels page:"; break; case 0xC3: evpdPageTitle = "HP Drive Mechanism Revision Levels page:"; break; case 0xC4: evpdPageTitle = "HP Drive Head Assembly Revision Levels page:"; break; case 0xC5: evpdPageTitle = "HP Drive ACI Revision Levels page:"; break; } evpdDecodedPage = EVPD.PrettifyPage_C0_to_C5_HP(page.Value); } else if (page.Key == 0xDF && StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == "certance") { evpdPageTitle = "Certance drive status page"; evpdDecodedPage = EVPD.PrettifyPage_DF_Certance(page.Value); } else { if (page.Key == 0x00) { continue; } evpdPageTitle = $"Page {page.Key:X2}h"; evpdDecodedPage = "Undecoded"; DicConsole.DebugWriteLine("Device-Info command", "Found undecoded SCSI VPD page 0x{0:X2}", page.Key); } evpdPagesList.Add(new TreeGridItem { Values = new object[] { evpdPageTitle, evpdDecodedPage, page.Value } }); } } if (configuration != null) { tabMmcFeatures.Visible = true; TreeGridItemCollection featuresList = new TreeGridItemCollection(); treeMmcFeatures.Columns.Add(new GridColumn { HeaderText = "Feature", DataCell = new TextBoxCell(0) }); treeMmcFeatures.AllowMultipleSelection = false; treeMmcFeatures.ShowHeader = false; treeMmcFeatures.DataStore = featuresList; Features.SeparatedFeatures ftr = Features.Separate(configuration); DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", ftr.DataLength); DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION current profile is {0:X4}h", ftr.CurrentProfile); if (ftr.Descriptors != null) { foreach (Features.FeatureDescriptor desc in ftr.Descriptors) { string featureNumber = $"Feature {desc.Code:X4}h"; string featureDescription; DicConsole.DebugWriteLine("Device-Info command", "Feature {0:X4}h", desc.Code); switch (desc.Code) { case 0x0000: featureDescription = Features.Prettify_0000(desc.Data); break; case 0x0001: featureDescription = Features.Prettify_0001(desc.Data); break; case 0x0002: featureDescription = Features.Prettify_0002(desc.Data); break; case 0x0003: featureDescription = Features.Prettify_0003(desc.Data); break; case 0x0004: featureDescription = Features.Prettify_0004(desc.Data); break; case 0x0010: featureDescription = Features.Prettify_0010(desc.Data); break; case 0x001D: featureDescription = Features.Prettify_001D(desc.Data); break; case 0x001E: featureDescription = Features.Prettify_001E(desc.Data); break; case 0x001F: featureDescription = Features.Prettify_001F(desc.Data); break; case 0x0020: featureDescription = Features.Prettify_0020(desc.Data); break; case 0x0021: featureDescription = Features.Prettify_0021(desc.Data); break; case 0x0022: featureDescription = Features.Prettify_0022(desc.Data); break; case 0x0023: featureDescription = Features.Prettify_0023(desc.Data); break; case 0x0024: featureDescription = Features.Prettify_0024(desc.Data); break; case 0x0025: featureDescription = Features.Prettify_0025(desc.Data); break; case 0x0026: featureDescription = Features.Prettify_0026(desc.Data); break; case 0x0027: featureDescription = Features.Prettify_0027(desc.Data); break; case 0x0028: featureDescription = Features.Prettify_0028(desc.Data); break; case 0x0029: featureDescription = Features.Prettify_0029(desc.Data); break; case 0x002A: featureDescription = Features.Prettify_002A(desc.Data); break; case 0x002B: featureDescription = Features.Prettify_002B(desc.Data); break; case 0x002C: featureDescription = Features.Prettify_002C(desc.Data); break; case 0x002D: featureDescription = Features.Prettify_002D(desc.Data); break; case 0x002E: featureDescription = Features.Prettify_002E(desc.Data); break; case 0x002F: featureDescription = Features.Prettify_002F(desc.Data); break; case 0x0030: featureDescription = Features.Prettify_0030(desc.Data); break; case 0x0031: featureDescription = Features.Prettify_0031(desc.Data); break; case 0x0032: featureDescription = Features.Prettify_0032(desc.Data); break; case 0x0033: featureDescription = Features.Prettify_0033(desc.Data); break; case 0x0035: featureDescription = Features.Prettify_0035(desc.Data); break; case 0x0037: featureDescription = Features.Prettify_0037(desc.Data); break; case 0x0038: featureDescription = Features.Prettify_0038(desc.Data); break; case 0x003A: featureDescription = Features.Prettify_003A(desc.Data); break; case 0x003B: featureDescription = Features.Prettify_003B(desc.Data); break; case 0x0040: featureDescription = Features.Prettify_0040(desc.Data); break; case 0x0041: featureDescription = Features.Prettify_0041(desc.Data); break; case 0x0042: featureDescription = Features.Prettify_0042(desc.Data); break; case 0x0050: featureDescription = Features.Prettify_0050(desc.Data); break; case 0x0051: featureDescription = Features.Prettify_0051(desc.Data); break; case 0x0080: featureDescription = Features.Prettify_0080(desc.Data); break; case 0x0100: featureDescription = Features.Prettify_0100(desc.Data); break; case 0x0101: featureDescription = Features.Prettify_0101(desc.Data); break; case 0x0102: featureDescription = Features.Prettify_0102(desc.Data); break; case 0x0103: featureDescription = Features.Prettify_0103(desc.Data); break; case 0x0104: featureDescription = Features.Prettify_0104(desc.Data); break; case 0x0105: featureDescription = Features.Prettify_0105(desc.Data); break; case 0x0106: featureDescription = Features.Prettify_0106(desc.Data); break; case 0x0107: featureDescription = Features.Prettify_0107(desc.Data); break; case 0x0108: featureDescription = Features.Prettify_0108(desc.Data); break; case 0x0109: featureDescription = Features.Prettify_0109(desc.Data); break; case 0x010A: featureDescription = Features.Prettify_010A(desc.Data); break; case 0x010B: featureDescription = Features.Prettify_010B(desc.Data); break; case 0x010C: featureDescription = Features.Prettify_010C(desc.Data); break; case 0x010D: featureDescription = Features.Prettify_010D(desc.Data); break; case 0x010E: featureDescription = Features.Prettify_010E(desc.Data); break; case 0x0110: featureDescription = Features.Prettify_0110(desc.Data); break; case 0x0113: featureDescription = Features.Prettify_0113(desc.Data); break; case 0x0142: featureDescription = Features.Prettify_0142(desc.Data); break; default: featureDescription = "Unknown feature"; break; } featuresList.Add(new TreeGridItem { Values = new object[] { featureNumber, featureDescription } }); } } else { DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION returned no feature descriptors"); } } Invalidate(); }
public string Process(Areas.Chat.Models.UserSession userSession, string input, Extracting.ValidInfo info) { //用户希望系统根据当前上下文推荐一个符合其他要求的基础上的手机属性 eg:能不能推荐一种颜色给我? if (Regex.IsMatch(input, @"推荐")) { if (userSession.liveTable.Candidates.Count == 0) { userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.NOTFOUND; return("不好意思,目前没有符合您要求的手机, 所以没有可以推荐的内容。我们会尽快收录。麻烦您改一下之前提出的条件吧。"); } else { // 目前推荐属性只支持单个属性的推荐 Models.CellPhone phone = userSession.liveTable.Candidates[0]; string retValue = ""; Type type = phone.GetType(); PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo pi in props) { string value1 = Convert.ToString(pi.GetValue(phone, null)); string name = pi.Name; if (GlobalHash.SemanticToCN[name].Equals(info.items[0].name)) { retValue = value1; break; } } if (Regex.IsMatch(retValue, @"^\d+$") && !info.items[0].name.Equals("型号")) { List <Code.Extracting.InfoUnit> temp = new List <Extracting.InfoUnit>(); temp.Add(new Code.Extracting.InfoUnit(retValue, string.Format("{0},{1}", Convert.ToDouble(retValue) * 0.99, Convert.ToDouble(retValue) * 1.01))); Code.Extracting.InfoBlock oneblock = new Extracting.InfoBlock(info.items[0].name, "or", temp); userSession.liveTable.Parameter[info.items[0].name] = oneblock; } else { if (retValue.IndexOf("|") >= 0) { retValue = retValue.Split(new char[] { '|' })[0]; } List <Code.Extracting.InfoUnit> temp = new List <Extracting.InfoUnit>(); temp.Add(new Code.Extracting.InfoUnit(retValue, retValue)); Code.Extracting.InfoBlock oneblock = new Extracting.InfoBlock(info.items[0].name, "or", temp); userSession.liveTable.Parameter[info.items[0].name] = oneblock; } return(retValue + "是个不错的选择。"); } } if (info.items.Count > 1) { // 诺基亚1200有什么颜色的? Areas.Chat.Models.LiveTable liveTableTemp = new Areas.Chat.Models.LiveTable(); List <string> ps = new List <string>(); List <Models.CellPhone> phonelist = Inquiry.Screening(liveTableTemp.Parameter, info); for (int i = 0; i < info.items.Count; i++) { ps.Add(info.items[i].name); } string answer = Answering.Statement(phonelist[0], ps); if (input.IndexOf("有") != -1) { answer = answer.Replace("是", "有"); } return(answer); } else { // 已经推荐了一款手机,用户问“有什么颜色” if (userSession.liveTable.CurrentMode == Areas.Chat.Models.LiveTable.ModeType.RECOMMEND || userSession.liveTable.CurrentMode == Areas.Chat.Models.LiveTable.ModeType.DETAIL) { if (userSession.liveTable.TalkingAbout != null) { List <string> ps = new List <string>(); for (int i = 0; i < info.items.Count; i++) { ps.Add(info.items[i].name); } userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.DETAIL; string answer = Answering.Statement(userSession.liveTable.TalkingAbout, ps); if (input.IndexOf("有") != -1) { answer = answer.Replace("是", "有"); } return(answer); } } else { // 查询数据库,返回手机列表list List <Models.CellPhone> list = Inquiry.Screening(userSession.liveTable.Parameter, info); userSession.liveTable.Candidates = list; if (list.Count > 3) { /* 如果筛选结果大于三款(且重要属性只有4个以下被确认),则进行主动引导 * 首先要先确定要引导的参数 * 然后还要记录当前状态变成主动引导 * 以及记录相关参数到live-table的RelativeParameter * */ string answear = "符合您要求的手机有以下几款:"; for (int i = 0; i < 2; ++i) { answear = answear + list[i].Brand + list[i].Model + "、"; } answear = answear + list[2].Brand + list[2].Model + "等。"; int recordedImportantParameter = 0; //如果重要属性已有4个以上被确认,直接进行推荐,不继续引导 foreach (string s in Code.GlobalHash.ImportantParameter) { if (recordedImportantParameter >= 4) { userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.RECOMMEND; userSession.liveTable.TalkingAbout = list[0]; return(Answering.Recommand(list[0])); } if (!userSession.liveTable.Parameter.ContainsKey(s)) { userSession.liveTable.RelatedParameter = s; userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.ACTIVE; return(answear + Answering.ActiveLeading(s)); } else { recordedImportantParameter++; } } } else if (list.Count <= 0) { return(Answering.NotFound(userSession, info)); // 状态CurrentMode在该方法中变更 } else { userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.RECOMMEND; userSession.liveTable.TalkingAbout = list[0]; return(Answering.Recommand(list[0])); } } } return(""); }
public static void PrintImageInfo(IMediaImage imageFormat) { DicConsole.WriteLine("Image information:"); if (!string.IsNullOrWhiteSpace(imageFormat.Info.Version)) { DicConsole.WriteLine("Format: {0} version {1}", imageFormat.Format, imageFormat.Info.Version); } else { DicConsole.WriteLine("Format: {0}", imageFormat.Format); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.Application) && !string.IsNullOrWhiteSpace(imageFormat.Info.ApplicationVersion)) { DicConsole.WriteLine("Was created with {0} version {1}", imageFormat.Info.Application, imageFormat.Info.ApplicationVersion); } else if (!string.IsNullOrWhiteSpace(imageFormat.Info.Application)) { DicConsole.WriteLine("Was created with {0}", imageFormat.Info.Application); } DicConsole.WriteLine("Image without headers is {0} bytes long", imageFormat.Info.ImageSize); DicConsole.WriteLine("Contains a media of {0} sectors with a maximum sector size of {1} bytes (if all sectors are of the same size this would be {2} bytes)", imageFormat.Info.Sectors, imageFormat.Info.SectorSize, imageFormat.Info.Sectors * imageFormat.Info.SectorSize); if (!string.IsNullOrWhiteSpace(imageFormat.Info.Creator)) { DicConsole.WriteLine("Created by: {0}", imageFormat.Info.Creator); } if (imageFormat.Info.CreationTime != DateTime.MinValue) { DicConsole.WriteLine("Created on {0}", imageFormat.Info.CreationTime); } if (imageFormat.Info.LastModificationTime != DateTime.MinValue) { DicConsole.WriteLine("Last modified on {0}", imageFormat.Info.LastModificationTime); } DicConsole.WriteLine("Contains a media of type {0} and XML type {1}", imageFormat.Info.MediaType, imageFormat.Info.XmlMediaType); DicConsole.WriteLine("{0} partitions", imageFormat.Info.HasPartitions ? "Has" : "Doesn't have"); DicConsole.WriteLine("{0} sessions", imageFormat.Info.HasSessions ? "Has" : "Doesn't have"); if (!string.IsNullOrWhiteSpace(imageFormat.Info.Comments)) { DicConsole.WriteLine("Comments: {0}", imageFormat.Info.Comments); } if (imageFormat.Info.MediaSequence != 0 && imageFormat.Info.LastMediaSequence != 0) { DicConsole.WriteLine("Media is number {0} on a set of {1} medias", imageFormat.Info.MediaSequence, imageFormat.Info.LastMediaSequence); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaTitle)) { DicConsole.WriteLine("Media title: {0}", imageFormat.Info.MediaTitle); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaManufacturer)) { DicConsole.WriteLine("Media manufacturer: {0}", imageFormat.Info.MediaManufacturer); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaModel)) { DicConsole.WriteLine("Media model: {0}", imageFormat.Info.MediaModel); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaSerialNumber)) { DicConsole.WriteLine("Media serial number: {0}", imageFormat.Info.MediaSerialNumber); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaBarcode)) { DicConsole.WriteLine("Media barcode: {0}", imageFormat.Info.MediaBarcode); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaPartNumber)) { DicConsole.WriteLine("Media part number: {0}", imageFormat.Info.MediaPartNumber); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveManufacturer)) { DicConsole.WriteLine("Drive manufacturer: {0}", imageFormat.Info.DriveManufacturer); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveModel)) { DicConsole.WriteLine("Drive model: {0}", imageFormat.Info.DriveModel); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveSerialNumber)) { DicConsole.WriteLine("Drive serial number: {0}", imageFormat.Info.DriveSerialNumber); } if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveFirmwareRevision)) { DicConsole.WriteLine("Drive firmware info: {0}", imageFormat.Info.DriveFirmwareRevision); } if (imageFormat.Info.Cylinders > 0 && imageFormat.Info.Heads > 0 && imageFormat.Info.SectorsPerTrack > 0 && imageFormat.Info.XmlMediaType != XmlMediaType.OpticalDisc && (!(imageFormat is ITapeImage tapeImage) || !tapeImage.IsTape)) { DicConsole.WriteLine("Media geometry: {0} cylinders, {1} heads, {2} sectors per track", imageFormat.Info.Cylinders, imageFormat.Info.Heads, imageFormat.Info.SectorsPerTrack); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Count > 0) { DicConsole.WriteLine("Contains {0} readable media tags:", imageFormat.Info.ReadableMediaTags.Count); foreach (MediaTagType tag in imageFormat.Info.ReadableMediaTags.OrderBy(t => t)) { DicConsole.Write("{0} ", tag); } DicConsole.WriteLine(); } if (imageFormat.Info.ReadableSectorTags != null && imageFormat.Info.ReadableSectorTags.Count > 0) { DicConsole.WriteLine("Contains {0} readable sector tags:", imageFormat.Info.ReadableSectorTags.Count); foreach (SectorTagType tag in imageFormat.Info.ReadableSectorTags.OrderBy(t => t)) { DicConsole.Write("{0} ", tag); } DicConsole.WriteLine(); } DicConsole.WriteLine(); PeripheralDeviceTypes scsiDeviceType = PeripheralDeviceTypes.DirectAccess; byte[] scsiVendorId = null; if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_INQUIRY)) { byte[] inquiry = imageFormat.ReadDiskTag(MediaTagType.SCSI_INQUIRY); scsiDeviceType = (PeripheralDeviceTypes)(inquiry[0] & 0x1F); if (inquiry.Length >= 16) { scsiVendorId = new byte[8]; Array.Copy(inquiry, 8, scsiVendorId, 0, 8); } DicConsole.WriteLine("SCSI INQUIRY contained in image:"); DicConsole.Write("{0}", Inquiry.Prettify(inquiry)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY)) { byte[] identify = imageFormat.ReadDiskTag(MediaTagType.ATA_IDENTIFY); DicConsole.WriteLine("ATA IDENTIFY contained in image:"); DicConsole.Write("{0}", Identify.Prettify(identify)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.ATAPI_IDENTIFY)) { byte[] identify = imageFormat.ReadDiskTag(MediaTagType.ATAPI_IDENTIFY); DicConsole.WriteLine("ATAPI IDENTIFY contained in image:"); DicConsole.Write("{0}", Identify.Prettify(identify)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_MODESENSE_10)) { byte[] modeSense10 = imageFormat.ReadDiskTag(MediaTagType.SCSI_MODESENSE_10); Modes.DecodedMode?decMode = Modes.DecodeMode10(modeSense10, scsiDeviceType); if (decMode.HasValue) { DicConsole.WriteLine("SCSI MODE SENSE (10) contained in image:"); PrintScsiModePages.Print(decMode.Value, scsiDeviceType, scsiVendorId); DicConsole.WriteLine(); } } else if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_MODESENSE_6)) { byte[] modeSense6 = imageFormat.ReadDiskTag(MediaTagType.SCSI_MODESENSE_6); Modes.DecodedMode?decMode = Modes.DecodeMode6(modeSense6, scsiDeviceType); if (decMode.HasValue) { DicConsole.WriteLine("SCSI MODE SENSE (6) contained in image:"); PrintScsiModePages.Print(decMode.Value, scsiDeviceType, scsiVendorId); DicConsole.WriteLine(); } } else if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_MODEPAGE_2A)) { byte[] mode2A = imageFormat.ReadDiskTag(MediaTagType.SCSI_MODEPAGE_2A); DicConsole.Write("{0}", Modes.PrettifyModePage_2A(mode2A)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_FullTOC)) { byte[] toc = imageFormat.ReadDiskTag(MediaTagType.CD_FullTOC); if (toc.Length > 0) { ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(toc, 0)); if (dataLen + 2 != toc.Length) { byte[] tmp = new byte[toc.Length + 2]; Array.Copy(toc, 0, tmp, 2, toc.Length); tmp[0] = (byte)((toc.Length & 0xFF00) >> 8); tmp[1] = (byte)(toc.Length & 0xFF); toc = tmp; } DicConsole.WriteLine("CompactDisc Table of Contents contained in image:"); DicConsole.Write("{0}", FullTOC.Prettify(toc)); DicConsole.WriteLine(); } } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_PMA)) { byte[] pma = imageFormat.ReadDiskTag(MediaTagType.CD_PMA); if (pma.Length > 0) { ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(pma, 0)); if (dataLen + 2 != pma.Length) { byte[] tmp = new byte[pma.Length + 2]; Array.Copy(pma, 0, tmp, 2, pma.Length); tmp[0] = (byte)((pma.Length & 0xFF00) >> 8); tmp[1] = (byte)(pma.Length & 0xFF); pma = tmp; } DicConsole.WriteLine("CompactDisc Power Management Area contained in image:"); DicConsole.Write("{0}", PMA.Prettify(pma)); DicConsole.WriteLine(); } } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_ATIP)) { byte[] atip = imageFormat.ReadDiskTag(MediaTagType.CD_ATIP); uint dataLen = Swapping.Swap(BitConverter.ToUInt32(atip, 0)); if (dataLen + 4 != atip.Length) { byte[] tmp = new byte[atip.Length + 4]; Array.Copy(atip, 0, tmp, 4, atip.Length); tmp[0] = (byte)((atip.Length & 0xFF000000) >> 24); tmp[1] = (byte)((atip.Length & 0xFF0000) >> 16); tmp[2] = (byte)((atip.Length & 0xFF00) >> 8); tmp[3] = (byte)(atip.Length & 0xFF); atip = tmp; } DicConsole.WriteLine("CompactDisc Absolute Time In Pregroove (ATIP) contained in image:"); DicConsole.Write("{0}", ATIP.Prettify(atip)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_TEXT)) { byte[] cdtext = imageFormat.ReadDiskTag(MediaTagType.CD_TEXT); uint dataLen = Swapping.Swap(BitConverter.ToUInt32(cdtext, 0)); if (dataLen + 4 != cdtext.Length) { byte[] tmp = new byte[cdtext.Length + 4]; Array.Copy(cdtext, 0, tmp, 4, cdtext.Length); tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24); tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16); tmp[2] = (byte)((cdtext.Length & 0xFF00) >> 8); tmp[3] = (byte)(cdtext.Length & 0xFF); cdtext = tmp; } DicConsole.WriteLine("CompactDisc Lead-in's CD-Text contained in image:"); DicConsole.Write("{0}", CDTextOnLeadIn.Prettify(cdtext)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) { byte[] mcn = imageFormat.ReadDiskTag(MediaTagType.CD_MCN); DicConsole.WriteLine("CompactDisc Media Catalogue Number contained in image: {0}", Encoding.UTF8.GetString(mcn)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.DVD_PFI)) { byte[] pfi = imageFormat.ReadDiskTag(MediaTagType.DVD_PFI); DicConsole.WriteLine("DVD Physical Format Information contained in image:"); DicConsole.Write("{0}", PFI.Prettify(pfi)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.DVDRAM_DDS)) { byte[] dds = imageFormat.ReadDiskTag(MediaTagType.DVDRAM_DDS); DicConsole.WriteLine("DVD-RAM Disc Definition Structure contained in image:"); DicConsole.Write("{0}", DDS.Prettify(dds)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.DVDR_PFI)) { byte[] pfi = imageFormat.ReadDiskTag(MediaTagType.DVDR_PFI); DicConsole.WriteLine("DVD-R Physical Format Information contained in image:"); DicConsole.Write("{0}", PFI.Prettify(pfi)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.BD_DI)) { byte[] di = imageFormat.ReadDiskTag(MediaTagType.BD_DI); DicConsole.WriteLine("Bluray Disc Information contained in image:"); DicConsole.Write("{0}", DI.Prettify(di)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.BD_DDS)) { byte[] dds = imageFormat.ReadDiskTag(MediaTagType.BD_DDS); DicConsole.WriteLine("Bluray Disc Definition Structure contained in image:"); DicConsole.Write("{0}", Decoders.Bluray.DDS.Prettify(dds)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS)) { byte[] cis = imageFormat.ReadDiskTag(MediaTagType.PCMCIA_CIS); DicConsole.WriteLine("PCMCIA CIS:"); Tuple[] tuples = CIS.GetTuples(cis); if (tuples != null) { foreach (Tuple tuple in tuples) { switch (tuple.Code) { case TupleCodes.CISTPL_NULL: case TupleCodes.CISTPL_END: break; case TupleCodes.CISTPL_DEVICEGEO: case TupleCodes.CISTPL_DEVICEGEO_A: DicConsole.WriteLine("{0}", CIS.PrettifyDeviceGeometryTuple(tuple)); break; case TupleCodes.CISTPL_MANFID: DicConsole.WriteLine("{0}", CIS.PrettifyManufacturerIdentificationTuple(tuple)); break; case TupleCodes.CISTPL_VERS_1: DicConsole.WriteLine("{0}", CIS.PrettifyLevel1VersionTuple(tuple)); break; case TupleCodes.CISTPL_ALTSTR: case TupleCodes.CISTPL_BAR: case TupleCodes.CISTPL_BATTERY: case TupleCodes.CISTPL_BYTEORDER: case TupleCodes.CISTPL_CFTABLE_ENTRY: case TupleCodes.CISTPL_CFTABLE_ENTRY_CB: case TupleCodes.CISTPL_CHECKSUM: case TupleCodes.CISTPL_CONFIG: case TupleCodes.CISTPL_CONFIG_CB: case TupleCodes.CISTPL_DATE: case TupleCodes.CISTPL_DEVICE: case TupleCodes.CISTPL_DEVICE_A: case TupleCodes.CISTPL_DEVICE_OA: case TupleCodes.CISTPL_DEVICE_OC: case TupleCodes.CISTPL_EXTDEVIC: case TupleCodes.CISTPL_FORMAT: case TupleCodes.CISTPL_FORMAT_A: case TupleCodes.CISTPL_FUNCE: case TupleCodes.CISTPL_FUNCID: case TupleCodes.CISTPL_GEOMETRY: case TupleCodes.CISTPL_INDIRECT: case TupleCodes.CISTPL_JEDEC_A: case TupleCodes.CISTPL_JEDEC_C: case TupleCodes.CISTPL_LINKTARGET: case TupleCodes.CISTPL_LONGLINK_A: case TupleCodes.CISTPL_LONGLINK_C: case TupleCodes.CISTPL_LONGLINK_CB: case TupleCodes.CISTPL_LONGLINK_MFC: case TupleCodes.CISTPL_NO_LINK: case TupleCodes.CISTPL_ORG: case TupleCodes.CISTPL_PWR_MGMNT: case TupleCodes.CISTPL_SPCL: case TupleCodes.CISTPL_SWIL: case TupleCodes.CISTPL_VERS_2: DicConsole.DebugWriteLine("Device-Info command", "Found undecoded tuple ID {0}", tuple.Code); break; default: DicConsole.DebugWriteLine("Device-Info command", "Found unknown tuple ID 0x{0:X2}", (byte)tuple.Code); break; } } } else { DicConsole.DebugWriteLine("Device-Info command", "Could not get tuples"); } } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_CID)) { byte[] cid = imageFormat.ReadDiskTag(MediaTagType.SD_CID); DicConsole.WriteLine("SecureDigital CID contained in image:"); DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCID(cid)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_CSD)) { byte[] csd = imageFormat.ReadDiskTag(MediaTagType.SD_CSD); DicConsole.WriteLine("SecureDigital CSD contained in image:"); DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCSD(csd)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_SCR)) { byte[] scr = imageFormat.ReadDiskTag(MediaTagType.SD_SCR); DicConsole.WriteLine("SecureDigital SCR contained in image:"); DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifySCR(scr)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_OCR)) { byte[] ocr = imageFormat.ReadDiskTag(MediaTagType.SD_OCR); DicConsole.WriteLine("SecureDigital OCR contained in image:"); DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyOCR(ocr)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_CID)) { byte[] cid = imageFormat.ReadDiskTag(MediaTagType.MMC_CID); DicConsole.WriteLine("MultiMediaCard CID contained in image:"); DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCID(cid)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_CSD)) { byte[] csd = imageFormat.ReadDiskTag(MediaTagType.MMC_CSD); DicConsole.WriteLine("MultiMediaCard CSD contained in image:"); DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCSD(csd)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_ExtendedCSD)) { byte[] ecsd = imageFormat.ReadDiskTag(MediaTagType.MMC_ExtendedCSD); DicConsole.WriteLine("MultiMediaCard ExtendedCSD contained in image:"); DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_OCR)) { byte[] ocr = imageFormat.ReadDiskTag(MediaTagType.MMC_OCR); DicConsole.WriteLine("MultiMediaCard OCR contained in image:"); DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyOCR(ocr)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.Xbox_PFI)) { byte[] xpfi = imageFormat.ReadDiskTag(MediaTagType.Xbox_PFI); DicConsole.WriteLine("Xbox Physical Format Information contained in image:"); DicConsole.Write("{0}", PFI.Prettify(xpfi)); DicConsole.WriteLine(); } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.Xbox_DMI)) { byte[] xdmi = imageFormat.ReadDiskTag(MediaTagType.Xbox_DMI); if (DMI.IsXbox(xdmi)) { DMI.XboxDMI?xmi = DMI.DecodeXbox(xdmi); if (xmi.HasValue) { DicConsole.WriteLine("Xbox DMI contained in image:"); DicConsole.Write("{0}", DMI.PrettifyXbox(xmi)); DicConsole.WriteLine(); } } if (DMI.IsXbox360(xdmi)) { DMI.Xbox360DMI?xmi = DMI.DecodeXbox360(xdmi); if (xmi.HasValue) { DicConsole.WriteLine("Xbox 360 DMI contained in image:"); DicConsole.Write("{0}", DMI.PrettifyXbox360(xmi)); DicConsole.WriteLine(); } } } if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.Xbox_SecuritySector)) { byte[] toc = imageFormat.ReadDiskTag(MediaTagType.Xbox_SecuritySector); DicConsole.WriteLine("Xbox Security Sectors contained in image:"); DicConsole.Write("{0}", SS.Prettify(toc)); DicConsole.WriteLine(); } if (imageFormat is IOpticalMediaImage opticalImage) { try { if (opticalImage.Sessions != null && opticalImage.Sessions.Count > 0) { DicConsole.WriteLine("Image sessions:"); DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", "Session", "First track", "Last track", "Start", "End"); DicConsole.WriteLine("========================================================="); foreach (Session session in opticalImage.Sessions) { DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", session.SessionSequence, session.StartTrack, session.EndTrack, session.StartSector, session.EndSector); } DicConsole.WriteLine(); } } catch { // ignored } try { if (opticalImage.Tracks != null && opticalImage.Tracks.Count > 0) { DicConsole.WriteLine("Image tracks:"); DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}", "Track", "Type", "Bps", "Raw bps", "Subchannel", "Pregap", "Start", "End"); DicConsole .WriteLine("================================================================================="); foreach (Track track in opticalImage.Tracks) { DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}", track.TrackSequence, track.TrackType, track.TrackBytesPerSector, track.TrackRawBytesPerSector, track.TrackSubchannelType, track.TrackPregap, track.TrackStartSector, track.TrackEndSector); } DicConsole.WriteLine(); } } catch { // ignored } } if (imageFormat.DumpHardware == null) { return; } const string MANUFACTURER_STRING = "Manufacturer"; const string MODEL_STRING = "Model"; const string SERIAL_STRING = "Serial"; const string SOFTWARE_STRING = "Software"; const string VERSION_STRING = "Version"; const string OS_STRING = "Operating system"; const string START_STRING = "Start"; const string END_STRING = "End"; int manufacturerLen = MANUFACTURER_STRING.Length; int modelLen = MODEL_STRING.Length; int serialLen = SERIAL_STRING.Length; int softwareLen = SOFTWARE_STRING.Length; int versionLen = VERSION_STRING.Length; int osLen = OS_STRING.Length; int sectorLen = START_STRING.Length; foreach (DumpHardwareType dump in imageFormat.DumpHardware) { if (dump.Manufacturer?.Length > manufacturerLen) { manufacturerLen = dump.Manufacturer.Length; } if (dump.Model?.Length > modelLen) { modelLen = dump.Model.Length; } if (dump.Serial?.Length > serialLen) { serialLen = dump.Serial.Length; } if (dump.Software?.Name?.Length > softwareLen) { softwareLen = dump.Software.Name.Length; } if (dump.Software?.Version?.Length > versionLen) { versionLen = dump.Software.Version.Length; } if (dump.Software?.OperatingSystem?.Length > osLen) { osLen = dump.Software.OperatingSystem.Length; } foreach (ExtentType extent in dump.Extents) { if ($"{extent.Start}".Length > sectorLen) { sectorLen = $"{extent.Start}".Length; } if ($"{extent.End}".Length > sectorLen) { sectorLen = $"{extent.End}".Length; } } } manufacturerLen += 2; modelLen += 2; serialLen += 2; softwareLen += 2; versionLen += 2; osLen += 2; sectorLen += 2; sectorLen += 2; char[] separator = new char[manufacturerLen + modelLen + serialLen + softwareLen + versionLen + osLen + sectorLen + sectorLen]; for (int i = 0; i < separator.Length; i++) { separator[i] = '='; } string format = $"{{0,-{manufacturerLen}}}{{1,-{modelLen}}}{{2,-{serialLen}}}{{3,-{softwareLen}}}{{4,-{versionLen}}}{{5,-{osLen}}}{{6,-{sectorLen}}}{{7,-{sectorLen}}}"; DicConsole.WriteLine("Dump hardware information:"); DicConsole.WriteLine(format, MANUFACTURER_STRING, MODEL_STRING, SERIAL_STRING, SOFTWARE_STRING, VERSION_STRING, OS_STRING, START_STRING, END_STRING); DicConsole.WriteLine(new string(separator)); foreach (DumpHardwareType dump in imageFormat.DumpHardware) { foreach (ExtentType extent in dump.Extents) { DicConsole.WriteLine(format, dump.Manufacturer, dump.Model, dump.Serial, dump.Software.Name, dump.Software.Version, dump.Software.OperatingSystem, extent.Start, extent.End); } } DicConsole.WriteLine(); }
/// <summary>Gets a list of all known storage devices on FreeBSD</summary> /// <returns>List of devices</returns> internal static DeviceInfo[] GetList() { string[] passDevices = Directory.GetFiles("/dev/", "pass*", SearchOption.TopDirectoryOnly); List <DeviceInfo> listDevices = new List <DeviceInfo>(); foreach (string passDevice in passDevices) { var deviceInfo = new DeviceInfo(); IntPtr dev = cam_open_device(passDevice, FileFlags.ReadWrite); var camDevice = (CamDevice)Marshal.PtrToStructure(dev, typeof(CamDevice)); IntPtr ccbPtr = cam_getccb(dev); if (ccbPtr.ToInt64() == 0) { continue; } var cgd = (CcbGetdev)Marshal.PtrToStructure(ccbPtr, typeof(CcbGetdev)); cgd.ccb_h.func_code = XptOpcode.XptGdevType; Marshal.StructureToPtr(cgd, ccbPtr, false); int error = cam_send_ccb(dev, ccbPtr); if (error < 0) { cam_freeccb(ccbPtr); continue; } cgd = (CcbGetdev)Marshal.PtrToStructure(ccbPtr, typeof(CcbGetdev)); cam_freeccb(ccbPtr); cam_close_device(dev); string simName = StringHandlers.CToString(camDevice.SimName); deviceInfo.Path = passDevice; byte[] serialNumber = new byte[camDevice.SerialNumLen]; Array.Copy(camDevice.SerialNum, 0, serialNumber, 0, serialNumber.Length); deviceInfo.Serial = StringHandlers.CToString(serialNumber); switch (cgd.protocol) { case CamProto.ProtoAta: case CamProto.ProtoAtapi: case CamProto.ProtoSatapm: { // Little-endian FreeBSD gives it resorted // Big-endian FreeBSD, no idea byte[] atadTneid = new byte[512]; for (int aIndex = 0; aIndex < 512; aIndex += 2) { atadTneid[aIndex] = cgd.ident_data[aIndex + 1]; atadTneid[aIndex + 1] = cgd.ident_data[aIndex]; } Identify.IdentifyDevice?idt = Identify.Decode(atadTneid); if (idt.HasValue) { string[] separated = idt.Value.Model.Split(' '); if (separated.Length == 1) { deviceInfo.Vendor = "ATA"; deviceInfo.Model = separated[0]; } else { deviceInfo.Vendor = separated[0]; deviceInfo.Model = separated[separated.Length - 1]; } deviceInfo.Serial = idt.Value.SerialNumber; deviceInfo.Bus = simName == "ahcich" ? "SATA" : "ATA"; deviceInfo.Supported = simName != "ata"; } if (cgd.protocol == CamProto.ProtoAtapi) { goto case CamProto.ProtoScsi; } break; } case CamProto.ProtoScsi: { Inquiry?inq = Inquiry.Decode(cgd.inq_data); if (inq.HasValue) { deviceInfo.Vendor = StringHandlers.CToString(inq.Value.VendorIdentification).Trim(); deviceInfo.Model = StringHandlers.CToString(inq.Value.ProductIdentification).Trim(); deviceInfo.Bus = simName == "ata" || simName == "ahcich" ? "ATAPI" : "SCSI"; deviceInfo.Supported = simName != "ata"; } break; } case CamProto.ProtoNvme: deviceInfo.Bus = "NVMe"; deviceInfo.Supported = false; break; case CamProto.ProtoMmcsd: deviceInfo.Model = "Unknown card"; deviceInfo.Bus = "MMC/SD"; deviceInfo.Supported = false; break; } listDevices.Add(deviceInfo); } return(listDevices.Count > 0 ? listDevices.OrderBy(t => t.Path).ToArray() : null); }
public void VisitElementB(Inquiry elemB) { throw new NotImplementedException(); }
[ValidateAntiForgeryToken] //protect against CSRF attacks public async Task <IActionResult> Kontakt(Inquiry inquiry) { var userAgent = Request.Headers["User-Agent"].ToString(); // OPTIONAL: Set version truncation to none, so full versions will be returned // By default only minor versions will be returned (e.g. X.Y) // for other options see VERSION_TRUNCATION_* constants in DeviceParserAbstract class // add using DeviceDetectorNET.Parser; DeviceDetector.SetVersionTruncation(VersionTruncation.VERSION_TRUNCATION_NONE); var dd = new DeviceDetector(userAgent); // OPTIONAL: Set caching method // By default static cache is used, which works best within one php process (memory array caching) // To cache across requests use caching in files or memcache // add using DeviceDetectorNET.Cache; dd.SetCache(new DictionaryCache()); // OPTIONAL: If called, GetBot() will only return true if a bot was detected (speeds up detection a bit) dd.DiscardBotInformation(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) dd.SkipBotDetection(); dd.Parse(); if (dd.IsBot()) { // handle bots,spiders,crawlers,... var botInfo = dd.GetBot(); inquiry.Browser = "BOT"; inquiry.OperatingSystem = "BOT"; inquiry.Device = "BOT"; inquiry.Brand = "BOT"; inquiry.Model = "BOT"; } else { var clientInfo = dd.GetClient(); // holds information about browser, feed reader, media player, ... var osInfo = dd.GetOs(); var device = dd.GetDeviceName(); var brand = dd.GetBrandName(); var model = dd.GetModel(); inquiry.Browser = $"{clientInfo.Match.Name} ({clientInfo.Match.Version})"; inquiry.OperatingSystem = $"{osInfo.Match.Name} ({osInfo.Match.Version}) {osInfo.Match.Platform}"; var deviceResult = device == "" ? inquiry.Device = "N/A" : inquiry.Device = device; var brandResult = brand == "" ? inquiry.Brand = "N/A" : inquiry.Brand = brand; var modelResult = model == "" ? inquiry.Model = "N/A" : inquiry.Model = model; } //local Environment //OperatingSystem os = Environment.OSVersion; //var platform = os.Platform.ToString(); //var version = os.Version.ToString(); //var servicePack = os.ServicePack.ToString(); var remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString(); inquiry.IpAddress = remoteIpAddress; inquiry.CreatedDate = DateTime.Now; inquiry.Status = "New"; inquiry.HoursSpend = 0; inquiry.HourPrice = 400; inquiry.InvoiceNo = "N/A"; inquiry.Payment = "N/A"; if (ModelState.IsValid) { var inquiryId = await contex.Inquiries.FirstOrDefaultAsync(x => x.Id == inquiry.Id); if (inquiryId != null) { ModelState.AddModelError("", "Nastapil bland, ponow wpis."); return(View()); } //string attachmentName = "noimagecar.png"; //if (inquiry.AttachmentUpload != null) //{ // string uploadsDir = Path.Combine(webHostEnvironment.WebRootPath, "media/cars"); // attachmentName = Guid.NewGuid().ToString() + "_" + inquiry.AttachmentUpload.FileName; // string filePath = Path.Combine(uploadsDir, attachmentName); // FileStream fs = new FileStream(filePath, FileMode.Create); // await inquiry.AttachmentUpload.CopyToAsync(fs); // fs.Close(); //} //inquiry.Attachment = attachmentName; contex.Add(inquiry); await contex.SaveChangesAsync(); TempData["Success"] = "Wiadomosc zostala wyslana!"; return(RedirectToAction("Kontakt")); } return(View()); }
public object CreateFilter(Inquiry inquiry) { return(Activator.CreateInstance((Type)inquiry.Key)); }
public void VisitElementA(Inquiry elemA) { }
public IHttpActionResult ApproveDenyInquiryFromMyGroup([FromUri] int groupTypeId, [FromUri] int groupId, [FromUri] bool approve, [FromBody] Inquiry inquiry) { return(Authorized(token => { try { _groupToolService.ApproveDenyInquiryFromMyGroup(token, groupId, approve, inquiry, inquiry.Message, _defaultRoleId); return Ok(); } catch (GroupParticipantRemovalException e) { var apiError = new ApiErrorDto(e.Message, null, e.StatusCode); throw new HttpResponseException(apiError.HttpResponseMessage); } catch (Exception ex) { var apiError = new ApiErrorDto(string.Format("Error {0} group inquiry {1} from group {2}", approve, inquiry.InquiryId, groupId), ex); throw new HttpResponseException(apiError.HttpResponseMessage); } })); }
/// <summary> /// 特指问+值已定 /// </summary> /// <param name="userSession"></param> /// <param name="input">有什么三星手机是2000块以下的?</param> /// <param name="info">品牌:三星;价钱:[0,2000],块</param> /// <returns></returns> public string Process(Areas.Chat.Models.UserSession userSession, string input, Extracting.ValidInfo info) { /* 分析: * 当手机型号被显式提出的情况一般在这里不会出现 *--值已定 * --明确提出主语 * --没提出主语 * --有当前讨论的手机 * --没有当前讨论的手机 * --有候选手机 * --没有候选手机 * */ //用户希望系统根据当前句的语义和之前的收集的信息立即推荐一款手机 eg:能给我推荐一款三星手机吗? if (Regex.IsMatch(input, @"推荐")) { userSession.liveTable.Candidates = Inquiry.Screening(userSession.liveTable.Parameter, info); if (userSession.liveTable.Candidates.Count == 0) { return(Answering.NotFound(userSession, info)); } else { // 目前能对多个值已定的属性进行手机推荐 userSession.liveTable.TalkingAbout = userSession.liveTable.Candidates[0]; userSession.liveTable.Candidates.Remove(userSession.liveTable.TalkingAbout); userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.RECOMMEND; return(userSession.liveTable.TalkingAbout.Brand + userSession.liveTable.TalkingAbout.Model + "这款不错,你可以了解一下。"); } } bool isDirect = false; List <Models.CellPhone> list = new List <Models.CellPhone>(); foreach (var it in info.items) { if (String.IsNullOrEmpty(info.conflictFeedback) && it.name.Equals("型号")) { if (it.items.Count > 0) { isDirect = true; } break; } } if (!isDirect) { if (userSession.liveTable.Candidates.Count > 0) { list = Inquiry.MiniScreening(userSession.liveTable.Candidates, userSession.liveTable.Parameter, info); userSession.liveTable.Candidates = list; } if (list.Count == 0) { // 查询数据库,返回手机列表list //####################这里的候选手机列表替换方式不是很妥当, 需要改 list = Inquiry.Screening(userSession.liveTable.Parameter, info); userSession.liveTable.Candidates = list; } if (list.Count > 3) { /* 如果筛选结果大于三款(且重要属性只有4个以下被确认),则进行主动引导 * 首先要先确定要引导的参数 * 然后还要记录当前状态变成主动引导 * 以及记录相关参数到live-table的RelativeParameter * */ //string answear = "符合您要求的手机有以下几款:"; //for (int i = 0; i < 2; ++i) //{ // answear = answear + list[i].Model + "、"; //} //answear = answear + list[2].Model + "等。"; int recordedImportantParameter = 0; //如果重要属性已有4个以上被确认,直接进行推荐,不继续引导 foreach (string s in Code.GlobalHash.ImportantParameter) { if (recordedImportantParameter >= 4) { userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.RECOMMEND; userSession.liveTable.TalkingAbout = list[0]; return(Answering.Recommand(list[0])); } if (!userSession.liveTable.Parameter.ContainsKey(s)) { userSession.liveTable.RelatedParameter = s; userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.ACTIVE; return(Answering.ActiveLeading(s)); } else { recordedImportantParameter++; } } } else if (list.Count <= 0) { return(Answering.NotFound(userSession, info)); // 状态CurrentMode在该方法中变更 } else { userSession.liveTable.CurrentMode = Areas.Chat.Models.LiveTable.ModeType.RECOMMEND; userSession.liveTable.TalkingAbout = list[0]; return(Answering.Recommand(list[0])); } } else { string answer = ""; List <string> ps = new List <string>(); list = Inquiry.Screening(userSession.liveTable.Parameter, info); if (list.Count <= 0) { if (info.items.Count < 2) { answer = "亲,不好意思," + "没有" + info.items[0].items[0].rawData; return(answer); } else { answer = "亲,不好意思," + "我们还没收录您提到的这个型号,我们正在努力更新数据~~"; return(answer); } } else { for (int i = 0; i < info.items.Count; i++) { ps.Add(info.items[i].name); } return(Answering.Statement(list[0], ps)); } } return(""); }
public ActionResult Save(Inquiry inquiry) { _repo.SaveInquiry(inquiry); return(RedirectToAction("Index")); }
public void Initialize() { this.inquiry = TestHelper.DefaultInquiry(out _sid, out _orderNum); this.inquiry.SetNoPayment(); }
public void success() { Inquiry inquiry = Inquiry.find(6); Assert.IsNotNull(inquiry); }
/// <summary> /// Opens the device for sending direct commands /// </summary> /// <param name="devicePath">Device path</param> public Device(string devicePath) { PlatformId = DetectOS.GetRealPlatformID(); Timeout = 15; Error = false; IsRemovable = false; switch (PlatformId) { case PlatformID.Win32NT: { FileHandle = Extern.CreateFile(devicePath, FileAccess.GenericRead | FileAccess.GenericWrite, FileShare.Read | FileShare.Write, IntPtr.Zero, FileMode.OpenExisting, FileAttributes.Normal, IntPtr.Zero); if (((SafeFileHandle)FileHandle).IsInvalid) { Error = true; LastError = Marshal.GetLastWin32Error(); } break; } case PlatformID.Linux: { FileHandle = Linux.Extern.open(devicePath, FileFlags.ReadWrite | FileFlags.NonBlocking | FileFlags.CreateNew); if ((int)FileHandle < 0) { LastError = Marshal.GetLastWin32Error(); if (LastError == 13) // EACCES { FileHandle = Linux.Extern.open(devicePath, FileFlags.Readonly | FileFlags.NonBlocking); if ((int)FileHandle < 0) { Error = true; LastError = Marshal.GetLastWin32Error(); } } else { Error = true; } LastError = Marshal.GetLastWin32Error(); } break; } case PlatformID.FreeBSD: { FileHandle = FreeBSD.Extern.cam_open_device(devicePath, FreeBSD.FileFlags.ReadWrite); if (((IntPtr)FileHandle).ToInt64() == 0) { Error = true; LastError = Marshal.GetLastWin32Error(); } CamDevice camDevice = (CamDevice)Marshal.PtrToStructure((IntPtr)FileHandle, typeof(CamDevice)); if (StringHandlers.CToString(camDevice.SimName) == "ata") { throw new InvalidOperationException("Parallel ATA devices are not supported on FreeBSD due to upstream bug #224250."); } break; } default: throw new InvalidOperationException($"Platform {PlatformId} not yet supported."); } if (Error) { throw new SystemException($"Error {LastError} opening device."); } Type = DeviceType.Unknown; ScsiType = PeripheralDeviceTypes.UnknownDevice; byte[] ataBuf; byte[] inqBuf = null; if (Error) { throw new SystemException($"Error {LastError} trying device."); } bool scsiSense = true; // Windows is answering SCSI INQUIRY for all device types so it needs to be detected first switch (PlatformId) { case PlatformID.Win32NT: StoragePropertyQuery query = new StoragePropertyQuery(); query.PropertyId = StoragePropertyId.Device; query.QueryType = StorageQueryType.Standard; query.AdditionalParameters = new byte[1]; IntPtr descriptorPtr = Marshal.AllocHGlobal(1000); byte[] descriptorB = new byte[1000]; uint returned = 0; int error = 0; bool hasError = !Extern.DeviceIoControlStorageQuery((SafeFileHandle)FileHandle, WindowsIoctl.IoctlStorageQueryProperty, ref query, (uint)Marshal.SizeOf(query), descriptorPtr, 1000, ref returned, IntPtr.Zero); if (hasError) { error = Marshal.GetLastWin32Error(); } Marshal.Copy(descriptorPtr, descriptorB, 0, 1000); if (!hasError && error == 0) { StorageDeviceDescriptor descriptor = new StorageDeviceDescriptor { Version = BitConverter.ToUInt32(descriptorB, 0), Size = BitConverter.ToUInt32(descriptorB, 4), DeviceType = descriptorB[8], DeviceTypeModifier = descriptorB[9], RemovableMedia = descriptorB[10] > 0, CommandQueueing = descriptorB[11] > 0, VendorIdOffset = BitConverter.ToInt32(descriptorB, 12), ProductIdOffset = BitConverter.ToInt32(descriptorB, 16), ProductRevisionOffset = BitConverter.ToInt32(descriptorB, 20), SerialNumberOffset = BitConverter.ToInt32(descriptorB, 24), BusType = (StorageBusType)BitConverter.ToUInt32(descriptorB, 28), RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32) }; descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength]; Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength); switch (descriptor.BusType) { case StorageBusType.SCSI: case StorageBusType.SSA: case StorageBusType.Fibre: case StorageBusType.iSCSI: case StorageBusType.SAS: Type = DeviceType.SCSI; break; case StorageBusType.FireWire: IsFireWire = true; Type = DeviceType.SCSI; break; case StorageBusType.USB: IsUsb = true; Type = DeviceType.SCSI; break; case StorageBusType.ATAPI: Type = DeviceType.ATAPI; break; case StorageBusType.ATA: case StorageBusType.SATA: Type = DeviceType.ATA; break; case StorageBusType.MultiMediaCard: Type = DeviceType.MMC; break; case StorageBusType.SecureDigital: Type = DeviceType.SecureDigital; break; case StorageBusType.NVMe: Type = DeviceType.NVMe; break; } switch (Type) { case DeviceType.SCSI: case DeviceType.ATAPI: scsiSense = ScsiInquiry(out inqBuf, out _); break; case DeviceType.ATA: bool atapiSense = AtapiIdentify(out ataBuf, out _); if (!atapiSense) { Type = DeviceType.ATAPI; Identify.IdentifyDevice?ataid = Identify.Decode(ataBuf); if (ataid.HasValue) { scsiSense = ScsiInquiry(out inqBuf, out _); } } else { Manufacturer = "ATA"; } break; } } string ntDevicePath = Windows.Command.GetDevicePath((SafeFileHandle)FileHandle); DicConsole.DebugWriteLine("Windows devices", "NT device path: {0}", ntDevicePath); Marshal.FreeHGlobal(descriptorPtr); if (Windows.Command.IsSdhci((SafeFileHandle)FileHandle)) { byte[] sdBuffer = new byte[16]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCsd, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _, out _, out bool sense); if (!sense) { cachedCsd = new byte[16]; Array.Copy(sdBuffer, 0, cachedCsd, 0, 16); } sdBuffer = new byte[16]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCid, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _, out _, out sense); if (!sense) { cachedCid = new byte[16]; Array.Copy(sdBuffer, 0, cachedCid, 0, 16); } sdBuffer = new byte[8]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, (MmcCommands)SecureDigitalCommands.SendScr, false, true, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer, out _, out _, out sense); if (!sense) { cachedScr = new byte[8]; Array.Copy(sdBuffer, 0, cachedScr, 0, 8); } if (cachedScr != null) { sdBuffer = new byte[4]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, (MmcCommands)SecureDigitalCommands .SendOperatingCondition, false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer, out _, out _, out sense); if (!sense) { cachedScr = new byte[4]; Array.Copy(sdBuffer, 0, cachedScr, 0, 4); } } else { sdBuffer = new byte[4]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendOpCond, false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer, out _, out _, out sense); if (!sense) { cachedScr = new byte[4]; Array.Copy(sdBuffer, 0, cachedScr, 0, 4); } } } break; case PlatformID.Linux: if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || devicePath.StartsWith("/dev/st", StringComparison.Ordinal)) { scsiSense = ScsiInquiry(out inqBuf, out _); } // MultiMediaCard and SecureDigital go here else if (devicePath.StartsWith("/dev/mmcblk", StringComparison.Ordinal)) { string devPath = devicePath.Substring(5); if (File.Exists("/sys/block/" + devPath + "/device/csd")) { int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/csd", out cachedCsd); if (len == 0) { cachedCsd = null; } } if (File.Exists("/sys/block/" + devPath + "/device/cid")) { int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/cid", out cachedCid); if (len == 0) { cachedCid = null; } } if (File.Exists("/sys/block/" + devPath + "/device/scr")) { int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/scr", out cachedScr); if (len == 0) { cachedScr = null; } } if (File.Exists("/sys/block/" + devPath + "/device/ocr")) { int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/ocr", out cachedOcr); if (len == 0) { cachedOcr = null; } } } break; default: scsiSense = ScsiInquiry(out inqBuf, out _); break; } #region SecureDigital / MultiMediaCard if (cachedCid != null) { ScsiType = PeripheralDeviceTypes.DirectAccess; IsRemovable = false; if (cachedScr != null) { Type = DeviceType.SecureDigital; CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(cachedCid); Manufacturer = VendorString.Prettify(decoded.Manufacturer); Model = decoded.ProductName; Revision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; Serial = $"{decoded.ProductSerialNumber}"; } else { Type = DeviceType.MMC; Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(cachedCid); Manufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); Model = decoded.ProductName; Revision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; Serial = $"{decoded.ProductSerialNumber}"; } } #endregion SecureDigital / MultiMediaCard #region USB switch (PlatformId) { case PlatformID.Linux: if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || devicePath.StartsWith("/dev/st", StringComparison.Ordinal)) { string devPath = devicePath.Substring(5); if (Directory.Exists("/sys/block/" + devPath)) { string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath); resolvedLink = "/sys" + resolvedLink.Substring(2); if (!string.IsNullOrEmpty(resolvedLink)) { while (resolvedLink.Contains("usb")) { resolvedLink = Path.GetDirectoryName(resolvedLink); if (!File.Exists(resolvedLink + "/descriptors") || !File.Exists(resolvedLink + "/idProduct") || !File.Exists(resolvedLink + "/idVendor")) { continue; } FileStream usbFs = new FileStream(resolvedLink + "/descriptors", System.IO.FileMode.Open, System.IO.FileAccess.Read); byte[] usbBuf = new byte[65536]; int usbCount = usbFs.Read(usbBuf, 0, 65536); UsbDescriptors = new byte[usbCount]; Array.Copy(usbBuf, 0, UsbDescriptors, 0, usbCount); usbFs.Close(); StreamReader usbSr = new StreamReader(resolvedLink + "/idProduct"); string usbTemp = usbSr.ReadToEnd(); ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out usbProduct); usbSr.Close(); usbSr = new StreamReader(resolvedLink + "/idVendor"); usbTemp = usbSr.ReadToEnd(); ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out usbVendor); usbSr.Close(); if (File.Exists(resolvedLink + "/manufacturer")) { usbSr = new StreamReader(resolvedLink + "/manufacturer"); UsbManufacturerString = usbSr.ReadToEnd().Trim(); usbSr.Close(); } if (File.Exists(resolvedLink + "/product")) { usbSr = new StreamReader(resolvedLink + "/product"); UsbProductString = usbSr.ReadToEnd().Trim(); usbSr.Close(); } if (File.Exists(resolvedLink + "/serial")) { usbSr = new StreamReader(resolvedLink + "/serial"); UsbSerialString = usbSr.ReadToEnd().Trim(); usbSr.Close(); } IsUsb = true; break; } } } } break; case PlatformID.Win32NT: Usb.UsbDevice usbDevice = null; // I have to search for USB disks, floppies and CD-ROMs as separate device types foreach (string devGuid in new[] { Usb.GuidDevinterfaceFloppy, Usb.GuidDevinterfaceCdrom, Usb.GuidDevinterfaceDisk }) { usbDevice = Usb.FindDrivePath(devicePath, devGuid); if (usbDevice != null) { break; } } if (usbDevice != null) { UsbDescriptors = usbDevice.BinaryDescriptors; usbVendor = (ushort)usbDevice.DeviceDescriptor.idVendor; usbProduct = (ushort)usbDevice.DeviceDescriptor.idProduct; UsbManufacturerString = usbDevice.Manufacturer; UsbProductString = usbDevice.Product; UsbSerialString = usbDevice.SerialNumber; // This is incorrect filled by Windows with SCSI/ATA serial number } break; default: IsUsb = false; break; } #endregion USB #region FireWire if (PlatformId == PlatformID.Linux) { if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || devicePath.StartsWith("/dev/st", StringComparison.Ordinal)) { string devPath = devicePath.Substring(5); if (Directory.Exists("/sys/block/" + devPath)) { string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath); resolvedLink = "/sys" + resolvedLink.Substring(2); if (!string.IsNullOrEmpty(resolvedLink)) { while (resolvedLink.Contains("firewire")) { resolvedLink = Path.GetDirectoryName(resolvedLink); if (!File.Exists(resolvedLink + "/model") || !File.Exists(resolvedLink + "/vendor") || !File.Exists(resolvedLink + "/guid")) { continue; } StreamReader fwSr = new StreamReader(resolvedLink + "/model"); string fwTemp = fwSr.ReadToEnd(); uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out firewireModel); fwSr.Close(); fwSr = new StreamReader(resolvedLink + "/vendor"); fwTemp = fwSr.ReadToEnd(); uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out firewireVendor); fwSr.Close(); fwSr = new StreamReader(resolvedLink + "/guid"); fwTemp = fwSr.ReadToEnd(); ulong.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out firewireGuid); fwSr.Close(); if (File.Exists(resolvedLink + "/model_name")) { fwSr = new StreamReader(resolvedLink + "/model_name"); FireWireModelName = fwSr.ReadToEnd().Trim(); fwSr.Close(); } if (File.Exists(resolvedLink + "/vendor_name")) { fwSr = new StreamReader(resolvedLink + "/vendor_name"); FireWireVendorName = fwSr.ReadToEnd().Trim(); fwSr.Close(); } IsFireWire = true; break; } } } } } // TODO: Implement for other operating systems else { IsFireWire = false; } #endregion FireWire #region PCMCIA if (PlatformId == PlatformID.Linux) { if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || devicePath.StartsWith("/dev/st", StringComparison.Ordinal)) { string devPath = devicePath.Substring(5); if (Directory.Exists("/sys/block/" + devPath)) { string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath); resolvedLink = "/sys" + resolvedLink.Substring(2); if (!string.IsNullOrEmpty(resolvedLink)) { while (resolvedLink.Contains("/sys/devices")) { resolvedLink = Path.GetDirectoryName(resolvedLink); if (!Directory.Exists(resolvedLink + "/pcmcia_socket")) { continue; } string[] subdirs = Directory.GetDirectories(resolvedLink + "/pcmcia_socket", "pcmcia_socket*", SearchOption.TopDirectoryOnly); if (subdirs.Length <= 0) { continue; } string possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]); if (!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis")) { continue; } FileStream cisFs = new FileStream(possibleDir + "/cis", System.IO.FileMode.Open, System.IO.FileAccess.Read); byte[] cisBuf = new byte[65536]; int cisCount = cisFs.Read(cisBuf, 0, 65536); Cis = new byte[cisCount]; Array.Copy(cisBuf, 0, Cis, 0, cisCount); cisFs.Close(); IsPcmcia = true; break; } } } } } // TODO: Implement for other operating systems else { IsPcmcia = false; } #endregion PCMCIA if (!scsiSense) { Inquiry.SCSIInquiry?inquiry = Inquiry.Decode(inqBuf); Type = DeviceType.SCSI; bool serialSense = ScsiInquiry(out inqBuf, out _, 0x80); if (!serialSense) { Serial = EVPD.DecodePage80(inqBuf); } if (inquiry.HasValue) { string tmp = StringHandlers.CToString(inquiry.Value.ProductRevisionLevel); if (tmp != null) { Revision = tmp.Trim(); } tmp = StringHandlers.CToString(inquiry.Value.ProductIdentification); if (tmp != null) { Model = tmp.Trim(); } tmp = StringHandlers.CToString(inquiry.Value.VendorIdentification); if (tmp != null) { Manufacturer = tmp.Trim(); } IsRemovable = inquiry.Value.RMB; ScsiType = (PeripheralDeviceTypes)inquiry.Value.PeripheralDeviceType; } bool atapiSense = AtapiIdentify(out ataBuf, out _); if (!atapiSense) { Type = DeviceType.ATAPI; Identify.IdentifyDevice?ataId = Identify.Decode(ataBuf); if (ataId.HasValue) { Serial = ataId.Value.SerialNumber; } } LastError = 0; Error = false; } if (scsiSense && (IsUsb || IsFireWire) || Manufacturer == "ATA") { bool ataSense = AtaIdentify(out ataBuf, out _); if (!ataSense) { Type = DeviceType.ATA; Identify.IdentifyDevice?ataid = Identify.Decode(ataBuf); if (ataid.HasValue) { string[] separated = ataid.Value.Model.Split(' '); if (separated.Length == 1) { Model = separated[0]; } else { Manufacturer = separated[0]; Model = separated[separated.Length - 1]; } Revision = ataid.Value.FirmwareRevision; Serial = ataid.Value.SerialNumber; ScsiType = PeripheralDeviceTypes.DirectAccess; if ((ushort)ataid.Value.GeneralConfiguration != 0x848A) { IsRemovable |= (ataid.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) == Identify.GeneralConfigurationBit.Removable; } else { IsCompactFlash = true; } } } } if (Type == DeviceType.Unknown) { Manufacturer = null; Model = null; Revision = null; Serial = null; } if (IsUsb) { if (string.IsNullOrEmpty(Manufacturer)) { Manufacturer = UsbManufacturerString; } if (string.IsNullOrEmpty(Model)) { Model = UsbProductString; } if (string.IsNullOrEmpty(Serial)) { Serial = UsbSerialString; } else { foreach (char c in Serial.Where(char.IsControl)) { Serial = UsbSerialString; } } } if (!IsFireWire) { return; } if (string.IsNullOrEmpty(Manufacturer)) { Manufacturer = FireWireVendorName; } if (string.IsNullOrEmpty(Model)) { Model = FireWireModelName; } if (string.IsNullOrEmpty(Serial)) { Serial = $"{firewireGuid:X16}"; } else { foreach (char c in Serial.Where(char.IsControl)) { Serial = $"{firewireGuid:X16}"; } } }
public int insertStudentInquiry(Inquiry inquiry) { return(gfo.insertInquiry(inquiry)); }
public void RisWTwoKCRulesReview() { Inquiry inquiry = TestHelper.CreateInquiry(PTOK, out _sid, out _orderNum); inquiry.SetMode(InquiryTypes.ModeW); inquiry.SetTotal(10001); inquiry.SetKountCentralCustomerId("KCentralCustomerOne"); // set CART with one item var cart = new ArrayList(); cart.Add(new CartItem("cart item 0 type", "cart item 0", "cart item 0 description", 10, 1234)); inquiry.SetCart(cart); Response response = inquiry.GetResponse(); var sessID = response.GetSessionId(); var tranID = response.GetTransactionId(); var ordNum = response.GetOrderNumber(); var errors = response.GetErrors(); Assert.True(errors.Count == 0, String.Join(Environment.NewLine, errors, "There are errors in response!")); var mode = response.GetMode(); Assert.True("W".Equals(mode), $"Update failed! Wrong response mode {mode}."); var warnings = response.GetWarnings(); Assert.True(warnings.Count == 0, String.Join(Environment.NewLine, warnings, "There are warnings in response!")); /* * "KC_TRIGGERED_COUNT": 2 * "KC_WARNING_COUNT": 0 * "KC_DECISION": "R" * "KC_EVENT_1_CODE": "billingToShippingAddressReview" * "KC_EVENT_1_DECISION": "R" * "KC_EVENT_2_CODE": "orderTotalReview" * "KC_EVENT_2_DECISION": "R" */ var kcCustId = response.GetKountCentralCustomerId(); var kcDecision = response.GetKountCentralDecision(); Assert.True("R".Equals(kcDecision), $"Inquiry failed! KC Decision {kcDecision} is not equal to R"); var kcErrs = response.GetKountCentralErrors(); Assert.True(kcErrs.Count == 0, $"Inquiry failed! KC Errors: {String.Join(Environment.NewLine, kcErrs)}"); var kcWarn = response.GetKountCentralWarnings(); Assert.True(kcWarn.Count == 0, $"Inquiry failed! KC Warnings: {String.Join(Environment.NewLine, kcWarn)}"); var kcEvents = response.GetKountCentralThresholdEvents(); Assert.True(kcEvents.Count == 2, $"Inquiry failed! KC Events: {kcEvents.Count} are not 2."); Assert.True("R".Equals(kcEvents[0].Decision), $"Inquiry failed! Wrong decisions d1 = {kcEvents[0].Decision}, d2 = {kcEvents[1].Decision} by Kount Central ThresholdEvents."); Assert.True("R".Equals(kcEvents[1].Decision), $"Inquiry failed! Wrong decisions d1 = {kcEvents[0].Decision}, d2 = {kcEvents[1].Decision} by Kount Central ThresholdEvents."); var code1 = kcEvents[0].Code; var code2 = kcEvents[1].Code; Assert.True("billingToShippingAddressReview".Equals(code1) || "billingToShippingAddressReview".Equals(code2), $"Inquiry failed! Wrong KC codes: {code1}, {code2} expected billingToShippingAddressReview."); Assert.True("orderTotalReview".Equals(code1) || "orderTotalReview".Equals(code2), $"Inquiry failed! Wrong KC codes: {code1}, {code2} expected orderTotalReview."); }
public bool updateStudentInquiry(Inquiry inquiry) { return(gfo.updateInquiry(inquiry) > 0); }
public void ModeXAfterModeQ() { Inquiry inquiry = TestHelper.CreateInquiry(PTOK, out _sid, out _orderNum); // set CART with one item var cart = new ArrayList(); cart.Add(new CartItem("cart item 0 type", "cart item 0", "cart item 0 description", 10, 1234)); inquiry.SetCart(cart); // get response Response response = inquiry.GetResponse(); // optional getter var errors = response.GetErrors(); if (errors.Count > 0) { Assert.True(false, String.Join(Environment.NewLine, errors)); return; } var sessID = response.GetSessionId(); var tranID = response.GetTransactionId(); var ordNum = response.GetOrderNumber(); // create update Update update = new Update(); update.SetMode(UpdateTypes.ModeX); update.SetVersion("0695"); update.SetSessionId(sessID); update.SetTransactionId(tranID); update.SetOrderNumber(ordNum); update.SetPaymentTokenLast4("6807"); update.SetMack('Y'); update.SetAuth('A'); update.SetAvst('M'); update.SetAvsz('M'); update.SetCvvr('M'); response = update.GetResponse(); errors = response.GetErrors(); Assert.True(errors.Count == 0, String.Join(Environment.NewLine, errors, "There are errors in response!")); var mode = response.GetMode(); Assert.True("X".Equals(mode), $"Update failed! Wrong response mode {mode}."); var sID = response.GetSessionId(); Assert.True(sessID.Equals(sID), $"Update failed! Wrong session ID {sID}."); var tId = response.GetTransactionId(); Assert.True(tranID.Equals(tId), $"Update failed! Wrong Transaction Id {tranID}."); var ordU = response.GetOrderNumber(); Assert.True(ordNum.Equals(ordU), $"Update failed! Wrong Order Number {ordNum}."); var auto = response.GetAuto(); Assert.True(auto != null, $"Update failed! AUTO not presented in response."); var scor = response.GetScore(); Assert.True(scor != null, $"Update failed! SCOR not presented in response."); var geox = response.GetGeox(); Assert.True(geox != null, $"Update failed! GEOX not presented in response."); }
private async Task FetchAndAddProductToInquiry(Inquiry inquiry, Guid productId, int amount) { var product = await _productRepository.GetProduct(productId).ConfigureAwait(false); inquiry.AddProduct(product, amount); }