public OctoprintFolder(JObject data, OctoprintFileTracker t)
        {
            octoprintFolders = new List <OctoprintFolder>();
            octoprintFiles   = new List <OctoprintFile>();
            foreach (JObject filedata in data["files"])
            {
                if ((string)filedata["type"] == "folder")
                {
                    //OctoprintFolder folder = t.GetFiles("/"+(string)filedata["path"]);
                    //octoprintFolders.Add(folder);
                }
                else
                {
                    OctoprintFile file = new OctoprintFile(filedata);
                    JToken        refs = filedata.Value <JToken>("refs");
                    if (refs != null)
                    {
                        file.Refs_resource = refs.Value <String>("resource") ?? "";
                        file.Refs_download = refs.Value <String>("download") ?? "";
                    }
                    JToken gcodeanalysis = filedata.Value <JToken>("gcodeAnalysis");
                    if (gcodeanalysis != null)
                    {
                        file.GcodeAnalysis.EstimatedPrintTime = gcodeanalysis.Value <float?>("estimatedPrintTime") ?? 0;

                        JToken filament = gcodeanalysis.Value <JToken>("filament");
                        if (filament != null)
                        {
                            JToken tool0 = filament.Value <JToken>("tool0");
                            if (tool0 != null)
                            {
                                file.GcodeAnalysis.FilamentLength = tool0.Value <int?>("length") ?? -1;
                                file.GcodeAnalysis.FilamentVolume = tool0.Value <int?>("volume") ?? -1;
                            }
                        }

                        JToken dimensions = gcodeanalysis.Value <JToken>("dimensions");
                        if (dimensions != null)
                        {
                            file.GcodeAnalysis.Dimensions_Depth  = dimensions.Value <float?>("depth") ?? -1f;
                            file.GcodeAnalysis.Dimensions_Height = dimensions.Value <float?>("height") ?? -1f;
                            file.GcodeAnalysis.Dimensions_Width  = dimensions.Value <float?>("width") ?? -1f;
                        }
                    }
                    JToken print = filedata.Value <JToken>("print");
                    if (print != null)
                    {
                        file.Print_failure = print.Value <int?>("failure") ?? -1;
                        JToken last = print.Value <JToken>("last");
                        if (last != null)
                        {
                            file.Print_last_date    = last.Value <int>("date");
                            file.Print_last_success = last.Value <bool>("success");
                        }
                    }
                    octoprintFiles.Add(file);
                }
            }
        }
Пример #2
0
 public OctoprintFolder(JObject data, OctoprintFileTracker t)
 {
     octoprintFolders = new List <OctoprintFolder>();
     octoprintFiles   = new List <OctoprintFile>();
     foreach (JObject filedata in data["files"])
     {
         if ((string)filedata["type"] == "folder")
         {
             OctoprintFolder folder = t.GetFiles((string)filedata["path"]);
             octoprintFolders.Add(folder);
         }
         else
         {
             OctoprintFile file = new OctoprintFile(filedata);
             JToken        refs = filedata.Value <JToken>("refs");
             if (refs != null)
             {
                 file.Refs_resource = refs.Value <String>("resource") ?? "";
                 file.Refs_download = refs.Value <String>("download") ?? "";
             }
             JToken gcodeanalysis = filedata.Value <JToken>("gcodeAnalysis");
             if (gcodeanalysis != null)
             {
                 file.GcodeAnalysis_estimatedPrintTime = gcodeanalysis.Value <int?>("estimatedPrintTime") ?? 0;
                 JToken filament = gcodeanalysis.Value <JToken>("filament");
                 if (filament != null)
                 {
                     file.GcodeAnalysis_filament_length = filament.Value <int?>("length") ?? -1;
                     file.GcodeAnalysis_filament_volume = filament.Value <int?>("volume") ?? -1;
                 }
             }
             JToken print = filedata.Value <JToken>("print");
             if (print != null)
             {
                 file.Print_failure = print.Value <int?>("failure") ?? -1;
                 JToken last = print.Value <JToken>("last");
                 if (last != null)
                 {
                     file.Print_last_date    = last.Value <int>("date");
                     file.Print_last_success = last.Value <bool>("success");
                 }
             }
             octoprintFiles.Add(file);
         }
     }
 }
Пример #3
0
        public OctoprintJobInfo(JToken job)
        {
            EstimatedPrintTime = job.Value <int?>("estimatedPrintTime") ?? -1;
            JToken filament = job.Value <JToken>("filament");

            if (filament.HasValues)
            {
                Filament = new OctoprintFilamentInfo
                {
                    Lenght = filament.Value <int?>("length") ?? -1,
                    Volume = filament.Value <int?>("volume") ?? -1
                }
            }
            ;
            JToken file = job.Value <JToken>("file");

            File = new OctoprintFile((JObject)file);
        }
        public OctoprintJobInfo(JToken job)
        {
            EstimatedPrintTime = job.Value <int?>("estimatedPrintTime") ?? -1;
            AveragePrintTime   = job.Value <float?>("averagePrintTime") ?? -1;
            LastPrintTime      = job.Value <float?>("lastPrintTime") ?? -1;
            User = job.Value <String>("user");

            JToken filament = job.Value <JToken>("filament");

            if (filament.HasValues)
            {
                Filament = new OctoprintFilamentInfo
                {
                    Lenght = filament.Value <int?>("length") ?? -1,
                    Volume = filament.Value <int?>("volume") ?? -1
                }
            }
            ;
            JToken file = job.Value <JToken>("file");

            File = new OctoprintFile((JObject)file);
        }