초기커밋
This commit is contained in:
63
ServerBase/Helper/VersionHelper.cs
Normal file
63
ServerBase/Helper/VersionHelper.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
namespace ServerBase;
|
||||
|
||||
public static class VersionHelper
|
||||
{
|
||||
public static (Result result, int buildVersion,int revisionVersion) tryReadVersion(string filePath)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var build_version = 0;
|
||||
var revision_version = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
using (var stream = new StreamReader(filePath))
|
||||
{
|
||||
while (stream.Peek() >= 0)
|
||||
{
|
||||
var line = stream.ReadLine();
|
||||
|
||||
if (line == null)
|
||||
break;
|
||||
|
||||
if (line.IndexOf("Build:") >= 0)
|
||||
{
|
||||
var version = line.Replace("Build:", "");
|
||||
build_version = int.Parse(version);
|
||||
}
|
||||
else if (line.IndexOf("Revision:") >= 0)
|
||||
{
|
||||
var version = line.Replace("Revision:", "");
|
||||
revision_version = int.Parse(version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var err_msg = $"Exception !!!, Failed to perform in tryReadVersion() !!! : exception:{e} - filePath:{filePath}";
|
||||
result.setFail(ServerErrorCode.TryCatchException, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, 0, 0);
|
||||
}
|
||||
|
||||
return (result, build_version, revision_version);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user