Apex : How to generate modal page URL? - oracle

I have the following code that generates a normal APEX page URL :
PageURL := APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || AppId || ':' || PageAlias || ':' || SessionId ||'::NO::' || Arguments || ':' || ArgumentValues, p_checksum_type => Checksum);
Does anyone know how to generate a URL for a modal page please ?
Thanks.
Cheers,

Related

Dynamic Query based on all optional parameters using an OR condition in ef core

I'm not sure if I'm barking up the wrong tree but I wanted to create a function to check if an account exists based on all optional parameters so it can be used to pull data depending on whatever you'd like to check on.
Basically the query should be:
where loginName = p1 or loginName = p2 or loginName = p3 but with the paramters all being optional, however at least one will be provided.
This is what I tried so far:
public async Task<bool> CheckAccountExistsAsync(string loginName = "", string authenticatorId = "", string eId = "")
{
if (string.IsNullOrWhiteSpace(loginName) && string.IsNullOrWhiteSpace(authenticatorId) && string.IsNullOrWhiteSpace(eId))
throw new InvalidOperationException("You must pass at least one parameter");
return await _context.Accounts.AnyAsync(a =>
(string.IsNullOrWhiteSpace(loginName) || a.LoginName == loginName)
|| (string.IsNullOrWhiteSpace(authenticatorId) || a.AuthenticatorId == authenticatorId)
|| (string.IsNullOrWhiteSpace(eId) || a.EmployeeId == eId));
}
Problem with this approach is that if I just pass the loginName, then the query is as follows with the condition completely omitted.:
SELECT CASE
WHEN EXISTS (
SELECT 1
FROM [Accounts] AS [a]) THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END
I'm sure I'm missing something, is there a better approach?
What you are using is applicable for optional and expressions, e.g.
return await _context.Accounts.AnyAsync(a =>
(string.IsNullOrWhiteSpace(loginName) || a.LoginName == loginName)
&& (string.IsNullOrWhiteSpace(authenticatorId) || a.AuthenticatorId == authenticatorId)
&& (string.IsNullOrWhiteSpace(eId) || a.EmployeeId == eId));
For optional or you have to use optional and sub conditions and add additional check for all optional parameters missing, e.g.
return await _context.Accounts.AnyAsync(a =>
(string.IsNullOrWhiteSpace(loginName)
&& string.IsNullOrWhiteSpace(authenticatorId)
&& string.IsNullOrWhiteSpace(eId))
|| (!string.IsNullOrWhiteSpace(loginName) && a.LoginName == loginName)
|| (!string.IsNullOrWhiteSpace(authenticatorId) && a.AuthenticatorId == authenticatorId)
|| (!string.IsNullOrWhiteSpace(eId) && a.EmployeeId == eId));

Identify all relevant ip addresses from ruby Socket.ip_address_list

When using rubies Socket.ip_address_list, it will return an array of addr_info (https://ruby-doc.org/stdlib-2.0.0/libdoc/socket/rdoc/Addrinfo.html)
Example:
require 'socket'
addr_infos = Socket.ip_address_list
This array could be iterated and listed by all defined ip_addresses and attributes like
addr_infos.each do |addr_info|
puts "#{addr_info.ip_address}
#{addr_info.ipv4? ? 'ipv4? ' : ''}" +
"#{addr_info.ipv4_loopback? ? 'ipv4_loopback? ' : ''}" +
"#{addr_info.ipv4_private? ? 'ipv4_private? ' : ''}" +
"#{addr_info.ipv4_multicast? ? 'ipv4_multicast? ' : ''}" +
"#{addr_info.ipv6? ? 'ipv6? ' : '' }" +
"#{addr_info.ipv6_loopback? ? 'ipv6_loopback? ' : ''}" +
"#{addr_info.ipv6_linklocal? ? 'ipv6_linklocal? ' : ''}" +
"#{addr_info.ipv6_multicast? ? 'ipv6_multicast? ' : ''}" +
"#{addr_info.ipv6_sitelocal? ? 'ipv6_sitelocal? ' : ''}" +
"#{addr_info.ipv6_unique_local? ? 'ipv6_unique_local? ' : ''}" +
"#{addr_info.ipv6_mc_global? ? 'ipv6_mc_global? ' : ''}" +
"#{addr_info.ipv6_unspecified? ? 'ipv6_unspecified? ' : ''}"
end
The result will look like
127.0.0.1
ipv4? ipv4_loopback?
192.168.178.33
ipv4? ipv4_private?
1.2.4.5
ipv4?
::1
ipv6? ipv6_loopback?
fe80::1%lo0
ipv6? ipv6_linklocal?
fe80::aede:48ff:fe00:1122%en5
ipv6? ipv6_linklocal?
fe80::68:e785:4cfb:41e6%en0
ipv6? ipv6_linklocal?
fe80::50fc:46ff:fe4c:c2b4%awdl0
ipv6? ipv6_linklocal?
fe80::3203:d609:ff08:151d%utun0
ipv6? ipv6_linklocal?
fd00::ffff:aaaa:bbbb:7005
ipv6? ipv6_unique_local?
2003:ffff:4723:aaaa:bbbb:8888:269a:42a4
ipv6?
Q: How to identify "correct" ip-addresses to bind listening services to?
IMHO it would be easy to identify the IPv4 addresses like:
IPv4 = ipv4? && (ipv4_loopback? || ipv4_private? || !(ipv4_loopback? || ipv4_private? || ipv4_multicast?))
But in case of those many ipv6_? attributes I wondering what to to check to identify the IPv6 addresses.
Is this the correct suggestion?
It is an IPv6 address when:
a. ipv6? is true and no other ipv6_...? attribute is true
b. ipv6? and ipv6_loopback? are true
c. ipv6? and ipv6_unique_local are true
Do I miss something from IPv6 addresses?
This is my current solution in addition to this question. Maybe some may add a comment or vote to make sure that this goes the right direction
ip_addresses_for_host = []
Socket.ip_address_list.each do |a|
# test for all local valid ipv4 and ipv6 ip_addresses
# check question on stackoverflow for details
# https://stackoverflow.com/questions/59770803/identify-all-relevant-ip-addresses-from-ruby-socket-ip-address-list
ip_addresses_for_host << a.ip_address if \
(a.ipv4? &&
(a.ipv4_loopback? || a.ipv4_private? ||
!(a.ipv4_loopback? || a.ipv4_private? || a.ipv4_multicast?)
)
) ||
(a.ipv6? &&
(a.ipv6_loopback? || a.ipv6_unique_local? ||
!(a.ipv6_loopback? || a.ipv6_unique_local? || a.ipv6_linklocal? || a.ipv6_multicast? || a.ipv6_sitelocal? ||
a.ipv6_mc_global? || a.ipv6_mc_linklocal? || a.ipv6_mc_nodelocal? || a.ipv6_mc_orglocal? || a.ipv6_mc_sitelocal? ||
a.ipv6_v4compat? || a.ipv6_v4mapped? || a.ipv6_unspecified?)
)
)
end
This will resolve for IPv4:
a. 127.0.0.1
b. private addresses like 192.168./16, 10./8, ...
c. other ipv4 addresses like 1.2.3.4
and for IPv6:
a. ::1
b. fc00::
c. abcd::
Appreciate if someone would add more knowledge.

How to search date in asp.net core 2.0

Hi I have this code working when searching a string I just use .contains but
what will I use if I will search Date?
if (!String.IsNullOrEmpty(id))
{
domescticwastes = domescticwastes.Where
(s => s.Location.Contains(id) ||
s.Name.Contains(id) ||
s.Address.Contains(id) ||
s.Contact.Contains(id) ||
s.AccNo.Contains(id) ||
s.Contractor.Contains(id));
}

laravel Blade is their a neat solution to : Trying to get property of non-object

I have thins line of code
{{($user->company_privileges->level < 3 ? '' : ' disabled') }}
In my menu file
but when a user doesn't have a company I get the error
Trying to get property of non-object
Is their a neat way of dealing with this in one line?
Something like this comes to mind
{{ ($user->company_privileges === null) : '' ? ($user->company_privileges->level < 3 ? '' : ' disabled') ) }}
as the second if statement is only ran if the user has a company
I have the statement inside a tag aswell
<a class="{{($user->company_privileges->level < 3 ? '' : ' disabled') }}">
Why not something like
<a class="{{($user->company_privileges && $user->company_privileges->level < 3 ? '' : ' disabled') }}">
Essentially, what you need here is to know that null == false for bool comparison. Check out the PHP type comparisons table

how to display text in ckeditor status bar?

I just want to know how to display text in the ckeditor status bar.
At the bottom of the ckeditor displays the elements path I just want to display text in that elements path like status bar.
Foe example, when the user finds and replaces a text in the editor, I want to display to the user the number of instances replaced in the text.
Any help is useful, thanks in advance.
You can disable the elementspath plugin:
config.removePlugins = 'elementspath';
Then make a custom plugin by copying _source/plugins/elementspath to plugins/elementspath.
Then rename the directory to your custom name and change line 33 of the plugin.js file to use the new name (the CkEditor styleguide calls for all lowercase letters for plugin names):
CKEDITOR.plugins.add( 'newname',
Then add the new plugin in your config:
config.extraPlugins = 'newname';
The editor.on( 'selectionChange', function( ev ) section is where the majority of the work is done to create the content for that line. The main section is this:
html.unshift(
'<a' +
' id="', idBase, index, '"' +
' href="javascript:void(\'', name, '\')"' +
' tabindex="-1"' +
' title="', label, '"' +
( ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ?
' onfocus="event.preventBubble();"' : '' ) +
' hidefocus="true" ' +
' onkeydown="return CKEDITOR.tools.callFunction(', onKeyDownHandler, ',', index, ', event );"' +
extra ,
' onclick="CKEDITOR.tools.callFunction('+ onClickHanlder, ',', index, '); return false;"',
' role="button" aria-labelledby="' + idBase + index + '_label">',
name,
'<span id="', idBase, index, '_label" class="cke_label">eee' + label + '</span>',
'rrrr</a>' );
You can modify it to display whatever content you like.
You'll need to look through the rest of the code to understand everything that's happening and make any other changes needed for your specific goals.

Resources