问:
How can I make this Query faster? Is Left Outer Joins / Inner Joins the fastest way to approach the required dataset in this case?
I have the following query, and it takes around 3-4 seconds to complete. I need this to return results in less than a second if possible.

I'm not sure if the Inner Joins and Outer joins are the best to use in this situation. Maybe using Cross Apply?

How can I approach this?

```<code>SELECT DISTINCT QH.SupplierCode AS SupplierCode,
                BP.Name AS SupplierName,
                BP.ShortName AS SupplierShortName,
                QH.BillingSupplierCode AS BillingSupplierCode,
                BillingSupplierBP.ShortName AS BillingSupplierShortName,
                QH.QuotationNum,
                QH.CurrencyCode,
                CONVERT(MONEY, QH.PackagingExpenses + QH.DeliveryExpenses + QH.OtherExpenses) AS PDOExpenses,
                ISNULL(ER.ExchangeRate, CASE
                                            WHEN QH.CurrencyCode =
                                                   (SELECT BaseCurrencyCode
                                                    FROM ApplicationProfile) THEN 1
                                            ELSE 0
                                        END) AS ExchangeRate,
                CONVERT(NUMERIC(20, 8), 0) AS TotalNetValue,
                CONVERT(NUMERIC(20, 8), 0) AS TotalNetValueForCommonItems,
                CONVERT(NUMERIC(20, 8), 0) AS TotalDiscountValue,
                CONVERT(NUMERIC(30, 8), 0) AS GrandTotal,
                CONVERT(NUMERIC(12, 2), 0) AS Variance,
                CONVERT(NUMERIC(5, 2), 0) AS TotalDiscount,
                CONVERT(NUMERIC(30, 8), 0) AS TotalSelected
FROM BusinessPartners BP,
(
QuotationsHeader QH
    LEFT OUTER JOIN (ExchangeRates ER
                    INNER JOIN
                            (SELECT CurrencyCode,
                                    MAX(ExchangeRateDate) AS ExchangeRateDate
                            FROM ExchangeRates
                            WHERE ExchangeRateDate <= '2023/01/04 00:00:00'
                            GROUP BY CurrencyCode
                            )
                        ERmax ON ER.CurrencyCode = ERmax.CurrencyCode
                    AND ER.ExchangeRateDate = ERmax.ExchangeRateDate
                        )
                    ON ER.CurrencyCode = QH.CurrencyCode
)
LEFT OUTER JOIN BusinessPartners BillingSupplierBP
    ON BillingSupplierBP.BusinessPartnerCode = QH.BillingSupplierCode,
                           EnquiriesDetail ED,
                           QuotationsDetail QD
WHERE BP.BusinessPartnerCode = QH.SupplierCode
  AND QH.EnquiryNum = QD.EnquiryNum
  AND QH.QuotationNum = QD.QuotationNum
  AND ED.EnquiryNum = QD.EnquiryNum
  AND ED.EnquirylineNum = QD.EnquirylineNum
  AND ED.EnquiryNum = 838
  AND QH.QuotationStatus <> 2
GROUP BY QH.QuotationNum,
         BP.Name,
         BP.ShortName,
         QH.CurrencyCode,
         QH.SupplierCode,
         QH.BillingSupplierCode,
         BillingSupplierBP.ShortName,
         QH.PackagingExpenses,
         QH.DeliveryExpenses,
         QH.OtherExpenses,
         ER.ExchangeRate
HAVING SUM(QD.PriceListValue) <> 0
</code>```

And it returns these results:

I have added the Execution Plan here:

https://www.brentozar.com/pastetheplan/?id=rJZHCyXqs

Here is the tables info:

https://docs.google.com/spreadsheets/d/1NHPVHD3quvT9LTpAOYlGmcJ8BRID9HO6lNf51ii_h3E/edit?usp=sharing

Edit:

Edit 2:

```<code>USE [Database]
GO

/****** Object:  Table [dbo].[ApplicationProfile]    Script Date: 4/1/2023 4:03:36 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ApplicationProfile](
    [BaseCurrencyCode] [varchar](3) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [CompanyName] [varchar](50) NOT NULL,
    [CompanyAddr1] [varchar](50) NOT NULL,
    [CompanyAddr2] [varchar](50) NOT NULL,
    [CompanyAddr3] [varchar](50) NOT NULL,
    [CompanyAddr4] [varchar](50) NOT NULL,
    [CompanyTelephone] [varchar](40) NOT NULL,
    [CompanyFax] [varchar](40) NOT NULL,
    [CompanyTelex] [varchar](40) NOT NULL,
    [CompanyEmail] [varchar](40) NOT NULL,
    [DocumentManagementInd] [int] NOT NULL,
    [CompanyLogo] [image] NULL,
    [DocumentManagementFilePath] [varchar](150) NOT NULL,
    [LubricantsBPCategory] [varchar](3) NOT NULL,
    [PaintsBPCategory] [varchar](3) NOT NULL,
    [BaseCurrencySuggestionInd] [int] NOT NULL,
    [ExRateDeviation] [numeric](3, 1) NOT NULL,
    [ExtraBPType1Name] [varchar](30) NOT NULL,
    [ExtraBPType2Name] [varchar](30) NOT NULL,
    [ExtraBPType3Name] [varchar](30) NOT NULL,
    [DataAccessControlActiveInd] [int] NOT NULL,
    [EnableAutoSaveProcessInd] [int] NOT NULL,
    [ValidateVesselsAccountDataInd] [int] NOT NULL,
    [ProfileID] [int] NOT NULL,
    [SMTPAuthenticationInd] [int] NOT NULL,
    [SMTPEncryptionInd] [int] NOT NULL,
    [SMTPPassword] [varchar](100) NOT NULL,
    [SMTPPortNumber] [varchar](5) NOT NULL,
    [SMTPServer] [varchar](50) NOT NULL,
    [SMTPUserName] [varchar](50) NOT NULL,
    [SPDocumentLibrary] [varchar](100) NOT NULL,
    [SPServerName] [varchar](100) NOT NULL,
    [SPServiceName] [varchar](100) NOT NULL,
    [SPServiceURL] [varchar](100) NOT NULL,
    [SPSSP] [varchar](100) NOT NULL,
    [AtSeaPortCode] [varchar](30) NOT NULL,
    [EmailCDTCode] [varchar](6) NOT NULL,
    [FaxCDTCode] [varchar](6) NOT NULL,
    [MobileCDTCode] [varchar](6) NOT NULL,
    [PhoneCDTCode] [varchar](6) NOT NULL,
    [AccEmailCDTCode] [varchar](6) NOT NULL,
    [InvoicingAddressType] [varchar](6) NOT NULL,
    [AOHPhoneCDTCode] [varchar](6) NOT NULL,
    [AttachmentsServerLocalPath] [varchar](150) NOT NULL,
    [AttachmentsServerNetworkPath] [varchar](150) NOT NULL,
    [ChemicalTankersVslTypeCode] [varchar](5) NOT NULL,
    [CompassMailInd] [int] NOT NULL,
    [BunkerSupplierBPType] [varchar](3) NOT NULL,
    [BunkerSurveyorBPType] [varchar](3) NOT NULL,
    [InsuranceBrokerBPType] [varchar](3) NOT NULL,
    [UnderwriterBPType] [varchar](3) NOT NULL,
    [DGCalculationFormula] [varchar](8000) NOT NULL,
    [MECalculationFormula] [varchar](8000) NOT NULL,
    [CompanyReceptionDpt] [varchar](5) NOT NULL,
    [CrewingAgencyBPType] [varchar](3) NOT NULL,
    [DefaultOnBoardWarehouse] [varchar](3) NOT NULL,
    [EmailFooter] [varchar](5000) NOT NULL,
    [CompanyVesselCode] [varchar](3) NOT NULL,
    [FWBPType] [varchar](3) NOT NULL,
    [PUAgentBPType] [varchar](3) NOT NULL,
    [PUSupplierBPType] [varchar](3) NOT NULL,
    [CashierCompanyTypeCode] [varchar](6) NOT NULL,
    [FOSuppliersBPCategory] [nvarchar](3) NOT NULL,
    [GRSuppliersBPCategory] [nvarchar](3) NOT NULL,
    [IsCashierRelTypeCode] [varchar](6) NOT NULL,
    [ManagesRelTypeCode] [varchar](6) NOT NULL,
    [MngCompanyTypeCode] [varchar](6) NOT NULL,
    [OwningRelationshipTypeCode] [varchar](6) NOT NULL,
    [SPVCompanyTypeCode] [varchar](6) NOT NULL,
    [AutoUpdateBPBankDetailsInd] [int] NOT NULL,
    [EUAgentsAppointmentRemarks] [varchar](600) NOT NULL,
    [FBB250CDTCode] [varchar](6) NOT NULL,
    [FBB500CDTCode] [varchar](6) NOT NULL,
    [HelicopterBPType] [varchar](3) NOT NULL,
    [HoldsSharesRelTypeCode] [varchar](6) NOT NULL,
    [LaunchingBPType] [varchar](3) NOT NULL,
    [MooringBPType] [varchar](3) NOT NULL,
    [PilotageBPType] [varchar](3) NOT NULL,
    [SHCompanyTypeCode] [varchar](6) NOT NULL,
    [TelexCDTCode] [varchar](6) NOT NULL,
    [TowageBPType] [varchar](3) NOT NULL,
    [IHCompanyTypeCode] [varchar](6) NOT NULL,
    [OverrideCachingInd] [int] NOT NULL,
    [MSOutlookInd] [int] NOT NULL,
    [DecodeSMTPCredentialsInd] [int] NOT NULL,
    [OverrideSyncUsersWithADInd] [int] NOT NULL,
    [CompanyWatermark] [image] NULL,
    [NotificationInterval] [int] NOT NULL,
    [NotificationUpdateInterval] [int] NOT NULL,
    [NotificationWarningInterval] [int] NOT NULL,
    [NotifyForUnprocessedMsgInd] [int] NOT NULL,
    [ShowBankDetailsCommentsInd] [int] NOT NULL,
    [ActiveDirectoryCustomFilter] [varchar](200) NOT NULL,
    [PuEmailCdtCode] [varchar](6) NOT NULL,
    [DocumentMaxFileSize] [int] NOT NULL,
    [UseTls12Ind] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[BusinessPartners]    Script Date: 4/1/2023 4:04:54 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BusinessPartners](
    [BusinessPartnerCode] [varchar](6) NOT NULL,
    [Name] [varchar](150) NOT NULL,
    [ShortName] [varchar](20) NOT NULL,
    [VatCode] [varchar](25) NOT NULL,
    [AddressLine1] [varchar](40) NOT NULL,
    [AddressLine2] [varchar](40) NOT NULL,
    [ZipCode] [varchar](10) NOT NULL,
    [CountryCode] [varchar](4) NOT NULL,
    [Telephone] [varchar](20) NOT NULL,
    [Fax] [varchar](20) NOT NULL,
    [Telex] [varchar](20) NOT NULL,
    [DefaultCurrency] [varchar](3) NOT NULL,
    [EmailAccount] [varchar](40) NOT NULL,
    [SupplierInd] [int] NOT NULL,
    [CategoryCode] [varchar](3) NOT NULL,
    [ChartererInd] [int] NOT NULL,
    [AgentInd] [int] NOT NULL,
    [BrokerInd] [int] NOT NULL,
    [OtherInd] [int] NOT NULL,
    [YardInd] [int] NOT NULL,
    [AllAccountsInd] [int] NOT NULL,
    [CreditTermsType] [varchar](3) NOT NULL,
    [CreditTermsDays] [int] NOT NULL,
    [OtherReference1] [varchar](40) NOT NULL,
    [OtherReference2] [varchar](40) NOT NULL,
    [OwnCode] [varchar](10) NOT NULL,
    [RelatedBusinessPartner] [varchar](6) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [UserDefinedCode1] [varchar](50) NOT NULL,
    [UserDefinedCode2] [varchar](50) NOT NULL,
    [UserDefinedCode3] [varchar](50) NOT NULL,
    [UserDefinedCode4] [varchar](50) NOT NULL,
    [UserDefinedCode5] [varchar](50) NOT NULL,
    [AddressLine3] [varchar](40) NOT NULL,
    [City] [varchar](50) NOT NULL,
    [LocalAddressNumber] [varchar](10) NOT NULL,
    [LocalAddressStreet] [varchar](50) NOT NULL,
    [LocalCity] [varchar](50) NOT NULL,
    [LocalInvoiceType] [varchar](50) NOT NULL,
    [LocalName] [varchar](100) NOT NULL,
    [LocalProfession] [varchar](50) NOT NULL,
    [LocalTaxAuthorityCode] [varchar](4) NOT NULL,
    [LocalZipCode] [varchar](10) NOT NULL,
    [CurrencyRestrictedInd] [int] NOT NULL,
    [ExtraBPType1Ind] [int] NOT NULL,
    [ExtraBPType2Ind] [int] NOT NULL,
    [ExtraBPType3Ind] [int] NOT NULL,
    [FinanciallyActiveInd] [int] NOT NULL,
    [MinoritiesInd] [int] NOT NULL,
    [OfficePersonnelInd] [int] NOT NULL,
    [DateRecordOpened] [datetime] NOT NULL,
    [FinancialActivationDate] [datetime] NOT NULL,
    [EntryNotAllowed] [int] NOT NULL,
    [BeneficiaryOPWordingInd] [int] NOT NULL,
    [ChartsPublicationsInd] [int] NOT NULL,
    [ChemicalsInd] [int] NOT NULL,
    [LubricantsInd] [int] NOT NULL,
    [PaintsInd] [int] NOT NULL,
    [ProvisionsInd] [int] NOT NULL,
    [ServicesInd] [int] NOT NULL,
    [SparePartsInd] [int] NOT NULL,
    [StoresInd] [int] NOT NULL,
    [BunkersInd] [int] NOT NULL,
    [DepartmentCode] [varchar](5) NOT NULL,
    [IDNum] [varchar](40) NOT NULL,
    [JobTitle] [varchar](40) NOT NULL,
    [PassportNum] [varchar](40) NOT NULL,
    [GrossRateDecimals] [int] NOT NULL,
    [ExcludeFromMYFInd] [int] NOT NULL,
    [OwnerInd] [int] NOT NULL,
    [PoolParticipantInd] [int] NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[EnquiriesDetail]    Script Date: 4/1/2023 4:05:40 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[EnquiriesDetail](
    [EnquiryNum] [numeric](5, 0) NOT NULL,
    [EnquiryLineNum] [int] NOT NULL,
    [ItemCode] [varchar](30) NOT NULL,
    [ItemDescription] [varchar](100) NOT NULL,
    [RobQuantity] [numeric](9, 3) NOT NULL,
    [PmsInd] [int] NOT NULL,
    [SparesCondition] [int] NOT NULL,
    [InactiveRecInd] [int] NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [Status] [int] NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [ComponentCode] [varchar](20) NOT NULL,
    [SubComponentCode] [varchar](20) NOT NULL,
    [ComparisonGroup] [varchar](10) NOT NULL,
    [RequestedQuantity] [numeric](9, 3) NOT NULL,
    [RequestedUnitOfMeasure] [varchar](3) NOT NULL,
    [OptionalQuantity] [numeric](9, 3) NOT NULL,
    [DrawingCode] [varchar](20) NOT NULL,
    [RequisitionLineNum] [int] NOT NULL,
    [RequisitionNum] [numeric](5, 0) NOT NULL,
    [Grade] [varchar](3) NOT NULL,
    [ISOStandard] [varchar](3) NOT NULL,
    [ItemCategory1] [varchar](3) NOT NULL,
    [ItemCategory2] [varchar](3) NOT NULL,
    [QuantityRangeFrom] [numeric](9, 3) NOT NULL,
    [VesselCode] [varchar](3) NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[ExchangeRates]    Script Date: 4/1/2023 4:05:48 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ExchangeRates](
    [CurrencyCode] [varchar](3) NOT NULL,
    [ExchangeRateDate] [datetime] NOT NULL,
    [ExchangeRate] [numeric](11, 5) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[QuotationsHeader]    Script Date: 4/1/2023 4:06:16 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[QuotationsHeader](
    [EnquiryNum] [numeric](5, 0) NOT NULL,
    [QuotationNum] [numeric](2, 0) NOT NULL,
    [RfqDate] [datetime] NOT NULL,
    [QuotationDate] [datetime] NOT NULL,
    [RequestedDeliveryDate] [datetime] NOT NULL,
    [SupplierCode] [varchar](6) NOT NULL,
    [CurrencyCode] [varchar](3) NOT NULL,
    [SupplierReference] [varchar](15) NOT NULL,
    [PackagingExpenses] [numeric](12, 2) NOT NULL,
    [DeliveryDays] [numeric](3, 0) NOT NULL,
    [DeliveryExpenses] [numeric](12, 2) NOT NULL,
    [OtherExpenses] [numeric](12, 2) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [AttachmentFileName] [nvarchar](100) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [BerthName] [varchar](100) NOT NULL,
    [DemurrageRate] [numeric](12, 6) NOT NULL,
    [Port] [varchar](30) NOT NULL,
    [BillingSupplierCode] [varchar](6) NOT NULL,
    [PaymentDays] [numeric](3, 0) NOT NULL,
    [QuotationStatus] [int] NOT NULL,
    [SupplierContactPerson] [int] NOT NULL,
    [PaymentTerms] [varchar](3) NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[QuotationsDetail]    Script Date: 4/1/2023 4:06:22 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[QuotationsDetail](
    [EnquiryNum] [numeric](5, 0) NOT NULL,
    [QuotationNum] [numeric](2, 0) NOT NULL,
    [QuotationLineNum] [int] NOT NULL,
    [EnquiryLineNum] [int] NOT NULL,
    [ItemCode] [varchar](30) NOT NULL,
    [RequestedQuantity] [numeric](9, 3) NOT NULL,
    [QuotedQuantity] [numeric](9, 3) NOT NULL,
    [UnitPrice] [numeric](15, 5) NOT NULL,
    [UnitPriceInd] [int] NOT NULL,
    [Discount] [numeric](5, 2) NOT NULL,
    [PriceListValue] [numeric](12, 2) NOT NULL,
    [NetValue] [numeric](12, 2) NOT NULL,
    [DeliveryDays] [int] NOT NULL,
    [DiscountValue] [numeric](12, 2) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [ConversionFactor] [numeric](10, 5) NOT NULL,
    [QuotedUnitOfMeasure] [varchar](3) NOT NULL,
    [RequestedUnitOfMeasure] [varchar](3) NOT NULL,
    [OptionalUnitPrice] [numeric](15, 5) NOT NULL,
    [PostedUnitPrice] [numeric](15, 5) NOT NULL,
    [PumpingRate] [numeric](12, 6) NOT NULL,
    [RequestedOptionalQuantity] [numeric](9, 3) NOT NULL,
    [UnitDiscountAmount] [numeric](12, 2) NOT NULL,
    [ValidToDate] [datetime] NOT NULL,
    [FirstUnitPrice] [numeric](15, 5) NOT NULL,
    [DeliveryMethodInd] [int] NOT NULL,
    [Grade] [varchar](3) NOT NULL,
    [ISOStandard] [varchar](3) NOT NULL,
    [ItemCategory1] [varchar](3) NOT NULL,
    [ItemCategory2] [varchar](3) NOT NULL,
    [RequestedQuantityRangeFrom] [numeric](9, 3) NOT NULL
) ON [PRIMARY]
GO

</code>```

Body:
I have the following query, and it takes around 3-4 seconds to complete. I need this to return results in less than a second if possible.

I'm not sure if the Inner Joins and Outer joins are the best to use in this situation. Maybe using Cross Apply?

How can I approach this?

SELECT DISTINCT QH.SupplierCode AS SupplierCode,
                BP.Name AS SupplierName,
                BP.ShortName AS SupplierShortName,
                QH.BillingSupplierCode AS BillingSupplierCode,
                BillingSupplierBP.ShortName AS BillingSupplierShortName,
                QH.QuotationNum,
                QH.CurrencyCode,
                CONVERT(MONEY, QH.PackagingExpenses + QH.DeliveryExpenses + QH.OtherExpenses) AS PDOExpenses,
                ISNULL(ER.ExchangeRate, CASE
                                            WHEN QH.CurrencyCode =
                                                   (SELECT BaseCurrencyCode
                                                    FROM ApplicationProfile) THEN 1
                                            ELSE 0
                                        END) AS ExchangeRate,
                CONVERT(NUMERIC(20, 8), 0) AS TotalNetValue,
                CONVERT(NUMERIC(20, 8), 0) AS TotalNetValueForCommonItems,
                CONVERT(NUMERIC(20, 8), 0) AS TotalDiscountValue,
                CONVERT(NUMERIC(30, 8), 0) AS GrandTotal,
                CONVERT(NUMERIC(12, 2), 0) AS Variance,
                CONVERT(NUMERIC(5, 2), 0) AS TotalDiscount,
                CONVERT(NUMERIC(30, 8), 0) AS TotalSelected
FROM BusinessPartners BP,
(
QuotationsHeader QH
    LEFT OUTER JOIN (ExchangeRates ER
                    INNER JOIN
                            (SELECT CurrencyCode,
                                    MAX(ExchangeRateDate) AS ExchangeRateDate
                            FROM ExchangeRates
                            WHERE ExchangeRateDate <= '2023/01/04 00:00:00'
                            GROUP BY CurrencyCode
                            )
                        ERmax ON ER.CurrencyCode = ERmax.CurrencyCode
                    AND ER.ExchangeRateDate = ERmax.ExchangeRateDate
                        )
                    ON ER.CurrencyCode = QH.CurrencyCode
)
LEFT OUTER JOIN BusinessPartners BillingSupplierBP
    ON BillingSupplierBP.BusinessPartnerCode = QH.BillingSupplierCode,
                           EnquiriesDetail ED,
                           QuotationsDetail QD
WHERE BP.BusinessPartnerCode = QH.SupplierCode
  AND QH.EnquiryNum = QD.EnquiryNum
  AND QH.QuotationNum = QD.QuotationNum
  AND ED.EnquiryNum = QD.EnquiryNum
  AND ED.EnquirylineNum = QD.EnquirylineNum
  AND ED.EnquiryNum = 838
  AND QH.QuotationStatus <> 2
GROUP BY QH.QuotationNum,
         BP.Name,
         BP.ShortName,
         QH.CurrencyCode,
         QH.SupplierCode,
         QH.BillingSupplierCode,
         BillingSupplierBP.ShortName,
         QH.PackagingExpenses,
         QH.DeliveryExpenses,
         QH.OtherExpenses,
         ER.ExchangeRate
HAVING SUM(QD.PriceListValue) <> 0

And it returns these results:

I have added the Execution Plan here:

https://www.brentozar.com/pastetheplan/?id=rJZHCyXqs

Here is the tables info:

https://docs.google.com/spreadsheets/d/1NHPVHD3quvT9LTpAOYlGmcJ8BRID9HO6lNf51ii_h3E/edit?usp=sharing

Edit:

Edit 2:

USE [Database]
GO

/****** Object:  Table [dbo].[ApplicationProfile]    Script Date: 4/1/2023 4:03:36 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ApplicationProfile](
    [BaseCurrencyCode] [varchar](3) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [CompanyName] [varchar](50) NOT NULL,
    [CompanyAddr1] [varchar](50) NOT NULL,
    [CompanyAddr2] [varchar](50) NOT NULL,
    [CompanyAddr3] [varchar](50) NOT NULL,
    [CompanyAddr4] [varchar](50) NOT NULL,
    [CompanyTelephone] [varchar](40) NOT NULL,
    [CompanyFax] [varchar](40) NOT NULL,
    [CompanyTelex] [varchar](40) NOT NULL,
    [CompanyEmail] [varchar](40) NOT NULL,
    [DocumentManagementInd] [int] NOT NULL,
    [CompanyLogo] [image] NULL,
    [DocumentManagementFilePath] [varchar](150) NOT NULL,
    [LubricantsBPCategory] [varchar](3) NOT NULL,
    [PaintsBPCategory] [varchar](3) NOT NULL,
    [BaseCurrencySuggestionInd] [int] NOT NULL,
    [ExRateDeviation] [numeric](3, 1) NOT NULL,
    [ExtraBPType1Name] [varchar](30) NOT NULL,
    [ExtraBPType2Name] [varchar](30) NOT NULL,
    [ExtraBPType3Name] [varchar](30) NOT NULL,
    [DataAccessControlActiveInd] [int] NOT NULL,
    [EnableAutoSaveProcessInd] [int] NOT NULL,
    [ValidateVesselsAccountDataInd] [int] NOT NULL,
    [ProfileID] [int] NOT NULL,
    [SMTPAuthenticationInd] [int] NOT NULL,
    [SMTPEncryptionInd] [int] NOT NULL,
    [SMTPPassword] [varchar](100) NOT NULL,
    [SMTPPortNumber] [varchar](5) NOT NULL,
    [SMTPServer] [varchar](50) NOT NULL,
    [SMTPUserName] [varchar](50) NOT NULL,
    [SPDocumentLibrary] [varchar](100) NOT NULL,
    [SPServerName] [varchar](100) NOT NULL,
    [SPServiceName] [varchar](100) NOT NULL,
    [SPServiceURL] [varchar](100) NOT NULL,
    [SPSSP] [varchar](100) NOT NULL,
    [AtSeaPortCode] [varchar](30) NOT NULL,
    [EmailCDTCode] [varchar](6) NOT NULL,
    [FaxCDTCode] [varchar](6) NOT NULL,
    [MobileCDTCode] [varchar](6) NOT NULL,
    [PhoneCDTCode] [varchar](6) NOT NULL,
    [AccEmailCDTCode] [varchar](6) NOT NULL,
    [InvoicingAddressType] [varchar](6) NOT NULL,
    [AOHPhoneCDTCode] [varchar](6) NOT NULL,
    [AttachmentsServerLocalPath] [varchar](150) NOT NULL,
    [AttachmentsServerNetworkPath] [varchar](150) NOT NULL,
    [ChemicalTankersVslTypeCode] [varchar](5) NOT NULL,
    [CompassMailInd] [int] NOT NULL,
    [BunkerSupplierBPType] [varchar](3) NOT NULL,
    [BunkerSurveyorBPType] [varchar](3) NOT NULL,
    [InsuranceBrokerBPType] [varchar](3) NOT NULL,
    [UnderwriterBPType] [varchar](3) NOT NULL,
    [DGCalculationFormula] [varchar](8000) NOT NULL,
    [MECalculationFormula] [varchar](8000) NOT NULL,
    [CompanyReceptionDpt] [varchar](5) NOT NULL,
    [CrewingAgencyBPType] [varchar](3) NOT NULL,
    [DefaultOnBoardWarehouse] [varchar](3) NOT NULL,
    [EmailFooter] [varchar](5000) NOT NULL,
    [CompanyVesselCode] [varchar](3) NOT NULL,
    [FWBPType] [varchar](3) NOT NULL,
    [PUAgentBPType] [varchar](3) NOT NULL,
    [PUSupplierBPType] [varchar](3) NOT NULL,
    [CashierCompanyTypeCode] [varchar](6) NOT NULL,
    [FOSuppliersBPCategory] [nvarchar](3) NOT NULL,
    [GRSuppliersBPCategory] [nvarchar](3) NOT NULL,
    [IsCashierRelTypeCode] [varchar](6) NOT NULL,
    [ManagesRelTypeCode] [varchar](6) NOT NULL,
    [MngCompanyTypeCode] [varchar](6) NOT NULL,
    [OwningRelationshipTypeCode] [varchar](6) NOT NULL,
    [SPVCompanyTypeCode] [varchar](6) NOT NULL,
    [AutoUpdateBPBankDetailsInd] [int] NOT NULL,
    [EUAgentsAppointmentRemarks] [varchar](600) NOT NULL,
    [FBB250CDTCode] [varchar](6) NOT NULL,
    [FBB500CDTCode] [varchar](6) NOT NULL,
    [HelicopterBPType] [varchar](3) NOT NULL,
    [HoldsSharesRelTypeCode] [varchar](6) NOT NULL,
    [LaunchingBPType] [varchar](3) NOT NULL,
    [MooringBPType] [varchar](3) NOT NULL,
    [PilotageBPType] [varchar](3) NOT NULL,
    [SHCompanyTypeCode] [varchar](6) NOT NULL,
    [TelexCDTCode] [varchar](6) NOT NULL,
    [TowageBPType] [varchar](3) NOT NULL,
    [IHCompanyTypeCode] [varchar](6) NOT NULL,
    [OverrideCachingInd] [int] NOT NULL,
    [MSOutlookInd] [int] NOT NULL,
    [DecodeSMTPCredentialsInd] [int] NOT NULL,
    [OverrideSyncUsersWithADInd] [int] NOT NULL,
    [CompanyWatermark] [image] NULL,
    [NotificationInterval] [int] NOT NULL,
    [NotificationUpdateInterval] [int] NOT NULL,
    [NotificationWarningInterval] [int] NOT NULL,
    [NotifyForUnprocessedMsgInd] [int] NOT NULL,
    [ShowBankDetailsCommentsInd] [int] NOT NULL,
    [ActiveDirectoryCustomFilter] [varchar](200) NOT NULL,
    [PuEmailCdtCode] [varchar](6) NOT NULL,
    [DocumentMaxFileSize] [int] NOT NULL,
    [UseTls12Ind] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[BusinessPartners]    Script Date: 4/1/2023 4:04:54 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BusinessPartners](
    [BusinessPartnerCode] [varchar](6) NOT NULL,
    [Name] [varchar](150) NOT NULL,
    [ShortName] [varchar](20) NOT NULL,
    [VatCode] [varchar](25) NOT NULL,
    [AddressLine1] [varchar](40) NOT NULL,
    [AddressLine2] [varchar](40) NOT NULL,
    [ZipCode] [varchar](10) NOT NULL,
    [CountryCode] [varchar](4) NOT NULL,
    [Telephone] [varchar](20) NOT NULL,
    [Fax] [varchar](20) NOT NULL,
    [Telex] [varchar](20) NOT NULL,
    [DefaultCurrency] [varchar](3) NOT NULL,
    [EmailAccount] [varchar](40) NOT NULL,
    [SupplierInd] [int] NOT NULL,
    [CategoryCode] [varchar](3) NOT NULL,
    [ChartererInd] [int] NOT NULL,
    [AgentInd] [int] NOT NULL,
    [BrokerInd] [int] NOT NULL,
    [OtherInd] [int] NOT NULL,
    [YardInd] [int] NOT NULL,
    [AllAccountsInd] [int] NOT NULL,
    [CreditTermsType] [varchar](3) NOT NULL,
    [CreditTermsDays] [int] NOT NULL,
    [OtherReference1] [varchar](40) NOT NULL,
    [OtherReference2] [varchar](40) NOT NULL,
    [OwnCode] [varchar](10) NOT NULL,
    [RelatedBusinessPartner] [varchar](6) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [UserDefinedCode1] [varchar](50) NOT NULL,
    [UserDefinedCode2] [varchar](50) NOT NULL,
    [UserDefinedCode3] [varchar](50) NOT NULL,
    [UserDefinedCode4] [varchar](50) NOT NULL,
    [UserDefinedCode5] [varchar](50) NOT NULL,
    [AddressLine3] [varchar](40) NOT NULL,
    [City] [varchar](50) NOT NULL,
    [LocalAddressNumber] [varchar](10) NOT NULL,
    [LocalAddressStreet] [varchar](50) NOT NULL,
    [LocalCity] [varchar](50) NOT NULL,
    [LocalInvoiceType] [varchar](50) NOT NULL,
    [LocalName] [varchar](100) NOT NULL,
    [LocalProfession] [varchar](50) NOT NULL,
    [LocalTaxAuthorityCode] [varchar](4) NOT NULL,
    [LocalZipCode] [varchar](10) NOT NULL,
    [CurrencyRestrictedInd] [int] NOT NULL,
    [ExtraBPType1Ind] [int] NOT NULL,
    [ExtraBPType2Ind] [int] NOT NULL,
    [ExtraBPType3Ind] [int] NOT NULL,
    [FinanciallyActiveInd] [int] NOT NULL,
    [MinoritiesInd] [int] NOT NULL,
    [OfficePersonnelInd] [int] NOT NULL,
    [DateRecordOpened] [datetime] NOT NULL,
    [FinancialActivationDate] [datetime] NOT NULL,
    [EntryNotAllowed] [int] NOT NULL,
    [BeneficiaryOPWordingInd] [int] NOT NULL,
    [ChartsPublicationsInd] [int] NOT NULL,
    [ChemicalsInd] [int] NOT NULL,
    [LubricantsInd] [int] NOT NULL,
    [PaintsInd] [int] NOT NULL,
    [ProvisionsInd] [int] NOT NULL,
    [ServicesInd] [int] NOT NULL,
    [SparePartsInd] [int] NOT NULL,
    [StoresInd] [int] NOT NULL,
    [BunkersInd] [int] NOT NULL,
    [DepartmentCode] [varchar](5) NOT NULL,
    [IDNum] [varchar](40) NOT NULL,
    [JobTitle] [varchar](40) NOT NULL,
    [PassportNum] [varchar](40) NOT NULL,
    [GrossRateDecimals] [int] NOT NULL,
    [ExcludeFromMYFInd] [int] NOT NULL,
    [OwnerInd] [int] NOT NULL,
    [PoolParticipantInd] [int] NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[EnquiriesDetail]    Script Date: 4/1/2023 4:05:40 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[EnquiriesDetail](
    [EnquiryNum] [numeric](5, 0) NOT NULL,
    [EnquiryLineNum] [int] NOT NULL,
    [ItemCode] [varchar](30) NOT NULL,
    [ItemDescription] [varchar](100) NOT NULL,
    [RobQuantity] [numeric](9, 3) NOT NULL,
    [PmsInd] [int] NOT NULL,
    [SparesCondition] [int] NOT NULL,
    [InactiveRecInd] [int] NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [Status] [int] NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [ComponentCode] [varchar](20) NOT NULL,
    [SubComponentCode] [varchar](20) NOT NULL,
    [ComparisonGroup] [varchar](10) NOT NULL,
    [RequestedQuantity] [numeric](9, 3) NOT NULL,
    [RequestedUnitOfMeasure] [varchar](3) NOT NULL,
    [OptionalQuantity] [numeric](9, 3) NOT NULL,
    [DrawingCode] [varchar](20) NOT NULL,
    [RequisitionLineNum] [int] NOT NULL,
    [RequisitionNum] [numeric](5, 0) NOT NULL,
    [Grade] [varchar](3) NOT NULL,
    [ISOStandard] [varchar](3) NOT NULL,
    [ItemCategory1] [varchar](3) NOT NULL,
    [ItemCategory2] [varchar](3) NOT NULL,
    [QuantityRangeFrom] [numeric](9, 3) NOT NULL,
    [VesselCode] [varchar](3) NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[ExchangeRates]    Script Date: 4/1/2023 4:05:48 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ExchangeRates](
    [CurrencyCode] [varchar](3) NOT NULL,
    [ExchangeRateDate] [datetime] NOT NULL,
    [ExchangeRate] [numeric](11, 5) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[QuotationsHeader]    Script Date: 4/1/2023 4:06:16 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[QuotationsHeader](
    [EnquiryNum] [numeric](5, 0) NOT NULL,
    [QuotationNum] [numeric](2, 0) NOT NULL,
    [RfqDate] [datetime] NOT NULL,
    [QuotationDate] [datetime] NOT NULL,
    [RequestedDeliveryDate] [datetime] NOT NULL,
    [SupplierCode] [varchar](6) NOT NULL,
    [CurrencyCode] [varchar](3) NOT NULL,
    [SupplierReference] [varchar](15) NOT NULL,
    [PackagingExpenses] [numeric](12, 2) NOT NULL,
    [DeliveryDays] [numeric](3, 0) NOT NULL,
    [DeliveryExpenses] [numeric](12, 2) NOT NULL,
    [OtherExpenses] [numeric](12, 2) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [AttachmentFileName] [nvarchar](100) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [BerthName] [varchar](100) NOT NULL,
    [DemurrageRate] [numeric](12, 6) NOT NULL,
    [Port] [varchar](30) NOT NULL,
    [BillingSupplierCode] [varchar](6) NOT NULL,
    [PaymentDays] [numeric](3, 0) NOT NULL,
    [QuotationStatus] [int] NOT NULL,
    [SupplierContactPerson] [int] NOT NULL,
    [PaymentTerms] [varchar](3) NOT NULL
) ON [PRIMARY]
GO

USE [Database]
GO

/****** Object:  Table [dbo].[QuotationsDetail]    Script Date: 4/1/2023 4:06:22 μμ ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[QuotationsDetail](
    [EnquiryNum] [numeric](5, 0) NOT NULL,
    [QuotationNum] [numeric](2, 0) NOT NULL,
    [QuotationLineNum] [int] NOT NULL,
    [EnquiryLineNum] [int] NOT NULL,
    [ItemCode] [varchar](30) NOT NULL,
    [RequestedQuantity] [numeric](9, 3) NOT NULL,
    [QuotedQuantity] [numeric](9, 3) NOT NULL,
    [UnitPrice] [numeric](15, 5) NOT NULL,
    [UnitPriceInd] [int] NOT NULL,
    [Discount] [numeric](5, 2) NOT NULL,
    [PriceListValue] [numeric](12, 2) NOT NULL,
    [NetValue] [numeric](12, 2) NOT NULL,
    [DeliveryDays] [int] NOT NULL,
    [DiscountValue] [numeric](12, 2) NOT NULL,
    [LastUser] [varchar](50) NOT NULL,
    [LastDate] [datetime] NOT NULL,
    [ConversionFactor] [numeric](10, 5) NOT NULL,
    [QuotedUnitOfMeasure] [varchar](3) NOT NULL,
    [RequestedUnitOfMeasure] [varchar](3) NOT NULL,
    [OptionalUnitPrice] [numeric](15, 5) NOT NULL,
    [PostedUnitPrice] [numeric](15, 5) NOT NULL,
    [PumpingRate] [numeric](12, 6) NOT NULL,
    [RequestedOptionalQuantity] [numeric](9, 3) NOT NULL,
    [UnitDiscountAmount] [numeric](12, 2) NOT NULL,
    [ValidToDate] [datetime] NOT NULL,
    [FirstUnitPrice] [numeric](15, 5) NOT NULL,
    [DeliveryMethodInd] [int] NOT NULL,
    [Grade] [varchar](3) NOT NULL,
    [ISOStandard] [varchar](3) NOT NULL,
    [ItemCategory1] [varchar](3) NOT NULL,
    [ItemCategory2] [varchar](3) NOT NULL,
    [RequestedQuantityRangeFrom] [numeric](9, 3) NOT NULL
) ON [PRIMARY]
GO


来源: stackexchange

问:
woocommerce hide class from catalog page if specific category in available
My goal is to hide the display of class from the shop sidebar woocommerce

class name ="widget woocommerce soo-product-filter-widget"  have  2 ids
id="soo-product-filter-10"  & id="soo-product-filter-11"

if the shop page has category A

Hide class "widget woocommerce soo-product-filter-widget" id="soo-product-filter-10"

if the shop page has category C
Hide class "widget woocommerce soo-product-filter-widget" id="soo-product-filter-11"

I tried the below code not working I use CSS inside the PHP code

```<code>   do_action( 'woocommerce_after_shop_loop' );

{
   $categories = array('A','B');
if ( is_product() && has_term( $categories, 'product_cat', $the_id ) )
{
echo '<div id="soo-product-filter-10" class="widget woocommerce soo-product-filter-widget" style="display:none;>';

}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
My goal is to hide the display of class from the shop sidebar woocommerce

class name ="widget woocommerce soo-product-filter-widget"  have  2 ids
id="soo-product-filter-10"  & id="soo-product-filter-11"

if the shop page has category A

Hide class "widget woocommerce soo-product-filter-widget" id="soo-product-filter-10"

if the shop page has category C
Hide class "widget woocommerce soo-product-filter-widget" id="soo-product-filter-11"

I tried the below code not working I use CSS inside the PHP code

   do_action( 'woocommerce_after_shop_loop' );

{
   $categories = array('A','B');
if ( is_product() && has_term( $categories, 'product_cat', $the_id ) )
{
echo '
';

}


问:
Intent was send by android method how to accept in react native and use value in any page
Intent was send by android method how to accept in react native and use value in any page

Intent data value this


问:
~TypeError: Cannot read properties of undefined (reading 'subscribe') ~ shown even after trying to return a mock value
```<code>TypeError: Cannot read properties of undefined (reading 'subscribe')
    at SubmissionDataComponent.getLookupData (http://localhost:9877/_karma_webpack_/webpack:/src/app/ViewModules/shared-components/submission-data/submission-data.component.ts:263:32)
    at SubmissionDataComponent.ngOnInit (http://localhost:9877/_karma_webpack_/webpack:/src/app/ViewModules/shared-components/submission-data/submission-data.component.ts:211:10)
    at callHook (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:2539:1)
    at callHooks (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:2508:1)
    at executeInitAndCheckHooks (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:2459:1)
    at refreshView (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:9586:1)
    at renderComponentOrTemplate (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:9685:1)
    at tickRootContext (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:10916:1)
    at detectChangesInRootView (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:10941:1)
    at RootViewRef.detectChanges (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:22961:1)
</code>```

This is the error that is showing up. I created a mockService for commonUtilty and then returned a mock value which I think is getting subscribed to. My initial thought was since lookup$ property is bonded to the service, if mocking the service and returning a mock value would fix it but the problem still seems to be there. Is there any fix for this problem?

.ts file

```<code>lookupsToBind=['a','b','c']
 lookup$ = this.commonUtilty.initializeLookupList(this.lookupsToBind)
 private getLookupData() {
    this.lookup$['example'].subscribe(lookup => {
      this.currencyLookup = lookup;
      // this.currencyLookup = cur
    });
    this.lookup$['example2'].subscribe(lookup => {
      this.planTypeLookup = lookup;
    });
}
</code>```

.spec.ts file (Edit: annotated the mocked return value)

```<code>import { async, ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormBuilder } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateService } from '@ngx-translate/core';
import { ApiRequestService, ValidationUtilService,CommonUtilty, I18nService, MultiLingualService, LookupDataService, InteractService, WorkqueueService, AppMetadataHandler } from 'app';
import { MetadataService } from 'app/BaseFramework/core/http/metadata.service';
import { NgZorroAntdModule } from 'app/ng-zorro.module';
import { NewBusinessAppSettings } from 'app/ViewModules/Newbusiness/newbusiness-configs/newbusiness-app-settings.config';
import { CustomHookService } from 'app/ViewModules/shared-services/custom-hook/custom-hook.service';
import { lookup } from 'dns';
import { of } from 'rxjs';
import { SubmissionDataComponent } from './submission-data.component';

describe('SubmissionDataComponent', () => {
  let component: SubmissionDataComponent;
  let fixture: ComponentFixture<SubmissionDataComponent>;
    let mockValidationUtilService;
    let mockApiRequestService;
    let mockFormBuilder;
    let mockCommonUtilty;
    let mockI18nService;
    let mockMultiLingualService;
    let mockTranslateService;
    let mockLookupDataService;
    let mockInteractService;
    let mockWorkqueueService;
    let mockAppMetadataHandler;
    let mockNewBusinessAppSettings
    let mockCustomHookService;
    let mockMetadataService;
    // let mock;

  beforeEach(waitForAsync(() => {
    mockValidationUtilService = jasmine.createSpyObj( 'ValidationUtilService',['validateForm','setValidationsForFormControl']);
    mockApiRequestService = jasmine.createSpyObj( 'ApiRequestService',['get']);
    mockFormBuilder = jasmine.createSpyObj( 'FormBuilder',['group']);
    mockCommonUtilty = jasmine.createSpyObj( 'CommonUtility',['serverDOtoUIDODate ','serverDOtoUIDODate','isArrayIterable','initializeLookupList' ]);
    mockCommonUtilty.initializeLookupList.and.returnValue(of([{}])); //--mock return value--
    mockI18nService = jasmine.createSpyObj( 'I18nService',['']);
    mockMultiLingualService=jasmine.createSpyObj('MultiLingualService',['']);
    mockTranslateService=jasmine.createSpyObj('TranslateService',['']);
    mockLookupDataService=jasmine.createSpyObj('LookupDataService',['getLookupData','lookupCacheMap']);
    mockInteractService=jasmine.createSpyObj('InteractService',['']);
    mockWorkqueueService=jasmine.createSpyObj('WorkqueueService',['fetchProducts']);
    mockWorkqueueService.fetchProducts.and.returnValue(of([{}]));
    mockAppMetadataHandler=jasmine.createSpyObj('AppMetadataHandler',['featureFlags']);
    mockNewBusinessAppSettings=jasmine.createSpyObj('NewBusinessAppSettings',['']);
    mockCustomHookService=jasmine.createSpyObj('CustomHookService',['']);
    mockMetadataService=jasmine.createSpyObj('MetadataService',['']);
    TestBed.configureTestingModule({
      declarations: [ SubmissionDataComponent ],
      providers:[
        {provide:ValidationUtilService,useValue:mockValidationUtilService},
        {provide:ApiRequestService,useValue:mockApiRequestService},
        {provide:FormBuilder,useValue:mockFormBuilder},
        {provide:CommonUtilty,useValue:mockCommonUtilty},
        {provide:I18nService,useValue:mockI18nService},
        {provide:MultiLingualService,useValue:mockMultiLingualService},
        {provide:TranslateService,useValue:mockTranslateService},
        {provide:LookupDataService,useValue:mockLookupDataService},
        {provide:InteractService,useValue:mockInteractService},
        {provide:WorkqueueService,useValue:mockWorkqueueService},
        {provide:AppMetadataHandler,useValue:mockAppMetadataHandler},
        {provide:NewBusinessAppSettings,useValue:mockNewBusinessAppSettings},
        {provide:CustomHookService,useValue:mockCustomHookService},
        {provide:MetadataService,useValue:mockMetadataService},
    ],
    imports:[NgZorroAntdModule, RouterTestingModule]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(SubmissionDataComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();

  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});
</code>```

Body:
TypeError: Cannot read properties of undefined (reading 'subscribe')
    at SubmissionDataComponent.getLookupData (http://localhost:9877/_karma_webpack_/webpack:/src/app/ViewModules/shared-components/submission-data/submission-data.component.ts:263:32)
    at SubmissionDataComponent.ngOnInit (http://localhost:9877/_karma_webpack_/webpack:/src/app/ViewModules/shared-components/submission-data/submission-data.component.ts:211:10)
    at callHook (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:2539:1)
    at callHooks (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:2508:1)
    at executeInitAndCheckHooks (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:2459:1)
    at refreshView (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:9586:1)
    at renderComponentOrTemplate (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:9685:1)
    at tickRootContext (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:10916:1)
    at detectChangesInRootView (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:10941:1)
    at RootViewRef.detectChanges (http://localhost:9877/_karma_webpack_/webpack:/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:22961:1)

This is the error that is showing up. I created a mockService for commonUtilty and then returned a mock value which I think is getting subscribed to. My initial thought was since lookup$ property is bonded to the service, if mocking the service and returning a mock value would fix it but the problem still seems to be there. Is there any fix for this problem?

.ts file

lookupsToBind=['a','b','c']
 lookup$ = this.commonUtilty.initializeLookupList(this.lookupsToBind)
 private getLookupData() {
    this.lookup$['example'].subscribe(lookup => {
      this.currencyLookup = lookup;
      // this.currencyLookup = cur
    });
    this.lookup$['example2'].subscribe(lookup => {
      this.planTypeLookup = lookup;
    });
}

.spec.ts file (Edit: annotated the mocked return value)

import { async, ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormBuilder } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateService } from '@ngx-translate/core';
import { ApiRequestService, ValidationUtilService,CommonUtilty, I18nService, MultiLingualService, LookupDataService, InteractService, WorkqueueService, AppMetadataHandler } from 'app';
import { MetadataService } from 'app/BaseFramework/core/http/metadata.service';
import { NgZorroAntdModule } from 'app/ng-zorro.module';
import { NewBusinessAppSettings } from 'app/ViewModules/Newbusiness/newbusiness-configs/newbusiness-app-settings.config';
import { CustomHookService } from 'app/ViewModules/shared-services/custom-hook/custom-hook.service';
import { lookup } from 'dns';
import { of } from 'rxjs';
import { SubmissionDataComponent } from './submission-data.component';

describe('SubmissionDataComponent', () => {
  let component: SubmissionDataComponent;
  let fixture: ComponentFixture<SubmissionDataComponent>;
    let mockValidationUtilService;
    let mockApiRequestService;
    let mockFormBuilder;
    let mockCommonUtilty;
    let mockI18nService;
    let mockMultiLingualService;
    let mockTranslateService;
    let mockLookupDataService;
    let mockInteractService;
    let mockWorkqueueService;
    let mockAppMetadataHandler;
    let mockNewBusinessAppSettings
    let mockCustomHookService;
    let mockMetadataService;
    // let mock;

  beforeEach(waitForAsync(() => {
    mockValidationUtilService = jasmine.createSpyObj( 'ValidationUtilService',['validateForm','setValidationsForFormControl']);
    mockApiRequestService = jasmine.createSpyObj( 'ApiRequestService',['get']);
    mockFormBuilder = jasmine.createSpyObj( 'FormBuilder',['group']);
    mockCommonUtilty = jasmine.createSpyObj( 'CommonUtility',['serverDOtoUIDODate ','serverDOtoUIDODate','isArrayIterable','initializeLookupList' ]);
    mockCommonUtilty.initializeLookupList.and.returnValue(of([{}])); //--mock return value--
    mockI18nService = jasmine.createSpyObj( 'I18nService',['']);
    mockMultiLingualService=jasmine.createSpyObj('MultiLingualService',['']);
    mockTranslateService=jasmine.createSpyObj('TranslateService',['']);
    mockLookupDataService=jasmine.createSpyObj('LookupDataService',['getLookupData','lookupCacheMap']);
    mockInteractService=jasmine.createSpyObj('InteractService',['']);
    mockWorkqueueService=jasmine.createSpyObj('WorkqueueService',['fetchProducts']);
    mockWorkqueueService.fetchProducts.and.returnValue(of([{}]));
    mockAppMetadataHandler=jasmine.createSpyObj('AppMetadataHandler',['featureFlags']);
    mockNewBusinessAppSettings=jasmine.createSpyObj('NewBusinessAppSettings',['']);
    mockCustomHookService=jasmine.createSpyObj('CustomHookService',['']);
    mockMetadataService=jasmine.createSpyObj('MetadataService',['']);
    TestBed.configureTestingModule({
      declarations: [ SubmissionDataComponent ],
      providers:[
        {provide:ValidationUtilService,useValue:mockValidationUtilService},
        {provide:ApiRequestService,useValue:mockApiRequestService},
        {provide:FormBuilder,useValue:mockFormBuilder},
        {provide:CommonUtilty,useValue:mockCommonUtilty},
        {provide:I18nService,useValue:mockI18nService},
        {provide:MultiLingualService,useValue:mockMultiLingualService},
        {provide:TranslateService,useValue:mockTranslateService},
        {provide:LookupDataService,useValue:mockLookupDataService},
        {provide:InteractService,useValue:mockInteractService},
        {provide:WorkqueueService,useValue:mockWorkqueueService},
        {provide:AppMetadataHandler,useValue:mockAppMetadataHandler},
        {provide:NewBusinessAppSettings,useValue:mockNewBusinessAppSettings},
        {provide:CustomHookService,useValue:mockCustomHookService},
        {provide:MetadataService,useValue:mockMetadataService},
    ],
    imports:[NgZorroAntdModule, RouterTestingModule]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(SubmissionDataComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();

  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});


问:
custom admin style on multisite wordpress
I'm trying to call custom file in network admin:

```<code>function admin_css_function(){
   wp_enqueue_style('blaa', '/wp-content/themes/theme-name/assets/css/admin/admin.css', false);
}

if (is_admin()) {
  add_action('admin_enqueue_scripts', 'admin_css_function');
}
</code>```

or

```<code>if (is_network_admin()) {
  add_action('admin_enqueue_scripts', 'admin_css_function');
}
</code>```

But it doesn't work. This example css loads only in a single admin site from the network, but not on the network admin.

Thanks for help,

Body:
I'm trying to call custom file in network admin:

function admin_css_function(){
   wp_enqueue_style('blaa', '/wp-content/themes/theme-name/assets/css/admin/admin.css', false);
}

if (is_admin()) {
  add_action('admin_enqueue_scripts', 'admin_css_function');
}

or

if (is_network_admin()) {
  add_action('admin_enqueue_scripts', 'admin_css_function');
}

But it doesn't work. This example css loads only in a single admin site from the network, but not on the network admin.

Thanks for help,


问:
Can not get API from React hook (useEffect)
I am building e-commerce website. I am having problem with getting product from API to show to user

here is my code

```<code>    import request from '../../utils/axiosInstances'

    const [relatedProducts, setRelatedProducts] = useState([])

    //props.match.params.slug is title of product I want to take
    //in this line code I want to find product data get from API have props.match.params.slug        (title) I choose
    const product = relatedProducts.find((e) => e.Slug === props.match.params.slug);

    useEffect(() => {
        async function fetchData() {
            const {data} = await request.get('/product/getAll');

            setRelatedProducts(data);
        }
        fetchData();
    },[]);
</code>```

.Using useEffect, I want to get product data from API. but useEffect not running . what should I do?

Body:
I am building e-commerce website. I am having problem with getting product from API to show to user

here is my code

    import request from '../../utils/axiosInstances'

    const [relatedProducts, setRelatedProducts] = useState([])

    //props.match.params.slug is title of product I want to take
    //in this line code I want to find product data get from API have props.match.params.slug        (title) I choose
    const product = relatedProducts.find((e) => e.Slug === props.match.params.slug);

    useEffect(() => {
        async function fetchData() {
            const {data} = await request.get('/product/getAll');

            setRelatedProducts(data);
        }
        fetchData();
    },[]);

.Using useEffect, I want to get product data from API. but useEffect not running . what should I do?


问:
Linux - 32bit compiled sem_timedwait example (with small mod) fails on 64 bit when libasan is used
I was having a problem with one application, so i went back to the basics and grabbed the sem_timedwait example from the ubuntu focal online manpages. I modified it slightly to repro the problem.

CASE: sem_post before sem_timedwait
EXPECTED: sem_timedwait to succeed immediately
OBTAINED: sem_timedwait times out

The problem was showing initially on a Docker (WSL disabled) container with Ubuntu 20.04 (g++ 9 multilib)
I then tried from a WSL Debian 9 (g++ 6 multilib) and a WSL Ubuntu 20.04 (g++ 9 multilib) installed fresh from PowerShell
I further installed a full fresh Ubuntu 20.04 VM with g++ 9 multilib on Hyper-V

I also tried apt update && apt upgrade to be sure to be on the latest packages, I also tried at some point to completely remove g++ 9 and all its dependencies and use g++ 10 (which comes with libasan.so.6 instead of libasan.so.5)

Original sem_timedwait example from Ubuntu

Modified version, added a sleep before sem_timedwait so that the call to sem_timedwait happens always after the sem_post. I also added a print of sem_getvalue to verify that the semaphore counter was being incremented correctly to 1.

[File: test_sem.cpp]

```<code>#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <semaphore.h>
#include <time.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>

sem_t sem;

#define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)

static void
handler(int sig)
{
   write(STDOUT_FILENO, "sem_post() from handler\n", 24);
   if (sem_post(&sem) == -1) {
       write(STDERR_FILENO, "sem_post() failed\n", 18);
       _exit(EXIT_FAILURE);
   }
}

int
main(int argc, char *argv[])
{
   struct sigaction sa;
   struct timespec ts;
   int s;

   if (argc != 3) {
       fprintf(stderr, "Usage: %s <alarm-secs> <wait-secs>\n",
               argv[0]);
       exit(EXIT_FAILURE);
   }

   if (sem_init(&sem, 0, 0) == -1)
       handle_error("sem_init");

   /* Establish SIGALRM handler; set alarm timer using argv[1] */

   sa.sa_handler = handler;
   sigemptyset(&sa.sa_mask);
   sa.sa_flags = 0;
   if (sigaction(SIGALRM, &sa, NULL) == -1)
       handle_error("sigaction");

   alarm(atoi(argv[1]));

   /* Calculate relative interval as current time plus
      number of seconds given argv[2] */

   if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
       handle_error("clock_gettime");

   ts.tv_sec += atoi(argv[2]);
   //this is a cancellation point when the alarm goes off
   sleep(atoi(argv[1]) + 2);

   int value = 0;

   sem_getvalue(&sem, &value);

   printf("sem_getvalue(): %d\n", value);

   sleep(2);

   printf("main() about to call sem_timedwait()\n");
   while ((s = sem_timedwait(&sem, &ts)) == -1 && errno == EINTR)
       continue;       /* Restart if interrupted by handler */

   /* Check what happened */

   if (s == -1) {
       if (errno == ETIMEDOUT)
           printf("sem_timedwait() timed out\n");
       else
           perror("sem_timedwait");
   } else
       printf("sem_timedwait() succeeded\n");

   exit((s == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
}
</code>```

to compile this example i used the following

g++ -std=gnu++17 -m32 -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer test_sem.cpp -lstdc++ -lpthread -lasan

to run it, simply ./a.out 2 5

what I obtain is the following unexpected result:

```<code>sem_post() from handler
sem_getvalue(): 1
main() about to call sem_timedwait()
sem_timedwait() timed out
</code>```

the same code compiled WITHOUT the -m32 flag g++ -std=gnu++17 -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer  test_sem.cpp -lstdc++ -lpthread -lasan gives me the following expected result

```<code>sem_post() from handler
sem_getvalue(): 1
main() about to call sem_timedwait()
sem_timedwait() succeeded
</code>```

the same code compiled WITH the -m32 flag but WITHOUT the libasan g++ -std=gnu++17 -m32 test_sem.cpp -lstdc++ -lpthread -lasan gives me the following expected result:

```<code>sem_post() from handler
sem_getvalue(): 1
main() about to call sem_timedwait()
sem_timedwait() succeeded
</code>```

Just for the sake of me I tried also to replace the signal handler code with a second thread to achieve the same sem_post before sem_timedwait and I obtain the same exact result. I further tried also using the non-POSIX-compliant sem_clockwait using both CLOCK_REALTIME and CLOCK_MONOTONIC and I got the same exact result.

I also tried completely removing g++ 9 and installed g++ 10 (which uses libasan.so.6 instead of libasan.so.5)

Right now I dont know if it is something on my side but seems that Docker Ubuntu 20.04 (no WSL), Debian 9 WSL 2, Ubuntu 20.04 WLS 2, and full Hyper-V Virtual Machine with Ubuntu 20.04 are all giving me the same result.

I tried everything I could think of to no avail.

Body:
I was having a problem with one application, so i went back to the basics and grabbed the sem_timedwait example from the ubuntu focal online manpages. I modified it slightly to repro the problem.

CASE: sem_post before sem_timedwait
EXPECTED: sem_timedwait to succeed immediately
OBTAINED: sem_timedwait times out

The problem was showing initially on a Docker (WSL disabled) container with Ubuntu 20.04 (g++ 9 multilib)
I then tried from a WSL Debian 9 (g++ 6 multilib) and a WSL Ubuntu 20.04 (g++ 9 multilib) installed fresh from PowerShell
I further installed a full fresh Ubuntu 20.04 VM with g++ 9 multilib on Hyper-V

I also tried apt update && apt upgrade to be sure to be on the latest packages, I also tried at some point to completely remove g++ 9 and all its dependencies and use g++ 10 (which comes with libasan.so.6 instead of libasan.so.5)

Original sem_timedwait example from Ubuntu

Modified version, added a sleep before sem_timedwait so that the call to sem_timedwait happens always after the sem_post. I also added a print of sem_getvalue to verify that the semaphore counter was being incremented correctly to 1.

[File: test_sem.cpp]

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <semaphore.h>
#include <time.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>

sem_t sem;

#define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)

static void
handler(int sig)
{
   write(STDOUT_FILENO, "sem_post() from handler\n", 24);
   if (sem_post(&sem) == -1) {
       write(STDERR_FILENO, "sem_post() failed\n", 18);
       _exit(EXIT_FAILURE);
   }
}

int
main(int argc, char *argv[])
{
   struct sigaction sa;
   struct timespec ts;
   int s;

   if (argc != 3) {
       fprintf(stderr, "Usage: %s <alarm-secs> <wait-secs>\n",
               argv[0]);
       exit(EXIT_FAILURE);
   }

   if (sem_init(&sem, 0, 0) == -1)
       handle_error("sem_init");

   /* Establish SIGALRM handler; set alarm timer using argv[1] */

   sa.sa_handler = handler;
   sigemptyset(&sa.sa_mask);
   sa.sa_flags = 0;
   if (sigaction(SIGALRM, &sa, NULL) == -1)
       handle_error("sigaction");

   alarm(atoi(argv[1]));

   /* Calculate relative interval as current time plus
      number of seconds given argv[2] */

   if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
       handle_error("clock_gettime");

   ts.tv_sec += atoi(argv[2]);
   //this is a cancellation point when the alarm goes off
   sleep(atoi(argv[1]) + 2);

   int value = 0;

   sem_getvalue(&sem, &value);

   printf("sem_getvalue(): %d\n", value);

   sleep(2);

   printf("main() about to call sem_timedwait()\n");
   while ((s = sem_timedwait(&sem, &ts)) == -1 && errno == EINTR)
       continue;       /* Restart if interrupted by handler */

   /* Check what happened */

   if (s == -1) {
       if (errno == ETIMEDOUT)
           printf("sem_timedwait() timed out\n");
       else
           perror("sem_timedwait");
   } else
       printf("sem_timedwait() succeeded\n");

   exit((s == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
}

to compile this example i used the following

g++ -std=gnu++17 -m32 -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer test_sem.cpp -lstdc++ -lpthread -lasan

to run it, simply ./a.out 2 5

what I obtain is the following unexpected result:

sem_post() from handler
sem_getvalue(): 1
main() about to call sem_timedwait()
sem_timedwait() timed out

the same code compiled WITHOUT the -m32 flag g++ -std=gnu++17 -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer  test_sem.cpp -lstdc++ -lpthread -lasan gives me the following expected result

sem_post() from handler
sem_getvalue(): 1
main() about to call sem_timedwait()
sem_timedwait() succeeded

the same code compiled WITH the -m32 flag but WITHOUT the libasan g++ -std=gnu++17 -m32 test_sem.cpp -lstdc++ -lpthread -lasan gives me the following expected result:

sem_post() from handler
sem_getvalue(): 1
main() about to call sem_timedwait()
sem_timedwait() succeeded

Just for the sake of me I tried also to replace the signal handler code with a second thread to achieve the same sem_post before sem_timedwait and I obtain the same exact result. I further tried also using the non-POSIX-compliant sem_clockwait using both CLOCK_REALTIME and CLOCK_MONOTONIC and I got the same exact result.

I also tried completely removing g++ 9 and installed g++ 10 (which uses libasan.so.6 instead of libasan.so.5)

Right now I dont know if it is something on my side but seems that Docker Ubuntu 20.04 (no WSL), Debian 9 WSL 2, Ubuntu 20.04 WLS 2, and full Hyper-V Virtual Machine with Ubuntu 20.04 are all giving me the same result.

I tried everything I could think of to no avail.


问:
React | Class | Arrow functions binds by "react" build or not
Arrow functions in classes, they bind by react build or not? One guy told me that arrow functions bind by a react build. He said we don't need to bind arrow functions because react did it for us. Is it so or not? But at the same time, we know that we don't need to bind arrow functions due to they don't have their own "this", due to their nature

UPDATE:
It looks like he was right. Take a look at this link (babel mode is spec and force all transforms):

Short example:

```<code>clickEvent = () => {
  console.log('clickEvent');
};
</code>```

Turn into this:

```<code>_defineProperty(
  _assertThisInitialized(_this),
  "clickEvent",
  function () {
    _newArrowCheck(this, _this2);
    console.log("clickEvent");
  }.bind(this)
);
</code>```

But if we don't transpile to es5, then we don't bind it. There is such a part of a code:

```<code>_defineProperty(this, "clickEvent", () => {
  console.log("clickEvent");
});
</code>```

Any ideas, guys?

Body:
Arrow functions in classes, they bind by react build or not? One guy told me that arrow functions bind by a react build. He said we don't need to bind arrow functions because react did it for us. Is it so or not? But at the same time, we know that we don't need to bind arrow functions due to they don't have their own "this", due to their nature

UPDATE:
It looks like he was right. Take a look at this <a href="https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=false&spec=true&loose=false&code_lz=MYGwhgzhAEDCIEtgGt6RgUwB4BcMDsATGAJQzGBwDpYB7AWwAdb8CdoBvAKGmmBYg4ATgFdKtIQApGQ2owgBKTj17QIIxhiky5i3ioC-Klb1BJkAUQBubaAF5okpXYB8y1av74ItEBiogtADmkgDkZijWbKEKANwm0Aax0Ma8QgSEWk7uquk4IkL4jgkAPABGIjg4LNAs8OZ2HDgAFggQVBGWNvg4Bi71KNAAshglAPQVVSwuCQpcRgZAA&debug=false&forceAllTransforms=true&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=true&timeTravel=false&sourceType=module&lineWrap=false&presets=env%2Creact%2Cstage-2&prettier=true&targets=&version=7.20.11&externalPlugins=&assumptions=%7B%7D" rel="nofollow noreferrer">link (babel mode is spec and force all transforms):

Short example:

clickEvent = () => {
  console.log('clickEvent');
};

Turn into this:

_defineProperty(
  _assertThisInitialized(_this),
  "clickEvent",
  function () {
    _newArrowCheck(this, _this2);
    console.log("clickEvent");
  }.bind(this)
);

But if we don't transpile to es5, then we don't bind it. There is such a part of a code:

_defineProperty(this, "clickEvent", () => {
  console.log("clickEvent");
});

Any ideas, guys?


问:
How do I create a PHP WebApi secured with NetworkCredentals?
I have a PHP WebApi. The client is using ASP.Net. The client set the standart that my PHP WebApi must secured with Basic Authentication. But the client request my PHP WebApi with NetworkCredentials. When I set the Basic auth with IIS or PHP the client couldn't access my WebApi.

My question is how can I set the Basic auth which is using NetworkCredentials?
I'm asking to equvalent of it on PHP.


问:
I'm trying to connect my Android App with MYSQL database using jdbc, but the app is crashing
I had checked previous questions on these but not able to find solution. I'm newbie in android. I want to connect directly to mysql database server. For local database sqlite I'm aware of please and don't want to connect with that.

I'm trying this code. I have added dependencies in gradle, added user privilege in Mysql server.

```<code>package com.example.mysqk;

import androidx.appcompat.app.AppCompatActivity;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ConnectToDatabaseTask connectToDatabaseTask = new ConnectToDatabaseTask();
        connectToDatabaseTask.execute();
   //   new ConnectToDatabaseTask().execute();

    }

    private class ConnectToDatabaseTask extends AsyncTask<Void, Void, Void> {
        String url = "jdbc:mysql://xxx.xxx.x.x:3306/world?useSSL=false&allowPublicKeyRetrieval=true";
        String username = "xxx";
        String password = "Xxx";
        Connection connection = null;

        @Override
        protected Void doInBackground(Void... voids) {
            try {
                connection = DriverManager.getConnection(url, username, password);
                Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery("SELECT * FROM employees LIMIT 10 ");
                while (resultSet.next()) {
                    String name = resultSet.getString("name");
                    String population = resultSet.getString("department");
                    System.out.println(name + " " + population);
                }
                resultSet.close();
                statement.close();
                connection.close();
            } catch (SQLException e) {
               Log.e("MyApp", "Error while connecting to database"+ e.getMessage().toString(),e);
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            // You can show a toast message here to indicate that the data has been retrieved successfully
            Toast.makeText(MainActivity.this, "Data retrieved successfully", Toast.LENGTH_SHORT).show();
        }
    }
}

</code>```

While running this code, the app is crashing with the Logs as ,mentioned below

```<code>FATAL EXCEPTION: AsyncTask #1
Process: com.example.mysqk, PID: 26856
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381)
at java.util.concurrent.FutureTask.setException(FutureTask.java:250)
at java.util.concurrent.FutureTask.run(FutureTask.java:269)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/sql/SQLType;
at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:768)
at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1169)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:439)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at java.sql.DriverManager.getConnection(DriverManager.java:580)
at java.sql.DriverManager.getConnection(DriverManager.java:218)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:39)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:29)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[dex file "/data/data/com.example.mysqk/code_cache/.overlay/base.apk/classes3.dex", zip file "/data/app/~~JQTRM_VdBHFyDtKa6sRjtQ==/com.example.mysqk-KqjfMJ8Q8I5NhMVqouUIfA==/base.apk"],nativeLibraryDirectories=[/data/app/~~JQTRM_VdBHFyDtKa6sRjtQ==/com.example.mysqk-KqjfMJ8Q8I5NhMVqouUIfA==/lib/arm64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:768)
at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1169)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:439)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at java.sql.DriverManager.getConnection(DriverManager.java:580)
at java.sql.DriverManager.getConnection(DriverManager.java:218)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:39)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:29)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
--------- beginning of system
</code>```

Body:
I had checked previous questions on these but not able to find solution. I'm newbie in android. I want to connect directly to mysql database server. For local database sqlite I'm aware of please and don't want to connect with that.

I'm trying this code. I have added dependencies in gradle, added user privilege in Mysql server.

package com.example.mysqk;

import androidx.appcompat.app.AppCompatActivity;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ConnectToDatabaseTask connectToDatabaseTask = new ConnectToDatabaseTask();
        connectToDatabaseTask.execute();
   //   new ConnectToDatabaseTask().execute();

    }

    private class ConnectToDatabaseTask extends AsyncTask<Void, Void, Void> {
        String url = "jdbc:mysql://xxx.xxx.x.x:3306/world?useSSL=false&allowPublicKeyRetrieval=true";
        String username = "xxx";
        String password = "Xxx";
        Connection connection = null;

        @Override
        protected Void doInBackground(Void... voids) {
            try {
                connection = DriverManager.getConnection(url, username, password);
                Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery("SELECT * FROM employees LIMIT 10 ");
                while (resultSet.next()) {
                    String name = resultSet.getString("name");
                    String population = resultSet.getString("department");
                    System.out.println(name + " " + population);
                }
                resultSet.close();
                statement.close();
                connection.close();
            } catch (SQLException e) {
               Log.e("MyApp", "Error while connecting to database"+ e.getMessage().toString(),e);
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            // You can show a toast message here to indicate that the data has been retrieved successfully
            Toast.makeText(MainActivity.this, "Data retrieved successfully", Toast.LENGTH_SHORT).show();
        }
    }
}

While running this code, the app is crashing with the Logs as ,mentioned below

FATAL EXCEPTION: AsyncTask #1
Process: com.example.mysqk, PID: 26856
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381)
at java.util.concurrent.FutureTask.setException(FutureTask.java:250)
at java.util.concurrent.FutureTask.run(FutureTask.java:269)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/sql/SQLType;
at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:768)
at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1169)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:439)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at java.sql.DriverManager.getConnection(DriverManager.java:580)
at java.sql.DriverManager.getConnection(DriverManager.java:218)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:39)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:29)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[dex file "/data/data/com.example.mysqk/code_cache/.overlay/base.apk/classes3.dex", zip file "/data/app/~~JQTRM_VdBHFyDtKa6sRjtQ==/com.example.mysqk-KqjfMJ8Q8I5NhMVqouUIfA==/base.apk"],nativeLibraryDirectories=[/data/app/~~JQTRM_VdBHFyDtKa6sRjtQ==/com.example.mysqk-KqjfMJ8Q8I5NhMVqouUIfA==/lib/arm64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.mysql.cj.jdbc.DatabaseMetaData.getInstance(DatabaseMetaData.java:768)
at com.mysql.cj.jdbc.ConnectionImpl.getMetaData(ConnectionImpl.java:1169)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:439)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at java.sql.DriverManager.getConnection(DriverManager.java:580)
at java.sql.DriverManager.getConnection(DriverManager.java:218)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:39)
at com.example.mysqk.MainActivity$ConnectToDatabaseTask.doInBackground(MainActivity.java:29)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
--------- beginning of system


问:
Javascript fetch response blob downloads empty file with full response
I am trying to make a get request and download the response. The response comes with value as seen in the following image but i get an empty file. What should I do in order to download the response?

Network

```<code>fetch(url, {
    method: "get",
    mode: "no-cors",
    headers: {
      accept: "application/json",
    },
    referrerPolicy: "no-referrer",
  })
    .then(res => res.blob())
    .then(res => {
      var url = window.URL.createObjectURL(res)
      var a = document.createElement("a")
      a.href = url
      a.download = fileName
      document.body.appendChild(a)
      a.click()
      a.remove()
    })

</code>```

Body:
I am trying to make a get request and download the response. The response comes with value as seen in the following image but i get an empty file. What should I do in order to download the response?

Network

fetch(url, {
    method: "get",
    mode: "no-cors",
    headers: {
      accept: "application/json",
    },
    referrerPolicy: "no-referrer",
  })
    .then(res => res.blob())
    .then(res => {
      var url = window.URL.createObjectURL(res)
      var a = document.createElement("a")
      a.href = url
      a.download = fileName
      document.body.appendChild(a)
      a.click()
      a.remove()
    })


问:
Error: Data path "" must NOT have additional properties(allowedCommonJsDependencies) when upgrading from Angular 11 to 12
So I just updated the Angular version of my project from 11 to 12 and whenever I try to run the server, I get the following error:

```<code>Warning: Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information.
"BuildCustomWebpackBrowserSchema" schema is using the keyword "id" which its support is deprecated. Use "$id" for schema ID.
Schema validation failed with the following errors:
  Data path "" must NOT have additional properties(allowedCommonJsDependencies).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! smart-med@0.0.0 start: `node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve --disable-host-check "pharmacy"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the smart-med@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
</code>```

I have already tried deleting node_modules and package_lock-json and run npm i but it didn't work. Furthermore the file "allowedCommonJsDependencies" does not exist on angular.json

Package.json:

```<code> "dependencies": {
    "@angular/animations": "~12.2.17",
    "@angular/cdk": "~12.2.13",
    "@angular/cli": "^12.2.18",
    "@angular/common": "~12.2.17",
    "@angular/compiler": "~12.2.17",
    "@angular/core": "~12.2.17",
    "@angular/forms": "~12.2.17",
    "@angular/localize": "^12.2.17",
    "@angular/material": "~12.2.13",
    "@angular/material-moment-adapter": "~12.2.13",
    "@angular/platform-browser": "~12.2.17",
    "@angular/platform-browser-dynamic": "~12.2.17",
    "@angular/router": "~12.2.17",
    "@angular/service-worker": "~12.2.17",
    "@auth0/angular-jwt": "^3.0.1",
    "@auth0/auth0-spa-js": "^1.6.0",
    "@devexpress/analytics-core": "^21.1.5",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@ngxs/logger-plugin": "^3.4.3",
    "@ngxs/router-plugin": "^3.4.3",
    "@ngxs/store": "^3.4.3",
    "@zxing/ngx-scanner": "^3.0.0",
    "adal-angular4": "4.0.12",
    "angular-tree-component": "~8.5.6",
    "angularx-qrcode": "^2.3.7",
    "bootstrap": "^3.4.1",
    "core-js": "~3.6.4",
    "devexpress-reporting-angular": "^21.1.5",
    "devextreme": "^21.1.5",
    "immer": "^2.0.0",
    "keycloak-angular": "^7.3.1",
    "keycloak-js": "^10.0.2",
    "lodash-es": "^4.17.11",
    "lodash.memoize": "^4.1.2",
    "moment-timezone": "^0.5.23",
    "ngx-infinite-scroll": "^9.0.0",
    "ngx-mask": "^9.1.0",
    "ngx-responsive": "^9.0.0",
    "roboto-fontface": "^0.8.0",
    "rxjs": "~6.5.4",
    "tslib": "^2.0.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "~9.0.0",
    "@angular-builders/jest": "~9.0.0",
    "@angular-devkit/build-angular": "~12.2.18",
    "@angular-devkit/build-ng-packagr": "~0.1002.4",
    "@angular-devkit/schematics": "~12.2.18",
    "@angular/compiler-cli": "~12.2.17",
    "@angular/language-service": "~12.2.17",
    "@babel/compat-data": "~7.9.0",
    "@openapitools/openapi-generator-cli": "^2.2.3",
    "@testing-library/angular": "^10.0.2",
    "@testing-library/dom": "^7.24.3",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/user-event": "^12.1.6",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/jest": "~25.1.5",
    "@types/lodash-es": "^4.17.3",
    "@types/moment-timezone": "^0.5.12",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "http-server": "~0.12.1",
    "husky": "^8.0.1",
    "istanbul-combine": "^0.3.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "jest": "~25.2.7",
    "jest-junit": "^10.0.0",
    "lint-staged": "^10.2.11",
    "ng-packagr": "^12.2.7",
    "npm-run-all": "^4.1.5",
    "prettier-stylelint": "^0.4.2",
    "protractor": "~7.0.0",
    "rimraf": "^2.6.3",
    "scss-bundle": "^2.5.1",
    "stylelint": "^9.10.1",
    "stylelint-config-prettier": "^6.0.0",
    "stylelint-config-standard": "^18.2.0",
    "ts-loader": "^5.4.4",
    "ts-node": "~7.0.0",
    "tslint": "~6.1.0",
    "tslint-plugin-prettier": "^2.0.1",
    "typescript": "~4.3.5",
    "webpack-bundle-analyzer": "^3.6.0",
    "yamljs": "^0.3.0",
    "yargs": "^17.1.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  }
</code>```

How can I fix this?

Body:
So I just updated the Angular version of my project from 11 to 12 and whenever I try to run the server, I get the following error:

Warning: Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information.
"BuildCustomWebpackBrowserSchema" schema is using the keyword "id" which its support is deprecated. Use "$id" for schema ID.
Schema validation failed with the following errors:
  Data path "" must NOT have additional properties(allowedCommonJsDependencies).
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! smart-med@0.0.0 start: `node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve --disable-host-check "pharmacy"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the smart-med@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I have already tried deleting node_modules and package_lock-json and run npm i but it didn't work. Furthermore the file "allowedCommonJsDependencies" does not exist on angular.json

Package.json:

 "dependencies": {
    "@angular/animations": "~12.2.17",
    "@angular/cdk": "~12.2.13",
    "@angular/cli": "^12.2.18",
    "@angular/common": "~12.2.17",
    "@angular/compiler": "~12.2.17",
    "@angular/core": "~12.2.17",
    "@angular/forms": "~12.2.17",
    "@angular/localize": "^12.2.17",
    "@angular/material": "~12.2.13",
    "@angular/material-moment-adapter": "~12.2.13",
    "@angular/platform-browser": "~12.2.17",
    "@angular/platform-browser-dynamic": "~12.2.17",
    "@angular/router": "~12.2.17",
    "@angular/service-worker": "~12.2.17",
    "@auth0/angular-jwt": "^3.0.1",
    "@auth0/auth0-spa-js": "^1.6.0",
    "@devexpress/analytics-core": "^21.1.5",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@ngxs/logger-plugin": "^3.4.3",
    "@ngxs/router-plugin": "^3.4.3",
    "@ngxs/store": "^3.4.3",
    "@zxing/ngx-scanner": "^3.0.0",
    "adal-angular4": "4.0.12",
    "angular-tree-component": "~8.5.6",
    "angularx-qrcode": "^2.3.7",
    "bootstrap": "^3.4.1",
    "core-js": "~3.6.4",
    "devexpress-reporting-angular": "^21.1.5",
    "devextreme": "^21.1.5",
    "immer": "^2.0.0",
    "keycloak-angular": "^7.3.1",
    "keycloak-js": "^10.0.2",
    "lodash-es": "^4.17.11",
    "lodash.memoize": "^4.1.2",
    "moment-timezone": "^0.5.23",
    "ngx-infinite-scroll": "^9.0.0",
    "ngx-mask": "^9.1.0",
    "ngx-responsive": "^9.0.0",
    "roboto-fontface": "^0.8.0",
    "rxjs": "~6.5.4",
    "tslib": "^2.0.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "~9.0.0",
    "@angular-builders/jest": "~9.0.0",
    "@angular-devkit/build-angular": "~12.2.18",
    "@angular-devkit/build-ng-packagr": "~0.1002.4",
    "@angular-devkit/schematics": "~12.2.18",
    "@angular/compiler-cli": "~12.2.17",
    "@angular/language-service": "~12.2.17",
    "@babel/compat-data": "~7.9.0",
    "@openapitools/openapi-generator-cli": "^2.2.3",
    "@testing-library/angular": "^10.0.2",
    "@testing-library/dom": "^7.24.3",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/user-event": "^12.1.6",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/jest": "~25.1.5",
    "@types/lodash-es": "^4.17.3",
    "@types/moment-timezone": "^0.5.12",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "http-server": "~0.12.1",
    "husky": "^8.0.1",
    "istanbul-combine": "^0.3.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "jest": "~25.2.7",
    "jest-junit": "^10.0.0",
    "lint-staged": "^10.2.11",
    "ng-packagr": "^12.2.7",
    "npm-run-all": "^4.1.5",
    "prettier-stylelint": "^0.4.2",
    "protractor": "~7.0.0",
    "rimraf": "^2.6.3",
    "scss-bundle": "^2.5.1",
    "stylelint": "^9.10.1",
    "stylelint-config-prettier": "^6.0.0",
    "stylelint-config-standard": "^18.2.0",
    "ts-loader": "^5.4.4",
    "ts-node": "~7.0.0",
    "tslint": "~6.1.0",
    "tslint-plugin-prettier": "^2.0.1",
    "typescript": "~4.3.5",
    "webpack-bundle-analyzer": "^3.6.0",
    "yamljs": "^0.3.0",
    "yargs": "^17.1.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  }

How can I fix this?


问:
Unable to send or receive emails when connected with cloudflare
I am unable to send or receive emails from my hanco.pk domain, I am also attaching the snapshot of the problem.

I send emails from the my shared hosting on which the website is also deployed.

image

Click here to view snapshot


问:
Hello World from BIOS not working in VMWare
I'm starting learning how to make a Hello World in a Boot Loader in assembly.
I have a problem because for some reason when I start of the floppy disk in "BOCHS" he can show me the Hello World. But when I try in "VMware" he identifies the Boot Loader but don't show anything.

In VMWare, I can already print a character on the screen but a entire string i can't.

```<code>[org 0x7c00]

mov bp, 0x7c00
mov sp, bp

mov bx, TestString
call PrintString

jmp $

PrintString:
    mov ah, 0x0e
    .Loop:
    cmp [bx], byte 0
    je .Exit
        mov al, [bx]
        int 0x10
        inc bx
        jmp .Loop
    .Exit:
    ret

TestString:
    db 'Hello World',0

times 510-($-$$) db 0

dw 0xaa55
</code>```

Body:
I'm starting learning how to make a Hello World in a Boot Loader in assembly.
I have a problem because for some reason when I start of the floppy disk in "BOCHS" he can show me the Hello World. But when I try in "VMware" he identifies the Boot Loader but don't show anything.

In VMWare, I can already print a character on the screen but a entire string i can't.

[org 0x7c00]

mov bp, 0x7c00
mov sp, bp

mov bx, TestString
call PrintString

jmp $

PrintString:
    mov ah, 0x0e
    .Loop:
    cmp [bx], byte 0
    je .Exit
        mov al, [bx]
        int 0x10
        inc bx
        jmp .Loop
    .Exit:
    ret

TestString:
    db 'Hello World',0

times 510-($-$$) db 0

dw 0xaa55


问:
How to convert code from node.js to JavaScript
I need to rewrite an Api call. The original call is write in Node.js and i'm trying to rewrite the call in Javascript.
Node.js code:

```<code>const http = require("https");

const options = {
  "method": "POST",
  "hostname": "test.com",
  "port": null,
  "path": "/path",
  "headers": {
    "Authorization": "Token token-value"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  data: {
    'Id': 'id value'
  },
  responsive: false
}));
req.end();
</code>```

I'm trying in this way:

```<code>const url='https://test.com/path'

    const bodyContent = {
        data: {
            'Id': 'id value'
        },
        responsive: false
    };
    const options = {
        "method":"POST",
        "port":null,
        "headers": {
            "Authorization":"Token token-value"
        },
        body: JSON.stringify(bodyContent)
    }
    const res = await fetch(url, options)
</code>```

I expected a positive response but the response keep saying "Missing value of required parameter 'Id'"

Body:
I need to rewrite an Api call. The original call is write in Node.js and i'm trying to rewrite the call in Javascript.
Node.js code:

const http = require("https");

const options = {
  "method": "POST",
  "hostname": "test.com",
  "port": null,
  "path": "/path",
  "headers": {
    "Authorization": "Token token-value"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  data: {
    'Id': 'id value'
  },
  responsive: false
}));
req.end();

I'm trying in this way:

const url='https://test.com/path'

    const bodyContent = {
        data: {
            'Id': 'id value'
        },
        responsive: false
    };
    const options = {
        "method":"POST",
        "port":null,
        "headers": {
            "Authorization":"Token token-value"
        },
        body: JSON.stringify(bodyContent)
    }
    const res = await fetch(url, options)

I expected a positive response but the response keep saying "Missing value of required parameter 'Id'"


问:
How to permutation index view for weights and input nodes for a layer? TensorFlow/numpy
Let's say I have a permutation index:

pa = [2,0,4,3,1,5] # node permutation index
pw = [0,3,4,1,2,5] # weight permutation index
a = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
w = np.array([0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
```
<p>I want semantics that resemble this:</p>
```ap = a[pa] # [0.3, 0.1, 0.5, 0.4, 0.2, 0.6]
```
<p>except that instead of a copy, I want a view. That is, I want:</p>
```ap[0] = 0.123
assert(a[2] == 0.123)
```

I don't think numpy has this concept. But wondering if there is a way to make this happen in  TensorFlow.

I want this concept in TensorFlow for arbitrary weight sharing. I need the weight sharing to be pre-defined by an arbitrary index because each target node will have a different ordering of the same set of weights, and apply these weights to an arbitrary subset of the input layer. The weight must be referenced through the permutation so that back-propagation will modify all instances of the same weight.

Body:
Let's say I have a permutation index:

pa = [2,0,4,3,1,5] # node permutation index
pw = [0,3,4,1,2,5] # weight permutation index
a = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
w = np.array([0.7, 0.6, 0.5, 0.4, 0.3, 0.2]

I want semantics that resemble this:

ap = a[pa] # [0.3, 0.1, 0.5, 0.4, 0.2, 0.6]

except that instead of a copy, I want a view. That is, I want:

ap[0] = 0.123
assert(a[2] == 0.123)

I don't think numpy has this concept. But wondering if there is a way to make this happen in  TensorFlow.

I want this concept in TensorFlow for arbitrary weight sharing. I need the weight sharing to be pre-defined by an arbitrary index because each target node will have a different ordering of the same set of weights, and apply these weights to an arbitrary subset of the input layer. The weight must be referenced through the permutation so that back-propagation will modify all instances of the same weight.


问:
Tool with macros blocked by security / ASR rules - how to fix?
I have an Excel tool (xlsm file) I'm spreading to users, they download the file from our site and after that can use it. In a nutshell:

the tool has its own menu bar and a bunch of macros that e.g. do calculations, pull in data from an API, etc.

I use Unviewable to hide the code from the users

I sign the VBA project with a certificate

Last month, an user reported having issues running the tool and passed it on to his IT department. They came back with several ASR rules they had to switch off to make the tool work (all macros etc). They were reluctant to do so because of "general virus threats". These were the 3 rules they had to switch off:
Attack surface reduction (ASR) rules reference

Block Win32 API calls from Office macro

Block execution of potentially obfuscated scripts (js/vbs/ps)

Block JavaScript or VBScript from launching downloaded executable content
https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/attack-surface-reduction-rules-reference?view=o365-worldwide

So my question 1 is: I think the obfuscated scripts line has to do with Unviewable, but have no idea what can cause the other 2 items in that list. Does anyone have an idea? Maybe some references in my project?
And the second question: as I signed my tool with a certificate, wouldn't that for that IT department be a fix - just allow macros that are signed (and add my certificate to the trusted publishers in Excel)?


问:
How do I make my button go away and How do i implement my code after a button is pressed?
Im just starting out and have made a timer and stuff succesfully but now wanted to make a GUI since its not that straight forward and I want to have a good project.
I want to know how to remove a button after I press it and how to start my timer code after i take an entry for how long I want my timer to last. Here is my timer code:

```<code>import time
from playsound import playsound
a = int(input("How long would you like your time to be(In Minutes): "))
with alive_bar() as bar:
    b = a * 60
    time.sleep(b)
    bar()
playsound(r"C:\Users\shavi\Music\mixkit-arcade-retro-game-over-213.wav")
print("done"
</code>```

and here is my gui code

```<code>from tkinter import *
#First creating my window
timer = Tk()

#My window name and dimension
timer.title("My Timer")
timer.geometry('400x200')
#My Command
def clicked():
    lbl.configure(text = "Starting Timer")

#Label text
lbl = Label(timer, text ="Start a timer?")
lbl.grid()
#Button
button = Button(timer, text = "Yes",
                command=clicked,)
button.grid(column=2, row=0)
#Running
timer.mainloop()
</code>```

I tried using the .after but cant figure it out pleae help me figure this out

Body:
Im just starting out and have made a timer and stuff succesfully but now wanted to make a GUI since its not that straight forward and I want to have a good project.
I want to know how to remove a button after I press it and how to start my timer code after i take an entry for how long I want my timer to last. Here is my timer code:

import time
from playsound import playsound
a = int(input("How long would you like your time to be(In Minutes): "))
with alive_bar() as bar:
    b = a * 60
    time.sleep(b)
    bar()
playsound(r"C:\Users\shavi\Music\mixkit-arcade-retro-game-over-213.wav")
print("done"

and here is my gui code

from tkinter import *
#First creating my window
timer = Tk()

#My window name and dimension
timer.title("My Timer")
timer.geometry('400x200')
#My Command
def clicked():
    lbl.configure(text = "Starting Timer")

#Label text
lbl = Label(timer, text ="Start a timer?")
lbl.grid()
#Button
button = Button(timer, text = "Yes",
                command=clicked,)
button.grid(column=2, row=0)
#Running
timer.mainloop()

I tried using the .after but cant figure it out pleae help me figure this out


问:
Use some pytest parameters for multiple test cases
I'm trying to use a single parameter of a test case in multiple tests to avoid hundreds of duplicate lines of code. My current approach is over a class that wraps the affected functions. This leaves me with two "parametrize" annotations. So my question is, if there is any possibility to configure those to only combine "pytest.params" with the same id and ignore all other combinations

```<code>@pytest.mark.parametrize(
    "foo",
    [
        pytest.param(
            3,
            id="SOME_ID",
        ),
        pytest.param(
            4,
            id="ANOTHER_ID",
        ),
    ]
)
class TestHandler:
    @pytest.mark.parametrize(
        "bar, expected",
        [
            pytest.param(
                2,
                6,
                id="SOME_ID",
            ),
            pytest.param(
                5,
                20,
                id="ANOTHER_ID",
            ),
        ],
    )
    def test_multiply_function(self, foo, bar, expected):
        resp = foo * bar

        assert resp == expected, "test_multiply_function failed"

    @pytest.mark.parametrize(
        "bar, expected",
        [
            pytest.param(
                2,
                5,
                id="SOME_ID",
            ),
            pytest.param(
                5,
                9,
                id="ANOTHER_ID",
            ),
        ],
    )
    def test_add_function(self, foo, bar, expected):
        resp = foo + bar

        assert resp == expected, "test_add_function failed"
</code>```

E.g. for this code I'd like to just get the tests

SOME_ID-SOME_ID

ANOTHER_ID-ANOTHER_ID

and exclude

ANOTHER_ID-SOME_ID

SOME_ID-ANOTHER_ID

Body:
I'm trying to use a single parameter of a test case in multiple tests to avoid hundreds of duplicate lines of code. My current approach is over a class that wraps the affected functions. This leaves me with two "parametrize" annotations. So my question is, if there is any possibility to configure those to only combine "pytest.params" with the same id and ignore all other combinations

@pytest.mark.parametrize(
    "foo",
    [
        pytest.param(
            3,
            id="SOME_ID",
        ),
        pytest.param(
            4,
            id="ANOTHER_ID",
        ),
    ]
)
class TestHandler:
    @pytest.mark.parametrize(
        "bar, expected",
        [
            pytest.param(
                2,
                6,
                id="SOME_ID",
            ),
            pytest.param(
                5,
                20,
                id="ANOTHER_ID",
            ),
        ],
    )
    def test_multiply_function(self, foo, bar, expected):
        resp = foo * bar

        assert resp == expected, "test_multiply_function failed"

    @pytest.mark.parametrize(
        "bar, expected",
        [
            pytest.param(
                2,
                5,
                id="SOME_ID",
            ),
            pytest.param(
                5,
                9,
                id="ANOTHER_ID",
            ),
        ],
    )
    def test_add_function(self, foo, bar, expected):
        resp = foo + bar

        assert resp == expected, "test_add_function failed"

E.g. for this code I'd like to just get the tests

SOME_ID-SOME_ID

ANOTHER_ID-ANOTHER_ID

and exclude

ANOTHER_ID-SOME_ID

SOME_ID-ANOTHER_ID