コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: JoeChen999/scut
        protected void OnExportAllClientCode(object sender, EventArgs e)
        {
            try
            {
                string type         = ddClientCodeType.Text;
                int    slnId        = ddlSolution.Text.ToInt();
                int    agreementId  = ddlAgreement.Text.ToInt();
                int    versionId    = ddVersion.Text.ToInt();
                bool   isSelfAction = ckSelfAction.Checked;

                List <ZipFileInfo>   zipFileList  = null;
                List <ContractModel> contractList = DbDataLoader.GetContractByAgreement(slnId, agreementId, versionId);
                if (type == "Lua")
                {
                    var codeBuild = new StringBuilder("");
                    zipFileList = new List <ZipFileInfo>();
                    var clientTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ClientLuaCode.txt"));
                    foreach (var model in contractList)
                    {
                        if (!model.Complated)
                        {
                            continue;
                        }
                        int contractId = model.ID;
                        var tileName   = GetTileName(model.ID, model.Descption);
                        List <ParamInfoModel> requestParams;
                        List <ParamInfoModel> responseParams;
                        GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                        codeBuild.AppendLine(TemplateHelper.FromatClientLuaTemp(clientTemp, contractId, responseParams, requestParams, tileName));
                        codeBuild.AppendLine();
                    }
                    zipFileList.Add(new ZipFileInfo()
                    {
                        Name = "actionLayer.lua", Content = codeBuild.ToString()
                    });
                }
                else if (type == "Quick")
                {
                    var sendCodeBuild    = new StringBuilder("");
                    var receiveCodeBuild = new StringBuilder();
                    sendCodeBuild.AppendLine(@"
local Request = class(""Request"")
function Request:ctor()
    
end
");
                    receiveCodeBuild.AppendLine("local Response = {}");
                    receiveCodeBuild.AppendLine("Response.Success = 0");
                    var clientSendTemp    = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ClientQuickCode-S.txt"));
                    var clientReceiveTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ClientQuickCode-R.txt"));
                    foreach (var model in contractList)
                    {
                        if (!model.Complated)
                        {
                            continue;
                        }
                        int contractId = model.ID;
                        var tileName   = GetTileName(model.ID, model.Descption);
                        List <ParamInfoModel> requestParams;
                        List <ParamInfoModel> responseParams;
                        GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                        sendCodeBuild.AppendLine(TemplateHelper.FromatClientQuickSendTemp(clientSendTemp, contractId, responseParams, requestParams, tileName));
                        receiveCodeBuild.AppendLine(TemplateHelper.FromatClientQuickReceiveTemp(clientReceiveTemp, contractId, responseParams, requestParams, tileName));
                    }
                    sendCodeBuild.AppendLine("return Request");
                    receiveCodeBuild.AppendLine("return Response");
                    zipFileList = new List <ZipFileInfo>();
                    zipFileList.Add(new ZipFileInfo()
                    {
                        Name = "Request.lua", Content = sendCodeBuild.ToString()
                    });
                    zipFileList.Add(new ZipFileInfo()
                    {
                        Name = "Response.lua", Content = receiveCodeBuild.ToString()
                    });
                }
                else if (type == "C#")
                {
                    var clientTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"),
                                                                          isSelfAction ? "Template/ClientCsharpSelfCode.txt" : "Template/ClientCsharpCode.txt"));
                    ZipFileInfo zipFile;
                    zipFileList = new List <ZipFileInfo>();

                    foreach (var model in contractList)
                    {
                        if (!model.Complated)
                        {
                            continue;
                        }
                        int contractId = model.ID;
                        zipFile = new ZipFileInfo()
                        {
                            Name = string.Format("Action{0}.cs", contractId)
                        };
                        var tileName = GetTileName(model.ID, model.Descption);
                        List <ParamInfoModel> requestParams;
                        List <ParamInfoModel> responseParams;
                        GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                        zipFile.Content = TemplateHelper.FromatClientCsharpTemp(clientTemp, contractId, responseParams, requestParams, tileName);

                        zipFileList.Add(zipFile);
                    }
                }
                if (zipFileList != null)
                {
                    SaveAsAttachment(string.Format("{0}Action{1}.zip", type, DateTime.Now.ToString("HHmmss")), zipFileList);
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnExportAllClientCode error:{0}", ex);
            }
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: lvshiling/Scut
        protected void OnExportAllSererCode(object sender, EventArgs e)
        {
            try
            {
                string type = ddServerCodeType.Text;
                int slnId = ddlSolution.Text.ToInt();
                int agreementId = ddlAgreement.Text.ToInt();
                int versionId = ddVersion.Text.ToInt();
                bool isSelfAction = ckSelfAction.Checked;

                var slnRecord = DbDataLoader.GetSolution(slnId);
                List<ZipFileInfo> zipFileList = null;
                List<ContractModel> contractList = DbDataLoader.GetContractByAgreement(slnId, agreementId, versionId);

                string serverTemp = string.Empty;
                if (type == "C#")
                {
                    serverTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), isSelfAction ? "Template/ServerCsharpSelfCode.txt" : "Template/ServerCsharpCode.txt"));
                }
                else if (type == "Python")
                {
                    serverTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ServerPythonCode.txt"));
                }
                else if (type == "Lua")
                {
                    serverTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ServerLuaCode.txt"));
                }
                else
                {
                    return;
                }

                ZipFileInfo zipFile;
                zipFileList = new List<ZipFileInfo>();
                string fileExt;
                string content;

                foreach (var model in contractList)
                {
                    int contractId = model.ID;
                    var tileName = GetTileName(model.ID, model.Descption);
                    List<ParamInfoModel> requestParams;
                    List<ParamInfoModel> responseParams;
                    GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                    if (type == "C#")
                    {
                        fileExt = ".cs";
                        content = TemplateHelper.FormatTemp(serverTemp, contractId, responseParams, requestParams, slnRecord, tileName);
                    }
                    else if (type == "Python")
                    {
                        fileExt = ".py";
                        content = TemplateHelper.FormatPython(serverTemp, responseParams, requestParams, slnRecord, tileName);
                    }
                    else if (type == "Lua")
                    {
                        fileExt = ".lua";
                        content = TemplateHelper.FormatLua(serverTemp, contractId, responseParams, requestParams, slnRecord, tileName);
                    }
                    else
                    {
                        break;
                    }
                    zipFile = new ZipFileInfo() { Name = string.Format("Action{0}{1}", contractId, fileExt) };
                    zipFile.Content = content;
                    zipFileList.Add(zipFile);
                }
                if (zipFileList.Count > 0)
                {
                    SaveAsAttachment(string.Format("{0}Action{1}.zip", type, DateTime.Now.ToString("HHmmss")), zipFileList, true);
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnExportAllSererCode error:{0}", ex);
            }

        }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: JoeChen999/scut
        protected void OnExportAllSererCode(object sender, EventArgs e)
        {
            try
            {
                string type         = ddServerCodeType.Text;
                int    slnId        = ddlSolution.Text.ToInt();
                int    agreementId  = ddlAgreement.Text.ToInt();
                int    versionId    = ddVersion.Text.ToInt();
                bool   isSelfAction = ckSelfAction.Checked;

                var slnRecord = DbDataLoader.GetSolution(slnId);
                List <ZipFileInfo>   zipFileList  = null;
                List <ContractModel> contractList = DbDataLoader.GetContractByAgreement(slnId, agreementId, versionId);

                string serverTemp = string.Empty;
                if (type == "C#")
                {
                    serverTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), isSelfAction ? "Template/ServerCsharpSelfCode.txt" : "Template/ServerCsharpCode.txt"));
                }
                else if (type == "Python")
                {
                    serverTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ServerPythonCode.txt"));
                }
                else if (type == "Lua")
                {
                    serverTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ServerLuaCode.txt"));
                }
                else
                {
                    return;
                }

                ZipFileInfo zipFile;
                zipFileList = new List <ZipFileInfo>();
                string fileExt;
                string content;

                foreach (var model in contractList)
                {
                    int contractId = model.ID;
                    var tileName   = GetTileName(model.ID, model.Descption);
                    List <ParamInfoModel> requestParams;
                    List <ParamInfoModel> responseParams;
                    GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                    if (type == "C#")
                    {
                        fileExt = ".cs";
                        content = TemplateHelper.FormatTemp(serverTemp, contractId, responseParams, requestParams, slnRecord, tileName);
                    }
                    else if (type == "Python")
                    {
                        fileExt = ".py";
                        content = TemplateHelper.FormatPython(serverTemp, responseParams, requestParams, slnRecord, tileName);
                    }
                    else if (type == "Lua")
                    {
                        fileExt = ".lua";
                        content = TemplateHelper.FormatLua(serverTemp, contractId, responseParams, requestParams, slnRecord, tileName);
                    }
                    else
                    {
                        break;
                    }
                    zipFile = new ZipFileInfo()
                    {
                        Name = string.Format("Action{0}{1}", contractId, fileExt)
                    };
                    zipFile.Content = content;
                    zipFileList.Add(zipFile);
                }
                if (zipFileList.Count > 0)
                {
                    SaveAsAttachment(string.Format("{0}Action{1}.zip", type, DateTime.Now.ToString("HHmmss")), zipFileList, true);
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnExportAllSererCode error:{0}", ex);
            }
        }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: lvshiling/Scut
        protected void OnExportAllClientCode(object sender, EventArgs e)
        {
            try
            {
                string type = ddClientCodeType.Text;
                int slnId = ddlSolution.Text.ToInt();
                int agreementId = ddlAgreement.Text.ToInt();
                int versionId = ddVersion.Text.ToInt();
                bool isSelfAction = ckSelfAction.Checked;

                List<ZipFileInfo> zipFileList = null;
                List<ContractModel> contractList = DbDataLoader.GetContractByAgreement(slnId, agreementId, versionId);
                if (type == "Lua")
                {
                    var codeBuild = new StringBuilder("");
                    zipFileList = new List<ZipFileInfo>();
                    var clientTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ClientLuaCode.txt"));
                    foreach (var model in contractList)
                    {
                        if (!model.Complated) continue;
                        int contractId = model.ID;
                        var tileName = GetTileName(model.ID, model.Descption);
                        List<ParamInfoModel> requestParams;
                        List<ParamInfoModel> responseParams;
                        GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                        codeBuild.AppendLine(TemplateHelper.FromatClientLuaTemp(clientTemp, contractId, responseParams, requestParams, tileName));
                        codeBuild.AppendLine();
                    }
                    zipFileList.Add(new ZipFileInfo() { Name = "actionLayer.lua", Content = codeBuild.ToString() });
                }
                else if (type == "Quick")
                {
                    var sendCodeBuild = new StringBuilder("");
                    var receiveCodeBuild = new StringBuilder();
                    sendCodeBuild.AppendLine(@"
local Request = class(""Request"")
function Request:ctor()
    
end
");
                    receiveCodeBuild.AppendLine("local Response = {}");
                    receiveCodeBuild.AppendLine("Response.Success = 0");
                    var clientSendTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ClientQuickCode-S.txt"));
                    var clientReceiveTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"), "Template/ClientQuickCode-R.txt"));
                    foreach (var model in contractList)
                    {
                        if (!model.Complated) continue;
                        int contractId = model.ID;
                        var tileName = GetTileName(model.ID, model.Descption);
                        List<ParamInfoModel> requestParams;
                        List<ParamInfoModel> responseParams;
                        GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                        sendCodeBuild.AppendLine(TemplateHelper.FromatClientQuickSendTemp(clientSendTemp, contractId, responseParams, requestParams, tileName));
                        receiveCodeBuild.AppendLine(TemplateHelper.FromatClientQuickReceiveTemp(clientReceiveTemp, contractId, responseParams, requestParams, tileName));

                    }
                    sendCodeBuild.AppendLine("return Request");
                    receiveCodeBuild.AppendLine("return Response");
                    zipFileList = new List<ZipFileInfo>();
                    zipFileList.Add(new ZipFileInfo() { Name = "Request.lua", Content = sendCodeBuild.ToString() });
                    zipFileList.Add(new ZipFileInfo() { Name = "Response.lua", Content = receiveCodeBuild.ToString() });
                }
                else if (type == "C#")
                {
                    var clientTemp = TemplateHelper.ReadTemp(Path.Combine(Server.MapPath("~"),
                          isSelfAction ? "Template/ClientCsharpSelfCode.txt" : "Template/ClientCsharpCode.txt"));
                    ZipFileInfo zipFile;
                    zipFileList = new List<ZipFileInfo>();

                    foreach (var model in contractList)
                    {
                        if (!model.Complated) continue;
                        int contractId = model.ID;
                        zipFile = new ZipFileInfo() { Name = string.Format("Action{0}.cs", contractId) };
                        var tileName = GetTileName(model.ID, model.Descption);
                        List<ParamInfoModel> requestParams;
                        List<ParamInfoModel> responseParams;
                        GetParamInfo(slnId, contractId, versionId, out requestParams, out responseParams);
                        zipFile.Content = TemplateHelper.FromatClientCsharpTemp(clientTemp, contractId, responseParams, requestParams, tileName);

                        zipFileList.Add(zipFile);
                    }
                }
                if (zipFileList != null)
                {
                    SaveAsAttachment(string.Format("{0}Action{1}.zip", type, DateTime.Now.ToString("HHmmss")), zipFileList);
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnExportAllClientCode error:{0}", ex);
            }
        }