问:
Visual Studio 2017 failed to install several components
The installer for release version of Visual Studio 2017 Community edition failed for several components

The product failed to install the listed workloads and components due
  to one or more package failures.

Incomplete workloads
      Mobile development with .NET (Microsoft.VisualStudio.Workload.NetCrossPlat,version=15.0.26228.0)

Incomplete components
      Google Android Emulator (API Level 23) (Component.Google.Android.Emulator.API23.V2,version=15.0.26208.0)

You can search for solutions using the information below, modify your
  selections for the above workloads and components and retry the
  installation, or remove the product from your machine.

Following is a collection of individual package failures that led to
  the incomplete workloads and components above. To search for existing
  reports of these specific problems, please copy and paste the URL from
  each package failure into a web browser. If the issue has already been
  reported, you can find solutions or workarounds there. If the issue
  has not been reported, you can create a new issue where other people
  will be able to find solutions or workarounds.

Package 'AndroidEmulator_API23V2,version=1.0.23' failed to download
  from 'https://go.microsoft.com/fwlink/?linkid=841569'.
      Search URL: https://aka.ms/VSSetupErrorReports?q=PackageId=AndroidEmulator_API23V2;PackageAction=DownloadPackage;ReturnCode=0x80072f7d
      Impacted workloads
          Mobile development with .NET (Microsoft.VisualStudio.Workload.NetCrossPlat,version=15.0.26228.0)
      Impacted components
          Google Android Emulator (API Level 23) (Component.Google.Android.Emulator.API23.V2,version=15.0.26208.0)
      Details
          WebClient download failed: The decryption operation failed, see inner exception.
          Bits download failed: Error context: BG_ERROR_CONTEXT_REMOTE_FILE, Error code: -2147012739
          WinInet download failed: Function: InternetReadFile, HR: -2147012739, Message: Unknown error 12157

Does this Mobile development with .NET  impact in anyway Windows UWP development?  I don't really need the Android development tools at this moment.

What is the best course of action for this - I tried the install twice, with the same result - can I install the components later on their own?

EDIT: Visual Studio seems to run correctly, and I can open my UWP project and run it so everything seems to work ok so far.  This is the version of the application that was installed

```<code>Microsoft Visual Studio Community 2017
Version 15.0.26228.9 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01586
Installed Version: Community
</code>```

答:
See if you have this file on your machine:

```<code>%programfiles(x86)%\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe
</code>```

If so, please launch it from an admin command prompt with a -full param:

```<code>InstallCleanup.exe -full
</code>```

If not, please manually delete the folder:

```<code>%programfiles(x86)%\Microsoft Visual Studio\Installer
</code>```

Relaunch the newly downloaded vs_enterprise.exe (or vs_professional.exe or vs_community.exe). Allow the first step to install the installer.

Once the installer comes up and you can see workload choices (.NET desktop and the like), close it. Go launch the same InstallCleanup.exe to clean up old build of VS.

Then relaunch vs_enterprise.exe and install

Body:
The installer for release version of Visual Studio 2017 Community edition failed for several components

The product failed to install the listed workloads and components due
  to one or more package failures.

Incomplete workloads
      Mobile development with .NET (Microsoft.VisualStudio.Workload.NetCrossPlat,version=15.0.26228.0)

Incomplete components
      Google Android Emulator (API Level 23) (Component.Google.Android.Emulator.API23.V2,version=15.0.26208.0)

You can search for solutions using the information below, modify your
  selections for the above workloads and components and retry the
  installation, or remove the product from your machine.

Following is a collection of individual package failures that led to
  the incomplete workloads and components above. To search for existing
  reports of these specific problems, please copy and paste the URL from
  each package failure into a web browser. If the issue has already been
  reported, you can find solutions or workarounds there. If the issue
  has not been reported, you can create a new issue where other people
  will be able to find solutions or workarounds.

Package 'AndroidEmulator_API23V2,version=1.0.23' failed to download
  from 'https://go.microsoft.com/fwlink/?linkid=841569'.
      Search URL: https://aka.ms/VSSetupErrorReports?q=PackageId=AndroidEmulator_API23V2;PackageAction=DownloadPackage;ReturnCode=0x80072f7d
      Impacted workloads
          Mobile development with .NET (Microsoft.VisualStudio.Workload.NetCrossPlat,version=15.0.26228.0)
      Impacted components
          Google Android Emulator (API Level 23) (Component.Google.Android.Emulator.API23.V2,version=15.0.26208.0)
      Details
          WebClient download failed: The decryption operation failed, see inner exception.
          Bits download failed: Error context: BG_ERROR_CONTEXT_REMOTE_FILE, Error code: -2147012739
          WinInet download failed: Function: InternetReadFile, HR: -2147012739, Message: Unknown error 12157

Does this Mobile development with .NET  impact in anyway Windows UWP development?  I don't really need the Android development tools at this moment.

What is the best course of action for this - I tried the install twice, with the same result - can I install the components later on their own?

EDIT: Visual Studio seems to run correctly, and I can open my UWP project and run it so everything seems to work ok so far.  This is the version of the application that was installed

Microsoft Visual Studio Community 2017
Version 15.0.26228.9 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01586
Installed Version: Community

Body:
See if you have this file on your machine:

%programfiles(x86)%\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe

If so, please launch it from an admin command prompt with a -full param:

InstallCleanup.exe -full

If not, please manually delete the folder:

%programfiles(x86)%\Microsoft Visual Studio\Installer

Relaunch the newly downloaded vs_enterprise.exe (or vs_professional.exe or vs_community.exe). Allow the first step to install the installer.

Once the installer comes up and you can see workload choices (.NET desktop and the like), close it. Go launch the same InstallCleanup.exe to clean up old build of VS.

Then relaunch vs_enterprise.exe and install


来源: stackexchange

问:
CSS Divs out of Place on IE
Please look at these 2 pages on IE and on another Browser (like firefox)

http://www.zomghentai.com/kite-episode-1-sub/
and
http://www.zomghentai.com/stream/kite/

Notice the glitches on IE, a lot of things look out of place.

Can anyone tell me what CSS edits I should make to fix this ??

Edit :: I'm Using IE 8,  I posted screenshots in the comment below

答:
your top menu is still set as a default unordered list, try floating left its LIs.
Also, IE < 8 's box model is different from the rest of the world's, so try to avoid using paddings & widths combined, or else, write a IE specific stylesheet and link it in the page head adding a code like this:</p>

```<code><!--[if lte IE 7]><link href="style/iespecific.css" rel="stylesheet" type="text/css" /><![endif]-->
</code>```

ContentLicense: CC BY-SA 2.5

Title: CSS Divs out of Place on IE

Body:
your top menu is still set as a default unordered list, try floating left its LIs.
Also, IE < 8 's box model is different from the rest of the world's, so try to avoid using paddings & widths combined, or else, write a IE specific stylesheet and link it in the page head adding a code like this:

<!--[if lte IE 7]><link href="style/iespecific.css" rel="stylesheet" type="text/css" /><![endif]-->


问:
Namespace 'fab' is not bound error when using com.github.clans.fab.FloatingActionButton
am trying to create a floating action menu using the Clans/FloatingActionButton but i am getting the namespace 'fab' is not bound error in my layout file. I have included the dependency of compile 'com.github.clans:fab:1.6.4' so i don't know what is wrong.

This is my layout file.

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.kabricks.betterapp.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <com.github.clans.fab.FloatingActionButton
        android:id="@+id/material_design_android_floating_action_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="11dp"
        android:layout_marginLeft="11dp"
        android:layout_marginRight="11dp"
        app:menu_animationDelayPerItem="55"
        app:menu_backgroundColor="@android:color/transparent"
        fab:menu_buttonSpacing="0dp"
        fab:menu_colorNormal="#da3c2f"
        fab:menu_colorPressed="#dc4b3f"
        fab:menu_colorRipple="#99d4d4d4"
        fab:menu_fab_label="Floating Action Menu"
        fab:menu_fab_size="normal"
        fab:menu_icon="@drawable/fab_add"
        fab:menu_labels_colorNormal="#333"
        fab:menu_labels_colorPressed="#444"
        fab:menu_labels_colorRipple="#66efecec"
        fab:menu_labels_cornerRadius="3dp"
        fab:menu_labels_ellipsize="none"
        fab:menu_labels_hideAnimation="@anim/fab_slide_out_to_right"
        fab:menu_labels_margin="0dp"
        fab:menu_labels_maxLines="-1"
        fab:menu_labels_padding="8dp"
        fab:menu_labels_position="left"
        fab:menu_labels_showAnimation="@anim/fab_slide_in_from_right"
        fab:menu_labels_showShadow="true"
        fab:menu_labels_singleLine="false"
        fab:menu_labels_textColor="#f2f1f1"
        fab:menu_labels_textSize="15sp"
        fab:menu_openDirection="up"
        fab:menu_shadowColor="#66aff198"
        fab:menu_shadowRadius="4dp"
        fab:menu_shadowXOffset="1dp"
        fab:menu_shadowYOffset="4dp"
        fab:menu_showShadow="true">

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_send"
            fab:fab_label="Menu Item 1"
            fab:fab_size="mini" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_photo"
            fab:fab_label="Menu Item 2"
            fab:fab_size="mini" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_edit"
            fab:fab_label="Menu Item 3"
            fab:fab_size="mini" />
    </com.github.clans.fab.FloatingActionButton>

</android.support.design.widget.CoordinatorLayout>
</code>```

And this is the error,

```<code>Error:(26) Error parsing XML: unbound prefix
</code>```

I am using Android studio 2.2 and design library 23.3.0

答:
Add this to root layout: </p>

```<code>xmlns:fab="http://schemas.android.com/apk/res/com.github.clans"
</code>```

ContentLicense: CC BY-SA 3.0

Body:
am trying to create a floating action menu using the Clans/FloatingActionButton but i am getting the namespace 'fab' is not bound error in my layout file. I have included the dependency of compile 'com.github.clans:fab:1.6.4' so i don't know what is wrong.

This is my layout file.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.kabricks.betterapp.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <com.github.clans.fab.FloatingActionButton
        android:id="@+id/material_design_android_floating_action_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="11dp"
        android:layout_marginLeft="11dp"
        android:layout_marginRight="11dp"
        app:menu_animationDelayPerItem="55"
        app:menu_backgroundColor="@android:color/transparent"
        fab:menu_buttonSpacing="0dp"
        fab:menu_colorNormal="#da3c2f"
        fab:menu_colorPressed="#dc4b3f"
        fab:menu_colorRipple="#99d4d4d4"
        fab:menu_fab_label="Floating Action Menu"
        fab:menu_fab_size="normal"
        fab:menu_icon="@drawable/fab_add"
        fab:menu_labels_colorNormal="#333"
        fab:menu_labels_colorPressed="#444"
        fab:menu_labels_colorRipple="#66efecec"
        fab:menu_labels_cornerRadius="3dp"
        fab:menu_labels_ellipsize="none"
        fab:menu_labels_hideAnimation="@anim/fab_slide_out_to_right"
        fab:menu_labels_margin="0dp"
        fab:menu_labels_maxLines="-1"
        fab:menu_labels_padding="8dp"
        fab:menu_labels_position="left"
        fab:menu_labels_showAnimation="@anim/fab_slide_in_from_right"
        fab:menu_labels_showShadow="true"
        fab:menu_labels_singleLine="false"
        fab:menu_labels_textColor="#f2f1f1"
        fab:menu_labels_textSize="15sp"
        fab:menu_openDirection="up"
        fab:menu_shadowColor="#66aff198"
        fab:menu_shadowRadius="4dp"
        fab:menu_shadowXOffset="1dp"
        fab:menu_shadowYOffset="4dp"
        fab:menu_showShadow="true">

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_send"
            fab:fab_label="Menu Item 1"
            fab:fab_size="mini" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_photo"
            fab:fab_label="Menu Item 2"
            fab:fab_size="mini" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_edit"
            fab:fab_label="Menu Item 3"
            fab:fab_size="mini" />
    </com.github.clans.fab.FloatingActionButton>

</android.support.design.widget.CoordinatorLayout>

And this is the error,

Error:(26) Error parsing XML: unbound prefix

I am using Android studio 2.2 and design library 23.3.0

Body:
Add this to root layout:

xmlns:fab="http://schemas.android.com/apk/res/com.github.clans"


问:
A bug happened when I try to import a "tlb" file. The VS 2013 said that it couldn't find a "tlh" file
I am trying to import a file as below:

```<code>#import "C:/xxxx/Proj/msd60.tlb"
</code>```

But it says to me that it cannot open source file "C:/xxxx/Proj/msd60.tlh"

The tlb file is actually existing in the place where I point it.

In my opinion, the VS can split the tlb file into a tlh file(as a header file) and a tli file(as a cpp file). So something happened and make it cannot create a tlh file? But I don't know what is it. Meanwhile, another cpp in other project can open the "msd60.tlb". So the environment may not exist problems.

How to solve that?

答:
I had the same issue with msado20.tlb in VS2015. But I had the same problem in VS2013. After some research, I read that there could be some problem with absolute paths in VS, at it was best to try relative path (which is quite bothering).

In my case, the project is located in a different drive, so the relative path would be really long, so I instead copied the msado20.tlb file to my project folder and build again the solution. In this case, it worked. I know it is more a hack than a solution, but it may help others. The directive looks like this:

```<code>#import "msado20.tlb" no_namespace rename("EOF", "adoEOF")
</code>```

If someone tries the relative path, it would be interesting to know for sure that it works. Copying the file to my project folder doesn't feel a solution, but a hack

Body:
I am trying to import a file as below:

#import "C:/xxxx/Proj/msd60.tlb"

But it says to me that it cannot open source file "C:/xxxx/Proj/msd60.tlh"

The tlb file is actually existing in the place where I point it.

In my opinion, the VS can split the tlb file into a tlh file(as a header file) and a tli file(as a cpp file). So something happened and make it cannot create a tlh file? But I don't know what is it. Meanwhile, another cpp in other project can open the "msd60.tlb". So the environment may not exist problems.

How to solve that?

Body:
I had the same issue with msado20.tlb in VS2015. But I had the same problem in VS2013. After some research, I read that there could be some problem with absolute paths in VS, at it was best to try relative path (which is quite bothering).

In my case, the project is located in a different drive, so the relative path would be really long, so I instead copied the msado20.tlb file to my project folder and build again the solution. In this case, it worked. I know it is more a hack than a solution, but it may help others. The directive looks like this:

#import "msado20.tlb" no_namespace rename("EOF", "adoEOF")

If someone tries the relative path, it would be interesting to know for sure that it works. Copying the file to my project folder doesn't feel a solution, but a hack


问:
BubbleSort Implementation
I tried to make an implementation of bubble sort, but I am not sure whether it is correct or not. If you can give it a look and if it is a bubble sort and can be done in better way please don't be shy. Here is the code:</p>

```<code>package Exercises;

import java.util.*;

public class BubbleSort_6_18
{
    public static void main(String[] args)
    {
        Random generator = new Random();

        int[] list = new int[11];
        for(int i=0; i<list.length; i++)
        {
            list[i] = generator.nextInt(10);
        }

        System.out.println("Original Random array: ");
        printArray(list);

        bubbleSort(list);

        System.out.println("\nAfter bubble sort: ");
        printArray(list);
    }

    public static void bubbleSort(int[] list)
    {
        for(int i=0; i<list.length; i++)
        {
            for(int j=i + 1; j<list.length; j++)
            {
                if(list[i] > list[j])
                {
                    int temp = list[i];
                    list[i] = list[j];
                    list[j] = temp;
                }
            }

        }
    }

    public static void printArray(int[] list)
    {
        for(int i=0; i<list.length; i++)
        {
            System.out.print(list[i] + ", ");
        }
    }
}
</code>```

答:
```<code>    int[] nums = new int[] { 6, 3, 2, 1, 7, 10, 9 };

        for(int i = nums.Length-1; i>=0; i--)
            for(int j = 0; j<i; j++)
            {
                int temp = 0;
                if( nums[j] < nums[j + 1])
                {
                    temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = temp;
                }
            }
</code>```

Title: BubbleSort Implementation

Body:
I tried to make an implementation of bubble sort, but I am not sure whether it is correct or not. If you can give it a look and if it is a bubble sort and can be done in better way please don't be shy. Here is the code:

package Exercises;

import java.util.*;

public class BubbleSort_6_18
{
    public static void main(String[] args)
    {
        Random generator = new Random();

        int[] list = new int[11];
        for(int i=0; i<list.length; i++)
        {
            list[i] = generator.nextInt(10);
        }

        System.out.println("Original Random array: ");
        printArray(list);

        bubbleSort(list);

        System.out.println("\nAfter bubble sort: ");
        printArray(list);
    }

    public static void bubbleSort(int[] list)
    {
        for(int i=0; i<list.length; i++)
        {
            for(int j=i + 1; j<list.length; j++)
            {
                if(list[i] > list[j])
                {
                    int temp = list[i];
                    list[i] = list[j];
                    list[j] = temp;
                }
            }

        }
    }

    public static void printArray(int[] list)
    {
        for(int i=0; i<list.length; i++)
        {
            System.out.print(list[i] + ", ");
        }
    }
}


问:
GetManifest() and GetThumbnail() fail on some Item Version of Forge Model Derivative API
I'm using Forge c# client library to read A360 hub/project/folders structure using a 3legged token (Model Derivative API).

For every [Version]  of a [Item] in [Data Service] of A360 i need to know:

if a file has conversion errors;

if it has a thumbnail, get it;

if a item version is ready show it in the viewer (using viewer v.
2.xx)....

After authentication, i correctly see the users account hub-project-folders structure:

A360Hub

---Samples

------Golden Bridge Gate.dwf

---------Golden Bridge Gate.dwf (v1)

------V8 Engine.iam

---------V8 Engine.iam (v1)

When i call the GetManifest()  using [Golden Bridge Gate.dwf (v1)] urn i get the expected result:

```<code>string strGoldenBridgeGateV1_urn (v1) urn1 = "dXJuOmFk......_dmVyc2lvbj0x";

....
DerivativesApi.GetManifest(strGoldenBridgeGateV1_urn)->OK
DerivativesApi.GetThumbnail(strGoldenBridgeGateV1_urn)->OK
....
</code>```

When i call the same code using [V8 Engine.iam (v1)] urn i get "Error 404: not found".

```<code>....
string strV8EngineIamV1_urn="dXJuOmFkc2su........Gc_dmVyc2lvbj0x";
DerivativesApi.GetManifest(strV8EngineIamV1_urn)->FAIL (404)
DerivativesApi.GetThumbnail(strV8EngineIamV1_urn)->Fail (404)
....

Error details:
-------------- Exception:

Error code:404

HResult:-2146233088

Stack:

Autodesk.Forge.Client.ApiException: Error calling GetThumbnail:     in
Autodesk.Forge.DerivativesApi.GetThumbnailWithHttpInfo(String urn,
Nullable`1 width, Nullable`1 height)    in
Autodesk.Forge.DerivativesApi.GetThumbnail(String urn, Nullable`1
width, Nullable`1 height)    in my code...
</code>```

Same happens on file with other files:  it works with .RVT,.DWF files;
it fails with .IAM, .NWC, .SLDASM, .IFC files....

Any idea?

答:
For A360 files the translation is already there, you don't need to use Derivative API, unless you need to convert to a different format (RVT -> IFC, for instance).

Update: Data Management API was released in mid-2016 and old files on old accounts, specially those sample files, need to be recreated for it to work. Workaround (for sample files) is to download and upload again to a different folder. Customer data was migrated.

Take a look at this sample, is shows the viewable if available (check this line too).

Body:
I'm using Forge c# client library to read A360 hub/project/folders structure using a 3legged token (Model Derivative API).

For every [Version]  of a [Item] in [Data Service] of A360 i need to know:

if a file has conversion errors;

if it has a thumbnail, get it;

if a item version is ready show it in the viewer (using viewer v.
2.xx)....

After authentication, i correctly see the users account hub-project-folders structure:

A360Hub

---Samples

------Golden Bridge Gate.dwf

---------Golden Bridge Gate.dwf (v1)

------V8 Engine.iam

---------V8 Engine.iam (v1)

When i call the GetManifest()  using [Golden Bridge Gate.dwf (v1)] urn i get the expected result:

string strGoldenBridgeGateV1_urn (v1) urn1 = "dXJuOmFk......_dmVyc2lvbj0x";

....
DerivativesApi.GetManifest(strGoldenBridgeGateV1_urn)->OK
DerivativesApi.GetThumbnail(strGoldenBridgeGateV1_urn)->OK
....

When i call the same code using [V8 Engine.iam (v1)] urn i get "Error 404: not found".

....
string strV8EngineIamV1_urn="dXJuOmFkc2su........Gc_dmVyc2lvbj0x";
DerivativesApi.GetManifest(strV8EngineIamV1_urn)->FAIL (404)
DerivativesApi.GetThumbnail(strV8EngineIamV1_urn)->Fail (404)
....

Error details:
-------------- Exception:

Error code:404

HResult:-2146233088

Stack:

Autodesk.Forge.Client.ApiException: Error calling GetThumbnail:     in
Autodesk.Forge.DerivativesApi.GetThumbnailWithHttpInfo(String urn,
Nullable`1 width, Nullable`1 height)    in
Autodesk.Forge.DerivativesApi.GetThumbnail(String urn, Nullable`1
width, Nullable`1 height)    in my code...

Same happens on file with other files:  it works with .RVT,.DWF files;
it fails with .IAM, .NWC, .SLDASM, .IFC files....

Any idea?


问:
CRM 4.0 reliant picklists javascript
I am currently working on a CRM 4.0 project where I have created picklist A with 34 values and picklist B with 132 values.

Picklist B is dependent on the value selected in picklist A which range from between 2 and 14 values of the total 132.

Previous developers wrote Javascript which defines each picklist value and sets disabled to true or false, but this is going to be messy with 132 values - see below..

```<code>var picklist = document.getElementById("picklist_b");
if(crmForm.all.picklist_a.value==2)
{
crmForm.SetFieldReqLevel("picklist_b", 2);
picklist[1].disabled = false;
picklist[2].disabled = false;
picklist[3].disabled = false;
picklist[4].disabled = true;
picklist[5].disabled = true;
picklist[6].disabled = true;
</code>```

Do you have any ideas on a better way to do this?

Many Thanks...

答:
Ultimately you will have to tell the system what values you want to appear and when which will take some manual work. To give some structure to your work you could lay it out like this:

1) Register an onChange() event against Picklist A and get its value:

```<code>var picklistA = Xrm.Page.getAttribute("picklistA").getValue();
</code>```

2) Get all of the available options from Picklist B (to save you typing):

```<code>var options = Xrm.Page.getAttribute("picklistB").getOptions();
</code>```

3) Now remove all options from Picklist B:

```<code>var picklistBControl = Xrm.Page.getControl("optionset");
picklistBControl.clearOptions();
</code>```

4) Define the relationship between Picklist A values and Picklist B values (example):

```<code>var mapping = [
    {
        parent: 550000000,
        children: [
            660000000, 660000001
        ]
    },
    {
        parent: 550000001,
        children: [
            660000003, 660000004
        ]
    }
];
</code>```

5) Get the new options that you want by comparing the value of Picklist A against the mapping array:

```<code>function getNewOptionValues(picklistA) {
    var newOptionValues = function (picklistA) {
        return mapping.forEach(function (m) {
            if (m.parent == picklistA) {
                return m.children;
            }
        });
    }(picklistA);

    return newOptionValues;
}
</code>```

6) From the values of the new options you want, build them into valid objects:

```<code>function buildNewOptions(oldOptions, newOptionValues) {
    var newOptions = [];

    for (var option in oldOptions) {
        for (var newOption in newOptionValues) {
            if (option.value == newOption) {
                newOptions.push(option);
            }
        }
    }
    return newOptions;
}
</code>```

7) Finally, add the new options to Picklist B:

```<code>function addNewOptions(newOptions, childControl) {
    for (var newOption in newOptions) {
        childControl.addOption(newOption);
    }
}
</code>```

Some of this code may not work in CRM 4.0, I can't remember. I hope this helps nonetheless. Also note that the functions in points 5, 6 and 7 need to be invoked (if you're not familiar with JavaScript).

Title: CRM 4.0 reliant picklists javascript

Body:
I am currently working on a CRM 4.0 project where I have created picklist A with 34 values and picklist B with 132 values.

Picklist B is dependent on the value selected in picklist A which range from between 2 and 14 values of the total 132.

Previous developers wrote Javascript which defines each picklist value and sets disabled to true or false, but this is going to be messy with 132 values - see below..

var picklist = document.getElementById("picklist_b");
if(crmForm.all.picklist_a.value==2)
{
crmForm.SetFieldReqLevel("picklist_b", 2);
picklist[1].disabled = false;
picklist[2].disabled = false;
picklist[3].disabled = false;
picklist[4].disabled = true;
picklist[5].disabled = true;
picklist[6].disabled = true;

Do you have any ideas on a better way to do this?

Many Thanks...

Body:
Ultimately you will have to tell the system what values you want to appear and when which will take some manual work. To give some structure to your work you could lay it out like this:

1) Register an onChange() event against Picklist A and get its value:

var picklistA = Xrm.Page.getAttribute("picklistA").getValue();

2) Get all of the available options from Picklist B (to save you typing):

var options = Xrm.Page.getAttribute("picklistB").getOptions();

3) Now remove all options from Picklist B:

var picklistBControl = Xrm.Page.getControl("optionset");
picklistBControl.clearOptions();

4) Define the relationship between Picklist A values and Picklist B values (example):

var mapping = [
    {
        parent: 550000000,
        children: [
            660000000, 660000001
        ]
    },
    {
        parent: 550000001,
        children: [
            660000003, 660000004
        ]
    }
];

5) Get the new options that you want by comparing the value of Picklist A against the mapping array:

function getNewOptionValues(picklistA) {
    var newOptionValues = function (picklistA) {
        return mapping.forEach(function (m) {
            if (m.parent == picklistA) {
                return m.children;
            }
        });
    }(picklistA);

    return newOptionValues;
}

6) From the values of the new options you want, build them into valid objects:

function buildNewOptions(oldOptions, newOptionValues) {
    var newOptions = [];

    for (var option in oldOptions) {
        for (var newOption in newOptionValues) {
            if (option.value == newOption) {
                newOptions.push(option);
            }
        }
    }
    return newOptions;
}

7) Finally, add the new options to Picklist B:

function addNewOptions(newOptions, childControl) {
    for (var newOption in newOptions) {
        childControl.addOption(newOption);
    }
}

Some of this code may not work in CRM 4.0, I can't remember. I hope this helps nonetheless. Also note that the functions in points 5, 6 and 7 need to be invoked (if you're not familiar with JavaScript).


问:
Accept decimals numbers with comma and dot
I'm developing a uwp app, where I have a textbox, which I want to accept only decimals, comma or dot (for example: 1.5 or 1.5 or 1.50 or 1.50)
With the value entered in this textbox, and after clicking a button in the app will do an operation:

```<code>double value= Convert.ToDouble(inputBox.Text);
</code>```

InputBox is my textbox where the user enters the numbers.
If I enter for example 1,50 does not give error, and does the operation I want. If I enter 1.50 it gives this error, in this line of code I presented:

```<code>System.FormatException was unhandled by user code
Message=Input string was not in a correct format.
</code>```

答:
You can specify separator(s) (. and ,) manually and try parsing with both formats:

```<code>string source = "123,456"; // "123.456" (with dot) will be accepted as well
double result;

if (double.TryParse(source,
                    NumberStyles.Number, //TODO: you may want to change style
                    new NumberFormatInfo() {
                      NumberDecimalSeparator = ".",
                      NumberGroupSeparator = "" },
                    out result) ||
    double.TryParse(source,
                    NumberStyles.Number, //TODO: you may want to change style
                    new NumberFormatInfo() {
                      NumberDecimalSeparator = ",",
                      NumberGroupSeparator = "" },
                    out result))
{
    // result contains parsed source value
}
else
{
    // source is not a valid double
}
</code>```

Body:
I'm developing a uwp app, where I have a textbox, which I want to accept only decimals, comma or dot (for example: 1.5 or 1.5 or 1.50 or 1.50)
With the value entered in this textbox, and after clicking a button in the app will do an operation:

double value= Convert.ToDouble(inputBox.Text);

InputBox is my textbox where the user enters the numbers.
If I enter for example 1,50 does not give error, and does the operation I want. If I enter 1.50 it gives this error, in this line of code I presented:

System.FormatException was unhandled by user code
Message=Input string was not in a correct format.

Body:
You can specify separator(s) (. and ,) manually and try parsing with both formats:

string source = "123,456"; // "123.456" (with dot) will be accepted as well
double result;

if (double.TryParse(source,
                    NumberStyles.Number, //TODO: you may want to change style
                    new NumberFormatInfo() {
                      NumberDecimalSeparator = ".",
                      NumberGroupSeparator = "" },
                    out result) ||
    double.TryParse(source,
                    NumberStyles.Number, //TODO: you may want to change style
                    new NumberFormatInfo() {
                      NumberDecimalSeparator = ",",
                      NumberGroupSeparator = "" },
                    out result))
{
    // result contains parsed source value
}
else
{
    // source is not a valid double
}


问:
LoadError in Devise (Cannot load bcrypt)
So I'm having issues with creating users with Devise.
It's an issue with "bcrypt".

Here is the error that's being generated

I looked at a few similar threads here and the solution was to install the bcrypt gem for Ruby.
And so I went to rubygems.org and added the line in gem file then ran bundle install.

However, after that I try to run the server but it fails for some reason. Server won't start. Here is the error I received in GitBash:

```<code>Zak@ZAKARIA ~/Desktop/Work/raddit (add_users)
$ rails s
c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependen
cies.rb:293:in `require': cannot load such file -- bcrypt_ext (LoadError)
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_sup
port/dependencies.rb:293:in `block in require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_sup
port/dependencies.rb:259:in `load_dependency'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_sup
port/dependencies.rb:293:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcry
pt.rb:16:in `rescue in <top (required)>'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcry
pt.rb:12:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:91:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:91:in `block (2 levels) in require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:86:in `each'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:86:in `block in require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:75:in `each'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:75:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler.rb:106:
in `require'
        from c:/Users/Zak/Desktop/Work/raddit/config/application.rb:7:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:88:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:88:in `block in server'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:85:in `tap'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:85:in `server'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:49:in `run_command!'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands.
rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
</code>```

NOTE: Before adding the gem, the server would run just fine.

Also here is my gem file

```<code>gem 'rails', '~> 5.0.2'
gem 'sqlite3'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'devise', '~> 4.2', '>= 4.2.1'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1', '>= 3.1.11'

group :development, :test do
   gem 'byebug', platform: :mri
end

group :development do
  gem 'web-console', '>= 3.3.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
</code>```

答: I don't think you need to set the explicitly bcrypt in your Gemfile. Devise already includes bcrypt as a runtime dependency. Try to remove the bcrypt gem from your Gemfile, run bundle update and the restart your server. That worked for me.

Body:
So I'm having issues with creating users with Devise.
It's an issue with "bcrypt".

Here is the error that's being generated

I looked at a few similar threads here and the solution was to install the bcrypt gem for Ruby.
And so I went to rubygems.org and added the line in gem file then ran bundle install.

However, after that I try to run the server but it fails for some reason. Server won't start. Here is the error I received in GitBash:

Zak@ZAKARIA ~/Desktop/Work/raddit (add_users)
$ rails s
c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependen
cies.rb:293:in `require': cannot load such file -- bcrypt_ext (LoadError)
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_sup
port/dependencies.rb:293:in `block in require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_sup
port/dependencies.rb:259:in `load_dependency'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.2/lib/active_sup
port/dependencies.rb:293:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcry
pt.rb:16:in `rescue in <top (required)>'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcry
pt.rb:12:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:91:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:91:in `block (2 levels) in require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:86:in `each'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:86:in `block in require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:75:in `each'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/runtime
.rb:75:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler.rb:106:
in `require'
        from c:/Users/Zak/Desktop/Work/raddit/config/application.rb:7:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:88:in `require'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:88:in `block in server'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:85:in `tap'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:85:in `server'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands/
commands_tasks.rb:49:in `run_command!'
        from c:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/commands.
rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `'

NOTE: Before adding the gem, the server would run just fine.

Also here is my gem file

gem 'rails', '~> 5.0.2'
gem 'sqlite3'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'devise', '~> 4.2', '>= 4.2.1'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1', '>= 3.1.11'

group :development, :test do
   gem 'byebug', platform: :mri
end

group :development do
  gem 'web-console', '>= 3.3.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]


问:
Program is not execute in python 2.7.3 { RESTART: C:/Python27/kushagra.py}
Whenever I write a program in python it shows an error in idle. A python 2.7.3 error.
 program is given below:

```<code>import turtle
def draw_square():

window = turtle.Screen()

window.bgcolor("red")

brad = turtle.Turtle()
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)

window.exitonclick()

draw_square()
</code>```

the error is given below:

```<code>RESTART: C:/Python27/kushagra.py
</code>```

答:
If your code is indented like this:

```<code>import turtle
def draw_square():

    window = turtle.Screen()

    window.bgcolor("red")

    brad = turtle.Turtle()
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)

    window.exitonclick()

    draw_square()
</code>```

... Then executing this program in IDLE will give you this output:

```<code>Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
================== RESTART: C:\Users\Kevin\Desktop\test.py ==================
>>>
</code>```

Because no code is actually running. draw_square() never gets called because it's indented inside the draw_square definition. Un-indent it so it's at the file-level scope instead.

```<code>import turtle
def draw_square():

    window = turtle.Screen()

    window.bgcolor("red")

    brad = turtle.Turtle()
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)

    window.exitonclick()

draw_square()
</code>```

Now you should get the turtle window you desire.

Body:
Whenever I write a program in python it shows an error in idle. A python 2.7.3 error.
 program is given below:

import turtle
def draw_square():

window = turtle.Screen()

window.bgcolor("red")

brad = turtle.Turtle()
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)

window.exitonclick()

draw_square()

the error is given below:

RESTART: C:/Python27/kushagra.py

Body:
If your code is indented like this:

import turtle
def draw_square():

    window = turtle.Screen()

    window.bgcolor("red")

    brad = turtle.Turtle()
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)

    window.exitonclick()

    draw_square()

... Then executing this program in IDLE will give you this output:

Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
================== RESTART: C:\Users\Kevin\Desktop\test.py ==================
>>>

Because no code is actually running. draw_square() never gets called because it's indented inside the draw_square definition. Un-indent it so it's at the file-level scope instead.

import turtle
def draw_square():

    window = turtle.Screen()

    window.bgcolor("red")

    brad = turtle.Turtle()
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)
    brad.forward(100)
    brad.right(90)

    window.exitonclick()

draw_square()

Now you should get the turtle window you desire.


问:
How to create a notification bar on top of a windows form application?
I am planning to create stackoverflow like top notification banner for my desktop, windows form application how can I create?I'm new to .Net world, help me proceed.</p>

答:
One way is to put a SplitContainer in your form, Dock==Fill, Orientation==Horizontal.

Put your notification in the top panel and the rest in the bottom panel.

Use the Panel1Collapsed property to toggle your notification on and off.


问:
React native : Is there any way to redirect the initial route to another page
I'm new in react native and currently developing a react-native app that require login. After successful login, the view change into Homepage. The problem is after i close and re-open the app, it shows me LoginPage again.Is there any way to redirect the initial route to another page

```<code> class Main extends Component {

  _renderScene(route, navigator) {
      if (route.id === 1) {
        return <LoginPage navigator={navigator} />
      } else if (route.id === 2) {
        return <HomePage navigator={navigator} />
      } else if (route.id === 3) {
        return <DetailPage navigator={navigator} />
      }  else if (route.id === 4) {
        return <CreateBookingPage navigator={navigator} />
      }
  }

  _configureScene(route) {
    return Navigator.SceneConfigs.PushFromRight;
  }

  render() {
      return (
        <Navigator
        initialRoute={{id: 1, }}
        renderScene={this._renderScene}
        configureScene={ () => { return Navigator.SceneConfigs.PushFromRight; }} />
      );
  }
}
</code>```

/////after some changes I get into this but still its rendering the login is I done something wrong////////

```<code>   componentWillMount() {
    AsyncStorage.getItem('key').then( (value) => {
        if(value==="yes") {
            this.setState({ loader: false, logged: true})
        } else {
            this.setState({ loader: false })
        }
    })
}

render() {
    const routeId = this.state.logged ? 2 : 1;
    if(this.state.loader) {
        return (
            <View /> // loading screen
        );
    }
    return (
        <Navigator
            initialRoute={{id: routeId }}
            renderScene={this._renderScene}
            configureScene={ () => { return Navigator.SceneConfigs.PushFromRight; }} />
    );
}
</code>```

答:
Replace with your render function and try it.</p>

```<code>  render() {
    var loggedStatus = true; // change here for login screen
    var routeId = loggedStatus ? 2 : 1;
    return (
      <Navigator
      initialRoute={{id: routeId }}
      renderScene={this._renderScene}
      configureScene={ () => { return Navigator.SceneConfigs.PushFromRight; }} />
    );
 }
</code>```

Body:
I'm new in react native and currently developing a react-native app that require login. After successful login, the view change into Homepage. The problem is after i close and re-open the app, it shows me LoginPage again.Is there any way to redirect the initial route to another page

 class Main extends Component {

  _renderScene(route, navigator) {
      if (route.id === 1) {
        return <LoginPage navigator={navigator} />
      } else if (route.id === 2) {
        return <HomePage navigator={navigator} />
      } else if (route.id === 3) {
        return <DetailPage navigator={navigator} />
      }  else if (route.id === 4) {
        return <CreateBookingPage navigator={navigator} />
      }
  }

  _configureScene(route) {
    return Navigator.SceneConfigs.PushFromRight;
  }

  render() {
      return (
        <Navigator
        initialRoute={{id: 1, }}
        renderScene={this._renderScene}
        configureScene={ () => { return Navigator.SceneConfigs.PushFromRight; }} />
      );
  }
}

/////after some changes I get into this but still its rendering the login is I done something wrong////////

   componentWillMount() {
    AsyncStorage.getItem('key').then( (value) => {
        if(value==="yes") {
            this.setState({ loader: false, logged: true})
        } else {
            this.setState({ loader: false })
        }
    })
}

render() {
    const routeId = this.state.logged ? 2 : 1;
    if(this.state.loader) {
        return (
            <View /> // loading screen
        );
    }
    return (
        <Navigator
            initialRoute={{id: routeId }}
            renderScene={this._renderScene}
            configureScene={ () => { return Navigator.SceneConfigs.PushFromRight; }} />
    );
}

Body:
Replace with your render function and try it.

  render() {
    var loggedStatus = true; // change here for login screen
    var routeId = loggedStatus ? 2 : 1;
    return (
      <Navigator
      initialRoute={{id: routeId }}
      renderScene={this._renderScene}
      configureScene={ () => { return Navigator.SceneConfigs.PushFromRight; }} />
    );
 }


问:
Crash when adding Firebase for Google Ads in gradle
I am trying to add in an older project google ads banner, but when I add to the Grandle the Firebase and run the app it crashes:

This is my gradle:

```<code>apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion '25.0.2'

defaultConfig {
    applicationId "com...."
    minSdkVersion 15
    targetSdkVersion 22
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile files('libs/pinch-0.8.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/twitter4j-async-3.0.3.jar')
compile files('libs/twitter4j-core-3.0.3.jar')
compile files('libs/twitter4j-examples-3.0.3.jar')
}
apply plugin: 'com.google.gms.google-services'
</code>```

and this is the error message

The first version of the project was developed with Eclipse.

答:
do not forget to add main firebase project :

compile 'com.google.firebase:firebase-core:10.2.0'

ContentLicense: CC BY-SA 4.0

Body:
I am trying to add in an older project google ads banner, but when I add to the Grandle the Firebase and run the app it crashes:

This is my gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion '25.0.2'

defaultConfig {
    applicationId "com...."
    minSdkVersion 15
    targetSdkVersion 22
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile files('libs/pinch-0.8.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/twitter4j-async-3.0.3.jar')
compile files('libs/twitter4j-core-3.0.3.jar')
compile files('libs/twitter4j-examples-3.0.3.jar')
}
apply plugin: 'com.google.gms.google-services'

and this is the error message

The first version of the project was developed with Eclipse.


问:
Exception raised during rendering: Could not find layout resource matching value 0x7F04001B (resolved name: content_main) in current configuration
Getting this exception when I created a new project with a new Activity.

Exception raised during rendering: Could not find layout resource matching value 0x7F04001B (resolved name: content_main) in current configuration.

When I go into the content_main, I do see a proper image and no rendering problems.

答:
Here is another way to get rid of this error.

Go to the Project folder where the XML file resides, (in the case of OP's question, this would be the content_main.xml file).

Rename the file to anything else such as ren_content_main.xml.

Rebuild the project. The compiler will complain that ren_content_main.xml resource does not exist. Ignore these errors.

Rename the file back to the original name i.e content_main.xml.

Rebuild the project again.

Watch the error disappear like magic.


问:
I cannot get jQuery to work in wordpress
Tried many different techniques to get jquery working in my custom wordpress theme but still haven't got anywhere.

I've included two different methods that I've tried below near the end of the code, with one commented out here.

Can anyone see why this code might not be working?

PHP:

```<code><?php

function wpb_custom_new_menu() {
    register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
}

add_action( 'init', 'wpb_custom_new_menu' );

function enqueue_stylesheets() {
    wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css');
    wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Montserrat:400,600,700|Raleway:400,500,600,700');
    wp_enqueue_style( 'fontAwesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );
}

/*function wp_enqeue_scripts() {
    wp_register_script('navbarScroll', home_url() . '/js/navbarScroll.js', array( 'jquery' ));
    wp_enqueue_script('navbarScroll');
    //wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js', array('jquery'), '3.3.4', true );
}*/

function navbar_script() {
    wp_register_script( 'jquery.navbarScroll', get_template_directory_uri() . '/js/jquery.navbarScroll.js', array( 'jquery' ) );
    wp_enqueue_script( 'jquery.navbarScroll' );
}

add_action('wp_enqueue_scripts', 'enqueue_stylesheets', 'enqueue_scripts', 'navbar_script');
</code>```

My Test JS (I've used both $ and jquery):

```<code>jquery(document).ready(function() {

jquery('#jQueryTest').html('jQuery is Working');

jQuery('nav').hover(function() {
    $(this).css('display', 'none');
})

/*var a = $('nav').offset().top;

$(document).scroll(function() {
    if ($(this).scrollTop() > a)
    {
       $(this).removeClass('nav');
       $(this).addClass('nav-scrolled');
    } else {
       $(this).removeClass('nav-scrolled');
    }
});*/

});
</code>```

答:
Well it seems that you have too many parameters in your add_action function.

The add_action should have only 4 arguments as follows:

```<code>add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
</code>```

See WordPress documentation for more information.

That's what should be working just fine:

```<code>function enqueueScript() {

wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css');
wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Montserrat:400,600,700|Raleway:400,500,600,700');
wp_enqueue_style( 'fontAwesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );

wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js', array('jquery'), '3.3.4', true );
wp_register_script('navbarScroll', get_stylesheet_directory_uri() . '/js/navbarScroll.js', array( 'jquery' ), '', true );
wp_enqueue_script('navbarScroll');
wp_register_script( 'jquery.navbarScroll', get_template_directory_uri() . '/js/jquery.navbarScroll.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'jquery.navbarScroll' );
}

add_action( 'wp_enqueue_scripts', 'enqueueScript' );
</code>```

Note that it is not necessary to enqueue style and script separately. One method can do both by using wp_enqueue_scripts.

If you really want to separate your style and script in different function, you should call add_action this way:

```<code>add_action('wp_enqueue_scripts','wp_enqueue_scripts');
add_action( 'wp_enqueue_scripts','enqueue_stylesheets');
add_action( 'wp_enqueue_scripts','enqueue_scripts');
add_action( 'wp_enqueue_scripts','navbar_script');
</code>```

If you want to load jQuery, add it to your function:

```<code>wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array(), null, true);
</code>```

Body:
Tried many different techniques to get jquery working in my custom wordpress theme but still haven't got anywhere.

I've included two different methods that I've tried below near the end of the code, with one commented out here.

Can anyone see why this code might not be working?

PHP:

<?php

function wpb_custom_new_menu() {
    register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
}

add_action( 'init', 'wpb_custom_new_menu' );

function enqueue_stylesheets() {
    wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css');
    wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Montserrat:400,600,700|Raleway:400,500,600,700');
    wp_enqueue_style( 'fontAwesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );
}

/*function wp_enqeue_scripts() {
    wp_register_script('navbarScroll', home_url() . '/js/navbarScroll.js', array( 'jquery' ));
    wp_enqueue_script('navbarScroll');
    //wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js', array('jquery'), '3.3.4', true );
}*/

function navbar_script() {
    wp_register_script( 'jquery.navbarScroll', get_template_directory_uri() . '/js/jquery.navbarScroll.js', array( 'jquery' ) );
    wp_enqueue_script( 'jquery.navbarScroll' );
}

add_action('wp_enqueue_scripts', 'enqueue_stylesheets', 'enqueue_scripts', 'navbar_script');

My Test JS (I've used both $ and jquery):

jquery(document).ready(function() {

jquery('#jQueryTest').html('jQuery is Working');

jQuery('nav').hover(function() {
    $(this).css('display', 'none');
})

/*var a = $('nav').offset().top;

$(document).scroll(function() {
    if ($(this).scrollTop() > a)
    {
       $(this).removeClass('nav');
       $(this).addClass('nav-scrolled');
    } else {
       $(this).removeClass('nav-scrolled');
    }
});*/

});

Body:
Well it seems that you have too many parameters in your add_action function.

The add_action should have only 4 arguments as follows:

add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )

See WordPress documentation for more information.

That's what should be working just fine:

function enqueueScript() {

wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css');
wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Montserrat:400,600,700|Raleway:400,500,600,700');
wp_enqueue_style( 'fontAwesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );

wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js', array('jquery'), '3.3.4', true );
wp_register_script('navbarScroll', get_stylesheet_directory_uri() . '/js/navbarScroll.js', array( 'jquery' ), '', true );
wp_enqueue_script('navbarScroll');
wp_register_script( 'jquery.navbarScroll', get_template_directory_uri() . '/js/jquery.navbarScroll.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'jquery.navbarScroll' );
}

add_action( 'wp_enqueue_scripts', 'enqueueScript' );

Note that it is not necessary to enqueue style and script separately. One method can do both by using wp_enqueue_scripts.

If you really want to separate your style and script in different function, you should call add_action this way:

add_action('wp_enqueue_scripts','wp_enqueue_scripts');
add_action( 'wp_enqueue_scripts','enqueue_stylesheets');
add_action( 'wp_enqueue_scripts','enqueue_scripts');
add_action( 'wp_enqueue_scripts','navbar_script');

If you want to load jQuery, add it to your function:

wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array(), null, true);


问:
How to get a distribution app when using xcodebuild -exportArchive (Xcode8.3, Auto Signing)?
After update Xcode8.3, the options '-exportSigningIdentity', '-exportProvisioningProfile' and '-exportFormat' are removed from  'xcodebuild -exportArchive'.

When i try to get a distribution app, i get the error below:
 xcodebuild: error: invalid option '-exportProvisioningProfile'.

So how can i get distribution MyApp.ipa from MyApp.xcarchive, when the project has set Automatic Signing Enabled?

Automatic Signing

答:
When you set Automatic Signing Enabled Xcode will automatically generate according provisioning profile.

But in order to make your command working you need to manually export the archive the first time.
Once it is done, Xcode will generate the provisioning profile (it starts by "XC" in the Apple Developer website).

Then your xcodebuild command will work.

Product -> Archive

Once it's done

Windows -> Organizer -> Select the last version -> Export (right pannel under Upload to App Store)

Keep me inform if you need additional informations.


问:
I need to input a value, and extract information of an object
I need to be able to input a random value, search through a list of objects in a class, and find the one with an ID that matches the random value. To make things more complicated, I also have to extract all information I can on that item.

I have the random input:

```<code>firstCard = Random.Range (1, 18);
</code>```

Then I have the cards:

```<code>public class Card {
    public int CardID;
    public string element;
    public int value;
    public string color;

    public Card (int cardids, string elementals, int values, string coloring) {
        this.CardID = cardids;
        this.element = elementals;
        this.value = values;
        this.color = coloring;
    }
}

public class CardList : MonoBehaviour {
    public Card a = new Card(1, "Fire", 3, "Blue");
    //Other cards appear here.
}
</code>```

So if the random number returns 1, I want it to retun "Fire", 3, and "Blue" because the CardID matches the random number. These two groups of code are in two different files, if that changes anything.

答:
"search through a list of objects in a class," doesn't look like you're creating a list, but define each card as field/property.

You should create a real list of cards:

```<code>var cards = new List<Card>();

// add the cards...
cards.Add(new Card(1, "Fire", 3, "Blue"));
cards.Add(new Card(2, "Water", 4, "Red"));
</code>```

To search for a card:

```<code>var random = new Random(); // do this ones...

//   <snip>

// generate a random id
int cardId = random.Next(1, 18);

// search for it
// if it isn't found (none matched the id) it will return null
var foundCard = cards.FirstOrDefault(card => card.CardID == cardId);

// is it found?
if (foundCard != null)
{
    // card is found.
    MessageBox.Show($"The card is of element {foundCard.element}");
}
else
{
    // card is NOT found.
    MessageBox.Show("Too bad, the card is not found");
}
</code>```

Next chapter: Dictionaries

Body:
I need to be able to input a random value, search through a list of objects in a class, and find the one with an ID that matches the random value. To make things more complicated, I also have to extract all information I can on that item.

I have the random input:

firstCard = Random.Range (1, 18);

Then I have the cards:

public class Card {
    public int CardID;
    public string element;
    public int value;
    public string color;

    public Card (int cardids, string elementals, int values, string coloring) {
        this.CardID = cardids;
        this.element = elementals;
        this.value = values;
        this.color = coloring;
    }
}

public class CardList : MonoBehaviour {
    public Card a = new Card(1, "Fire", 3, "Blue");
    //Other cards appear here.
}

So if the random number returns 1, I want it to retun "Fire", 3, and "Blue" because the CardID matches the random number. These two groups of code are in two different files, if that changes anything.

Body:
"search through a list of objects in a class," doesn't look like you're creating a list, but define each card as field/property.

You should create a real list of cards:

var cards = new List<Card>();

// add the cards...
cards.Add(new Card(1, "Fire", 3, "Blue"));
cards.Add(new Card(2, "Water", 4, "Red"));

To search for a card:

var random = new Random(); // do this ones...

//   <snip>

// generate a random id
int cardId = random.Next(1, 18);

// search for it
// if it isn't found (none matched the id) it will return null
var foundCard = cards.FirstOrDefault(card => card.CardID == cardId);

// is it found?
if (foundCard != null)
{
    // card is found.
    MessageBox.Show($"The card is of element {foundCard.element}");
}
else
{
    // card is NOT found.
    MessageBox.Show("Too bad, the card is not found");
}

Next chapter: Dictionaries


问:
Log4net doesn't write to file during MSBuild
What I want to do is to log some events from xunit test with log4net.

Everything works fine when I run test manually from Visual Studio, but when I run them in MSBuild, nothing is logged. I have already checked if the config file for test.dll is missing, but that was not the case. What else could be the reason for this strange behavior?

答:
There are a few things you can check:

is your log4net.config file copied to the directory where the tests are executed

is the filename where you try to log relative to the path you are running msbuild? And do you have access to that file? Make it an absolute path to be sure.

is the a configure attribute in the dll you try to test? Point it to the right configutation file


问:
easiest way to implement a shift register in python
I want to implement a data structure similar to a shift register, basically a shift register should have a fixed length (L) and should have a function to mange the input to this register (New_Input), the new input will be in the first cell of the shift register and the previous element will be shifted one cell forward. When the register is full and a new element is added it will shift all the element such that the element in the last cell will be thrown (out of our concern).

My idea to implement such things is by using a dictionary that contain those element such that the keys are the order of this dictionary.

Can any one help me?

答:
Python already contains this data structure as collections.deque:

```<code>>>> import collections
>>> c = collections.deque([], 2)
>>> c.extend('a')
>>> c.extend('b')
>>> c.extend('c')
>>> c
deque(['b', 'c'], maxlen=2)
</code>```

Body:
Python already contains this data structure as collections.deque:

>>> import collections
>>> c = collections.deque([], 2)
>>> c.extend('a')
>>> c.extend('b')
>>> c.extend('c')
>>> c
deque(['b', 'c'], maxlen=2)


问:
How can I create a text box for a note in markdown?
I am writing a document in markdown. I am using the wonderful pandoc to create docx and tex files from the markdown source. I would like to have a textbox for tips and notes to readers the way programming books often do. I cannot figure out how to do this in markdown. Can you help?</p>

答:
With GitHub, I usually insert a blockquote.

```<code>> **_NOTE:_**  The note content.
</code>```

becomes...

NOTE:  The note content.

Of course, there is always plain HTML...

Body:
With GitHub, I usually insert a blockquote.

> **_NOTE:_**  The note content.

becomes...

NOTE:  The note content.

Of course, there is always plain HTML...


问:
Display titles which are missing association values partially or completely
I am having problem writing SQL query for the following scenario. I need someone's help to write the query.

I have the following tables 7 tables:

1) Titles

```<code>ID    Title                                                        Author
-------------------------------------------------------------------------
1     The Hidden Language of Computer Hardware and Software   Charles Petzold
2     Paths, Dangers, Strategies                              Nick Bostrom
3     The Smart Girl's Guide to Privacy                       Violet Blue
4     Introduction to Algorithms                              Thomas H. Cormen
5     Machine Learning in Action                              Peter Harrington
...
</code>```

2) Themes

```<code>ID         Name
------------------------------------------
1          Science Fiction
2          Biography
3          Painting
...
</code>```

3)   Subjects

```<code>ID           Name
-----------------------------------
1            Science
2            Technology
3            Music
4            Geography
...
</code>```

4)  Grades

```<code>ID            Name
------------------------------------
1             Grade 1
2             Grade 2
3             Grade 3
4             Grade 4
5             Grade 5
...
</code>```

5) TitleThemeAssociation

```<code>TitleID         ThemeID
------------------------------------------
1               1
1               3
4               2
4               3
...
</code>```

6) TitleSubjectAssociaton

```<code>TitleID          SubjectID
---------------------------------
1                1
1                3
2                1
2                3
4                1
4                2
...
</code>```

7) TitleGradeAssociaton

```<code>TitleID              GradeID
1                    1
1                    2
1                    3
2                    1
2                    2
...
</code>```

I need to write a query to display only titles which are missing any of three values (Themes, Subjects and Grades) or not assigned values completely. I should not display the title if all three values (Themes, Subjects, Grades) are assigned. In the above data set since TitleID 1 has all three values it should not be present in the list. TitleID 2 has only Subjects and Grades assigned but not Themes so it should be displayed in the output. While listing the titles if a title has multiple values then they should be contacted with comma (,) separator.

So the final output of the above data set should be as below:

Output:

```<code>Title ID      Title                      Theme        Subject           Grade
-------------------------------------------------------------------------------------------
2      Paths, Dangers, Strategies          -          Science, Music    Grade 1, Grade 2
3      The Smart Girl's Guide to Privacy   -           -                   -
4      Introduction to Algorithms         Biography, Painting    Science, Technology    -
5      Machine Learning in Action          -              -              -
</code>```

答:
There are essentially two questions you're asking.  The first being how to filter when either a Theme, Subject or Grade is missing.  And the other is asking how to concat these items into a comma separated list.

The following query should be what you're looking for:

```<code>Select  Distinct
        T.Id As [Title ID],
        T.Title,
        H.Theme,
        S.Subject,
        G.Grade
From    Titles  T
Outer Apply
(
    Select  Stuff(( Select ', ' + Name
                    From    Themes                  H
                    Join    TitleThemeAssociation   TH  On  H.Id = TH.ThemeId
                    Where   TH.TitleId = T.Id
                    For Xml Path('')), 1, 2, '') As Theme
    From    Themes
) H
Outer Apply
(
    Select  Stuff(( Select ', ' + Name
                    From    Subjects                S
                    Join    TitleSubjectAssociaton  TS  On  S.Id = TS.SubjectId
                    Where   TS.TitleId = T.Id
                    For Xml Path('')), 1, 2, '') As Subject
    From    Subjects
) S
Outer Apply
(
    Select  Stuff(( Select ', ' + Name
                    From    Grades                  G
                    Join    TitleGradeAssociaton    TG  On  G.Id = TG.GradeId
                    Where   TG.TitleId = T.Id
                    For Xml Path('')), 1, 2, '') As Grade
    From    Grades
) G
Where   H.Theme Is Null
Or      S.Subject Is Null
Or      G.Grade Is Null
</code>```

Body:
I am having problem writing SQL query for the following scenario. I need someone's help to write the query.

I have the following tables 7 tables:

1) Titles

ID    Title                                                        Author
-------------------------------------------------------------------------
1     The Hidden Language of Computer Hardware and Software   Charles Petzold
2     Paths, Dangers, Strategies                              Nick Bostrom
3     The Smart Girl's Guide to Privacy                       Violet Blue
4     Introduction to Algorithms                              Thomas H. Cormen
5     Machine Learning in Action                              Peter Harrington
...

2) Themes

ID         Name
------------------------------------------
1          Science Fiction
2          Biography
3          Painting
...

3)   Subjects

ID           Name
-----------------------------------
1            Science
2            Technology
3            Music
4            Geography
...

4)  Grades

ID            Name
------------------------------------
1             Grade 1
2             Grade 2
3             Grade 3
4             Grade 4
5             Grade 5
...

5) TitleThemeAssociation

TitleID         ThemeID
------------------------------------------
1               1
1               3
4               2
4               3
...

6) TitleSubjectAssociaton

TitleID          SubjectID
---------------------------------
1                1
1                3
2                1
2                3
4                1
4                2
...

7) TitleGradeAssociaton

TitleID              GradeID
1                    1
1                    2
1                    3
2                    1
2                    2
...

I need to write a query to display only titles which are missing any of three values (Themes, Subjects and Grades) or not assigned values completely. I should not display the title if all three values (Themes, Subjects, Grades) are assigned. In the above data set since TitleID 1 has all three values it should not be present in the list. TitleID 2 has only Subjects and Grades assigned but not Themes so it should be displayed in the output. While listing the titles if a title has multiple values then they should be contacted with comma (,) separator.

So the final output of the above data set should be as below:

Output:

Title ID      Title                      Theme        Subject           Grade
-------------------------------------------------------------------------------------------
2      Paths, Dangers, Strategies          -          Science, Music    Grade 1, Grade 2
3      The Smart Girl's Guide to Privacy   -           -                   -
4      Introduction to Algorithms         Biography, Painting    Science, Technology    -
5      Machine Learning in Action          -              -              -

Body:
There are essentially two questions you're asking.  The first being how to filter when either a Theme, Subject or Grade is missing.  And the other is asking how to concat these items into a comma separated list.

The following query should be what you're looking for:

Select  Distinct
        T.Id As [Title ID],
        T.Title,
        H.Theme,
        S.Subject,
        G.Grade
From    Titles  T
Outer Apply
(
    Select  Stuff(( Select ', ' + Name
                    From    Themes                  H
                    Join    TitleThemeAssociation   TH  On  H.Id = TH.ThemeId
                    Where   TH.TitleId = T.Id
                    For Xml Path('')), 1, 2, '') As Theme
    From    Themes
) H
Outer Apply
(
    Select  Stuff(( Select ', ' + Name
                    From    Subjects                S
                    Join    TitleSubjectAssociaton  TS  On  S.Id = TS.SubjectId
                    Where   TS.TitleId = T.Id
                    For Xml Path('')), 1, 2, '') As Subject
    From    Subjects
) S
Outer Apply
(
    Select  Stuff(( Select ', ' + Name
                    From    Grades                  G
                    Join    TitleGradeAssociaton    TG  On  G.Id = TG.GradeId
                    Where   TG.TitleId = T.Id
                    For Xml Path('')), 1, 2, '') As Grade
    From    Grades
) G
Where   H.Theme Is Null
Or      S.Subject Is Null
Or      G.Grade Is Null


问:
Add extra node XML
I'm extracting some data using FOR XML PATH. However, I'm not able to get a node.
Expected result:

```<code><Users>
  <User UserId="1">
   <Profile>
     <PersonalDetails>
        <FirstName>Name1</FirstName>
        <LastName>Last1</LastName>
     </PersonalDetails>
     <Reward>0</Reward>
   </Profile>
 </User>
 <User UserId="2">
    <Profile>
      <PersonalDetails>
          <FirstName>Name2</FirstName>
          <LastName>Last2</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
    </Profile>
 </User>
 <User UserId="3">
   <Profile>
      <PersonalDetails>
        <FirstName>Name3</FirstName>
        <LastName>Last3</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
   </Profile>
 </User>
 <User UserId="4">
   <Profile>
    <PersonalDetails>
        <FirstName>Name4</FirstName>
        <LastName>Last4</LastName>
    </PersonalDetails>
    <Reward>0</Reward>
   </Profile>
 </User>
</Users>
</code>```

Let me show you with this example:

```<code>DECLARE @User TABLE ( ID INT
                 ,FirstName VARCHAR(20)
                 ,LastName VARCHAR(20)
                 ,Reward BIT
                 )

INSERT INTO @User (ID, FirstName, LastName, Reward )
VALUES (1, 'Name1', 'Last1', 0)
      ,(2, 'Name2', 'Last2', 0)
      ,(3, 'Name3', 'Last3', 0)
      ,(4, 'Name4', 'Last4', 0)

    SELECT ID AS '@UserId'
            ,( SELECT FirstName AS 'FirstName'
                     ,LastName AS 'LastName'
               FROM @User
               WHERE ID = users.ID
               FOR XML PATH('PersonalDetails'), TYPE)
           ,Reward AS 'Reward'
    FROM @User AS users
    FOR XML PATH('User'), ROOT('Users'), ELEMENTS
</code>```

This is what I've got so far:

```<code> <Users>
<User UserId="1">
   <PersonalDetails>
      <FirstName>Name1</FirstName>
      <LastName>Last1</LastName>
   </PersonalDetails>
   <Reward>0</Reward>
</User>
</User>
   <User UserId="2">
     <PersonalDetails>
       <FirstName>Name2</FirstName>
       <LastName>Last2</LastName>
     </PersonalDetails>
     <Reward>0</Reward>
   </User>
   <User UserId="3">
      <PersonalDetails>
         <FirstName>Name3</FirstName>
         <LastName>Last3</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
   </User>
   <User UserId="4">
     <PersonalDetails>
       <FirstName>Name4</FirstName>
       <LastName>Last4</LastName>
     </PersonalDetails>
     <Reward>0</Reward>
   </User>
 </Users>
</code>```

I'm not able to add that extra Profile element.
I've tried using the modify('insert   as first into (/Users/User)[1]') but the output is not as expeted either.
Can you help me with this please?

答:
Your data seems to be plain 1:1 internally: nested, but not 1:n. This does not need a subselect. With FOR XML PATH you can specify your nestings directly:

```<code>DECLARE @User TABLE ( ID INT
                 ,FirstName VARCHAR(20)
                 ,LastName VARCHAR(20)
                 ,Reward BIT
                 )

INSERT INTO @User (ID, FirstName, LastName, Reward )
VALUES (1, 'Name1', 'Last1', 0)
      ,(2, 'Name2', 'Last2', 0);

SELECT ID AS [@UserId]
      ,FirstName AS [Profile/PersonalDetails/FirstName]
      ,LastName AS [Profile/PersonalDetails/LastName]
      ,Reward AS [Profile/Reward]
FROM @User AS u
FOR XML PATH('User'),ROOT('Users')
</code>```

The result

```<code><Users>
  <User UserId="1">
    <Profile>
      <PersonalDetails>
        <FirstName>Name1</FirstName>
        <LastName>Last1</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
    </Profile>
  </User>
  <User UserId="2">
    <Profile>
      <PersonalDetails>
        <FirstName>Name2</FirstName>
        <LastName>Last2</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
    </Profile>
  </User>
</Users>
</code>```

Title: Add extra node XML

Body:
I'm extracting some data using FOR XML PATH. However, I'm not able to get a node.
Expected result:

<Users>
  <User UserId="1">
   <Profile>
     <PersonalDetails>
        <FirstName>Name1</FirstName>
        <LastName>Last1</LastName>
     </PersonalDetails>
     <Reward>0</Reward>
   </Profile>
 </User>
 <User UserId="2">
    <Profile>
      <PersonalDetails>
          <FirstName>Name2</FirstName>
          <LastName>Last2</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
    </Profile>
 </User>
 <User UserId="3">
   <Profile>
      <PersonalDetails>
        <FirstName>Name3</FirstName>
        <LastName>Last3</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
   </Profile>
 </User>
 <User UserId="4">
   <Profile>
    <PersonalDetails>
        <FirstName>Name4</FirstName>
        <LastName>Last4</LastName>
    </PersonalDetails>
    <Reward>0</Reward>
   </Profile>
 </User>
</Users>

Let me show you with this example:

DECLARE @User TABLE ( ID INT
                 ,FirstName VARCHAR(20)
                 ,LastName VARCHAR(20)
                 ,Reward BIT
                 )

INSERT INTO @User (ID, FirstName, LastName, Reward )
VALUES (1, 'Name1', 'Last1', 0)
      ,(2, 'Name2', 'Last2', 0)
      ,(3, 'Name3', 'Last3', 0)
      ,(4, 'Name4', 'Last4', 0)

    SELECT ID AS '@UserId'
            ,( SELECT FirstName AS 'FirstName'
                     ,LastName AS 'LastName'
               FROM @User
               WHERE ID = users.ID
               FOR XML PATH('PersonalDetails'), TYPE)
           ,Reward AS 'Reward'
    FROM @User AS users
    FOR XML PATH('User'), ROOT('Users'), ELEMENTS

This is what I've got so far:

 <Users>
<User UserId="1">
   <PersonalDetails>
      <FirstName>Name1</FirstName>
      <LastName>Last1</LastName>
   </PersonalDetails>
   <Reward>0</Reward>
</User>
</User>
   <User UserId="2">
     <PersonalDetails>
       <FirstName>Name2</FirstName>
       <LastName>Last2</LastName>
     </PersonalDetails>
     <Reward>0</Reward>
   </User>
   <User UserId="3">
      <PersonalDetails>
         <FirstName>Name3</FirstName>
         <LastName>Last3</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
   </User>
   <User UserId="4">
     <PersonalDetails>
       <FirstName>Name4</FirstName>
       <LastName>Last4</LastName>
     </PersonalDetails>
     <Reward>0</Reward>
   </User>
 </Users>

I'm not able to add that extra Profile element.
I've tried using the modify('insert   as first into (/Users/User)[1]') but the output is not as expeted either.
Can you help me with this please?

Body:
Your data seems to be plain 1:1 internally: nested, but not 1:n. This does not need a subselect. With FOR XML PATH you can specify your nestings directly:

DECLARE @User TABLE ( ID INT
                 ,FirstName VARCHAR(20)
                 ,LastName VARCHAR(20)
                 ,Reward BIT
                 )

INSERT INTO @User (ID, FirstName, LastName, Reward )
VALUES (1, 'Name1', 'Last1', 0)
      ,(2, 'Name2', 'Last2', 0);

SELECT ID AS [@UserId]
      ,FirstName AS [Profile/PersonalDetails/FirstName]
      ,LastName AS [Profile/PersonalDetails/LastName]
      ,Reward AS [Profile/Reward]
FROM @User AS u
FOR XML PATH('User'),ROOT('Users')

The result

<Users>
  <User UserId="1">
    <Profile>
      <PersonalDetails>
        <FirstName>Name1</FirstName>
        <LastName>Last1</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
    </Profile>
  </User>
  <User UserId="2">
    <Profile>
      <PersonalDetails>
        <FirstName>Name2</FirstName>
        <LastName>Last2</LastName>
      </PersonalDetails>
      <Reward>0</Reward>
    </Profile>
  </User>
</Users>


问:
Dynamically add cells to table rows and dynamically create table rows with reactjs
I'm building a tbody dynamically in reactjs. I have a function that creates seed data from a loop with this:

```<code>accounts.push(
  <tr key={i}>
  <td>{obj.type}</td>
  <td>{obj.name}</td>
  <td>{obj.balance}</td>
  <td>{obj.id}</td>
</tr>);
</code>```

It works and i can populate rows in react with
{accounts}
. Now I'm trying to dynamically add . I tried the following but it creates a string and ReactJS throws error Warning: validateDOMNesting(...): Text nodes cannot appear as a child of
:

```<code>let fields = ['type', 'name', 'balance', 'id'];

data.forEach( function(element, index) {
  let fieldsLabel = `<tr key=${++i}>`;
  fields.forEach( function(key, index) {
    fieldsLabel = fieldsLabel.concat(`<td>${element[key]}</td>`);
  });
  fieldsLabel = fieldsLabel.concat(`</tr>`);
  accounts.push(Array.from(fieldsLabel));
});
</code>```

I'd like to do something simple like the following but it won't work because of the open
 tag:

```<code>    data.forEach( function(element, index) {
      let row = []
      row.push(<tr key={++i}>)
      fields.forEach( function(key, index) {
        row.push(<td>{element[key]}</td>)
      });
      row.push(</tr>)
      accounts.push(row.join(''));
    });
</code>```

How do you dynamically push  into an array so it can be used in reactjs like {accounts}?

答:
The following will dynamically add cells to table rows and dynamically create table rows for you to use in your components.

```<code>class TbodyRow extends React.Component {
  constructor() {
    super()
    this.createRow = this.createRow.bind(this);
  }

  createRow(tableRowID, data, dataOrder, cells = []) {
    for (let i in dataOrder) {
      cells.push(<td key={i}>{data[dataOrder[i]]}</td>)
    }
    return (<tr key={tableRowID}>{cells}</tr>);
  }

  render() {
    return this.createRow(
      this.props.tbodyIdKey,
      this.props.rowData,
      this.props.dataOrder
    );
  }
}
</code>```

Adding data cells () to a row (
): Put this inside your method that's looping over your array of data (i.e [obj, obj, obj].forEach...):

```<code>let fields = ['type', 'name', 'balance', 'id'];
accounts.push(
  <TbodyRow key={obj.id}
    tbodyIdKey={obj.id}
    rowData={obj}
    dataOrder={fields}
  />
);
</code>```

Then use in your tbody as requested:

```<code><tbody>
  {accounts}
</tbody>
</code>```

Body:
I'm building a tbody dynamically in reactjs. I have a function that creates seed data from a loop with this:

accounts.push(

  {obj.type}
  {obj.name}
  {obj.balance}
  {obj.id}

);

It works and i can populate rows in react with
{accounts}
. Now I'm trying to dynamically add . I tried the following but it creates a string and ReactJS throws error Warning: validateDOMNesting(...): Text nodes cannot appear as a child of
:

let fields = ['type', 'name', 'balance', 'id'];

data.forEach( function(element, index) {
  let fieldsLabel = `<tr key=${++i}>`;
  fields.forEach( function(key, index) {
    fieldsLabel = fieldsLabel.concat(`<td>${element[key]}</td>`);
  });
  fieldsLabel = fieldsLabel.concat(`</tr>`);
  accounts.push(Array.from(fieldsLabel));
});

I'd like to do something simple like the following but it won't work because of the open
 tag:

    data.forEach( function(element, index) {
      let row = []
      row.push(
)
      fields.forEach( function(key, index) {
        row.push({element[key]}	)
      });
      row.push(
)
      accounts.push(row.join(''));
    });

How do you dynamically push  into an array so it can be used in reactjs like {accounts}?

Body:
The following will dynamically add cells to table rows and dynamically create table rows for you to use in your components.

class TbodyRow extends React.Component {
  constructor() {
    super()
    this.createRow = this.createRow.bind(this);
  }

  createRow(tableRowID, data, dataOrder, cells = []) {
    for (let i in dataOrder) {
      cells.push(<td key={i}>{data[dataOrder[i]]}</td>)
    }
    return (<tr key={tableRowID}>{cells}</tr>);
  }

  render() {
    return this.createRow(
      this.props.tbodyIdKey,
      this.props.rowData,
      this.props.dataOrder
    );
  }
}

Adding data cells (<td>) to a row (<tr>): Put this inside your method that's looping over your array of data (i.e [obj, obj, obj].forEach...):

let fields = ['type', 'name', 'balance', 'id'];
accounts.push(
  <TbodyRow key={obj.id}
    tbodyIdKey={obj.id}
    rowData={obj}
    dataOrder={fields}
  />
);

Then use in your tbody as requested:

<tbody>
  {accounts}
</tbody>


问:
Using a Class with Generics with GSON
I am hoping to get some direction on how to resolve this issue. I am working with a Third Party API get JSON data. It has a structure similar to:

```<code>{items: [
    {attribute : Value},
    {attribute : Value}]
 count : value,
 etc
}
</code>```

The items array can hold different data, so I have a class:

```<code>public Items<T> {
    private List<T> items;
    // Others API Variables

    public List<T> getItems(){
        return items;
    }

    public void setItems(List<T> items){
       this.items = items;
    }
    // Other Getters/Setters
}
</code>```

What I am trying to do in the calling class is:

```<code>public CallingClass {

    public void Method(){
    //Code to get reader object
    Items<User> userItems = Gson().fromJson(ReaderObject, Items.class);
    //Other processing code
    }
}
</code>```

And I get the error:

```<code>java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to User.class
</code>```

I was reading through this post and I think the solution is similar to what I need but I don't know who to do it. My though was to have a single Items class that could be passed the different Types which are returned.

Thoughts, assistance, anything would be helpful.

EDIT:

OK So I feel like an idiot now, but some sleep helped. The solution was in the link I posted, I was just didn't need a list. My coded solution is as follows:

```<code>public CallingClass {

    public void Method(){
    //Code to get reader object
    Items<User> userItems = Gson().fromJson(ReaderObject, new TypeToken<Items<User>>(){}.getType());
    //Other processing code
    }
}
</code>```

答:
OK So I feel like an idiot now, but some sleep helped. The solution was in the link I posted, I was just didn't need a list. My coded solution is as follows:</p>

```<code>public CallingClass {

    public void Method(){
    //Code to get reader object
    Items<User> userItems = Gson().fromJson(ReaderObject, new TypeToken<Items<User>>(){}.getType());
    //Other processing code
    }
}
</code>```

Title: Using a Class with Generics with GSON

Body:
I am hoping to get some direction on how to resolve this issue. I am working with a Third Party API get JSON data. It has a structure similar to:

{items: [
    {attribute : Value},
    {attribute : Value}]
 count : value,
 etc
}

The items array can hold different data, so I have a class:

public Items<T> {
    private List<T> items;
    // Others API Variables

    public List<T> getItems(){
        return items;
    }

    public void setItems(List<T> items){
       this.items = items;
    }
    // Other Getters/Setters
}

What I am trying to do in the calling class is:

public CallingClass {

    public void Method(){
    //Code to get reader object
    Items<User> userItems = Gson().fromJson(ReaderObject, Items.class);
    //Other processing code
    }
}

And I get the error:

java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to User.class

I was reading through this post and I think the solution is similar to what I need but I don't know who to do it. My though was to have a single Items class that could be passed the different Types which are returned.

Thoughts, assistance, anything would be helpful.

EDIT:

OK So I feel like an idiot now, but some sleep helped. The solution was in the link I posted, I was just didn't need a list. My coded solution is as follows:

public CallingClass {

    public void Method(){
    //Code to get reader object
    Items<User> userItems = Gson().fromJson(ReaderObject, new TypeToken<Items<User>>(){}.getType());
    //Other processing code
    }
}


问:
Single sign on in ASP.NET - cookie name, machineKey and what more?
I have two ASP.NET apps hosted on one server. Their configs have the same machineKey values and the authentication sections look as follows:

```<code><authentication mode="Forms">
      <forms loginUrl="/_login/default.aspx" name=".MySingleAuth" />
    </authentication>

<authentication mode="Forms">
      <forms loginUrl="~/MySingle/LogOn/0" timeout="2880" name=".MySingleAuth"/>
    </authentication>
</code>```

The single sign on (authentication in both applications using one cookie) still doesn't work. What am I missing?

Edit: The two apps are on our intranet, one under https://ip:84 and the other under https://ip:86 (where ip is an IP).

答:
For me, the following configuration for SingleSignOn worked:

```<code><machineKey
  validationKey="818B77A6AFBF5E0B82B7FBE6F992E1733986DAEF81D1EB107B55D6F68EB6FEC6097349A9E37A407A6B5CF2FA1AB9327CA182A2C999A768C14B146036420203F9"
  decryptionKey="45798D54477D1D11BFC16733786AABB50E7FD5DDB3F8F46A"
  validation="SHA1"
/>

<authentication mode="Forms">
  <forms name=".ASPXAUTH" loginUrl="~/Login.aspx" protection="All" cookieless="UseCookies" enableCrossAppRedirects="true"/>
</authentication>
</code>```

Be sure the keys on the two applications are absolutely identical (validation and decryption)

The cookie name must be the same

SingleSignOn is only working if you are on the same domain (cookies).

Read this page, it helped me: http://www.codeproject.com/KB/aspnet/SingleSignon.aspx

Body:
I have two ASP.NET apps hosted on one server. Their configs have the same machineKey values and the authentication sections look as follows:

<authentication mode="Forms">
      <forms loginUrl="/_login/default.aspx" name=".MySingleAuth" />
    </authentication>

<authentication mode="Forms">
      <forms loginUrl="~/MySingle/LogOn/0" timeout="2880" name=".MySingleAuth"/>
    </authentication>

The single sign on (authentication in both applications using one cookie) still doesn't work. What am I missing?

Edit: The two apps are on our intranet, one under https://ip:84 and the other under https://ip:86 (where ip is an IP).

Body:
For me, the following configuration for SingleSignOn worked:

<machineKey
  validationKey="818B77A6AFBF5E0B82B7FBE6F992E1733986DAEF81D1EB107B55D6F68EB6FEC6097349A9E37A407A6B5CF2FA1AB9327CA182A2C999A768C14B146036420203F9"
  decryptionKey="45798D54477D1D11BFC16733786AABB50E7FD5DDB3F8F46A"
  validation="SHA1"
/>

<authentication mode="Forms">
  <forms name=".ASPXAUTH" loginUrl="~/Login.aspx" protection="All" cookieless="UseCookies" enableCrossAppRedirects="true"/>
</authentication>

Be sure the keys on the two applications are absolutely identical (validation and decryption)

The cookie name must be the same

SingleSignOn is only working if you are on the same domain (cookies).

Read this page, it helped me: http://www.codeproject.com/KB/aspnet/SingleSignon.aspx


问:
How to invert / reflect a 3DS Max Scene
I want to invert/reflect a scene (collection of meshes).

Example (in 3d space):
Before:
[1][2]
After:
[2][1]

Like if you would reflect it.
I hope you understand what i mean.
How should i do this?

答:
If you want to mimic with MaxScript what the Mirror tool does, it does like this, for example mirroring X axis:

```<code>for i=1 to objects.count do
(
  scale objects[i] [-1,1,1]
  objects[i].pos.x = -objects[i].pos.x
)
</code>```

You should be warned that after that your objects scale will be negative, and that could be problematic in some situations.

Title: How to invert / reflect a 3DS Max Scene

Body:
If you want to mimic with MaxScript what the Mirror tool does, it does like this, for example mirroring X axis:

for i=1 to objects.count do
(
  scale objects[i] [-1,1,1]
  objects[i].pos.x = -objects[i].pos.x
)

You should be warned that after that your objects scale will be negative, and that could be problematic in some situations.