Example #1
0
        public void ConvertToTCBolt(int ObjectId)
        {
            PsObjectProperties psObjectProperties = new PsObjectProperties();
            PsTransaction      psTransaction      = new PsTransaction();

            psObjectProperties.readFrom(ObjectId);
            if (psObjectProperties.ObjectType == ObjectType.kBolt)
            {
                PsBolt standardBolt = new PsBolt();
                psTransaction.GetObject((long)ObjectId, PsOpenMode.kForWrite, ref standardBolt);
                if ((new ArrayList(new string[] { "A325 SHOP", "A325 FIELD", "A490 SHOP", "A490 FIELD" })).Contains(standardBolt.BoltStyleName))
                {
                    SetStandardBoltParams(standardBolt.Diameter, standardBolt.BoltStyleName, standardBolt.LengthAddition);
                    Length      = standardBolt.Length;
                    Diameter    = standardBolt.Diameter;
                    KlemmLength = standardBolt.KlemmLength;
                    InsertPoint = standardBolt.InsertPoint;
                    XAxis       = standardBolt.XAxis;
                    YAxis       = standardBolt.YAxis;
                    PsPoint  psEndPoint = new PsPoint();
                    PsVector tempVector = new PsVector();
                    tempVector.SetFromCrossProduct(XAxis, YAxis);
                    tempVector.Normalize();
                    ZAxis      = tempVector.Clone();
                    psEndPoint = InsertPoint.Clone();
                    psEndPoint.AddScaled(ZAxis, KlemmLength);
                    CreateByTwoPoints(InsertPoint, psEndPoint);
                    psTransaction.Close();
                    psTransaction.EraseLongId((long)ObjectId);
                }
                psTransaction.Close();
            }
        }
        internal Model.LocalUserGroup Map(PSObject result)
        {
            var properties = new PsObjectProperties(result);

            var model = new Model.LocalUserGroup();

            model.Name        = properties.Get <string>("Name");
            model.Description = properties.Get <string>("Description");

            model.Members = new List <string>();

            return(model.Name == null? null : model);
        }
Example #3
0
        internal LocalUserInfo MapToLocalUserInfo(PSObject result)
        {
            if (result == null)
            {
                return(null);
            }

            var properties = new PsObjectProperties(result);

            var flags = properties.Get("UserFlags") ?? default(int);

            var userFlags = new UserFlags((int)flags);

            var user = new LocalUserInfo();

            user.Sid         = result.Properties["SecurityId"]?.Value as string;
            user.Name        = properties.Get <string>("Name");
            user.FullName    = properties.Get <string>("FullName");
            user.Description = properties.Get <string>("Description");

            user.PasswordCanBeChangedByUser = userFlags.PasswordCanBeChangedByUser;
            user.PasswordRequired           = userFlags.PasswordRequired;
            user.AccountDisabled            = userFlags.AccountDisabled;
            user.AccountLocked = userFlags.AccountLocked;

            user.PasswordMaxBadAttempts = properties.GetValue <int>("MaxBadPasswordsAllowed");

            user.PasswordBadAttemptsInterval = properties.GetTimeSpan("LockoutObservationInterval");
            user.AutoUnlockInterval          = properties.GetTimeSpan("AutoUnlockInterval");
            user.LastLogon         = properties.GetDateTime("LastLogin");
            user.PasswordMinLength = properties.GetValue <int>("MinPasswordLength");

            var accountExpirationDate = properties.GetTimeSpan("AccountExpirationDate");
            var passwordAge           = properties.GetTimeSpan("PasswordAge");
            var maxPasswordAge        = properties.GetTimeSpan("MaxPasswordAge");
            var passwordExpired       = properties.GetValue <int>("PasswordExpired");

            user.PasswordLastChange = DateTime.Now.Add(passwordAge.Negate()).Date;

            user.AccountExpires = GetExpirationDate(TimeSpan.Zero, accountExpirationDate);

            user.PasswordExpires = userFlags.PasswordCanExpire
                ? GetExpirationDate(passwordAge, maxPasswordAge)
                : null;

            user.PasswordMustBeChangedAtNextLogon = IsPasswordChangeRequiredOnNextLogon(passwordAge, passwordExpired);

            return(user);
        }
Example #4
0
        public int CreateAnchorCode111(PsPoint Point1, PsPoint Point2)
        {
            PsCreatePrimitive psCylinder   = new PsCreatePrimitive();
            PsCreatePrimitive psWasher     = new PsCreatePrimitive();
            PsCreatePrimitive psNut        = new PsCreatePrimitive();
            PsPolygon         psNutPolygon = new PsPolygon();

            PsVector psVector1 = new PsVector();
            PsVector psVector2 = new PsVector();
            PsVector psVector3 = new PsVector();
            PsVector psVector  = new PsVector();

            psVector1.SetFromPoints(Point1, Point2);
            psVector2 = psVector.GetPerpendicularVector(psVector1);
            psVector3.SetFromCrossProduct(psVector1, psVector2);

            InsertPoint = Point1;

            psVector1.Normalize();
            psVector2.Normalize();
            psVector3.Normalize();

            ZAxis = psVector1;
            XAxis = psVector2;
            YAxis = psVector3;

            PsVector XAxisNegative = new PsVector();

            XAxisNegative = XAxis.Clone();
            XAxisNegative.Invert();

            //Cylinder
            PsPoint CylinderInsertPoint = new PsPoint();

            CylinderInsertPoint = InsertPoint.Clone();
            CylinderInsertPoint.AddScaled(ZAxis, -1 * (Length - Embedment - PartThickness));

            psCylinder.SetXYPlane(XAxis, YAxis);
            psCylinder.SetInsertPoint(CylinderInsertPoint);
            psCylinder.CreateCylinder(Diameter / 2, Length);
            // Washer
            psWasher.SetXYPlane(XAxisNegative, YAxis);
            psWasher.SetInsertPoint(InsertPoint);
            psWasher.CreateCylinder(WasherOuterDiameter / 2, WasherThickness);

            // Nut
            PsPoint nutInsertPoint = new PsPoint();

            nutInsertPoint = InsertPoint.Clone();
            nutInsertPoint.AddScaled(ZAxis, -1 * WasherThickness);
            psNutPolygon.createPolygon(6, NutKeySize / 2, false);
            psNut.SetXYPlane(XAxisNegative, YAxis);
            psNut.SetPolygon(psNutPolygon);
            psNut.SetInsertPoint(nutInsertPoint);
            psNut.CreateExtrusion(NutHeight, 0D, 0D);

            // Unite all
            int cylinderId = psCylinder.ObjectId;
            int washerId   = psWasher.ObjectId;
            int nutId      = psNut.ObjectId;

            int[] ids = { washerId, nutId };

            PsCutObjects psUniteObjects = new PsCutObjects();

            psUniteObjects.SetObjectId(cylinderId);
            PsTransaction psTransaction = new PsTransaction();

            foreach (int i in ids)
            {
                psUniteObjects.SetAsBooleanCut(i);
                psUniteObjects.SetSubBodyType(SubBodyType.kAddBody);
                psUniteObjects.CreateLogicalLink = false;
                psUniteObjects.Apply();
                psTransaction.EraseLongId((long)i);
                psTransaction.Close();
            }

            PsUnits            psUnits            = new PsUnits();
            PsObjectProperties psObjectProperties = new PsObjectProperties();

            psObjectProperties.Name         = Type + " " + psUnits.ConvertToText(Diameter) + "x" + psUnits.ConvertToText(Length);
            psObjectProperties.ColorIndex   = Color;
            psObjectProperties.PartListFlag = PartListFlag;
            psObjectProperties.FamilyClass  = PartFamilyClassIndex;
            psObjectProperties.Length       = Length;
            psObjectProperties.writeTo(cylinderId);
            PsPrimitive psPrimitive = new PsPrimitive();

            psTransaction.GetObject((long)cylinderId, PsOpenMode.kForWrite, ref psPrimitive);
            psPrimitive.writeProps(psObjectProperties);
            psTransaction.Close();
            ObjectId = cylinderId;
            return(ObjectId);
        }
Example #5
0
        public void CreateByTwoPoints(PsPoint StartPoint, PsPoint EndPoint)
        {
            PsCreatePrimitive psCylinder   = new PsCreatePrimitive();
            PsCreatePrimitive psHead1      = new PsCreatePrimitive();
            PsCreatePrimitive psHead2      = new PsCreatePrimitive();
            PsCreatePrimitive psWasher     = new PsCreatePrimitive();
            PsCreatePrimitive psNut        = new PsCreatePrimitive();
            PsPolygon         psNutPolygon = new PsPolygon();

            PsVector psVector1 = new PsVector();
            PsVector psVector2 = new PsVector();
            PsVector psVector3 = new PsVector();
            PsVector psVector  = new PsVector();

            psVector1.SetFromPoints(StartPoint, EndPoint);
            psVector2 = psVector.GetPerpendicularVector(psVector1);
            psVector3.SetFromCrossProduct(psVector1, psVector2);

            InsertPoint = StartPoint;
            KlemmLength = psVector1.Length;

            psVector1.Normalize();
            psVector2.Normalize();
            psVector3.Normalize();

            ZAxis = psVector1;
            XAxis = psVector2;
            YAxis = psVector3;

            psCylinder.SetXYPlane(XAxis, YAxis);
            psCylinder.SetInsertPoint(InsertPoint);
            Length = Math.Round((KlemmLength + WasherThickness + NutHeight + LengthAdd + 0.375D) * 4, MidpointRounding.ToEven) / 4;
            psCylinder.CreateCylinder(Diameter / 2, Length);

            // Head
            PsVector XAxisNegative = new PsVector();

            XAxisNegative = XAxis.Clone();
            XAxisNegative.Invert();

            psHead1.SetXYPlane(XAxisNegative, YAxis);
            psHead1.SetInsertPoint(InsertPoint);
            psHead1.CreateCylinder(HeadDiameter / 2, HeadHeight / 4);

            PsPoint head2InsertPoint = new PsPoint();

            head2InsertPoint = InsertPoint.Clone();
            head2InsertPoint.AddScaled(ZAxis, -1 * HeadHeight / 4);

            psHead2.SetXYPlane(XAxisNegative, YAxis);
            psHead2.SetInsertPoint(head2InsertPoint);
            psHead2.CreateCone(HeadDiameter / 2, HeadDiameter / 6, 0.75 * HeadHeight);

            // Washer
            psWasher.SetXYPlane(XAxis, YAxis);
            psWasher.SetInsertPoint(EndPoint);
            psWasher.CreateCylinder(WasherOuterDiameter / 2, WasherThickness);

            // Nut
            PsPoint nutInsertPoint = new PsPoint();

            nutInsertPoint = EndPoint.Clone();
            nutInsertPoint.AddScaled(ZAxis, WasherThickness);
            psNutPolygon.createPolygon(6, NutKeySize / 2, false);
            psNut.SetXYPlane(XAxis, YAxis);
            psNut.SetPolygon(psNutPolygon);
            psNut.SetInsertPoint(nutInsertPoint);
            psNut.CreateExtrusion(NutHeight, 0D, 0D);

            // Unite all
            int cylinderId = psCylinder.ObjectId;
            int head1Id    = psHead1.ObjectId;
            int head2Id    = psHead2.ObjectId;
            int washerId   = psWasher.ObjectId;
            int nutId      = psNut.ObjectId;

            int[] ids = { head1Id, head2Id, washerId, nutId };

            PsCutObjects psUniteObjects = new PsCutObjects();

            psUniteObjects.SetObjectId(cylinderId);
            PsTransaction psTransaction = new PsTransaction();

            foreach (int i in ids)
            {
                psUniteObjects.SetAsBooleanCut(i);
                psUniteObjects.SetSubBodyType(SubBodyType.kAddBody);
                psUniteObjects.CreateLogicalLink = false;
                psUniteObjects.Apply();
                psTransaction.EraseLongId((long)i);
                psTransaction.Close();
            }

            PsUnits            psUnits            = new PsUnits();
            PsMaterialTable    psMaterialTable    = new PsMaterialTable();
            PsObjectProperties psObjectProperties = new PsObjectProperties();

            psObjectProperties.Name = Type + " " + psUnits.ConvertToText(Diameter) + "x" + psUnits.ConvertToText(Length) +
                                      " " + MaterialName;
            psObjectProperties.Material   = psMaterialTable.get_MaterialIndexFromName(MaterialName);
            psObjectProperties.ColorIndex = Color;
            PartListFlag = true;
            psObjectProperties.PartListFlag = PartListFlag;
            PartFamilyClassIndex            = -1;
            psObjectProperties.FamilyClass  = PartFamilyClassIndex;
            psObjectProperties.Length       = Length;
            psObjectProperties.writeTo(cylinderId);

            PsPrimitive psPrimitive = new PsPrimitive();

            psTransaction.GetObject((long)cylinderId, PsOpenMode.kForWrite, ref psPrimitive);
            psPrimitive.writeProps(psObjectProperties);
            psTransaction.Close();
        }