示例#1
0
	// Execute the compiler and wait for it to return.
	public static void ExecWait(String cmd, TempFileCollection tempFiles)
			{
				String outputName = null;
				String errorName = null;
				ExecWaitWithCapture(IntPtr.Zero, cmd, null, tempFiles,
									ref outputName, ref errorName);
			}
示例#2
0
	public static int ExecWaitWithCapture
				(String cmd, String currentDir, TempFileCollection tempFiles,
				 ref String outputName, ref String errorName)
			{
				return ExecWaitWithCapture(IntPtr.Zero, cmd, currentDir,
										   tempFiles, ref outputName,
										   ref errorName);
			}
示例#3
0
	public static int ExecWaitWithCapture
				(IntPtr userToken, String cmd, TempFileCollection tempFiles,
				 ref String outputName, ref String errorName)
			{
				return ExecWaitWithCapture(userToken, cmd, null,
										   tempFiles, ref outputName,
										   ref errorName);
			}
示例#4
0
	public static int ExecWaitWithCapture
				(IntPtr userToken, String cmd, String currentDir,
				 TempFileCollection tempFiles, ref String outputName,
				 ref String errorName)
			{
				// We do not allow the compiler to be launched this way
				// as it is a severe security threat to allow arbitrary
				// command-lines to be passed to the underlying system.
				// Besides, Unix-style systems don't like command lines
				// that consist of a single string.  Use ICodeCompiler
				// to compile source files instead of this class.

				throw new NotImplementedException();
			}
	public static int ExecWaitWithCapture(System.IntPtr userToken, string cmd, string currentDir, TempFileCollection tempFiles, System.String& outputName, System.String& errorName) {}
	public static int ExecWaitWithCapture(string cmd, TempFileCollection tempFiles, System.String& outputName, System.String& errorName) {}
	// Methods
	public static void ExecWait(string cmd, TempFileCollection tempFiles) {}
	// Constructors
	public CompilerResults(TempFileCollection tempFiles) {}
 public bool GenerateandCompileLibrary(string moduleFolderPath, string moduleName, Dictionary<string, string> columnlist, Dictionary<string, string> updateList, bool isNewModule, bool autoIncrement)
 {
     string filePathInfo = Server.MapPath("/Modules/Admin/ModuleMaker/RawModule/library/ModuleInfo.cs");
     string filePathController = Server.MapPath("/Modules/Admin/ModuleMaker/RawModule/library/ModuleController.cs");
     string filePathDataProvider = Server.MapPath("/Modules/Admin/ModuleMaker/RawModule/library/ModuleDataProvider.cs");
     string bigCode = string.Empty;
     string code = string.Empty;
     bool isCompiled = false;
     try
     {
         string libraryPath = Server.MapPath(moduleFolderPath + moduleName + "/SageFrame." + moduleName);
         ModuleHelper.CreateDirectory(libraryPath);
         string infoPath = libraryPath + "/Info";
         ModuleHelper.CreateDirectory(infoPath);
         string destinationPath = infoPath + "/" + moduleName + "Info.cs";
         using (StreamWriter sw = new StreamWriter(destinationPath))
         {
             using (StreamReader rdr = new StreamReader(filePathInfo))
             {
                 code = rdr.ReadToEnd();
             }
             StringBuilder html = new StringBuilder();
             foreach (KeyValuePair<string, string> datatype in columnlist)
             {
                 html.Append(ModuleHelper.SageProp(datatype.Value, datatype.Key));
             }
             code = code.Replace("//properties", html.ToString());
             string references = "using System;";
             references = "using System;\nusing SageFrame.Web.Utilities;\nusing System.Collections.Generic;\n";
             code = code.Replace("//references", references);
             code = code.Replace("ModuleName", moduleName);
             sw.Write(code);
             bigCode = code;
         }
         string contollerPath = libraryPath + "/Controller";
         ModuleHelper.CreateDirectory(contollerPath);
         destinationPath = contollerPath + "/" + moduleName + "Controller.cs";
         using (StreamWriter sw = new StreamWriter(destinationPath))
         {
             using (StreamReader rdr = new StreamReader(filePathController))
             {
                 code = rdr.ReadToEnd();
             }
             string controllerCode = ModuleHelper.ControllerCode(columnlist, moduleName).ToString();
             code = code.Replace("//properties", controllerCode);
             code = code.Replace("ModuleName", moduleName);
             bigCode += "\n" + code;
             string references = "using System; using System.Collections.Generic;";
             code = code.Replace("//references", references);
             sw.Write(code);
         }
         string dataProviderPath = libraryPath + "/DataProvider";
         ModuleHelper.CreateDirectory(dataProviderPath);
         destinationPath = dataProviderPath + "/" + moduleName + "DataProvider.cs";
         using (StreamWriter sw = new StreamWriter(destinationPath))
         {
             using (StreamReader rdr = new StreamReader(filePathDataProvider))
             {
                 code = rdr.ReadToEnd();
             }
             string dataProviderCode = ModuleHelper.DataProviderCode(columnlist, moduleName, updateList, autoIncrement).ToString();
             code = code.Replace("//properties", dataProviderCode);
             code = code.Replace("ModuleName", moduleName);
             bigCode += "\n" + code;
             string references = "using System;\n using SageFrame.Web.Utilities;\n using System.Collections.Generic;\n";
             code = code.Replace("//references", references);
             sw.Write(code);
         }
     }
     catch (Exception ex)
     {
         ShowMessage("", ex.ToString(), "", SageMessageType.Error);
         ProcessException(ex);
     }
     if (isNewModule)
     {
         CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
         //CSharpCodeProvider csp = new CSharpCodeProvider();
         // ICodeCompiler cc = provider.CreateCompiler();
         CompilerParameters cp = new CompilerParameters();
         string OutputAssembly = Path.Combine(Server.MapPath("/bin/"), "SageFrame." + moduleName + ".dll");
         cp.OutputAssembly = OutputAssembly;
         cp.ReferencedAssemblies.Add("System.dll");
         cp.ReferencedAssemblies.Add(AppDomain.CurrentDomain.BaseDirectory + "bin\\SageFrame.Common.dll");
         cp.WarningLevel = 3;
         //cp.CompilerOptions = "/target:library /optimize";
         cp.GenerateExecutable = false;
         cp.GenerateInMemory = false;
         System.CodeDom.Compiler.TempFileCollection tfc = new TempFileCollection(GetApplicationName, false);
         CompilerResults cr = new CompilerResults(tfc);
         cr = provider.CompileAssemblyFromSource(cp, bigCode);
         if (cr.Errors.Count > 0)
         {
             string error = string.Empty;
             foreach (CompilerError ce in cr.Errors)
             {
                 error += ce.ErrorNumber + ": " + ce.ErrorText;
             }
             ShowMessage("", error, "", SageMessageType.Error);
             isCompiled = false;
         }
         else
         {
             isCompiled = true;
         }
     }
     return isCompiled;
 }