问:
How do you ensure that the update of a PWA is an "atomic transaction"?
In a PWA I have a JavaScript array installCache with names of files to cache. And this code for updating:

function addInstallListener() {
  self.addEventListener('install',
    event => {
      async function doIinstall() {
        try {
          await event.waitUntil(cache.addAll(installCache));
        } catch (err) {
          console.error("install event", err);
        }
      }
      event.waitUntil(doIinstall());
    }
  );
}
addInstallListener();
```

This does not work as I expect. I expect all the files listed to be installed on the client, but sometimes not all the files are updated.

The files are uploaded to the server (using firebase deploy), but the old version of a file may still be in the PWA cache in the browser.

(I am testing this in latest Chrome on Android and Windows 10.)

What is wrong here?

答:
You can get the behavior you describe by ensuring that the promise passed to event.waitUntil() rejects when there's a caching failure. Your current code wraps the async rejection in a catch block but then dosen't re-throw the error, so the overall promise will always end up fulfilling and never reject.

You can do this instead:

```<code>self.addEventListener('install', (event) => {
  const doInstall = async () => {
    try {
      const cache = await caches.open('my-cache-name');
      await cache.addAll(installCache);
    } catch (error) {
      // Do whatever logging you want.

      // Important: re-throw the error!
      throw error;
    }
  };

  event.waitUntil(doIinstall());
});
</code>```

I'd suggest reading through https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#install for an overview of this stage of the service worker lifecycle.

Body:
In a PWA I have a JavaScript array installCache with names of files to cache. And this code for updating:

function addInstallListener() {
  self.addEventListener('install',
    event => {
      async function doIinstall() {
        try {
          await event.waitUntil(cache.addAll(installCache));
        } catch (err) {
          console.error("install event", err);
        }
      }
      event.waitUntil(doIinstall());
    }
  );
}
addInstallListener();

This does not work as I expect. I expect all the files listed to be installed on the client, but sometimes not all the files are updated.

The files are uploaded to the server (using firebase deploy), but the old version of a file may still be in the PWA cache in the browser.

(I am testing this in latest Chrome on Android and Windows 10.)

What is wrong here?

Body:
You can get the behavior you describe by ensuring that the promise passed to event.waitUntil() rejects when there's a caching failure. Your current code wraps the async rejection in a catch block but then dosen't re-throw the error, so the overall promise will always end up fulfilling and never reject.

You can do this instead:

self.addEventListener('install', (event) => {
  const doInstall = async () => {
    try {
      const cache = await caches.open('my-cache-name');
      await cache.addAll(installCache);
    } catch (error) {
      // Do whatever logging you want.

      // Important: re-throw the error!
      throw error;
    }
  };

  event.waitUntil(doIinstall());
});

I'd suggest reading through https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#install for an overview of this stage of the service worker lifecycle.


来源: stackexchange

问:
Not getting a production build in create-react-app
I have a project using create-react-app.

I had no probelm working on it in developement mode (using scripts/start). After working on my project for a few weeks, I wanted to deploy for production.

I ran scripts/build.

This created a folder structure that looks like this :

I assume that the index.html is the entry point for all this so I ran index.html.

All I get is a blank screen with some 404 errors.

I have absolutely no idea what this means..!

I tried to have a look at the index.html file but it just contains obfuscated javascript. (create-react-app seems to hide everything that might be helpful in solving a problem).

```<code><!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <link rel="shortcut icon" href="/favicon.ico"/>
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/>
    <meta name="theme-color" content="#000000"/>
    <link rel="manifest" href="/manifest.json"/>
    <title>React App</title>
    <link href="/static/css/main.a5508311.chunk.css" rel="stylesheet">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script>!function (l) {
    function e(e) {
        for (var r, t, n = e[0], o = e[1], u = e[2], f = 0, i = []; f < n.length; f++) t = n[f], p[t] && i.push(p[t][0]), p[t] = 0;
        for (r in o) Object.prototype.hasOwnProperty.call(o, r) && (l[r] = o[r]);
        for (s && s(e); i.length;) i.shift()();
        return c.push.apply(c, u || []), a()
    }
</code>```

How do I get my create-react-app from developement into production?

UPDATE:

I decided to update my generated index.html file and put a '.' in front of my paths.

```<code><script src="/static/js/1.e82eda2e.chunk.js"></script>
</code>```

becomes :

```<code><script src="./static/js/1.e82eda2e.chunk.js"></script>
</code>```

Now it works (kind of). So much for this being an out of the box solution!!

How do I prevent my paths being messed up in create-react-app when generating the production build index.html? And why is it doing this in the first place??!

UPDATE 2:

Digging around the internet I found out that you can add

```<code>  "homepage": "./",
</code>```

I did this.

Now my application works, but the images are not loading. Also my react routing is broken. Refreshing links does not work....

答:
The best way you can do this is to simply run it locally using serve:

npm install serve -g

npm run build

serve -s build

This will create a local server running on port 5000 at http://localhost:5000

ContentLicense: CC BY-SA 4.0

Body:
I have a project using create-react-app.

I had no probelm working on it in developement mode (using scripts/start). After working on my project for a few weeks, I wanted to deploy for production.

I ran scripts/build.

This created a folder structure that looks like this :

I assume that the index.html is the entry point for all this so I ran index.html.

All I get is a blank screen with some 404 errors.

I have absolutely no idea what this means..!

I tried to have a look at the index.html file but it just contains obfuscated javascript. (create-react-app seems to hide everything that might be helpful in solving a problem).

<!doctype html>

    <meta charset="utf-8"/>
    <link rel="shortcut icon" href="/favicon.ico"/>
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/>
    <meta name="theme-color" content="#000000"/>
    <link rel="manifest" href="/manifest.json"/>
    <title>React App</title>
    <link href="/static/css/main.a5508311.chunk.css" rel="stylesheet">

You need to enable JavaScript to run this app.

becomes :

Now it works (kind of). So much for this being an out of the box solution!!

How do I prevent my paths being messed up in create-react-app when generating the production build index.html? And why is it doing this in the first place??!

UPDATE 2:

Digging around the internet I found out that you can add

  "homepage": "./",

I did this.

Now my application works, but the images are not loading. Also my react routing is broken. Refreshing links does not work....


问:
How to check if document exist if firestore database collection or not in Flutter application?
How to check whether a document exists in the firestore collection or not in flutter application?
I tried various examples already available on SO, but they seem to be deprecated. Please advise the solution</p>

```<code>DocumentReference ref2 = Firestore.instance.collection("users").document(currentUserID);
</code>```

答:
To check if a document exists, you need to use get() method which is used to retrieve the data from the document, then you can use the property exists:

```<code>    Firestore.instance
        .collection("users")
        .document(currentUserID)
        .get()
        .then((doc) {
      if(doc.exists) {
        print("exists");
      } else {
        print("doesnt exists");
      }
    });
</code>```

Body:
How to check whether a document exists in the firestore collection or not in flutter application?
I tried various examples already available on SO, but they seem to be deprecated. Please advise the solution

DocumentReference ref2 = Firestore.instance.collection("users").document(currentUserID);

Body:
To check if a document exists, you need to use get() method which is used to retrieve the data from the document, then you can use the property exists:

    Firestore.instance
        .collection("users")
        .document(currentUserID)
        .get()
        .then((doc) {
      if(doc.exists) {
        print("exists");
      } else {
        print("doesnt exists");
      }
    });


问:
JavaScript, issue with object variables being declared NaN
I have made the following object in javascript :

```<code>var gr = {
    SIZE : 30,
    NO_X : (window.innerWidth / this.SIZE),
    NO_Y : (window.innerHeight / this.SIZE),
    drawGrid : function(){
        console.log(`NO_X : ${this.NO_X}`);
        console.log(`NO_Y : ${this.NO_Y}`);

        //
        //grid drawing function here
        //
    }
}

</code>```

when I call the drawGrid function, the console log statements return the values of both NO_X and NO_Y as NaN, I would like them to equal the screen width / SIZE .

If I use window.innerWidth outside of the object it works as expected.

Sorry if the answer is obvious I am pretty new to programming in javascript.

thanks!

答:
You can convert NO_X and NO_Y to getters instead like:

```<code>get NO_X() {
    return window.innerWidth / this.SIZE
  },
  get NO_Y() {
    return window.innerHeight / this.SIZE
  },
</code>```

and then you should be able to access this.NO_X and this.NO_Y inside drawGrid properly. In this way you can draw grid with any size you want, instead of a fixed size 30.

var gr = {
  SIZE: 30,
  get NO_X() {
    return window.innerWidth / this.SIZE
  },
  get NO_Y() {
    return window.innerHeight / this.SIZE
  },
  drawGrid: function() {
    console.log(`NO_X : ${this.NO_X}`);
    console.log(`NO_Y : ${this.NO_Y}`);
  }
}

// Draw grid with size 30
gr.drawGrid()

// Draw grid with size 20
gr.SIZE = 20
gr.drawGrid()```

Body:
I have made the following object in javascript :

var gr = {
    SIZE : 30,
    NO_X : (window.innerWidth / this.SIZE),
    NO_Y : (window.innerHeight / this.SIZE),
    drawGrid : function(){
        console.log(`NO_X : ${this.NO_X}`);
        console.log(`NO_Y : ${this.NO_Y}`);

        //
        //grid drawing function here
        //
    }
}

when I call the drawGrid function, the console log statements return the values of both NO_X and NO_Y as NaN, I would like them to equal the screen width / SIZE .

If I use window.innerWidth outside of the object it works as expected.

Sorry if the answer is obvious I am pretty new to programming in javascript.

thanks!

Body:
You can convert NO_X and NO_Y to getters instead like:

get NO_X() {
    return window.innerWidth / this.SIZE
  },
  get NO_Y() {
    return window.innerHeight / this.SIZE
  },

and then you should be able to access this.NO_X and this.NO_Y inside drawGrid properly. In this way you can draw grid with any size you want, instead of a fixed size 30.

var gr = {
  SIZE: 30,
  get NO_X() {
    return window.innerWidth / this.SIZE
  },
  get NO_Y() {
    return window.innerHeight / this.SIZE
  },
  drawGrid: function() {
    console.log(`NO_X : ${this.NO_X}`);
    console.log(`NO_Y : ${this.NO_Y}`);
  }
}

// Draw grid with size 30
gr.drawGrid()

// Draw grid with size 20
gr.SIZE = 20
gr.drawGrid()


问:
How can I downgrade GKE master and exit Rapid channel
I didn't notice my GKE cluster is in Rapid channel. Until today I want to add Node Pool.

It shows Node version "1.17.5-gke.6" is unsupported.

https://cloud.google.com/kubernetes-engine/docs/release-notes-rapid#may_27_2020

My questions are:

How to downgrade GKE master version

How to update a GKE cluster don't use rapid channel

I can't find anything about that in gcloud cli, official documents and stackoverflow.

答:
When you create a cluster you have two options to choose from

A. Release channel [Rapid/Regular/Stable]

B. Static version

1.How to downgrade GKE master version.

From documentation, it mentions that if you are in release channel [Rapid/Regular/Stable], downgrading is not possible.

With static version it is possible to downgrade with the following limitations.

2.How to update a GKE cluster to not use rapid channel.

This is not possible and it will give the following error

```<code>Migrating off of releaseChannel RAPID is not supported.
</code>```

More information can be also found here in regards to the migration between different release channels.

Body:
When you create a cluster you have two options to choose from

A. Release channel [Rapid/Regular/Stable]

B. Static version

1.How to downgrade GKE master version.

From documentation, it mentions that if you are in release channel [Rapid/Regular/Stable], downgrading is not possible.

With static version it is possible to downgrade with the following limitations.

2.How to update a GKE cluster to not use rapid channel.

This is not possible and it will give the following error

Migrating off of releaseChannel RAPID is not supported.

More information can be also found here in regards to the migration between different release channels.


问:
Logitech Script, 1st and 2nd click events with time reset
What I want to do is if I press the button on my mouse it uses a key like "E" and if I press the button again it uses the key "W" and after 2 seconds it resets, I mean if I don’t press the same button after 2 seconds it uses letter "e " again. Is that possible?

I've tried some codes but no results yet:

```<code>  function OnEvent(event, arg, family)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
    toggle = not toggle
    if toggle then
      PressKey("e")
      ReleaseKey("e")
    else
      PressKey("w")
      ReleaseKey("w")
    end
  end
end
</code>```

答:
```<code>local prev_tm_btn5 = -math.huge

function OnEvent(event, arg, family)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
      local tm = GetRunningTime()
      local key = tm - prev_tm_btn5 > 2000 and "e" or "w"
      prev_tm_btn5 = tm
      PressKey(key)
      Sleep(15)
      ReleaseKey(key)
   end
end
</code>```

Body:
What I want to do is if I press the button on my mouse it uses a key like "E" and if I press the button again it uses the key "W" and after 2 seconds it resets, I mean if I don’t press the same button after 2 seconds it uses letter "e " again. Is that possible?

I've tried some codes but no results yet:

  function OnEvent(event, arg, family)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
    toggle = not toggle
    if toggle then
      PressKey("e")
      ReleaseKey("e")
    else
      PressKey("w")
      ReleaseKey("w")
    end
  end
end


问:
How to check from which onResume the user is coming
I have a problem. The following Picture visualises my issue. We start in App 1 and press the button. Now we either get to see the screen of app2 or the setting screen. Now when i press the back button (marked as the red circle in app2 and settings) and we get back to the app1 screen. But what i wanna know is from what screen we get back to the app1 screen.

```<code>    @Override
        protected void onResume() {
            super.onResume();

        // if(from setting) {
            // do this
           }

            NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
            NfcAdapter adapter = manager.getDefaultAdapter();
            if (adapter != null && adapter.isEnabled()) {
                   Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                    startActivity(userHomeScreen);

            }
        }

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nfc_setting);

        NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
        NfcAdapter adapter = manager.getDefaultAdapter();
        if (adapter != null && adapter.isEnabled()) {
            FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
            if (currentUser != null){
                Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                startActivity(userHomeScreen);
            }else{
                Intent loginScreen = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(loginScreen);
            }
        }
        else {
            btn_nfc_navigate_setting = findViewById(R.id.btn_nfc_navigate_setting);

            btn_nfc_navigate_setting.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
                }
            });
        }
</code>```

答:
Look now that I understand whats going on, you have to startActivityForResult() not startActivity():

Now in the activity that you use to open other activities:

When you open Log in screen:

```<code>Intent loginScreen = new Intent(getApplicationContext(), LoginActivity.class);
int requestCode = 10;
startActivityForResult(loginScreen , requestCode);
</code>```

When you open settings

```<code>btn_nfc_navigate_setting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int requestCode = 11;
startActivityForResult(new Intent(Settings.ACTION_NFC_SETTINGS) , requestCode);
}
});
</code>```

Override this method to listen to from where you came instead of onResume()

```<code>@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

//this is triggered when you come back to this activity
if(requestCode == 10){

//we came from login

}else if(requestCode == 11){

//we came from settings

}

}
</code>```

Body:
I have a problem. The following Picture visualises my issue. We start in App 1 and press the button. Now we either get to see the screen of app2 or the setting screen. Now when i press the back button (marked as the red circle in app2 and settings) and we get back to the app1 screen. But what i wanna know is from what screen we get back to the app1 screen.

    @Override
        protected void onResume() {
            super.onResume();

        // if(from setting) {
            // do this
           }

            NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
            NfcAdapter adapter = manager.getDefaultAdapter();
            if (adapter != null && adapter.isEnabled()) {
                   Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                    startActivity(userHomeScreen);

            }
        }

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nfc_setting);

        NfcManager manager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
        NfcAdapter adapter = manager.getDefaultAdapter();
        if (adapter != null && adapter.isEnabled()) {
            FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
            if (currentUser != null){
                Intent userHomeScreen = new Intent(getApplicationContext(), UserHomeActivity.class);
                startActivity(userHomeScreen);
            }else{
                Intent loginScreen = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(loginScreen);
            }
        }
        else {
            btn_nfc_navigate_setting = findViewById(R.id.btn_nfc_navigate_setting);

            btn_nfc_navigate_setting.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
                }
            });
        }

Body:
Look now that I understand whats going on, you have to startActivityForResult() not startActivity():

Now in the activity that you use to open other activities:

When you open Log in screen:

Intent loginScreen = new Intent(getApplicationContext(), LoginActivity.class);
int requestCode = 10;
startActivityForResult(loginScreen , requestCode);

When you open settings

btn_nfc_navigate_setting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int requestCode = 11;
startActivityForResult(new Intent(Settings.ACTION_NFC_SETTINGS) , requestCode);
}
});

Override this method to listen to from where you came instead of onResume()

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

//this is triggered when you come back to this activity
if(requestCode == 10){

//we came from login

}else if(requestCode == 11){

//we came from settings

}

}


问:
How to convert Python code to executable file
I want to convert Python code to executable file which can run on any machine without Python to be installed.
pygui.py is Python file name

```<code>pyinstaller.exe pygui.py
</code>```

I have try the above code but instead of executable file i got .pyc file

答: The .pyc file is your executable file. It's not a .exe file, but it is compiled code. It will run. See the pyinstaller manual for more information about Compiled Python code.

Body:
I want to convert Python code to executable file which can run on any machine without Python to be installed.
pygui.py is Python file name

pyinstaller.exe pygui.py

I have try the above code but instead of executable file i got .pyc file


问:
Is there a way to console.log when a variable has a certain value?
I am a starter coder and cannot find the solution to this problem. I have tried the code

```<code>var X = "Angry";
if X = "Angry" console.log(X is Angry)
</code>```

When I run this code I am informed of an error on the third line.

答:
You need to use == or === equality operator. Also, I would suggest  you should wrap your syntax for if blcok.

var X = "Angry";
if (X === "Angry") console.log('X is ' + X)

// Best way
if (X === "Angry") {
    console.log('X is ' + X)
}```

Body:
I am a starter coder and cannot find the solution to this problem. I have tried the code

var X = "Angry";
if X = "Angry" console.log(X is Angry)

When I run this code I am informed of an error on the third line.


问:
Vue 2 Unknown custom element on vue libraries
I'm using a few libraries in my vue project like FusionCharts, VueProgressBar etc. But I get this error in my console:

```<code>Unknown custom element: <vue-progress-bar> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <App> at src/App.vue
       <Root>
2vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: <fusioncharts> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Home> at src/views/Home.vue
       <App> at src/App.vue
         <Root>
</code>```

Here's my main.js where I use Vue.use() to incorporate these libraries in my app:

```<code>import Vue from "vue";
import firebase from "firebase/app";
import "firebase/firestore";
import { firestorePlugin } from "vuefire";
import Notifications from "vue-notification";
import VueProgressBar from "vue-progressbar";

// Include Dependencies
import VueFusionCharts from "vue-fusioncharts";
import FusionCharts from "fusioncharts";
import Column2D from "fusioncharts/fusioncharts.charts";
import FusionTheme from "fusioncharts/themes/fusioncharts.theme.fusion";

import App from "./App.vue";
import router from "./router";

import "./style.scss";

Vue.config.productionTip = false;

new Vue({
  router,
  render: h => h(App),
}).$mount("#app");

Vue.use(Notifications);
Vue.use(firestorePlugin);
Vue.use(VueProgressBar, {
  color: "rgb(143, 255, 199)",
  failedColor: "red",
  height: "2px"
});
Vue.use(VueFusionCharts, FusionCharts, Column2D, FusionTheme);
//More code here
</code>```

Why I'm getting this error even after properly importing and using these libraries?

答:
Change the order of code. You are creating a new Vue instance which does not have the component vue-progress-bar:</p>

```<code>Vue.use(Notifications);
Vue.use(firestorePlugin);
Vue.use(VueProgressBar, {
  color: "rgb(143, 255, 199)",
  failedColor: "red",
  height: "2px"
});
Vue.use(VueFusionCharts, FusionCharts, Column2D, FusionTheme);

new Vue({
  router,
  render: h => h(App),
}).$mount("#app");
</code>```

Body:
I'm using a few libraries in my vue project like FusionCharts, VueProgressBar etc. But I get this error in my console:

Unknown custom element: <vue-progress-bar> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <App> at src/App.vue
       <Root>
2vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: <fusioncharts> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Home> at src/views/Home.vue
       <App> at src/App.vue
         <Root>

Here's my main.js where I use Vue.use() to incorporate these libraries in my app:

import Vue from "vue";
import firebase from "firebase/app";
import "firebase/firestore";
import { firestorePlugin } from "vuefire";
import Notifications from "vue-notification";
import VueProgressBar from "vue-progressbar";

// Include Dependencies
import VueFusionCharts from "vue-fusioncharts";
import FusionCharts from "fusioncharts";
import Column2D from "fusioncharts/fusioncharts.charts";
import FusionTheme from "fusioncharts/themes/fusioncharts.theme.fusion";

import App from "./App.vue";
import router from "./router";

import "./style.scss";

Vue.config.productionTip = false;

new Vue({
  router,
  render: h => h(App),
}).$mount("#app");

Vue.use(Notifications);
Vue.use(firestorePlugin);
Vue.use(VueProgressBar, {
  color: "rgb(143, 255, 199)",
  failedColor: "red",
  height: "2px"
});
Vue.use(VueFusionCharts, FusionCharts, Column2D, FusionTheme);
//More code here

Why I'm getting this error even after properly importing and using these libraries?

Body:
Change the order of code. You are creating a new Vue instance which does not have the component vue-progress-bar:

Vue.use(Notifications);
Vue.use(firestorePlugin);
Vue.use(VueProgressBar, {
  color: "rgb(143, 255, 199)",
  failedColor: "red",
  height: "2px"
});
Vue.use(VueFusionCharts, FusionCharts, Column2D, FusionTheme);

new Vue({
  router,
  render: h => h(App),
}).$mount("#app");


问:
Is it better to write the same lines of code, or to recall the same function?
It's true that writing the same lines of code is not good programming, and would be better this approach, but does this bring to problems of any kind? will the variables created still exist, so am I wasting memory?

What do actually happens when I recall foo() ?

```<code>#include <stdio.h>

int foo(){
    printf("\nSelect operation. 1 to add, 2 to remove, 3 to exit.");
    printf("\n> ");
    unsigned int choice;
    scanf("%d",&choice);
    while (choice!=3){
        if (choice==1){
            // stuff
        } else if (choice==2){
            // stuff
        } else {
            printf("\nError, try again..\n");
            foo();          // what happens? does this bring to problems of any kind? will the variables created still exist, so am I wasting memory?
        }
    }
    printf("\nEnd of run.\n");
}
</code>```

or

```<code>#include <stdio.h>

int foo(){
    printf("\nSelect operation. 1 to add, 2 to remove, 3 to exit.");
    printf("\n> ");
    unsigned int choice;
    scanf("%d",&choice);
    while (choice!=3){
        if (choice==1){
            // stuff
        } else if (choice==2){
            // stuff
        } else {
            printf("\nError, try again..\n");
            printf("\nSelect operation. 1 to add, 2 to remove, 3 to exit.");
            printf("\n> ");
            scanf("%d",&choice);
        }
    }
    printf("\nEnd of run.\n");
}
</code>```

What's the best approach? I have also read that calling main() for example, is not good programming.

答:
If your call to foo() is the last statement (in your example it is not, as there is another call to printf, but I figure this is only for debugging) this is called a "tail-call", which may be optimized by your compiler:

With this optimization in place, you don't waste stack as the call is actually replaced by a jump.

Personally I am a bit careful relying on compiler optimizations, so you'd probably go better with a loop here. YMMV.

Edit: I oversaw that the call is actually in a loop itself, I guess you meant to replace the loop by the call. But maybe I got your idea wrong in the first place.

Body:
It's true that writing the same lines of code is not good programming, and would be better this approach, but does this bring to problems of any kind? will the variables created still exist, so am I wasting memory?

What do actually happens when I recall foo() ?

#include <stdio.h>

int foo(){
    printf("\nSelect operation. 1 to add, 2 to remove, 3 to exit.");
    printf("\n> ");
    unsigned int choice;
    scanf("%d",&choice);
    while (choice!=3){
        if (choice==1){
            // stuff
        } else if (choice==2){
            // stuff
        } else {
            printf("\nError, try again..\n");
            foo();          // what happens? does this bring to problems of any kind? will the variables created still exist, so am I wasting memory?
        }
    }
    printf("\nEnd of run.\n");
}

or

#include <stdio.h>

int foo(){
    printf("\nSelect operation. 1 to add, 2 to remove, 3 to exit.");
    printf("\n> ");
    unsigned int choice;
    scanf("%d",&choice);
    while (choice!=3){
        if (choice==1){
            // stuff
        } else if (choice==2){
            // stuff
        } else {
            printf("\nError, try again..\n");
            printf("\nSelect operation. 1 to add, 2 to remove, 3 to exit.");
            printf("\n> ");
            scanf("%d",&choice);
        }
    }
    printf("\nEnd of run.\n");
}

What's the best approach? I have also read that calling main() for example, is not good programming.


问:
How does WCF + SSL working with load balancing?
If SSL is handled by a load balancer, do I still need to configure it in the WCF serviceCertificate node?  My scenario is to use message level security.  If someone can explain how load balancing with wcf and ssl works, that would be very nice.</p>

答:
If you want to use message security then each message is encrypted and signed separately - there is no secure connection and load balancer behaves as with any other HTTP transport. Loadbalancer doesn't know about security and doesn't need certificate.

There are two gotchas:

All load balanced application servers hosting your WCF service must use the same certificate

You must ensure that your WCF binding doesn't use sessions (reliable, security) otherwise you will need load balancing algorithm with sticky sessions (all request for single session always routed to the same server)

ContentLicense: CC BY-SA 3.0


问:
Azure Data Factory Pipeline errorCode
I have a relatively simple process set up in Azure Data Factory to copy, cleanse and process some log files from a chatbot which has been running fine until I recently started getting the following errorCode:

```<code>    "errorCode": "InvalidTemplate",
    "message": "Unable to process expressions for action 'EvaluatefinaliseTSCRPTS': 'The function 'bool' was invoked with a parameter that is not valid. The value cannot be converted to the target type",
    "failureType": "UserError",
    "target": "finaliseTSCRPTS",
    "details": ""
</code>```

I can't seem to identify the error in the ADF process despite going through the code for my process below:

```
"name": "SearchBot dailyTranscripts",
"properties": {
    "activities": [
        {
            "name": "MST Validation",
            "type": "Validation",
            "dependsOn": [],
            "userProperties": [],
            "typeProperties": {
                "dataset": {
                    "referenceName": "teamsLogs",
                    "type": "DatasetReference"
                },
                "timeout": "0.00:00:30",
                "sleep": 10,
                "childItems": true
            }
        },
        {
            "name": "Get MST-TSCRPTS",
            "type": "Copy",
            "dependsOn": [
                {
                    "activity": "MST Validation",
                    "dependencyConditions": [
                        "Succeeded"
                    ]
                }
            ],
            "policy": {
                "timeout": "7.00:00:00",
                "retry": 0,
                "retryIntervalInSeconds": 30,
                "secureOutput": false,
                "secureInput": false
            },
            "userProperties": [],
            "typeProperties": {
                "source": {
                    "type": "JsonSource",
                    "storeSettings": {
                        "type": "AzureBlobStorageReadSettings",
                        "recursive": true,
                        "wildcardFileName": "*.json",
                        "enablePartitionDiscovery": false
                    }
                },
                "sink": {
                    "type": "JsonSink",
                    "storeSettings": {
                        "type": "AzureBlobStorageWriteSettings",
                        "copyBehavior": "MergeFiles"
                    },
                    "formatSettings": {
                        "type": "JsonWriteSettings",
                        "quoteAllText": true
                    }
                },
                "enableStaging": false,
                "translator": {
                    "type": "TabularTranslator",
                    "mappings": [
                        {
                            "source": {
                                "path": "$['type']"
                            },
                            "sink": {
                                "path": "$['type']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['timestamp']"
                            },
                            "sink": {
                                "path": "$['timestamp']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['id']"
                            },
                            "sink": {
                                "path": "$['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['channelId']"
                            },
                            "sink": {
                                "path": "$['channelId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['serviceUrl']"
                            },
                            "sink": {
                                "path": "$['serviceUrl']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['id']"
                            },
                            "sink": {
                                "path": "$['from']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['aadObjectId']"
                            },
                            "sink": {
                                "path": "$['from']['aadObjectId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['role']"
                            },
                            "sink": {
                                "path": "$['from']['role']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['name']"
                            },
                            "sink": {
                                "path": "$['from']['name']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['conversation']['conversationType']"
                            },
                            "sink": {
                                "path": "$['conversation']['conversationType']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['conversation']['tenantId']"
                            },
                            "sink": {
                                "path": "$['conversation']['tenantId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['conversation']['id']"
                            },
                            "sink": {
                                "path": "$['conversation']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['id']"
                            },
                            "sink": {
                                "path": "$['recipient']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['name']"
                            },
                            "sink": {
                                "path": "$['recipient']['name']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['aadObjectId']"
                            },
                            "sink": {
                                "path": "$['recipient']['aadObjectId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['role']"
                            },
                            "sink": {
                                "path": "$['recipient']['role']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['channelData']['tenant']['id']"
                            },
                            "sink": {
                                "path": "$['channelData']['tenant']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['text']"
                            },
                            "sink": {
                                "path": "$['text']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['inputHint']"
                            },
                            "sink": {
                                "path": "$['inputHint']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['replyToId']"
                            },
                            "sink": {
                                "path": "$['replyToId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['textFormat']"
                            },
                            "sink": {
                                "path": "$['textFormat']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['localTimestamp']"
                            },
                            "sink": {
                                "path": "$['localTimestamp']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['locale']"
                            },
                            "sink": {
                                "path": "$['locale']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['value']"
                            },
                            "sink": {
                                "path": "$['value']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['valueType']"
                            },
                            "sink": {
                                "path": "$['valueType']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['name']"
                            },
                            "sink": {
                                "path": "$['name']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['label']"
                            },
                            "sink": {
                                "path": "$['label']"
                            }
                        }
                    ]
                }
            },
            "inputs": [
                {
                    "referenceName": "teamsLogs",
                    "type": "DatasetReference"
                }
            ],
            "outputs": [
                {
                    "referenceName": "transcriptsStaging",
                    "type": "DatasetReference"
                }
            ]
        },
        {
            "name": "finaliseTSCRPTS",
            "type": "IfCondition",
            "dependsOn": [
                {
                    "activity": "MST Validation",
                    "dependencyConditions": [
                        "Completed"
                    ]
                },
                {
                    "activity": "Get MST-TSCRPTS",
                    "dependencyConditions": [
                        "Succeeded",
                        "Skipped"
                    ]
                }
            ],
            "userProperties": [],
            "typeProperties": {
                "expression": {
                    "value": "activity('MST Validation').output.exists",
                    "type": "Expression"
                },
                "ifTrueActivities": [
                    {
                        "name": "Combine TSCRPTS",
                        "type": "Copy",
                        "dependsOn": [],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true,
                                    "wildcardFileName": "*.json",
                                    "enablePartitionDiscovery": false
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings",
                                    "copyBehavior": "MergeFiles"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "transcriptsStaging",
                                "type": "DatasetReference"
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "SearchBotDailyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@concat(formatDateTime(utcnow(), 'yyyy-MM-dd'),'.json')"
                                }
                            }
                        ]
                    },
                    {
                        "name": "Delete Staging",
                        "type": "Delete",
                        "dependsOn": [
                            {
                                "activity": "Combine TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "dataset": {
                                "referenceName": "transcriptsStaging",
                                "type": "DatasetReference"
                            },
                            "enableLogging": false,
                            "storeSettings": {
                                "type": "AzureBlobStorageReadSettings",
                                "recursive": true
                            }
                        }
                    },
                    {
                        "name": "Get monthlyTSCRPTS",
                        "type": "Copy",
                        "dependsOn": [
                            {
                                "activity": "Combine TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "SearchBotDailyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@concat('2019-',formatDateTime(utcnow(), 'MM'),'-??.json')"
                                }
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "SearchBotMonthlyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@dataset().sourceFileName"
                                }
                            }
                        ]
                    },
                    {
                        "name": "Get yearlyTSCRPTS",
                        "type": "Copy",
                        "dependsOn": [
                            {
                                "activity": "Get monthlyTSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings",
                                    "copyBehavior": "MergeFiles"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "SearchBotMonthlyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": {
                                        "value": "@concat(formatDateTime(utcnow(), 'yyyy'),'-??.json')",
                                        "type": "Expression"
                                    }
                                }
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "SearchBotYearlyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@dataset().sourceFileName"
                                }
                            }
                        ]
                    },
                    {
                        "name": "Copy MST-TSCRPTS",
                        "type": "Copy",
                        "dependsOn": [
                            {
                                "activity": "Delete Staging",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "0.00:01:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true,
                                    "wildcardFileName": "*.json",
                                    "enablePartitionDiscovery": false
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings",
                                    "copyBehavior": "MergeFiles"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "teamsLogs",
                                "type": "DatasetReference"
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "transcriptsHistory",
                                "type": "DatasetReference"
                            }
                        ]
                    },
                    {
                        "name": "Delete MST-TSCRPTS",
                        "type": "Delete",
                        "dependsOn": [
                            {
                                "activity": "Copy MST-TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded",
                                    "Failed"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "dataset": {
                                "referenceName": "teamsLogs",
                                "type": "DatasetReference"
                            },
                            "enableLogging": false,
                            "storeSettings": {
                                "type": "AzureBlobStorageReadSettings",
                                "recursive": true
                            }
                        }
                    },
                    {
                        "name": "run learningList",
                        "type": "ExecutePipeline",
                        "dependsOn": [
                            {
                                "activity": "Delete MST-TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped"
                                ]
                            }
                        ],
                        "userProperties": [],
                        "typeProperties": {
                            "pipeline": {
                                "referenceName": "runLearningList",
                                "type": "PipelineReference"
                            },
                            "waitOnCompletion": true
                        }
                    }
                ]
            }
        }
    ],
    "parameters": {
        "sourceFileName": {
            "type": "string",
            "defaultValue": "@concat(formatDateTime(utcnow(),'yyyy-MM-dd'),'.json')"
        }
    },
    "annotations": []
},
"type": "Microsoft.DataFactory/factories/pipelines"
```

There is no expression 'EvaluatefinaliseTSCRPTS' and I can't find a 'bool' function either. The only hint I've found was a previous question here

答: You have an IF activity named "finaliseTSCRPTS", so "EvaluatefinaliseTSCRPTS" is most likely the internal name of the function that performs the IF condition check. The message seems to indicate that it cannot evaluate your expression "activity('MST Validation').output.exists".</p>

Title: Azure Data Factory Pipeline errorCode

Body:
I have a relatively simple process set up in Azure Data Factory to copy, cleanse and process some log files from a chatbot which has been running fine until I recently started getting the following errorCode:

    "errorCode": "InvalidTemplate",
    "message": "Unable to process expressions for action 'EvaluatefinaliseTSCRPTS': 'The function 'bool' was invoked with a parameter that is not valid. The value cannot be converted to the target type",
    "failureType": "UserError",
    "target": "finaliseTSCRPTS",
    "details": ""

I can't seem to identify the error in the ADF process despite going through the code for my process below:

"name": "SearchBot dailyTranscripts",
"properties": {
    "activities": [
        {
            "name": "MST Validation",
            "type": "Validation",
            "dependsOn": [],
            "userProperties": [],
            "typeProperties": {
                "dataset": {
                    "referenceName": "teamsLogs",
                    "type": "DatasetReference"
                },
                "timeout": "0.00:00:30",
                "sleep": 10,
                "childItems": true
            }
        },
        {
            "name": "Get MST-TSCRPTS",
            "type": "Copy",
            "dependsOn": [
                {
                    "activity": "MST Validation",
                    "dependencyConditions": [
                        "Succeeded"
                    ]
                }
            ],
            "policy": {
                "timeout": "7.00:00:00",
                "retry": 0,
                "retryIntervalInSeconds": 30,
                "secureOutput": false,
                "secureInput": false
            },
            "userProperties": [],
            "typeProperties": {
                "source": {
                    "type": "JsonSource",
                    "storeSettings": {
                        "type": "AzureBlobStorageReadSettings",
                        "recursive": true,
                        "wildcardFileName": "*.json",
                        "enablePartitionDiscovery": false
                    }
                },
                "sink": {
                    "type": "JsonSink",
                    "storeSettings": {
                        "type": "AzureBlobStorageWriteSettings",
                        "copyBehavior": "MergeFiles"
                    },
                    "formatSettings": {
                        "type": "JsonWriteSettings",
                        "quoteAllText": true
                    }
                },
                "enableStaging": false,
                "translator": {
                    "type": "TabularTranslator",
                    "mappings": [
                        {
                            "source": {
                                "path": "$['type']"
                            },
                            "sink": {
                                "path": "$['type']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['timestamp']"
                            },
                            "sink": {
                                "path": "$['timestamp']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['id']"
                            },
                            "sink": {
                                "path": "$['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['channelId']"
                            },
                            "sink": {
                                "path": "$['channelId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['serviceUrl']"
                            },
                            "sink": {
                                "path": "$['serviceUrl']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['id']"
                            },
                            "sink": {
                                "path": "$['from']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['aadObjectId']"
                            },
                            "sink": {
                                "path": "$['from']['aadObjectId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['role']"
                            },
                            "sink": {
                                "path": "$['from']['role']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['from']['name']"
                            },
                            "sink": {
                                "path": "$['from']['name']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['conversation']['conversationType']"
                            },
                            "sink": {
                                "path": "$['conversation']['conversationType']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['conversation']['tenantId']"
                            },
                            "sink": {
                                "path": "$['conversation']['tenantId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['conversation']['id']"
                            },
                            "sink": {
                                "path": "$['conversation']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['id']"
                            },
                            "sink": {
                                "path": "$['recipient']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['name']"
                            },
                            "sink": {
                                "path": "$['recipient']['name']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['aadObjectId']"
                            },
                            "sink": {
                                "path": "$['recipient']['aadObjectId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['recipient']['role']"
                            },
                            "sink": {
                                "path": "$['recipient']['role']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['channelData']['tenant']['id']"
                            },
                            "sink": {
                                "path": "$['channelData']['tenant']['id']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['text']"
                            },
                            "sink": {
                                "path": "$['text']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['inputHint']"
                            },
                            "sink": {
                                "path": "$['inputHint']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['replyToId']"
                            },
                            "sink": {
                                "path": "$['replyToId']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['textFormat']"
                            },
                            "sink": {
                                "path": "$['textFormat']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['localTimestamp']"
                            },
                            "sink": {
                                "path": "$['localTimestamp']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['locale']"
                            },
                            "sink": {
                                "path": "$['locale']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['value']"
                            },
                            "sink": {
                                "path": "$['value']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['valueType']"
                            },
                            "sink": {
                                "path": "$['valueType']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['name']"
                            },
                            "sink": {
                                "path": "$['name']"
                            }
                        },
                        {
                            "source": {
                                "path": "$['label']"
                            },
                            "sink": {
                                "path": "$['label']"
                            }
                        }
                    ]
                }
            },
            "inputs": [
                {
                    "referenceName": "teamsLogs",
                    "type": "DatasetReference"
                }
            ],
            "outputs": [
                {
                    "referenceName": "transcriptsStaging",
                    "type": "DatasetReference"
                }
            ]
        },
        {
            "name": "finaliseTSCRPTS",
            "type": "IfCondition",
            "dependsOn": [
                {
                    "activity": "MST Validation",
                    "dependencyConditions": [
                        "Completed"
                    ]
                },
                {
                    "activity": "Get MST-TSCRPTS",
                    "dependencyConditions": [
                        "Succeeded",
                        "Skipped"
                    ]
                }
            ],
            "userProperties": [],
            "typeProperties": {
                "expression": {
                    "value": "activity('MST Validation').output.exists",
                    "type": "Expression"
                },
                "ifTrueActivities": [
                    {
                        "name": "Combine TSCRPTS",
                        "type": "Copy",
                        "dependsOn": [],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true,
                                    "wildcardFileName": "*.json",
                                    "enablePartitionDiscovery": false
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings",
                                    "copyBehavior": "MergeFiles"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "transcriptsStaging",
                                "type": "DatasetReference"
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "SearchBotDailyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@concat(formatDateTime(utcnow(), 'yyyy-MM-dd'),'.json')"
                                }
                            }
                        ]
                    },
                    {
                        "name": "Delete Staging",
                        "type": "Delete",
                        "dependsOn": [
                            {
                                "activity": "Combine TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "dataset": {
                                "referenceName": "transcriptsStaging",
                                "type": "DatasetReference"
                            },
                            "enableLogging": false,
                            "storeSettings": {
                                "type": "AzureBlobStorageReadSettings",
                                "recursive": true
                            }
                        }
                    },
                    {
                        "name": "Get monthlyTSCRPTS",
                        "type": "Copy",
                        "dependsOn": [
                            {
                                "activity": "Combine TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "SearchBotDailyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@concat('2019-',formatDateTime(utcnow(), 'MM'),'-??.json')"
                                }
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "SearchBotMonthlyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@dataset().sourceFileName"
                                }
                            }
                        ]
                    },
                    {
                        "name": "Get yearlyTSCRPTS",
                        "type": "Copy",
                        "dependsOn": [
                            {
                                "activity": "Get monthlyTSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings",
                                    "copyBehavior": "MergeFiles"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "SearchBotMonthlyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": {
                                        "value": "@concat(formatDateTime(utcnow(), 'yyyy'),'-??.json')",
                                        "type": "Expression"
                                    }
                                }
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "SearchBotYearlyTranscripts",
                                "type": "DatasetReference",
                                "parameters": {
                                    "sourceFileName": "@dataset().sourceFileName"
                                }
                            }
                        ]
                    },
                    {
                        "name": "Copy MST-TSCRPTS",
                        "type": "Copy",
                        "dependsOn": [
                            {
                                "activity": "Delete Staging",
                                "dependencyConditions": [
                                    "Succeeded"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "0.00:01:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "source": {
                                "type": "JsonSource",
                                "storeSettings": {
                                    "type": "AzureBlobStorageReadSettings",
                                    "recursive": true,
                                    "wildcardFileName": "*.json",
                                    "enablePartitionDiscovery": false
                                }
                            },
                            "sink": {
                                "type": "JsonSink",
                                "storeSettings": {
                                    "type": "AzureBlobStorageWriteSettings",
                                    "copyBehavior": "MergeFiles"
                                },
                                "formatSettings": {
                                    "type": "JsonWriteSettings",
                                    "quoteAllText": true
                                }
                            },
                            "enableStaging": false
                        },
                        "inputs": [
                            {
                                "referenceName": "teamsLogs",
                                "type": "DatasetReference"
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "transcriptsHistory",
                                "type": "DatasetReference"
                            }
                        ]
                    },
                    {
                        "name": "Delete MST-TSCRPTS",
                        "type": "Delete",
                        "dependsOn": [
                            {
                                "activity": "Copy MST-TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded",
                                    "Failed"
                                ]
                            }
                        ],
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "userProperties": [],
                        "typeProperties": {
                            "dataset": {
                                "referenceName": "teamsLogs",
                                "type": "DatasetReference"
                            },
                            "enableLogging": false,
                            "storeSettings": {
                                "type": "AzureBlobStorageReadSettings",
                                "recursive": true
                            }
                        }
                    },
                    {
                        "name": "run learningList",
                        "type": "ExecutePipeline",
                        "dependsOn": [
                            {
                                "activity": "Delete MST-TSCRPTS",
                                "dependencyConditions": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped"
                                ]
                            }
                        ],
                        "userProperties": [],
                        "typeProperties": {
                            "pipeline": {
                                "referenceName": "runLearningList",
                                "type": "PipelineReference"
                            },
                            "waitOnCompletion": true
                        }
                    }
                ]
            }
        }
    ],
    "parameters": {
        "sourceFileName": {
            "type": "string",
            "defaultValue": "@concat(formatDateTime(utcnow(),'yyyy-MM-dd'),'.json')"
        }
    },
    "annotations": []
},
"type": "Microsoft.DataFactory/factories/pipelines"

There is no expression 'EvaluatefinaliseTSCRPTS' and I can't find a 'bool' function either. The only hint I've found was a previous question here


问:
How do I render one of several of the same react component?
I dont know if my brain is extra mushy today or what. Im trying to learn react and now I have a list of messages that is rendered from an array. Inside every message I have a button to render the "send message" component to answer the message. My problem is that when I press the button "answer", All the message-items in the list renders the 'send message' component. How do I bind it to just one message I clicked answer in?
See my code and you will understand my question:</p>

```<code>render() {
let messages = this.state.messages.map((item, key) =>
  <div>
    <ul key={item.id} className="messageList">
      <li><h3 className="messageTitle">{item.title}</h3></li>
      <li>{item.message}</li>
      <li className="messageSignature">from: {item.from}</li>
    </ul>
    {this.state.showSendMessage ? <SendMessage recipient={item.from} title={item.title}></SendMessage> : null}
    <button onClick={this.toggleShowSendMsg.bind(this)}>Answer</button>
  </div>
);
</code>```

答:
Its because your state variable "showSendMessage" is not unique to any particular message and hence its becoming true for all the elements of messages.

Add one more state variable as "key".

```<code>render() {
let messages = this.state.messages.map((item, key) =>
  <div>
    <ul key={item.id} className="messageList">
      <li><h3 className="messageTitle">{item.title}</h3></li>
      <li>{item.message}</li>
      <li className="messageSignature">from: {item.from}</li>
    </ul>
    {this.state.showSendMessage && this.state.key == key ? <SendMessage recipient={item.from} title={item.title}></SendMessage> : null}
    <button onClick={this.toggleShowSendMsg.bind(key)}>Answer</button>
  </div>
);
</code>```

and change the state of key in your toggleShowSendMsg method the way you are doing for showSendMessage.

Body:
I dont know if my brain is extra mushy today or what. Im trying to learn react and now I have a list of messages that is rendered from an array. Inside every message I have a button to render the "send message" component to answer the message. My problem is that when I press the button "answer", All the message-items in the list renders the 'send message' component. How do I bind it to just one message I clicked answer in?
See my code and you will understand my question:

render() {
let messages = this.state.messages.map((item, key) =>

{item.title}

{item.message}

from: {item.from}

    {this.state.showSendMessage ? <SendMessage recipient={item.from} title={item.title}></SendMessage> : null}
    <button onClick={this.toggleShowSendMsg.bind(this)}>Answer</button>

);

Body:
Its because your state variable "showSendMessage" is not unique to any particular message and hence its becoming true for all the elements of messages.

Add one more state variable as "key".

render() {
let messages = this.state.messages.map((item, key) =>
  <div>
    <ul key={item.id} className="messageList">
      <li><h3 className="messageTitle">{item.title}</h3></li>
      <li>{item.message}</li>
      <li className="messageSignature">from: {item.from}</li>
    </ul>
    {this.state.showSendMessage && this.state.key == key ? <SendMessage recipient={item.from} title={item.title}></SendMessage> : null}
    <button onClick={this.toggleShowSendMsg.bind(key)}>Answer</button>
  </div>
);

and change the state of key in your toggleShowSendMsg method the way you are doing for showSendMessage.


问:
In which case do you use the JPA @JoinTable annotation?
In which case do you use the JPA @JoinTable annotation?

答:
@ManyToMany associations

Most often, you will need to use @JoinTable annotation to specify the mapping of a many-to-many table relationship:

the name of the link table and

the two Foreign Key columns

So, assuming you have the following database tables:

In the Post entity, you would map this relationship, like this:

```<code>@ManyToMany(cascade = {
    CascadeType.PERSIST,
    CascadeType.MERGE
})
@JoinTable(
    name = "post_tag",
    joinColumns = @JoinColumn(name = "post_id"),
    inverseJoinColumns = @JoinColumn(name = "tag_id")
)
private List<Tag> tags = new ArrayList<>();
</code>```

The @JoinTable annotation is used to specify the table name via the name attribute, as well as the Foreign Key column that references the post table (e.g., joinColumns) and the Foreign Key column in the post_tag link table that references the Tag entity via the inverseJoinColumns attribute.

Notice that the cascade attribute of the @ManyToMany annotation is set to PERSIST and MERGE only because cascading REMOVE is a bad idea since we the DELETE statement will be issued for the other parent record, tag in our case, not to the post_tag record.

Unidirectional @OneToMany associations

The unidirectional @OneToMany associations, that lack a @JoinColumn mapping, behave like many-to-many table relationships, rather than one-to-many.

So, assuming you have the following entity mappings:

```<code>@Entity(name = "Post")
@Table(name = "post")
public class Post {

    @Id
    @GeneratedValue
    private Long id;

    private String title;

    @OneToMany(
        cascade = CascadeType.ALL,
        orphanRemoval = true
    )
    private List<PostComment> comments = new ArrayList<>();

    //Constructors, getters and setters removed for brevity
}

@Entity(name = "PostComment")
@Table(name = "post_comment")
public class PostComment {

    @Id
    @GeneratedValue
    private Long id;

    private String review;

    //Constructors, getters and setters removed for brevity
}
</code>```

Hibernate will assume the following database schema for the above entity mapping:

As already explained, the unidirectional @OneToMany JPA mapping behaves like a many-to-many association.

To customize the link table, you can also use the @JoinTable annotation:

```<code>@OneToMany(
    cascade = CascadeType.ALL,
    orphanRemoval = true
)
@JoinTable(
    name = "post_comment_ref",
    joinColumns = @JoinColumn(name = "post_id"),
    inverseJoinColumns = @JoinColumn(name = "post_comment_id")
)
private List<PostComment> comments = new ArrayList<>();
</code>```

And now, the link table is going to be called post_comment_ref and the Foreign Key columns will be post_id, for the post table, and post_comment_id, for the post_comment table.

Unidirectional @OneToMany associations are not efficient, so you are better off using bidirectional @OneToMany associations or just the @ManyToOne side.

Body:
@ManyToMany associations

Most often, you will need to use @JoinTable annotation to specify the mapping of a many-to-many table relationship:

the name of the link table and

the two Foreign Key columns

So, assuming you have the following database tables:

In the Post entity, you would map this relationship, like this:

@ManyToMany(cascade = {
    CascadeType.PERSIST,
    CascadeType.MERGE
})
@JoinTable(
    name = "post_tag",
    joinColumns = @JoinColumn(name = "post_id"),
    inverseJoinColumns = @JoinColumn(name = "tag_id")
)
private List<Tag> tags = new ArrayList<>();

The @JoinTable annotation is used to specify the table name via the name attribute, as well as the Foreign Key column that references the post table (e.g., joinColumns) and the Foreign Key column in the post_tag link table that references the Tag entity via the inverseJoinColumns attribute.

Notice that the cascade attribute of the @ManyToMany annotation is set to PERSIST and MERGE only because cascading REMOVE is a bad idea since we the DELETE statement will be issued for the other parent record, tag in our case, not to the post_tag record.

Unidirectional @OneToMany associations

The unidirectional @OneToMany associations, that lack a @JoinColumn mapping, behave like many-to-many table relationships, rather than one-to-many.

So, assuming you have the following entity mappings:

@Entity(name = "Post")
@Table(name = "post")
public class Post {

    @Id
    @GeneratedValue
    private Long id;

    private String title;

    @OneToMany(
        cascade = CascadeType.ALL,
        orphanRemoval = true
    )
    private List<PostComment> comments = new ArrayList<>();

    //Constructors, getters and setters removed for brevity
}

@Entity(name = "PostComment")
@Table(name = "post_comment")
public class PostComment {

    @Id
    @GeneratedValue
    private Long id;

    private String review;

    //Constructors, getters and setters removed for brevity
}

Hibernate will assume the following database schema for the above entity mapping:

As already explained, the unidirectional @OneToMany JPA mapping behaves like a many-to-many association.

To customize the link table, you can also use the @JoinTable annotation:

@OneToMany(
    cascade = CascadeType.ALL,
    orphanRemoval = true
)
@JoinTable(
    name = "post_comment_ref",
    joinColumns = @JoinColumn(name = "post_id"),
    inverseJoinColumns = @JoinColumn(name = "post_comment_id")
)
private List<PostComment> comments = new ArrayList<>();

And now, the link table is going to be called post_comment_ref and the Foreign Key columns will be post_id, for the post table, and post_comment_id, for the post_comment table.

Unidirectional @OneToMany associations are not efficient, so you are better off using bidirectional @OneToMany associations or just the @ManyToOne side.