I have designed some notes in the online library (the separation and conversion business of the Online Library Series III)

Source: Internet
Author: User

Hello everyone, the first and second editions of the Online Library series have already described the ideas of online library and the details of document conversion. It seems that this is not enough. When is the document converted? Is it human conversion? Or is it automatically converted by a computer? Next, we propose a solution to this problem. I have passed the test and verified the feasibility of each method.

1. Conversion business:

(1) manual conversion:

Upload files by users-> document editors review the documents uploaded by users. And set the review ID-> the administrator should switch the documents that have passed the review at the selected time

(2) Computer conversion:

Upload files to the user-> Computer preliminary review-> Computer startup document Conversion Program to convert files-> start the process monitoring service at the same time, close the deadlock Conversion Program, and release memory resources

Supplement: Throughout the document business, we hope to join the reporting business, that is, reporting bad documents. (Administrators can manage the reported documents)

2. Business Implementation Details:

(1) Increase the first type of business. Due to the need to increase the corresponding review work and investment in manpower, the first type of business is not considered for the moment.

(2) Let's focus on the second business form.

The computer starts the document Conversion Program to convert the document: In this step, we can write a windows service and set the service execution time, that is, each service receives an extra entry every other time. As for the document conversion details, I already have

"I have published some notes in the design of online library (Online Library Series II document conversion. If you have any questions about the preparation of the windows Service Program, Google will learn about it first. I will also explain the preparation of the windows Service in my blog later.

Key 1: Because the conversion program started by windows is installed on the server, it is a desktop program. So here we need to emphasize the service settings. Right-click the service, select properties, and select "allow service and desktop interaction. In this way, the service can start the document conversion program normally when running.

Key 2: A Conversion error occurs when the Conversion Program encounters a malicious file uploaded by the user, and the process is dead. This will cause a large amount of resources to be wasted and occupied by the server. To make rational use of resources, we also need to compile a Process Monitoring Service to specifically monitor the corresponding dead processes.

The Process Monitoring Program is as follows:

Partial class ProcessManager: ServiceBase
{
Private static readonly ILog log = LogManager. GetLogger (System. Reflection. MethodBase. GetCurrentMethod (). DeclaringType );

Public ProcessManager ()
{
InitializeComponent ();
}

Protected override void OnStart (string [] args)
{
MyTime. Interval = 600000; // every 10 minutes
MyTime. Start ();
}

Protected override void OnStop ()
{
MyTime. Stop ();
MyTime. Dispose ();
}

Private void TimerEventProcessor (object sender, System. Timers. ElapsedEventArgs e)
{
Log. Info ("Execution Process Management! ");
Try
{
Foreach (Process thisproc in Process. GetProcessesByName ("WINWORD "))
{
TimeSpan oTime = DateTime. Now. Subtract (thisproc. StartTime );

If (oTime. Minutes> = 1) // if the Enabled Program fails to run within 10 Minutes, it is forcibly disabled to release resources.
Thisproc. Kill (); // end the process
}
}
Catch (Exception ex)
{
Log. Info (ex. Message );
}
}
}

With these two services, we can automate document conversion and ensure that server resources are not wasted.

Separating the document conversion process from windows Services can separate user uploads from the document conversion function. This function is independent and reduces dependencies. At the same time, it also greatly enhances the user experience. How about the second business form!

Now, I will write it here today. In the next article, I will focus on the presentation of swf files, that is, document playback.

Thank you for your support. I wish you a good mood every day.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.