问:
Detect log file rotation (while watching log file for modification)
I use the following code to track ssh log-ins:

```<code>def follow(thefile):
  thefile.seek(0,2)
  while True:
    line = thefile.readline()
    if not line:
      time.sleep(0.1)
      continue
    yield line

if __name__ == '__main__':
  logfile = open('/var/log/auth.log', 'r')
  loglines = follow(logfile)
  for line in loglines:
    print 'do something here'
</code>```

I've noticed that this script suddenly stops working after a couple of days. I don't get any error, it doesn't terminate, it just stops working, as if readline() would never return.

So I executed a echo 'test' >> auth.log.1 and this indeed ends up getting processed by the script, because sometime ago auth.log got renamed to auth.log.1

How can I track when such a log rotation happens and adjust accordingly?

答: This is best done with inotify you don't want to keep polling the file system to ask if things have changed during each iteration of the loop. That's a lot of wasted IO. inotify will notify you when a change occurs. There is an example right from the manual which shows it's usage with log file.

Body:
I use the following code to track ssh log-ins:

def follow(thefile):
  thefile.seek(0,2)
  while True:
    line = thefile.readline()
    if not line:
      time.sleep(0.1)
      continue
    yield line

if __name__ == '__main__':
  logfile = open('/var/log/auth.log', 'r')
  loglines = follow(logfile)
  for line in loglines:
    print 'do something here'

I've noticed that this script suddenly stops working after a couple of days. I don't get any error, it doesn't terminate, it just stops working, as if readline() would never return.

So I executed a echo 'test' >> auth.log.1 and this indeed ends up getting processed by the script, because sometime ago auth.log got renamed to auth.log.1

How can I track when such a log rotation happens and adjust accordingly?


来源: stackexchange

问:
Is creating instances of a class inside a static PageMethod thread safe?
I am using jQuery to call PageMethods.  For certain operations, the current user credentials must be validated and for other operations, I need to call other static methods.  Here is some sample code:

Sample #1

```<code>[WebMethod]
public static void PostComment(string comment)
{
    UserAuth auth = new UserAuth();
    if (auth.isAuthenticated)
        {
            //Post comment here...
        }
}
</code>```

Sample #2

```<code>[WebMethod]
public static string GetComment(int commentId)
{

    commentDto comment = //get comment data from the database...
    string friendlyDate = ConvertFriendlyDate(comment.commentDate);

    return friendlyDate + " " + comment.text;
}

public static string ConvertFriendlyDate(DateTime commentDate)
{
    string friendlyDate = //call static utility method to convert date to friendly format

    return friendlyDate;

}
</code>```

Will I be safe using these kinds of operations?

Am I better to drop page methods and just call a separate ASPX page for my AJAX requests?

答: The examples you gave look fine.  If you were reusing an instance of an object, then I would make sure that object is thread safe.</p>

ContentLicense: CC BY-SA 2.5

Body:
I am using jQuery to call PageMethods.  For certain operations, the current user credentials must be validated and for other operations, I need to call other static methods.  Here is some sample code:

Sample #1

[WebMethod]
public static void PostComment(string comment)
{
    UserAuth auth = new UserAuth();
    if (auth.isAuthenticated)
        {
            //Post comment here...
        }
}

Sample #2

[WebMethod]
public static string GetComment(int commentId)
{

    commentDto comment = //get comment data from the database...
    string friendlyDate = ConvertFriendlyDate(comment.commentDate);

    return friendlyDate + " " + comment.text;
}

public static string ConvertFriendlyDate(DateTime commentDate)
{
    string friendlyDate = //call static utility method to convert date to friendly format

    return friendlyDate;

}

Will I be safe using these kinds of operations?

Am I better to drop page methods and just call a separate ASPX page for my AJAX requests?


问:
Horizontal scroll bar bot working in bootstrap modal
I am having a modal, showing div in 'modal-body'.

```<code><div class="modal-body">
    <div class="scoll-tree">
        <div class="history">
            Report Event Details
        </div>
        <div class="history">
            Report Event Details 1
        </div>
       <div class="history">
            Report Event Details 2
        </div>
       <div class="history">
            Report Event Details 3
        </div>
    </div>
</div>
</code>```

Set the class as bellow :

```<code>.scoll-tree{
   width: 400px;
   height:80px;
   overflow-x: scroll;
}

.history {
    background: rgba(255, 255, 255, 0.7);
    float: left;
    min-width: 5em;
    width: 25ex;
    max-height: 3em;
    margin: 2em;
    padding: 1em;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    box-shadow: 2px 5px 5px rgba(0,0,0,0.2);
    vertical-align: central;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
</code>```

I want horizontal scroll bar to 'scoll-tree' container,  when 'history' div exceed the width.

Currently it give vertical scroll bar, i want only horizontal scroll bar.

https://jsfiddle.net/hemantmalpote/4duq2svh/35/

答:
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

Modal Example

  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

          <button type="button" class="close" data-dismiss="modal">×</button>

Modal Header

Content1
Content2
Content3
Content4
Content5
Content6
Content7
Content8
Content9
Content10

          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

```

ContentLicense: CC BY-SA 3.0

Body:
I am having a modal, showing div in 'modal-body'.

            Report Event Details

            Report Event Details 1

            Report Event Details 2

            Report Event Details 3

Set the class as bellow :

.scoll-tree{
   width: 400px;
   height:80px;
   overflow-x: scroll;
}

.history {
    background: rgba(255, 255, 255, 0.7);
    float: left;
    min-width: 5em;
    width: 25ex;
    max-height: 3em;
    margin: 2em;
    padding: 1em;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    box-shadow: 2px 5px 5px rgba(0,0,0,0.2);
    vertical-align: central;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

I want horizontal scroll bar to 'scoll-tree' container,  when 'history' div exceed the width.

Currently it give vertical scroll bar, i want only horizontal scroll bar.

https://jsfiddle.net/hemantmalpote/4duq2svh/35/

Body:
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">

     <div style="height:100px; width:100px; overflow-x:auto">
Content1
Content2
Content3
Content4
Content5
Content6
Content7
Content8
Content9
Content10
</div>

        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>

    </div>
  </div>

</div>

</body>
</html>


问:
Trouble with CLI and iOS simulator
I'm moving to a new machine and want to start out fresh. I'm leaving Appcelerator Studio behind and want to go all CLI.

The project I'm working on is still on SDK 5.5.1.

When I try to build our app for the iPhone simulator it builds fine and launches the simulator but when it tries to start the app the simulator goes black execpt for the status bar. No errors are thrown in the terminal and nothing interesting shows up in console.app

I can launch the app in the simulator on my old machine without issues (done it 1000 times or so).

I build with: appc run -p ios

This is the last output I get:

```<code>[INFO]  Launching iOS Simulator
-- Start simulator log -------------------------------------------------------
[INFO]  Application started
[INFO]  OurAppName/2.8.1 (5.5.1.b18727f)
</code>```

This is my setup:

```<code>Appcelerator Command-Line Interface, version 5.5.1

2017-02-08 14:54:46

Name = Mac OS X

Xcode 8.1

Version = 10.12.3

Node.js Version = 4.7.3

npm Version = 2.15.11

Titanium CLI Version = 5.0.9

Titanium SDK Version = 5.5.1.GA

SDK Path = /Users/-/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA

Target Platform = iphone
</code>```

What am I missing?

答:
if you are using Xcode 8.1 then you can use the following command

```<code>appc ti build -p ios -I 10.1
</code>```

where -p is platform and -I is IOS version

if you want to check IOS version

Step 1: Go to Xcode

Step 2: Window -> Devices.

please see the image it will clear all things.

It worked for me.

Title: Trouble with CLI and iOS simulator

Body:
I'm moving to a new machine and want to start out fresh. I'm leaving Appcelerator Studio behind and want to go all CLI.

The project I'm working on is still on SDK 5.5.1.

When I try to build our app for the iPhone simulator it builds fine and launches the simulator but when it tries to start the app the simulator goes black execpt for the status bar. No errors are thrown in the terminal and nothing interesting shows up in console.app

I can launch the app in the simulator on my old machine without issues (done it 1000 times or so).

I build with: appc run -p ios

This is the last output I get:

[INFO]  Launching iOS Simulator
-- Start simulator log -------------------------------------------------------
[INFO]  Application started
[INFO]  OurAppName/2.8.1 (5.5.1.b18727f)

This is my setup:

Appcelerator Command-Line Interface, version 5.5.1

2017-02-08 14:54:46

Name = Mac OS X

Xcode 8.1

Version = 10.12.3

Node.js Version = 4.7.3

npm Version = 2.15.11

Titanium CLI Version = 5.0.9

Titanium SDK Version = 5.5.1.GA

SDK Path = /Users/-/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA

Target Platform = iphone

What am I missing?

Body:
if you are using Xcode 8.1 then you can use the following command

appc ti build -p ios -I 10.1

where -p is platform and -I is IOS version

if you want to check IOS version

Step 1: Go to Xcode

Step 2: Window -> Devices.

please see the image it will clear all things.

It worked for me.


问:
Karma Test Cases for CSS File Available or not in a folder or specific path
I need to write test cases for css file so whether css file present or not on specific folder or path..So how to check using karma or jasmine test cases. Need help... Thanks in advance..</p>

答: You can use this npm package: file-exists to check if filepath exists and is a file.</p>


问:
How to Fix Visual Studio 2012 error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string?
How to fix a Visual Studio 2012 error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string?

I've been compiling a solution containing one exe and several static lib projects
on which the exe depends fine with Visual Studio 2008.  The static libs include:

TCL: tcl84tsx.lib

wxWidgets: wxbase.lib

zlib.lib

ws2_32.lib

xerces-c_2.lib

SNMP Research EMANATE: subagent.lib,agent.lib,emanate.lib,pack.lib,mibtable.lib,devkit.lib

etc.

I loaded the solution into Visual Studio 2012 and have compiled all the projects in the solution but when I try to link the exe, I'm getting errors about unresolved symbols for stuff in the standard C++ library like the output below.

I've found lots of people with unresolved symbols like this one but none of the fixes are working for me.  Fixes I've tried so far include

Updating the EXE project by manually adding references to static lib projects on which the exe project depends

Toggling the "treat wchar_t as built-in type" linker option

Output from Visual Studio 2012 linker...

```<code> 1>ace_funcs.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
 1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
 1>ComponentX-Win32.lib(MyOrgConsoleSktServer.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentY-Win32.lib(ORBSingleton.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentY-Win32.lib(OrbException.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(ExceptionHelper.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(ComponentCCheckpointImpl.obj) : warning LNK4217: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
 1>ComponentX-Win32.lib(MyOrgConsole.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentX-Win32.lib(MyOrgThreadFactory.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(ComponentBServiceImpl.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(XmlPreferencesHelper.obj) : warning LNK4217: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "private: void __thiscall _CORBA_Sequence_String::copybuffer(unsigned long)" (?copybuffer@_CORBA_Sequence_String@@AAEXK@Z)
 1>ComponentZ-Win32.lib(XmlHelper.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : warning LNK4217: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
 1>ComponentA-Win32.lib(propertyutil.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentA-Win32.lib(SystemEnvironment.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(PersistenceClient.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentY-Win32.lib(OrbException.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentX-Win32.lib(MyOrgConsole.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentX-Win32.lib(MyOrgThreadFactory.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentX-Win32.lib(MyOrgConsoleSktServer.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentY-Win32.lib(ORBSingleton.obj) : warning LNK4217: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported in function "public: virtual __thiscall OrbException::~OrbException(void)" (??1OrbException@@UAE@XZ)
 1>ComponentZ-Win32.lib(XmlPreferencesHelper.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 -- snip --
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::substr(unsigned int,unsigned int)const " (__imp_?substr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV12@II@Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (?trimmed@ServiceBootstrap@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_last_not_of(char const *,unsigned int,unsigned int)const " (__imp_?find_last_not_of@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (?trimmed@ServiceBootstrap@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_first_not_of(char const *,unsigned int,unsigned int)const " (__imp_?find_first_not_of@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (?trimmed@ServiceBootstrap@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) referenced in function "private: void __thiscall ServiceBootstrap::verifyBootstrapProperties(void)" (?verifyBootstrapProperties@ServiceBootstrap@@AAEXXZ)
 1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@0@Z) referenced in function "public: class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > __thiscall ServiceBootstrap::getBootstrapProperties(void)" (?getBootstrapProperties@ServiceBootstrap@@QAE?AV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ)
 1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@0@Z)
 1>ComponentA-Win32.lib(propertyutil.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Mutex::_Lock(void)" (__imp_?_Lock@_Mutex@std@@QAEXXZ) referenced in function "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Sentry_base::_Sentry_base(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0_Sentry_base@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@AAV12@@Z)
 1>ComponentZ-Win32.lib(XmlHelper.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Mutex::_Lock(void)" (__imp_?_Lock@_Mutex@std@@QAEXXZ)
 -- snip --
 1>.\Debug/sComponentC.exe : fatal error LNK1120: 22 unresolved externals
 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</code>```

答:
Even I faced this type of errors in visual studio. The reason for these kind of errors are,

1) You might have included multiple libraries which are conflicting each other.
   Sometimes,one class in a library can conflict other class in other library.

2) You might have included libraries from directories. Check the path of the libraries once again.

3) You need to specify libraries and header files (if you have to include) in the project properties. Check once again whether the paths are correct.

Body:
How to fix a Visual Studio 2012 error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string?

I've been compiling a solution containing one exe and several static lib projects
on which the exe depends fine with Visual Studio 2008.  The static libs include:

TCL: tcl84tsx.lib

wxWidgets: wxbase.lib

zlib.lib

ws2_32.lib

xerces-c_2.lib

SNMP Research EMANATE: subagent.lib,agent.lib,emanate.lib,pack.lib,mibtable.lib,devkit.lib

etc.

I loaded the solution into Visual Studio 2012 and have compiled all the projects in the solution but when I try to link the exe, I'm getting errors about unresolved symbols for stuff in the standard C++ library like the output below.

I've found lots of people with unresolved symbols like this one but none of the fixes are working for me.  Fixes I've tried so far include

Updating the EXE project by manually adding references to static lib projects on which the exe project depends

Toggling the "treat wchar_t as built-in type" linker option

Output from Visual Studio 2012 linker...

 1>ace_funcs.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
 1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
 1>ComponentX-Win32.lib(MyOrgConsoleSktServer.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentY-Win32.lib(ORBSingleton.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentY-Win32.lib(OrbException.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(ExceptionHelper.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(ComponentCCheckpointImpl.obj) : warning LNK4217: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
 1>ComponentX-Win32.lib(MyOrgConsole.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentX-Win32.lib(MyOrgThreadFactory.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(ComponentBServiceImpl.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(XmlPreferencesHelper.obj) : warning LNK4217: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "private: void __thiscall _CORBA_Sequence_String::copybuffer(unsigned long)" (?copybuffer@_CORBA_Sequence_String@@AAEXK@Z)
 1>ComponentZ-Win32.lib(XmlHelper.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : warning LNK4217: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
 1>ComponentA-Win32.lib(propertyutil.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentA-Win32.lib(SystemEnvironment.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentZ-Win32.lib(PersistenceClient.obj) : warning LNK4049: locally defined symbol ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported
 1>ComponentY-Win32.lib(OrbException.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentX-Win32.lib(MyOrgConsole.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentX-Win32.lib(MyOrgThreadFactory.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentX-Win32.lib(MyOrgConsoleSktServer.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 1>ComponentY-Win32.lib(ORBSingleton.obj) : warning LNK4217: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported in function "public: virtual __thiscall OrbException::~OrbException(void)" (??1OrbException@@UAE@XZ)
 1>ComponentZ-Win32.lib(XmlPreferencesHelper.obj) : warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported
 -- snip --
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::substr(unsigned int,unsigned int)const " (__imp_?substr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV12@II@Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (?trimmed@ServiceBootstrap@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_last_not_of(char const *,unsigned int,unsigned int)const " (__imp_?find_last_not_of@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (?trimmed@ServiceBootstrap@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_first_not_of(char const *,unsigned int,unsigned int)const " (__imp_?find_first_not_of@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (?trimmed@ServiceBootstrap@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) referenced in function "private: void __thiscall ServiceBootstrap::verifyBootstrapProperties(void)" (?verifyBootstrapProperties@ServiceBootstrap@@AAEXXZ)
 1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z)
 1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@0@Z) referenced in function "public: class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > __thiscall ServiceBootstrap::getBootstrapProperties(void)" (?getBootstrapProperties@ServiceBootstrap@@QAE?AV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ)
 1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@0@Z)
 1>ComponentA-Win32.lib(propertyutil.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Mutex::_Lock(void)" (__imp_?_Lock@_Mutex@std@@QAEXXZ) referenced in function "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Sentry_base::_Sentry_base(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0_Sentry_base@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@AAV12@@Z)
 1>ComponentZ-Win32.lib(XmlHelper.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Mutex::_Lock(void)" (__imp_?_Lock@_Mutex@std@@QAEXXZ)
 -- snip --
 1>.\Debug/sComponentC.exe : fatal error LNK1120: 22 unresolved externals
 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


问:
How to inline h1 with p to match height?
How can i match the height of the h1 with the p tag?
I want to set the h1 to the left followed by the p on the same base line

.row_cont {
  float: left;
  width: 33.33333333%;
  overflow: hidden;
  border-left: 0.5px solid rgba(0, 0, 0, 0.37);
  padding-right: 15px;
  padding-left: 15px;
}

.row_cont h1 {
  font-size: 70px;
  float: left;
  margin-right: 10px;
}

.row_cont p {
  font-size: 12px;
  margin: 0;
  padding: 0;
  overflow: hidden;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="page_container">
  <div class="row">
    <div class="col-md-12">
      <div class="row_cont">
        <h1>1</h1>
        <p>Lorem ipsum dolor sit amet</p>
      </div>
      <div class="row_cont">
        <h1>2</h1>
        <p>Aenean massa. Cum sociis natoque penatibus </p>
      </div>
      <div class="row_cont">
        <h1>3</h1>
        <p>Cras dapibus. Vivamus elementum semper nisi. </p>
      </div>
    </div>
  </div>
</div></code>```

I've tried vertical-align but it's not working, here is my fiddle

答:
you could use the sibling css selectors...

h1, h1 + p {
  line-height: 1.5;
  font-size: 2rem;
  font-weight: bold;
  display: inline;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><h1>Title</h1><p>Paragraph</p></code>```

Body:
How can i match the height of the h1 with the p tag?
I want to set the h1 to the left followed by the p on the same base line

.row_cont {
  float: left;
  width: 33.33333333%;
  overflow: hidden;
  border-left: 0.5px solid rgba(0, 0, 0, 0.37);
  padding-right: 15px;
  padding-left: 15px;
}

.row_cont h1 {
  font-size: 70px;
  float: left;
  margin-right: 10px;
}

.row_cont p {
  font-size: 12px;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

1

Lorem ipsum dolor sit amet

2

Aenean massa. Cum sociis natoque penatibus

3

Cras dapibus. Vivamus elementum semper nisi.

I've tried vertical-align but it's not working, here is my fiddle

Body:
you could use the sibling css selectors...

h1, h1 + p {
  line-height: 1.5;
  font-size: 2rem;
  font-weight: bold;
  display: inline;
}

<h1>Title</h1><p>Paragraph</p>


问:
Improve performance of WareHouse query on Exact Online
We have 20 warehouses and 3.000 articles. Therefore there are 60.000 rows in the ItemWarehouses table of Exact Online. However, retrieval takes 1200 ms per 60 rows, so total query on this data volume for a warehouse analysis takes 3-4 hours.

I've tried to restrict the number of data retrieved using the following filter because we are only in items with some non-zero stock information:

```<code>select t.*
from   exactonlinerest..itemwarehouses t
where  ( currentstock != 0 or projectedstock != 0 or plannedstockin != 0 or plannedstockout != 0 or safetystock != 0 or reorderpoint != 0)
</code>```

But it still downloads all 60.000 combinations and filters them on the PC. The result at the end is approximately 700 valid combinations of warehouse and item stock information.

Is there a way to retrieve the data in a more performant way?

答:
Invantive SQL does not forward OR-constructs to the server-side. But in this case you might want to change the OR into a UNION (without ALL):

```<code>select t.*
from   exactonlinerest..itemwarehouses t
where  currentstock != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  projectedstock != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  plannedstockin != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  plannedstockin != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  safetystock != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  reorderpoint != 0
</code>```

These filters are forwarded to Exact Online and should run very fast given your data distribution. The UNION ensures that you only get the unique rows back.

Body:
We have 20 warehouses and 3.000 articles. Therefore there are 60.000 rows in the ItemWarehouses table of Exact Online. However, retrieval takes 1200 ms per 60 rows, so total query on this data volume for a warehouse analysis takes 3-4 hours.

I've tried to restrict the number of data retrieved using the following filter because we are only in items with some non-zero stock information:

select t.*
from   exactonlinerest..itemwarehouses t
where  ( currentstock != 0 or projectedstock != 0 or plannedstockin != 0 or plannedstockout != 0 or safetystock != 0 or reorderpoint != 0)

But it still downloads all 60.000 combinations and filters them on the PC. The result at the end is approximately 700 valid combinations of warehouse and item stock information.

Is there a way to retrieve the data in a more performant way?

Body:
Invantive SQL does not forward OR-constructs to the server-side. But in this case you might want to change the OR into a UNION (without ALL):

select t.*
from   exactonlinerest..itemwarehouses t
where  currentstock != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  projectedstock != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  plannedstockin != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  plannedstockin != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  safetystock != 0
union
select t.*
from   exactonlinerest..itemwarehouses t
where  reorderpoint != 0

These filters are forwarded to Exact Online and should run very fast given your data distribution. The UNION ensures that you only get the unique rows back.


问:
Request rate is large for remove request
When I try to find some docs in documentDB, all is good -

```<code>collection.find({query})
</code>```

when I try to remove, all is bad

```<code>[mongooseModel | collection].remove({same-query})
</code>```

I got

Request rate is large

The number of documents to remove ~ 10 000 . I have tested queries in robomongo shell, which limits find results to 50 per page. Also my remove query fails with mongoose. I can't understand such behavior. How can I got in to Request Limit while remove query is a single request?

Update

Count with query also raise same error.

```<code>db.getCollection('taxonomies').count({query})
</code>```

答:
"Request rate is large" indicates that the application has exceeded the provisioned RU quota, and should retry the request after a small time interval.

Since you are using DocumentDB Node.js API, you could check out @Larry Maccherone's answer in Request rate is large on how to avoid this issue by handling retry behavior and logic in your application's error handling routines.

More on this:

Dealing with RequestRateTooLarge errors in Azure DocumentDB and testing performance

Request Units in Azure Cosmos DB

Body:
When I try to find some docs in documentDB, all is good -

collection.find({query})

when I try to remove, all is bad

[mongooseModel | collection].remove({same-query})

I got

Request rate is large

The number of documents to remove ~ 10 000 . I have tested queries in robomongo shell, which limits find results to 50 per page. Also my remove query fails with mongoose. I can't understand such behavior. How can I got in to Request Limit while remove query is a single request?

Update

Count with query also raise same error.

db.getCollection('taxonomies').count({query})


问:
SASS - vertical center timline content
I'm new to frontend developer and i'm using sass. I have my custom timeline and I need help in aligning the location with the year and the timeline marker. and also i want to put the image description to the right side of the image.

here's the link for my jsfiddle

https://jsfiddle.net/g99Lmsaz/

heres my sass code

```<code>$purple: #AF80ED;
        $gray: #f2f2f2;
        $white: #ffffff;
        $timeline-gray: #dddddd;

        .event {
            background: $purple;
            display: table;
            width: 100%;
            margin: 0 auto;
        }

        .event-2 {
            background: $gray;
            display: table;
            width: 100%;
        }

        time {
            /*float: left;
            position: absolute;
            top: 40%;*/
            display: table-cell;
            width: auto;
            text-align: center;
            vertical-align: middle;
            width: 25%;
        }

        .timeline ul li {
          list-style-type: none;
          position: relative;
          width: 6px;
          /*left: 10%;
          margin: 0 auto;*/
          padding: 10px 0 10px 0;
          background: $timeline-gray;

          .content {
            position: relative;
            left: 20px;
            max-width: 700px;
            top: calc(100% / 2 - 10px);

            img{
                border-radius: 50%;
                height: 20px;
                width: 20px;
            }

          }
        }

        .timeline ul li::after {
          content: '';
          position: absolute;
          left: 50%;
          bottom: 0;
          transform: translateX(-50%);
          width: 15px;
          height: 15px;
          border: 4px solid $timeline-gray;
          border-radius: 50%;
          background: $white;
          top: calc(100% / 2 - 10px);
        }
</code>```

the html code

```<code><section class="timeline">
                  <ul>
                    <div class='event'>
                        <time>1934</time>
                        <li>
                          <div class='content'>
                                <p>
                                Paris
                                </p>

                                <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Tour_Eiffel_Wikimedia_Commons_%28cropped%29.jpg/240px-Tour_Eiffel_Wikimedia_Commons_%28cropped%29.jpg" >

                                <p>
                                    Eiffel Tower
                                </p>

                          </div>
                        </li>
                    </div>
                    <div class='event-2'>
                        <time>1934</time>
                        <li>
                          <div class='content'>
                            <p>
                                asdsadsadsadsad
                            </p>
                          </div>
                        </li>
                    </div>
                  </ul>
                </section>
</code>```

答:
Your HTML structure is wrong you shouldn't add div directly inside ul tag

ul tag must have li tag inside and then you can put what ever you want inside li

I changed i few things in your code, its better to use pseudo element on time tag and not on li

See updated jsfiddle

Title: SASS - vertical center timline content

Body:
I'm new to frontend developer and i'm using sass. I have my custom timeline and I need help in aligning the location with the year and the timeline marker. and also i want to put the image description to the right side of the image.

here's the link for my jsfiddle

https://jsfiddle.net/g99Lmsaz/

heres my sass code

$purple: #AF80ED;
        $gray: #f2f2f2;
        $white: #ffffff;
        $timeline-gray: #dddddd;

        .event {
            background: $purple;
            display: table;
            width: 100%;
            margin: 0 auto;
        }

        .event-2 {
            background: $gray;
            display: table;
            width: 100%;
        }

        time {
            /*float: left;
            position: absolute;
            top: 40%;*/
            display: table-cell;
            width: auto;
            text-align: center;
            vertical-align: middle;
            width: 25%;
        }

        .timeline ul li {
          list-style-type: none;
          position: relative;
          width: 6px;
          /*left: 10%;
          margin: 0 auto;*/
          padding: 10px 0 10px 0;
          background: $timeline-gray;

          .content {
            position: relative;
            left: 20px;
            max-width: 700px;
            top: calc(100% / 2 - 10px);

            img{
                border-radius: 50%;
                height: 20px;
                width: 20px;
            }

          }
        }

        .timeline ul li::after {
          content: '';
          position: absolute;
          left: 50%;
          bottom: 0;
          transform: translateX(-50%);
          width: 15px;
          height: 15px;
          border: 4px solid $timeline-gray;
          border-radius: 50%;
          background: $white;
          top: calc(100% / 2 - 10px);
        }

the html code

                        <time>1934</time>

                                Paris

                                    Eiffel Tower

                        <time>1934</time>

                                asdsadsadsadsad


问:
What is the fastest way to insert a new has relation to an existing entry?
I need to insert a finance_entity for each club in a one to one relationship.
I decided to run this in the mysql server, because single inserts are even slower. How could I optimize this to run faster? Is there some way to hack insert select to do this?

I cannot put the club_id on finance_entity, since more then one relation points to it.

```<code>alter table clubs add column finance_entity_id int unsigned null after id;
DELIMITER !
drop procedure if exists create_entities!
create procedure create_entities()
begin
    create_entities_for_club: loop
        set @club_key = (select id from clubs where finance_entity_id is null limit 1);

        insert into finance_entity (id) value (null);
        update clubs set finance_entity_id = last_insert_id() where id = @club_key;

        if @club_key is null then
            leave create_entities_for_club;
        end if;
    end loop create_entities_for_club;
end!
call create_entities_for_club()!

DELIMITER ;

alter table clubs change column finance_entity_id finance_entity_id int unsigned not null;
alter table clubs add unique (finance_entity_id);
</code>```

答:
Setting a temporary key seems to be the fastest approach.

In addition to this, it's essential for there to be enough size in the buffer, turns out my testing machine only had 16M of buffer size.

Add these to your my.ini or my.cnf

```<code>innodb_buffer_pool_size=1024M
innodb_additional_mem_pool_size = 8M
innodb_log_file_size = 256M
innodb_log_buffer_size = 512M
</code>```

Use this to insert to the table, adding and index to club_id, might make it even faster.

```<code>alter table finance_entity add column club_id int unsigned null;
insert into finance_entity (club_id) select id from clubs;

update clubs join finance_entity on clubs.id = finance_entity.club_id
set finance_entity_id = finance_entity.id;

alter table finance_entity drop column club_id;
</code>```

This ran in 1.6 seconds for 20 thousand entries.

Body:
I need to insert a finance_entity for each club in a one to one relationship.
I decided to run this in the mysql server, because single inserts are even slower. How could I optimize this to run faster? Is there some way to hack insert select to do this?

I cannot put the club_id on finance_entity, since more then one relation points to it.

alter table clubs add column finance_entity_id int unsigned null after id;
DELIMITER !
drop procedure if exists create_entities!
create procedure create_entities()
begin
    create_entities_for_club: loop
        set @club_key = (select id from clubs where finance_entity_id is null limit 1);

        insert into finance_entity (id) value (null);
        update clubs set finance_entity_id = last_insert_id() where id = @club_key;

        if @club_key is null then
            leave create_entities_for_club;
        end if;
    end loop create_entities_for_club;
end!
call create_entities_for_club()!

DELIMITER ;

alter table clubs change column finance_entity_id finance_entity_id int unsigned not null;
alter table clubs add unique (finance_entity_id);

Body:
Setting a temporary key seems to be the fastest approach.

In addition to this, it's essential for there to be enough size in the buffer, turns out my testing machine only had 16M of buffer size.

Add these to your my.ini or my.cnf

innodb_buffer_pool_size=1024M
innodb_additional_mem_pool_size = 8M
innodb_log_file_size = 256M
innodb_log_buffer_size = 512M

Use this to insert to the table, adding and index to club_id, might make it even faster.

alter table finance_entity add column club_id int unsigned null;
insert into finance_entity (club_id) select id from clubs;

update clubs join finance_entity on clubs.id = finance_entity.club_id
set finance_entity_id = finance_entity.id;

alter table finance_entity drop column club_id;

This ran in 1.6 seconds for 20 thousand entries.


问:
Access VBA Run-time error '3021' No current record - Concatenating multiple rows into one row
For each "ConcatID", I want to concatenate "Major" into one row separated by a ";"

```<code>Source table:
ConcatID    Major
A           Math
A           English
A           Theatre
B           Math
C           Biology

Target table:
A           Math; English; Theatre
B           Math
C           Biology
</code>```

The code runs and performs what I need it to do, but I get this error "Run-time error '3021' No current record" on this line of code

```<code>Do While (ID_prev = rs_source![ConcatID].Value And Not (rs_source.EOF))
</code>```

.

```<code>Option Compare Database
Option Explicit

Sub Concat()
    Dim dbs As DAO.Database

    Dim rs_source As DAO.Recordset
    Dim rs_target As DAO.Recordset

    Dim MajorList As String 'Placeholder for concatenating list of college majors
    Dim ID_prev As String 'Retains ID from previous record

    Set dbs = CurrentDb
    Set rs_source = dbs.OpenRecordset("tbl_ConcatMajorsSource") 'many records per student/college
    Set rs_target = dbs.OpenRecordset("tbl_ConcatMajorsTarget") 'one record per student/college
    dbs.Execute ("DELETE * FROM tbl_ConcatMajorsTarget") 'clear out table

    ID_prev = rs_source![ConcatID].Value ' set equal to first ID
    MajorList = rs_source![Major].Value ' set equal to first major
    rs_source.MoveNext ' move to the second record

    Do While Not (rs_source.EOF)
        Do While (ID_prev = rs_source![ConcatID].Value And Not (rs_source.EOF))
            MajorList = rs_source![Major].Value & "; " & MajorList 'concatenate majors
            rs_source.MoveNext
        Loop
        rs_target.AddNew ' add new record in target table
        rs_target![ConcatID].Value = ID_prev ' populate ID
        rs_target![Major].Value = MajorList ' populate MajorList
        rs_target.Update
        ID_prev = rs_source![ConcatID].Value ' set ID_prev to the new ID
        MajorList = "" 'blank out MajorList
    Loop

    rs_source.Close
    rs_target.Close
    Set rs_source = Nothing
    Set rs_target = Nothing
End Sub
</code>```

Thank you in advance!

答:
That's because a record can't be read when the recordset reaches EOF. Thus:</p>

```<code>    Do While Not rs_source.EOF
        If ID_prev = rs_source![ConcatID].Value Then
            Exit Do
        Else
            MajorList = rs_source![Major].Value & "; " & MajorList 'concatenate majors
            rs_source.MoveNext
        End If
    Loop
</code>```

Body:
For each "ConcatID", I want to concatenate "Major" into one row separated by a ";"

Source table:
ConcatID    Major
A           Math
A           English
A           Theatre
B           Math
C           Biology

Target table:
A           Math; English; Theatre
B           Math
C           Biology

The code runs and performs what I need it to do, but I get this error "Run-time error '3021' No current record" on this line of code

Do While (ID_prev = rs_source![ConcatID].Value And Not (rs_source.EOF))

.

Option Compare Database
Option Explicit

Sub Concat()
    Dim dbs As DAO.Database

    Dim rs_source As DAO.Recordset
    Dim rs_target As DAO.Recordset

    Dim MajorList As String 'Placeholder for concatenating list of college majors
    Dim ID_prev As String 'Retains ID from previous record

    Set dbs = CurrentDb
    Set rs_source = dbs.OpenRecordset("tbl_ConcatMajorsSource") 'many records per student/college
    Set rs_target = dbs.OpenRecordset("tbl_ConcatMajorsTarget") 'one record per student/college
    dbs.Execute ("DELETE * FROM tbl_ConcatMajorsTarget") 'clear out table

    ID_prev = rs_source![ConcatID].Value ' set equal to first ID
    MajorList = rs_source![Major].Value ' set equal to first major
    rs_source.MoveNext ' move to the second record

    Do While Not (rs_source.EOF)
        Do While (ID_prev = rs_source![ConcatID].Value And Not (rs_source.EOF))
            MajorList = rs_source![Major].Value & "; " & MajorList 'concatenate majors
            rs_source.MoveNext
        Loop
        rs_target.AddNew ' add new record in target table
        rs_target![ConcatID].Value = ID_prev ' populate ID
        rs_target![Major].Value = MajorList ' populate MajorList
        rs_target.Update
        ID_prev = rs_source![ConcatID].Value ' set ID_prev to the new ID
        MajorList = "" 'blank out MajorList
    Loop

    rs_source.Close
    rs_target.Close
    Set rs_source = Nothing
    Set rs_target = Nothing
End Sub

Thank you in advance!

Body:
That's because a record can't be read when the recordset reaches EOF. Thus:

    Do While Not rs_source.EOF
        If ID_prev = rs_source![ConcatID].Value Then
            Exit Do
        Else
            MajorList = rs_source![Major].Value & "; " & MajorList 'concatenate majors
            rs_source.MoveNext
        End If
    Loop


问:
How to print errors in error log in Django?
I have example code in view:

try
   bla-bla-bla
  except
    return 500 status

How to view error in this try in error.log for Django ( for example if Django run on mod-python in Apache ) ?

答: Print to sys.stderr, or better yet, use logging.


问:
Unable to display dropdown and popover AngularJS
I am new to this, can you help me figure out why my dropdown is not displaying properly and also the popover of the second value of dropdown is not working properly?
I am a bit confuse since it is my first time trying this.
Here is my code

```<code><ul class="nav site-nav">
<li class=flyout>
    <a href=#>Menu</a>

<!-- Flyout -->
<ul class="flyout-content nav stacked">
  <li>
    <div ng-app>
      <div ng-controller="popoverCtrl">
        <a href="#" ng-mouseover="showPopover=true;" ng-mouseleave="showPopover=false;">Real Account <div class="popover" ng-show="showPopover"><span>{{ popover.title }}</span>{{ popover.message }}</div></a>
      </div>
    </div>
  </li>
  <li>
    <div ng-app>
      <div ng-controller="popoverCtrl2">
        <a href="#" ng-mouseover="showPopover2=true;" ng-mouseleave="showPopover2=false;">Practice Account <div class="popover2" ng-show="showPopover2"><span>{{ popover2.title }}</span>{{ popover2.message }}</div></a>
      </div>
    </div>
  </li>

</ul>
</code>```

and my JS

```<code>function popoverCtrl($scope) {

  $scope.showPopover = false;

  $scope.popover = {
    title: 'Title',
    message: 'Message'
  };

}

function popoverCtrl2($scope2) {

  $scope2.showPopover2 = false;

  $scope2.popover2 = {
    title: 'Test',
    message: 'Sample'
  };
}
</code>```

Here is what I have done so far http://jsfiddle.net/fn1aj1e6/

答:
You have to first create the module using the AngularJS function angular.module. For example:

```<code>    var myApp = angular.module('app', []);

    myApp.controller('YourController', function ($scope) {
        //Your code
    });
</code>```

Then in the HTML do it as,

```<code>    <div ng-app="app">...</div>
</code>```

Body:
I am new to this, can you help me figure out why my dropdown is not displaying properly and also the popover of the second value of dropdown is not working properly?
I am a bit confuse since it is my first time trying this.
Here is my code

    Menu

        Real Account
{{ popover.title }}{{ popover.message }}

        Practice Account
{{ popover2.title }}{{ popover2.message }}

and my JS

function popoverCtrl($scope) {

  $scope.showPopover = false;

  $scope.popover = {
    title: 'Title',
    message: 'Message'
  };

}

function popoverCtrl2($scope2) {

  $scope2.showPopover2 = false;

  $scope2.popover2 = {
    title: 'Test',
    message: 'Sample'
  };
}

Here is what I have done so far http://jsfiddle.net/fn1aj1e6/

Body:
You have to first create the module using the AngularJS function angular.module. For example:

    var myApp = angular.module('app', []);

    myApp.controller('YourController', function ($scope) {
        //Your code
    });

Then in the HTML do it as,

    <div ng-app="app">...</div>


问:
addCustomView in CRM 2013 lookup
I get an Savedquery With Id = 00000000-0000-0000-0000-000000000000 Does Not Exist message when I set up the custom view to a CRM 2013 Team lookup, whit this code, working in CRM 2011.

```<code>// Set the Owning Team View based on the account selected
function setOwningTeamView(entityFieldName, lookupFieldName, resetSelection) {
  // Get the selected entity
  var account = Xrm.Page.getAttribute(entityFieldName).getValue();

if (account != null) {
    var accid = account[0].id;
    var accname = account[0].name;

    if (resetSelection == true) {
        // reset old selection for Contact
        Xrm.Page.getAttribute(lookupFieldName).setValue(null);
    }

    // use randomly generated GUID Id for the view
    var viewId = "{0CBC820C-7033-4AFF-9CE8-FB610464DBD3}";
    var entityName = "team";

    // give the custom view a name
    var viewDisplayName = "Teams applicable to " + accname + "";

    var accountBU = SDK.REST.retrieveRecordSync(Xrm.Page.getAttribute("a_account").getValue()[0].id, "Account", "OwningBusinessUnit", "");
    var relatedBusinessUnits = SDK.REST.retrieveMultipleRecordsSync("BusinessUnit", "?$select=BusinessUnitId,Name&$filter=a_Type/Value eq 1");
    var FetchXMLBU = "";
    for (var i = 0; i < relatedBusinessUnits.results.length; i++) {
        FetchXMLBU += "<value>" + relatedBusinessUnits.results[i].BusinessUnitId + "</value>"
    }

    debugger;

    // find all contacts where parent customer is the account selected and where the Contact record is active
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
        + "<entity name='team'>"
        + "<attribute name='teamid' />"
        + "<attribute name='name' />"
        + "<attribute name='description' />"
        + "<attribute name='businessunitid' />"
        + "<filter>"
        + "<condition attribute='businessunitid' operator='in'>"
        + "<value>" + accountBU.OwningBusinessUnit.Id + "</value>"
        + FetchXMLBU
        + "</condition>"
        + "</filter>"
        + "</entity>"
        + "</fetch>";

    // build Grid Layout
    var layoutXml = "<grid name='resultset' " +
        "object='1' " +
        "jump='teamid' " +
        "select='1' " +
        "icon='0' " +
        "preview='0'>" +
        "<row name='result' id='teamid'>" +
        "<cell name='name' width='200' />" +
        "<cell name='businessunitid' width='200' />" +
        "<cell name='description' width='400' />" +
        "</row>" +
        "</grid>";

    // add the Custom View to the indicated [lookupFieldName] Control
    Xrm.Page.getControl(lookupFieldName).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
    //The following line is the an unsupported way of disabling the View Picker, currently there is no supported way.
    document.getElementById(lookupFieldName + "_i").setAttribute("disableViewPicker", "1");
    //document.getElementById(lookupFieldName).setAttribute("disableViewPicker", "1");
}
}
</code>```

I suspect that the problem with be with the calls to SDK.REST as explained in this thread, but results in accountBU and  relatedBusinessUnits are correct.

I have using another SDK call aith a correct behavior as:

```<code> var systemUserTeam = SDK.REST.retrieveMultipleRecordsSync("TeamMembership",
                "$select=TeamId&$filter=TeamId eq guid'"
                + Xrm.Page.getAttribute("aux_owningteamid").getValue()[0].id
                + "' and SystemUserId eq guid'"
                + Xrm.Page.getAttribute("ownerid").getValue()[0].id
                + "'");
    if (systemUserTeam.results.length != 1) {
</code>```

I'm setting up a Customer lookup view with custom fetchXML and laoyoutXML with same method except for the calls to SDK.

Which change could I do to the SDK call to get it working?

答:
addCustomView doesn’t work with Owner lookups. Owner lookups are used to assign user-owned records.

Link - https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addCustomView

Title: addCustomView in CRM 2013 lookup

Body:
I get an Savedquery With Id = 00000000-0000-0000-0000-000000000000 Does Not Exist message when I set up the custom view to a CRM 2013 Team lookup, whit this code, working in CRM 2011.

// Set the Owning Team View based on the account selected
function setOwningTeamView(entityFieldName, lookupFieldName, resetSelection) {
  // Get the selected entity
  var account = Xrm.Page.getAttribute(entityFieldName).getValue();

if (account != null) {
    var accid = account[0].id;
    var accname = account[0].name;

    if (resetSelection == true) {
        // reset old selection for Contact
        Xrm.Page.getAttribute(lookupFieldName).setValue(null);
    }

    // use randomly generated GUID Id for the view
    var viewId = "{0CBC820C-7033-4AFF-9CE8-FB610464DBD3}";
    var entityName = "team";

    // give the custom view a name
    var viewDisplayName = "Teams applicable to " + accname + "";

    var accountBU = SDK.REST.retrieveRecordSync(Xrm.Page.getAttribute("a_account").getValue()[0].id, "Account", "OwningBusinessUnit", "");
    var relatedBusinessUnits = SDK.REST.retrieveMultipleRecordsSync("BusinessUnit", "?$select=BusinessUnitId,Name&$filter=a_Type/Value eq 1");
    var FetchXMLBU = "";
    for (var i = 0; i < relatedBusinessUnits.results.length; i++) {
        FetchXMLBU += "<value>" + relatedBusinessUnits.results[i].BusinessUnitId + "</value>"
    }

    debugger;

    // find all contacts where parent customer is the account selected and where the Contact record is active
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
        + "<entity name='team'>"
        + "<attribute name='teamid' />"
        + "<attribute name='name' />"
        + "<attribute name='description' />"
        + "<attribute name='businessunitid' />"
        + "<filter>"
        + "<condition attribute='businessunitid' operator='in'>"
        + "<value>" + accountBU.OwningBusinessUnit.Id + "</value>"
        + FetchXMLBU
        + "</condition>"
        + "</filter>"
        + "</entity>"
        + "</fetch>";

    // build Grid Layout
    var layoutXml = "<grid name='resultset' " +
        "object='1' " +
        "jump='teamid' " +
        "select='1' " +
        "icon='0' " +
        "preview='0'>" +
        "<row name='result' id='teamid'>" +
        "<cell name='name' width='200' />" +
        "<cell name='businessunitid' width='200' />" +
        "<cell name='description' width='400' />" +
        "</row>" +
        "</grid>";

    // add the Custom View to the indicated [lookupFieldName] Control
    Xrm.Page.getControl(lookupFieldName).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
    //The following line is the an unsupported way of disabling the View Picker, currently there is no supported way.
    document.getElementById(lookupFieldName + "_i").setAttribute("disableViewPicker", "1");
    //document.getElementById(lookupFieldName).setAttribute("disableViewPicker", "1");
}
}

I suspect that the problem with be with the calls to SDK.REST as explained in this thread, but results in accountBU and  relatedBusinessUnits are correct.

I have using another SDK call aith a correct behavior as:

 var systemUserTeam = SDK.REST.retrieveMultipleRecordsSync("TeamMembership",
                "$select=TeamId&$filter=TeamId eq guid'"
                + Xrm.Page.getAttribute("aux_owningteamid").getValue()[0].id
                + "' and SystemUserId eq guid'"
                + Xrm.Page.getAttribute("ownerid").getValue()[0].id
                + "'");
    if (systemUserTeam.results.length != 1) {

I'm setting up a Customer lookup view with custom fetchXML and laoyoutXML with same method except for the calls to SDK.

Which change could I do to the SDK call to get it working?


问:
Objects handling logic on Android
Recently I started learning Android (after some introductory course on Java and some Java EE) and I wonder about the mechanism of how objects are passed in Android methods.

For example, when dealing with a standard doGet() method, a HttpServletRequest is passed as an argument and then I can do various actions on it.

But for example with Android's EditText widget, the listener method receives only android.view.View which is not used for text extraction, but instead I have to create an android.widget.EditText object directly in the method's body and and get the text from it.

It seems counterintuitive to me or maybe I miss some understanding of how objects and parameters and transferred in Android?

Thank you!

答:
I assume you are aware of findViewById() method to get reference of any widget in xml file to its associated java class.
Now coming to your point , Let say I want to pass object type of Button in to method .

```<code>public void onClickButton(View view){
    if(view.getId() == R.id.buttonSave){
        // Do something
    } else if(view.getId() == R.id.buttonCancel){
        // Do something else
    }
}
</code>```

Here , we compare our argument with View class object , as View class is the parent of all widgets (Button ,EditText etc..)

Title: Objects handling logic on Android

Body:
I assume you are aware of findViewById() method to get reference of any widget in xml file to its associated java class.
Now coming to your point , Let say I want to pass object type of Button in to method .

public void onClickButton(View view){
    if(view.getId() == R.id.buttonSave){
        // Do something
    } else if(view.getId() == R.id.buttonCancel){
        // Do something else
    }
}

Here , we compare our argument with View class object , as View class is the parent of all widgets (Button ,EditText etc..)


问:
Image does not display on Heroku
I have two images on a static web page in a Ruby on Rails web application. Both images are in the same place:

```<code>/app/assets/images
</code>```

The image tag for both is generated in the same way, barring some attributes:

```<code><%= image_tag("logo.png", alt: "Logo", width: 150) %>

<%= image_tag("image.jpeg", alt: "image", class: "img-responsive") %>
</code>```

Both work fine on the local server, but when I push to production, only the first image displays. The source shows the tag for the second image is not being processed correctly:

```<code><img alt="Logo" width="150" src="/assets/logo-9e9dd9c19ef18b3ef26e23f11d73a8817af6cea78a5d9e1a34691d591a780987.png" />

<img alt="image" class="img-responsive" src="/images/image.jpeg" />
</code>```

I don't understand why one works and the other doesn't?

In terms of context, the first image is PNG and part of the layout, rendered in application.html.erb. The second is part of the page view yielded into application.html.erb. Does that make a difference?

Any pointers in the right direction? Thanks for your help.

Regards,

Jonathan

答:
The problem really is that your assets are not precompiled to work on production.

For a little explanation and lesson to learn from as a newbie, Rails comes bundled with a task to compile the asset manifests and other files in the pipeline.

Compiled assets are written to the location specified in config.assets.prefix. By default, this is the /assets directory.

You can call this task on the server during deployment to create compiled versions of your assets directly on the server.

You can run the task below from your terminals for your images or assets to show on production and redeploy to heroic:

RAILS_ENV=production bin/rails assets:precompile

For more read-up, kindly refer to Rails Documentations on Precompiling Assets

I hope this helps a little for your to learn.

Title: Image does not display on Heroku

Body:
I have two images on a static web page in a Ruby on Rails web application. Both images are in the same place:

/app/assets/images

The image tag for both is generated in the same way, barring some attributes:

<%= image_tag("logo.png", alt: "Logo", width: 150) %>

<%= image_tag("image.jpeg", alt: "image", class: "img-responsive") %>

Both work fine on the local server, but when I push to production, only the first image displays. The source shows the tag for the second image is not being processed correctly:

I don't understand why one works and the other doesn't?

In terms of context, the first image is PNG and part of the layout, rendered in application.html.erb. The second is part of the page view yielded into application.html.erb. Does that make a difference?

Any pointers in the right direction? Thanks for your help.

Regards,

Jonathan


问:
Ruby on Rails with REST API
I am new to the Ruby on Rails thing, and while I like the organization and standards provided, I am a little confused on how to make rails work for me in this specific case.

I have a Webservice that I want to use my rails application with. Making a direct connection to the database would be nice and provide me instantly with the models I need to make my Rails application work.

However, I would have to replicate all of the logic provided by the webservice(which isn't trivial). If I didn't make a direct connection to the database, how would I persist the models(such as a user model).

Would I have to make a separate database that mimics the server's DB but never actually interacts with it directly?

Thanks in advance -- let me know if you need clarification.

EDIT: Example

I have a rails app that gets on URL www.mywebservice:8080.com/users/5

Service returns JSON {name:foo,nick:bar,friend:baz}

At this point how do I tell rails to make a User object out of what it just got and then store it in the database? Or do is there a way to persist this JSON object?

答:
ActiveResource handles your use case just fine http://api.rubyonrails.org/classes/ActiveResource/Base.html

What it does is reflect on the json returned by the service and fake out the object to make it look like it's a real object.

```<code>class User < ActiveResource::Base
end

user = User.find(1)
puts user.name
# "scott"
</code>```

Title: Ruby on Rails with REST API

Body:
ActiveResource handles your use case just fine http://api.rubyonrails.org/classes/ActiveResource/Base.html

What it does is reflect on the json returned by the service and fake out the object to make it look like it's a real object.

class User < ActiveResource::Base
end

user = User.find(1)
puts user.name
# "scott"


问:
Upload image to Cloudinary IOS
I can't upload images to Cloudinary hosting via HTTPS POST request, I want to use the simple API methods instead of the SDK. I'm having a problem with formatting the image in a byte array buffer or as Base64 encoded.

Here's my code:

```<code>UIImage *image = [UIImage imageNamed:@"image.png"];
NSData *imageData = UIImagePNGRepresentation(image);
NSString *strImageData = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

NSURL *url = [NSURL URLWithString:@"https://api.cloudinary.com/v1_1/MYSECTER/image/upload"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
NSString *strRequest = [NSString stringWithFormat:@"file=%@&upload_preset=MYSECTER", strImageData];
request.HTTPBody = [strRequest dataUsingEncoding:NSUTF8StringEncoding];

[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

    NSDictionary *recievedData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];

    NSLog(@"RECEIVED: %@", recievedData);

}] resume];
</code>```

Unfortunately I receive the following answer from the server: "Unsupported source URL..."

I really tried a lot of other methods, but I can't get it to work.

UPDATE: When I put URL link at 'file' param all works fine.

答:
You can use Cloudinary's SDK in order to perform an upload image task as explained here: http://cloudinary.com/blog/direct_upload_made_easy_from_browser_or_mobile_app_to_the_cloud

The following code samples show a direct unsigned upload API call in Objective-C for iOS...:

```<code>CLCloudinary *cloudinary = [[CLCloudinary alloc] init];
[cloudinary.config setValue:@"demo" forKey:@"cloud_name"];

NSString *imageFilePath = [[NSBundle mainBundle] pathForResource:@"logo"
ofType:@"png"];

CLUploader* uploader = [[CLUploader alloc] init:cloudinary delegate:self];
[uploader unsignedUpload:imageFilePath uploadPreset:@"zcudy0uz" options:@{}];
</code>```

The following code samples show a more advanced example: specifying a custom public ID of user_sample_image_1002, making it possible to later access the uploaded image, and assigning a tag to simplify management of the images. In addition, we show an example of building a dynamic URL that performs an on-the-fly image manipulation: generating a 150x100 face-detection-based thumbnail of the uploaded images for embedding in your application.

```<code>NSData *imageData = [NSData dataWithContentsOfFile:imageFilePath];

[uploader unsignedUpload:imageData uploadPreset:@"zcudy0uz" options:
[NSDictionary dictionaryWithObjectsAndKeys:@"user_sample_image_1002",
@"public_id", @"tags", @"ios_upload", nil] withCompletion:^(NSDictionary
*successResult, NSString *errorResult, NSInteger code, id context) {

    if (successResult) {

      NSString* publicId = [successResult valueForKey:@"public_id"];
      NSLog(@"Upload success. Public ID=%@, Full result=%@", publicId,
      successResult);
      CLTransformation *transformation = [CLTransformation transformation];
      [transformation setWidthWithInt: 150];
      [transformation setHeightWithInt: 100];
      [transformation setCrop: @"fill"];
      [transformation setGravity:@"face"];

      NSLog(@"Result: %@", [cloudinary url:publicId
      options:@{@"transformation":
      transformation, @"format": @"jpg"}]);

     } else {

         NSLog(@"Upload error: %@, %d", errorResult, code);

      }

 }   andProgress:^(NSInteger bytesWritten, NSInteger totalBytesWritten,
     NSInteger totalBytesExpectedToWrite, id context) {
     NSLog(@"Upload progress: %d/%d (+%d)", totalBytesWritten,
     totalBytesExpectedToWrite, bytesWritten);
 }];
</code>```

Title: Upload image to Cloudinary IOS

Body:
I can't upload images to Cloudinary hosting via HTTPS POST request, I want to use the simple API methods instead of the SDK. I'm having a problem with formatting the image in a byte array buffer or as Base64 encoded.

Here's my code:

UIImage *image = [UIImage imageNamed:@"image.png"];
NSData *imageData = UIImagePNGRepresentation(image);
NSString *strImageData = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

NSURL *url = [NSURL URLWithString:@"https://api.cloudinary.com/v1_1/MYSECTER/image/upload"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
NSString *strRequest = [NSString stringWithFormat:@"file=%@&upload_preset=MYSECTER", strImageData];
request.HTTPBody = [strRequest dataUsingEncoding:NSUTF8StringEncoding];

[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

    NSDictionary *recievedData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];

    NSLog(@"RECEIVED: %@", recievedData);

}] resume];

Unfortunately I receive the following answer from the server: "Unsupported source URL..."

I really tried a lot of other methods, but I can't get it to work.

UPDATE: When I put URL link at 'file' param all works fine.

Body:
You can use Cloudinary's SDK in order to perform an upload image task as explained here: http://cloudinary.com/blog/direct_upload_made_easy_from_browser_or_mobile_app_to_the_cloud

The following code samples show a direct unsigned upload API call in Objective-C for iOS...:

CLCloudinary *cloudinary = [[CLCloudinary alloc] init];
[cloudinary.config setValue:@"demo" forKey:@"cloud_name"];

NSString *imageFilePath = [[NSBundle mainBundle] pathForResource:@"logo"
ofType:@"png"];

CLUploader* uploader = [[CLUploader alloc] init:cloudinary delegate:self];
[uploader unsignedUpload:imageFilePath uploadPreset:@"zcudy0uz" options:@{}];

The following code samples show a more advanced example: specifying a custom public ID of user_sample_image_1002, making it possible to later access the uploaded image, and assigning a tag to simplify management of the images. In addition, we show an example of building a dynamic URL that performs an on-the-fly image manipulation: generating a 150x100 face-detection-based thumbnail of the uploaded images for embedding in your application.

NSData *imageData = [NSData dataWithContentsOfFile:imageFilePath];

[uploader unsignedUpload:imageData uploadPreset:@"zcudy0uz" options:
[NSDictionary dictionaryWithObjectsAndKeys:@"user_sample_image_1002",
@"public_id", @"tags", @"ios_upload", nil] withCompletion:^(NSDictionary
*successResult, NSString *errorResult, NSInteger code, id context) {

    if (successResult) {

      NSString* publicId = [successResult valueForKey:@"public_id"];
      NSLog(@"Upload success. Public ID=%@, Full result=%@", publicId,
      successResult);
      CLTransformation *transformation = [CLTransformation transformation];
      [transformation setWidthWithInt: 150];
      [transformation setHeightWithInt: 100];
      [transformation setCrop: @"fill"];
      [transformation setGravity:@"face"];

      NSLog(@"Result: %@", [cloudinary url:publicId
      options:@{@"transformation":
      transformation, @"format": @"jpg"}]);

     } else {

         NSLog(@"Upload error: %@, %d", errorResult, code);

      }

 }   andProgress:^(NSInteger bytesWritten, NSInteger totalBytesWritten,
     NSInteger totalBytesExpectedToWrite, id context) {
     NSLog(@"Upload progress: %d/%d (+%d)", totalBytesWritten,
     totalBytesExpectedToWrite, bytesWritten);
 }];


问:
Some confusion about Slice[::]
```<code>alphabet='abide'
>>>alphabet[-1::-1]
'ediba'
>>>alphabet[::-1]
'ediba'
</code>```

Why did this two print out the same thing?
Shouldn't the second one be 'aedib'?

答:
```<code>alphabet[::-1]
</code>```

Will reverse your string. Why? There is no value before the first colon, so it stats at the beginning index of the list. Then, still no value, so you go all the way to the end of the list. Third, you have -1, so you increment by -1, in other words you are going backwards.

It is equivalent to alphabet[-1::-1] since you just ask to start from the final character, which it already does.

Title: Some confusion about Slice[::]

Body:
alphabet='abide'
>>>alphabet[-1::-1]
'ediba'
>>>alphabet[::-1]
'ediba'

Why did this two print out the same thing?
Shouldn't the second one be 'aedib'?

Body:
alphabet[::-1]

Will reverse your string. Why? There is no value before the first colon, so it stats at the beginning index of the list. Then, still no value, so you go all the way to the end of the list. Third, you have -1, so you increment by -1, in other words you are going backwards.

It is equivalent to alphabet[-1::-1] since you just ask to start from the final character, which it already does.


问:
How to customize the default scrollbar on the pdf document?
How can I customize the default scrollbar that browser shows on pdf file?</p>

```<code><object data="/pdf/sample.pdf" type="application/pdf" width="100%" height="100%">
   <p><b>Example fallback content</b>: This browser does not support PDFs. Please download the PDF to view it: <a href="/pdf/sample.pdf">Download PDF</a>.</p>
</object>
</code>```

答:
It is unclear which scroll bar you're talking about. Is it part of the browser or part of the PDF viewer? More importantly: Which browser and viewer are you using?

Suppose you're using Adobe's PDF viewer, then you can add an argument to the url like this:

data="/pdf/sample.pdf?scrollbar=0"

See: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf

This can however have no effect when using other pdf viewers. More so, the scroll bars are often there for a good reason.

Activating touch mode can also remove the scroll bar in some viewers.

Basically you don't have much control over this.

Your real question is about customization. This could mean a lot of things, for instance making the scroll bar wider, changing its color, etc. Clearly this cannot be easily done when the scroll bar is part of the viewer.

Lastly, the message; 'This browser does not support PDFs.', is not entirely accurate. It will also be shown if the PDF file doesn't exist.

EDIT:

This works to get rid of the extra scroll bar in Chrome:

```<code><html>
<body style="overflow:hidden;margin:0">
<object data="sample.pdf" type="application/pdf" width="100%" height="100%">
   <p>Error!</p>
</object>
</body>
</html>
</code>```

Body:
How can I customize the default scrollbar that browser shows on pdf file?

<object data="/pdf/sample.pdf" type="application/pdf" width="100%" height="100%">

Example fallback content: This browser does not support PDFs. Please download the PDF to view it: Download PDF.

</object>

Body:
It is unclear which scroll bar you're talking about. Is it part of the browser or part of the PDF viewer? More importantly: Which browser and viewer are you using?

Suppose you're using Adobe's PDF viewer, then you can add an argument to the url like this:

data="/pdf/sample.pdf?scrollbar=0"

See: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf

This can however have no effect when using other pdf viewers. More so, the scroll bars are often there for a good reason.

Activating touch mode can also remove the scroll bar in some viewers.

Basically you don't have much control over this.

Your real question is about customization. This could mean a lot of things, for instance making the scroll bar wider, changing its color, etc. Clearly this cannot be easily done when the scroll bar is part of the viewer.

Lastly, the message; 'This browser does not support PDFs.', is not entirely accurate. It will also be shown if the PDF file doesn't exist.

EDIT:

This works to get rid of the extra scroll bar in Chrome:

<html>
<body style="overflow:hidden;margin:0">
<object data="sample.pdf" type="application/pdf" width="100%" height="100%">
   <p>Error!</p>
</object>
</body>
</html>