Record the development and background construction of a public account, and set up a Public Account
I. background
Shortly after entering the new company, I met a colleague who was about to leave and handed over the project to me. My colleagues' departure was too hasty, so the handover was not very good, which is also an objective cause of many problems. As shown in the project, the front-end adopts vue. js + node. js development, and the c # development interface is used in the background. You also need to develop a c # website to display data. In the previous job, we used erp and powerbuilder. Therefore, this project involves a lot of unfamiliar knowledge.
Ii. Problems Encountered
1. Build a test environment
The setup of the test environment is still quite troublesome (for beginners), but I don't know what to write when I look back. I 'd like to find a tutorial on the Internet.
2. if you want to download a specified path for recording upload/download, you must first upload the recording to the server and then download it to your target path based on the returned serverId (I .e. the downloaded MEDIA_ID, if there is no problem in the test environment, there is basically no problem according to this. However, debugging and other problems are troublesome and can only be viewed by writing logs. An interface is provided for testing. You can enter parameters to obtain the error message.
/// <SUMMARY> /// download and save the multimedia file, back to multimedia storage path // </SUMMARY> /// <PARAM name = "ACCESS_TOKEN"> </PARAM> /// <PARAM name = "MEDIA_ID"> </PARAM >/// <RETURNS> </RETURNS> public string GetMultimedia (string ACCESS_TOKEN, string MEDIA_ID) {string file = string. empty; string strpath = string. empty; string stUrl = Common. textHelper. WXUploadMediaUrl + "? Access_token = "+ ACCESS_TOKEN +" & media_id = "+ MEDIA_ID; HttpWebRequest req = (HttpWebRequest) HttpWebRequest. create (stUrl); req. method = "GET"; using (WebResponse wr = req. getResponse () {HttpWebResponse myResponse = (HttpWebResponse) req. getResponse (); strpath = myResponse. responseUri. toString (); WebClient mywebclient = new WebClient (); string basePath = AppDomain. currentDomain. baseDirectory + "Attachment"; // temporary Attachment storage path string amrFile = DateTime. now. toString ("yyyyMMddhhmmssms") + ". amr "; string mp3File = DateTime. now. toString ("yyyyMMddhhmmssms") + ". mp3 "; try {mywebclient. downloadFile (strpath, Path. combine (basePath, amrFile); ConvertToMp3 (Path. combine (basePath, amrFile), Path. combine (basePath, mp3File); file = mp3File; // file = amrFile;} catch (Exception ex) {// savepath = ex. toString () ;}} return file ;}View Code
For more information, see http://www.cnblogs.com/zhangs1986/p/3636234.html3.the recording format is used to convert files in amr format. The webpage cannot be played, so you need to convert them into MP3 format. When I started using it, I encountered an embarrassing situation where MP3 can be converted to wav, but amr cannot be converted to mp3. After a long time, after checking, we found that the amr file used for testing has crashed. This story tells us to be careful. If you have any problems, you don't have to worry about it. Take a deep breath and check it again from the beginning. You may be rewarded.
Public string ConvertToMp3 (string pathBefore, string pathLater) {string c = System. web. httpContext. current. server. mapPath ("/ffmpeg/") + @ "ffmpeg.exe-I" + pathBefore + "" + pathLater; log. writeLine (c); string str = RunCmd (c); return str ;} /// <summary> /// execute the Cmd command /// </summary> private string RunCmd (string c) {try {ProcessStartInfo info = new ProcessStartInfo ("cmd.exe "); info. redirectStandardOutput = false; info. useShellExecute = false; Process p = Process. start (info); p. startInfo. useShellExecute = false; p. startInfo. redirectStandardInput = true; p. startInfo. redirectStandardOutput = true; p. startInfo. redirectStandardError = true; p. start (); p. standardInput. writeLine (c); p. standardInput. autoFlush = true; Thread. sleep (1000); p. standardInput. writeLine ("exit"); p. waitForExit (); string outStr = p. standardOutput. readToEnd (); p. close (); return outStr;} catch (Exception ex) {return "error" + ex. message ;}}View Code reference document: http://www.cnblogs.com/LittleBai/p/5924416.html 4. the path is correct, but the information submitted by the Public Account of the attachment (iis mine type configuration) cannot be obtained, including images, audios, and videos. After being uploaded to the server, they are all placed in the same folder, however, when the web page is displayed, images can be accessed, while audio and video prompts that images cannot be accessed. I asked the old man to know that the mine type on iis needs to be configured. Since I did not develop web pages or even c #, many pitfalls have not been step on yet. I can only step on them one by one to make my memory better. Experience is probably a lot of pitfalls! 5. There is nothing to say about image rotation. It's just a simple implementation of image rotation.
Function rotate (row) {var deg = eval ('get' + $ ("#" + row).css ('transform'); // construct the getmatrix function, returns the last degree of rotation var step = 90; // how many degrees of rotation each time $ ("#" + row).css ({'transform': 'rotate ('+ (deg + step) % 360 + 'deg) '});} function getmatrix (a, B, c, d, e, f) {var aa = Math. round (180 * Math. asin (a)/Math. PI); var bb = Math. round (180 * Math. acos (B)/Math. PI); var cc = Math. round (180 * Math. asin (c)/Math. PI); var dd = Math. round (180 * Math. acos (d)/Math. PI); var deg = 0; if (aa = bb |-aa = bb) {deg = dd;} else if (-aa + bb = 180) {deg = 180 + cc;} else if (aa + bb = 180) {deg = 360-cc | 360-dd;} return deg >= 360? 0: deg; // return (aa + ',' + bb + ',' + cc + ',' + dd );}View Code
Reference: http://m.blog.csdn.net/cengjingcanghai123/article/details/53537242
Iii. Summary
It took nearly a month to complete the task. There are many shortcomings, such as the ugly front-end style thief (although I am not the front-end, but small companies can only accept and store both sides). For example, the efficiency is slightly lower (this is because I did pb before, c # although there is a foundation, there is not much development experience ). In general, I am still satisfied with my performance. After all, I am not familiar with all the things involved. If I can complete the task in a month, I 'd like to score 60! My advantage lies in the logic capability and database (the previous job was done with erp and abused), and the disadvantages are also obvious (the foundation is not good enough, so I still need to fill in the Foundation ), hope to make persistent efforts! If the article I wrote can solve some of the problems of a ape, I would be very happy if some ape could step on a pitfall! I am not good at writing, so I am so embarrassed. Please abuse me!