Exemplo n.º 1
0
        public bool EstablishCsvLink(CsvReader csvReader, string folderPath, string fileName)
        {
            if (!folderPath.EndsWith(@"\"))
            {
                folderPath = folderPath + @"\";
            }
            if (!fileName.ToLower().EndsWith(".csv"))
            {
                fileName = fileName + ".csv";
            }
            string filePath    = folderPath + fileName;
            string returnValue = csvReader.ConnectToFile(filePath);

            if (returnValue != "")
            {
                Print(returnValue);
                return(false);
            }
            Print("Connection to CSV file established.");
            return(true);
        }
Exemplo n.º 2
0
        // ************************************************** Private Functions ****************************************************
        private void Process()
        {
            listBoxResults.Items.Clear();
            listBoxResults.Items.Add("");

            CsvReader csvReader = new CsvReader();

            csvReader.ConnectToFile(textBoxPathCsv.Text);
            string returnValue = csvReader.ReadFile();

            if (returnValue != "")
            {
                MessageBox.Show(returnValue);
            }
            returnValue = csvReader.GetInput();
            if (returnValue != "")
            {
                MessageBox.Show(returnValue);
            }
            else
            {
                //csvReader.
                List <HbInputItem> inputItems = csvReader.HbInputItems;
                foreach (HbInputItem inputItem in inputItems)
                {
                    string valueElementId;
                    if (inputItem.ElementId == null)
                    {
                        valueElementId = "NULL";
                    }
                    else
                    {
                        valueElementId = inputItem.ElementId.ElementIdValue.ToString();
                    }
                    listBoxResults.Items.Add("RowId: " + inputItem.RowId + " || ElementId: " + valueElementId);
                    listBoxResults.Items.Add(inputItem.CommandAction + " || " + inputItem.CommandObject + " || " + inputItem.CommandModifier);
                    if (inputItem.ListHbXYZ == null)
                    {
                        listBoxResults.Items.Add("ListHbXYZ = NULL");
                    }
                    else
                    {
                        listBoxResults.Items.Add("ListHbXYZ:");
                        foreach (HbXYZ hbXyz in inputItem.ListHbXYZ)
                        {
                            if (hbXyz == null)
                            {
                                listBoxResults.Items.Add("     (Null value for hbXyz.)");
                            }
                            else
                            {
                                listBoxResults.Items.Add("     (" + hbXyz.X.ToString() + ", " + hbXyz.Y.ToString() + ", " + hbXyz.Z.ToString() + ")");
                            }
                        }
                    }
                    if (inputItem.HbCurveArrArray == null)
                    {
                        listBoxResults.Items.Add("HbCurveArrayArray = NULL");
                    }
                    else
                    {
                        listBoxResults.Items.Add("HbCurveArrayArray:");
                        foreach (HbCurveArray hbCurveArray in inputItem.HbCurveArrArray)
                        {
                            listBoxResults.Items.Add("     CurveArray:" + hbCurveArray.ToString());
                            foreach (HbCurve hbCurve in hbCurveArray)
                            {
                                string hbName = hbCurve.ToString();
                                string hbType = hbName.Substring(hbName.LastIndexOf(".") + 1);
                                switch (hbType)
                                {
                                case "HbLine":
                                    HbLine hbLine = (HbLine)hbCurve;
                                    listBoxResults.Items.Add("          HbLine: (" + hbLine.PointStart.X.ToString() + ", " + hbLine.PointStart.Y.ToString() + ", " + hbLine.PointStart.Z.ToString() + ") "
                                                             + "(" + hbLine.PointEnd.X.ToString() + ", " + hbLine.PointEnd.Y.ToString() + ", " + hbLine.PointEnd.Z.ToString() + ")");
                                    break;

                                case "HbArc":
                                    HbArc hbArc = (HbArc)hbCurve;
                                    listBoxResults.Items.Add("          HbArc: (" + hbArc.PointStart.X.ToString() + ", " + hbArc.PointStart.Y.ToString() + ", " + hbArc.PointStart.Z.ToString() + ") "
                                                             + "(" + hbArc.PointMid.X.ToString() + ", " + hbArc.PointMid.Y.ToString() + ", " + hbArc.PointMid.Z.ToString() + ") "
                                                             + "(" + hbArc.PointEnd.X.ToString() + ", " + hbArc.PointEnd.Y.ToString() + ", " + hbArc.PointEnd.Z.ToString() + ")");
                                    break;

                                default:
                                    listBoxResults.Items.Add("          " + hbCurve.ToString());
                                    break;
                                }
                            }
                        }
                    }
                    if (inputItem.HbReferenceArrayArray == null)
                    {
                        listBoxResults.Items.Add("HbReferenceArrayArray = NULL");
                    }
                    else
                    {
                        listBoxResults.Items.Add("HbReferenceArrayArray:");
                        foreach (HbReferenceArray hbReferenceArray in inputItem.HbReferenceArrayArray)
                        {
                            listBoxResults.Items.Add("     " + hbReferenceArray.ToString());
                        }
                    }
                    //if (inputItem.Variables == null) listBoxResults.Items.Add("Variables = NULL");
                    //else {
                    //    listBoxResults.Items.Add("Variables:");
                    //    foreach (string variable in inputItem.Variables) {
                    //        listBoxResults.Items.Add("     " + variable);
                    //    }
                    //}
                    listBoxResults.Items.Add("");
                    listBoxResults.Items.Add("-------------------------------------------------------------------------------------------------");
                    listBoxResults.Items.Add("");
                    //string valueElementId;
                    //string valuesListHbXYZ;
                    //string valuesHbCurveArrayArray;
                    //string valuesHbReferenceArrayArray;
                    //string valuesVariables;
                    //string valueElementId;
                    //string valuesListHbXYZ;
                    //string valuesHbCurveArrayArray;
                    //string valuesHbReferenceArrayArray;
                    //string valuesVariables;
                    //if (inputItem.ElementId == null) valueElementId = "NULL";
                    //else valueElementId = inputItem.ElementId.ElementIdValue.ToString();
                    //if (inputItem.ListHbXYZ == null) valuesListHbXYZ = "ListHbXYZ = NULL";
                    //else {
                    //    valuesListHbXYZ = "ListHbXYZ:";
                    //    foreach (HbXYZ hbXyz in inputItem.ListHbXYZ) {
                    //        valuesListHbXYZ += "\n     (" + hbXyz.X.ToString() + ", " + hbXyz.Y.ToString() + ", " + hbXyz.Z.ToString() + ")";
                    //    }
                    //}
                    //if (inputItem.HbCurveArrayArray == null) valuesHbCurveArrayArray = "HbCurveArrayArray = NULL";
                    //else {
                    //    valuesHbCurveArrayArray = "HbCurveArrayArray:";
                    //    foreach (HbCurveArray hbCurveArray in inputItem.HbCurveArrayArray) {
                    //        valuesHbCurveArrayArray += "\n     " + hbCurveArray.ToString();
                    //    }
                    //}
                    //if (inputItem.HbReferenceArrayArray == null) valuesHbReferenceArrayArray = "HbReferenceArrayArray = NULL";
                    //else {
                    //    valuesHbReferenceArrayArray = "HbReferenceArrayArray:";
                    //    foreach (HbReferenceArray hbReferenceArray in inputItem.HbReferenceArrayArray) {
                    //        valuesHbReferenceArrayArray += "\n     " + hbReferenceArray.ToString();
                    //    }
                    //}
                    //if (inputItem.Variables == null) valuesVariables = "Variables = NULL";
                    //else {
                    //    valuesVariables = "Variables:";
                    //    foreach (string variable in inputItem.Variables) {
                    //        valuesVariables += "\n     " + variable;
                    //    }
                    //}
                    //DialogResult result = MessageBox.Show(
                    //    "RowId: " + inputItem.RowId + " || ElementId: " + valueElementId + "\n"
                    //  + inputItem.CommandAction + " || " + inputItem.CommandObject + " || " + inputItem.CommandModifier + "\n"
                    //  + valuesListHbXYZ + "\n"
                    //  + valuesHbCurveArrayArray + "\n"
                    //  + valuesHbReferenceArrayArray + "\n"
                    //  + valuesVariables + "\n"
                    //    , constantProgramName, MessageBoxButtons.OKCancel);
                    //if (result != DialogResult.OK) break;
                }
            }
        }