问:
Exit Event / Welcome Event Not Firing
We're trying to get some events/messages to post when a user exits a chatbot window (or the site) (or a welcome message), but so far the events are not firing.

I can see within Inspector tools:

Screen Shot 2020-02-18 at 3 15 39 PM

Various activities/conversations are created, the chatbot works, but no welcome/exit events are triggered.

The code we're using is nearly if not identical to documentation code here: https://github.com/microsoft/BotFramework-WebChat/blob/master/docs/WELCOME_MESSAGE.md

and here: How to handle user leaving conversation

I have a function that fires when the window is closed, as follows:

    const store = window.WebChat.createStore( {}, ( { dispatch } ) => next => async action => {
    return next( action );});

        window.addEventListener( 'sendEventActivity', ( { data } ) => {

          store.dispatch({
            type: 'WEB_CHAT/SEND_EVENT',
            payload: {
              name: 'user_event',
              value: {
                name: 'end_conversation',
                value: 'user ended conversation'
              },
              text: 'The user has left the conversation.'
            }
          })

        });

        function exitEvent(){
          const eventSendActivity = new Event( 'sendEventActivity' );
          eventSendActivity.data = 'User left conversation';
          window.dispatchEvent( eventSendActivity );
          console.log('Exit Event Submitted (hopefully)');
        }
        exitEvent();
```

<p>I have tried other variations, defining the store earlier, above render chat, after render chat, sending welcome messages from various locations and at various times but can't seem to get it to send.</p>

<p>We are using https://cdn.botframework.com/botframework-webchat/latest/webchat.js</p>

<p>Any idea what the issue might be? Not sure where we are going wrong or why it's not firing - copying in theory known to be working code straight into our code doesn't seem to do the trick.</p>

<p>Thanks in advance and please let me know if I have failed to include any necessary details- new to chatbot and do not post much on github. Many thanks,</p>

<p>EDIT:</p>

<p>I was able to marry the aforementioned code and code from here: https://github.com/microsoft/BotFramework-WebChat/issues/2120#issuecomment-516056614 in order to achieve what I wanted. I'll post below in case it helps anyone else... </p>

```const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
            if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
               dispatch({
                  type: 'WEB_CHAT/SEND_EVENT',
                  payload: {
                     name: 'webchat/join'
                  }
               });
            }
            return next(action);
         });

          window.addEventListener( 'sendEventActivity', ( { data } ) => {

          store.dispatch( {
              type: 'WEB_CHAT/SEND_EVENT',
              payload: {
                 name: 'webchat/exit'
              }
            } );
          } );

          document.getElementById("action_menu_btn").addEventListener( 'click', function() {
            const eventSendActivity = new Event( 'sendEventActivity' );
            eventSendActivity.data = 'User left conversation';
            window.dispatchEvent( eventSendActivity );
            console.log('End Converstaion Event Fired');
          });

```

Cheers!

答:
I failed to mention this in the other post (I'll update it), but the reason the code works is because of the window.onbeforeunload() function. Without it, the window closes before any code can finish executing. The result being no event is created, is caught by a listener, nor is sent via the Web Chat store to the bot.

Here, using the above, refreshing the page produces the "User left conversation" activity.

Also, something to note, any function you create and pass thru like you have with exitEvent() is going to run as soon as the page loads. Take the following code which gets the user's location via the browser (placed just before the closing </script> tag). As you can see, it's loading even before Web Chat. If you are wanting a function to run according to some activity passed from the bot, then utilize either the store's actions (i.e. DIRECT_LINE/INCOMING_ACTIVITY, or some other) or via the available middleware.

let geoLoc = async () => {
  await navigator.geolocation.getCurrentPosition(position => {
    console.log('Latitude: ', position.coords.latitude);
    console.log('Longitude: ', position.coords.longitude);
  });
}

geoLoc();
```

Regarding a welcome message, you have two options. Either send as an activity from your bot (reference this sample) or initiate an event on your page after some initial activity is received (reference this sample).

Lastly, I would recommend getting the code working as-is before tinkering with it. This usually trips me up, so thought I'd pass it along.

Hope of help!

Title: Exit Event / Welcome Event Not Firing

Body:
We're trying to get some events/messages to post when a user exits a chatbot window (or the site) (or a welcome message), but so far the events are not firing.

I can see within Inspector tools:

Screen Shot 2020-02-18 at 3 15 39 PM

Various activities/conversations are created, the chatbot works, but no welcome/exit events are triggered.

The code we're using is nearly if not identical to documentation code here: https://github.com/microsoft/BotFramework-WebChat/blob/master/docs/WELCOME_MESSAGE.md

and here: How to handle user leaving conversation

I have a function that fires when the window is closed, as follows:

    const store = window.WebChat.createStore( {}, ( { dispatch } ) => next => async action => {
    return next( action );});

        window.addEventListener( 'sendEventActivity', ( { data } ) => {

          store.dispatch({
            type: 'WEB_CHAT/SEND_EVENT',
            payload: {
              name: 'user_event',
              value: {
                name: 'end_conversation',
                value: 'user ended conversation'
              },
              text: 'The user has left the conversation.'
            }
          })

        });

        function exitEvent(){
          const eventSendActivity = new Event( 'sendEventActivity' );
          eventSendActivity.data = 'User left conversation';
          window.dispatchEvent( eventSendActivity );
          console.log('Exit Event Submitted (hopefully)');
        }
        exitEvent();

I have tried other variations, defining the store earlier, above render chat, after render chat, sending welcome messages from various locations and at various times but can't seem to get it to send.

We are using https://cdn.botframework.com/botframework-webchat/latest/webchat.js

Any idea what the issue might be? Not sure where we are going wrong or why it's not firing - copying in theory known to be working code straight into our code doesn't seem to do the trick.

Thanks in advance and please let me know if I have failed to include any necessary details- new to chatbot and do not post much on github. Many thanks,

EDIT:

I was able to marry the aforementioned code and code from here: https://github.com/microsoft/BotFramework-WebChat/issues/2120#issuecomment-516056614 in order to achieve what I wanted. I'll post below in case it helps anyone else...

const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
            if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
               dispatch({
                  type: 'WEB_CHAT/SEND_EVENT',
                  payload: {
                     name: 'webchat/join'
                  }
               });
            }
            return next(action);
         });

          window.addEventListener( 'sendEventActivity', ( { data } ) => {

          store.dispatch( {
              type: 'WEB_CHAT/SEND_EVENT',
              payload: {
                 name: 'webchat/exit'
              }
            } );
          } );

          document.getElementById("action_menu_btn").addEventListener( 'click', function() {
            const eventSendActivity = new Event( 'sendEventActivity' );
            eventSendActivity.data = 'User left conversation';
            window.dispatchEvent( eventSendActivity );
            console.log('End Converstaion Event Fired');
          });

Cheers!

Body:
I failed to mention this in the other post (I'll update it), but the reason the code works is because of the window.onbeforeunload() function. Without it, the window closes before any code can finish executing. The result being no event is created, is caught by a listener, nor is sent via the Web Chat store to the bot.

Here, using the above, refreshing the page produces the "User left conversation" activity.

Also, something to note, any function you create and pass thru like you have with exitEvent() is going to run as soon as the page loads. Take the following code which gets the user's location via the browser (placed just before the closing </script> tag). As you can see, it's loading even before Web Chat. If you are wanting a function to run according to some activity passed from the bot, then utilize either the store's actions (i.e. DIRECT_LINE/INCOMING_ACTIVITY, or some other) or via the available middleware.

let geoLoc = async () => {
  await navigator.geolocation.getCurrentPosition(position => {
    console.log('Latitude: ', position.coords.latitude);
    console.log('Longitude: ', position.coords.longitude);
  });
}

geoLoc();

Regarding a welcome message, you have two options. Either send as an activity from your bot (reference this sample) or initiate an event on your page after some initial activity is received (reference this sample).

Lastly, I would recommend getting the code working as-is before tinkering with it. This usually trips me up, so thought I'd pass it along.

Hope of help!


来源: stackexchange

问:
Concatenation of 2 values from same column using oracle SQL
I'm trying to concatenate the values of a column.

For EX:

```<code>select case when month=1 then month_name1
when month =12 then month_name2 END
from Calendar
where month in (1,12)
</code>```

results:

```<code>Jan
Dec
</code>```

Target results:

```<code>Jan - Dec
</code>```

tried different ways but couldn't get it. looks very simple but hard luck.
Thanks in advance.

答:
You can use aggregate function max as following:

```<code>select max(case when month=1 then month_name1 end)
       || ' - '||
       max(case when month=12 then month_name2 end)
from Calendar
where month in (1,12);
</code>```

Cheers!!

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to concatenate the values of a column.

For EX:

select case when month=1 then month_name1
when month =12 then month_name2 END
from Calendar
where month in (1,12)

results:

Jan
Dec

Target results:

Jan - Dec

tried different ways but couldn't get it. looks very simple but hard luck.
Thanks in advance.

Body:
You can use aggregate function max as following:

select max(case when month=1 then month_name1 end)
       || ' - '||
       max(case when month=12 then month_name2 end)
from Calendar
where month in (1,12);

Cheers!!


问:
Remove trailing slash from wordpress
My address of website is

https://lofty-tibiabot.com/new/
This website is in subfolder - new

I want address to be

https://lofty-tibiabot.com/new

```<code>  # BEGIN WordPress
    # The directives (lines) between `BEGIN WordPress` and `END WordPress` are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /new/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /new/index.php [L]
    </IfModule>
    # END WordPress
</code>```

what to do?

答:
Are you sure?

It gets a little messy, as Apache requires the trailing slash on the directory in order to evaluate the DirectoryIndex etc. By disabling the trailing slash, we must handle this situation manually with mod_rewrite.

Try the following:

1) Move the /new/.htaccess file into the root at /.htaccess. This takes the .htaccess out of WordPress, so WP can no longer maintain this file (not necessarily a bad thing).

2) Change the /.htaccess file to read:

```<code># Prevent mod_dir from appending the trailing slash to directories (with a 301 redirect)
DirectorySlash Off

RewriteEngine On
RewriteBase /new

# Allow mod_rewrite to match directories that do not have a trailing slash (when DirecrorySlash Off)
RewriteOptions AllowNoSlash

# Rewrite directory without trailing slash directly to the front-controller
RewriteRule ^new$ index.php [L]

# Standard front-controller
RewriteRule ^new/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^new/. index.php [L]
</code>```

Title: Remove trailing slash from wordpress

Body:
My address of website is

https://lofty-tibiabot.com/new/
This website is in subfolder - new

I want address to be

https://lofty-tibiabot.com/new

  # BEGIN WordPress
    # The directives (lines) between `BEGIN WordPress` and `END WordPress` are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /new/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /new/index.php [L]
    </IfModule>
    # END WordPress

what to do?

Body:
Are you sure?

It gets a little messy, as Apache requires the trailing slash on the directory in order to evaluate the DirectoryIndex etc. By disabling the trailing slash, we must handle this situation manually with mod_rewrite.

Try the following:

1) Move the /new/.htaccess file into the root at /.htaccess. This takes the .htaccess out of WordPress, so WP can no longer maintain this file (not necessarily a bad thing).

2) Change the /.htaccess file to read:

# Prevent mod_dir from appending the trailing slash to directories (with a 301 redirect)
DirectorySlash Off

RewriteEngine On
RewriteBase /new

# Allow mod_rewrite to match directories that do not have a trailing slash (when DirecrorySlash Off)
RewriteOptions AllowNoSlash

# Rewrite directory without trailing slash directly to the front-controller
RewriteRule ^new$ index.php [L]

# Standard front-controller
RewriteRule ^new/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^new/. index.php [L]


问:
Nav Bar Text Not Centering & Covering Text
I have an html page that "contains" many pages meaning I have links at the top of the page but when they are clicked you are not actually taken to a new page. The links stay on the same page but just take you to another part of the same html page. (I think this is called single page layout with multiple pages, I forget). My page is split into 4 sections, and the first section under the nav bar contains the least amount of text. I'm not sure why but the nav bar is cutting off my p tag text. It looks like the text is covered under the nav bar.

I'm not sure how to stop the nav bar from covering my text

Another problem I'm having is the nav bar itself, I'm trying to center the text inside and also make the nav bar extend the full width of my page.

I tried things like padding, margin, and text align but I'm still having trouble with these 2 things. Can someone please help me out? Thanks.

Code:

```<code>    nav {
        width: 100%;
        background: #1B2631;
        overflow: hidden;
        position: fixed;
        top: 0;
    }

    ul {

        list-style: none;
    }

    li {
        text-align: center;
        float: left;

    }

<nav>
    <ul>
        <li><a href="#page1">page1</a>
        </li>
        <li><a href="#page2">page2</a>
        </li>
        <li><a href="#page3">page3</a>
        </li>
        <li><a href="#page4">page4</a>
        </li>
        <li><a href="#page5">page5</a>
        </li>
    </ul>
</nav>
</code>```

答:
I made the ul in your nav a flexbox parent, and then centered the contents via justify-content: center. For the inner "pages", I gave each one some upper padding, to ensure it clears the height of the fixed nav menu.

Some more explanation. The following block targets section elements which are direct children of the pages class. I did it this way so that nested sections would not be targetted accidentially.

```<code>.pages>section {
  padding: 3em 1em 2em;
}
</code>```

The next thing to explain is this block. It removes bottom margin from the last p in the long list of ps I included in the sections. This is so the spacing at the bottom of each section looks even.

```<code>.pages p:last-child {
  margin-bottom: 0;
}
</code>```

Here's a possible implementation of this.

html {
  scroll-behavior: smooth;
}

.pages>section {
  padding: 3em 1em 2em;
}

.pages p:last-child {
  margin-bottom: 0;
}

#page1 {
  background-color: yellow;
}

#page2 {
  background-color: red;
}

#page3 {
  background-color: gray;
}

#page4 {
  background-color: purple;
}

#page5 {
  background-color: orange;
}

nav {
  width: 100%;
  /*       background: #1B2631; */
  background: #ccc;
  overflow: hidden;
  position: fixed;
  top: 0;
}

ul {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

ul a {
  padding: 0 1em;
}

body {
  margin: 0;
  font-family: sans-serif;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav>
  <ul>
    <li>page1
    </li>
    <li>page2
    </li>
    <li>page3
    </li>
    <li>page4
    </li>
    <li>page5
    </li>
  </ul>
</nav>

<div class="pages">

  <section id="page1">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page2">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page3">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page4">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page5">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

</div></code>```

jsFiddle

Body:
I have an html page that "contains" many pages meaning I have links at the top of the page but when they are clicked you are not actually taken to a new page. The links stay on the same page but just take you to another part of the same html page. (I think this is called single page layout with multiple pages, I forget). My page is split into 4 sections, and the first section under the nav bar contains the least amount of text. I'm not sure why but the nav bar is cutting off my p tag text. It looks like the text is covered under the nav bar.

I'm not sure how to stop the nav bar from covering my text

Another problem I'm having is the nav bar itself, I'm trying to center the text inside and also make the nav bar extend the full width of my page.

I tried things like padding, margin, and text align but I'm still having trouble with these 2 things. Can someone please help me out? Thanks.

Code:

    nav {
        width: 100%;
        background: #1B2631;
        overflow: hidden;
        position: fixed;
        top: 0;
    }

    ul {

        list-style: none;
    }

    li {
        text-align: center;
        float: left;

    }

page1

page2

page3

page4

page5

Body:
I made the ul in your nav a flexbox parent, and then centered the contents via justify-content: center. For the inner "pages", I gave each one some upper padding, to ensure it clears the height of the fixed nav menu.

Some more explanation. The following block targets section elements which are direct children of the pages class. I did it this way so that nested sections would not be targetted accidentially.

.pages>section {
  padding: 3em 1em 2em;
}

The next thing to explain is this block. It removes bottom margin from the last p in the long list of ps I included in the sections. This is so the spacing at the bottom of each section looks even.

.pages p:last-child {
  margin-bottom: 0;
}

Here's a possible implementation of this.

html {
  scroll-behavior: smooth;
}

.pages>section {
  padding: 3em 1em 2em;
}

.pages p:last-child {
  margin-bottom: 0;
}

#page1 {
  background-color: yellow;
}

#page2 {
  background-color: red;
}

#page3 {
  background-color: gray;
}

#page4 {
  background-color: purple;
}

#page5 {
  background-color: orange;
}

nav {
  width: 100%;
  /*       background: #1B2631; */
  background: #ccc;
  overflow: hidden;
  position: fixed;
  top: 0;
}

ul {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

ul a {
  padding: 0 1em;
}

body {
  margin: 0;
  font-family: sans-serif;
}

<nav>
  <ul>
    <li><a href="#page1">page1</a>
    </li>
    <li><a href="#page2">page2</a>
    </li>
    <li><a href="#page3">page3</a>
    </li>
    <li><a href="#page4">page4</a>
    </li>
    <li><a href="#page5">page5</a>
    </li>
  </ul>
</nav>

<div class="pages">

  <section id="page1">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page2">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page3">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page4">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

  <section id="page5">
    <h2>Page Header</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis ducimus pariatur atque quo nobis aliquid a accusantium soluta tempora dicta, eveniet harum adipisci voluptatibus, minima aliquam quasi perferendis delectus, voluptatem!</p>
  </section>

</div>

jsFiddle


问:
match multiple OR conditions in python 3 regex findall
In python 3:

This is the Office of Foreign Asset Control list where individuals' assets should be monitored

https://www.treasury.gov/ofac/downloads/sdn.csv

a lot of their data of births (the very last column, comma delimited) are like

```<code>DOB 23 Jun 1959; alt. DOB 23 Jun 1958
</code>```

or

```<code>DOB 1959; alt. DOB 1958
</code>```

I am trying to capture all the birthdates after the keyword "DOB" AND "alt. DOB" with the following codes:

```<code>   if len(x.split(';')) > 0:
        if len(re.findall('DOB (.*)', x.split(';')[0])) > 0:
            new = re.findall('DOB | alt. DOB (.*)', x.split(';')[0])[0]
            print(new)

            try:
                print(datetime.strptime(new, '%d %b %Y'))
                return datetime.strptime(new, '%d %b %Y')
            except:
                return None
</code>```

But the codes only get the birthdate right after "DOB", but not include the date of birth after "alt. DOB". Wonder how could i do it? Thank you.

答:
You can use (?<=DOB\s)[\s[a-zA-Z0-9]+]*

```<code>   (?<=DOB\s)  = Negative look-behind assertion. This matches string (which is to its right) only if the string preceded by letters DOB followed by a space
   [\s[a-zA-Z0-9]+]* = Match space followed by letters of numbers multiple times
</code>```

Example:

```<code>items=['DOB 23 Jun 1959; alt. DOB 23 Jun 1958', 'DOB 1959; alt. DOB 1958']
for item in items:
    print(re.findall(r'(?<=DOB\s)[\s[a-zA-Z0-9]+]*',item))
</code>```

Output

```<code>['23 Jun 1959', '23 Jun 1958']
['1959', '1958']
</code>```

Body:
In python 3:

This is the Office of Foreign Asset Control list where individuals' assets should be monitored

https://www.treasury.gov/ofac/downloads/sdn.csv

a lot of their data of births (the very last column, comma delimited) are like

DOB 23 Jun 1959; alt. DOB 23 Jun 1958

or

DOB 1959; alt. DOB 1958

I am trying to capture all the birthdates after the keyword "DOB" AND "alt. DOB" with the following codes:

   if len(x.split(';')) > 0:
        if len(re.findall('DOB (.*)', x.split(';')[0])) > 0:
            new = re.findall('DOB | alt. DOB (.*)', x.split(';')[0])[0]
            print(new)

            try:
                print(datetime.strptime(new, '%d %b %Y'))
                return datetime.strptime(new, '%d %b %Y')
            except:
                return None

But the codes only get the birthdate right after "DOB", but not include the date of birth after "alt. DOB". Wonder how could i do it? Thank you.

Body:
You can use (?<=DOB\s)[\s[a-zA-Z0-9]+]*

   (?<=DOB\s)  = Negative look-behind assertion. This matches string (which is to its right) only if the string preceded by letters DOB followed by a space
   [\s[a-zA-Z0-9]+]* = Match space followed by letters of numbers multiple times

Example:

items=['DOB 23 Jun 1959; alt. DOB 23 Jun 1958', 'DOB 1959; alt. DOB 1958']
for item in items:
    print(re.findall(r'(?<=DOB\s)[\s[a-zA-Z0-9]+]*',item))

Output

['23 Jun 1959', '23 Jun 1958']
['1959', '1958']


问:
Is it possible to call a directive in Chart.Js?
In angular JS and chart.js, its possible to display a tooltip on hover, and even call functions when you click a bar (Assuming that your using a bar graph from chart.js).

However, is it possible to call a directive when you click on a bar graph? Or should I use canvas.js for this?

The directive I'm refering to is custom and it pops-up as a window containing some values. It doesn't have to be a directive, it can even be an angular component you call after clicking a bar in the chart.

答:
From what I've looked into and made, it seems that this scenario was impossible. There are three type of directives, namely structural, component and property directive.

What I wanted was a property directive, but a property directive doesn't really have html code inside and it simply modifies/adds a behaviour to the DOM.

The best way to do what I wanted was to create a component and get the event thrown by the click function by adding the code (clickChart) = "chartClick($event)" to the Canvas

```<code><canvas myChart [datasets]="myDataSetVar" (chartClick)="chartClick($event)">
</code>```

By calling the chartClick function and passing the event. If you console.log the event, you can see the color, data, and alot of things from the chart just from this event. You can even tell if a dataset was clicked.

With this, instead of using a directive I used an ngIf that checks for a certain property that becomes true when a dataset from the chart is clicked. I then display the DOM element when the propert is true.

So the short answer to my question is: No, you cannot use a property directive to do what I wanted.

Body:
From what I've looked into and made, it seems that this scenario was impossible. There are three type of directives, namely structural, component and property directive.

What I wanted was a property directive, but a property directive doesn't really have html code inside and it simply modifies/adds a behaviour to the DOM.

The best way to do what I wanted was to create a component and get the event thrown by the click function by adding the code (clickChart) = "chartClick($event)" to the Canvas

<canvas myChart [datasets]="myDataSetVar" (chartClick)="chartClick($event)">

By calling the chartClick function and passing the event. If you console.log the event, you can see the color, data, and alot of things from the chart just from this event. You can even tell if a dataset was clicked.

With this, instead of using a directive I used an ngIf that checks for a certain property that becomes true when a dataset from the chart is clicked. I then display the DOM element when the propert is true.

So the short answer to my question is: No, you cannot use a property directive to do what I wanted.


问:
SOAP Envelope Element is not declared
I have an issue with a SOAP request I'm sending to an external ASP Web Service. I have used both SoapUI and PHP's SoapClient class, and both times the same issue occurs - an error that tells me The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.

My Request to 'GetStudentEntitlement'

```<code><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/" xmlns:heim="http://dest.gov.au/Heims/">
   <soap:Header/>
   <soap:Body><adm:GetStudentEntitlement>
         <heim:entitlementRequest>
            <heim:RequestControlTable>
               <heim:RequestId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RequestId>
               <heim:ClientOrganisationCode>7591</heim:ClientOrganisationCode>
               <heim:RequestLocalDateTime>2015-08-10T00:00:00</heim:RequestLocalDateTime>
            </heim:RequestControlTable>
            <heim:GetEntitlementIn>
               <heim:RecordId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RecordId>
               <heim:Chessn>1344</heim:Chessn>
               <heim:FamilyName>Bassett</heim:FamilyName>
               <heim:BirthDate>1988-05-21</heim:BirthDate>
            </heim:GetEntitlementIn>
         </heim:entitlementRequest>
      </adm:GetStudentEntitlement>
   </soap:Body>
</soap:Envelope>
</code>```

The response:

```<code><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <soap:Code>
            <soap:Value>soap:Sender</soap:Value>
         </soap:Code>
         <soap:Reason>
            <soap:Text xml:lang="en">Heims.WebServices.Extensions.Exceptions.XmlSchemaValidationException: Schema validation errors
   at Heims.WebServices.Extensions.SoapFilterExtension.ValidateXmlMessage(SoapMessage message, WebMethodSettings methodSettings) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 408
   at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessageBeforeDeserialise(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 200
   at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessage(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 173
   at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</soap:Text>
         </soap:Reason>
         <detail>
            <ValidationError>
               <RecordId/>
               <Element>Envelope</Element>
               <Line>1</Line>
               <Column>2</Column>
               <Description>The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.</Description>
            </ValidationError>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
</code>```

I have tried adding and removing the trailing / on the :soap declaration, as well as trying both the 1.1 and 1.2 SOAP versions offered by this web service.

This endpoint request to 'Ping' works correctly:

```<code><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/">
   <soap:Header/>
   <soap:Body>
      <adm:Ping/>
   </soap:Body>
</soap:Envelope>
</code>```

The result is returned as expected:

```<code><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <PingResponse xmlns="http://dest.gov.au/Heims/Admin/">
         <PingResult>Heims web services pinged. DateTime = 2015-08-10 11:11:00:05</PingResult>
      </PingResponse>
   </soap:Body>
</soap:Envelope>
</code>```

So why would the code for one request (the ping) work perfectly, while the other request (GetStudentEntitlement) fails? Both have the soap:Envelope declaration, but the Ping request works fine.

I have also tried using xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" in the soap:Envelope element, but the error remained.

Is it possible that this is a server-side issue from the Web Service itself? Or is something simply going wrong in my code?

答:
Did you get any solution to this...

I have encountered same problem today while converting UTL_DBWS utility (oracle plsql) to APEX utilities to make calls to HEIMS web service.

Ping worked but GetStudentEntitlements and AllocateStudentChessn both are failing with same envelop error.

Regards
RC

ContentLicense: CC BY-SA 3.0

Title: SOAP Envelope Element is not declared

Body:
I have an issue with a SOAP request I'm sending to an external ASP Web Service. I have used both SoapUI and PHP's SoapClient class, and both times the same issue occurs - an error that tells me The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.

My Request to 'GetStudentEntitlement'

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/" xmlns:heim="http://dest.gov.au/Heims/">
   <soap:Header/>
   <soap:Body><adm:GetStudentEntitlement>
         <heim:entitlementRequest>
            <heim:RequestControlTable>
               <heim:RequestId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RequestId>
               <heim:ClientOrganisationCode>7591</heim:ClientOrganisationCode>
               <heim:RequestLocalDateTime>2015-08-10T00:00:00</heim:RequestLocalDateTime>
            </heim:RequestControlTable>
            <heim:GetEntitlementIn>
               <heim:RecordId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RecordId>
               <heim:Chessn>1344</heim:Chessn>
               <heim:FamilyName>Bassett</heim:FamilyName>
               <heim:BirthDate>1988-05-21</heim:BirthDate>
            </heim:GetEntitlementIn>
         </heim:entitlementRequest>
      </adm:GetStudentEntitlement>
   </soap:Body>
</soap:Envelope>

The response:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <soap:Code>
            <soap:Value>soap:Sender</soap:Value>
         </soap:Code>
         <soap:Reason>
            <soap:Text xml:lang="en">Heims.WebServices.Extensions.Exceptions.XmlSchemaValidationException: Schema validation errors
   at Heims.WebServices.Extensions.SoapFilterExtension.ValidateXmlMessage(SoapMessage message, WebMethodSettings methodSettings) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 408
   at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessageBeforeDeserialise(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 200
   at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessage(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 173
   at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</soap:Text>
         </soap:Reason>
         <detail>
            <ValidationError>
               <RecordId/>
               <Element>Envelope</Element>
               <Line>1</Line>
               <Column>2</Column>
               <Description>The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.</Description>
            </ValidationError>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

I have tried adding and removing the trailing / on the :soap declaration, as well as trying both the 1.1 and 1.2 SOAP versions offered by this web service.

This endpoint request to 'Ping' works correctly:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/">
   <soap:Header/>
   <soap:Body>
      <adm:Ping/>
   </soap:Body>
</soap:Envelope>

The result is returned as expected:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <PingResponse xmlns="http://dest.gov.au/Heims/Admin/">
         <PingResult>Heims web services pinged. DateTime = 2015-08-10 11:11:00:05</PingResult>
      </PingResponse>
   </soap:Body>
</soap:Envelope>

So why would the code for one request (the ping) work perfectly, while the other request (GetStudentEntitlement) fails? Both have the soap:Envelope declaration, but the Ping request works fine.

I have also tried using xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" in the soap:Envelope element, but the error remained.

Is it possible that this is a server-side issue from the Web Service itself? Or is something simply going wrong in my code?


问:
Parse Tree Of Structs Easily With getline()?
This is a watered down version of a program that I'm working on. In this example, I'd like to parse through a text file and create a tree of Branch structs.

```<code>struct Branch {
    int value = -1;
    Branch *positive;
    Branch *negative;
}
</code>```

This is an example of what the text file would look like...

```<code>First Tree>
    Value:      5
    Positive:
        Value:      7
        Positive:   X
        Negative:
            Value:      23
            Positive:   X
            Negative:   X
    Negative:   X
Another Tree>
    Value:      1
    Positive:
        Value:      2
        Positive:   X
        Negative:   X
    Negative:
        Value:      3
        Positive:   X
        Negative:   X
Third Tree>
    Value:      19
    Positive:   X
    Negative:   X
</code>```

The names, which come before the >, should be ignored. There will always be 3 trees in the correct order, and I have pointers to them.

```<code>Branch *firsttree;
Branch *anothertree;
Branch *thirdtree;
</code>```

I'd imagine creating an array of pointers to the 3 Branch pointers (firsttree, anothertree, thirdtree), then iterating through them would be easiest way to ensure that we can put this into a loop.

I'd like to use getline() for this and not rely on some parsing library.

This is some psuedocode of what I'd expect the data to look like after being read:

```<code>//firsttree
{
    value: 5,
    positive: {
        value: 7,
        positive: nullptr,
        negative: {
            value: 23,
            positive: nullptr,
            negative: nullptr
        }
    },
    negative: nullptr
}

//anothertree
{
    value: 1,
    positive: {
        value: 2,
        positive: nullptr,
        negative: nulptr
    },
    negative: {
        value: 3,
        positive: nullptr,
        negative: nulptr
    }
}

//thirdtree
{
    value: 19,
    positive: nullptr,
    negative: nulptr
}
</code>```

Here it is in an image format:

Is there a way to easily loop through the input file relying on std::getline()? If so, could you help give me some psuedocode for achieving it, since I'm mostly getting lost on keeping track on the index and hopping into children nodes. Thank you so much!

答:
With this example, I have opted for code that is easy to understand rather than code that is robust and fault tolerant.  What that means is that this code relies on the input file having EXACTLY the info in your specification and there is no code that checks the input file is valid - or even that it exists.  The reason for that is I think the code is easier to understand without all that input validity checking - but of course you can't use the code without adding all that stuff.

This program reads the file from input.txt in your format, stores it in memory using your structure, and then prints the data it read in the output you specified.  Let me know if you need more info on how the code works and I will add more details.

The Branch structure is recursive by design because the structure contains pointers to structure of its own type.  So the secret to input and output of a structure like Branch is to do everything recursively.

For example, when a branch is to be parsed:

first read the value

then recursively read another branch for the positive side (using the same parsing code so that it can handle reading even more branches)

then recursively read another branch for the negative side (using the same parsing code so that it can handle reading even more branches)

So both the reading and printing parts are recursive:

You can try it here: https://onlinegdb.com/BkWv_G9mI

```<code>#include <iostream>
#include <sstream>
#include <fstream>
#include <string>

struct Branch {
    int value;
    Branch *positive;
    Branch *negative;
};

Branch *firsttree   = NULL;
Branch *anothertree = NULL;
Branch *thirdtree   = NULL;

void printbranch(Branch *branch, std::string indent)
{
    std::cout << "{\n";
    std::cout << indent << "    value: " << branch->value << ",\n";

    std::cout << indent << "    positive: ";
    if (branch->positive)
        printbranch(branch->positive, indent + "    ");
    else
        std::cout << "nullptr,\n";

    std::cout << indent << "    negative: ";
    if (branch->negative)
        printbranch(branch->negative, indent + "    ");
    else
        std::cout << "nullptr\n";

    std::cout << indent << "}\n";
}

void printtree(std::string treename, Branch *branch)
{
    std::cout << "//" << treename << "\n";
    printbranch(branch, "");
    std::cout << std::endl; // now we want to flush the output
}

Branch* readbranch(std::ifstream &file)
{
    Branch *branch = new Branch;
    std::string line, token, value;
    for (int currentitem = 0; currentitem < 3; currentitem++)
    {
        std::getline(file, line);
        std::istringstream ss(line);
        ss >> token;

        if (token == "Value:")
            ss >> branch->value;
        else if (token == "Positive:")
            branch->positive = !(ss >> value)?readbranch(file):nullptr;
        else if (token == "Negative:")
            branch->negative = !(ss >> value)?readbranch(file):nullptr;
    }
    return branch;
}

int main()
{
    std::string line;
    std::ifstream file("input.txt");

    // read the firsttree
    std::getline(file, line); // read the line with the >
    firsttree = readbranch(file);

    // read anothertree
    std::getline(file, line); // read the line with the >
    anothertree = readbranch(file);

    // read the thirdtree
    std::getline(file, line); // read the line with the >
    thirdtree = readbranch(file);

    // print the trees
    printtree("firsttree",firsttree);
    printtree("anothertree",anothertree);
    printtree("thirdtree",thirdtree);

    return 0;
}
</code>```

Body:
This is a watered down version of a program that I'm working on. In this example, I'd like to parse through a text file and create a tree of Branch structs.

struct Branch {
    int value = -1;
    Branch *positive;
    Branch *negative;
}

This is an example of what the text file would look like...

First Tree>
    Value:      5
    Positive:
        Value:      7
        Positive:   X
        Negative:
            Value:      23
            Positive:   X
            Negative:   X
    Negative:   X
Another Tree>
    Value:      1
    Positive:
        Value:      2
        Positive:   X
        Negative:   X
    Negative:
        Value:      3
        Positive:   X
        Negative:   X
Third Tree>
    Value:      19
    Positive:   X
    Negative:   X

The names, which come before the >, should be ignored. There will always be 3 trees in the correct order, and I have pointers to them.

Branch *firsttree;
Branch *anothertree;
Branch *thirdtree;

I'd imagine creating an array of pointers to the 3 Branch pointers (firsttree, anothertree, thirdtree), then iterating through them would be easiest way to ensure that we can put this into a loop.

I'd like to use getline() for this and not rely on some parsing library.

This is some psuedocode of what I'd expect the data to look like after being read:

//firsttree
{
    value: 5,
    positive: {
        value: 7,
        positive: nullptr,
        negative: {
            value: 23,
            positive: nullptr,
            negative: nullptr
        }
    },
    negative: nullptr
}

//anothertree
{
    value: 1,
    positive: {
        value: 2,
        positive: nullptr,
        negative: nulptr
    },
    negative: {
        value: 3,
        positive: nullptr,
        negative: nulptr
    }
}

//thirdtree
{
    value: 19,
    positive: nullptr,
    negative: nulptr
}

Here it is in an image format:

Is there a way to easily loop through the input file relying on std::getline()? If so, could you help give me some psuedocode for achieving it, since I'm mostly getting lost on keeping track on the index and hopping into children nodes. Thank you so much!

Body:
With this example, I have opted for code that is easy to understand rather than code that is robust and fault tolerant.  What that means is that this code relies on the input file having EXACTLY the info in your specification and there is no code that checks the input file is valid - or even that it exists.  The reason for that is I think the code is easier to understand without all that input validity checking - but of course you can't use the code without adding all that stuff.

This program reads the file from input.txt in your format, stores it in memory using your structure, and then prints the data it read in the output you specified.  Let me know if you need more info on how the code works and I will add more details.

The Branch structure is recursive by design because the structure contains pointers to structure of its own type.  So the secret to input and output of a structure like Branch is to do everything recursively.

For example, when a branch is to be parsed:

first read the value

then recursively read another branch for the positive side (using the same parsing code so that it can handle reading even more branches)

then recursively read another branch for the negative side (using the same parsing code so that it can handle reading even more branches)

So both the reading and printing parts are recursive:

You can try it here: https://onlinegdb.com/BkWv_G9mI

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>

struct Branch {
    int value;
    Branch *positive;
    Branch *negative;
};

Branch *firsttree   = NULL;
Branch *anothertree = NULL;
Branch *thirdtree   = NULL;

void printbranch(Branch *branch, std::string indent)
{
    std::cout << "{\n";
    std::cout << indent << "    value: " << branch->value << ",\n";

    std::cout << indent << "    positive: ";
    if (branch->positive)
        printbranch(branch->positive, indent + "    ");
    else
        std::cout << "nullptr,\n";

    std::cout << indent << "    negative: ";
    if (branch->negative)
        printbranch(branch->negative, indent + "    ");
    else
        std::cout << "nullptr\n";

    std::cout << indent << "}\n";
}

void printtree(std::string treename, Branch *branch)
{
    std::cout << "//" << treename << "\n";
    printbranch(branch, "");
    std::cout << std::endl; // now we want to flush the output
}

Branch* readbranch(std::ifstream &file)
{
    Branch *branch = new Branch;
    std::string line, token, value;
    for (int currentitem = 0; currentitem < 3; currentitem++)
    {
        std::getline(file, line);
        std::istringstream ss(line);
        ss >> token;

        if (token == "Value:")
            ss >> branch->value;
        else if (token == "Positive:")
            branch->positive = !(ss >> value)?readbranch(file):nullptr;
        else if (token == "Negative:")
            branch->negative = !(ss >> value)?readbranch(file):nullptr;
    }
    return branch;
}

int main()
{
    std::string line;
    std::ifstream file("input.txt");

    // read the firsttree
    std::getline(file, line); // read the line with the >
    firsttree = readbranch(file);

    // read anothertree
    std::getline(file, line); // read the line with the >
    anothertree = readbranch(file);

    // read the thirdtree
    std::getline(file, line); // read the line with the >
    thirdtree = readbranch(file);

    // print the trees
    printtree("firsttree",firsttree);
    printtree("anothertree",anothertree);
    printtree("thirdtree",thirdtree);

    return 0;
}


问:
Entity Send to Server Problem
On the client-side I add all related entities (navigation properties) to my main entity and attach it to the list and call SubmitChange. But on the server-side, all related entities are missing!

Code:

Client:

```<code>DomainService1 domainService1= new DomainService1();
.
.
.
WorkCode newWorkCode = new WorkCode();
newWorkCode.Date = DateTime.Now;

.
.
.

for(Work item in WorkList)
{
 newWorkCode.Works.Add(item)
}

.
.
.

domainService1.WorkCodes.Attach(newWorkCode);
domainService1.InsertWorkCode(newWorkCode);
      dsMaintenance.SubmitChanges(submitOperation =>
      {
        if (!submitOperation.HasError)
        {

        }
      },
            null);
</code>```

Server:

```<code>[Update(UsingCustomMethod = true)]
public void InsertWorkCode(WorkCode workCode)
{
    //////// workCode.Works = 0 ///////////////////

  this.ObjectContext.WorkCodes.AddObject(workCode);
}
</code>```

答:
I'm not sure what you are doing here. But if I want to add stuff I do it like this and it works:

```<code>Context = new DomainContext();

var customer = new Customer() { /* ... */ };
var order = new Order() { Customer = customer, /* ... */ };

Context.Customers.Add(customer);
Context.Orders.Add(order);
</code>```

If you like the other approach though, you can do that too like this:

```<code>var customer = new Customer() { /* ... */ };
var order = new Order { /* ... */ };

customer.Orders.Add(order);
Context.Customers.Add(customer);
</code>```

Now you just submit:

```<code>var submitOperation = Context.SubmitChanges();
submitOperation.Completed += // [...]
</code>```

Hope this helps.

Title: Entity Send to Server Problem

Body:
On the client-side I add all related entities (navigation properties) to my main entity and attach it to the list and call SubmitChange. But on the server-side, all related entities are missing!

Code:

Client:

DomainService1 domainService1= new DomainService1();
.
.
.
WorkCode newWorkCode = new WorkCode();
newWorkCode.Date = DateTime.Now;

.
.
.

for(Work item in WorkList)
{
 newWorkCode.Works.Add(item)
}

.
.
.

domainService1.WorkCodes.Attach(newWorkCode);
domainService1.InsertWorkCode(newWorkCode);
      dsMaintenance.SubmitChanges(submitOperation =>
      {
        if (!submitOperation.HasError)
        {

        }
      },
            null);

Server:

[Update(UsingCustomMethod = true)]
public void InsertWorkCode(WorkCode workCode)
{
    //////// workCode.Works = 0 ///////////////////

  this.ObjectContext.WorkCodes.AddObject(workCode);
}

Body:
I'm not sure what you are doing here. But if I want to add stuff I do it like this and it works:

Context = new DomainContext();

var customer = new Customer() { /* ... */ };
var order = new Order() { Customer = customer, /* ... */ };

Context.Customers.Add(customer);
Context.Orders.Add(order);

If you like the other approach though, you can do that too like this:

var customer = new Customer() { /* ... */ };
var order = new Order { /* ... */ };

customer.Orders.Add(order);
Context.Customers.Add(customer);

Now you just submit:

var submitOperation = Context.SubmitChanges();
submitOperation.Completed += // [...]

Hope this helps.