Git Product home page Git Product logo

jcaillon / oetools.sakoe Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 644 KB

SAKOE - Swiss army knife for openedge, provides various tools useful for any openedge developer such as database manipulation, compiling a project, linting source files, etc...

Home Page: https://jcaillon.github.io/Oetools.Sakoe/

License: GNU General Public License v3.0

C# 96.86% PowerShell 3.14%
openedge abl 4gl progress swissarmyknife tool database lint lintcode package deploy build sakoe

oetools.sakoe's Issues

Add http archiver

        ASSIGN
            /* curl.exe -v --stderr - -X DELETE -u rawdeploy:rawdeploy http://192.168.213.143/repository/raw-ressources/progress/snapshot/cnaf/pc/sac/18062.0001-SNAPSHOT/sac-18062.0001.dar --proxy http://192.168.213.137:3128 */
            lc_out = DYNAMIC-FUNCTION('btUseCurl', INPUT "-v --stderr - -X DELETE -u " + gb_confignexus.nexusUser + ":" + gb_confignexus.nexusPwd + " " + gc_url + "/" + gc_darName, INPUT lc_targetPath, INPUT TRUE)
            .
        RUN pi_stopWait.
        IF NOT lc_out MATCHES "*HTTP/1.1 204*" THEN
            DYNAMIC-FUNCTION('btDisplayError', INPUT "Erreur lors de la suppression du fichier .dar sur nexus : " + QUOTER(lc_out)).
    /* Upload to xldeploy */
    /* curl -u<username>:<password> -X POST -H "content-type:multipart/form-data" http://<xl-deploy-server>:<xl-deploy-port>/deployit/package/upload/Test.dar -F fileData=@/tmp/test1-1.0.dar */

    ASSIGN
        lc_out = DYNAMIC-FUNCTION('btUseCurl', INPUT "-v -H " + QUOTER("Expect:") + " --stderr - -u " + gb_confignexus.nexusUser + ":" + gb_confignexus.nexusPwd + " --upload-file " + QUOTER(lc_targetPath + gc_darName) + " " + gc_url + "/" + gc_darName, INPUT lc_targetPath, INPUT TRUE)
        .

    RUN pi_stopWait.

    IF NOT lc_out MATCHES "*HTTP/1.1 201*" THEN
        RETURN ERROR "Erreur lors de l'upload du fichier .dar sur nexus : " + QUOTER(lc_out).
    DYNAMIC-FUNCTION('btDisplayInfo', INPUT "Le paquet au format .dar a été correctement uploadé sur Nexus").
private static void SendFileToServer(string fileFullPath)
        {
            FileInfo fi = new FileInfo(fileFullPath);
            string fileName = fi.Name;
            byte[] fileContents = File.ReadAllBytes(fi.FullName);
            Uri webService = new Uri(@"http://avalidwebservice.com");
            HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, webService);
            requestMessage.Headers.ExpectContinue = false;
 
            MultipartFormDataContent multiPartContent = new MultipartFormDataContent("----MyGreatBoundary");
            ByteArrayContent byteArrayContent = new ByteArrayContent(fileContents);
            byteArrayContent.Headers.Add("Content-Type", "application/octet-stream");
            multiPartContent.Add(byteArrayContent, "this is the name of the content", fileName);
            requestMessage.Content = multiPartContent;
 
            HttpClient httpClient = new HttpClient();
            try
            {
                Task<HttpResponseMessage> httpRequest = httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, CancellationToken.None);
                HttpResponseMessage httpResponse = httpRequest.Result;
                HttpStatusCode statusCode = httpResponse.StatusCode;
                HttpContent responseContent = httpResponse.Content;
 
                if (responseContent != null)
                {
                    Task<String> stringContentsTask = responseContent.ReadAsStringAsync();
                    String stringContents = stringContentsTask.Result;                    
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
```

Automated tasks

    [Serializable]
    [XmlRoot("AutomatedTasks")]
    public class OeAutomatedTasks {
        
        [XmlAttribute("Label")]
        public string Label { get; set; }
        
        [XmlArray("Variables")]
        [XmlArrayItem("Variable", typeof(OeVariable))]
        public List<OeVariable> Variables { get; set; }
        
        [XmlArray("Tasks")]
        [XmlArrayItem("Execute", typeof(OeTaskExec))]
        [XmlArrayItem("RemoveDirectory", typeof(OeTaskDirectoryDelete))]
        [XmlArrayItem("Delete", typeof(OeTaskFileDelete))]
        [XmlArrayItem("Cab", typeof(OeTaskFileArchiverArchiveCab))]
        public List<AOeTask> Tasks { get; set; }
    }

Implement custom tasks

Could be interesting and useful to have something along these lines:

  <!-- defines the Zip task -->
  <UsingTask TaskName="Zip" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
    <ParameterGroup>
      <InputFileNames ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
      <OutputFileName ParameterType="System.String" Required="true" />
      <OverwriteExistingFile ParameterType="System.Boolean" Required="false" />
    </ParameterGroup>
    <Task>
      <Reference Include="System.IO.Compression" />
      <Using Namespace="System.IO.Compression" />
      <Code Type="Fragment" Language="cs">
        <![CDATA[        
        const int BufferSize = 64 * 1024;
 
        var buffer = new byte[BufferSize];
        var fileMode = OverwriteExistingFile ? FileMode.Create : FileMode.CreateNew;
 
        using (var outputFileStream = new FileStream(OutputFileName, fileMode))
        {
          using (var archive = new ZipArchive(outputFileStream, ZipArchiveMode.Create))
          {
            foreach (var inputFileName in InputFileNames.Select(f => f.ItemSpec))
            {
              var archiveEntry = archive.CreateEntry(Path.GetFileName(inputFileName));
 
              using (var fs = new FileStream(inputFileName, FileMode.Open))
              {
                using (var zipStream = archiveEntry.Open())
                {
                  int bytesRead = -1;
                  while ((bytesRead = fs.Read(buffer, 0, BufferSize)) > 0)
                  {
                    zipStream.Write(buffer, 0, bytesRead);
                  }
                }
              }
            }
          }
        }        
      ]]>
      </Code>
    </Task>
  </UsingTask>

à la msbuild

todo

  • After the source build tasks, check each previous files, those which were recompiled, check the targets differences, and remove the targets needed using sourceRemover task
  • we also need to do that for unchanged files; use the task executor in test mode to simply get all the files built then do the same comparison with the previous built
  • for Compile tasks, use a boolean that indicates wether or not files received in ExecuteForFiles should be compiled or they they already are

Improve current wildcard system

instead of just using * and ?, allow the usage of : **, * and ?

  • ** matches any number of char including / and \
    • matches any number of char excluding / and \
  • ? matches 1 char excluding \ and /

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.