FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WpkgNotifier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yusuf Hamied Department of Chemistry
COs
wpkg
WpkgNotifier
Commits
70368ab9
Commit
70368ab9
authored
4 years ago
by
Dr Adam Thorn
Browse files
Options
Downloads
Patches
Plain Diff
Add WpkgInstaller.RunWpkgSync() method
parent
0047227b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
WpkgInstaller/WpkgInstaller.cs
+51
-0
51 additions, 0 deletions
WpkgInstaller/WpkgInstaller.cs
with
51 additions
and
0 deletions
WpkgInstaller/WpkgInstaller.cs
+
51
−
0
View file @
70368ab9
...
...
@@ -2,6 +2,7 @@
using
System.ServiceProcess
;
using
System.Diagnostics
;
using
System
;
using
System.Threading
;
namespace
WpkgInstaller
{
...
...
@@ -81,6 +82,56 @@ namespace WpkgInstaller
eventLog
.
WriteEntry
(
"Service stopped"
,
EventLogEntryType
.
Information
);
}
private
void
RunWpkgSync
()
{
eventLog
.
WriteEntry
(
"Starting sync"
,
EventLogEntryType
.
Information
);
Thread
thWorker
=
new
Thread
(
new
ThreadStart
(
delegate
{
Process
process
=
new
Process
();
ProcessStartInfo
startInfo
=
new
ProcessStartInfo
()
{
RedirectStandardInput
=
true
,
RedirectStandardOutput
=
true
,
RedirectStandardError
=
true
,
WindowStyle
=
System
.
Diagnostics
.
ProcessWindowStyle
.
Hidden
,
FileName
=
Environment
.
GetEnvironmentVariable
(
"comspec"
),
Arguments
=
"/C \\\\wpkg.ch.cam.ac.uk\\wpkg\\wpkg.cmd /synchronize"
,
WorkingDirectory
=
Environment
.
GetEnvironmentVariable
(
"temp"
),
UseShellExecute
=
false
,
};
process
.
StartInfo
=
startInfo
;
process
.
EnableRaisingEvents
=
true
;
process
.
OutputDataReceived
+=
WriteDataToLog
;
process
.
ErrorDataReceived
+=
WriteDataToLog
;
process
.
Start
();
process
.
BeginErrorReadLine
();
process
.
BeginOutputReadLine
();
process
.
WaitForExit
();
String
msg
=
String
.
Format
(
"sync done with exit code {0}"
,
process
.
ExitCode
);
eventLog
.
WriteEntry
(
msg
,
EventLogEntryType
.
Information
);
}));
thWorker
.
Start
();
}
private
void
WriteDataToLog
(
object
sendingProcess
,
DataReceivedEventArgs
e
)
{
if
(
e
!=
null
)
{
eventLog
.
WriteEntry
(
e
.
Data
,
EventLogEntryType
.
Information
);
}
}
private
void
eventLog_EntryWritten
(
object
sender
,
System
.
Diagnostics
.
EntryWrittenEventArgs
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment