Example #1
0
        private void RefreshTaskTree()
        {
            List <string> listTasks = new List <string>();

            string        sTaskFolder = String.Format("{0}PackingTasks\\", _CodeBase);
            DirectoryInfo taskFiles   = new DirectoryInfo(sTaskFolder);

            foreach (var xmlTaskFile in taskFiles.EnumerateFiles())
            {
                string taskName = GetTaskName(xmlTaskFile.FullName);
                listTasks.Add(taskName);
            }
            listTasks.Sort();

            treeViewTasks.Nodes.Clear();

            for (int i = 0; i < listTasks.Count; i++)
            {
                string   taskName = listTasks[i];
                TreeNode rootTask = new TreeNode();
                rootTask.Text               = taskName;
                rootTask.ImageIndex         = _goodIconIndex;
                rootTask.SelectedImageIndex = _goodIconIndex;

                string     sTaskFile = String.Format("{0}PackingTasks\\{1}.xml", _CodeBase, listTasks[i]);
                List <MDF> allMDF    = BinPackingInfo.LoadFromXml(sTaskFile);
                for (int p = 0; p < allMDF.Count; p++)
                {
                    TreeNode child = new TreeNode();
                    child.Text               = allMDF[p]._JobName;
                    child.ImageIndex         = _badIconIndex;
                    child.SelectedImageIndex = _badIconIndex;
                    string jobFolder = String.Format("{0}Jobs\\{1}\\", _CodeBase, allMDF[p]._JobName);
                    if (Directory.Exists(jobFolder))
                    {
                        string jobFile = String.Format("{0}Jobs\\{1}\\{1}.cf", _CodeBase, allMDF[p]._JobName);
                        if (File.Exists(jobFile))
                        {
                            child.ImageIndex         = _goodIconIndex;
                            child.SelectedImageIndex = _goodIconIndex;
                        }
                    }
                    if (child.ImageIndex == _badIconIndex)
                    {
                        rootTask.ImageIndex         = _badIconIndex;
                        rootTask.SelectedImageIndex = _badIconIndex;
                    }
                    rootTask.Nodes.Add(child);
                }
                treeViewTasks.Nodes.Add(rootTask);
            }
        }
Example #2
0
        private void buttonNew_Click(object sender, EventArgs e)
        {
            List <MDF> allMDF        = null;
            string     xmlResultFile = CNController.CADM_BinPacking(_cncConnector.GetModelName());

            if (!String.IsNullOrEmpty(xmlResultFile))
            {
                //System.Diagnostics.Process.Start(xmlResultFile);
                allMDF = BinPackingInfo.LoadFromXml(xmlResultFile);
                if (allMDF.Count > 0)
                {
                    try
                    {
                        string taskName    = GetTaskName(xmlResultFile);
                        string sTaskFolder = String.Format("{0}PackingTasks\\", _CodeBase);
                        string sTaskFile   = String.Format("{0}PackingTasks\\{1}.xml", _CodeBase, taskName);

                        if (!Directory.Exists(sTaskFolder))
                        {
                            Directory.CreateDirectory(sTaskFolder);
                        }

                        int seq = 1;
                        while (File.Exists(sTaskFile))
                        {
                            sTaskFile = String.Format("{0}PackingTasks\\{1}-{2:000}.xml", _CodeBase, taskName, seq++);
                        }

                        File.Copy(xmlResultFile, sTaskFile);

                        RefreshTaskTree();
                    }
                    catch (Exception er)
                    { }
                }
            }
        }