Esempio n. 1
0
        private HashSet <ObjectId> GetSelectedBlocks()
        {
            blocksCompleteInput = true;
            HashSet <ObjectId> blocks = new HashSet <ObjectId>();

            foreach (BlockStructureMappingPairModel bsModel in BlocksStructuresMappingColl)
            {
                BlockTableRecord btr = bsModel.BlockVM.SelectedBlock;
                PartFamily       pf  = bsModel.StructureVM.SelectedPartFamily?.PartFamily;
                PartSize         ps  = bsModel.StructureVM.SelectedPartSize;

                if (btr != null)                  //проверка, что блок введен в строку
                {
                    if (!blocks.Contains(btr.Id)) //блоки могут повторяться!!!
                    {
                        blocks.Add(btr.Id);
                    }
                }
                else
                {
                    blocksCompleteInput = false;
                    //ввод неполный, то считать ввод не выполнен вообще
                    blocks.Clear();
                    break;
                }
            }
            return(blocks);
        }
Esempio n. 2
0
        private Dictionary <ObjectId, SelectedPartTypeId> GetBlockStructureMapping()
        {
            blocksStructureMappingCompleteInput = true;
            Dictionary <ObjectId, SelectedPartTypeId> mapping
                = new Dictionary <ObjectId, SelectedPartTypeId>();

            foreach (BlockStructureMappingPairModel bsModel in BlocksStructuresMappingColl)
            {
                BlockTableRecord btr = bsModel.BlockVM.SelectedBlock;
                PartFamily       pf  = bsModel.StructureVM.SelectedPartFamily?.PartFamily;
                PartSize         ps  = bsModel.StructureVM.SelectedPartSize;

                if (btr != null && pf != null && ps != null) //проверка, что ввод в строку полный
                {
                    if (!mapping.ContainsKey(btr.Id))        //блоки могут повторяться!!!
                    {
                        mapping.Add(btr.Id, new SelectedPartTypeId(pf.Id, ps.Id));
                    }
                }
                else
                {
                    blocksStructureMappingCompleteInput = false;
                    //ввод неполный, то считать ввод не выполнен вообще
                    mapping.Clear();
                    break;
                }
            }
            return(mapping);
        }
Esempio n. 3
0
        public bool EqualETag(S3ObjectInfo s3Object, FileInfo fileInfo, PartSize partSize)
        {
            if (s3Object is null)
            {
                throw new ArgumentNullException(nameof(s3Object));
            }

            return(s3Object.ETag == ComputeLocalETag(fileInfo, partSize));
        }
Esempio n. 4
0
        private ObservableCollection <SelectPartFamilyModel> GetPartFams(Document doc, PartsList partsList,
                                                                         ObjectId defPartFamIfExists, ObjectId defPartSizeIfExists)
        {
            ObservableCollection <SelectPartFamilyModel> partfams = new ObservableCollection <SelectPartFamilyModel>();
            Database db = doc.Database;

            pfStartSelection = null;
            psStartSelection = null;


            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                for (int i = 0; i < partsList.PartFamilyCount; i++)
                {
                    ObjectId   plFamId = partsList[i];
                    PartFamily pf      = (PartFamily)tr.GetObject(plFamId, OpenMode.ForRead);



                    if (partType.HasFlag(pf.PartType))
                    {
                        ObservableCollection <PartSize> partSizes = new ObservableCollection <PartSize>();
                        PartSize startSelSizeCandidate            = null;
                        for (int j = 0; j < pf.PartSizeCount; j++)
                        {
                            ObjectId psId = pf[j];
                            PartSize ps   = (PartSize)psId.GetObject(OpenMode.ForRead);
                            if (defPartSizeIfExists.Equals(psId))
                            {
                                startSelSizeCandidate = ps;
                            }
                            partSizes.Add(ps);
                        }

                        SelectPartFamilyModel spfm = new SelectPartFamilyModel(pf, partSizes);
                        if (defPartFamIfExists.Equals(plFamId))
                        {
                            pfStartSelection = spfm;
                            if (startSelSizeCandidate != null)
                            {
                                psStartSelection = startSelSizeCandidate;
                            }
                        }
                        partfams.Add(spfm);
                    }
                }


                tr.Commit();
            }

            return(partfams);
        }
Esempio n. 5
0
        private static string ComputeLocalETag(FileInfo fileInfo, PartSize partSize)
        {
            if (fileInfo is null)
            {
                throw new ArgumentNullException(nameof(fileInfo));
            }

            if (partSize is null)
            {
                throw new ArgumentNullException(nameof(partSize));
            }

            var localETag = "";

            using (var md5 = MD5.Create())
            {
                var br         = new BinaryReader(new FileStream(fileInfo.FullName, FileMode.Open));
                var sumIndex   = 0;
                var parts      = 0;
                var hashLength = md5.HashSize / 8;
                var n          = ((fileInfo.Length / partSize) * hashLength) + ((fileInfo.Length % partSize != 0) ? hashLength : 0);
                var sum        = new byte[n];
                var a          = (fileInfo.Length > partSize) ? partSize : (int)fileInfo.Length;
                while (sumIndex < sum.Length)
                {
                    md5.ComputeHash(br.ReadBytes(a)).CopyTo(sum, sumIndex);
                    parts++;
                    if (parts * partSize > fileInfo.Length)
                    {
                        a = (int)fileInfo.Length % partSize;
                    }

                    sumIndex += hashLength;
                }

                if (parts > 1)
                {
                    sum = md5.ComputeHash(sum);
                }

                for (var i = 0; i < sum.Length; i++)
                {
                    localETag = Invariant($"{localETag}{sum[i]:x2}");
                }

                localETag = Invariant($"\"{localETag}{((parts > 1) ? $"-{parts}\"" : "\"")}");
            }

            return(localETag);
        }
        public bool EqualETag(S3ObjectInfo s3Object, FileInfo fileInfo, PartSize partSize)
        {
            if (s3Object is null)
            {
                throw new ArgumentNullException(nameof(s3Object));
            }

            if (fileInfo is null)
            {
                throw new ArgumentNullException(nameof(fileInfo));
            }

            if (_inner.EqualETag(s3Object, fileInfo, partSize))
            {
                _log.PutOut($"Hash {s3Object.Key} {fileInfo.Name} matched.");
                return(true);
            }

            _log.PutOut($"File {fileInfo.Name} hash does not match S3Object {s3Object.Key} hash.");
            return(false);
        }
Esempio n. 7
0
        public void Save()
        {
            XmlDocument    document = new XmlDocument();
            XmlDeclaration decl     = document.CreateXmlDeclaration("1.0", "UTF-8", null);

            document.AppendChild(decl);

            XmlElement rootElem = document.CreateElement("Configuration");

            document.AppendChild(rootElem);

            XmlElement cameraList = document.CreateElement("CameraList");

            rootElem.AppendChild(cameraList);

            foreach (CameraSettings cameraSetting in CameraSettingsList)
            {
                XmlElement camera = AddElementWithAttribute(document, cameraList, "Camera", "Name", cameraSetting.Name);
                AddElementWithValue(document, camera, "SourceFolder", cameraSetting.SourceFolder);
                AddElementWithValue(document, camera, "Identifier", cameraSetting.Identifier);
                AddElementWithValue(document, camera, "TargetFolder", cameraSetting.TargetFolder);
                AddElementWithValue(document, camera, "TargetFile", cameraSetting.TargetFile);
            }

            AddElementWithAttribute(document, rootElem, "TimerSetting", "Value", TimerSetting.ToString());
            AddElementWithAttribute(document, rootElem, "PartSize", "Value", PartSize.ToString());
            AddElementWithValue(document, rootElem, "MeteoInfoFile", MeteoInfoFile);

            AddElementWithAttribute(document, rootElem, "MeteoInfoFont", "Name", MeteoInfoFont.FontFamily.Name, "Size", MeteoInfoFont.Size.ToString(Thread.CurrentThread.CurrentUICulture));
            AddElementWithAttribute(document, rootElem, "MeteoInfoFontColor", "Color", MeteoInfoFontColor.ToKnownColor().ToString());
            AddElementWithAttribute(document, rootElem, "MeteoInfoOutlineColor", "Color", MeteoInfoOutlineColor.ToKnownColor().ToString());
            AddElementWithAttribute(document, rootElem, "MeteoInfoOutlineWidth", "Value", MeteoInfoOutlineWidth.ToString());

            AddElementWithAttribute(document, rootElem, "Hostname", "Value", Hostname);
            AddElementWithAttribute(document, rootElem, "Username", "Value", Username);
            AddElementWithAttribute(document, rootElem, "Password", "Value", Password);

            document.Save(ConfigFile);
        }
Esempio n. 8
0
        public async Task <bool> TryUploadObjects(IEnumerable <FileInfo> filesInfo, ObjectKeyCreator keyCreator, PartSize partSize)
        {
            _log.PutOut($"Try upload multiple objects.");
            foreach (var fileInfo in filesInfo)
            {
                if (!await _inner.TryUploadObjectToBucket(fileInfo, keyCreator, partSize).ConfigureAwait(false))
                {
                    _log.PutOut($"Multiple upload skipped.");
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 9
0
        private async Task MultipartUploadObject(FileInfo fileInfo, string objectKey, PartSize partSize)
        {
            if (fileInfo is null)
            {
                throw new ArgumentNullException(nameof(fileInfo));
            }

            if (partSize is null)
            {
                throw new ArgumentNullException(nameof(partSize));
            }

            var multipartUploadRequest = new InitiateMultipartUploadRequest()
            {
                BucketName = _bucketName,
                Key        = objectKey,
            };

            await Initialize().ConfigureAwait(false);

            var multipartUploadResponse = await Client.InitiateMultipartUploadAsync(multipartUploadRequest).ConfigureAwait(false);

            var a = (fileInfo.Length > partSize) ? partSize : (int)fileInfo.Length;

            try
            {
                var taskList      = new List <Task <UploadPartResponse> >();
                var partResponses = new List <UploadPartResponse>();
                for (var i = 0; partSize *i < fileInfo.Length; i++)
                {
                    var upload = new UploadPartRequest()
                    {
                        BucketName   = _bucketName,
                        Key          = objectKey,
                        UploadId     = multipartUploadResponse.UploadId,
                        PartNumber   = i + 1,
                        PartSize     = a,
                        FilePosition = partSize * i,
                        FilePath     = fileInfo.FullName,
                    };
                    if ((i + 1) * partSize > fileInfo.Length)
                    {
                        a = (int)fileInfo.Length % partSize;
                    }

                    if (taskList.Count >= _parallelParts)
                    {
                        await Task.WhenAny(taskList).ConfigureAwait(false);

                        foreach (var task in taskList)
                        {
                            if (task.IsCompleted)
                            {
                                partResponses.Add(await task.ConfigureAwait(false));
                                taskList.Remove(task);
                            }
                        }
                    }
                    else
                    {
                        taskList.Add(Client.UploadPartAsync(upload));
                    }
                }

                foreach (var task in taskList)
                {
                    partResponses.Add(await task.ConfigureAwait(false));
                }

                var completeRequest = new CompleteMultipartUploadRequest
                {
                    BucketName = _bucketName,
                    Key        = objectKey,
                    UploadId   = multipartUploadResponse.UploadId,
                };
                completeRequest.AddPartETags(partResponses);
                var completeUploadResponse = await Client.CompleteMultipartUploadAsync(completeRequest).ConfigureAwait(false);
            }
            catch
            {
                var abortMultipartUploadRequest = new AbortMultipartUploadRequest
                {
                    BucketName = _bucketName,
                    Key        = objectKey,
                    UploadId   = multipartUploadResponse.UploadId,
                };
                await Client.AbortMultipartUploadAsync(abortMultipartUploadRequest).ConfigureAwait(false);

                throw;
            }
        }
 public async Task UploadObjects(IEnumerable <FileInfo> filesInfo, ObjectKeyCreator keyCreator, PartSize partSize)
 {
     await _dryRun.TryUploadObjects(filesInfo, keyCreator, partSize).ConfigureAwait(false);
 }
Esempio n. 11
0
        public async Task <bool> TryUploadObjectToBucket(FileInfo fileInfo, ObjectKeyCreator keyCreator, PartSize partSize)
        {
            if (fileInfo is null)
            {
                throw new ArgumentNullException(nameof(fileInfo));
            }

            _log.PutOut($"Try upload {fileInfo.Name} to bucket.");
            if (!await _inner.TryUploadObjectToBucket(fileInfo, keyCreator, partSize).ConfigureAwait(false))
            {
                _log.PutOut($"{fileInfo.Name} upload skipped.");
                return(false);
            }

            return(true);
        }
Esempio n. 12
0
        public void ChangePipeType()
        {
            Document adoc = Application.DocumentManager.MdiActiveDocument;

            if (adoc == null)
            {
                return;
            }

            Database db = adoc.Database;

            Editor ed = adoc.Editor;

            try
            {
                //выбор элементов сети (TODO: или использовать текущий выбор объектов)
                //отобрать только трубы
                PromptSelectionOptions pso = new PromptSelectionOptions();
                pso.MessageForAdding = "\nВыберите трубы:";

                TypedValue[]    tv  = new TypedValue[] { new TypedValue(0, "AECC_PIPE") };
                SelectionFilter flt = new SelectionFilter(tv);

                PromptSelectionResult acSSPrompt = adoc.Editor.GetSelection(pso, flt);


                if (acSSPrompt.Status != PromptStatus.OK)
                {
                    return;
                }

                //определить каталог
                //трубы должны принадлежать к одному каталогу иначе отменить
                SelectionSet acSSet = acSSPrompt.Value;
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    ObjectId    partsListId = ObjectId.Null;
                    List <Pipe> pipes       = new List <Pipe>();

                    ObjectId defPartFam  = ObjectId.Null;
                    ObjectId defPartSize = ObjectId.Null;

                    foreach (ObjectId id in acSSet.GetObjectIds())
                    {
                        Pipe pipe = null;
                        //using (Transaction tr = db.TransactionManager.StartTransaction())
                        //{
                        pipe = tr.GetObject(id, OpenMode.ForRead) as Pipe;
                        //    tr.Commit();
                        //}
                        if (pipe == null)
                        {
                            continue;
                        }


                        pipes.Add(pipe);

                        Network network = null;
                        //using (Transaction tr = db.TransactionManager.StartTransaction())
                        //{
                        network = tr.GetObject(pipe.NetworkId, OpenMode.ForRead) as Network;
                        //    tr.Commit();
                        //}
                        if (partsListId == ObjectId.Null)
                        {
                            partsListId = network.PartsListId;
                        }
                        else if (partsListId != network.PartsListId)
                        {
                            ed.WriteMessage("\nВыбранные трубы относятся к разным PartsList");
                            return;
                        }

                        //Нельзя узнать текущий PartFamily и PartSize???
                        //pipe.SwapPartFamilyAndSize
                    }

                    if (partsListId == ObjectId.Null)
                    {
                        return;
                    }

                    PartsList partsList = null;
                    //using (Transaction tr = db.TransactionManager.StartTransaction())
                    //{
                    partsList = tr.GetObject(partsListId, OpenMode.ForRead) as PartsList;
                    //    tr.Commit();
                    //}

                    //вывести окно с выбором нового типа трубы (если выбранные трубы имели одинаковый тип, то отобразить его)
                    SetPipeTypeViewModel viewModel = new SetPipeTypeViewModel(adoc, partsList);
                    SetPipeTypeView      view      = new SetPipeTypeView();
                    view.DataContext = viewModel;

                    Application.ShowModalWindow(view);

                    if (!view.DialogResult.HasValue || !view.DialogResult.Value)
                    {
                        return;
                    }

                    //задать выбранный тип трубы
                    PartFamily partFamily = viewModel.PipeVM.SelectedPartFamily.PartFamily;
                    PartSize   partSize   = viewModel.PipeVM.SelectedPartSize;


                    foreach (Pipe pipe in pipes)
                    {
                        pipe.SwapPartFamilyAndSize(partFamily.Id, partSize.Id);
                    }

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                CommonException(ex, "Ошибка при попытке изменить тип труб");
            }
        }
 public async Task UploadObjectToBucket(FileInfo fileInfo, ObjectKeyCreator keyCreator, PartSize partSize)
 {
     await _dryRun.TryUploadObjectToBucket(fileInfo, keyCreator, partSize).ConfigureAwait(false);
 }
Esempio n. 14
0
 public async Task UploadObjectToBucket(FileInfo fileInfo, ObjectKeyCreator keyCreator, PartSize partSize)
 {
     await CommonExceptionHandler(_inner.UploadObjectToBucket(fileInfo, keyCreator, partSize)).ConfigureAwait(false);
 }
Esempio n. 15
0
        makePipeNetwork(ObjectId idAlign, string nameNetwork, string pipeType)
        {
            string pntDesc = fMNP.pntDesc;

            Point3d pnt3dPick = Pub.pnt3dO;

            if (idAlign == ObjectId.Null)
            {
                Autodesk.AutoCAD.DatabaseServices.Entity ent = Select.selectEntity(typeof(Alignment), "Select Alignment: ", "Selected object was not an alignment. Try again: ", out pnt3dPick);
                idAlign = ent.ObjectId;
            }

            Network            net   = null;
            ObjectIdCollection ids   = CivilApplication.ActiveDocument.GetPipeNetworkIds();
            ObjectId           idNet = ObjectId.Null;

            if (ids.Count == 0)
            {
                idNet = Network.Create(CivilApplication.ActiveDocument, ref nameNetwork);
            }
            else
            {
                for (int i = 0; i < ids.Count; i++)
                {
                    net = (Network)ids[i].getEnt();
                    //if (net.Name == nameNetwork){
                    //    string index = Align.getAlignIndex(nameNetwork);
                    //    nameNetwork = string.Format("{0}-{1}", nameNetwork, index);
                    //    break;
                    //}
                }
                idNet = Network.Create(CivilApplication.ActiveDocument, ref nameNetwork);
            }

            bool exists = false;

            Alignment align = (Alignment)idAlign.getEnt();
            AlignmentEntityCollection ents = align.Entities;
            TinSurface tinSurfDE           = Surf.getTinSurface("CPNT-ON", out exists);

            List <AlgnEntData> algnData = MNP_Align.sortAlignEnts(align);
            List <string>      hPipe    = new List <string>();
            List <ObjectId>    idsCgPnt = new List <ObjectId>();

            ObjectId idPipe, idPipeSize, idStruct, idStructSize;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                net = (Network)tr.GetObject(idNet, OpenMode.ForWrite);
                net.ReferenceAlignmentId = idAlign;
                net.ReferenceSurfaceId   = Surf.getTinSurface("CPNT-ON", out exists).ObjectId;

                ObjectId  idPartsList = CivilApplication.ActiveDocument.Styles.PartsListSet["Standard"];
                PartsList partsList   = (PartsList)tr.GetObject(idPartsList, OpenMode.ForRead);

                idPipe = partsList["Concrete Pipe"];
                PartFamily partFamily = (PartFamily)tr.GetObject(idPipe, OpenMode.ForWrite);

                idPipeSize = partFamily[0];

                PartSize        partSize = (PartSize)tr.GetObject(idPipeSize, OpenMode.ForRead);
                PartDataRecord  pdr      = partSize.SizeDataRecord;
                PartDataField[] pdf      = pdr.GetAllDataFields();

                for (int i = 0; i < pdf.Length; i++)
                {
                    System.Diagnostics.Debug.Print(string.Format("{0}: {1}", pdf[i].Description, pdf[i].Value.ToString()));
                }

                idStruct     = partsList["Rectangular Structure Slab Top Rectangular Frame"];
                partFamily   = (PartFamily)tr.GetObject(idStruct, OpenMode.ForWrite);
                idStructSize = partFamily[0];

                double depth = -6, slope = 0, dZ = 0, top = 0;
                double diam = double.Parse(pdf[0].Value.ToString()) / 12;

                ObjectId idPipeNew = ObjectId.Null;

                AlignmentEntity ent    = null;
                Structure       sPrev  = null;
                uint            pntNum = 0;

                ObjectId     idCgPntBeg, idCgPntEnd, idCgPntPrev = ObjectId.Null;
                TypedValue[] tvs;

                for (int i = 0; i < algnData.Count; i++)
                {
                    if (algnData.Count == 1)
                    {
                        ent = ents[0];
                    }
                    else
                    {
                        ent = ents.EntityAtId(algnData[i].ID);
                    }

                    ObjectId  idStructNew = ObjectId.Null;
                    Structure s           = null;
                    Pipe      p           = null;

                    if (ent.EntityType == AlignmentEntityType.Line)
                    {
                        AlignmentLine line     = (AlignmentLine)ent;
                        Point2d       pnt2dBeg = line.StartPoint;
                        Point2d       pnt2dEnd = line.EndPoint;

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dBeg.X, pnt2dBeg.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        Point3d pnt3dBeg = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, top);

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dEnd.X, pnt2dEnd.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        Point3d pnt3dEnd = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, top);

                        LineSegment3d seg3d = new LineSegment3d(pnt3dBeg, pnt3dEnd);

                        net.AddLinePipe(idPipe, idPipeSize, seg3d, ref idPipeNew, true);

                        p = (Pipe)idPipeNew.getEnt();
                        p.AddToProfileView(fMNP.idProfileView);

                        ObjectId idPart = getProfileViewPart();

                        slope = pnt3dBeg.getSlope(pnt3dEnd);

                        dZ = diam / (2 * (System.Math.Cos(System.Math.Atan(System.Math.Abs(slope)))));

                        if (i == 0)
                        {
                            pnt3dBeg = new Point3d(pnt3dBeg.X, pnt3dBeg.Y, pnt3dBeg.Z - dZ);
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntBeg = pnt3dBeg.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntBeg);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            idCgPntPrev = idCgPntEnd;

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntBeg.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);

                            net.AddStructure(idStruct, idStructSize, pnt3dEnd, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);

                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                        else
                        {
                            pnt3dEnd   = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);
                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntPrev.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            idCgPntPrev = idCgPntEnd;

                            net.AddStructure(idStruct, idStructSize, pnt3dEnd, 0, ref idStructNew, true);
                            s = (Structure)idStructNew.getEnt();
                            s.AddToProfileView(fMNP.idProfileView);
                            sPrev.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);

                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                    }
                    else if (ent.EntityType == AlignmentEntityType.Arc)
                    {
                        AlignmentArc arc    = (AlignmentArc)ent;
                        double       radius = arc.Radius;

                        Point2d pnt2dBeg = arc.StartPoint;
                        Point2d pnt2dEnd = arc.EndPoint;

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dBeg.X, pnt2dBeg.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }
                        Point3d pnt3dBeg = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, top);

                        try
                        {
                            top = tinSurfDE.FindElevationAtXY(pnt2dEnd.X, pnt2dEnd.Y) + depth;
                        }
                        catch (System.Exception)
                        {
                            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Pipe endpoint is beyond limit of design surface");
                            return;
                        }

                        IntPtr  iptr     = (IntPtr)0;
                        Point3d pnt3dEnd = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, top);

                        Arc a = new Arc();
                        a.Radius     = arc.Radius;
                        a.StartPoint = new Point3d(pnt2dBeg.X, pnt2dBeg.Y, 0);
                        a.EndPoint   = new Point3d(pnt2dEnd.X, pnt2dEnd.Y, 0);
                        a.Center     = new Point3d(arc.CenterPoint.X, arc.CenterPoint.Y, 0);

                        Curve3d c = (Curve3d)a.GetGeCurve();

                        net.AddCurvePipe(idPipe, idPipeSize, c, arc.Clockwise, ref idPipeNew, true);

                        p = (Pipe)idPipeNew.getEnt();
                        p.AddToProfileView(fMNP.idProfileView);

                        ObjectId idPart = getProfileViewPart();
                        slope = (pnt3dEnd.Z - pnt3dBeg.Z) / arc.Length;

                        dZ = diam / (2 * (System.Math.Cos(System.Math.Atan(System.Math.Abs(slope)))));

                        if (i == 0)
                        {
                            pnt3dBeg = new Point3d(pnt3dBeg.X, pnt3dBeg.Y, pnt3dBeg.Z - dZ);
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntBeg = pnt3dBeg.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntBeg);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntBeg.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);
                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                        else
                        {
                            pnt3dEnd = new Point3d(pnt3dEnd.X, pnt3dEnd.Y, pnt3dEnd.Z - dZ);

                            idCgPntEnd = pnt3dEnd.setPoint(out pntNum, pntDesc);
                            idsCgPnt.Add(idCgPntEnd);

                            tvs = new TypedValue[3];
                            tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                            tvs.SetValue(new TypedValue(1005, idCgPntPrev.getHandle().ToString()), 1);
                            tvs.SetValue(new TypedValue(1005, idCgPntEnd.getHandle().ToString()), 2);

                            //idPart.setXData(rb, apps.lnkMNP);
                            idPipeNew.setXData(tvs, apps.lnkMNP);

                            idCgPntPrev = idCgPntEnd;

                            net.AddStructure(idStruct, idStructSize, pnt3dBeg, 0, ref idStructNew, true);
                            s = (Structure)tr.GetObject(idStructNew, OpenMode.ForWrite);
                            s.AddToProfileView(fMNP.idProfileView);
                            sPrev.ConnectToPipe(idPipeNew, ConnectorPositionType.Start);
                            s.ConnectToPipe(idPipeNew, ConnectorPositionType.End);
                            sPrev = s;
                            hPipe.Add(idPipeNew.getHandle().ToString());
                        }
                    }
                }
                tr.Commit();
            }

            hPipe.Insert(0, "-1");
            hPipe.Add("-1");

            for (int i = 0; i < idsCgPnt.Count; i++)
            {
                TypedValue[] tvs = new TypedValue[3];
                tvs.SetValue(new TypedValue(1001, apps.lnkMNP), 0);
                tvs.SetValue(new TypedValue(1005, hPipe[i]), 1);
                tvs.SetValue(new TypedValue(1005, hPipe[i + 1]), 2);
                idsCgPnt[i].setXData(tvs, apps.lnkMNP);
            }
        }
        public async Task <bool> TryUploadObjectToBucket(FileInfo fileInfo, ObjectKeyCreator keyCreator, PartSize partSize)
        {
            if (!_dryRun)
            {
                await _amazonFunctions
                .UploadObjectToBucket(fileInfo, keyCreator, partSize)
                .ConfigureAwait(false);
            }

            return(!_dryRun);
        }
        public async Task UploadObjectToBucket(FileInfo fileInfo, ObjectKeyCreator keyCreator, PartSize partSize)
        {
            if (fileInfo is null)
            {
                throw new ArgumentNullException(nameof(fileInfo));
            }

            if (keyCreator is null)
            {
                throw new ArgumentNullException(nameof(keyCreator));
            }

            _log.PutOut($"Upload {keyCreator(fileInfo.FullName)} to bucket started.");
            await _inner.UploadObjectToBucket(fileInfo, keyCreator, partSize).ConfigureAwait(false);

            _log.PutOut($"Uploaded");
        }
Esempio n. 18
0
 public Hardpoint(PartSize _allowableSize, PartType _allowableType, Orientation _orientation)
 {
     allowableSize = _allowableSize;
     allowableType = _allowableType;
     orientation   = _orientation;
 }
        public async Task <bool> TryUploadObjects(IEnumerable <FileInfo> filesInfo, ObjectKeyCreator keyCreator, PartSize partSize)
        {
            if (!_dryRun)
            {
                foreach (var fileInfo in filesInfo)
                {
                    await _amazonFunctions
                    .UploadObjectToBucket(fileInfo, keyCreator, partSize)
                    .ConfigureAwait(false);
                }
            }

            return(!_dryRun);
        }
Esempio n. 20
0
        public async Task UploadObjectToBucket(FileInfo fileInfo, ObjectKeyCreator keyCreator, PartSize partSize)
        {
            if (fileInfo is null)
            {
                throw new ArgumentNullException(nameof(fileInfo));
            }

            if (keyCreator is null)
            {
                throw new ArgumentNullException(nameof(keyCreator));
            }

            if (partSize is null)
            {
                throw new ArgumentNullException(nameof(partSize));
            }

            await Initialize().ConfigureAwait(false);

            var objectKey = keyCreator(fileInfo.FullName);

            if (fileInfo.Length <= partSize)
            {
                var putObjectRequest = new PutObjectRequest
                {
                    BucketName = _bucketName,
                    Key        = objectKey,
                    FilePath   = fileInfo.FullName,
                };

                var putObjectResponse = await Client.PutObjectAsync(putObjectRequest).ConfigureAwait(false);
            }
            else
            {
                await MultipartUploadObject(fileInfo, objectKey, partSize).ConfigureAwait(false);
            }
        }