public static DescriptiveObject Error(ErrorStatus status)
 {
     return(new DescriptiveObject
     {
         IsErrorState = true,
         ErrorMetaData = status,
         ErrorDescription = status.ToString()
     });
 }
 public static new DescriptiveResponse <T> Error(ErrorStatus status)
 {
     return(new DescriptiveResponse <T>
     {
         IsErrorState = true,
         ErrorMetaData = status,
         ErrorDescription = status.ToString()
     });
 }
Пример #3
0
        public void tExtract() // This method can have any name
        {
            // Put your command code here
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed;

            if (doc != null)
            {
                ed = doc.Editor;
                PromptSelectionResult psr = ed.GetSelection();
                if (psr.Status != PromptStatus.OK)
                {
                    return;
                }

                using (Transaction t = doc.Database.TransactionManager.StartOpenCloseTransaction())
                {
                    Database     db     = doc.Database;
                    SelectionSet acSSet = psr.Value;

                    // Step through the objects in the selection set
                    foreach (SelectedObject acSSObj in acSSet)
                    {
                        // Check to make sure a valid SelectedObject object was returned
                        if (acSSObj != null)
                        {
                            // Open the selected object for write
                            PointCloudEx acEnt = t.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as PointCloudEx;

                            if (acEnt != null)
                            {
                                Elements    elements = new Elements();
                                ErrorStatus es       = getCylinder(acEnt.ObjectId.OldIdPtr, ref elements);
                                if (es == ErrorStatus.OK)
                                {
                                    ed.WriteMessage("_axis {0},origin {1},height {2},raidus {3}"
                                                    + elements._axis.ToString() + "\t"
                                                    + elements._origin.ToString() + "\t"
                                                    + elements._height + "\t"
                                                    + elements._raidus);
                                }
                                else
                                {
                                    ed.WriteMessage(es.ToString());
                                }


                                break;
                            }
                        }
                    }
                }

                ed.WriteMessage("Hello, this is your first command.");
            }
        }
Пример #4
0
        /// <summary>
        /// Creates a String representation of the ProtocolDataUnit in JSON Format
        /// </summary>
        /// <returns>The String representation of the ProtcolDataUnit</returns>
        public override string ToString()
        {
            string PacketTemplate = @"{{'SnmpPacket':{{                
                    'Version': {0},
                    'CommunityName': {1},
                    {2}                
                }}
            }}";

            string PduTemplate = @"'ProtocolDataUnit':{{
                        'RequestId': {0},
                        'ErrorStatus': {1},
                        'ErrorIndex': {2},
                        'PduType': {3},
                        'Bindings': [{4}]
                    }}";

            string BindingTemplate = @"{{ 'Identifier': {0}, 'Type': {1}, 'Length': {2}, 'Values': {3} }}";

            string bindings = string.Empty;

            for (int i = 0, end = Bindings.Count; i < end; ++i)
            {
                Variable v = Bindings[i];
                string   valueString;
                if (v.TypeCode != SnmpType.Null)
                {
                    valueString = "[" + string.Join(",", Array.ConvertAll <int, string>(Array.ConvertAll <byte, int>(v.Value.ToArray(), Convert.ToInt32), Convert.ToString)) + "]";
                }
                else
                {
                    valueString = "[]";
                }

                bindings += String.Format(BindingTemplate, ('"' + v.Identifier + '"'), ('"' + v.TypeCode.ToString() + '"'), v.Length.ToString(), valueString);

                if (i == end - 1)
                {
                    break;
                }
                else
                {
                    bindings += "," + Environment.NewLine;
                }
            }

            string pdu = string.Format(PduTemplate, RequestId, ('"' + ErrorStatus.ToString() + '"'), ErrorIndex, ('"' + PduType.ToString() + '"'), bindings);

            string output = string.Format(PacketTemplate, Version, CommunityName, pdu);

            return(output);
        }
Пример #5
0
 public override void Error(ErrorStatus errorStatus)
 {
     switch (errorStatus)
     {
         case ErrorStatus.InvalidToken:
             {
                 APNsTableAdapter ta = new APNsTableAdapter();
                 ta.UpdateInvalidDeviceToken(apnsId);
                 break;
             }
         default:
             logger.Error("APNs returned error:" + errorStatus.ToString() + " APNs id:" + apnsId);
             break;
     }
 }
            public static dynamic GetTSObject(ErrorStatus dynEnum)
            {
                var tsType = TSActivator.CreateInstance("Tekla.Structures.Model.SpiralBeam.ErrorStatus").GetType();

                switch (dynEnum)
                {
                case ErrorStatus.DataMissing:
                    return(System.Enum.Parse(tsType, "DataMissing"));

                case ErrorStatus.DefinitionPointsTooClose:
                    return(System.Enum.Parse(tsType, "DefinitionPointsTooClose"));

                case ErrorStatus.DefinitionPointsCannotBeAligned:
                    return(System.Enum.Parse(tsType, "DefinitionPointsCannotBeAligned"));

                case ErrorStatus.ZeroTotalRiseWithMore360Degrees:
                    return(System.Enum.Parse(tsType, "ZeroTotalRiseWithMore360Degrees"));

                default:
                    throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented");
                }
            }
        public bool GetVi()
        {
            //CalibrationCurrent.Properties.Resources.cmd2
            //ErrorStatus = -1;
            short t1 = 1, t2 = 0;

            GPIB_Address = GPIB.Text;
            Visa32.viGetDefaultRM(out int defrm);
            Thread.Sleep(200);
            if (ErrorStatus != 0)
            {
                Visa32.viParseRsrcEx(defrm, "GPIB0::" + GPIB_Address + "::0::INSTR", ref t1, ref t2, instr, null, null);
                ErrorStatus = Visa32.viOpen(defrm, "GPIB0::" + GPIB_Address + "::0::INSTR", 1, 3000, out Vi);
                if (ErrorStatus != 0)
                {
                    Output(ErrorStatus.ToString());
                    Output("GPIB address unavailable!");
                    Config_Lable(Result, "失败", Color.Red);
                    //Result.Text = "FAIL";
                    //Result.BackColor = Color.OrangeRed;
                    return(false);
                }
            }


            Feedback.Remove(0, Feedback.Length);
            Visa32.viPrintf(Vi, "*IDN?" + System.Environment.NewLine);
            Thread.Sleep(500);
            Visa32.viScanf(Vi, "%t", Feedback);
            Output(Feedback.ToString());
            Config_Lable(Result, "已连接", Color.PaleGreen);
            //Result.Text = "Connecting";
            //Result.BackColor = Color.PaleGreen;
            //Result.Update();
            return(true);
        }