问:
datetime vs. value plot gives strange order on values-axis
Given data of the form

```<code>Wed May 27 18:00:02 2020    2029.63
Wed May 27 19:00:04 2020    2029.63
Wed May 27 20:00:06 2020    2029.63
Wed May 27 21:00:04 2020    2029.63
Wed May 27 22:00:03 2020    2029.63
Wed May 27 23:00:03 2020    1663.70
Thu May 28 00:00:05 2020    1663.70
Thu May 28 01:00:04 2020    1663.70
Thu May 28 02:00:03 2020    1663.70
Thu May 28 13:00:04 2020    2029.63
Thu May 28 14:00:06 2020    2029.63
Thu May 28 15:00:04 2020    2029.63
Thu May 28 16:00:02 2020    2029.63
Thu May 28 17:00:06 2020    2029.63
Thu May 28 18:00:03 2020    2029.63
Thu May 28 19:00:09 2020    2029.63
</code>```

I'm trying to create a plot date/time vs. value. My approach for this was very straight forward (although a bit hacky...)

```<code>import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import datetime

data = open("data.txt").read().split("\n")
data = [x for x in data if x!='']

date = []
values = []

for line in data:
    index = line.find("\t")
    time_str = str(line[4:index])
    date_time_obj = datetime.datetime.strptime(time_str, '%b  %d %H:%M:%S %Y')
    date.append(date_time_obj)
    values.append(line[index+1:])

#dates = mpl.dates.date2num(date)
dates = [x.date() for x in date]

dates_sorted, values_sorted = zip(*sorted(zip(dates, values)))

fig = plt.figure()
plt.plot(dates_sorted, values_sorted, 'ro')
fig.autofmt_xdate()
plt.show()
</code>```

This produces a plot, but unfortunately the value-axis is not sorted correctly. To fix this I tried the suggestion in this post, but that also didn't help.

Body:
Given data of the form

Wed May 27 18:00:02 2020    2029.63
Wed May 27 19:00:04 2020    2029.63
Wed May 27 20:00:06 2020    2029.63
Wed May 27 21:00:04 2020    2029.63
Wed May 27 22:00:03 2020    2029.63
Wed May 27 23:00:03 2020    1663.70
Thu May 28 00:00:05 2020    1663.70
Thu May 28 01:00:04 2020    1663.70
Thu May 28 02:00:03 2020    1663.70
Thu May 28 13:00:04 2020    2029.63
Thu May 28 14:00:06 2020    2029.63
Thu May 28 15:00:04 2020    2029.63
Thu May 28 16:00:02 2020    2029.63
Thu May 28 17:00:06 2020    2029.63
Thu May 28 18:00:03 2020    2029.63
Thu May 28 19:00:09 2020    2029.63

I'm trying to create a plot date/time vs. value. My approach for this was very straight forward (although a bit hacky...)

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import datetime

data = open("data.txt").read().split("\n")
data = [x for x in data if x!='']

date = []
values = []

for line in data:
    index = line.find("\t")
    time_str = str(line[4:index])
    date_time_obj = datetime.datetime.strptime(time_str, '%b  %d %H:%M:%S %Y')
    date.append(date_time_obj)
    values.append(line[index+1:])

#dates = mpl.dates.date2num(date)
dates = [x.date() for x in date]

dates_sorted, values_sorted = zip(*sorted(zip(dates, values)))

fig = plt.figure()
plt.plot(dates_sorted, values_sorted, 'ro')
fig.autofmt_xdate()
plt.show()

This produces a plot, but unfortunately the value-axis is not sorted correctly. To fix this I tried the suggestion in this post, but that also didn't help.

Body:
It might save you some time to have a look at pandas.

import io
import pandas as pd

s = """Timestamp,Value
Wed May 27 18:00:02 2020,2029.63
Wed May 27 19:00:04 2020,2029.63
Wed May 27 20:00:06 2020,2029.63
Wed May 27 21:00:04 2020,2029.63
Wed May 27 22:00:03 2020,2029.63
Wed May 27 23:00:03 2020,1663.70
Thu May 28 00:00:05 2020,1663.70
Thu May 28 01:00:04 2020,1663.70
Thu May 28 02:00:03 2020,1663.70
Thu May 28 13:00:04 2020,2029.63
Thu May 28 14:00:06 2020,2029.63
Thu May 28 15:00:04 2020,2029.63
Thu May 28 16:00:02 2020,2029.63
Thu May 28 17:00:06 2020,2029.63
Thu May 28 18:00:03 2020,2029.63
Thu May 28 19:00:09 2020,2029.63"""

df = pd.read_csv(io.StringIO(s), parse_dates=['Timestamp'])

df.plot(x='Timestamp', y='Value')

Just replace the io.String with the path to the file with your data. Find more info on pd.DataFrame.plot here.

Exemplary output:


来源: stackexchange

问:
Check if an element exists with Selenium, JavaScript, and Node.js
I'm trying to check if an element exists before I can execute this line:

driver.findElement(webdriver.By.id('test'));

This throws an error "no such element" if the id test doesn't exist in the document, even in a try-block.
I've found answers for Java, where you can check if the size is 0, but in Node.js this throws an error before I can check the size:

throw error; ^ NoSuchElementError: no such element

答:
Here the summary for newbies like me ;-)

As described here:

For consistency with the other Selenium language bindings, WebDriver#isElementPresent() and WebElement#isElementPresent() have been deprecated. These methods will be removed in v3.0. Use the findElements command to test for the presence of an element:

```<code>  driver.findElements(By.css('.foo')).then(found => !!found.length);
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Here the summary for newbies like me ;-)

As described here:

For consistency with the other Selenium language bindings, WebDriver#isElementPresent() and WebElement#isElementPresent() have been deprecated. These methods will be removed in v3.0. Use the findElements command to test for the presence of an element:

  driver.findElements(By.css('.foo')).then(found => !!found.length);


问:
How to Limit Query Result to Organizations with 2 or More Accounts Associated with it
I have the following code which returns results for sub-organizations (of parent organizations) that do not have an address associated with them. However, this returns 2,000+ rows, many of which have 0 or 1 accounts associated with them.

What I'd like to do is edit the query to only show results where the number of accounts associated with the sub-organization is 2 or more.

In our database, the primary key relating the accounts and organizations tables in a JOIN statement is:

```<code>organizations.id = accounts.organization_id
</code>```

and the primary key on the accounts table is accounts.id

I have tried to figure this out to no avail. If someone could please help provide a solution to limit the results to only sub-organizations with the number of accounts equal to or greater than 2.

```<code>SELECT DISTINCT
  organizations.id AS org_id,
  organizations.name AS org_name,
  parent.id AS parent_org_id,
  parent.name AS parent_org_name
FROM
    organizations
  INNER JOIN organizations parent
    ON
    organizations.parent_org_id = parent.id
  LEFT JOIN addresses sub_addresses
    ON
    sub_addresses.addressable_type = 'Organization'
    AND sub_addresses.is_current = 1
    AND sub_addresses.addressable_id = organizations.id
  LEFT JOIN addresses p_addresses
    ON
    p_addresses.addressable_type = 'Organization'
    AND p_addresses.is_current = 1
    AND p_addresses.addressable_id = parent.id
WHERE
  sub_addresses.id is null
ORDER BY
  parent.name,
  organizations.name
</code>```

答:
You need one more join or subquery in where clause which will give you organizations with at least 2 or more accounts. Below is the join version.</p>

```<code>FROM organizations p
INNER JOIN organizations o ON o.parent_org_id = p.id
INNER JOIN (Select a.organization_id,Count(distinct a.id) as num_of_accounts
            FROM accounts a
            GROUP BY a.organization_id
            HAVING Count(distinct a.id) >= 2) accnts ON accnts.organization_id = o.id
</code>```

Body:
I have the following code which returns results for sub-organizations (of parent organizations) that do not have an address associated with them. However, this returns 2,000+ rows, many of which have 0 or 1 accounts associated with them.

What I'd like to do is edit the query to only show results where the number of accounts associated with the sub-organization is 2 or more.

In our database, the primary key relating the accounts and organizations tables in a JOIN statement is:

organizations.id = accounts.organization_id

and the primary key on the accounts table is accounts.id

I have tried to figure this out to no avail. If someone could please help provide a solution to limit the results to only sub-organizations with the number of accounts equal to or greater than 2.

SELECT DISTINCT
  organizations.id AS org_id,
  organizations.name AS org_name,
  parent.id AS parent_org_id,
  parent.name AS parent_org_name
FROM
    organizations
  INNER JOIN organizations parent
    ON
    organizations.parent_org_id = parent.id
  LEFT JOIN addresses sub_addresses
    ON
    sub_addresses.addressable_type = 'Organization'
    AND sub_addresses.is_current = 1
    AND sub_addresses.addressable_id = organizations.id
  LEFT JOIN addresses p_addresses
    ON
    p_addresses.addressable_type = 'Organization'
    AND p_addresses.is_current = 1
    AND p_addresses.addressable_id = parent.id
WHERE
  sub_addresses.id is null
ORDER BY
  parent.name,
  organizations.name

Body:
You need one more join or subquery in where clause which will give you organizations with at least 2 or more accounts. Below is the join version.

FROM organizations p
INNER JOIN organizations o ON o.parent_org_id = p.id
INNER JOIN (Select a.organization_id,Count(distinct a.id) as num_of_accounts
            FROM accounts a
            GROUP BY a.organization_id
            HAVING Count(distinct a.id) >= 2) accnts ON accnts.organization_id = o.id


问:
MS Access: Filter/Search records in a form using main form and subform criteria from user input
I'm currently working on a database which is rather complex, at least for my ability level. Essentially it is a database of projects, structures and contacts. Within these structures there are sub structures each with unique attributes.

Projects, structures and contacts are joined together in one main control form with a tabbed pane. And within these panes are the forms which have multiple subforms. I am trying to write a search function which I can place on each form that will allow the user to select multiple criteria to filter results. However, some of the criteria or on the forms and other criteria are drawn from multiple subforms and to top it off some fields in the subforms have multiple entries. I understand that this may not sound like very sound database design, but I've been told to adhere to a specific structure and layout which I am not skilled enough to work through.

I've been looking through allen browne's website regarding search criteria, but that is only one a single form. I've attempted to piece together the Subquery tutorial page as well, but to no avail. Essentially, I'm wondering if it is at all possible to filter information say.. the type of structure which is on the main form and then for example.. a range of numbers such as length which exists in a subform and an object proximity which exists in another subform, and have it so that the main form only displays records which fulfill that combination of criteria from the subforms and main form.

My apologies if this is vague, and if it'll help I can post up the general framework I have for my database thus far. Thank you for any assistance you can provide.

EDIT--- Added screenshots for more information
I can't post images since my rep is below 10 but hopefully I can include links

http://img829.imageshack.us/img829/1594/99258898.png
 http://img40.imageshack.us/img40/2186/27578829.png

It's difficult to see here, but within the combo boxes some are multi-valued lists.  And the combo box on the first image to the right, is switched based on the selection of Type from the upper left combo box, which has different attributes.  Ideally I'd like to be able to search through primary forms and subforms. and result in records which only fulfill all the user inputted data.   Right now I've tried using filters, one for each criteria, but all that does is blank out information in the subforms which doesn't correspond to the filter criteria.

答:
Do you have any screenshots you could possibly post?

This sounds to me like a larger design issue, perhaps mostly in your UI but possibly in your table structure as well. One my own principles I try to follow is to limit how many things a single screen/form does or shows. What your describing sounds quite confusing to me and I think the average user could easily be overwhelmed by it.

Normally subforms are the result of a main form. That is, they contain child records and are linked to records in the main form via the child records foreign key and the main forms primary key. It isn't that there aren't other ways to design your forms but this is considered "normal" or "standard" design. Your description indicates that filtering the main form is determine by filters set on the subforms. I guess I can't think of any problem that could possibly need solving through something as confusing and clumsy as this. I leave the possibility open that I haven't encountered something as difficult or complex as you're dealing with.

I think you may have some difficulty getting better help here as your question is really better suited to a discussion forum such as UtterAccess.com. You may consider posting a copy of your database on such a site so the users can review your design and possibly recommend a more solid and standard approach.

Edit1:

1) Based on your screenshots, I think you're trying to do too many things in one form. I would normally take each of your top tabs (Projects, Structures, Companies, Contacts) and make each of those their own form. Access 2007 and 2010 allow you to use a tabbed interface natively and I can't think of any real benefit to using the tabbed container control to develop your own tabbed interface.

2) It's my opinion that searches should normally be performed in a single main form that has a single listbox, datasheet view subform, or continuous forms subform. Whichever of these three you choose is not overly important. After performing the search, the user should be able to click in the resulting records in the listbox or subform to select that record and move to it on a details view form similar to what you've already built here. It might take several different search screens to allow your users to search all of the different ways you'd like them to. For example, you might build a screen to search projects, one to search structures, another to search contacts, and a fourth one to search companies. It should be possible to combine some of these in a query and allow the user to search by more than one criteria but it can get confusing if you try to allow them to search too many fields at once, especially if the fields they are searching are in separate tables. For example, if you build a query that shows all projects, structures, and companies together and use this as the recordsource for a datasheet subform, this could allow users to search by project, structure, or company. However, if a project has 10 structures that project will be listed 10 times in the query/form which could confuse users if they are thinking about searching by project. If they are instead searching by structure, it will make perfect sense to them that there are 10 entries for the same project since they'll see 10 different structures.

My basic recommendation is, be careful about trying to build too many functions into a single form. There are some types of tasks or sets of data that do require complex forms with multiple subforms and lots of controls, but in general you want to try to avoid this. It's better to build each form with a very focused task and just simply build more forms to accomplish all of the necessary tasks. Of course, you can take this approach too far as well but you do really need to try to minimize complexity to save yourself from headaches in the future.

As far as filtering based on multiple criteria, I'll see if I can find any good examples or maybe put one together and make it available. It isn't so difficult but it is a multi-step process to build and experience has led me to a general design that I'm happy with and that works almost flawlessly in every possible situation.

Edit2:

Here's how you can create a multi-field filter/search.

1) Build your query. Include all tables and fields which need to viewed by the user or searched on by the user. You can include fields here that will be searched on but not viewable by the user, although that could be confusing to the user. Save your query and give it an appropriate name. Be sure to include your id/primary key fields since those will be needed in step number 4.

2) Now Highlight your query in the navigation pane, go to the top menu and choose Create > More Forms > Datasheet (I'm using Access 2007). Allow access to create and show you a datasheet form which we will use as a subform. Save this and give it an appropriate name like subformProjectSearch of fsubProjectSearch.

3) Get the design view for the new form you just created. Change the properties to disallow additions, deletions, and edits unless you'd really like to allow any of these operations. In general, I don't allow any data entry in these kinds of search forms unless I have it well planned out and tested.

4) Go to the code for this form and add code to popup relevant detail forms on double click. For example, in the projectid or project name field, allow your user to double click to bring up the project details form. Add double click routines to any other textbox where the user might want to pop up a structure, company or contact, assuming you've chosen to include one or more of those in your query. You're code will look something like DoCmd.OpenForm "ProjectDetails", , , "ProjectID = " & Me!ProjectID Now save your form again and close it.

5) Now create a new blank form and add your first form as a subform. Leave room at the top to add controls for filtering. This form does not need to have any recordsource set.

Diversion: I usually take one of two different approaches to filtering. Number one is to give the user one textbox that they can type into. I think do fuzzy searches in a whole bunch of different fields using the data they've typed in. It's a perfectly awful approach performance wise, especially once the database grows past about 20,000 records. It can also lead to some confusion since too many results will likely come up for a short generic search. If they only type in the letter s and search for it they will likely get almost all records.

The second approach I use is probably more common. Give them a different textbox for every field they are likely to want to search by. You an also make it a checkbox or combobox if that fits the field they are searching on. These will not be bound controls. This allows the user to get fairly specific and it also is most likely to return the exact results they are looking for. As far as the code goes, I don't think that one approach is really much simpler than the other. With either approach that I've listed here you really need to check the type of data they've entered before you put it in your filter statement for certain fields. For example, you wouldn't want to try to filter a date field using their non-date, text input. On this second approach you can possibly eliminate more of this problem by using validation rules, input masks, or by setting the textboxes format property. Combos also help to prohibit incorrect data from being entered.

Yet a third option is somewhat of a hybrid approach. You can create one text box that searches on more than one field but not necessarily on all fields. For example, you might create one textbox that will be used to search on Company, FirstName, or LastName. You can create as many of these textboxes as you need. How the input in these textboxes gets used will be totally determined by you in your VBA code.

6) Now that you've decided which approach you want to take, you can go ahead and add your controls. Give them appropriate names and labels.

7) Now it's time to create the function that will build the filtering statement. Use one of the two ideas I listed below. Make sure you run these when the user presses your search button or on the controls AfterUpdate event.

```<code>    Private Sub txtSearch_AfterUpadate()
         Call FilterSubformOption1
    End Sub

Private Sub FilterSubformOption1()
    Dim strFilter as String
    Dim sSearch as String
    sSearch = Replace(Nz(Me.txtSearch, ""), "'", "''")
    If sSearch <> "" Then
        If IsDate(sSearch) = False Then
            strFilter = "(ProjectName LIKE '*" & sSearch & "*' OR "
            strFilter = strFilter & "StructureName LIKE '*" & sSearch & "*' OR "
            strFilter = strFilter & "CompanyName LIKE '*" & sSearch & "*')"
        Else
            strFilter = "ProjectDate = #" & CDate(sSearch) & "#"
        End If
    End If
    If strFilter <> "" Then
        Me.fsubProjectSearch.Form.Filter = strFilter
        Me.fsubProjectSearch.Form.FilterOn = True
    Else
        Me.fsubProjectSearch.Form.Filter = ""
        Me.fsubProjectSearch.Form.FilterOn = False
    End If
End Sub

Private Sub FilterSubformOption2()
    Dim strFilter as String

    If Nz(Me.txtProjectName, "") <> "" Then
        strFilter = "ProjectName LIKE '*" & Replace(Me.txtProjectName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtStructureName, "") <> "" Then
        strFilter = strFilter & "StructureName LIKE '*" & Replace(Me.txtStructureName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtCompanyName, "") <> "" Then 'Search on multiple fields from one textbox
        strFilter = strFilter & "CompanyName LIKE '*" & Replace(Me.txtCompanyName, "'", "''") & "*' AND "
    End If
    If IsNull(Me.txtProjectDate) = False Then
        If IsDate(Me.txtProjectDate) = True Then
            strFilter = strFilter & "ProjectDate = #" & Me.txtProjectDate & "#"
        End If
    End If
    If Right(strFilter, 5) = " AND " THEN strFilter = Left(strFilter, Len(strFilter) - 5)
    If strFilter <> "" Then
        Me.fsubProjectSearch.Form.Filter = strFilter
        Me.fsubProjectSearch.Form.FilterOn = True
    Else
        Me.fsubProjectSearch.Form.Filter = ""
        Me.fsubProjectSearch.Form.FilterOn = False
    End If
End Sub

Private Sub FilterSubformOption3()
    Dim strFilter as String

    If Nz(Me.txtProjectName, "") <> "" Then
        strFilter = "ProjectName LIKE '*" & Replace(Me.txtProjectName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtStructureName, "") <> "" Then
        strFilter = strFilter & "StructureName LIKE '*" & Replace(Me.txtStructureName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtName, "") <> "" Then 'Search on multiple fields from one textbox, the "hybrid" solution
        strFilter = strFilter & "(CompanyName LIKE '*" & Replace(Me.txtName, "'", "''") & "*' OR "
        strFilter = strFilter & "FirstName LIKE '*" & Replace(Me.txtName, "'", "''") & "*' OR "
        strFilter = strFitler & "LastName LIKE '*" & Replace(Me.txtName, "'", "''") & "*') AND "
    End If
    If IsNull(Me.txtProjectDate) = False Then
        If IsDate(Me.txtProjectDate) = True Then
            strFilter = strFilter & "ProjectDate = #" & Me.txtProjectDate & "#"
        End If
    End If
    If Right(strFilter, 5) = " AND " THEN strFilter = Left(strFilter, Len(strFilter) - 5)
    If strFilter <> "" Then
        Me.fsubProjectSearch.Form.Filter = strFilter
        Me.fsubProjectSearch.Form.FilterOn = True
    Else
        Me.fsubProjectSearch.Form.Filter = ""
        Me.fsubProjectSearch.Form.FilterOn = False
    End If
End Sub
</code>```

And that pretty much completes the multiple criteria filtering solution I typically use.

ContentLicense: CC BY-SA 3.0

Body:
Do you have any screenshots you could possibly post?

This sounds to me like a larger design issue, perhaps mostly in your UI but possibly in your table structure as well. One my own principles I try to follow is to limit how many things a single screen/form does or shows. What your describing sounds quite confusing to me and I think the average user could easily be overwhelmed by it.

Normally subforms are the result of a main form. That is, they contain child records and are linked to records in the main form via the child records foreign key and the main forms primary key. It isn't that there aren't other ways to design your forms but this is considered "normal" or "standard" design. Your description indicates that filtering the main form is determine by filters set on the subforms. I guess I can't think of any problem that could possibly need solving through something as confusing and clumsy as this. I leave the possibility open that I haven't encountered something as difficult or complex as you're dealing with.

I think you may have some difficulty getting better help here as your question is really better suited to a discussion forum such as UtterAccess.com. You may consider posting a copy of your database on such a site so the users can review your design and possibly recommend a more solid and standard approach.

Edit1:

1) Based on your screenshots, I think you're trying to do too many things in one form. I would normally take each of your top tabs (Projects, Structures, Companies, Contacts) and make each of those their own form. Access 2007 and 2010 allow you to use a tabbed interface natively and I can't think of any real benefit to using the tabbed container control to develop your own tabbed interface.

2) It's my opinion that searches should normally be performed in a single main form that has a single listbox, datasheet view subform, or continuous forms subform. Whichever of these three you choose is not overly important. After performing the search, the user should be able to click in the resulting records in the listbox or subform to select that record and move to it on a details view form similar to what you've already built here. It might take several different search screens to allow your users to search all of the different ways you'd like them to. For example, you might build a screen to search projects, one to search structures, another to search contacts, and a fourth one to search companies. It should be possible to combine some of these in a query and allow the user to search by more than one criteria but it can get confusing if you try to allow them to search too many fields at once, especially if the fields they are searching are in separate tables. For example, if you build a query that shows all projects, structures, and companies together and use this as the recordsource for a datasheet subform, this could allow users to search by project, structure, or company. However, if a project has 10 structures that project will be listed 10 times in the query/form which could confuse users if they are thinking about searching by project. If they are instead searching by structure, it will make perfect sense to them that there are 10 entries for the same project since they'll see 10 different structures.

My basic recommendation is, be careful about trying to build too many functions into a single form. There are some types of tasks or sets of data that do require complex forms with multiple subforms and lots of controls, but in general you want to try to avoid this. It's better to build each form with a very focused task and just simply build more forms to accomplish all of the necessary tasks. Of course, you can take this approach too far as well but you do really need to try to minimize complexity to save yourself from headaches in the future.

As far as filtering based on multiple criteria, I'll see if I can find any good examples or maybe put one together and make it available. It isn't so difficult but it is a multi-step process to build and experience has led me to a general design that I'm happy with and that works almost flawlessly in every possible situation.

Edit2:

Here's how you can create a multi-field filter/search.

1) Build your query. Include all tables and fields which need to viewed by the user or searched on by the user. You can include fields here that will be searched on but not viewable by the user, although that could be confusing to the user. Save your query and give it an appropriate name. Be sure to include your id/primary key fields since those will be needed in step number 4.

2) Now Highlight your query in the navigation pane, go to the top menu and choose Create > More Forms > Datasheet (I'm using Access 2007). Allow access to create and show you a datasheet form which we will use as a subform. Save this and give it an appropriate name like subformProjectSearch of fsubProjectSearch.

3) Get the design view for the new form you just created. Change the properties to disallow additions, deletions, and edits unless you'd really like to allow any of these operations. In general, I don't allow any data entry in these kinds of search forms unless I have it well planned out and tested.

4) Go to the code for this form and add code to popup relevant detail forms on double click. For example, in the projectid or project name field, allow your user to double click to bring up the project details form. Add double click routines to any other textbox where the user might want to pop up a structure, company or contact, assuming you've chosen to include one or more of those in your query. You're code will look something like DoCmd.OpenForm "ProjectDetails", , , "ProjectID = " & Me!ProjectID Now save your form again and close it.

5) Now create a new blank form and add your first form as a subform. Leave room at the top to add controls for filtering. This form does not need to have any recordsource set.

Diversion: I usually take one of two different approaches to filtering. Number one is to give the user one textbox that they can type into. I think do fuzzy searches in a whole bunch of different fields using the data they've typed in. It's a perfectly awful approach performance wise, especially once the database grows past about 20,000 records. It can also lead to some confusion since too many results will likely come up for a short generic search. If they only type in the letter s and search for it they will likely get almost all records.

The second approach I use is probably more common. Give them a different textbox for every field they are likely to want to search by. You an also make it a checkbox or combobox if that fits the field they are searching on. These will not be bound controls. This allows the user to get fairly specific and it also is most likely to return the exact results they are looking for. As far as the code goes, I don't think that one approach is really much simpler than the other. With either approach that I've listed here you really need to check the type of data they've entered before you put it in your filter statement for certain fields. For example, you wouldn't want to try to filter a date field using their non-date, text input. On this second approach you can possibly eliminate more of this problem by using validation rules, input masks, or by setting the textboxes format property. Combos also help to prohibit incorrect data from being entered.

Yet a third option is somewhat of a hybrid approach. You can create one text box that searches on more than one field but not necessarily on all fields. For example, you might create one textbox that will be used to search on Company, FirstName, or LastName. You can create as many of these textboxes as you need. How the input in these textboxes gets used will be totally determined by you in your VBA code.

6) Now that you've decided which approach you want to take, you can go ahead and add your controls. Give them appropriate names and labels.

7) Now it's time to create the function that will build the filtering statement. Use one of the two ideas I listed below. Make sure you run these when the user presses your search button or on the controls AfterUpdate event.

    Private Sub txtSearch_AfterUpadate()
         Call FilterSubformOption1
    End Sub

Private Sub FilterSubformOption1()
    Dim strFilter as String
    Dim sSearch as String
    sSearch = Replace(Nz(Me.txtSearch, ""), "'", "''")
    If sSearch <> "" Then
        If IsDate(sSearch) = False Then
            strFilter = "(ProjectName LIKE '*" & sSearch & "*' OR "
            strFilter = strFilter & "StructureName LIKE '*" & sSearch & "*' OR "
            strFilter = strFilter & "CompanyName LIKE '*" & sSearch & "*')"
        Else
            strFilter = "ProjectDate = #" & CDate(sSearch) & "#"
        End If
    End If
    If strFilter <> "" Then
        Me.fsubProjectSearch.Form.Filter = strFilter
        Me.fsubProjectSearch.Form.FilterOn = True
    Else
        Me.fsubProjectSearch.Form.Filter = ""
        Me.fsubProjectSearch.Form.FilterOn = False
    End If
End Sub

Private Sub FilterSubformOption2()
    Dim strFilter as String

    If Nz(Me.txtProjectName, "") <> "" Then
        strFilter = "ProjectName LIKE '*" & Replace(Me.txtProjectName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtStructureName, "") <> "" Then
        strFilter = strFilter & "StructureName LIKE '*" & Replace(Me.txtStructureName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtCompanyName, "") <> "" Then 'Search on multiple fields from one textbox
        strFilter = strFilter & "CompanyName LIKE '*" & Replace(Me.txtCompanyName, "'", "''") & "*' AND "
    End If
    If IsNull(Me.txtProjectDate) = False Then
        If IsDate(Me.txtProjectDate) = True Then
            strFilter = strFilter & "ProjectDate = #" & Me.txtProjectDate & "#"
        End If
    End If
    If Right(strFilter, 5) = " AND " THEN strFilter = Left(strFilter, Len(strFilter) - 5)
    If strFilter <> "" Then
        Me.fsubProjectSearch.Form.Filter = strFilter
        Me.fsubProjectSearch.Form.FilterOn = True
    Else
        Me.fsubProjectSearch.Form.Filter = ""
        Me.fsubProjectSearch.Form.FilterOn = False
    End If
End Sub

Private Sub FilterSubformOption3()
    Dim strFilter as String

    If Nz(Me.txtProjectName, "") <> "" Then
        strFilter = "ProjectName LIKE '*" & Replace(Me.txtProjectName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtStructureName, "") <> "" Then
        strFilter = strFilter & "StructureName LIKE '*" & Replace(Me.txtStructureName, "'", "''") & "*' AND "
    End If
    If Nz(Me.txtName, "") <> "" Then 'Search on multiple fields from one textbox, the "hybrid" solution
        strFilter = strFilter & "(CompanyName LIKE '*" & Replace(Me.txtName, "'", "''") & "*' OR "
        strFilter = strFilter & "FirstName LIKE '*" & Replace(Me.txtName, "'", "''") & "*' OR "
        strFilter = strFitler & "LastName LIKE '*" & Replace(Me.txtName, "'", "''") & "*') AND "
    End If
    If IsNull(Me.txtProjectDate) = False Then
        If IsDate(Me.txtProjectDate) = True Then
            strFilter = strFilter & "ProjectDate = #" & Me.txtProjectDate & "#"
        End If
    End If
    If Right(strFilter, 5) = " AND " THEN strFilter = Left(strFilter, Len(strFilter) - 5)
    If strFilter <> "" Then
        Me.fsubProjectSearch.Form.Filter = strFilter
        Me.fsubProjectSearch.Form.FilterOn = True
    Else
        Me.fsubProjectSearch.Form.Filter = ""
        Me.fsubProjectSearch.Form.FilterOn = False
    End If
End Sub

And that pretty much completes the multiple criteria filtering solution I typically use.


问:
Cannot add reference to project because of a circular dependency error
I created 2 dummy projects in my application and named them BAL and DAL. When I build them, they build successfully. If I add a reference to BAL to the DAL project, it added nicely. But while adding the DAL reference to the BAL project, I get the following error:

A reference to DAL could not be added. Adding this project as a reference would cause a circular dependency.

Can anyone help me to solve this error?

答: Occasionally, you have two different projects, each of which needs methods that the other has. In this case, you can either make a third project and move the shared code into there, or choose one of the two projects to put the shared code in.</p>


问:
How to extract all command history in one file linux
I know how History command works in linux and also that it only displays the commands typed from terminal from that very directory in which the history command was executed,,Isn't it?My intent is to display all the commands typed(History) by me (as a user per se) .

Thanks in advance .

答: $ history > history_for_print.txt

Body: $ history > history_for_print.txt


问:
How to pass a docker variable to jboss-cli.sh?
I have a variable in my jboss cli file, let's call it ${FOO}.

I can see that the variable is set in my Dockerfile, if I:

```<code>RUN echo ${FOO}
</code>```

I see the value printed.

I have a foo.cli file which contains a line similar to:

```<code>/system-property=foo:add(value="${FOO}")
</code>```

and when I run jboss-cli.sh foo.cli

I get:

```<code>Cannot resolve expression ${FOO}.
</code>```

Is there a way to pass a variable from Docker to the file argument to jboss-cli.sh ?

I've tried removing the quotes around ${FOO} also in the system-property line but no luck.

答:
you might need to set jboss-cli.xml to <resolve-parameter-values>true<\/resolve-parameter-values>

```<code>$ sed -i "s/<resolve-parameter-values>false<\/resolve-parameter-values>/\
<resolve-parameter-values>true<\/resolve-parameter-values>/" \
$JBOSS_HOME/bin/jboss-cli.xml
</code>```

src: https://mirocupak.com/using-environment-variables-in-jboss-cli/

Body:
I have a variable in my jboss cli file, let's call it ${FOO}.

I can see that the variable is set in my Dockerfile, if I:

RUN echo ${FOO}

I see the value printed.

I have a foo.cli file which contains a line similar to:

/system-property=foo:add(value="${FOO}")

and when I run jboss-cli.sh foo.cli

I get:

Cannot resolve expression ${FOO}.

Is there a way to pass a variable from Docker to the file argument to jboss-cli.sh ?

I've tried removing the quotes around ${FOO} also in the system-property line but no luck.

Body:
you might need to set jboss-cli.xml to <resolve-parameter-values>true<\/resolve-parameter-values>

$ sed -i "s/<resolve-parameter-values>false<\/resolve-parameter-values>/\
<resolve-parameter-values>true<\/resolve-parameter-values>/" \
$JBOSS_HOME/bin/jboss-cli.xml

src: https://mirocupak.com/using-environment-variables-in-jboss-cli/


问:
MyUnifiedNativeAd.OnUnifiedNativeAdLoaded (Android.Gms.Ads.Formats.UnifiedNativeAd ad) crash on some devices _ Xamarin.Android
My Xamarin.Android app crashes on some devices
Stacktrace says MyUnifiedNativeAd.OnUnifiedNativeAdLoaded (Android.Gms.Ads.Formats.UnifiedNativeAd ad)

Here is stacktrace

```<code>MyUnifiedNativeAd.OnUnifiedNativeAdLoaded (Android.Gms.Ads.Formats.UnifiedNativeAd ad)
UnifiedNativeAd+IOnUnifiedNativeAdLoadedListenerInvoker.n_OnUnifiedNativeAdLoaded_Lcom_google_android_gms_ads_formats_UnifiedNativeAd_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_ad)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.26(intptr,intptr,intptr)
</code>```

Here is my code where I do inflate and initializing of Listener

```<code>UnifiedNativeAdView adView = (UnifiedNativeAdView)LayoutInflater.Inflate(Resource.Layout.ad_unified, null);
            FrameLayout frameLayout = inflated.FindViewById<FrameLayout>(Resource.Id.frameLayout1);
            var a = new MyUnifiedNativeAd(adView, frameLayout);
            AdLoader adLoader = new AdLoader.Builder(Context, Resources.GetString(Resource.String.ad_unit_id))
                .ForUnifiedNativeAd(a)
                .WithAdListener(new MyAdListener())
                .Build();
            adLoader.LoadAd(new AdRequest.Builder().Build());
</code>```

This is listener Class which implements IOnUnifiedNativeAdLoadedListener interface

```<code>class MyUnifiedNativeAd : Java.Lang.Object, IOnUnifiedNativeAdLoadedListener
    {
        UnifiedNativeAdView AdView = null;
        FrameLayout frame = null;
        public MyUnifiedNativeAd( UnifiedNativeAdView adv, FrameLayout f)
        {
            AdView = adv;
            frame = f;
        }
        public void OnUnifiedNativeAdLoaded(UnifiedNativeAd ad)
        {
            if (ad is null)
                return;
            MediaView mv = AdView.FindViewById<MediaView>(Resource.Id.ad_media);
            TextView advertiser = AdView.FindViewById<TextView>(Resource.Id.ad_advertiser);
            TextView headline = AdView.FindViewById<TextView>(Resource.Id.ad_headline);
            ImageView img = AdView.FindViewById<ImageView>(Resource.Id.ad_app_icon);
            TextView body = AdView.FindViewById<TextView>(Resource.Id.ad_body);
            RatingBar rating = AdView.FindViewById<RatingBar>(Resource.Id.ad_stars);
            TextView price = AdView.FindViewById<TextView>(Resource.Id.ad_price);
            TextView store = AdView.FindViewById<TextView>(Resource.Id.ad_store);
            Button action = AdView.FindViewById<Button>(Resource.Id.ad_call_to_action);
            List<View> v = new List<View>() { mv, advertiser, headline, img, body, rating, price, store, action };
            action.Text = ad.CallToAction;
            store.Text = ad.Store;
            price.Text = ad.Price;
            rating.NumStars = ad.StarRating is null ? 0 : ad.StarRating.IntValue();
            body.Text = ad.Body;
            img.SetImageDrawable(ad.Icon.Drawable);
            headline.Text = ad.Headline;
            advertiser.Text = ad.Advertiser;
            AdView.MediaView = mv;
            AdView.SetNativeAd(ad);
            frame.RemoveAllViews();
            frame.AddView(AdView);
        }
    }
</code>```

答:
I solved my issue
I think so
After add "google_app_id" in the "string.xml" file with admob app id value, I tested many times and error was gone</p>

Body:
My Xamarin.Android app crashes on some devices
Stacktrace says MyUnifiedNativeAd.OnUnifiedNativeAdLoaded (Android.Gms.Ads.Formats.UnifiedNativeAd ad)

Here is stacktrace

MyUnifiedNativeAd.OnUnifiedNativeAdLoaded (Android.Gms.Ads.Formats.UnifiedNativeAd ad)
UnifiedNativeAd+IOnUnifiedNativeAdLoadedListenerInvoker.n_OnUnifiedNativeAdLoaded_Lcom_google_android_gms_ads_formats_UnifiedNativeAd_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_ad)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.26(intptr,intptr,intptr)

Here is my code where I do inflate and initializing of Listener

UnifiedNativeAdView adView = (UnifiedNativeAdView)LayoutInflater.Inflate(Resource.Layout.ad_unified, null);
            FrameLayout frameLayout = inflated.FindViewById<FrameLayout>(Resource.Id.frameLayout1);
            var a = new MyUnifiedNativeAd(adView, frameLayout);
            AdLoader adLoader = new AdLoader.Builder(Context, Resources.GetString(Resource.String.ad_unit_id))
                .ForUnifiedNativeAd(a)
                .WithAdListener(new MyAdListener())
                .Build();
            adLoader.LoadAd(new AdRequest.Builder().Build());

This is listener Class which implements IOnUnifiedNativeAdLoadedListener interface

class MyUnifiedNativeAd : Java.Lang.Object, IOnUnifiedNativeAdLoadedListener
    {
        UnifiedNativeAdView AdView = null;
        FrameLayout frame = null;
        public MyUnifiedNativeAd( UnifiedNativeAdView adv, FrameLayout f)
        {
            AdView = adv;
            frame = f;
        }
        public void OnUnifiedNativeAdLoaded(UnifiedNativeAd ad)
        {
            if (ad is null)
                return;
            MediaView mv = AdView.FindViewById<MediaView>(Resource.Id.ad_media);
            TextView advertiser = AdView.FindViewById<TextView>(Resource.Id.ad_advertiser);
            TextView headline = AdView.FindViewById<TextView>(Resource.Id.ad_headline);
            ImageView img = AdView.FindViewById<ImageView>(Resource.Id.ad_app_icon);
            TextView body = AdView.FindViewById<TextView>(Resource.Id.ad_body);
            RatingBar rating = AdView.FindViewById<RatingBar>(Resource.Id.ad_stars);
            TextView price = AdView.FindViewById<TextView>(Resource.Id.ad_price);
            TextView store = AdView.FindViewById<TextView>(Resource.Id.ad_store);
            Button action = AdView.FindViewById<Button>(Resource.Id.ad_call_to_action);
            List<View> v = new List<View>() { mv, advertiser, headline, img, body, rating, price, store, action };
            action.Text = ad.CallToAction;
            store.Text = ad.Store;
            price.Text = ad.Price;
            rating.NumStars = ad.StarRating is null ? 0 : ad.StarRating.IntValue();
            body.Text = ad.Body;
            img.SetImageDrawable(ad.Icon.Drawable);
            headline.Text = ad.Headline;
            advertiser.Text = ad.Advertiser;
            AdView.MediaView = mv;
            AdView.SetNativeAd(ad);
            frame.RemoveAllViews();
            frame.AddView(AdView);
        }
    }


问:
Build one project inside a solution from the command line
I am working on a large C++ solution in Visual Studio 2005.  I want to log all of the output from the build of one project within that solution.  The output window in VS seems to be malfunctioning.  I suspect there is too much output for it to handle.  I can't copy the output and I can't even save it to disk.

My idea is to build the project on the command line and just redirect the output to a file.  I'm not sure what command I have to execute in order to build a project in the context of a solution.  I tried to just vcbuild the project, but I think it's missing data inherited from the solution.

Any ideas?

答:
C# version with MSBuild (put the below code in a .bat file)

```<code>set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727

call %msBuildDir%\msbuild ".\SomeFolder\MyCSharpProject.csproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_CSharp_LOG.log

set msBuildDir=
</code>```

Or for C++:

```<code>set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319

call %msBuildDir%\msbuild ".\Project1\Project1\Project1.vcxproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_C_Plus_Plus_LOG.log

set msBuildDir=
</code>```

You'll need to pick your framework (2.0 or 4.0 (or other??), where I have

```<code>set msBuildDir=%WINDIR%\Microsoft.NET\Framework\vA.BCDEF
</code>```

Just comment out or remove the framework version you do not want.

I had a solution with five (sub) projects. I built the "bottom most" project.  And it only built this (single) assembly.

Keep in mind if the project you pick has dependencies, it'll build those as well. AKA, if you pick the "top most" assembly, it will build everything it needs.

ContentLicense: CC BY-SA 2.5

Body:
C# version with MSBuild (put the below code in a .bat file)

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727

call %msBuildDir%\msbuild ".\SomeFolder\MyCSharpProject.csproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_CSharp_LOG.log

set msBuildDir=

Or for C++:

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319

call %msBuildDir%\msbuild ".\Project1\Project1\Project1.vcxproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_C_Plus_Plus_LOG.log

set msBuildDir=

You'll need to pick your framework (2.0 or 4.0 (or other??), where I have

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\vA.BCDEF

Just comment out or remove the framework version you do not want.

I had a solution with five (sub) projects. I built the "bottom most" project.  And it only built this (single) assembly.

Keep in mind if the project you pick has dependencies, it'll build those as well. AKA, if you pick the "top most" assembly, it will build everything it needs.


问:
Comment a file in Doxygen
I have a C header for which I want to write an introductory comment. Like this:

```<code>/**
 * @brief Provides stuff for my great program.
 */

#ifndef MYHEADER_H
#define MYHEADER_H

#define __USE_GLIBC

#endif
</code>```

Furthermore, I have this Doxyfile:

```<code>FULL_PATH_NAMES = YES
TAB_SIZE = 8
OPTIMIZE_OUTPUT_FOR_C = YES
RECURSIVE = YES
INPUT = .
EXTRACT_ALL = YES
QUIET = YES
EXTRACT_STATIC = YES
</code>```

When I run Doxygen now, it generates HTML and LaTeX documentation, but the brief description ends up documenting the macro instead of the whole file.

So how can I provide Doxygen with a brief description of the file?

答:
While using @file myfile.ext works in any file (ie. not just the one where the documentation comment is), according to the docs, doing just @file will document the current file.

Complete example

```<code>/**
 * @file
 * @brief A file that is documented.
 *
 * Detailed description, etc.
 */
</code>```

Title: Comment a file in Doxygen

Body:
I have a C header for which I want to write an introductory comment. Like this:

/**
 * @brief Provides stuff for my great program.
 */

#ifndef MYHEADER_H
#define MYHEADER_H

#define __USE_GLIBC

#endif

Furthermore, I have this Doxyfile:

FULL_PATH_NAMES = YES
TAB_SIZE = 8
OPTIMIZE_OUTPUT_FOR_C = YES
RECURSIVE = YES
INPUT = .
EXTRACT_ALL = YES
QUIET = YES
EXTRACT_STATIC = YES

When I run Doxygen now, it generates HTML and LaTeX documentation, but the brief description ends up documenting the macro instead of the whole file.

So how can I provide Doxygen with a brief description of the file?

Body:
While using @file myfile.ext works in any file (ie. not just the one where the documentation comment is), according to the docs, doing just @file will document the current file.

Complete example

/**
 * @file
 * @brief A file that is documented.
 *
 * Detailed description, etc.
 */


问:
Querying GORM database by its pq.StringArray attribute
I have the following gorm.Model and I want to Query my Postgres database to return Confessions that have a specific category in their .Categories attribute, but I have no idea how to Query inside a pq.StringArray. Is there a work-around?

```<code>type Confession struct {
    gorm.Model
    User       string         `json:"User"`
    Title      string         `json:"Title"`
    Body       string         `json:"Body"`
    Mood       string         `json:"Mood"`
    Categories pq.StringArray `gorm:"type:varchar(64)[]" json:"Categories"`
}
</code>```

And here is how I tried to query, but using the LIKE operator throws an error.

```<code>if categories != nil {
        for _, cat := range categories {
            tx = tx.Where("Categories LIKE ?", "%"+cat+"%")
        }
    }
</code>```

答:
The easiest solution to my problem was to use the .Where command as such

```<code>tx = tx.Where("categories && ?", pq.Array(categories))
</code>```

This will return a gorm.DB so I can continue to chain actions. The && operator is to check for OVERLAPPING elements.

Body:
I have the following gorm.Model and I want to Query my Postgres database to return Confessions that have a specific category in their .Categories attribute, but I have no idea how to Query inside a pq.StringArray. Is there a work-around?

type Confession struct {
    gorm.Model
    User       string         `json:"User"`
    Title      string         `json:"Title"`
    Body       string         `json:"Body"`
    Mood       string         `json:"Mood"`
    Categories pq.StringArray `gorm:"type:varchar(64)[]" json:"Categories"`
}

And here is how I tried to query, but using the LIKE operator throws an error.

if categories != nil {
        for _, cat := range categories {
            tx = tx.Where("Categories LIKE ?", "%"+cat+"%")
        }
    }

Body:
The easiest solution to my problem was to use the .Where command as such

tx = tx.Where("categories && ?", pq.Array(categories))

This will return a gorm.DB so I can continue to chain actions. The && operator is to check for OVERLAPPING elements.


问:
Assign values to the nested property
I have a config files where i have created nested properties like below

```<code>export class Config {
     public msalConfig: {
        auth: {
          authority: string;
          clientId: string;
          validateAuthority: boolean;
          redirectUri: string;
          postLogoutRedirectUri: string;
          navigateToLoginRequestUrl: boolean;
        },
        cache: {};
        scopes: {};
        system: {};
      };
}
</code>```

From ts file i am trying to assign values to the nested properties but it throws error

```<code>public Settings: Config = null;
this.Settings.msalConfig.auth.redirectUri = window.location.href;
</code>```

Can you tell me how to assign values to the nested properties.

答:
You can't access the inner property of the Settings variable, because it's null, so the msalConfig doesn't exist in it yet. You first need to instantiate the Settings to be an object and then you can set the msalConfig to some value.

Assign the Settings to a new Config instance

private Settings: Config = new Config();
```

<p>then assign a value to the msalConfig like this (in the constructor for instance)</p>

<pre class="lang-cs prettyprint-override"><code>this.Settings.msalConfig = {
    auth: {
        authority: null,
        clientId: null,
        validateAuthority: false,
        redirectUri: null,
        postLogoutRedirectUri: null,
        navigateToLoginRequestUrl: false
      },
      cache: {},
      scopes: {},
      system: {}
    };
</code>```

now you can assign value to the redirectUri, just as you wanted to

this.Settings.msalConfig.auth.redirectUri = window.location.href;
```

Title: Assign values to the nested property

Body:
I have a config files where i have created nested properties like below

export class Config {
     public msalConfig: {
        auth: {
          authority: string;
          clientId: string;
          validateAuthority: boolean;
          redirectUri: string;
          postLogoutRedirectUri: string;
          navigateToLoginRequestUrl: boolean;
        },
        cache: {};
        scopes: {};
        system: {};
      };
}

From ts file i am trying to assign values to the nested properties but it throws error

public Settings: Config = null;
this.Settings.msalConfig.auth.redirectUri = window.location.href;

Can you tell me how to assign values to the nested properties.

Body:
You can't access the inner property of the Settings variable, because it's null, so the msalConfig doesn't exist in it yet. You first need to instantiate the Settings to be an object and then you can set the msalConfig to some value.

Assign the Settings to a new Config instance

private Settings: Config = new Config();

then assign a value to the msalConfig like this (in the constructor for instance)

this.Settings.msalConfig = {
    auth: {
        authority: null,
        clientId: null,
        validateAuthority: false,
        redirectUri: null,
        postLogoutRedirectUri: null,
        navigateToLoginRequestUrl: false
      },
      cache: {},
      scopes: {},
      system: {}
    };

now you can assign value to the redirectUri, just as you wanted to

this.Settings.msalConfig.auth.redirectUri = window.location.href;


问:
Changing visibility of button in viewholder of recyclerview (cardview is used)
This question is already answered but not for cardview I guess, I have already gone through most answers and experimented with them still my problem is not solved.

I have a recyclerview with adapter and a cardview now I have added a button in a cardview and I want to change the visibility of this button to invisible when the button is clicked, but when I do so the visibility of other buttons in other cards like at position=9 get affected and becomes invisible but I never clicked the button at 9th card.

I found some solutions like writing the onClick under onBindViewHolder method. I did so but still its not working please help!

Here is the code for cardview

```<code><?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/shop_cardview"
android:layout_width="match_parent"
android:layout_height="280dp"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="5dp"
card_view:cardMaxElevation="5dp"
card_view:contentPadding="5dp">

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/btnGrey">

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/shopVolleyImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@mipmap/pyaa_logo_iii"
        card_view:layout_constraintBottom_toBottomOf="parent"
        card_view:layout_constraintEnd_toEndOf="parent"
        card_view:layout_constraintStart_toStartOf="parent"
        card_view:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/shopImageNameTV"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginTop="8dp"
        android:text="Json Image Name"
        android:textAlignment="center"
        android:textColor="#000000"
        android:textSize="20dp"
        card_view:layout_constraintEnd_toEndOf="parent"
        card_view:layout_constraintStart_toStartOf="parent"
        card_view:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:text="Button"
        card_view:layout_constraintBottom_toBottomOf="parent"
        card_view:layout_constraintEnd_toEndOf="parent"
        card_view:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>
</code>```

Here is the code for recyclerviewadapter

```<code>    public class shopRecyclerViewAdapter extends  RecyclerView.Adapter<shopRecyclerViewAdapter.ViewHolder> {
    Context context;
    List<shopDataAdapter> dataAdapters;
    ImageLoader imageLoader;

    public shopRecyclerViewAdapter(List<shopDataAdapter> getDataAdapter,Context context){
        super();
        this.dataAdapters=getDataAdapter;
        this.context=context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v=   LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_shop,parent,false);
        ViewHolder vh=new ViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(final ViewHolder Viewholder, int position) {
        shopDataAdapter dataAdapterOBJ= dataAdapters.get(position);
        imageLoader=shopImageAdapter.getInstance(context).getImageLoader();
        imageLoader.get(dataAdapterOBJ.getshopImageUrl(),
                ImageLoader.getImageListener(
                        Viewholder.VollyImageView,
                        R.mipmap.ic_launcher,
                        android.R.drawable.ic_dialog_alert
                )
        );
        Viewholder.VollyImageView.setImageUrl(dataAdapterOBJ.getshopImageUrl(),imageLoader);
        Viewholder.ImageTitleTV.setText(dataAdapterOBJ.getshopName());
        Viewholder.check.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               Viewholder.check.setVisibility(View.INVISIBLE);
            }
        });

    }

    @Override
    public int getItemCount() {
        return dataAdapters.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public TextView ImageTitleTV;
        public NetworkImageView VollyImageView;
        public Button check;
        public ViewHolder(View itemView) {
            super(itemView);
            ImageTitleTV=itemView.findViewById(R.id.shopImageNameTV);
            VollyImageView=itemView.findViewById(R.id.shopVolleyImageView);
            check=itemView.findViewById(R.id.button);
        }
    }
}
</code>```

答:
You can do like this declare global variable clickPosition = -1

```<code>public void onBindViewHolder(final ViewHolder Viewholder, final int position) {
    Viewholder.check.setVisibility(View.VISIBLE);
    Viewholder.check.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            clickPosition = position;
            notifyDataSetChanged();
        }
    });
    if(clickPosition == position){
        Viewholder.check.setVisibility(View.INVISIBLE);
    }
}
</code>```

Don't forgot to write line Viewholder.check.setVisibility(View.VISIBLE); otherwise it will give strange behavior.

If you can give more explain what particular behavior you want I can give more explanation or exact solution.

Body:
This question is already answered but not for cardview I guess, I have already gone through most answers and experimented with them still my problem is not solved.

I have a recyclerview with adapter and a cardview now I have added a button in a cardview and I want to change the visibility of this button to invisible when the button is clicked, but when I do so the visibility of other buttons in other cards like at position=9 get affected and becomes invisible but I never clicked the button at 9th card.

I found some solutions like writing the onClick under onBindViewHolder method. I did so but still its not working please help!

Here is the code for cardview

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/shop_cardview"
android:layout_width="match_parent"
android:layout_height="280dp"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="5dp"
card_view:cardMaxElevation="5dp"
card_view:contentPadding="5dp">

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/btnGrey">

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/shopVolleyImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@mipmap/pyaa_logo_iii"
        card_view:layout_constraintBottom_toBottomOf="parent"
        card_view:layout_constraintEnd_toEndOf="parent"
        card_view:layout_constraintStart_toStartOf="parent"
        card_view:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/shopImageNameTV"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginTop="8dp"
        android:text="Json Image Name"
        android:textAlignment="center"
        android:textColor="#000000"
        android:textSize="20dp"
        card_view:layout_constraintEnd_toEndOf="parent"
        card_view:layout_constraintStart_toStartOf="parent"
        card_view:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:text="Button"
        card_view:layout_constraintBottom_toBottomOf="parent"
        card_view:layout_constraintEnd_toEndOf="parent"
        card_view:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>

Here is the code for recyclerviewadapter

    public class shopRecyclerViewAdapter extends  RecyclerView.Adapter<shopRecyclerViewAdapter.ViewHolder> {
    Context context;
    List<shopDataAdapter> dataAdapters;
    ImageLoader imageLoader;

    public shopRecyclerViewAdapter(List<shopDataAdapter> getDataAdapter,Context context){
        super();
        this.dataAdapters=getDataAdapter;
        this.context=context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v=   LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_shop,parent,false);
        ViewHolder vh=new ViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(final ViewHolder Viewholder, int position) {
        shopDataAdapter dataAdapterOBJ= dataAdapters.get(position);
        imageLoader=shopImageAdapter.getInstance(context).getImageLoader();
        imageLoader.get(dataAdapterOBJ.getshopImageUrl(),
                ImageLoader.getImageListener(
                        Viewholder.VollyImageView,
                        R.mipmap.ic_launcher,
                        android.R.drawable.ic_dialog_alert
                )
        );
        Viewholder.VollyImageView.setImageUrl(dataAdapterOBJ.getshopImageUrl(),imageLoader);
        Viewholder.ImageTitleTV.setText(dataAdapterOBJ.getshopName());
        Viewholder.check.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               Viewholder.check.setVisibility(View.INVISIBLE);
            }
        });

    }

    @Override
    public int getItemCount() {
        return dataAdapters.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public TextView ImageTitleTV;
        public NetworkImageView VollyImageView;
        public Button check;
        public ViewHolder(View itemView) {
            super(itemView);
            ImageTitleTV=itemView.findViewById(R.id.shopImageNameTV);
            VollyImageView=itemView.findViewById(R.id.shopVolleyImageView);
            check=itemView.findViewById(R.id.button);
        }
    }
}

Body:
You can do like this declare global variable clickPosition = -1

public void onBindViewHolder(final ViewHolder Viewholder, final int position) {
    Viewholder.check.setVisibility(View.VISIBLE);
    Viewholder.check.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            clickPosition = position;
            notifyDataSetChanged();
        }
    });
    if(clickPosition == position){
        Viewholder.check.setVisibility(View.INVISIBLE);
    }
}

Don't forgot to write line Viewholder.check.setVisibility(View.VISIBLE); otherwise it will give strange behavior.

If you can give more explain what particular behavior you want I can give more explanation or exact solution.


问:
Oracle SQL -- Pick Max Value from RN Function but update all fields with that value
My query is as follows

```<code>SELECT HEADER_TABLE.SEGMENT1,
       LINES_TABLE.LINE_NUM,
       CASE
          WHEN (    HEADER_TABLE.REVISION_NUM = '0'
                AND HEADER_TABLE.PRINT_COUNT = '0')
          THEN
             'Unavailable'
          ELSE
             NVL (ACK_TABLE.ACK_TYPE, 'Absent')
       END
          AS X_ACK_TYPE,
       ACK_TABLE.GXS_DATE
  FROM HEADER_TABLE,
       LINES_TABLE,
       (SELECT po_number,
               po_line_number,
               gxs_date,
               po_ack_filename,
               ack_type
          FROM (SELECT po_number,
                       po_line_number,
                       gxs_date,
                       po_ack_filename,
                       ack_type,
                       ROW_NUMBER ()
                       OVER (PARTITION BY po_number ORDER BY gxs_date DESC)
                          rn
                  FROM xxcmst_po_ack_from_gxs_stg)
         WHERE rn = 1) ACK_TABLE,
       (SELECT PO_NUMBER FROM XXCMST.XXCMST_ACTION_TABLE_ACKNOWLEDGEMENT) ACTION_TABLE
 WHERE     HEADER_TABLE.PO_HEADER_ID = LINES_TABLE.PO_HEADER_ID
       AND HEADER_TABLE.SEGMENT1 = ACK_TABLE.PO_NUMBER(+)
       AND HEADER_TABLE.SEGMENT1 = ACTION_TABLE.PO_NUMBER(+)
       AND LINES_TABLE.LINE_NUM = ACK_TABLE.PO_LINE_NUMBER(+)
       AND HEADER_TABLE.SEGMENT1 = '100';
</code>```

This is giving me 6 records with 1 GXS_DATE and X_ACK_TYPE = 'Absent'. The RN function is needed here to pull 1 record only from the subquery but the requirement is to have all the 6 records have the same date and ACK_TYPE which is not happening. How can I achieve this? Please refer to the below screenshot and I need X_ACK_TYPE = AK for all the 6 LINE_NUMs and GXS_DATE = 3/6/2020 for all these 6 records.

My current data screenshot here

答:
Instead of

```<code>ACK_TABLE.GXS_DATE
</code>```

in SELECT clause use the LAG function as follows:

```<code>CASE WHEN ACK_TABLE.GXS_DATE IS NOT NULL
     THEN ACK_TABLE.GXS_DATE
     ELSE LAG(ACK_TABLE.GXS_DATE IGNORE NULLS)
                OVER (PARTITION BY HEADER_TABLE.SEGMENT1 ORDER BY LINES_TABLE.LINE_NUM )
END AS GXS_DATE
</code>```

or If there will be always one value of ACK_TABLE.GXS_DATE exists per HEADER_TABLE.SEGMENT1 then you can simply write it as

```<code>MIN(ACK_TABLE.GXS_DATE)
    OVER (PARTITION BY HEADER_TABLE.SEGMENT1) AS GXS_DATE
</code>```

-- Update --

for ACK_TYPE, You need to apply the same logic in ELSE portion of your CASE statement from the original query as follows:

Replace this:

```<code>ELSE
    NVL (ACK_TABLE.ACK_TYPE, 'Absent')
END
</code>```

With this:

```<code>ELSE
    NVL (MIN(ACK_TABLE.ACK_TYPE)
           OVER (PARTITION BY HEADER_TABLE.SEGMENT1), 'Absent')
END
</code>```

Body:
My query is as follows

SELECT HEADER_TABLE.SEGMENT1,
       LINES_TABLE.LINE_NUM,
       CASE
          WHEN (    HEADER_TABLE.REVISION_NUM = '0'
                AND HEADER_TABLE.PRINT_COUNT = '0')
          THEN
             'Unavailable'
          ELSE
             NVL (ACK_TABLE.ACK_TYPE, 'Absent')
       END
          AS X_ACK_TYPE,
       ACK_TABLE.GXS_DATE
  FROM HEADER_TABLE,
       LINES_TABLE,
       (SELECT po_number,
               po_line_number,
               gxs_date,
               po_ack_filename,
               ack_type
          FROM (SELECT po_number,
                       po_line_number,
                       gxs_date,
                       po_ack_filename,
                       ack_type,
                       ROW_NUMBER ()
                       OVER (PARTITION BY po_number ORDER BY gxs_date DESC)
                          rn
                  FROM xxcmst_po_ack_from_gxs_stg)
         WHERE rn = 1) ACK_TABLE,
       (SELECT PO_NUMBER FROM XXCMST.XXCMST_ACTION_TABLE_ACKNOWLEDGEMENT) ACTION_TABLE
 WHERE     HEADER_TABLE.PO_HEADER_ID = LINES_TABLE.PO_HEADER_ID
       AND HEADER_TABLE.SEGMENT1 = ACK_TABLE.PO_NUMBER(+)
       AND HEADER_TABLE.SEGMENT1 = ACTION_TABLE.PO_NUMBER(+)
       AND LINES_TABLE.LINE_NUM = ACK_TABLE.PO_LINE_NUMBER(+)
       AND HEADER_TABLE.SEGMENT1 = '100';

This is giving me 6 records with 1 GXS_DATE and X_ACK_TYPE = 'Absent'. The RN function is needed here to pull 1 record only from the subquery but the requirement is to have all the 6 records have the same date and ACK_TYPE which is not happening. How can I achieve this? Please refer to the below screenshot and I need X_ACK_TYPE = AK for all the 6 LINE_NUMs and GXS_DATE = 3/6/2020 for all these 6 records.

My current data screenshot here

Body:
Instead of

ACK_TABLE.GXS_DATE

in SELECT clause use the LAG function as follows:

CASE WHEN ACK_TABLE.GXS_DATE IS NOT NULL
     THEN ACK_TABLE.GXS_DATE
     ELSE LAG(ACK_TABLE.GXS_DATE IGNORE NULLS)
                OVER (PARTITION BY HEADER_TABLE.SEGMENT1 ORDER BY LINES_TABLE.LINE_NUM )
END AS GXS_DATE

or If there will be always one value of ACK_TABLE.GXS_DATE exists per HEADER_TABLE.SEGMENT1 then you can simply write it as

MIN(ACK_TABLE.GXS_DATE)
    OVER (PARTITION BY HEADER_TABLE.SEGMENT1) AS GXS_DATE

-- Update --

for ACK_TYPE, You need to apply the same logic in ELSE portion of your CASE statement from the original query as follows:

Replace this:

ELSE
    NVL (ACK_TABLE.ACK_TYPE, 'Absent')
END

With this:

ELSE
    NVL (MIN(ACK_TABLE.ACK_TYPE)
           OVER (PARTITION BY HEADER_TABLE.SEGMENT1), 'Absent')
END


问:
add methods to org.w3c.dom.Node
I tried adding a custom method to the Node class but ended up creating a new class that holds a node object in a variable.

so the question is. is it even possible?

I did this:

```<code>public class Trip implements org.w3c.dom.Node {
    [...generated methods...]
    public String myMethod(){
        return "";
    }
}
</code>```

but I was getting lots of errors so I ended up doing this

```<code>public class Trip {
    private Node mNode;
    public void Trip(Node tripNode){
            this.mNode = tripNode;
    }
    public String myMethod(){
        return "";
    }
}
</code>```

答:
org.w3c.dom.Node is an interface, therefore your posted code won't work.

You don't want to start trying to implement your own DOM, so I suggest you think of a different approach. What is it you want to do?

You might be able to make use of get and setUserData to accomplish your goal.

Title: add methods to org.w3c.dom.Node

Body:
I tried adding a custom method to the Node class but ended up creating a new class that holds a node object in a variable.

so the question is. is it even possible?

I did this:

public class Trip implements org.w3c.dom.Node {
    [...generated methods...]
    public String myMethod(){
        return "";
    }
}

but I was getting lots of errors so I ended up doing this

public class Trip {
    private Node mNode;
    public void Trip(Node tripNode){
            this.mNode = tripNode;
    }
    public String myMethod(){
        return "";
    }
}


问:
Vue Highcharts "TypeError: Cannot read property 'chart' of undefined"
I am trying to display a chart from Highcharts in Vue.js with Highcharts for Vue. I keep getting the error in the title on the browser console for the watcher I created and the methods (see code below). As well as for other Vue methods (see screenshot below the code).

The watcher triggers the dataSource() method. The dataSource() method is used to read the list and calculate chart data; The const "base" is from where categories and data are going to be extracted. The setup() method is used to set up the chart and display it on the screen (this method will only be triggered when data is ready).

How do I solve these errors ?

```

答:
https://www.npmjs.com/package/highcharts

From the docs Load Highcharts as an ES6 module

import Highcharts from 'highcharts';

You are using a named import.

Also, a bit off-topic, but still on topic.. why would you load vue js from CDN, but the other libraries are imported?


问:
CodeDeploy PM2 Command Not Found
I'm trying to use AWS CodeDeploy to deploy my application. Everything seems to be working fine but I'm getting the following error.

[stderr]/opt/codedeploy-agent/deployment-root/f1ea67bd-97bo-08q1-b3g4-7b14becf91bf/d-WJL0QLF9H/deployment-archive/scripts/start_server.sh:
  line 3: pm2: command not found

Below is my start_server.sh file.

```<code>#!/bin/bash
pm2 start ~/server.js -i 0 --name "admin" &
</code>```

I have tried using SSH to connect to my server as user ubuntu and running that bash file and it works perfectly with no errors. So I know that PM2 is installed and working correctly on that user.

Below is also my appspec.yml file.

```<code>version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu
hooks:
  ApplicationStart:
    - location: scripts/start_server.sh
      timeout: 300
      runas: ubuntu
  ApplicationStop:
    - location: scripts/stop_server.sh
      timeout: 300
      runas: ubuntu
</code>```

Also not sure if this will help but here is my stop_server.sh file.

```<code>#!/bin/bash
npm install pm2 -g
pm2 stop admin || true
pm2 delete admin || true
</code>```

Any ideas?

答:
Perform the below steps:

which node

sudo ln -s /home/ubuntu/.nvm/versions/node/v12.13.1/bin/node

(output of above step) /usr/bin/node

which pm2

sudo ln -s /home/ubuntu/.nvm/versions/node/v12.13.1/bin/pm2

(output of above step) /usr/bin/pm2

in start_server.sh and stop_server.sh use it as below (run start.sh as ubuntu):

```<code>sudo /usr/bin/pm2 status
</code>```

Hope this will help you!!

Title: CodeDeploy PM2 Command Not Found

Body:
I'm trying to use AWS CodeDeploy to deploy my application. Everything seems to be working fine but I'm getting the following error.

[stderr]/opt/codedeploy-agent/deployment-root/f1ea67bd-97bo-08q1-b3g4-7b14becf91bf/d-WJL0QLF9H/deployment-archive/scripts/start_server.sh:
  line 3: pm2: command not found

Below is my start_server.sh file.

#!/bin/bash
pm2 start ~/server.js -i 0 --name "admin" &

I have tried using SSH to connect to my server as user ubuntu and running that bash file and it works perfectly with no errors. So I know that PM2 is installed and working correctly on that user.

Below is also my appspec.yml file.

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu
hooks:
  ApplicationStart:
    - location: scripts/start_server.sh
      timeout: 300
      runas: ubuntu
  ApplicationStop:
    - location: scripts/stop_server.sh
      timeout: 300
      runas: ubuntu

Also not sure if this will help but here is my stop_server.sh file.

#!/bin/bash
npm install pm2 -g
pm2 stop admin || true
pm2 delete admin || true

Any ideas?

Body:
Perform the below steps:

which node

sudo ln -s /home/ubuntu/.nvm/versions/node/v12.13.1/bin/node

(output of above step) /usr/bin/node

which pm2

sudo ln -s /home/ubuntu/.nvm/versions/node/v12.13.1/bin/pm2

(output of above step) /usr/bin/pm2

in start_server.sh and stop_server.sh use it as below (run start.sh as ubuntu):

sudo /usr/bin/pm2 status

Hope this will help you!!