Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            IdeaInstallDir = IOM.SteelFrameDesktop.Properties.Settings.Default.IdeaInstallDir;

            if (!Directory.Exists(IdeaInstallDir))
            {
                Console.WriteLine("IDEA StatiCa installation was not found in '{0}'", IdeaInstallDir);
                return;
            }

            Console.WriteLine("IDEA StatiCa installation directory is '{0}'", IdeaInstallDir);

            Console.WriteLine("Start generate example of IOM...");

            // create IOM and results
            OpenModel       example = SteelFrameExample.CreateIOM();
            OpenModelResult result  = Helpers.GetResults();

            string iomFileName    = "example.xml";
            string iomResFileName = "example.xmlR";

            // save to the files
            example.SaveToXmlFile(iomFileName);
            result.SaveToXmlFile(iomResFileName);


            var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            var fileConnFileNameFromLocal = Path.Combine(desktopDir, "connectionFromIOM-local.ideaCon");

            var calcFactory = new ConnHiddenClientFactory(IdeaInstallDir);

            var client = calcFactory.Create();

            try
            {
                // it creates connection project from IOM
                Console.WriteLine("Creating Idea connection project ");
                client.CreateConProjFromIOM(iomFileName, iomResFileName, fileConnFileNameFromLocal);
                Console.WriteLine("Generated project was saved to the file '{0}'", fileConnFileNameFromLocal);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error '{0}'", e.Message);
            }
            finally
            {
                if (client != null)
                {
                    client.Close();
                }
            }

            // end console application
            Console.WriteLine("Done. Press any key to exit.");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        private void CreateIDEAOpenModelResults()
        {
            openStructModelR = new OpenModelResult();
            openStructModelR.ResultOnMembers = new List <ResultOnMembers>();
            ResultOnMembers resIF = new ResultOnMembers();

            for (int ib = 0; ib < openStructModel.Member1D.Count; ib++)
            {
                Member1D mb = openStructModel.Member1D[ib];
                for (int iel = 0; iel < mb.Elements1D.Count; iel++)
                {
                    Element1D      elem      = openStructModel.Element1D.First(c => c.Id == mb.Elements1D[iel].Id);
                    ResultOnMember resMember = new ResultOnMember(new Member()
                    {
                        Id = elem.Id, MemberType = MemberType.Element1D
                    }, ResultType.InternalForces);
                    int numPoints = 10;
                    for (int ip = 0; ip <= numPoints; ip++)
                    {
                        ResultOnSection resSec = new ResultOnSection();

                        resSec.AbsoluteRelative = AbsoluteRelative.Relative;
                        resSec.Position         = (double)ip / (double)numPoints;
                        int count = openStructModel.LoadCase.Count;
                        for (int i = 1; i <= count; i++)
                        {
                            ResultOfInternalForces resLc = new ResultOfInternalForces();
                            int loadCaseNumber           = i;
                            resLc.Loading = new ResultOfLoading()
                            {
                                Id = loadCaseNumber, LoadingType = LoadingType.LoadCase
                            };
                            resLc.Loading.Items.Add(new ResultOfLoadingItem()
                            {
                                Coefficient = 1.0
                            });
                            resLc.N  = 15000;
                            resLc.Qy = 2;
                            resLc.Qz = 3;
                            resLc.Mx = 4;
                            resLc.My = (ip + 1) * 21000;
                            resLc.Mz = 6;
                            resSec.Results.Add(resLc);
                        }

                        resMember.Results.Add(resSec);
                    }

                    resIF.Members.Add(resMember);
                }
            }

            openStructModelR.ResultOnMembers.Add(resIF);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load file with the results
        /// </summary>
        /// <returns>Instance of open model result</returns>
        public static OpenModelResult GetResults()
        {
            string     rootDir    = AppDomain.CurrentDomain.BaseDirectory;
            FileStream resultFile = new FileStream(rootDir + "\\SampleFiles\\IOM-SteelFrame.xmlR", FileMode.Open);

            XmlSerializer   serializer = new XmlSerializer(typeof(OpenModelResult));
            OpenModelResult result     = serializer.Deserialize(resultFile) as OpenModelResult;

            resultFile.Close();
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load file with the results
        /// </summary>
        /// <returns>Instance of open model result</returns>
        public static OpenModelResult GetResults()
        {
            string     rootDir    = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            FileStream resultFile = new FileStream(rootDir + "\\..\\IdeaStatiCa.Codes\\SampleFiles\\IOM-SteelFrame.xmlR", FileMode.Open);

            XmlSerializer   serializer = new XmlSerializer(typeof(OpenModelResult));
            OpenModelResult result     = serializer.Deserialize(resultFile) as OpenModelResult;

            resultFile.Close();
            return(result);
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            IdeaInstallDir = IOM.SteelFrameDesktop.Properties.Settings.Default.IdeaInstallDir;

            Console.WriteLine("IDEA StatiCa installation directory is '{0}'", IdeaInstallDir);

            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += new ResolveEventHandler(IdeaResolveEventHandler);

            Console.WriteLine("Start generate example of IOM...");

            // create IOM and results
            OpenModel       example = Example.CreateIOM();
            OpenModelResult result  = Helpers.GetResults();

            // save to the files
            result.SaveToXmlFile("example.xmlR");
            example.SaveToXmlFile("example.xml");

            var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            var fileConnFileNameFromLocal = Path.Combine(desktopDir, "connectionFromIOM-local.ideaCon");

            string  ideaConLinkFullPath = System.IO.Path.Combine(IdeaInstallDir, "IdeaStatiCa.IOMToConnection.dll");
            var     conLinkAssembly     = Assembly.LoadFrom(ideaConLinkFullPath);
            object  obj = conLinkAssembly.CreateInstance("IdeaStatiCa.IOMToConnection.IOMToConnection");
            dynamic d   = obj;

            // Initializtion
            var initMethod = (obj).GetType().GetMethod("Init");

            initMethod.Invoke(obj, null);

            Console.WriteLine("Generating IDEA Connection project locally");

            // Invoking method Import by reflection
            var methodImport = (obj).GetType().GetMethod("Import");

            object[] array = new object[3];
            array[0] = example;
            array[1] = result;
            array[2] = fileConnFileNameFromLocal;
            methodImport.Invoke(obj, array);

            Console.WriteLine("Writing Idea connection project to file '{0}'", fileConnFileNameFromLocal);

            // end console application
            Console.WriteLine("Done. Press any key to exit.");
            Console.ReadKey();
        }
        public static void CreateOnServer(OpenModel model, OpenModelResult openModelResult, string path)
        {
            IdeaRS.OpenModel.OpenModelContainer openModelContainer = new OpenModelContainer()
            {
                OpenModel       = model,
                OpenModelResult = openModelResult,
            };

            // serialize IOM to XML
            var stringwriter = new System.IO.StringWriter();
            var serializer   = new XmlSerializer(typeof(OpenModelContainer));

            serializer.Serialize(stringwriter, openModelContainer);

            var serviceUrl = viewerURL + "/ConnectionViewer/CreateFromIOM";

            Console.WriteLine("Posting iom in xml to the service {0}", serviceUrl);
            var resultMessage = Helpers.PostXMLData(serviceUrl, stringwriter.ToString());

            ResponseMessage responseMessage = JsonConvert.DeserializeObject <ResponseMessage>(resultMessage);

            Console.WriteLine("Service response is : '{0}'", responseMessage.status);
            if (responseMessage.status == "OK")
            {
                byte[] dataBuffer = Convert.FromBase64String(responseMessage.fileContent);
                Console.WriteLine("Writing {0} bytes to file '{1}'", dataBuffer.Length, path);
                if (dataBuffer.Length > 0)
                {
                    using (FileStream fileStream = new FileStream(path
                                                                  , FileMode.Create
                                                                  , FileAccess.Write))
                    {
                        fileStream.Write(dataBuffer, 0, dataBuffer.Length);
                    }
                }
                else
                {
                    Console.WriteLine("The service returned no data");
                }
            }
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Start generate example of IOM...");

            // create IOM and results
            OpenModel       example = Example.CreateIOM();
            OpenModelResult result  = Helpers.GetResults();

            // save to the files
            result.SaveToXmlFile("example.xmlR");
            example.SaveToXmlFile("example.xml");

            var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            #region Generatig IDEA Connection by web service
            Console.WriteLine("Generating IDEA Connection project by web service");
            var fileConnFileNameFromWeb = Path.Combine(desktopDir, "connectionFromIOM-web.ideaCon");
            Example.CreateOnServer(example, result, fileConnFileNameFromWeb);
            #endregion

            // end console application
            Console.WriteLine("Done. Press any key to exit.");
            Console.ReadKey();
        }
Exemplo n.º 8
0
        protected override ModelBIM ImportActive(CountryCode countryCode, RequestedItemsType requestedType)
        {
            try
            {
                if (_selectedObjects?.Count == 0)
                {
                    Debug.Fail("Nothing selected");
                    return(null);
                }

                var materials        = new Dictionary <string, MatSteelEc2>();
                var crossSections    = new Dictionary <string, CrossSectionParameter>();
                var pointConnections = _selectedObjects.OfType <StructuralPointConnection>().ToList();
                var curveMembers     = _selectedObjects.OfType <StructuralCurveMember>().ToList();
                var assemblies       = _selectedObjects.OfType <ElementAssembly>().ToList();
                if (pointConnections.Count == 0)
                {
                    MessageBoxHelper.ShowInformation("please select a PointConnection object to identify the connectionPoint", null);
                    return(null);
                }

                // read all nodes (maybe it's esier)
                var nodes = _integrationBase.ApiCore.DtObjects.GetObjects <StructuralPointConnection>(
                    _integrationBase.CurrentProject.Id, false, false, true);



                OpenModel openModel = new OpenModel
                {
                    OriginSettings = new OriginSettings()
                    {
                        CrossSectionConversionTable = IdeaRS.OpenModel.CrossSectionConversionTable.NoUsed, CountryCode = countryCode
                    }
                };


                int ccsId    = 1;
                int matId    = 1;
                int lsId     = 1;
                int memberId = 1;
                // ConnectionPoint
                ConnectionPoint connectionPoint = null;
                foreach (var point in pointConnections)
                {
                    // ad main node to openModel
                    connectionPoint = new ConnectionPoint();
                    if (point.NodeId.HasValue)
                    {
                        ConnectionPointId = point.NodeId.Value;
                    }
                    Point3D node = AddNodeToOpenModel(point, openModel, ConnectionPointId);
                    connectionPoint.Node = new ReferenceElement(node);

                    connectionPoint.Id              = ConnectionPointId;
                    connectionPoint.Name            = string.Format("Conn-{0}", ConnectionPointId);
                    connectionPoint.ProjectFileName = Path.Combine(".\\Connections", connectionPoint.Name + ".ideaCon");
                }


                // try to add Member1D objects if they are not selected by user
                foreach (var assembly in assemblies)
                {
                    if (assembly.Connections == null)
                    {
                        continue;
                    }
                    foreach (var c in assembly.Connections)
                    {
                        var ce = c as RelConnectsElements;
                        if (ce == null || curveMembers.Find(x => x.Id == ce.RelatedElement.Value) != null)
                        {
                            continue;
                        }
                        var cm = _integrationBase.ApiCore.DtObjects.GetObjectInternal(ce.RelatedElement.Value) as StructuralCurveMember;
                        if (cm != null)
                        {
                            foreach (var cm1 in pointConnections[0].ConnectsStructuralMembers)
                            {
                                if (cm.Id.ToString() == cm1.RelatingStructuralMember.GetValueOrDefault().ToString())
                                {
                                    curveMembers.Add(cm);
                                }
                            }
                        }
                    }
                }
                // create Element1D from StructuralCurveMember
                foreach (var element in curveMembers)
                {
                    var matName = element.GetStringProperty(TableNames.contentAttributes, MaterialAttributeId) ?? "S355";
                    if (!materials.ContainsKey(matName))
                    {
                        MatSteelEc2 material = new MatSteelEc2();

                        // set properties
                        material.Id                         = matId++;
                        material.Name                       = matName;
                        material.E                          = 210000000000;
                        material.G                          = material.E / (2 * (1 + 0.3));
                        material.Poisson                    = 0.3;
                        material.UnitMass                   = 7850;
                        material.SpecificHeat               = 0.6;
                        material.ThermalExpansion           = 0.000012;
                        material.ThermalConductivity        = 45;
                        material.IsDefaultMaterial          = false;
                        material.OrderInCode                = 0;
                        material.StateOfThermalExpansion    = ThermalExpansionState.Code;
                        material.StateOfThermalConductivity = ThermalConductivityState.Code;
                        material.StateOfThermalSpecificHeat = ThermalSpecificHeatState.Code;
                        material.StateOfThermalStressStrain = ThermalStressStrainState.Code;
                        material.StateOfThermalStrain       = ThermalStrainState.Code;
                        material.fy                         = 355000000;
                        material.fu                         = 510000000;
                        material.fy40                       = 335000000;
                        material.fu40                       = 470000000;
                        material.DiagramType                = SteelDiagramType.Bilinear;

                        // add material to the model
                        openModel.AddObject(material);
                        materials.Add(matName, material);
                    }

                    var crossSection = element.GetStringProperty(TableNames.contentAttributes, CrossSectionAttributeId) ?? "HE200";
                    crossSection = crossSection.Replace("HE200B", "HEB200");
                    crossSection = crossSection.Replace("HE240B", "HEB240");
                    if (!crossSections.ContainsKey(crossSection))
                    {
                        CrossSectionParameter css = new CrossSectionParameter
                        {
                            Id   = ccsId++,
                            Name = crossSection,
                            CrossSectionRotation = 0,
                            CrossSectionType     = CrossSectionType.RolledI,
                            Material             = new ReferenceElement(materials[matName])
                        };
                        css.Parameters.Add(new ParameterString()
                        {
                            Name = "UniqueName", Value = crossSection
                        });

                        // add cross sections to the model
                        openModel.AddObject(css);
                        crossSections.Add(crossSection, css);
                    }

                    if (element?.ConnectedBy.Count != 2)
                    {
                        continue;
                    }

                    var node = nodes.Find(x => x.Id == element?.ConnectedBy[0].RelatedStructuralConnection.Value);
                    if (node == null)
                    {
                        continue;
                    }
                    Point3D ptA = AddNodeToOpenModel(node, openModel, node.NodeId.GetValueOrDefault());

                    node = nodes.Find(x => x.Id == element?.ConnectedBy[1].RelatedStructuralConnection.Value);
                    Point3D ptB = AddNodeToOpenModel(node, openModel, node.NodeId.GetValueOrDefault());

                    var member1d = new Member1D
                    {
                        Id   = memberId++,
                        Name = element.Name
                    };

                    IdeaRS.OpenModel.Geometry3D.PolyLine3D polyLine3D = new IdeaRS.OpenModel.Geometry3D.PolyLine3D
                    {
                        Id = member1d.Id
                    };

                    var start      = new WM.Point3D(ptA.X, ptA.Y, ptA.Z);
                    var end        = new WM.Point3D(ptB.X, ptB.Y, ptB.Z);
                    var dirVectort = end - start;

                    GetAngles(dirVectort, out double alpha, out double beta);
                    beta *= -1;

                    CI.Geometry3D.Matrix44 lcsSegmentMatrix = new CI.Geometry3D.Matrix44();

                    if (!IsZero(beta))
                    {
                        // gamma pitch
                        lcsSegmentMatrix.Rotate(beta, new CI.Geometry3D.Vector3D(0, 1, 0));
                    }

                    if (!IsZero(alpha))
                    {
                        // beta direction
                        lcsSegmentMatrix.Rotate(alpha, new CI.Geometry3D.Vector3D(0, 0, 1));
                    }

                    IdeaRS.OpenModel.Geometry3D.LineSegment3D ls = new IdeaRS.OpenModel.Geometry3D.LineSegment3D
                    {
                        Id                    = member1d.Id,
                        StartPoint            = new ReferenceElement(ptA),
                        EndPoint              = new ReferenceElement(ptB),
                        LocalCoordinateSystem = new IdeaRS.OpenModel.Geometry3D.CoordSystemByVector()
                        {
                            VecX = new IdeaRS.OpenModel.Geometry3D.Vector3D()
                            {
                                X = lcsSegmentMatrix.AxisX.DirectionX,
                                Y = lcsSegmentMatrix.AxisX.DirectionY,
                                Z = lcsSegmentMatrix.AxisX.DirectionZ,
                            }
                            ,
                            VecY = new IdeaRS.OpenModel.Geometry3D.Vector3D()
                            {
                                X = lcsSegmentMatrix.AxisY.DirectionX,
                                Y = lcsSegmentMatrix.AxisY.DirectionY,
                                Z = lcsSegmentMatrix.AxisY.DirectionZ,
                            }
                            ,
                            VecZ = new IdeaRS.OpenModel.Geometry3D.Vector3D()
                            {
                                X = lcsSegmentMatrix.AxisZ.DirectionX,
                                Y = lcsSegmentMatrix.AxisZ.DirectionY,
                                Z = lcsSegmentMatrix.AxisZ.DirectionZ,
                            }
                        },
                    };
                    polyLine3D.Segments.Add(new ReferenceElement(ls));

                    openModel.PolyLine3D.Add(polyLine3D);
                    openModel.LineSegment3D.Add(ls);

                    Element1D element1d = new Element1D
                    {
                        Id                = member1d.Id,
                        Name              = element.Id.ToString(), //element.Name, Its esier for mapping Element1D with bimplus Structuralcurvemember
                        RotationRx        = element.GetDoubleProperty(TableNames.contentAttributes, RotationAttributeId) ?? 0,
                        CrossSectionBegin = new ReferenceElement(crossSections[crossSection]),
                        CrossSectionEnd   = new ReferenceElement(crossSections[crossSection]),
                        Segment           = new ReferenceElement(ls)
                    };
                    openModel.Element1D.Add(element1d);

                    member1d.Elements1D.Add(new ReferenceElement(element1d));

                    openModel.Member1D.Add(member1d);

                    if (connectionPoint != null)
                    {
                        ConnectedMember conMb = new ConnectedMember
                        {
                            Id           = member1d.Id,
                            MemberId     = new ReferenceElement(member1d),
                            IsContinuous = false,
                        };

                        connectionPoint.ConnectedMembers.Add(conMb);
                    }

                    BeamData beamData = new BeamData
                    {
                        Id                       = member1d.Id,
                        Name                     = element1d.Name,
                        OriginalModelId          = member1d.Id.ToString(), // member1d.Name,
                        IsAdded                  = false,
                        MirrorY                  = false,
                        RefLineInCenterOfGravity = true,
                    };

                    if (openModel.Connections.Count == 0)
                    {
                        openModel.Connections.Add(new ConnectionData());
                    }
                    (openModel.Connections[0].Beams ?? (openModel.Connections[0].Beams = new List <BeamData>())).Add(beamData);
                }

                // create Member1D from assemblies

                /* foreach (var assembly in assemblies)
                 * {
                 *   var member1d = new Member1D
                 *   {
                 *       Id = assembly.OrderNumber.GetValueOrDefault(),
                 *       Name = assembly.Name
                 *   };
                 *   foreach (var c in assembly.Connections)
                 *   {
                 *       var ce = c as RelConnectsElements;
                 *       var element = openModel.Element1D.Find(x => x.Name == ce.RelatedElement.ToString());
                 *       if (element == null) continue;
                 *       member1d.Elements1D.Add(new ReferenceElement(element));
                 *       openModel.Member1D.Add(member1d);
                 *   }
                 * }*/

                /*if (connectionPoint != null)
                 * {
                 *   var p0t = pointConnections.Find(x => x.NodeId.GetValueOrDefault() == ConnectionPointId);
                 *   if (p0t != null && p0t.ConnectsStructuralMembers != null)
                 *   {
                 *       foreach (var cm in p0t.ConnectsStructuralMembers)
                 *       {
                 *           var member = openModel.Element1D.Find(x => x.Name == cm.RelatingStructuralMember.GetValueOrDefault().ToString());
                 *           if (member == null)
                 *               continue;
                 *           ConnectedMember conMb = new ConnectedMember
                 *           {
                 *               Id = member.Id,
                 *               MemberId = new ReferenceElement(member),
                 *               IsContinuous = false,
                 *           };
                 *           connectionPoint.ConnectedMembers.Add(conMb);
                 *
                 *           // BEAM DATA - definition
                 *           BeamData bData = new BeamData
                 *           {
                 *               Id = conMb.Id,
                 *               OriginalModelId = "???", // ass.Id.ToString(), is it important?
                 *               IsAdded = false,
                 *               MirrorY = false,
                 *               RefLineInCenterOfGravity = false,
                 *           };
                 *           if (openModel.Connections.Count == 0)
                 *           {
                 *               openModel.Connections.Add(new ConnectionData { Beams = new List<BeamData>() });
                 *           }
                 *           openModel.Connections[0].Beams.Add(bData);
                 *       }
                 *   }
                 *
                 * }*/
                openModel.AddObject(connectionPoint); // important !!!

                OpenModelResult openModelResult =
                    new OpenModelResult()
                {
                    ResultOnMembers = new System.Collections.Generic.List <ResultOnMembers>()
                    {
                        new ResultOnMembers()
                    }
                };
                OpenMessages openMessages = new OpenMessages();

                return(new ModelBIM()
                {
                    Items = new List <BIMItemId>()
                    {
                        new BIMItemId()
                        {
                            Id = connectionPoint.Id, Type = BIMItemType.Node
                        }
                    },
                    Model = openModel,
                    Results = openModelResult,
                    Messages = openMessages,
                    Project = AllplanBimplusDemo.Properties.Settings.Default.IdeaDefaultWorkingDir,
                });
            }
            catch (Exception e)
            {
                MessageBoxHelper.ShowInformation(e.Message, null);
                return(null);
            }
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            IdeaInstallDir = IOM.SteelFrameDesktop.Properties.Settings.Default.IdeaInstallDir;

            if (!Directory.Exists(IdeaInstallDir))
            {
                Console.WriteLine("IDEA StatiCa installation was not found in '{0}'", IdeaInstallDir);
                return;
            }

            Console.WriteLine("IDEA StatiCa installation directory is '{0}'", IdeaInstallDir);

            Console.WriteLine("Select the required example");
            Console.WriteLine("1  - Steel frame ECEN");
            Console.WriteLine("2  - Simple frame AUS");

            var option = Console.ReadLine();

            OpenModel       iom       = null;
            OpenModelResult iomResult = null;

            if (option.Equals("2", StringComparison.InvariantCultureIgnoreCase))
            {
                Console.WriteLine("Generating Australian steel frame ...");

                // create IOM and results
                iom       = SimpleFrameAUS.CreateIOM();
                iomResult = null;
            }
            else
            {
                Console.WriteLine("Generating ECEN steel frame ...");

                // create IOM and results
                iom       = SteelFrameExample.CreateIOM();
                iomResult = Helpers.GetResults();
            }

            string iomFileName    = "example.xml";
            string iomResFileName = "example.xmlR";

            // save to the files
            iom.SaveToXmlFile(iomFileName);

            if (iomResult != null)
            {
                iomResult.SaveToXmlFile(iomResFileName);
            }
            else
            {
                iomResFileName = string.Empty;
            }

            var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            var fileConnFileNameFromLocal = Path.Combine(desktopDir, "connectionFromIOM-local.ideaCon");

            var calcFactory = new ConnHiddenClientFactory(IdeaInstallDir);

            var client = calcFactory.Create();

            try
            {
                // it creates connection project from IOM
                Console.WriteLine("Creating Idea connection project ");
                client.CreateConProjFromIOM(iomFileName, iomResFileName, fileConnFileNameFromLocal);
                Console.WriteLine("Generated project was saved to the file '{0}'", fileConnFileNameFromLocal);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error '{0}'", e.Message);
            }
            finally
            {
                if (client != null)
                {
                    client.Close();
                }
            }

            // end console application
            Console.WriteLine("Done. Press any key to exit.");
            Console.ReadKey();
        }