Example #1
0
        /// <summary>
        /// Get the suggested link name for the device in the "\DosDevices\" format.
        /// </summary>
        public unsafe static string QuerySuggestedLinkName(SafeHandle deviceHandle)
        {
            return(BufferHelper.BufferInvoke(((HeapBuffer buffer) =>
            {
                buffer.EnsureByteCapacity((ulong)sizeof(MOUNTDEV_SUGGESTED_LINK_NAME));
                ControlCode controlCode = ControlCodes.MountDevice.QuerySuggestedLinkName;

                while (!Imports.DeviceIoControl(
                           hDevice: deviceHandle,
                           dwIoControlCode: controlCode,
                           lpInBuffer: null,
                           nInBufferSize: 0,
                           lpOutBuffer: buffer.VoidPointer,
                           nOutBufferSize: checked ((uint)buffer.ByteCapacity),
                           lpBytesReturned: out _,
                           lpOverlapped: null))
                {
                    WindowsError error = Errors.GetLastError();
                    switch (error)
                    {
                    case WindowsError.ERROR_MORE_DATA:
                        buffer.EnsureByteCapacity(((MOUNTDEV_SUGGESTED_LINK_NAME *)buffer.VoidPointer)->NameLength + (ulong)sizeof(MOUNTDEV_SUGGESTED_LINK_NAME));
                        break;

                    default:
                        throw Errors.GetIoExceptionForError(error);
                    }
                }

                return (((MOUNTDEV_SUGGESTED_LINK_NAME *)buffer.VoidPointer)->Name).CreateString();
            })));
        }
Example #2
0
 public BinaryOutput(ControlCode code, byte count, System.UInt16 onTime, System.UInt16 offTime)
 {
     this.code = code;
     this.count = count;
     this.onTime = onTime;
     this.offTime = offTime;
 }
Example #3
0
 /// <summary>
 /// Primary constructor
 /// </summary>
 /// <param name="code">Enumeration that controls that behavior of the command</param>
 /// <param name="count">How many times to repeat the operation</param>
 /// <param name="onTime">How long to set the output active></param>
 /// <param name="offTime">How long to set the output inactive></param>
 public ControlRelayOutputBlock(ControlCode code, byte count, System.UInt16 onTime, System.UInt16 offTime)
 {
     this.code    = code;
     this.count   = count;
     this.onTime  = onTime;
     this.offTime = offTime;
 }
        protected void SendControlPacket(EndPoint end, int remoteid, int localid,
                                         ControlCode c, object state)
        {
            using (MemoryStream ms = new MemoryStream()) {
                NumberSerializer.WriteInt((int)c, ms);
                if (c == ControlCode.EdgeDataAnnounce)
                {
                    UdpEdge e = (UdpEdge)_id_ht[localid];
                    if ((e != null) && (e.RemoteID == remoteid))
                    {
                        Hashtable t = new Hashtable();
                        t["RemoteTA"] = e.RemoteTA.ToString();
                        t["LocalTA"]  = e.LocalTA.ToString();
                        AdrConverter.Serialize(t, ms);
                    }
                    else
                    {
                        if (ProtocolLog.UdpEdge.Enabled)
                        {
                            ProtocolLog.Write(ProtocolLog.UdpEdge, String.Format(
                                                  "Problem sending EdgeData: EndPoint: {0}, remoteid: {1}, " +
                                                  "localid: {2}, Edge: {3}", end, remoteid, localid, e));
                        }
                    }
                }

                _send_queue.Enqueue(new UdpMessage(localid, ~remoteid, MemBlock.Reference(ms.ToArray()), end));
                if (ProtocolLog.UdpEdge.Enabled)
                {
                    ProtocolLog.Write(ProtocolLog.UdpEdge, String.Format(
                                          "Sending control {1} to: {0}", end, c));
                }
            }
        }
Example #5
0
 public BinaryOutput(ControlCode code, byte count, System.UInt16 onTime, System.UInt16 offTime)
 {
     this.code    = code;
     this.count   = count;
     this.onTime  = onTime;
     this.offTime = offTime;
 }
Example #6
0
        private bool Validate(string code)
        {
            if (!new FiscalCodeValidator().Validate(code))
            {
                return(false);
            }

            var tokens =
                code
                .Token(FiscalCodeTokens.Lastname, 3)
                .Token(FiscalCodeTokens.Firstname, 3)
                .Token(FiscalCodeTokens.Year, 2)
                .Token(FiscalCodeTokens.Month, 1)
                .Token(FiscalCodeTokens.Day, 2)
                .Token(FiscalCodeTokens.Area, 4)
                .Token(FiscalCodeTokens.Control, 1)
                .Tokens;

            LastName  = new LastNameCode(tokens[FiscalCodeTokens.Lastname]).ToString();
            FirstName = new FirstNameCode(tokens[FiscalCodeTokens.Firstname]).ToString();
            AssignBirthDateAndSex(tokens);
            Area    = new AreaCode(tokens[FiscalCodeTokens.Area]).ToString();
            Control = ControlCode.GetControlCode(code.Substring(0, 15)).ToInvariant();

            return(true);
        }
Example #7
0
 public PacketHeader(PacketType packetType, ControlCode code, ushort req, uint bodySize)
 {
     Type     = packetType.GetPacketType();
     Code     = (ushort)code;
     Request  = req;
     BodySize = bodySize;
 }
Example #8
0
        public bool Validate(string fiscalCode)
        {
            if (string.IsNullOrEmpty(fiscalCode) || fiscalCode.Length != 16)
            {
                return(false);
            }

            fiscalCode = fiscalCode.ToUpper();

            if (!fiscalCode.All(char.IsLetterOrDigit))
            {
                return(false);
            }

            var formatValid = fiscalCodeFormat.Match(fiscalCode).Success;

            if (!formatValid)
            {
                return(false);
            }

            var controlCode = fiscalCode[15];

            var calculatedCode = ControlCode.GetControlCode(fiscalCode.Substring(0, 15));

            return(calculatedCode == controlCode);
        }
Example #9
0
 public void AddEntry(byte[] Identifier, ControlCode NewEntry)
 {
     if (this.ControlCodes.ContainsKey(Identifier))
         this.ControlCodes[Identifier] = NewEntry;
     else
         this.ControlCodes.Add(Identifier, NewEntry);
 }
Example #10
0
    public void Update(ControlCode code, bool yes)
    {
        switch (code)
        {
        case ControlCode.Left:
            isLeft = yes;
            break;

        case ControlCode.Right:
            isRight = yes;
            break;

        case ControlCode.Up:
            isUp = yes;
            break;

        case ControlCode.Down:
            isDown = yes;
            break;

        default:
            Debug.Log("Illegal control code.");
            break;
        }
    }
Example #11
0
        /// <summary>
        /// Get the unique ID as presented to the mount manager by a device.
        /// </summary>
        public unsafe static byte[] QueryUniqueId(SafeHandle deviceHandle)
        {
            return(BufferHelper.BufferInvoke((HeapBuffer buffer) =>
            {
                buffer.EnsureByteCapacity((ulong)sizeof(MOUNTDEV_UNIQUE_ID));
                ControlCode controlCode = ControlCodes.MountDevice.QueryUniqueId;

                while (!Imports.DeviceIoControl(
                           hDevice: deviceHandle,
                           dwIoControlCode: controlCode,
                           lpInBuffer: null,
                           nInBufferSize: 0,
                           lpOutBuffer: buffer.VoidPointer,
                           nOutBufferSize: checked ((uint)buffer.ByteCapacity),
                           lpBytesReturned: out _,
                           lpOverlapped: null))
                {
                    WindowsError error = Errors.GetLastError();
                    switch (error)
                    {
                    case WindowsError.ERROR_MORE_DATA:
                        buffer.EnsureByteCapacity(((MOUNTDEV_UNIQUE_ID *)buffer.VoidPointer)->UniqueIdLength + (ulong)sizeof(MOUNTDEV_UNIQUE_ID));
                        break;

                    default:
                        throw Errors.GetIoExceptionForError(error);
                    }
                }

                return ((MOUNTDEV_UNIQUE_ID *)buffer.VoidPointer)->UniqueId.ToArray();
            }));
        }
 public static extern int EnableTraceEx2(ulong traceHandle,
                                         ref Guid providerId,
                                         ControlCode controlCode,
                                         TraceLevel level,
                                         long matchAnyKeyword,
                                         long matchAllKeyword,
                                         uint timeout,
                                         IntPtr useIntPtrZero);
Example #13
0
 public static unsafe extern bool DeviceIoControl(
     SafeHandle hDevice,
     ControlCode dwIoControlCode,
     void *lpInBuffer,
     uint nInBufferSize,
     void *lpOutBuffer,
     uint nOutBufferSize,
     out uint lpBytesReturned,
     OVERLAPPED *lpOverlapped);
Example #14
0
    private void SendControlCode(ControlCode code, bool yes)
    {
        Message msg;

        msg.isRedRoller = isRed;
        msg.code        = code;
        msg.yes         = yes;
        c2sChannel.SendMessage(msg);
    }
Example #15
0
 public void Displose()
 {
     buffer = null;
     tmpbuf = null;
     m_Crypto.Dispose();
     m_SendControlCode = null;
     m_RecvControlCode = null;
     _queue            = null;
     //m_UserInfo = null;
 }
Example #16
0
 /// <summary>
 /// 数据帧构造函数
 /// </summary>
 /// <param name="task"></param>
 public Frame(TaskArge task)
 {
     this.Adress      = task.IoTMac;
     this.ControlCode = task.ControlCode;
     this.DataItem    = task.Data;
     mkey             = task.MKey;
     if (this.DataItem != null)
     {
         this.dataLength = this.DataItem.Length;
     }
 }
Example #17
0
        public void DecodeControlCode()
        {
            ControlCode code = new ControlCode {
                Value = 0x0f60401a
            };

            code.DeviceType.Should().Be(ControlCodeDeviceType.Infrared);
            code.RequiredAccess.Should().Be(ControlCodeAccess.Read);
            code.TransferType.Should().Be(ControlCodeMethod.OutDirect);
            code.FunctionCode.Should().Be(6);
        }
Example #18
0
 public void AddEntry(byte[] Identifier, ControlCode NewEntry)
 {
     if (this.ControlCodes.ContainsKey(Identifier))
     {
         this.ControlCodes[Identifier] = NewEntry;
     }
     else
     {
         this.ControlCodes.Add(Identifier, NewEntry);
     }
 }
Example #19
0
        /// <summary>
        /// Gets the DOS drive letter for the given volume if it has one.
        /// </summary>
        public unsafe static string QueryDosVolumePath(string volume)
        {
            var mountManager = FileMethods.CreateFile(
                @"\\?\MountPointManager", CreationDisposition.OpenExisting, 0);

            ControlCode controlCode = ControlCodes.MountManager.QueryDosVolumePath;

            // Read ulong then get string
            string dosVolumePath = null;

            BufferHelper.BufferInvoke((StringBuffer inBuffer) =>
            {
                // The input is MOUNTMGR_TARGET_NAME which is a short length in bytes followed by the unicode string
                // https://msdn.microsoft.com/en-us/library/windows/hardware/ff562289.aspx

                inBuffer.Append((char)(volume.Length * sizeof(char)));
                inBuffer.Append(volume);

                BufferHelper.BufferInvoke((StringBuffer outBuffer) =>
                {
                    // Give enough for roughly 50 characters for a start
                    outBuffer.EnsureCharCapacity(50);

                    while (!Imports.DeviceIoControl(
                               hDevice: mountManager,
                               dwIoControlCode: controlCode,
                               lpInBuffer: inBuffer.VoidPointer,
                               nInBufferSize: checked ((uint)inBuffer.ByteCapacity),
                               lpOutBuffer: outBuffer.VoidPointer,
                               nOutBufferSize: checked ((uint)outBuffer.ByteCapacity),
                               lpBytesReturned: out _,
                               lpOverlapped: null))
                    {
                        WindowsError error = Errors.GetLastError();
                        switch (error)
                        {
                        case WindowsError.ERROR_MORE_DATA:
                            outBuffer.EnsureByteCapacity(checked (outBuffer.ByteCapacity * 2));
                            break;

                        default:
                            throw Errors.GetIoExceptionForError(error, volume);
                        }
                    }

                    // MOUNTMGR_VOLUME_PATHS is a uint length followed by a multi string (double null terminated)
                    // we only care about the first string in this case (should only be one?) so we can skip beyond
                    // the 4 bytes and read to null.
                    dosVolumePath = new string(outBuffer.CharPointer + 2);
                });
            });

            return(dosVolumePath);
        }
Example #20
0
        public async Task StopSelection()
        {
            ControlCode model = new ControlCode
            {
                IfSelectCourse = "0"
            };

            using (IDAL.IControlCodeService Svc = new ControlCodeService())
            {
                await Svc.EditAsync(model);
            }
        }
Example #21
0
    private void CallEvent(ControlCode code)
    {
        switch (code)
        {
        case ControlCode.Circle:
            EventCirclePress();
            break;

        case ControlCode.L1:
            EventL1Press();
            break;

        case ControlCode.L2:
            EventL2Press();
            break;

        case ControlCode.Option:
            EventOptionsPress();
            break;

        case ControlCode.PadPress:
            EventPadPress();
            break;

        case ControlCode.R1:
            EventR1Press();
            break;

        case ControlCode.R2:
            EventR2Press();
            break;

        case ControlCode.Share:
            EventSharePress();
            break;

        case ControlCode.Square:
            EventSquarePress();
            break;

        case ControlCode.Triangle:
            EventTrianglePress();
            break;

        case ControlCode.X:
            EventXPress();
            break;

        default:
            break;
        }
    }
Example #22
0
        /// <summary>
        /// Gets reparse point names for symbolic links and mount points.
        /// </summary>
        /// <param name="fileHandle">Handle for the reparse point, must be opened with <see cref="FileAccessRights.ReadExtendedAttributes"/>.</param>
        public unsafe static (string printName, string substituteName, ReparseTag tag) GetReparsePointNames(SafeFileHandle fileHandle)
        {
            return(BufferHelper.BufferInvoke((HeapBuffer buffer) =>
            {
                ControlCode controlCode = ControlCodes.FileSystem.GetReparsePoint;
                buffer.EnsureByteCapacity(1024);

                while (!Imports.DeviceIoControl(
                           hDevice: fileHandle,
                           dwIoControlCode: controlCode,
                           lpInBuffer: null,
                           nInBufferSize: 0,
                           lpOutBuffer: buffer.VoidPointer,
                           nOutBufferSize: checked ((uint)buffer.ByteCapacity),
                           lpBytesReturned: out _,
                           lpOverlapped: null))
                {
                    WindowsError error = Errors.GetLastError();
                    switch (error)
                    {
                    case WindowsError.ERROR_SUCCESS:
                        // This can happen if the handle isn't a reparse point.
                        break;

                    case WindowsError.ERROR_MORE_DATA:
                        buffer.EnsureByteCapacity(buffer.ByteCapacity + 1024);
                        break;

                    default:
                        throw Errors.GetIoExceptionForError(error);
                    }
                }

                ReparseTag reparseTag = ((REPARSE_DATA_BUFFER *)buffer.VoidPointer)->ReparseTag;

                string printName = null;
                string substitutename = null;

                if (reparseTag == ReparseTag.MountPoint)
                {
                    printName = ((REPARSE_DATA_BUFFER *)buffer.VoidPointer)->MountPointData.PrintName.CreateString();
                    substitutename = ((REPARSE_DATA_BUFFER *)buffer.VoidPointer)->MountPointData.SubstituteName.CreateString();
                }
                else if (reparseTag == ReparseTag.SymbolicLink)
                {
                    printName = ((REPARSE_DATA_BUFFER *)buffer.VoidPointer)->SymbolicLinkData.PrintName.CreateString();
                    substitutename = ((REPARSE_DATA_BUFFER *)buffer.VoidPointer)->SymbolicLinkData.SubstituteName.CreateString();
                }

                return (printName, substitutename, reparseTag);
            }));
        }
Example #23
0
        /// <summary>
        /// 根据主站请求数据,从站创建应答数据对象
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private TaskArge CreateAnswerData(TaskArge e)
        {
            ControlCode ctrCode       = e.ControlCode;
            DataItem    item          = null;
            ControlCode answerCtrCode = ControlCode.ReadData_Success;

            byte[] currentKey = this.MKey;//本次发送数据使用的密钥
            switch (ctrCode)
            {
            case ControlCode.ReadData:
                //主站请求的读数据操作
                item          = DowithReadData(e.Data.IdentityCode, e.Data.SER);
                answerCtrCode = ControlCode.ReadData_Success;
                break;

            case ControlCode.WriteData:
                //主站请求的写数据操作
                item          = DowithWriteData(e.Data.IdentityCode, e.Data.SER, e.Data);
                answerCtrCode = ControlCode.WriteData_Answer;    //正常应答
                break;

            case ControlCode.ReadKeyVersion:
                //主站读从站密钥版本
                item = new DataItem_8106(e.Data.SER, this.MKeyVer);
                break;

            case ControlCode.ReadMeterAdress:
                //读地址(仅用于单机)
                break;

            case ControlCode.WriteMeterAdress:
                break;

            case ControlCode.WriteMeterNum:
                break;

            case ControlCode.CYReadData:
                //item = this.DowithCYWriteData(e.Data.IdentityCode, e.Data.SER, e.Data);
                //answerCtrCode = ControlCode.CYWriteData_Answer;//正常应答
                break;

            case ControlCode.CYWriteData:
                //处理创源写数据
                item          = DowithCYWriteData(e.Data.IdentityCode, e.Data.SER, e.Data);
                answerCtrCode = ControlCode.CYWriteData_Answer;
                break;

            default:
                break;
            }
            return(new TaskArge(this.Mac, item, answerCtrCode, currentKey));
        }
 public static bool TryParse(char character, out ControlCode code)
 {
     try
     {
         code = Parse(character);
         return(true);
     }
     catch
     {
         code = ControlCode.Ctrl_A;
         return(false);
     }
 }
Example #25
0
        public void OnExecute(ControlCode controlCode)
        {
            switch (controlCode)
            {
            case ControlCode.HorizontalTabulation:
                _events.PutTab?.Invoke(1);
                break;

            case ControlCode.Backspace:
                _events.Backspace?.Invoke();
                break;

            case ControlCode.CarriageReturn:
                _events.CarriageReturn?.Invoke();
                break;

            case ControlCode.FormFeed:
            case ControlCode.VerticalTabulation:
            case ControlCode.LineFeed:
                _events.LineFeed?.Invoke();
                break;

            case ControlCode.Bell:
                _events.Bell?.Invoke();
                break;

            case ControlCode.ShiftIn:
                _activeCharSetIndex = G0;
                break;

            case ControlCode.ShiftOut:
                _activeCharSetIndex = G1;
                break;

            case ControlCode.NewLine:
                _events.NewLine?.Invoke();
                break;

            case ControlCode.HorizontalTabulationSet:
                _events.SetHorizontalTabStop?.Invoke();
                break;

            case ControlCode.SingleCharacterIntroducer:
                _events.IdentifyTerminal?.Invoke();
                break;
            }
        }
Example #26
0
        public void InsertTransaction(List <Payment> u, double total, Payer p)
        {
            string queryInvoice = @"INSERT INTO INVOICE(INVOICEDATE,TOTAL,NROINVOICE,CONTROLCODE,IDPAYER)
VALUES(CURRENT_TIMESTAMP,:TOTAL,:NROINVOICE,:CONTROLCODE,:IDPAYER)";


            string queryDetail = @"INSERT INTO DETAIL(DESCRIPTIONS,AMOUNT,IDPAYMENT,IDINVOICE)
VALUES(:DESCRIPTIONS,:AMOUNT,:IDPAYMENT,:IDINVOICE)";



            try
            {
                int details = 0;
                foreach (var d in u)
                {
                    details++;
                }
                System.Diagnostics.Debug.WriteLine(string.Format("{0} | Info: Start Add Class.", DateTime.Now));
                List <OracleCommand>     cmds       = DBImplementation.CreateNBasicCommands(1);
                List <OracleParameter[]> parameters = new List <OracleParameter[]>();
                DosageImpl dosageImpl    = new DosageImpl();
                Dosage     dosage        = dosageImpl.Get();
                int        numberinvoice = dosage.FinalNumber + 1;
                string     controlCode   = ControlCode.generateControlCode(dosage.NroAuthorization.ToString(), numberinvoice.ToString(), p.Nit,
                                                                           DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString(),
                                                                           total.ToString(), dosage.DosageKey);
                int id = DBImplementation.GetIdentityFromTable("INVOICE");
                DBImplementation.ResetIdentFromTable("INVOICE");
                cmds[0].CommandText = queryInvoice;
                cmds[0].Parameters.Add(new OracleParameter(":TOTAL", total));
                cmds[0].Parameters.Add(new OracleParameter(":NROINVOICE", numberinvoice));
                cmds[0].Parameters.Add(new OracleParameter(":CONTROLCODE", controlCode));
                cmds[0].Parameters.Add(new OracleParameter(":IDPAYER", p.IdPayer));
                cmds[0].Parameters.AddRange(parameters[0]);



                DBImplementation.ExecuteNBasicCommand(cmds);
                System.Diagnostics.Debug.WriteLine(string.Format("{0} | Info: Invoice Succesfully.", DateTime.Now));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("{0} | Error:  Could not Add Class({1}).", DateTime.Now, ex.Message));
            }
        }
Example #27
0
        private void SendFrame(ControlCode code, int channelId)
        {
            if (this.Completion.IsCompleted)
            {
                // Any frames that come in after we're done are most likely frames just informing that channels are being terminated,
                // which we do not need to communicate since the connection going down implies that.
                return;
            }

            var header = new FrameHeader
            {
                Code               = code,
                ChannelId          = channelId,
                FramePayloadLength = 0,
            };

            this.DisposeSelfOnFailure(this.SendFrameAsync(header, payload: default, CancellationToken.None));
Example #28
0
		internal FiscalCode(
			LastNameCode lastNameCode,
			FirstNameCode firstNameCode,
			YearCode yearCode,
			MonthCode monthCode,
			DayCode dayCode,
			AreaCode areaCode,
			ControlCode controlCode)
			: this(
				lastNameCode.ToString(),
				firstNameCode.ToString(),
				yearCode.ToString(),
				monthCode.ToString(),
				dayCode.ToString(),
				areaCode.ToString(),
				controlCode.ToString())
		{
		}
Example #29
0
 public FiscalCode(
     LastNameCode lastNameCode,
     FirstNameCode firstNameCode,
     YearCode yearCode,
     MonthCode monthCode,
     DayCode dayCode,
     AreaCode areaCode,
     ControlCode controlCode)
     : this(
         lastNameCode.ToString(),
         firstNameCode.ToString(),
         yearCode.ToString(),
         monthCode.ToString(),
         dayCode.ToString(),
         areaCode.ToString(),
         controlCode.ToString())
 {
 }
Example #30
0
        public FiscalCode Calculate(NaturalPerson naturalPerson, AreaCode areaCode)
        {
            var lastName = new LastNameCode(naturalPerson.LastName.Replace(" ", null));

            var firstName = new FirstNameCode(naturalPerson.FirstName.Replace(" ", null));

            var year = new YearCode(naturalPerson.BirthDate);

            var month = new MonthCode(naturalPerson.BirthDate);

            var day = new DayCode(naturalPerson.BirthDate, naturalPerson.Sex);

            var control = new ControlCode(lastName, firstName, year, month, day, areaCode);

            var fiscalCode = new FiscalCode(lastName, firstName, year, month, day, areaCode, control);

            return(fiscalCode);
        }
Example #31
0
 public TaskArge(string mac, DataItem data, ControlCode controlcode, byte[] key = null)
 {
     this._data        = data;
     this._controlcode = controlcode;
     this._MKey        = key;
     if (mac.Length > 14)
     {
         this._lotMac = mac.Substring(0, 14);
     }
     else if (mac.Length < 14)
     {
         this._lotMac = mac.PadLeft(14, '0');
     }
     else
     {
         this._lotMac = mac;
     }
 }
Example #32
0
		public FiscalCode Calculate(NaturalPerson naturalPerson, AreaCode areaCode)
		{
			Enforce.Argument(() => areaCode);

			var lastName = new LastNameCode(naturalPerson.LastName.Replace(" ", null));

			var firstName = new FirstNameCode(naturalPerson.FirstName.Replace(" ", null));

			var year = new YearCode(naturalPerson.BirthDate);

			var month = new MonthCode(naturalPerson.BirthDate);

			var day = new DayCode(naturalPerson.BirthDate, naturalPerson.Sex);

			var control = new ControlCode(lastName, firstName, year, month, day, areaCode);

			var fiscalCode = new FiscalCode(lastName, firstName, year, month, day, areaCode, control);

			return fiscalCode;
		}
Example #33
0
        /// <summary>
        /// Get the stable Guid for the given device handle.
        /// </summary>
        public unsafe static Guid QueryStableGuid(SafeHandle deviceHandle)
        {
            ControlCode          controlCode = ControlCodes.MountDevice.QueryStableGuid;
            MOUNTDEV_STABLE_GUID guid        = new MOUNTDEV_STABLE_GUID();

            if (!Imports.DeviceIoControl(
                    hDevice: deviceHandle,
                    dwIoControlCode: controlCode,
                    lpInBuffer: null,
                    nInBufferSize: 0,
                    lpOutBuffer: &guid,
                    nOutBufferSize: (uint)sizeof(MOUNTDEV_STABLE_GUID),
                    lpBytesReturned: out _,
                    lpOverlapped: null))
            {
                throw Errors.GetIoExceptionForLastError();
            }

            return(guid.StableGuid);
        }
Example #34
0
            private void InternalCompile(Client state, bool encrypt)
            {
                if (state == null)
                {
                    LogConsole.Show(LogType.DEBUG, "Null NetState passed in Network.Packet.Compile()");
                }
                if (this.m_Length == 0)
                {
                    long num = this.m_Stream.Length;
                    this.m_Stream.Seek(0L, SeekOrigin.Begin);
                    this.m_Stream.Write((ushort)num);
                }
                else if (this.m_Stream.Length != this.m_Length)
                {
                    LogConsole.Show(LogType.DEBUG, "Packet {0:X2}: Bad packet length, Expected {1} , Stream {2}", new object[] { this.m_PacketID, this.m_Length, this.m_Stream.Length });
                }
                MemoryStream underlyingStream = this.m_Stream.UnderlyingStream;

                this.m_FinalBuffer = underlyingStream.GetBuffer();
                int length = (int)underlyingStream.Length;

                if (!encrypt)
                {
                    ControlCode sendControlCode = new ControlCode(true);
                    if (state.FirstPacketSent)
                    {
                        sendControlCode.Update(length - 4);
                    }
                    this.m_Stream.Seek(2L, SeekOrigin.Begin);
                    this.m_Stream.Write(sendControlCode.Value);
                }
                if (this.m_FinalBuffer != null)
                {
                    byte[] finalBuffer = this.m_FinalBuffer;
                    this.m_FinalBuffer = new byte[length];
                    Buffer.BlockCopy(finalBuffer, 0, this.m_FinalBuffer, 0, length);
                }
                this.m_Stream = null;
            }
Example #35
0
            public LineItem(
                RichTextEdit InParent,
                ControlCode InCode)
                : this(InParent)
            {
                Code = InCode;

                if (Code == ControlCode.Item)
                {
                    Item = EnumIcon.CreateImage();
                }
                else
                    Height = 20;
            }
 public ControlInstruction(ControlCode code, ConsoleColor arg = ConsoleColor.Black)
 {
     Code = code;
     Arg = arg;
 }
Example #37
0
        public void InsertCtrlCode(ControlCode InCode)
        {
            Int32 SelStart = SelectionStart;
            Int32 SelLength = SelectionLength;

            switch (InCode)
            {
                case ControlCode.Enter:
                    {
                        RemoveSelection();
                        SelLength = 0;
                    } break;

                case ControlCode.Indent:
                case ControlCode.Item:
                case ControlCode.Unindent:
                    {
                        Select(CursorPosition.End, SelectionStart, 0);
                    } break;

                default:
                    throw new ArgumentException("Unknown control code.");
            }

            InternalInsertCtrlCode(InCode);

            Update();

            Select(CursorPosition.End, SelStart + 1, SelLength);

            if (OnContentChanged != null)
                OnContentChanged(this);
        }
Example #38
0
 private void InternalCompile(Client state, bool encrypt)
 {
     if (state == null)
     {
         LogConsole.Show(LogType.DEBUG, "Null NetState passed in Network.Packet.Compile()");
     }
     if (this.m_Length == 0)
     {
         long num = this.m_Stream.Length;
         this.m_Stream.Seek(0L, SeekOrigin.Begin);
         this.m_Stream.Write((ushort)num);
     }
     else if (this.m_Stream.Length != this.m_Length)
     {
         LogConsole.Show(LogType.DEBUG, "Packet {0:X2}: Bad packet length, Expected {1} , Stream {2}", new object[] { this.m_PacketID, this.m_Length, this.m_Stream.Length });
     }
     MemoryStream underlyingStream = this.m_Stream.UnderlyingStream;
     this.m_FinalBuffer = underlyingStream.GetBuffer();
     int length = (int)underlyingStream.Length;
     if (!encrypt)
     {
         ControlCode sendControlCode = new ControlCode(true);
         if (state.FirstPacketSent)
         {
             sendControlCode.Update(length - 4);
         }
         this.m_Stream.Seek(2L, SeekOrigin.Begin);
         this.m_Stream.Write(sendControlCode.Value);
     }
     if (this.m_FinalBuffer != null)
     {
         byte[] finalBuffer = this.m_FinalBuffer;
         this.m_FinalBuffer = new byte[length];
         Buffer.BlockCopy(finalBuffer, 0, this.m_FinalBuffer, 0, length);
     }
     this.m_Stream = null;
 }
Example #39
0
 public void Displose()
 {
     buffer = null;
     tmpbuf = null;
     m_Crypto.Dispose();
     m_SendControlCode = null;
     m_RecvControlCode = null;
     _queue = null;
     m_UserInfo = null;
 }
Example #40
0
        /// <summary>
        /// Send a control message to all the attendees in the conference
        /// </summary>
        /// <param name="ctrlCode"> Control code identifying this message </param>
        /// <param name="param"> Any extra info needed by the clients </param>
        public void BroadcastControlMessage(ControlCode ctrlCode, Object param)
        {
            try
            {
                ControlMessage ctrlMsg;
                //
                // Construct a control message
                //
                ctrlMsg = new ControlMessage(ctrlCode);
                ctrlMsg.Parameter = param;
                ctrlMsg.SenderID=-1;

                //
                // Send the message to all the clients in the conference
                //
                ((IMessageReceiver) this._dispatcher.TransparentProxy).ReceiveMessage(ctrlMsg);
                ctrlMsg = null; //GC
                GC.Collect(); //GC
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #41
0
        void InternalInsertCtrlCode(ControlCode InCode)
        {
            m_LastModification = DateTime.Now.Ticks;

            if (InCode == ControlCode.Item)
            {
                InsertCtrlCode(ControlCode.Enter);
            }

            LineItem Entry = new LineItem(this, InCode);

            LineItems.Insert(SelectionStart, Entry);

            m_Surface.Children.Add(Entry);
        }
Example #42
0
    protected void SendControlPacket(EndPoint end, int remoteid, int localid,
                                     ControlCode c, object state) 
    {
      using(MemoryStream ms = new MemoryStream()) {
        NumberSerializer.WriteInt((int)c, ms);
        if( c == ControlCode.EdgeDataAnnounce ) {
          UdpEdge e = (UdpEdge)_id_ht[localid];
          if( (e != null) && (e.RemoteID == remoteid) ) {
            Hashtable t = new Hashtable();
            t["RemoteTA"] = e.RemoteTA.ToString();
            t["LocalTA"] = e.LocalTA.ToString();
            AdrConverter.Serialize(t, ms);
          }
          else {
            if(ProtocolLog.UdpEdge.Enabled)
              ProtocolLog.Write(ProtocolLog.UdpEdge, String.Format(
                "Problem sending EdgeData: EndPoint: {0}, remoteid: {1}, " +
                "localid: {2}, Edge: {3}", end, remoteid, localid, e));
          }
        }

        _send_queue.Enqueue(new UdpMessage(localid, ~remoteid, MemBlock.Reference(ms.ToArray()), end));
        if(ProtocolLog.UdpEdge.Enabled) {
          ProtocolLog.Write(ProtocolLog.UdpEdge, String.Format(
            "Sending control {1} to: {0}", end, c));
        }
      }
    }