问:
Difference between 2 ReactJS array state update methods
I have 2 apps running in parallel:

ReactJS front end app.

Socket.IO and Kafka Streams embedded Java server.

The Java server will stream the data from brokers and its Socket.IO component will broadcast data to its clients. Clients receive the incoming data by

```<code>socketInstance.on('sv_broadcast_data', (data) => {
   // State update method here
}
</code>```

Note: Front end app is running 'socket.io-client' v2.5.0.

At the 'State update method here' comment, initially I used setState([...currentState, newData]) but whenever the Java server broadcasted a new event message, it did not append itself to the state array. Rather, it changed the first state, so the first state was gone and became the second new state. At first, I thought it was just because of a typo. Therefore, I tested it with console.log(newData).

Surprisingly, the console still logged all of the incoming data. Just the array state update method did not append new data and only replaced the first state with new data. I even logged the length of the state array and tested with bunch of messages from the Java server. The result was just a consistent length = 1.

In the end, I tried an alternative state array update method

```<code>const updateState = (newData) => {
   setEventLog(prevData => prevData.concat(newData)
}
</code>```

And it worked! The new data got appended into the state array and the length is now > 1. I got so confused about this but I was happy that the solution worked. So, my question is what are the differences between the 2 state array update methods?

The FAIL one:
setState([...currentState, newData])

The SUCCESS one:

```<code>const updateState = (newData) => {
   setEventLog(prevData => prevData.concat(newData)
}
</code>```

Body:
I have 2 apps running in parallel:

ReactJS front end app.

Socket.IO and Kafka Streams embedded Java server.

The Java server will stream the data from brokers and its Socket.IO component will broadcast data to its clients. Clients receive the incoming data by

socketInstance.on('sv_broadcast_data', (data) => {
   // State update method here
}

Note: Front end app is running 'socket.io-client' v2.5.0.

At the 'State update method here' comment, initially I used setState([...currentState, newData]) but whenever the Java server broadcasted a new event message, it did not append itself to the state array. Rather, it changed the first state, so the first state was gone and became the second new state. At first, I thought it was just because of a typo. Therefore, I tested it with console.log(newData).

Surprisingly, the console still logged all of the incoming data. Just the array state update method did not append new data and only replaced the first state with new data. I even logged the length of the state array and tested with bunch of messages from the Java server. The result was just a consistent length = 1.

In the end, I tried an alternative state array update method

const updateState = (newData) => {
   setEventLog(prevData => prevData.concat(newData)
}

And it worked! The new data got appended into the state array and the length is now > 1. I got so confused about this but I was happy that the solution worked. So, my question is what are the differences between the 2 state array update methods?

The FAIL one:
setState([...currentState, newData])

The SUCCESS one:

const updateState = (newData) => {
   setEventLog(prevData => prevData.concat(newData)
}


来源: stackexchange

问:
Intellij error 'object update_eori is not a member of package views.html'
I am getting the below error while compiling my scala project-

```<code>object update_eori is not a member of package views.html
import views.html.update_eori
</code>```

This is the package that I am using -

```<code>import views.html.update_eori
</code>```

What could be possibly going wrong here?

P.S. I am completely new to coding

I tried to run the command sbt clean and then tried to compile again but same error persists.

ContentLicense: CC BY-SA 4.0

Body:
I am getting the below error while compiling my scala project-

object update_eori is not a member of package views.html
import views.html.update_eori

This is the package that I am using -

import views.html.update_eori

What could be possibly going wrong here?

P.S. I am completely new to coding

I tried to run the command sbt clean and then tried to compile again but same error persists.


问:
Reading console.log of a page using chrome extension
I m not getting any idea in which direction I should search/investigate. I need to create a chrome extension which has a button. Clicking the button will show the console output of the devinspector window without opening the inspector.

I have seen some extension, which takes the screenshot and also log the console messages.

Which chrome API can provide this info?


问:
Error: The tuning parameter grid should have columns
For the training of the GBM model I use the defined grid with the parameters. However r constantly tells me that the parameters are not defined, even though I did it.

enter image description here

Does anyone know how to fix this, help is much appreciated!


问:
Getting "Internal Server Error" when using api deployed on vercel
I have deployed the express app on vercel, other api are working fine but uploading image one is giving the error "Internal Server Error"

upload api in index.js

```<code>app.post("/api/upload", upload.single("file"), async (req, res) => {
  res.status(200).json("File has been uploaded");
});
</code>```

multer configuration

```<code>const multerStorage = multer.diskStorage({
    destination: (req, file, cb) => {
        cb(null, "./images");
    },
    filename: (req, file, cb) => {
        cb(null, req.body.name);
    },
});

const upload = multer({ storage: multerStorage });
</code>```

I am trying in postman by entering the form data which includes name and file but if I try with only uploading file in binary, it is getting successful.

Path is fine, api is working smoothly in local but dont know why it is not working after deploying.

Github repo - https://github.com/JavaKaran/techducant-backend

Edit - 1

Error (getting in postman)

```<code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
```Internal Server Error```
</body>
</html>
</code>```

Edit - 2

vercel error for upload api

[POST] /api/upload
2022-12-14T15:52:55.912Z    0988f1fa-ba5c-49b8-ae08-889cc67e7889    ERROR   Error: EROFS: read-only file system, open 'images/virtual.jpg'

Body:
I have deployed the express app on vercel, other api are working fine but uploading image one is giving the error "Internal Server Error"

upload api in index.js

app.post("/api/upload", upload.single("file"), async (req, res) => {
  res.status(200).json("File has been uploaded");
});

multer configuration

const multerStorage = multer.diskStorage({
    destination: (req, file, cb) => {
        cb(null, "./images");
    },
    filename: (req, file, cb) => {
        cb(null, req.body.name);
    },
});

const upload = multer({ storage: multerStorage });

I am trying in postman by entering the form data which includes name and file but if I try with only uploading file in binary, it is getting successful.

Path is fine, api is working smoothly in local but dont know why it is not working after deploying.

Github repo - https://github.com/JavaKaran/techducant-backend

Edit - 1

Error (getting in postman)

<!DOCTYPE html>

<meta charset="utf-8">
<title>Error</title>

Internal Server Error

Edit - 2

vercel error for upload api

[POST] /api/upload
2022-12-14T15:52:55.912Z    0988f1fa-ba5c-49b8-ae08-889cc67e7889    ERROR   Error: EROFS: read-only file system, open 'images/virtual.jpg'


问:
EF Linq query to check elements from list inside list with multiple properties
I'm trying to write a Linq query that will translate to SQL to get existing record based on provided lists.

searchRequest is a list of:

```<code>class SearchRequestDTO
    {
        public string Book { get; set; }
        public string Page { get; set; }
        public string DocumentNumber { get; set; }
    }
</code>```

This is my initial idea:

var documentNumbersFlat = new HashSet<string>(searchRequest.Select(d => d.DocumentNumber));
var books = new HashSet<string>(searchRequest.Select(d => d.Book));
var pages = new HashSet<string>(searchRequest.Select(d => d.Page));

var queryable = _dbSet.Include(i => i.Searches).Where(a =>
    a.Searches.Count == searchRequest.Count &&
    a.Searches.All(i => documentNumbersFlat.Contains(i.DocumentNumber) || (books.Contains(i.Book) && pages.Contains(i.Page))));
```
<p>But I dont think it is correct because I want exact Book and Page and in this case Im checking two separate list, so ideally I wanted to have something like that:</p>
<pre class="lang-cs prettyprint-override"><code>a.Searches.All(i => searchRequest.Contains(new {i.DocumentNumber, i.Book, i.Page)));
</code>```

Alternative (like a last resort):

var documentNumbersFlat = new HashSet<string>(searchRequest.Select(d => d.DocumentNumber));
var books = new HashSet<string>(searchRequest.Select(d => $"{d.Book}_{d.Page}"));

var queryable = _dbSet.Where(a =>
    a.Searches.Count == searchRequest.Count &&
    a.Searches.All(i => documentNumbersFlat.Contains(i.DocumentNumber) || books.Contains($"{i.Book}_{i.Page}")));
```

Additionally I want to point out I`m looking for best way of handling it in terms of performance.

All suggestions appreciated:)

Body:
I'm trying to write a Linq query that will translate to SQL to get existing record based on provided lists.

searchRequest is a list of:

class SearchRequestDTO
    {
        public string Book { get; set; }
        public string Page { get; set; }
        public string DocumentNumber { get; set; }
    }

This is my initial idea:

var documentNumbersFlat = new HashSet<string>(searchRequest.Select(d => d.DocumentNumber));
var books = new HashSet<string>(searchRequest.Select(d => d.Book));
var pages = new HashSet<string>(searchRequest.Select(d => d.Page));

var queryable = _dbSet.Include(i => i.Searches).Where(a =>
    a.Searches.Count == searchRequest.Count &&
    a.Searches.All(i => documentNumbersFlat.Contains(i.DocumentNumber) || (books.Contains(i.Book) && pages.Contains(i.Page))));

But I dont think it is correct because I want exact Book and Page and in this case Im checking two separate list, so ideally I wanted to have something like that:

a.Searches.All(i => searchRequest.Contains(new {i.DocumentNumber, i.Book, i.Page)));

Alternative (like a last resort):

var documentNumbersFlat = new HashSet<string>(searchRequest.Select(d => d.DocumentNumber));
var books = new HashSet<string>(searchRequest.Select(d => $"{d.Book}_{d.Page}"));

var queryable = _dbSet.Where(a =>
    a.Searches.Count == searchRequest.Count &&
    a.Searches.All(i => documentNumbersFlat.Contains(i.DocumentNumber) || books.Contains($"{i.Book}_{i.Page}")));

Additionally I want to point out I`m looking for best way of handling it in terms of performance.

All suggestions appreciated:)


问:
Weighting input parameters in XGBoost regression
I am trying to use XGBoost (in Python) to predict advertising campaign revenue based on several features, including the day the campaign is active, number of installs, and the spend. What I would like to do is to configure XGBoost in such a way that e.g. 3 most recent days (for the campaigns that have been active for longer than 3 days) are weighted more in the prediction of the revenue. I would think that somehow DMatrix has to be involved, yet maybe also the dataframe I am working with might also have to be transformed. Currently, the data I use has the following format (and a random example):

campaign
day of activity
installs
spend
revenue

A
1
24
230
50

A
2
36
230
62

A
3
48
235
77

A
4
49
235
79

C
1
2
100
13

C
2
6
100
14

C
3
7
105
16

so I am assigning the revenue to y, the rest to X, setting the train/test and then configuring the XGBRegressor parameters.

That said, I would appreciate the help on

determing what approach to use to have the weighting as described below

at what point to the weighting has to be introduces (in relation to assigning variables, train/test split, setting XGB params)


问:
How do I add a "disabled" property to specific rows in React TanStack Table?

The desired output is what you see above.

I got to that state by adding a disabled prop to my data:

{
  firstName: 'loss',
  lastName: 'psychology',
  age: 6,
  visits: 97,
  progress: 11,
  status: 'complicated',
  disabled: true,
},
```
<p>then accessing that prop with <code>row.original.disabled</code> (shown below)</p>
<pre class="lang-js prettyprint-override"><code><tbody>
  {table.getRowModel().rows.map((row, index) => {
    return (
      <tr
        key={`${row.id}-${index}`}
        className={`bg-white group ${
          row.getIsSelected()
            ? 'bg-primary-50'
            : 'bg-white hover:bg-neutral-50'
        }  w-full`}
      >
        {isSelectable && (
          <td
            className={`px-4 border-neutral-300 border-b-1
            first:border-l-1 last:border-r-1
            ${
              hasPagination
                ? ''
                : 'group-last:first:rounded-bl-lg group-last:last:rounded-br-lg'
            } ${
              row.original.disabled
                ? 'bg-neutral-100 text-text-disabled'
                : ''
            }`}
          >
            <Checkbox
              hideLabel
              checked={row.getIsSelected()}
              label={`${row.id}-test`}
              onChange={row.getToggleSelectedHandler()}
              disabled={row.original.disabled}
            />
          </td>
        )}
        {row.getVisibleCells().map((cell, index) => (
          <td
            style={{ width: cell.column.getSize() }}
            key={`cell.id-${index}`}
            className={`text-left px-6 py-2 h-[60px]
              border-neutral-300 border-b-1
              first:border-l-1 last:border-r-1
              ${
                hasPagination
                  ? ''
                  : 'group-last:first:rounded-bl-lg group-last:last:rounded-br-lg'
              } ${
              index === 0
                ? 'text-text-primary font-medium'
                : 'font-normal text-text-secondary'
              } ${
              row.original.disabled
                ? 'bg-neutral-100 text-text-disabled'
                : ''
            }
            `}
          >
            {flexRender(cell.column.columnDef.cell, cell.getContext())}
          </td>
        ))}
      </tr>
    );
  })}
</tbody>
</code>```

While the output appears to work, I am getting an error for that row.original.disabled that states TS2339: Property 'disabled' does not exist on type 'T'.

I'm still a noob with TanStack Table and Typescript. If you have any advice, I would greatly appreciate it.

Body:
The desired output is what you see above.

I got to that state by adding a disabled prop to my data:

{
  firstName: 'loss',
  lastName: 'psychology',
  age: 6,
  visits: 97,
  progress: 11,
  status: 'complicated',
  disabled: true,
},

then accessing that prop with row.original.disabled (shown below)

  {table.getRowModel().rows.map((row, index) => {
    return (
      <tr
        key={`${row.id}-${index}`}
        className={`bg-white group ${
          row.getIsSelected()
            ? 'bg-primary-50'
            : 'bg-white hover:bg-neutral-50'
        }  w-full`}
      >
        {isSelectable && (

            <Checkbox
              hideLabel
              checked={row.getIsSelected()}
              label={`${row.id}-test`}
              onChange={row.getToggleSelectedHandler()}
              disabled={row.original.disabled}
            />

        )}
        {row.getVisibleCells().map((cell, index) => (
          <td
            style={{ width: cell.column.getSize() }}
            key={`cell.id-${index}`}
            className={`text-left px-6 py-2 h-[60px]
              border-neutral-300 border-b-1
              first:border-l-1 last:border-r-1
              ${
                hasPagination
                  ? ''
                  : 'group-last:first:rounded-bl-lg group-last:last:rounded-br-lg'
              } ${
              index === 0
                ? 'text-text-primary font-medium'
                : 'font-normal text-text-secondary'
              } ${
              row.original.disabled
                ? 'bg-neutral-100 text-text-disabled'
                : ''
            }
            `}
          >
            {flexRender(cell.column.columnDef.cell, cell.getContext())}

        ))}

    );
  })}

While the output appears to work, I am getting an error for that row.original.disabled that states TS2339: Property 'disabled' does not exist on type 'T'.

I'm still a noob with TanStack Table and Typescript. If you have any advice, I would greatly appreciate it.


问:
Sorting dictionary by key value using standard approach not working
The line where I am creating the "sorted" dictionary it is giving me as error:

TypeError: 'dict' object is not callable

However, this method of sorting a dictionary seems to be a pretty standard way of doing it and cannot see why this would not work?

```<code>word_counts = {'positive': {},
                'neutral': {},
                'negative': {}}

for idx, sentence in enumerate(df_norm['Full Text']):
    for word in sentence:
        if word in word_counts[df_norm['Sentiment'][idx]].keys():
            word_counts[df_norm['Sentiment'][idx]][word] += 1
        else:
            word_counts[df_norm['Sentiment'][idx]][word] = 1

sorted = dict(sorted(word_counts['positive'].items(), key=lambda x: x[1]))
print(sorted)
</code>```

Body:
The line where I am creating the "sorted" dictionary it is giving me as error:

TypeError: 'dict' object is not callable

However, this method of sorting a dictionary seems to be a pretty standard way of doing it and cannot see why this would not work?

word_counts = {'positive': {},
                'neutral': {},
                'negative': {}}

for idx, sentence in enumerate(df_norm['Full Text']):
    for word in sentence:
        if word in word_counts[df_norm['Sentiment'][idx]].keys():
            word_counts[df_norm['Sentiment'][idx]][word] += 1
        else:
            word_counts[df_norm['Sentiment'][idx]][word] = 1

sorted = dict(sorted(word_counts['positive'].items(), key=lambda x: x[1]))
print(sorted)


问:
The incompatible between windows builder versions and java versions and eclipse version
I encounter this problem as below:
"Eclipse is running under 0, butthis Java project has a 1.8 Java compliance level, so WindowBuilder will not be able to load classesfrom this project. Use a lower level of Java for the project, or run Eclipse using a newer Javaversion. "

I tried several ways but it did not work. I installed both java 17 and java 1.8 and changed the jre to 1.8 & the complier to 1.8. In the end, it still did not work.
The eclipse version I am using is 2018. I need it to start the SWING application and now I am into troubles.
Can you give me some suggestions? Thanks in advance!


问:
How to ignore the exception in flutter integration test & continue the test execution
I'm getting FirebaseException is CAUGHT BY FLUTTER TEST FRAMEWORK, while flutter integration test is being run.!

Can anybody help in understading how to ignore the FirebaseException in integration test and continue the rest of execution?

I tried below walkaround,

Future<void> restoreFlutterError(Future<void> Function() call) async {
  FlutterError.onError = (FlutterErrorDetails data) {
    if (data.exception is FirebaseException) {
      return;
    }
    FlutterError.presentError(data);
  };
}```
</div>
</div>
</p>
<p>And called above method in <code>testWidgets</code> by</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>testWidgets('test execution', (tester) async {
    await restoreFlutterError(() async {
      app.main();
      await tester.pumpAndSettle(const Duration(seconds: 10));
    });
    ...
    ...
});</code>```

But getting below error.!

```<code> A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.
</code>```

Any helps appreciated.!

Body:
I'm getting FirebaseException is CAUGHT BY FLUTTER TEST FRAMEWORK, while flutter integration test is being run.!

Can anybody help in understading how to ignore the FirebaseException in integration test and continue the rest of execution?

I tried below walkaround,

Future<void> restoreFlutterError(Future<void> Function() call) async {
  FlutterError.onError = (FlutterErrorDetails data) {
    if (data.exception is FirebaseException) {
      return;
    }
    FlutterError.presentError(data);
  };
}

And called above method in testWidgets by

testWidgets('test execution', (tester) async {
    await restoreFlutterError(() async {
      app.main();
      await tester.pumpAndSettle(const Duration(seconds: 10));
    });
    ...
    ...
});

But getting below error.!

 A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.

Any helps appreciated.!


问:
my plot picture have two xticks and two yticks by using matplotlib
the code is so simple, but there are two xticks and two yticks. it's so strange!

```<code>fig = plt.figure(figsize=(16,12))
ax1 = fig.add_subplot(1, 1, 1)
ax1.plot(data['timestamp'], data['value'], 'r', label='value')
ax1.set_xlabel('date', fontsize=16)
ax1.set_ylabel('profit', fontsize=16)
ax1.legend(loc='upper left')
ax1.grid(True)
</code>```

the data value is below:

```<code>    0   2010-01-04
    1   2010-01-04
    2   2010-03-08
    3   2010-07-05
    4   2010-11-04
Name: timestamp, dtype: datetime64[ns]

    0    1.037868
    1    1.085912
    2    1.092537
    3    1.077828
    4    1.160641
</code>```

plot:

I just want the data['timestamp'] and data['value'] show on the picture.

I have tried to add the code below, but the result is the same.

```<code>ax1.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m"))
ax1.xaxis.set_major_locator(mdates.YearLocator())
ax1.xaxis.set_minor_locator(mdates.MonthLocator())
</code>```

I have get the x-tick and y-ticks, the result as below, there are not any value like 0, 0.2, 0.4, 0.6, 0.8, 1.0 in the result.
[14610. 14641. 14669. 14700. 14730. 14761. 14791. 14822. 14853. 14883. 14914.]
[1.02 1.04 1.06 1.08 1.1  1.12 1.14 1.16 1.18]

Body:
the code is so simple, but there are two xticks and two yticks. it's so strange!

fig = plt.figure(figsize=(16,12))
ax1 = fig.add_subplot(1, 1, 1)
ax1.plot(data['timestamp'], data['value'], 'r', label='value')
ax1.set_xlabel('date', fontsize=16)
ax1.set_ylabel('profit', fontsize=16)
ax1.legend(loc='upper left')
ax1.grid(True)

the data value is below:

    0   2010-01-04
    1   2010-01-04
    2   2010-03-08
    3   2010-07-05
    4   2010-11-04
Name: timestamp, dtype: datetime64[ns]

    0    1.037868
    1    1.085912
    2    1.092537
    3    1.077828
    4    1.160641

plot:

I just want the data['timestamp'] and data['value'] show on the picture.

I have tried to add the code below, but the result is the same.

ax1.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m"))
ax1.xaxis.set_major_locator(mdates.YearLocator())
ax1.xaxis.set_minor_locator(mdates.MonthLocator())

I have get the x-tick and y-ticks, the result as below, there are not any value like 0, 0.2, 0.4, 0.6, 0.8, 1.0 in the result.
[14610. 14641. 14669. 14700. 14730. 14761. 14791. 14822. 14853. 14883. 14914.]
[1.02 1.04 1.06 1.08 1.1  1.12 1.14 1.16 1.18]


问:
Docker private container registry on DigitalOcean kubernetes
I am trying to create a Private Container Registry on DigitalOcean Kubernetes. And I want all data to be saved in the DigitalOcean Spaces. I am using this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-docker-registry-on-top-of-digitalocean-spaces-and-use-it-with-digitalocean-kubernetes

Things and pod are running well, I am able to push or pull images and I would like to configure basic auth (htpasswd) on top on it, but when I add htpasswd attribute to my chart values file, I am getting error:

{"level":"fatal","msg":"configuring application: unable to configure authorization (htpasswd): no access controller registered with name: htpasswd","time":"2022-12-14T13:02:23.608Z"}

My chart_values.yaml file:

```<code>ingress:
  enabled: true
  hosts:
    - cr.somedomain.com
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/proxy-body-size: "30720m"
  args:
    - --set controller.extraArgs.ingress-class=nginx
  tls:
    - secretName: somedomain-cr-prod
      hosts:
        - cr.somedomain.com

storage: s3

secrets:
  htpasswd: |-
    username:someBcryptPassword
  s3:
    accessKey: "someaccesskey"
    secretKey: "someaccesssecret"

s3:
  region: region
  regionEndpoint: region.digitaloceanspaces.com
  secure: true
  bucket: somebucketname

image:
  repository: somerepo
  tag: latest

</code>```

Maybe someone can answer where did I go wrong?

I have tried different formats to enter htpasswd, but it did produce the same error.

Body:
I am trying to create a Private Container Registry on DigitalOcean Kubernetes. And I want all data to be saved in the DigitalOcean Spaces. I am using this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-docker-registry-on-top-of-digitalocean-spaces-and-use-it-with-digitalocean-kubernetes

Things and pod are running well, I am able to push or pull images and I would like to configure basic auth (htpasswd) on top on it, but when I add htpasswd attribute to my chart values file, I am getting error:

{"level":"fatal","msg":"configuring application: unable to configure authorization (htpasswd): no access controller registered with name: htpasswd","time":"2022-12-14T13:02:23.608Z"}

My chart_values.yaml file:

ingress:
  enabled: true
  hosts:
    - cr.somedomain.com
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/proxy-body-size: "30720m"
  args:
    - --set controller.extraArgs.ingress-class=nginx
  tls:
    - secretName: somedomain-cr-prod
      hosts:
        - cr.somedomain.com

storage: s3

secrets:
  htpasswd: |-
    username:someBcryptPassword
  s3:
    accessKey: "someaccesskey"
    secretKey: "someaccesssecret"

s3:
  region: region
  regionEndpoint: region.digitaloceanspaces.com
  secure: true
  bucket: somebucketname

image:
  repository: somerepo
  tag: latest

Maybe someone can answer where did I go wrong?

I have tried different formats to enter htpasswd, but it did produce the same error.


问:
Is there an element or not?
```<code>const arrow = document.querySelector("#arrow");
const callAllPie = document.querySelector(".allPie");

eventList();
function eventList(e) {
  arrow.addEventListener("click", showSkills);
}

// function showSkills() {
//   const pie = document.createElement("div");
//   pie.classList.add("pie1");

//   callAllPie.appendChild(pie);

//   const rightDiv = document.createElement("div");
//   rightDiv.classList.add("slice-right1");

//   const leftDiv = document.createElement("div");
//   leftDiv.classList.add("slice-left1");

//   const percentDiv = document.createElement("div");
//   percentDiv.classList.add("percent1");

//   const numberDiv = document.createElement("div");
//   numberDiv.classList.add("number1");
//   numberDiv.innerHTML = "%99";

//   const nameDiv = document.createElement("div");
//   nameDiv.classList.add("name1");
//   nameDiv.innerHTML = "HTML";

//   pie.appendChild(rightDiv);
//   pie.appendChild(leftDiv);
//   pie.appendChild(percentDiv);
//   percentDiv.appendChild(numberDiv);
//   percentDiv.appendChild(nameDiv);
//   callAllPie.appendChild(pie);
// }
function showSkills() {
  for (let element = callAllPie; element < 5; element++) {
    console.log(element);
  }
}

</code>```

I'm trying to create a loop. If there is no element in the allPie div, I want to add the pie div I created and I want to end it when it reaches 4, how do I do it? I'm a beginner in javascript so if you can help I'd appreciate it

Title: Is there an element or not?

Body:
const arrow = document.querySelector("#arrow");
const callAllPie = document.querySelector(".allPie");

eventList();
function eventList(e) {
  arrow.addEventListener("click", showSkills);
}

// function showSkills() {
//   const pie = document.createElement("div");
//   pie.classList.add("pie1");

//   callAllPie.appendChild(pie);

//   const rightDiv = document.createElement("div");
//   rightDiv.classList.add("slice-right1");

//   const leftDiv = document.createElement("div");
//   leftDiv.classList.add("slice-left1");

//   const percentDiv = document.createElement("div");
//   percentDiv.classList.add("percent1");

//   const numberDiv = document.createElement("div");
//   numberDiv.classList.add("number1");
//   numberDiv.innerHTML = "%99";

//   const nameDiv = document.createElement("div");
//   nameDiv.classList.add("name1");
//   nameDiv.innerHTML = "HTML";

//   pie.appendChild(rightDiv);
//   pie.appendChild(leftDiv);
//   pie.appendChild(percentDiv);
//   percentDiv.appendChild(numberDiv);
//   percentDiv.appendChild(nameDiv);
//   callAllPie.appendChild(pie);
// }
function showSkills() {
  for (let element = callAllPie; element < 5; element++) {
    console.log(element);
  }
}

I'm trying to create a loop. If there is no element in the allPie div, I want to add the pie div I created and I want to end it when it reaches 4, how do I do it? I'm a beginner in javascript so if you can help I'd appreciate it


问:
Why my jetstream application in Laravel not showing proper CSS and JS path when uploading in Cpanel?
I have built a project in laravel using jetstream. The project is running smoothly in my local machine (localhost) but the CSS and JS path is not working when I am uploading in server. Can anyone help?

My cpanel directory is

```<code>public_html/pro1/admin/
</code>```

Error

```<code>Falied to load resource : app.js
Falied to load resource : app.css
Falied to load resource : app.css
</code>```

Body:
I have built a project in laravel using jetstream. The project is running smoothly in my local machine (localhost) but the CSS and JS path is not working when I am uploading in server. Can anyone help?

My cpanel directory is

public_html/pro1/admin/

Error

Falied to load resource : app.js
Falied to load resource : app.css
Falied to load resource : app.css


问:
Does order of Select statements matter when you have a stored procedure with multiple select statements being read by Dapper?
I have a stored procedure that loads the schedule data for departments in my business. I have multiple select statements that are read using dapper to load them into a c# method.  I managed to optimise the procedure to get down to loading in about 6 seconds each time from well over a minute. However, recently it has started to slow down, and one of the departments called me this morning to say that it was timing out.

I load the procedure into SSMS and run it from there, and it loads in 6 seconds. They then load the C# method into visual studio and its taking over a minute to load. So I step through each of the dapper reading statements, and it gets stuck on one statement, for over a minute. Then after that everything takes less than a second to load.

Then I moved the statement that was slowing things down up towards the top of the list, and it loads the whole thing in 3 seconds now. Why would the order of the select statement affect the speed with which Dapper is able to load the procedure?

I have put a couple of comments in so you can see what was moved:
//slow statement moved to here   -- this is the place earlier in the chain where the slow statement (orderDesignProcessSteps) was moved)
//here is where slow statement used to be -- this is the placed further down the chain where that statement used to load

C# code:

```<code>public static List<Job> GetOverviewJobsV2(List<int> JobTypes, int SupplierId, bool FindDesignStock)
{
        using (SqlConnection conn = new SqlConnection(Settings.ConnectionString))
        {
            DataTable dt = Common.DataTableHelpers.CreateIntDataTable(JobTypes);

            using (var multi = conn.QueryMultiple("PR_GetOverviewJobs_V5", new { JobTypes = dt.AsTableValuedParameter("dbo.IntTable"), SupplierId }, commandType: System.Data.CommandType.StoredProcedure))
            {
                var jobs = multi.Read<Job>().ToList();

                bool orderVersion0required = jobs.Exists(x => x.OrderVersion == 0);

                try
                {
                    //orderversion 0
                    var designData = new List<DesignProcessData>();
                    var children = new List<DesignProcessData>();
                    var designStatuses = new List<DesignProcessStep>();

                    var orderItemsV1 = new List<OrderItem>();
                    var jobItemsV1 = new List<JobItem>();
                    var despatchItems = new List<DespatchItem>();

                    if (orderVersion0required)
                    {
                        designData = multi.Read<DesignProcessData>().OrderBy(x => x.ApplicationDate).ToList();
                        children = multi.Read<DesignProcessData>().ToList();
                        designStatuses = multi.Read<DesignProcessStep>().ToList();

                        orderItemsV1 = multi.Read<OrderItem>().ToList();
                        jobItemsV1 = multi.Read<JobItem>().ToList();
                        despatchItems = multi.Read<DespatchItem>().ToList();
                    }

                    //orderversion 1
                    var masterDesigns = multi.Read<DesignProcessData>().ToList();
                    var orderDesigns = multi.Read<OrderDesign>().ToList();

                    //slow statement moved to here
                    var orderDesignProcessSteps = multi.Read<DesignProcessStep>().ToList();
                    var masterDesignProcessSteps = multi.Read<DesignProcessStep>().ToList();

                    //orderversion 1
                    var orderItemsV2 = multi.Read<OrderItem>().ToList();
                    var jobItemsV2 = multi.Read<OrderItem>().ToList();
                    var jobItemIdsLinkedToOrderItemIds = multi.Read<JobItem>().ToList();
                    var despatchItemsV2 = multi.Read<DespatchItem>().ToList();

                    var finishing = multi.Read<FinishingProcessData>().ToList();

                    var filestoreFiles = multi.Read<FileStoreFile>().ToList();
                    var masterDesignFileStore = multi.Read<FileStoreFile>().ToList();

                    var staffMembers = multi.Read<StaffMember>().ToList();
                    var logs = multi.Read<LogEntry>().ToList();

                    var potentialJobs = multi.Read<Job>().ToList();

                    //orderversion0
                    var designColours = new List<PrintColour>();
                    var stencils = new List<Stencil>();
                    stencils = null;

                    var screens = new List<Screen>();
                    screens = null;

                    if (orderVersion0required)
                    {
                        designColours = multi.Read<PrintColour>().ToList();

                        if (JobTypes.Exists(jt => jt == 1 || jt == 6))
                        {
                            stencils = multi.Read<Stencil>().ToList();
                            screens = multi.Read<Screen>().ToList();
                        }
                    }

                    //orderversion 1
                    var designColoursv2 = multi.Read<PrintColour>().ToList();
                    var colourways = multi.Read<PrintColourway>().ToList();
                    var colourWayColours = multi.Read<MyStore.Design.PrintColour>().OrderBy(x => x.ColourNumber).ToList();
                    var designStock = multi.Read<DesignStock>().ToList();

                    var stencilsv2 = new List<Stencil>();
                    stencilsv2 = null;

                    var screensv2 = new List<Screen>();
                    screensv2 = null;

                    if (JobTypes.Exists(jt => jt == 1 || jt == 6))
                    {
                        stencilsv2 = multi.Read<Stencil>().ToList();
                        screensv2 = multi.Read<Screen>().ToList();
                    }

                    //here is where slow statement used to be

                    var itemPurchaseOrders = multi.Read<ItemPurchaseOrder>().ToList();
                    var purchaseOrderItems = multi.Read<PurchasingItem>().ToList();
                    var purchaseOrderBookingDatas = multi.Read<BookingData>().ToList();
                    var purchaseOrderBookingItems = multi.Read<BookingItem>().ToList();
                    var itemFaults = multi.Read<ItemFault>().ToList();
                    var orderItemIdsLinkedToPurchaseItems = multi.Read<PurchasingItem>().ToList();
                    var stockLocations = multi.Read<StockLocation>().ToList();

                    var highlightColours = multi.Read<Core.Site.HighlightColour>().ToList();
                    var serviceSuppliers = multi.Read<ServiceSupplier>().ToList();
</code>```

T-SQL Procedure:

If you want to see the bit that was slowing it down that was moved, it's got a comment directly above it called --design process stepsv2 orderDesignProcessSteps.  It ends with WHERE olddps.MasterDesignId = 0

```USE [LaunchPad3_Production]
GO
/****** Object:  StoredProcedure [dbo].[PR_GetOverviewJobs_V5]    Script Date: 14/12/2022 13:15:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

 ALTER PROCEDURE [dbo].[PR_GetOverviewJobs_V5]
    @JobTypes IntTable READONLY,
    @SupplierId INT = 1
AS
BEGIN
    SET NOCOUNT ON;
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
------------------------------------------------------------------------TEMP TABLES
    --temptable for jobs
    SELECT
        prj.Id AS JobId,
        ob.Id AS OrderId,
        prj.DesignId,
        ob.GlobalId,
        ob.OrderVersion
    INTO #Jobs
    FROM
        LaunchPad3_Production.dbo.PR_Job prj
            INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = prj.OrderId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Base opb ON opb.OrderId = prj.OrderId
            INNER JOIN @JobTypes jt ON jt.Int = prj.JobType
    WHERE
        prj.completed = 0
        AND ob.deleted = 0
        AND opb.IsProcessed = 1
        AND opb.Complete = 0
        AND opb.HoldInStoke = 0
        AND prj.SupplierId = @SupplierId

        --AND prj.Id = 46167

    DECLARE @NumberOf0VersionOrders int = (SELECT COUNT(OrderVersion) FROM #Jobs WHERE OrderVersion = 0)

------------------------------------------------------------------------SELECT QUERIES

    -- Get all jobs
    SELECT DISTINCT
        opb.*,
        prj.*,
        CONVERT(DATE,opb.DespatchDate) AS DespatchDate,
        CONVERT(DATE,prj.ProductionDate) AS ApplicationDate,
        prj.Id as JobId,
        ISNULL(prj.Notes, '') AS JobNotes,
        ub.CompanyName,
        ub.FirstName,
        ub.LastName,
        ob.OrderVersion,
        opb.DespatchDateType AS DespatchType
    FROM LaunchPad3_Production.dbo.PR_Job prj
        INNER JOIN #Jobs ej ON ej.jobid = prj.id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = prj.OrderId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Base opb ON opb.OrderId = prj.OrderId
        INNER JOIN LaunchPad3_Core.dbo.USER_Base ub ON ob.UserId = ub.Id

IF (@NumberOf0VersionOrders != 0)
    BEGIN
        -- order version 0 parent designs
        SELECT distinct opd.*, od.*, db.*,
            dpm.ViewPoint as TemplateViewPoint,
            dp.Type as DesignPosition,
            db.ApplicationTypeId,
            opd.ProcessTypeId as ProcessId,
            od.CategoryId,
            od.DesignId,
            dp.Type AS DesignPosition,
            od.Id,
            db.Name,
            od.OrderId,
            DesignPositionId AS PositionId,
            opd.OrderDesignId,
            opd.OrderDesignId as DesignId,
            opd.ApplicationDate,
            od.OrderId,
            dpr.Department,
            dlpc.ParentId, dlpc.ChildId,
            dpr.WeedingRequired,
            dpr.Name AS ProcessType
        FROM #Jobs pj
            INNER JOIN LaunchPad3_MyStore_2015.dbo.ORDER_Design od ON od.orderid = pj.orderid
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Base db ON od.DesignId = db.Id
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Position dp ON dp.Id = od.DesignPositionId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Design opd ON opd.OrderDesignId = od.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Process dpr ON dpr.id = opd.ProcessTypeId
            left JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PositionMap dpm ON dpm.TemplateId = od.CategoryId and dpm.PositionId = od.DesignPositionId AND dpm.GlobalId = pj.GlobalId
            LEFT JOIN LaunchPad3_OrderProcess.dbo.DESIGN_LINK_Parent_Child dlpc ON dlpc.childid = od.DesignId
        WHERE dlpc.ParentId IS NULL OR dlpc.parentid = od.designid

        -- order version 1 child designs
        SELECT distinct opd.*, od.*, db.*,
            dpm.ViewPoint as TemplateViewPoint,
            dp.Type as DesignPosition,
            db.ApplicationTypeId,
            opd.ProcessTypeId as ProcessId,
            od.CategoryId,
            od.DesignId,
            dp.Type AS DesignPosition,
            od.Id,
            db.Name,
            od.OrderId,
            DesignPositionId AS PositionId,
            opd.OrderDesignId,
            opd.OrderDesignId as DesignId,
            opd.ApplicationDate,
            od.OrderId,
            dpr.Department,
            dlpc.ParentId, dlpc.ChildId
            --, pj.designid, od.designid
        FROM #Jobs pj
            INNER JOIN LaunchPad3_MyStore_2015.dbo.ORDER_Design od ON od.orderid = pj.orderid
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_LINK_Parent_Child dlpc ON dlpc.childid = od.DesignId
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Base db ON od.DesignId = db.Id
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Position dp ON dp.Id = od.DesignPositionId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Design opd ON opd.OrderDesignId = od.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Process dpr ON dpr.id = opd.ProcessTypeId
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PositionMap dpm ON dpm.TemplateId = od.CategoryId and dpm.PositionId = od.DesignPositionId AND dpm.GlobalId = pj.GlobalId

        --design statuses v1
        SELECT DISTINCT
            olddps.*,
            dps.*,
            dpss.*,
            dpdps.*,
            olddps.DesignId,
            olddps.PathStepId as Id,
            dps.StatusText as DisplayText,
            dpss.StatusText AS StatusText,
            dpdps.StepOrder as PathOrder,
            dp.ApplicationTypeId AS ProcessTypeId
        FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_DesignPathStep olddps
            INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Design od1 ON od1.DesignId = olddps.DesignId
            INNER JOIN #Jobs j ON j.OrderId = od1.OrderId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStep dps ON olddps.PathStepId = dps.Id
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStepStatus dpss ON olddps.PathStepStatusId = dpss.Id
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Design od ON od.OrderDesignId = olddps.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPath dp ON dp.ApplicationTypeId = od.ProcessTypeId AND dp.GlobalId = j.GlobalId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_DesignPath_DesignPathStep dpdps ON dpdps.PathStepId = olddps.PathStepId AND dpdps.PathId = dp.Id

        --order items v1
        SELECT distinct oi.*, dt.Name AS TemplateName, Qty as ItemQty, ej.JobId
        FROM Launchpad3_MyStore_2015.dbo.ORDER_Item oi
            INNER JOIN Launchpad3_MyStore_2015.dbo.design_template dt on dt.Id = oi.TemplateId
            INNER JOIN #Jobs ej ON ej.OrderId = oi.OrderId

        --jobItems v1
        SELECT ji.*
        FROM LaunchPad3_Production.dbo.PR_JobItem ji
            INNER JOIN #Jobs ej ON ej.jobid = ji.jobid

        --despatch datav1
        SELECT DISTINCT  db.*,di.*
        FROM
            LaunchPad3_OrderProcess.dbo.despatch_item di
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESPATCH_Base db ON db.id = di.DespatchId
            inner JOIN Launchpad3_MyStore_2015.dbo.order_item oi ON oi.id = di.OrderItemId
            INNER JOIN #Jobs ej ON ej.orderid = oi.OrderId
        WHERE db.Deleted= 0
    END

    --master designs order version 2
    SELECT DISTINCT
        dm.*,
        0 AS DesignId,
        dtd.Type AS DesignType,
        dm.Id AS MasterDesignId,
        pc.HexCode as FontColourCode,
        pc.Name AS FontColourName,
        df.Name as FontName,
        dta.Type AS DesignApplicationType,
        dm.ProcessTypeId as ProcessId,
        dp.Name AS ProcessType,
        dp.Department,
        dp.WeedingRequired,
        pjlmd.JobId
    FROM Launchpad3_MyStore_2015.dbo.Order_Design_V2 od
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Master dm ON dm.Id = od.MasterDesignId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Application dta ON dta.Id = dm.ApplicationTypeId
        inner JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Design dtd ON dtd.Id = dm.DesignTypeId
        LEFT JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PrintColours pc ON Dm.FontColourId = pc.Id
        LEFT JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Font df ON df.Id = Dm.FontId
        LEFT JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Process dp ON dp.Id = dm.ProcessTypeId

    -- order designs order version 2
    SELECT DISTINCT
        od.*,
        od.Id AS OrderDesignId,
        od.DesignPositionId AS PositionId,
        dpm.ViewPoint as TemplateView,
        dpm.ViewPoint,
        dtp.Type AS DesignPosition,
        pjlmd.JobId
    FROM Launchpad3_MyStore_2015.dbo.Order_Design_V2 od
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId AND j.OrderId = od.OrderId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Position dtp ON dtp.Id = od.DesignPositionId
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oi ON oi.Id = od.OrderItemId
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = od.OrderId
        INNER JOIN Launchpad3_MyStore_2015.dbo.PRODUCT_Base pb ON pb.Id = oi.ProductId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PositionMap dpm on dpm.TemplateId = pb.TemplateId AND dpm.PositionId = od.DesignPositionId

    --design process stepsv2 orderDesignProcessSteps
    SELECT DISTINCT
        olddps.*,
        dps.*,
        dpss.*,
        dpdps.*,
        olddps.PathStepId as Id,
        dps.StatusText as DisplayText,
        dpss.StatusText AS StatusText,
        dpdps.StepOrder as PathOrder,
        dp.ApplicationTypeId AS ProcessId
    FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_DesignPathStepV2 olddps
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStep dps ON olddps.PathStepId = dps.Id
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStepStatus dpss ON olddps.PathStepStatusId = dpss.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.Order_Design_V2 od ON  od.Id = olddps.DesignId
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Master dm ON dm.Id = od.MasterDesignId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPath dp ON dp.ApplicationTypeId = dm.ProcessTypeId AND dp.GlobalId = j.GlobalId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_DesignPath_DesignPathStep dpdps ON dpdps.PathStepId = olddps.PathStepId AND dpdps.PathId = dp.Id
    WHERE olddps.MasterDesignId = 0

    --master design process stepsv2
    SELECT DISTINCT
        olddps.*,
        dps.*,
        dpss.*,
        dpdps.*,
        olddps.PathStepId as Id,
        dps.StatusText as DisplayText,
        dpss.StatusText AS StatusText,
        dpdps.StepOrder as PathOrder,
        dp.ApplicationTypeId AS ProcessId
    FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_DesignPathStepV2 olddps
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStep dps ON olddps.PathStepId = dps.Id
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStepStatus dpss ON olddps.PathStepStatusId = dpss.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.Order_Design_V2 od ON  od.MasterDesignId = olddps.MasterDesignId
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Master dm ON dm.Id = od.MasterDesignId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPath dp ON dp.ApplicationTypeId = dm.ProcessTypeId AND dp.GlobalId = j.GlobalId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_DesignPath_DesignPathStep dpdps ON dpdps.PathStepId = olddps.PathStepId AND dpdps.PathId = dp.Id
    WHERE olddps.MasterDesignId != 0

    --order itemsv2
    SELECT DISTINCT oi.*, S.Size AS SizeName, oi.Qty AS ItemQty
    FROM    Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oi
        INNER JOIN Launchpad3_MyStore_2015.dbo.PRODUCT_Size s ON oi.SizeId = s.Id
        INNER JOIN #Jobs j ON j.OrderId = oi.OrderId

    -- Job itemsv2
    SELECT DISTINCT
    oiv.OrderId
    ,oiv.ProductId
    ,oiv.ProductCode
    ,oiv.ProductName
    ,oiv.ColourId
    ,oiv.SizeId
    ,oiv.ColourName
    ,oiv.TemplateId
    ,S.Size AS SizeName
    ,pji.*
    ,dt.Name AS TemplateName
    FROM LaunchPad3_Production.dbo.PR_JobItem pji
        INNER JOIN LaunchPad3_Production.dbo.PR_JobItem_LINK_OrderItem pjiloi ON pjiloi.JobItemId = pji.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oiv ON oiv.Id = pjiloi.OrderItemId
        INNER JOIN Launchpad3_MyStore_2015.dbo.PRODUCT_Size s ON oiv.SizeId = s.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = oiv.OrderId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Template dt ON dt.Id = oiv.TemplateId
        INNER JOIN #Jobs j ON j.JobId = pji.JobId

    --job items linked to orderItemsv2
    SELECT DISTINCT pjiloi.*
    FROM LaunchPad3_Production.dbo.PR_JobItem pji
        INNER JOIN LaunchPad3_Production.dbo.PR_JobItem_LINK_OrderItem pjiloi ON pjiloi.JobItemId = pji.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oiv ON oiv.Id = pjiloi.OrderItemId
        INNER JOIN #Jobs j ON j.JobId = pji.JobId

    --despatch datav2
    SELECT DISTINCT di.*, db.* FROM
        LaunchPad3_OrderProcess.dbo.despatch_item di
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESPATCH_Base db ON db.id = di.DespatchId
        inner JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oiv ON oiv.id = di.OrderItemId
        INNER JOIN #Jobs ej ON ej.orderid = oiv.OrderId
    WHERE db.Deleted= 0

    -- get finishing
    SELECT DISTINCT
        f.Id,
        f.OrderId,
        f.Type,
        ISNULL(ft.Name, '') as TypeName,
        f.Method,
        ISNULL(fp.Name,'') AS MethodName,
        f.SupplierId,
        f.Notes,
        f.Date,
        ft.PackingDepartmentRequiredForFinishing,
        ISNULL(f.MediaLocation,'') AS MediaLocation,
        ISNULL(fp.PackingDepartmentRequiredForPacking,0) AS PackingDepartmentRequiredForPacking
    FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Finishing f
        Left JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_TYPE_Finishing ft ON ft.Id = f.Type
        Left JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_TYPE_Packing fp ON fp.Id = f.Method
        INNER JOIN #Jobs j ON j.OrderId = f.orderid

    -- order filestore
    SELECT DISTINCT ej.DesignId, ff.*, flfo.OrderId, flfo.FileTypeId as Type, flfo.DesignId AS OrderDesignId
    FROM LaunchPad3_OrderProcess.dbo.FILESTORE_File ff
        INNER JOIN LaunchPad3_OrderProcess.dbo.FILESTORE_LINK_File_Order flfo ON ff.Id = flfo.FileId
        INNER JOIN #Jobs ej ON ej.orderid = flfo.OrderId

    --filestore files for design
    SELECT DISTINCT
        ff.Id
       ,ff.Name
       ,ff.FilePath
       ,ff.Size
       ,ff.GlobalId
        ,flfo.FileId
       ,flfo.FileTypeId
       ,flfo.DesignId
       ,flfo.MasterDesignId
       ,flfo.ColourwayId
        ,flfo.FileTypeId as Type
        ,flfo.OrderId
    FROM LaunchPad3_OrderProcess.dbo.FILESTORE_File ff
        INNER JOIN  LaunchPad3_OrderProcess.dbo.FILESTORE_LINK_File_Order flfo ON ff.Id = flfo.FileId
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = flfo.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId

    --staff members
    SELECT * FROM LaunchPad3_Core.dbo.USER_Base ub
        INNER JOIN LaunchPad3_Production.dbo.PR_StaffMember sm ON sm.UserId = ub.Id AND sm.GlobalId = ub.GlobalId
    WHERE ub.GlobalId = 29

    --log entries
    SELECT DISTINCT
        pl.Id
       ,pl.JobId
       ,pl.OrderId
       ,pl.DesignId
       ,pl.UserId
       ,pl.StatusId AS Status
       ,pl.Notes
       ,pl.Date
    FROM LaunchPad3_Production.dbo.PR_Log pl
        INNER JOIN  #Jobs ej ON ej.JobId = pl.JobId

    -- list of all other jobs
    EXEC LaunchPad3_Production.dbo.[PR_GetAllJobsForLiveOrders]

IF (@NumberOf0VersionOrders != 0)
    BEGIN
    -- get design colourways and print colours
        SELECT pc.id, cb.DesignId, pc.name, cb.Id as ColourWayId, pc.HexCode, clbc.PantoneMixed
        FROM #Jobs sp
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_PrintColour oldpc ON oldpc.DesignId = sp.DesignId -- AND oldpc.PrintColourId = pc.Id
            INNER join LaunchPad3_MyStore_2015.dbo.DESIGN_PrintColours pc ON pc.Id = oldpc.PrintColourId -- clbc.ColourId
            INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_Base cb ON cb.DesignId = oldpc.DesignId -- sp.DesignId = cb.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_LINK_Base_Colour clbc ON cb.Id = clbc.ColourwayId
        --WHERE sp.OrderVersion = 0

        IF EXISTS (SELECT int FROM @JobTypes WHERE Int = 1 OR int = 6)
            BEGIN
                --get the stencils
                SELECT DISTINCT sps.*
                , slss.ScreenId
                FROM
                    #Jobs j
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON sps.OrderId = j.OrderId AND sps.DesignId = j.DesignId
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.StencilId = sps.Id

                --get the screens
                SELECT DISTINCT spsc.*
                FROM LaunchPad3_Production.dbo.PR_SP_Screen spsc
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.ScreenId = spsc.Id
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON sps.Id = slss.StencilId
                    INNER JOIN #Jobs j ON j.DesignId = sps.DesignId
            END
END

    --design coloursv2
    SELECT  distinct
        dpc.*
        ,dpc.HexCode as ColourCode
        ,opc.ColourOnAllGarments
        ,od.ColourWayId
        ,opc.ColourNumber
        ,od.MasterDesignId
        ,clbc.PantoneMixed
    FROM #Jobs j
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Design_V2 od ON od.MasterDesignId = pjlmd.MasterDesignId
        INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_LINK_Base_Colour clbc ON od.ColourWayId = clbc.ColourwayId -- AND clbc.ColourwayId = od.ColourWayId
        INNER join LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_PrintColour opc ON od.MasterDesignId = opc.MasterDesignId AND opc.PrintColourId = clbc.ColourId
        INNER join LaunchPad3_MyStore_2015.dbo.DESIGN_PrintColours dpc ON dpc.Id = opc.PrintColourId

    --master design colourwaysv2
    SELECT DISTINCT cb.*
    FROM
        #Jobs j
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_Base cb ON pjlmd.MasterDesignId = cb.MasterDesignId

    --print colours from master design colourwaysv2
        SELECT DISTINCT
        dpc.*
        ,cb.*
        ,cb.Id AS ColourWayId
        ,dpc.Id
        ,clbc.ColourNumber
        ,clbc.PantoneMixed
        FROM
            #Jobs j
            INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
            inner JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_Base cb ON cb.MasterDesignId = pjlmd.MasterDesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_LINK_Base_Colour clbc ON cb.Id = clbc.ColourwayId
            INNER join LaunchPad3_MyStore_2015.dbo.DESIGN_PrintColours dpc ON dpc.Id = clbc.ColourId

    --designstock
    SELECT *
    FROM LaunchPad3_OrderProcess.dbo.Design_Master_Stock_LINK_OrderId dmsloi
        INNER join #Jobs j ON j.OrderId = dmsloi.OrderId

IF EXISTS (SELECT int FROM @JobTypes WHERE Int = 1 OR int = 6)
    BEGIN
        --get the stencilsv2
        SELECT DISTINCT sps.*
        , slss.ScreenId
        FROM
            #Jobs j
            INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON pjlmd.MasterDesignId = sps.MasterDesignId
            LEFT JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.StencilId = sps.Id

        --get the screensv2
        SELECT DISTINCT spsc.* ,slss.StencilId
        FROM
            #Jobs j
            INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON sps.MasterDesignId = pjlmd.MasterDesignId
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.StencilId = sps.Id
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_Screen spsc  ON slss.ScreenId = spsc.Id
    END

    --item purchase orders
        SELECT DISTINCT ipo.* FROM LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo
            INNER JOIN #Jobs ej ON ej.OrderId = ipo.OrderId
        WHERE ipo.deleted = 0

    --purchase order items
    SELECT DISTINCT poi.*, ej.OrderId FROM LaunchPad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem poi
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = poi.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.OrderId = ipo.OrderId
    WHERE ipo.deleted = 0

    --booking records
    SELECT DISTINCT bb.*, ej.OrderId, bb.Location AS location FROM LaunchPad3_Purchasing.dbo.BOOKING_Base bb
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = bb.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.OrderId = ipo.OrderId
    WHERE ipo.deleted = 0

    --booking items
    SELECT DISTINCT bi.*, ej.OrderId FROM LaunchPad3_Purchasing.dbo.BOOKING_Item bi
        INNER JOIN LaunchPad3_Purchasing.dbo.BOOKING_Base bb ON bi.BookingDataId = bb.Id
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = bb.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.orderid = ipo.orderid
    WHERE ipo.deleted = 0

    -- items faults
    SELECT DISTINCT bif.* FROM LaunchPad3_Purchasing.dbo.BOOKING_ItemFault bif
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem poi ON poi.Id = bif.PurchaseItemId
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = poi.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.orderid = ipo.OrderId
    WHERE ipo.deleted = 0

    --orderItemIds linked to purchase order items
    SELECT DISTINCT ppoiloi.PurchaseItemId AS Id, ppoiloi.OrderItemId
    FROM Launchpad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem_LINK_OrderItem ppoiloi
        INNER JOIN Launchpad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem poi ON ppoiloi.PurchaseItemId = poi.Id
        INNER JOIN Launchpad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder pipo ON pipo.Id = poi.PurchaseOrderId
        INNER JOIN #Jobs j ON j.OrderId = pipo.OrderId
    WHERE pipo.Deleted = 0

    -- stock locations
    SELECT
    *
    , LocationType AS Type
    FROM LaunchPad3_Purchasing.dbo.STOCK_Location

    -- get the highlight colours
    EXEC LaunchPad3_Core.dbo.HIGHLIGHTCOLOUR_GetAll

    --service suppliers
    EXEC LaunchPad3_OrderProcess.dbo.SERVICESUPPLIER_GetAll 29

    DROP TABLE #jobs
END
```

Body:
I have a stored procedure that loads the schedule data for departments in my business. I have multiple select statements that are read using dapper to load them into a c# method.  I managed to optimise the procedure to get down to loading in about 6 seconds each time from well over a minute. However, recently it has started to slow down, and one of the departments called me this morning to say that it was timing out.

I load the procedure into SSMS and run it from there, and it loads in 6 seconds. They then load the C# method into visual studio and its taking over a minute to load. So I step through each of the dapper reading statements, and it gets stuck on one statement, for over a minute. Then after that everything takes less than a second to load.

Then I moved the statement that was slowing things down up towards the top of the list, and it loads the whole thing in 3 seconds now. Why would the order of the select statement affect the speed with which Dapper is able to load the procedure?

I have put a couple of comments in so you can see what was moved:
//slow statement moved to here   -- this is the place earlier in the chain where the slow statement (orderDesignProcessSteps) was moved)
//here is where slow statement used to be -- this is the placed further down the chain where that statement used to load

C# code:

public static List<Job> GetOverviewJobsV2(List<int> JobTypes, int SupplierId, bool FindDesignStock)
{
        using (SqlConnection conn = new SqlConnection(Settings.ConnectionString))
        {
            DataTable dt = Common.DataTableHelpers.CreateIntDataTable(JobTypes);

            using (var multi = conn.QueryMultiple("PR_GetOverviewJobs_V5", new { JobTypes = dt.AsTableValuedParameter("dbo.IntTable"), SupplierId }, commandType: System.Data.CommandType.StoredProcedure))
            {
                var jobs = multi.Read<Job>().ToList();

                bool orderVersion0required = jobs.Exists(x => x.OrderVersion == 0);

                try
                {
                    //orderversion 0
                    var designData = new List<DesignProcessData>();
                    var children = new List<DesignProcessData>();
                    var designStatuses = new List<DesignProcessStep>();

                    var orderItemsV1 = new List<OrderItem>();
                    var jobItemsV1 = new List<JobItem>();
                    var despatchItems = new List<DespatchItem>();

                    if (orderVersion0required)
                    {
                        designData = multi.Read<DesignProcessData>().OrderBy(x => x.ApplicationDate).ToList();
                        children = multi.Read<DesignProcessData>().ToList();
                        designStatuses = multi.Read<DesignProcessStep>().ToList();

                        orderItemsV1 = multi.Read<OrderItem>().ToList();
                        jobItemsV1 = multi.Read<JobItem>().ToList();
                        despatchItems = multi.Read<DespatchItem>().ToList();
                    }

                    //orderversion 1
                    var masterDesigns = multi.Read<DesignProcessData>().ToList();
                    var orderDesigns = multi.Read<OrderDesign>().ToList();

                    //slow statement moved to here
                    var orderDesignProcessSteps = multi.Read<DesignProcessStep>().ToList();
                    var masterDesignProcessSteps = multi.Read<DesignProcessStep>().ToList();

                    //orderversion 1
                    var orderItemsV2 = multi.Read<OrderItem>().ToList();
                    var jobItemsV2 = multi.Read<OrderItem>().ToList();
                    var jobItemIdsLinkedToOrderItemIds = multi.Read<JobItem>().ToList();
                    var despatchItemsV2 = multi.Read<DespatchItem>().ToList();

                    var finishing = multi.Read<FinishingProcessData>().ToList();

                    var filestoreFiles = multi.Read<FileStoreFile>().ToList();
                    var masterDesignFileStore = multi.Read<FileStoreFile>().ToList();

                    var staffMembers = multi.Read<StaffMember>().ToList();
                    var logs = multi.Read<LogEntry>().ToList();

                    var potentialJobs = multi.Read<Job>().ToList();

                    //orderversion0
                    var designColours = new List<PrintColour>();
                    var stencils = new List<Stencil>();
                    stencils = null;

                    var screens = new List<Screen>();
                    screens = null;

                    if (orderVersion0required)
                    {
                        designColours = multi.Read<PrintColour>().ToList();

                        if (JobTypes.Exists(jt => jt == 1 || jt == 6))
                        {
                            stencils = multi.Read<Stencil>().ToList();
                            screens = multi.Read<Screen>().ToList();
                        }
                    }

                    //orderversion 1
                    var designColoursv2 = multi.Read<PrintColour>().ToList();
                    var colourways = multi.Read<PrintColourway>().ToList();
                    var colourWayColours = multi.Read<MyStore.Design.PrintColour>().OrderBy(x => x.ColourNumber).ToList();
                    var designStock = multi.Read<DesignStock>().ToList();

                    var stencilsv2 = new List<Stencil>();
                    stencilsv2 = null;

                    var screensv2 = new List<Screen>();
                    screensv2 = null;

                    if (JobTypes.Exists(jt => jt == 1 || jt == 6))
                    {
                        stencilsv2 = multi.Read<Stencil>().ToList();
                        screensv2 = multi.Read<Screen>().ToList();
                    }

                    //here is where slow statement used to be

                    var itemPurchaseOrders = multi.Read<ItemPurchaseOrder>().ToList();
                    var purchaseOrderItems = multi.Read<PurchasingItem>().ToList();
                    var purchaseOrderBookingDatas = multi.Read<BookingData>().ToList();
                    var purchaseOrderBookingItems = multi.Read<BookingItem>().ToList();
                    var itemFaults = multi.Read<ItemFault>().ToList();
                    var orderItemIdsLinkedToPurchaseItems = multi.Read<PurchasingItem>().ToList();
                    var stockLocations = multi.Read<StockLocation>().ToList();

                    var highlightColours = multi.Read<Core.Site.HighlightColour>().ToList();
                    var serviceSuppliers = multi.Read<ServiceSupplier>().ToList();

T-SQL Procedure:

If you want to see the bit that was slowing it down that was moved, it's got a comment directly above it called --design process stepsv2 orderDesignProcessSteps.  It ends with WHERE olddps.MasterDesignId = 0

USE [LaunchPad3_Production]
GO
/****** Object:  StoredProcedure [dbo].[PR_GetOverviewJobs_V5]    Script Date: 14/12/2022 13:15:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

 ALTER PROCEDURE [dbo].[PR_GetOverviewJobs_V5]
    @JobTypes IntTable READONLY,
    @SupplierId INT = 1
AS
BEGIN
    SET NOCOUNT ON;
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
------------------------------------------------------------------------TEMP TABLES
    --temptable for jobs
    SELECT
        prj.Id AS JobId,
        ob.Id AS OrderId,
        prj.DesignId,
        ob.GlobalId,
        ob.OrderVersion
    INTO #Jobs
    FROM
        LaunchPad3_Production.dbo.PR_Job prj
            INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = prj.OrderId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Base opb ON opb.OrderId = prj.OrderId
            INNER JOIN @JobTypes jt ON jt.Int = prj.JobType
    WHERE
        prj.completed = 0
        AND ob.deleted = 0
        AND opb.IsProcessed = 1
        AND opb.Complete = 0
        AND opb.HoldInStoke = 0
        AND prj.SupplierId = @SupplierId

        --AND prj.Id = 46167

    DECLARE @NumberOf0VersionOrders int = (SELECT COUNT(OrderVersion) FROM #Jobs WHERE OrderVersion = 0)

------------------------------------------------------------------------SELECT QUERIES

    -- Get all jobs
    SELECT DISTINCT
        opb.*,
        prj.*,
        CONVERT(DATE,opb.DespatchDate) AS DespatchDate,
        CONVERT(DATE,prj.ProductionDate) AS ApplicationDate,
        prj.Id as JobId,
        ISNULL(prj.Notes, '') AS JobNotes,
        ub.CompanyName,
        ub.FirstName,
        ub.LastName,
        ob.OrderVersion,
        opb.DespatchDateType AS DespatchType
    FROM LaunchPad3_Production.dbo.PR_Job prj
        INNER JOIN #Jobs ej ON ej.jobid = prj.id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = prj.OrderId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Base opb ON opb.OrderId = prj.OrderId
        INNER JOIN LaunchPad3_Core.dbo.USER_Base ub ON ob.UserId = ub.Id

IF (@NumberOf0VersionOrders != 0)
    BEGIN
        -- order version 0 parent designs
        SELECT distinct opd.*, od.*, db.*,
            dpm.ViewPoint as TemplateViewPoint,
            dp.Type as DesignPosition,
            db.ApplicationTypeId,
            opd.ProcessTypeId as ProcessId,
            od.CategoryId,
            od.DesignId,
            dp.Type AS DesignPosition,
            od.Id,
            db.Name,
            od.OrderId,
            DesignPositionId AS PositionId,
            opd.OrderDesignId,
            opd.OrderDesignId as DesignId,
            opd.ApplicationDate,
            od.OrderId,
            dpr.Department,
            dlpc.ParentId, dlpc.ChildId,
            dpr.WeedingRequired,
            dpr.Name AS ProcessType
        FROM #Jobs pj
            INNER JOIN LaunchPad3_MyStore_2015.dbo.ORDER_Design od ON od.orderid = pj.orderid
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Base db ON od.DesignId = db.Id
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Position dp ON dp.Id = od.DesignPositionId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Design opd ON opd.OrderDesignId = od.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Process dpr ON dpr.id = opd.ProcessTypeId
            left JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PositionMap dpm ON dpm.TemplateId = od.CategoryId and dpm.PositionId = od.DesignPositionId AND dpm.GlobalId = pj.GlobalId
            LEFT JOIN LaunchPad3_OrderProcess.dbo.DESIGN_LINK_Parent_Child dlpc ON dlpc.childid = od.DesignId
        WHERE dlpc.ParentId IS NULL OR dlpc.parentid = od.designid

        -- order version 1 child designs
        SELECT distinct opd.*, od.*, db.*,
            dpm.ViewPoint as TemplateViewPoint,
            dp.Type as DesignPosition,
            db.ApplicationTypeId,
            opd.ProcessTypeId as ProcessId,
            od.CategoryId,
            od.DesignId,
            dp.Type AS DesignPosition,
            od.Id,
            db.Name,
            od.OrderId,
            DesignPositionId AS PositionId,
            opd.OrderDesignId,
            opd.OrderDesignId as DesignId,
            opd.ApplicationDate,
            od.OrderId,
            dpr.Department,
            dlpc.ParentId, dlpc.ChildId
            --, pj.designid, od.designid
        FROM #Jobs pj
            INNER JOIN LaunchPad3_MyStore_2015.dbo.ORDER_Design od ON od.orderid = pj.orderid
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_LINK_Parent_Child dlpc ON dlpc.childid = od.DesignId
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Base db ON od.DesignId = db.Id
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Position dp ON dp.Id = od.DesignPositionId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Design opd ON opd.OrderDesignId = od.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Process dpr ON dpr.id = opd.ProcessTypeId
            INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PositionMap dpm ON dpm.TemplateId = od.CategoryId and dpm.PositionId = od.DesignPositionId AND dpm.GlobalId = pj.GlobalId

        --design statuses v1
        SELECT DISTINCT
            olddps.*,
            dps.*,
            dpss.*,
            dpdps.*,
            olddps.DesignId,
            olddps.PathStepId as Id,
            dps.StatusText as DisplayText,
            dpss.StatusText AS StatusText,
            dpdps.StepOrder as PathOrder,
            dp.ApplicationTypeId AS ProcessTypeId
        FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_DesignPathStep olddps
            INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Design od1 ON od1.DesignId = olddps.DesignId
            INNER JOIN #Jobs j ON j.OrderId = od1.OrderId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStep dps ON olddps.PathStepId = dps.Id
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStepStatus dpss ON olddps.PathStepStatusId = dpss.Id
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Design od ON od.OrderDesignId = olddps.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPath dp ON dp.ApplicationTypeId = od.ProcessTypeId AND dp.GlobalId = j.GlobalId
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_DesignPath_DesignPathStep dpdps ON dpdps.PathStepId = olddps.PathStepId AND dpdps.PathId = dp.Id

        --order items v1
        SELECT distinct oi.*, dt.Name AS TemplateName, Qty as ItemQty, ej.JobId
        FROM Launchpad3_MyStore_2015.dbo.ORDER_Item oi
            INNER JOIN Launchpad3_MyStore_2015.dbo.design_template dt on dt.Id = oi.TemplateId
            INNER JOIN #Jobs ej ON ej.OrderId = oi.OrderId

        --jobItems v1
        SELECT ji.*
        FROM LaunchPad3_Production.dbo.PR_JobItem ji
            INNER JOIN #Jobs ej ON ej.jobid = ji.jobid

        --despatch datav1
        SELECT DISTINCT  db.*,di.*
        FROM
            LaunchPad3_OrderProcess.dbo.despatch_item di
            INNER JOIN LaunchPad3_OrderProcess.dbo.DESPATCH_Base db ON db.id = di.DespatchId
            inner JOIN Launchpad3_MyStore_2015.dbo.order_item oi ON oi.id = di.OrderItemId
            INNER JOIN #Jobs ej ON ej.orderid = oi.OrderId
        WHERE db.Deleted= 0
    END

    --master designs order version 2
    SELECT DISTINCT
        dm.*,
        0 AS DesignId,
        dtd.Type AS DesignType,
        dm.Id AS MasterDesignId,
        pc.HexCode as FontColourCode,
        pc.Name AS FontColourName,
        df.Name as FontName,
        dta.Type AS DesignApplicationType,
        dm.ProcessTypeId as ProcessId,
        dp.Name AS ProcessType,
        dp.Department,
        dp.WeedingRequired,
        pjlmd.JobId
    FROM Launchpad3_MyStore_2015.dbo.Order_Design_V2 od
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Master dm ON dm.Id = od.MasterDesignId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Application dta ON dta.Id = dm.ApplicationTypeId
        inner JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Design dtd ON dtd.Id = dm.DesignTypeId
        LEFT JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PrintColours pc ON Dm.FontColourId = pc.Id
        LEFT JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Font df ON df.Id = Dm.FontId
        LEFT JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Process dp ON dp.Id = dm.ProcessTypeId

    -- order designs order version 2
    SELECT DISTINCT
        od.*,
        od.Id AS OrderDesignId,
        od.DesignPositionId AS PositionId,
        dpm.ViewPoint as TemplateView,
        dpm.ViewPoint,
        dtp.Type AS DesignPosition,
        pjlmd.JobId
    FROM Launchpad3_MyStore_2015.dbo.Order_Design_V2 od
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId AND j.OrderId = od.OrderId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_TYPE_Position dtp ON dtp.Id = od.DesignPositionId
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oi ON oi.Id = od.OrderItemId
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = od.OrderId
        INNER JOIN Launchpad3_MyStore_2015.dbo.PRODUCT_Base pb ON pb.Id = oi.ProductId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_PositionMap dpm on dpm.TemplateId = pb.TemplateId AND dpm.PositionId = od.DesignPositionId

    --design process stepsv2 orderDesignProcessSteps
    SELECT DISTINCT
        olddps.*,
        dps.*,
        dpss.*,
        dpdps.*,
        olddps.PathStepId as Id,
        dps.StatusText as DisplayText,
        dpss.StatusText AS StatusText,
        dpdps.StepOrder as PathOrder,
        dp.ApplicationTypeId AS ProcessId
    FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_DesignPathStepV2 olddps
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStep dps ON olddps.PathStepId = dps.Id
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStepStatus dpss ON olddps.PathStepStatusId = dpss.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.Order_Design_V2 od ON  od.Id = olddps.DesignId
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Master dm ON dm.Id = od.MasterDesignId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPath dp ON dp.ApplicationTypeId = dm.ProcessTypeId AND dp.GlobalId = j.GlobalId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_DesignPath_DesignPathStep dpdps ON dpdps.PathStepId = olddps.PathStepId AND dpdps.PathId = dp.Id
    WHERE olddps.MasterDesignId = 0

    --master design process stepsv2
    SELECT DISTINCT
        olddps.*,
        dps.*,
        dpss.*,
        dpdps.*,
        olddps.PathStepId as Id,
        dps.StatusText as DisplayText,
        dpss.StatusText AS StatusText,
        dpdps.StepOrder as PathOrder,
        dp.ApplicationTypeId AS ProcessId
    FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_DesignPathStepV2 olddps
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStep dps ON olddps.PathStepId = dps.Id
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPathStepStatus dpss ON olddps.PathStepStatusId = dpss.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.Order_Design_V2 od ON  od.MasterDesignId = olddps.MasterDesignId
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = od.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESIGN_Master dm ON dm.Id = od.MasterDesignId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_DesignPath dp ON dp.ApplicationTypeId = dm.ProcessTypeId AND dp.GlobalId = j.GlobalId
        INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_DesignPath_DesignPathStep dpdps ON dpdps.PathStepId = olddps.PathStepId AND dpdps.PathId = dp.Id
    WHERE olddps.MasterDesignId != 0

    --order itemsv2
    SELECT DISTINCT oi.*, S.Size AS SizeName, oi.Qty AS ItemQty
    FROM    Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oi
        INNER JOIN Launchpad3_MyStore_2015.dbo.PRODUCT_Size s ON oi.SizeId = s.Id
        INNER JOIN #Jobs j ON j.OrderId = oi.OrderId

    -- Job itemsv2
    SELECT DISTINCT
    oiv.OrderId
    ,oiv.ProductId
    ,oiv.ProductCode
    ,oiv.ProductName
    ,oiv.ColourId
    ,oiv.SizeId
    ,oiv.ColourName
    ,oiv.TemplateId
    ,S.Size AS SizeName
    ,pji.*
    ,dt.Name AS TemplateName
    FROM LaunchPad3_Production.dbo.PR_JobItem pji
        INNER JOIN LaunchPad3_Production.dbo.PR_JobItem_LINK_OrderItem pjiloi ON pjiloi.JobItemId = pji.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oiv ON oiv.Id = pjiloi.OrderItemId
        INNER JOIN Launchpad3_MyStore_2015.dbo.PRODUCT_Size s ON oiv.SizeId = s.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Base ob ON ob.Id = oiv.OrderId
        INNER JOIN Launchpad3_MyStore_2015.dbo.DESIGN_Template dt ON dt.Id = oiv.TemplateId
        INNER JOIN #Jobs j ON j.JobId = pji.JobId

    --job items linked to orderItemsv2
    SELECT DISTINCT pjiloi.*
    FROM LaunchPad3_Production.dbo.PR_JobItem pji
        INNER JOIN LaunchPad3_Production.dbo.PR_JobItem_LINK_OrderItem pjiloi ON pjiloi.JobItemId = pji.Id
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oiv ON oiv.Id = pjiloi.OrderItemId
        INNER JOIN #Jobs j ON j.JobId = pji.JobId

    --despatch datav2
    SELECT DISTINCT di.*, db.* FROM
        LaunchPad3_OrderProcess.dbo.despatch_item di
        INNER JOIN LaunchPad3_OrderProcess.dbo.DESPATCH_Base db ON db.id = di.DespatchId
        inner JOIN Launchpad3_MyStore_2015.dbo.ORDER_ITEM_V2 oiv ON oiv.id = di.OrderItemId
        INNER JOIN #Jobs ej ON ej.orderid = oiv.OrderId
    WHERE db.Deleted= 0

    -- get finishing
    SELECT DISTINCT
        f.Id,
        f.OrderId,
        f.Type,
        ISNULL(ft.Name, '') as TypeName,
        f.Method,
        ISNULL(fp.Name,'') AS MethodName,
        f.SupplierId,
        f.Notes,
        f.Date,
        ft.PackingDepartmentRequiredForFinishing,
        ISNULL(f.MediaLocation,'') AS MediaLocation,
        ISNULL(fp.PackingDepartmentRequiredForPacking,0) AS PackingDepartmentRequiredForPacking
    FROM LaunchPad3_OrderProcess.dbo.ORDERPROCESS_Finishing f
        Left JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_TYPE_Finishing ft ON ft.Id = f.Type
        Left JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_TYPE_Packing fp ON fp.Id = f.Method
        INNER JOIN #Jobs j ON j.OrderId = f.orderid

    -- order filestore
    SELECT DISTINCT ej.DesignId, ff.*, flfo.OrderId, flfo.FileTypeId as Type, flfo.DesignId AS OrderDesignId
    FROM LaunchPad3_OrderProcess.dbo.FILESTORE_File ff
        INNER JOIN LaunchPad3_OrderProcess.dbo.FILESTORE_LINK_File_Order flfo ON ff.Id = flfo.FileId
        INNER JOIN #Jobs ej ON ej.orderid = flfo.OrderId

    --filestore files for design
    SELECT DISTINCT
        ff.Id
       ,ff.Name
       ,ff.FilePath
       ,ff.Size
       ,ff.GlobalId
        ,flfo.FileId
       ,flfo.FileTypeId
       ,flfo.DesignId
       ,flfo.MasterDesignId
       ,flfo.ColourwayId
        ,flfo.FileTypeId as Type
        ,flfo.OrderId
    FROM LaunchPad3_OrderProcess.dbo.FILESTORE_File ff
        INNER JOIN  LaunchPad3_OrderProcess.dbo.FILESTORE_LINK_File_Order flfo ON ff.Id = flfo.FileId
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.MasterDesignId = flfo.MasterDesignId
        INNER JOIN #Jobs j ON j.JobId = pjlmd.JobId

    --staff members
    SELECT * FROM LaunchPad3_Core.dbo.USER_Base ub
        INNER JOIN LaunchPad3_Production.dbo.PR_StaffMember sm ON sm.UserId = ub.Id AND sm.GlobalId = ub.GlobalId
    WHERE ub.GlobalId = 29

    --log entries
    SELECT DISTINCT
        pl.Id
       ,pl.JobId
       ,pl.OrderId
       ,pl.DesignId
       ,pl.UserId
       ,pl.StatusId AS Status
       ,pl.Notes
       ,pl.Date
    FROM LaunchPad3_Production.dbo.PR_Log pl
        INNER JOIN  #Jobs ej ON ej.JobId = pl.JobId

    -- list of all other jobs
    EXEC LaunchPad3_Production.dbo.[PR_GetAllJobsForLiveOrders]

IF (@NumberOf0VersionOrders != 0)
    BEGIN
    -- get design colourways and print colours
        SELECT pc.id, cb.DesignId, pc.name, cb.Id as ColourWayId, pc.HexCode, clbc.PantoneMixed
        FROM #Jobs sp
            INNER JOIN LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_PrintColour oldpc ON oldpc.DesignId = sp.DesignId -- AND oldpc.PrintColourId = pc.Id
            INNER join LaunchPad3_MyStore_2015.dbo.DESIGN_PrintColours pc ON pc.Id = oldpc.PrintColourId -- clbc.ColourId
            INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_Base cb ON cb.DesignId = oldpc.DesignId -- sp.DesignId = cb.DesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_LINK_Base_Colour clbc ON cb.Id = clbc.ColourwayId
        --WHERE sp.OrderVersion = 0

        IF EXISTS (SELECT int FROM @JobTypes WHERE Int = 1 OR int = 6)
            BEGIN
                --get the stencils
                SELECT DISTINCT sps.*
                , slss.ScreenId
                FROM
                    #Jobs j
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON sps.OrderId = j.OrderId AND sps.DesignId = j.DesignId
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.StencilId = sps.Id

                --get the screens
                SELECT DISTINCT spsc.*
                FROM LaunchPad3_Production.dbo.PR_SP_Screen spsc
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.ScreenId = spsc.Id
                    INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON sps.Id = slss.StencilId
                    INNER JOIN #Jobs j ON j.DesignId = sps.DesignId
            END
END

    --design coloursv2
    SELECT  distinct
        dpc.*
        ,dpc.HexCode as ColourCode
        ,opc.ColourOnAllGarments
        ,od.ColourWayId
        ,opc.ColourNumber
        ,od.MasterDesignId
        ,clbc.PantoneMixed
    FROM #Jobs j
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
        INNER JOIN Launchpad3_MyStore_2015.dbo.ORDER_Design_V2 od ON od.MasterDesignId = pjlmd.MasterDesignId
        INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_LINK_Base_Colour clbc ON od.ColourWayId = clbc.ColourwayId -- AND clbc.ColourwayId = od.ColourWayId
        INNER join LaunchPad3_OrderProcess.dbo.ORDERPROCESS_LINK_Design_PrintColour opc ON od.MasterDesignId = opc.MasterDesignId AND opc.PrintColourId = clbc.ColourId
        INNER join LaunchPad3_MyStore_2015.dbo.DESIGN_PrintColours dpc ON dpc.Id = opc.PrintColourId

    --master design colourwaysv2
    SELECT DISTINCT cb.*
    FROM
        #Jobs j
        INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
        INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_Base cb ON pjlmd.MasterDesignId = cb.MasterDesignId

    --print colours from master design colourwaysv2
        SELECT DISTINCT
        dpc.*
        ,cb.*
        ,cb.Id AS ColourWayId
        ,dpc.Id
        ,clbc.ColourNumber
        ,clbc.PantoneMixed
        FROM
            #Jobs j
            INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
            inner JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_Base cb ON cb.MasterDesignId = pjlmd.MasterDesignId
            INNER JOIN LaunchPad3_OrderProcess.dbo.COLOURWAY_LINK_Base_Colour clbc ON cb.Id = clbc.ColourwayId
            INNER join LaunchPad3_MyStore_2015.dbo.DESIGN_PrintColours dpc ON dpc.Id = clbc.ColourId

    --designstock
    SELECT *
    FROM LaunchPad3_OrderProcess.dbo.Design_Master_Stock_LINK_OrderId dmsloi
        INNER join #Jobs j ON j.OrderId = dmsloi.OrderId

IF EXISTS (SELECT int FROM @JobTypes WHERE Int = 1 OR int = 6)
    BEGIN
        --get the stencilsv2
        SELECT DISTINCT sps.*
        , slss.ScreenId
        FROM
            #Jobs j
            INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON pjlmd.MasterDesignId = sps.MasterDesignId
            LEFT JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.StencilId = sps.Id

        --get the screensv2
        SELECT DISTINCT spsc.* ,slss.StencilId
        FROM
            #Jobs j
            INNER JOIN LaunchPad3_Production.dbo.PR_Job_LINK_MasterDesign pjlmd ON pjlmd.JobId = j.JobId
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_Stencil sps ON sps.MasterDesignId = pjlmd.MasterDesignId
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_LINK_Stencil_Screen slss ON slss.StencilId = sps.Id
            INNER JOIN LaunchPad3_Production.dbo.PR_SP_Screen spsc  ON slss.ScreenId = spsc.Id
    END

    --item purchase orders
        SELECT DISTINCT ipo.* FROM LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo
            INNER JOIN #Jobs ej ON ej.OrderId = ipo.OrderId
        WHERE ipo.deleted = 0

    --purchase order items
    SELECT DISTINCT poi.*, ej.OrderId FROM LaunchPad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem poi
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = poi.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.OrderId = ipo.OrderId
    WHERE ipo.deleted = 0

    --booking records
    SELECT DISTINCT bb.*, ej.OrderId, bb.Location AS location FROM LaunchPad3_Purchasing.dbo.BOOKING_Base bb
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = bb.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.OrderId = ipo.OrderId
    WHERE ipo.deleted = 0

    --booking items
    SELECT DISTINCT bi.*, ej.OrderId FROM LaunchPad3_Purchasing.dbo.BOOKING_Item bi
        INNER JOIN LaunchPad3_Purchasing.dbo.BOOKING_Base bb ON bi.BookingDataId = bb.Id
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = bb.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.orderid = ipo.orderid
    WHERE ipo.deleted = 0

    -- items faults
    SELECT DISTINCT bif.* FROM LaunchPad3_Purchasing.dbo.BOOKING_ItemFault bif
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem poi ON poi.Id = bif.PurchaseItemId
        INNER JOIN LaunchPad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder ipo ON ipo.Id = poi.PurchaseOrderId
        INNER JOIN #Jobs ej ON ej.orderid = ipo.OrderId
    WHERE ipo.deleted = 0

    --orderItemIds linked to purchase order items
    SELECT DISTINCT ppoiloi.PurchaseItemId AS Id, ppoiloi.OrderItemId
    FROM Launchpad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem_LINK_OrderItem ppoiloi
        INNER JOIN Launchpad3_Purchasing.dbo.PURCHASING_PurchaseOrderItem poi ON ppoiloi.PurchaseItemId = poi.Id
        INNER JOIN Launchpad3_Purchasing.dbo.PURCHASING_ItemPurchaseOrder pipo ON pipo.Id = poi.PurchaseOrderId
        INNER JOIN #Jobs j ON j.OrderId = pipo.OrderId
    WHERE pipo.Deleted = 0

    -- stock locations
    SELECT
    *
    , LocationType AS Type
    FROM LaunchPad3_Purchasing.dbo.STOCK_Location

    -- get the highlight colours
    EXEC LaunchPad3_Core.dbo.HIGHLIGHTCOLOUR_GetAll

    --service suppliers
    EXEC LaunchPad3_OrderProcess.dbo.SERVICESUPPLIER_GetAll 29

    DROP TABLE #jobs
END


问:
HTTP error 400 Bad Request when POSTing JSON data over HttpURLConnection
I am trying to connect to sharepoint  to get the access token.I am using  below  code to call the api but getting 400  bad request.It's working with  postman.

```<code>        URL url = new URL(myurl);

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        // conn.setRequestProperty("Accept", "application/json;");
        // conn.setRequestProperty("x-csrf-token", "fetch");
        // conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
        // conn.setRequestProperty("Accept-Charset", "UTF-8");
        // conn.setRequestProperty("User-Agent", "Java client");

        JSONObject obj2 = new JSONObject();
        obj2.put("grant_type", mygranttype);
        obj2.put("client_id", clientid);
        obj2.put("client_secret", secret);
        obj2.put("resource", resource);
        // System.out.println(conn.getHeaderFields());

        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
        out.write(obj2.toString());
        out.close();

        BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            System.out.println(output);
        }

        conn.disconnect();
</code>```

I tried below options:

```<code> // conn.setRequestProperty("x-csrf-token", "fetch");
        // conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
        // conn.setRequestProperty("Accept-Charset", "UTF-8");
        // conn.setRequestProperty("User-Agent", "Java client");
</code>```

Body:
I am trying to connect to sharepoint  to get the access token.I am using  below  code to call the api but getting 400  bad request.It's working with  postman.

        URL url = new URL(myurl);

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        // conn.setRequestProperty("Accept", "application/json;");
        // conn.setRequestProperty("x-csrf-token", "fetch");
        // conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
        // conn.setRequestProperty("Accept-Charset", "UTF-8");
        // conn.setRequestProperty("User-Agent", "Java client");

        JSONObject obj2 = new JSONObject();
        obj2.put("grant_type", mygranttype);
        obj2.put("client_id", clientid);
        obj2.put("client_secret", secret);
        obj2.put("resource", resource);
        // System.out.println(conn.getHeaderFields());

        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
        out.write(obj2.toString());
        out.close();

        BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            System.out.println(output);
        }

        conn.disconnect();

I tried below options:

 // conn.setRequestProperty("x-csrf-token", "fetch");
        // conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
        // conn.setRequestProperty("Accept-Charset", "UTF-8");
        // conn.setRequestProperty("User-Agent", "Java client");