コード例 #1
0
        public short ReadSubProgramFolder(ushort flib, bool drill, ref ReadProgramFolderItemModel data)
        {
            short num_prog     = 50;
            var   pdf_adir_out = new Focas1.PRGFOLDER();

            var pdf_adir_in = new Focas1.IDBPDFADIR();

            pdf_adir_in.req_num   = 0;
            pdf_adir_in.size_kind = 2;
            pdf_adir_in.type      = 0;
            pdf_adir_in.path      = data.Folder;

            var ret = Focas1.cnc_rdpdf_alldir(flib, ref num_prog, pdf_adir_in, pdf_adir_out);

            if (ret == 0)
            {
                try
                {
                    for (int i = 0; i < num_prog; i++)
                    {
                        string strdata = "folder" + (i + 1).ToString();
                        object obj     = pdf_adir_out.GetType().GetField(strdata).GetValue(pdf_adir_out);

                        string name      = obj.GetType().GetField("d_f").GetValue(obj).ToString();
                        short  data_kind = short.Parse(obj.GetType().GetField("data_kind").GetValue(obj).ToString());

                        if (data_kind == 0)
                        {
                            var item = new ReadProgramFolderItemModel()
                            {
                                Name   = data.Folder + name + @"/",
                                Folder = data.Folder + name + @"/",
                                RegNum = (short)(data.RegNum + 1)
                            };

                            if (drill == true)
                            {
                                ret = ReadSubProgramFolder(flib, true, ref item);
                                if (ret != 0)
                                {
                                    return(ret);
                                }
                            }

                            data.Nodes.Add(item);
                        }
                    }
                }
                catch {
                    return(-100);
                }
            }
            else if (ret == 3)
            {
                return(0);
            }

            return(ret);
        }
コード例 #2
0
        public Tuple <short, string> ReadProgramList(ushort flib, string folder, ref List <ReadProgramListItemResultModel> data)
        {
            data.Clear();

            short num_prog     = 50;
            var   pdf_adir_out = new Focas1.PRGFOLDER();

            var pdf_adir_in = new Focas1.IDBPDFADIR();

            pdf_adir_in.req_num   = 0;
            pdf_adir_in.size_kind = 1;
            pdf_adir_in.type      = 1;
            pdf_adir_in.path      = folder;

            var ret = Focas1.cnc_rdpdf_alldir(flib, ref num_prog, pdf_adir_in, pdf_adir_out);

            if (ret == 0)
            {
                try
                {
                    for (int i = 0; i < num_prog; i++)
                    {
                        string strdata = "folder" + (i + 1).ToString();
                        object obj     = pdf_adir_out.GetType().GetField(strdata).GetValue(pdf_adir_out);

                        short  data_kind = short.Parse(obj.GetType().GetField("data_kind").GetValue(obj).ToString());
                        int    size      = int.Parse(obj.GetType().GetField("size").GetValue(obj).ToString());
                        string name      = obj.GetType().GetField("d_f").GetValue(obj).ToString();
                        string comment   = obj.GetType().GetField("comment").GetValue(obj).ToString();
                        short  year      = short.Parse(obj.GetType().GetField("year").GetValue(obj).ToString());
                        short  mon       = short.Parse(obj.GetType().GetField("mon").GetValue(obj).ToString());
                        short  day       = short.Parse(obj.GetType().GetField("day").GetValue(obj).ToString());
                        short  hour      = short.Parse(obj.GetType().GetField("hour").GetValue(obj).ToString());
                        short  min       = short.Parse(obj.GetType().GetField("min").GetValue(obj).ToString());
                        short  sec       = short.Parse(obj.GetType().GetField("sec").GetValue(obj).ToString());


                        if (data_kind == 1)
                        {
                            data.Add(new ReadProgramListItemResultModel
                            {
                                Name           = name,
                                Description    = comment,
                                Size           = size,
                                CreateDateTime = new DateTime(year, mon, day, hour, min, sec)
                            });;
                        }
                    }
                }
                catch
                {
                    return(new Tuple <short, string>(-100, $"读取程序列表错误,系统错误"));
                }

                return(new Tuple <short, string>(0, null));
            }
            else
            {
                return(new Tuple <short, string>(ret, $"读取程序列表错误,返回:{ret}"));
            }
        }