Category Archives: How to Fix

C # generate data in DataGridView into XML file

Development environment: VS2019
code directly without more b words

  private void button1_Click(object sender, EventArgs e)
        {
           
            DataTable dt = GetDataGridView(dataGridView1);
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            ds.WriteXml(File.OpenWrite(@"D:\emlout.xml"));
            MessageBox.Show("export xml file success", "note", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

Print regularly to activate the printer (for some printers that need to be activated to print)

Save the following code as prtxls.vbs, and then you can use it on the command line, such as printing a.xlsx under C drive with the command prtxls.vbs c:\a.xlsx
Dim objxls
On error resume next.
Set objxls = wscript getobject (” Excel. Application “)
If objxls = “” then.
Set objxls = wscript createobject (” Excel. Application”)
end If
the If Wscript.argument.count = 0 then
msgBox (” There are not enough arguments.”)
cript.quit
e>f
objxls.>books.open wscript.arguments(0),false
if objxls.wor>ks.count = 0 then
Wscript.quit
Else
objxls.workbooks(1).printout
objxls.quit
End if
wscript.quit


So that’s the code

prtxls.vbs c:\a.xlsx
: \a.xlsx
c:\a.xlsx
Note: A. Xlsx must add content, otherwise the printer will not print the content because it is empty.

Git prompts another git process sees to be running in this repository, e.g. an editor opened by

Another git process seems to be running in this repository, e.g. An editor is opened by ‘git commit’. Please make sure all processes are terminated then try again. a git process may have crashed in this repository earlier: remove the file manually to continue.

Another Git process appears to be running in this repository, such as the editor opened by ‘git commit’. Make sure all processes are terminated and try again. If it still fails, then a Git process may have crashed earlier in the repository: manually delete the file to continue.
If you have an editor with the “git commit” command on, close all git related processes and try again. If not, delete the file manually.
Windows for the process of synchronous mutually exclusive management, there is a resource lock mechanism. There must be a process to lock a resource, but because the process suddenly crashed, not in time to unlock, resulting in other processes can not access
We delete a mutex file on the line, into the workspace directory under the hidden file. Git, where the index.lock file deleted, the problem solved.

The time of the time database displayed by the front end is inconsistent

These days I have encountered a huge pit. The time of data storage is 2 o ‘clock, but the time displayed on the front page is 16 o ‘clock, which is 14 hours short.
Describe the project background, the service is in the US, the project is a Mexican project, the database time and server time have been set to the Mexican time zone, but it is still not correct.
I have asked the project boss in the middle, and the boss gave me the opinion that the time zone was set on the URL of connecting data, but the front-end page was still not displayed correctly.
After several times of locating, the time to find it directly in the dev location will change. This is because the computer’s time zone is the Chinese time zone. But the time log is still on the server, the log time is correct. So guess the front-end is the time zone problem.
Because the last segment passes the timestamp, the timestamp has no time zone. So the front end also needs to change the time zone to correspond

  id : "crete_time",
		            renderer : function(idValue,value,record){
                        return value ?moment(value).tz("America/Guatemala").format("YYYY-MM-DD HH:mm:ss") : "---";
			        }

You can set the time zone using the Moment.tz method

Generate template asp.net Cs1010: newline in constant

compiler error message: CS1010: constants of line breaks
the source error:

Solutions:
Method 1: Open the corresponding template that will prompt “inconsistent line end “, select” Yes “, save → generate
Method 2: When you have written the template, press the formatting code shortcut key Ctrl+K+D

>

ASP.NET How to deal with “unexpected character” when writing code

Compiler error message: CS1056: Handling of unexpected characters

error generated:

An “unexpected character” error occurred in C# code while compiling an ASP. NET 4.0 website using VS2010.

does not use UTF-8 format for display and save, the compiler can not correctly recognize such characters, resulting in compilation error.

:

set the file open mode of VS 2010, make it in view of the error file using utf-8 format to open. The specific operation is as follows:

1) In Solution Explorer, select the file you want to open

2) Right mouse button pops up the menu, select “Open mode”, and use “Charp editor with encoding function” to open it. As shown in the figure below:

Instead, select the following in the code:

then rebuild the solution, error elimination.

Compiler error message: cs1056: unexpected character handling

Error generation:
always returns an error when compiling a pre-existing program code using VS2015. strange In some added to the end of the class file some [] [] [] [], prompt Unexpected character, ‘application error.

A compilation error as shown in the title was caused by a special full-corner character in C# code. > special full-corner characters are not displayed and saved in UTF-8 format, and the compiler cannot correctly recognize such characters, resulting in compilation errors.

solution:
set the file open mode of VS 2015, make it contains a file with the Angle of all special characters use utf-8 format to open.
>
1) In Solution Explorer, select the file that needs special opening. 2) Right-click the mouse button to pop up the menu, select “Open Mode”, and use “Charp Editor with Encoding” to open.

Reproduced in: https://blog.51cto.com/studybao/2048899

Command failed: NPM install — loglevel error — registry= https://registry.npm.taobao.org

Use the vue – cli create project has the following error: the command failed: NPM install – loglevel error – registry=https://registry.npm.taobao.org – disturl=https://npm.taobao.org/dist

the solution has the following kinds:
Make sure that the vue-cli, NPM, node, Versions had better high node must be
1. 8 + NPM install chromedriver – chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
finished to recreate the project (this approach is not once and for all)
2. NPM cache clean — force Clear the NPM cache (if it doesn’t work, it’s not a cache problem)
3. If the above two steps or not To install the following taobao source
NPM install – g CNPM – registry=https://registry.npm.taobao.org
4. Find your computer C: \ Users \ Administrator found. vuerc the file
initial is true instead of false can

Vue init webpack command error Vue cli / node_ modules/_ [email protected]@rimraf/rimraf.js :313

This is a low-level error in Vue development that can be encountered but is shared here so that it can be resolved if encountered
To explain the development environment in which this problem occurs: native Mac + NVM-managed node uses Node V8.0.0 to install vue-cli globally: NPM install vue-cli-g

Error is as follows

/Users/weiyongqiang/.nvm/versions/node/v9.2.0/lib/node_modules/vue-cli/node_modules/[email protected]@rimraf/rimraf.js:313
        throw er
        ^

Error: EACCES: permission denied, unlink '/Users/weiyongqiang/.vue-templates/webpack/.gitignore'

Error analysis
This problem is actually relatively simple. The intuitive error is that an exception is thrown on line 313 of rimraf.js. Exploring the cause of this problem requires understanding the role of rimraf.js. It uses the rm -rf command of Unix for deep package deletions. RM-RF is required to operate the corresponding permissions.
Error resolution
Run the vue command with sudo

sudo vue init webpack

Although the solution to this problem is very simple but I believe that many people will encounter, the use of Windows system, of course, will not appear the problem of authority.

Error: ~ /. Vuerc may be updated. Please delete it and re run vuercli in manual mode

Recently ready to develop an H5 sharing service, found the new version of Vue CLI4.0 is a lot of pit
First: My local @vue CLI version is 4.5.11:

 
Later, due to the tight schedule of the project, I directly reduced the local CLI version to 3.0, but because of my mistake, I made a mistake when creating the Vue project, but don’t worry:

Just find the local user directory C disk to find a.vuerc file deleted on the OK

Image proxy settings Flash + JavaScript

The article directories
Problem description idea specific implementation front end back end

Problem description
If is request http://www.example.com/image1.png picture originally, now ask for pictures, https://www.petal.social/image/www.example.com/image1.png you will need to do an image proxy
(request pictures to our own when the server request, then our HTTP server request images, the result of the HTTP in the way back to the web site of the HTTPS)
Train of thought
First, add an API locally for the front-end request that returns the modified image URL
The specific implementation
The front end
Original version:

showImage(url) {
    if (url.startsWith('http://')) {
        if (url.includes('qpic.cn') || url.includes('gtimg.cn')) {
            return url.replace('http://', 'https://')
        } else {
            return return 'https://demo.cloudimg.io/v7/' + url
        }
    } else {
        return url
    }
}

Image URL contains /, so in Flask is mistaken for routing calls, so you need to for the original URL with Base64 encryption
modify after:

import {Base64} from 'js-base64'
const BASE_URL = 'http://localhost:5000'
// const BASE_URL = 'https://www.petal.social'
showImage(url) {
    if (url.startsWith('http://')) {
        if (url.includes('qpic.cn') || url.includes('gtimg.cn')) {
            return url.replace('http://', 'https://')
        } else {
            return BASE_URL + '/api/v1/image/' + Base64.encode(url)
        }
    } else {
        return url
    }
}

The back-end

from flask_restplus import Namespace, Resource
from flask import request, make_response
from maintenance import check_maintenance, not_under_maintenance
import requests
from flask import Response, stream_with_context
import base64
image_api = Namespace('image', description='image related public interface')

@image_api.route('/<image_url>')
@image_api.param('image_url', 'The original image url')
class Image(Resource):
    @image_api.doc('get_image_url')
    @not_under_maintenance
    def get(self, image_url):
        check_maintenance()
        image_url = base64.b64decode(image_url)
        res = requests.get(image_url, stream = True)
        return Response(stream_with_context(res.iter_content(2048)), content_type = res.headers['content-type'])