private UInt32 _sectorSize; //Sector大小

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 初始化CompoundBinaryFile
        /// </summary>
        /// <param name="filePath">文件路径</param>
        public CompoundBinaryFile(String filePath)
        {
            try
            {
                this._stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                this._reader = new BinaryReader(this._stream);

                this._length = this._stream.Length;

                this.ReadHeader();
                this.ReadFAT();
                this.ReadDirectory();
                this.ReadMiniFAT();
                this.ReadDocumentSummaryInformation();
                this.ReadSummaryInformation();
                this.ReadContent();
            }
            finally
            {
                if (this._reader != null)
                {
                    this._reader.Close();
                }

                if (this._stream != null)
                {
                    this._stream.Close();
                }
            }
        }
        public Product GetProduct(Int64 id)
        {
            var products = new List<Product>();
            using (var conn = _getConnection())
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM Products WHERE Id = @Id order by Name";
                    cmd.Parameters.Add(new SqlParameter("Id", System.Data.SqlDbType.BigInt) { Value = id });
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (!reader.Read())
                        {
                            return null;
                        }

                        return new Product
                        {
                            Id = (Int64)reader["Id"],
                            Name = reader["Name"].ToString(),
                            Description = reader["Description"].ToString(),
                            Title1 = reader["Title1"].ToString(),
                            Title2 = reader["Title2"].ToString(),
                            TitlesCount = (int)(reader["TitlesCount"] ?? 0),
                            Price = (int)reader["Price"]
                        };
                    }
                }
            }
        }
        private static byte[] GetHashFinalBlock(byte[] input, int ibStart, int cbSize, ABCDStruct ABCD, Int64 len)
        {
            byte[] working = new byte[64];
            byte[] length = BitConverter.GetBytes(len);

            //Padding is a single bit 1, followed by the number of 0s required to make size congruent to 448 modulo 512. Step 1 of RFC 1321  
            //The CLR ensures that our buffer is 0-assigned, we don't need to explicitly set it. This is why it ends up being quicker to just
            //use a temporary array rather then doing in-place assignment (5% for small inputs)
            Array.Copy(input, ibStart, working, 0, cbSize);
            working[cbSize] = 0x80;

            //We have enough room to store the length in this chunk
            if (cbSize <= 56)
            {
                Array.Copy(length, 0, working, 56, 8);
                GetHashBlock(working, ref ABCD, 0);
            }
            else  //We need an aditional chunk to store the length
            {
                GetHashBlock(working, ref ABCD, 0);
                //Create an entirely new chunk due to the 0-assigned trick mentioned above, to avoid an extra function call clearing the array
                working = new byte[64];
                Array.Copy(length, 0, working, 56, 8);
                GetHashBlock(working, ref ABCD, 0);
            }
            byte[] output = new byte[16];
            Array.Copy(BitConverter.GetBytes(ABCD.A), 0, output, 0, 4);
            Array.Copy(BitConverter.GetBytes(ABCD.B), 0, output, 4, 4);
            Array.Copy(BitConverter.GetBytes(ABCD.C), 0, output, 8, 4);
            Array.Copy(BitConverter.GetBytes(ABCD.D), 0, output, 12, 4);
            return output;
        }
 /// <summary>
 /// Creates new instance of <see cref="QuickIOTransferFileCopyProgressEventArgs"/>
 /// </summary>
 /// <param name="job">Affected job</param>
 /// <param name="sourcePath">Source file path</param>
 /// <param name="targetPath">Target file path</param>
 /// <param name="totalBytes">Total bytes to transfer</param>
 /// <param name="transferStarted"></param>
 public QuickIOTransferFileCopyFinishedEventArgs( IQuickIOTransferJob job, string sourcePath, string targetPath, Int64 totalBytes, DateTime transferStarted )
     : base(job, sourcePath, targetPath)
 {
     TotalBytes = ( UInt64 ) totalBytes;
     TransferStarted = transferStarted;
     TransferFinished = DateTime.Now;
 }
Exemple #5
1
 public Partition( Device device, MBRPartitionEntry entry )
 {
     this.device         = device;
     partition_id        = entry.id;
     partition_start     = ( Int64 ) entry.start_lba * ( Int64 ) device.SectorSize;
     partition_length    = ( Int64 ) entry.size_lba * ( Int64 ) device.SectorSize;
 }
 public PlanningOfficerMessage(string message, Int64 customerMobile, DateTime dateSent, string connectionString)
 {
     Message = message;
     CustomerMobile = customerMobile;
     DateSent = dateSent;
     _connectionString = connectionString;
 }
Exemple #7
1
        private void btnSaveAsNew_Click(object sender, EventArgs e)
        {
            try
            {
                string query;
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("@Name", txtName.Text);
                parameters.Add("@StartTime", dtpStart.Value.TimeOfDay);
                parameters.Add("@EndTime", dtpEnd.Value.TimeOfDay);
                query = @"INSERT INTO Periods (Name, StartTime, EndTime) VALUES (@Name, @StartTime, @EndTime);";

                _PeriodID = SqlHelper.ExecteNonQuery(query, parameters);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.Close();
            Central.MainForm.Focus();
            foreach (DockContent item in Central.MainForm.Contents)
            {
                if (item is Periods)
                {
                    ((Periods)item).RefreshPeriods();
                    continue;
                }
            }

            this.TabText = txtName.Text + " Details";
        }
        public ValueVersion(UInt64 ve, string ss, byte[] va, int ec, ProcessStatus status, Int64 start, Int64 stop)
        {
            version = ve;
            shortStatus = ss;
            value = va;
            exitCode = ec;
            startTime = start;
            stopTime = stop;
            switch (status)
            {
                case ProcessStatus.Queued:
                    processStatus = "Queued";
                    break;

                case ProcessStatus.Running:
                    processStatus = "Running";
                    break;

                case ProcessStatus.Canceling:
                    processStatus = "Canceling";
                    break;

                default:
                    processStatus = "Completed";
                    break;
            }
        }
        public static bool GetBestAddress(Int64 APartnerKey,
            out PLocationTable AAddress,
            out string ACountryNameLocal)
        {
            bool NewTransaction;
            TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum, out NewTransaction);

            bool ResultValue = false;

            try
            {
                ResultValue = TAddressTools.GetBestAddress(APartnerKey,
                    out AAddress,
                    out ACountryNameLocal,
                    Transaction);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }
            }
            return ResultValue;
        }
Exemple #10
1
				public static float StepsToMiles(Int64 stepCount)
				{
					if (stepCount <= 0) return 0.00f;
					//Average steps in a mile
					const float stepsPerMile = 2000;
					return stepCount/stepsPerMile;
				}
Exemple #11
1
        /// <summary>
        /// Indicates whether any network connection is available.
        /// Filter connections below a specified speed, as well as virtual network cards.
        /// </summary>
        /// <param name="minimumSpeed">The minimum speed required. Passing 0 will not filter connection using speed.</param>
        /// <returns>True if a network connection is available; otherwise false.</returns>
        public static Boolean IsNetworkAvailable(Int64 minimumSpeed)
        {
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
                {
                    // discard because of standard reasons
                    if ((ni.OperationalStatus != OperationalStatus.Up) ||
                        (ni.NetworkInterfaceType == NetworkInterfaceType.Loopback) ||
                        (ni.NetworkInterfaceType == NetworkInterfaceType.Tunnel))
                        continue;

                    // this allow to filter modems, serial, etc.
                    // I use 10000000 as a minimum speed for most cases
                    if (ni.Speed < minimumSpeed)
                        continue;

                    // discard virtual cards (virtual box, virtual pc, etc.)
                    if ((ni.Description.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0) ||
                        (ni.Name.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0))
                        continue;

                    // discard "Microsoft Loopback Adapter", it will not show as NetworkInterfaceType.Loopback but as Ethernet Card.
                    if (ni.Description.Equals("Microsoft Loopback Adapter", StringComparison.OrdinalIgnoreCase))
                        continue;

                    return true;
                }
            }

            return false;
        }
Exemple #12
1
        public void highlightStuff(string[] fileContent, Int64 seconds, Player p)
        {
            Player.UndoPos Pos;

            for (int i = fileContent.Length / 7; i >= 0; i--)
            {
                try
                {
                    if (Convert.ToDateTime(fileContent[(i * 7) + 4].Replace('&', ' ')).AddSeconds(seconds) >= DateTime.Now)
                    {
                        Level foundLevel = Level.Find(fileContent[i * 7]);
                        if (foundLevel != null && foundLevel == p.level)
                        {
                            Pos.mapName = foundLevel.name;
                            Pos.x = Convert.ToUInt16(fileContent[(i * 7) + 1]);
                            Pos.y = Convert.ToUInt16(fileContent[(i * 7) + 2]);
                            Pos.z = Convert.ToUInt16(fileContent[(i * 7) + 3]);

                            Pos.type = foundLevel.GetTile(Pos.x, Pos.y, Pos.z);

                            if (Pos.type == Convert.ToByte(fileContent[(i * 7) + 6]) || Block.Convert(Pos.type) == Block.water || Block.Convert(Pos.type) == Block.lava)
                            {
                                if (Pos.type == Block.air || Block.Convert(Pos.type) == Block.water || Block.Convert(Pos.type) == Block.lava)
                                    p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.red);
                                else p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.green);
                            }
                        }
                    }
                    else break;
                }
                catch { }
            }
        }
Exemple #13
0
 public static Int64 GetBigEndian(Int64 value) {
     if (BitConverter.IsLittleEndian) {
         return swapByteOrder(value);
     } else {
         return value;
     }
 }
 public Fields()
 {
     date = "";
     user_name="";
     nas_port=0;
     nas_ip_address="";
     framed_ip_address="";
     nas_identifier="";
     airespace_wlan_id=0;
     acct_session_id="";
     acct_authentic="";
     tunnel_type="";
     tunnel_medium_type="";
     tunnel_private_group_id=0;
     acct_status_type="";
     acct_input_octets=0;
     acct_output_octets=0;
     acct_input_packets=0;
     acct_output_packets=0;
     acct_session_time=0;
     acct_delay_time=0;
     calling_station_id="";
     called_station_id="";
     acct_unique_session_id="";
     realm="";
     timestamp=0;
     request_authenticator="";
 }
        public Int64 DispositionList_Save(ref Int64 ID, string DispositionListName, bool IsActive, Int64 CreatedBy, string Description)
        {
            try
            {
                SqlCommand cmd;
                ExecuteNonQuery(out cmd, "spAEDispositionList",
                    CreateParameter("@pID", SqlDbType.BigInt, ID, ParameterDirection.Input),
                    CreateParameter("@pDespsitionListName", SqlDbType.NVarChar, DispositionListName),
                    CreateParameter("@pIsActive", SqlDbType.Bit, IsActive),
                    CreateParameter("@pDescription", SqlDbType.NVarChar, Description),
                    CreateParameter("@pUserID", SqlDbType.BigInt, CreatedBy),
                    CreateParameter("@pReturnMaxId", SqlDbType.BigInt, ParameterDirection.Output));

                ID = Convert.ToInt64(cmd.Parameters["@pReturnMaxId"].Value.ToString());


                cmd.Dispose();
                return ID;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Call Center--:--DispositionList--:--DispositionList.DataAccess--:--ClsDispositionListDataService.cs--:--DispositionList_Save()--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);
                return 0;
            } 
        }
Exemple #16
0
        public static INode AddNode(this IGraph myIGraph, Int64 myInt64Id)
        {
            if (myIGraph == null)
                throw new ArgumentNullException("myIGraph must not be null!");

            return myIGraph.AddNode(myInt64Id.ToString());
        }
Exemple #17
0
        public PeriodDetails(Int64 PeriodID)
        {
            InitializeComponent();

            UpdatePeriodData(PeriodID);
            this.TabText = txtName.Text + " Details";
        }
Exemple #18
0
 /// <summary>
 /// Gets the bytes of an Int64.
 /// </summary>
 public static unsafe void GetBytes(Int64 value, byte[] buffer, int startingIndex)
 {
     fixed(byte* numRef = buffer)
     {
         *((long*)(numRef + startingIndex)) = value;
     }
 }
        public int GetSongPlayCount(Int64 productId, Int64 customerId)
        {
            var playCount = 0;
            using (var conn = _getConnection())
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT Sum(CU.IsPlayed) as PlayCount FROM CustomerUsage CU WHERE Cu.CustomerId = @CustomerId AND Cu.ProductId = @ProductId";
                    cmd.Parameters.Add(new SqlParameter("CustomerId", System.Data.SqlDbType.BigInt) { Value = customerId });
                    cmd.Parameters.Add(new SqlParameter("ProductId", System.Data.SqlDbType.BigInt) { Value = productId });
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (!DBNull.Value.Equals(reader["PlayCount"]))
                            {
                                playCount = (int) (reader["PlayCount"]);
                            }
                            else
                            {
                                playCount = 0;
                            }
                        }
                    }
                }
            }

            return playCount;
        }
        public static Cliente getCliente(Int64 id_cliente)
        {
            //creo la conexion
            SqlConnection cnn = new SqlConnection(conexion);
            //abro la conexion
            cnn.Open();
            //creo la lista para almacenar las personas
             Cliente c = new Cliente();
            //Creo el comando sql a utlizar
            SqlCommand cmd = new SqlCommand("select c.id_cliente, c.nombre, c.documento, c.telefono, c.email, c.direccion, c.ciudad, c.id_pais, p.nombre, c.rut, c.nacimiento from cliente c, pais p where c.id_pais = p.id_pais and id_cliente = @id_cliente");
            cmd.Parameters.Add(new SqlParameter("@id_cliente", id_cliente));

            //asigno la conexion al comando
            cmd.Connection = cnn;
            //creo el datareader
            SqlDataReader obdr = cmd.ExecuteReader();
            //recorro el datareader
            while (obdr.Read())
            {

                c.Nombre = obdr.GetString(1);

            }

            //Cierro la conexion
            cnn.Close();
            //retorno la lsita
            return c;
        }
Exemple #21
0
        public static SocialEntry Read(Int64 character, IDataReader reader, SocialType type)
        {
            if (!reader.Read())
                return null;

            SocialEntry entry;

            if (type == SocialType.Enemy)
            {
                var eentry = new EnemyEntry
                {
                    Race = reader.GetByte(1)
                };
                //eentry.TimesKilled = reader.GetByte("TimesKilled");
                //eentry.TimesKilledBy = reader.GetByte("TimesKilledBy");

                entry = eentry;
            }
            else
                entry = new SocialEntry();

            entry.Character = character;
            entry.OtherCharacter = reader.GetInt64(0);
            entry.Level = reader.GetByte(3);
            entry.LastContinentId = reader.GetUInt32(4);
            entry.Class = reader.GetByte(2);
            entry.Online = false;
            entry.Name = reader.GetString(5);
            entry.Type = (SocialType)reader.GetByte(6);

            return entry;
        }
 public void getMpdata(Int16 constituencyId)
 {
     try
     {
         DataTable dt = new DataTable();
         dt = mpdetailsbal.getData(constituencyId); /** empid fetch throw ***/
         imgMpProfile.ImageUrl = dt.Rows[0]["profilePic"].ToString();
         lblname.Text = dt.Rows[0]["firstName"].ToString() + "  " + dt.Rows[0]["middleName"].ToString() + " " + dt.Rows[0]["lastName"].ToString();
         lblconstituency.Text = dt.Rows[0]["constituency"].ToString();
         lblparty.Text = dt.Rows[0]["partyName"].ToString() + "(" + dt.Rows[0]["Abbreviation"].ToString() + ")";
         lblmail.Text = dt.Rows[0]["email"].ToString();
         lblcntct.Text = dt.Rows[0]["mobile"].ToString();
         lbleducational_q.Text = dt.Rows[0]["qualification"].ToString();
         lblprofession.Text = dt.Rows[0]["profession"].ToString();
         lblp_address.Text = dt.Rows[0]["permanentAddress"].ToString() + ", " + dt.Rows[0][12].ToString() + ", " + dt.Rows[0][13].ToString();
         lblpresent_address.Text = dt.Rows[0]["currentAddress"].ToString() + ", " + dt.Rows[0][15].ToString() + ", " + dt.Rows[0][16].ToString();
         mpidval = Int64.Parse(dt.Rows[0]["mpId"].ToString());
         //DataTable numDt = new DataTable();
         //numDt = issuesbal.Issues_Numbers(Convert.ToInt64(dt.Rows[0]["mpId"]));
         //lblissuesno.Text = numDt.Rows[0][0].ToString();
         //lblsolvedissuesno.Text = numDt.Rows[0][1].ToString();
     }
     catch
     {
         throw;
     }
     finally
     {
     }
 }
        /// <summary>
        ///     Gets the specified percentage of the number.
        /// </summary>
        /// <param name="number">The number.</param>
        /// <param name="percent">The percent.</param>
        /// <returns>Returns the specified percentage of the number</returns>
        public static Double PercentageOf( this Int64 number, Int64 percent )
        {
            if ( number <= 0 )
                throw new DivideByZeroException( "The number must be greater than zero." );

            return (Double) number * percent / 100;
        }
        public Int32 DeleteShopeMappingById(Int64 Id)
        {
            Hashtable lstItems = new Hashtable();
            lstItems.Add("@Id", Id);

            return dal.DeleteShopeMappingById(lstItems);
        }
Exemple #25
0
        internal string GetInternalUsername(Int64 nodeID)
        {
            string sql = "SELECT ";
            sql += "    [User.Account].[User].InternalUserName ";
            sql += "FROM ";
            sql += "    [RDF.Stage].InternalNodeMap  ";
            sql += "    INNER JOIN [User.Account].[User] ON [RDF.Stage].InternalNodeMap.InternalID = [User.Account].[User].PersonID ";
            sql += "WHERE ";
            sql += "    ([RDF.Stage].InternalNodeMap.Class = 'http://xmlns.com/foaf/0.1/Person')  ";
            sql += "    AND ([RDF.Stage].InternalNodeMap.NodeID = " + nodeID.ToString() + ") ";

            DbCommand cmd = GetCommand();
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;

            System.Data.DataTable dt = FillTable(cmd);
            if (dt.Rows.Count > 0)
            {
                if (!dt.Rows[0].IsNull("InternalUserName"))
                {
                    return dt.Rows[0]["InternalUserName"].ToString();
                }
            }
            return string.Empty;
        }
Exemple #26
0
    static public void TestAbs_Ok(Int64 i)
    {
      Contract.Requires(i > 0);
      var z = Math.Abs(i);

      Contract.Assert(z >= 0);
    }
Exemple #27
0
 public Trip(BinaryReader byteFile)
 {
     this.Time = byteFile.ReadInt64();
     this.TimeDT = new DateTime(this.Time);
     this.Comment = byteFile.ReadString();
     this.declination = byteFile.ReadInt16();
 }
Exemple #28
0
 public Trip()
 {
     this.TimeDT = DateTime.Now;
     this.Time = this.TimeDT.Ticks;
     this.Comment = "";
     this.declination = Int16.MinValue;
 }
        public bool MakeOffer(Int64 requestRecID, string driverID, string notes)
        {
            bool isInserted;

            try
            {
                using (connection)
                {
                    connection = new SqlConnection(DAL.ConnectionString);
                    Int64 nextRecID = getNextRecID();

                    string sqlSelectString = "INSERT into [RideOffers] (RideRequestRecID, DriverUserID, Notes, Status) values("
                                                 + requestRecID + ",'"
                                                 + driverID + "','"
                                                 + notes + "',"
                                                 + nextRecID+")";

                    command = new SqlCommand(sqlSelectString, connection);
                    command.Connection.Open();

                    int totalRowsAffected = command.ExecuteNonQuery();

                    command.Connection.Close();
                    isInserted = totalRowsAffected > 0;

                    return isInserted;
                }
            }
            catch (Exception ex)
            {
                // err.ErrorMessage = ex.Message.ToString();
                throw;
            }
        }
Exemple #30
0
        void IStream.Seek(Int64 offset, Int32 origin, IntPtr newPositionPtr)
        {
            SeekOrigin  seekOrigin;

            // The operation will generally be I/O bound, so there is no point in
            // eliminating the following switch by playing on the fact that
            // System.IO uses the same integer values as IStream for SeekOrigin.
            switch(origin)
            {
                case NativeMethods.STREAM_SEEK_SET:
                    seekOrigin = SeekOrigin.Begin;
                    break;
                case NativeMethods.STREAM_SEEK_CUR:
                    seekOrigin = SeekOrigin.Current;
                    break;
                case NativeMethods.STREAM_SEEK_END:
                    seekOrigin = SeekOrigin.End;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("origin");
            }
            long position = _ioStream.Seek(offset, seekOrigin);

            // Dereference newPositionPtr and assign to the pointed location.
            if (newPositionPtr != IntPtr.Zero)
            {
                Marshal.WriteInt64(newPositionPtr, position);
            }
        }
    private void Process()
    {
        m_LVL_Received  = true;
        m_ButtonMessage = "Check LVL";
        m_ButtonEnabled = true;

        if (m_LVLCheck == null)
        {
            return;
        }

        int    responseCode = m_LVLCheck.Get <int>("_arg0");
        string message      = m_LVLCheck.Get <string>("_arg1");
        string signature    = m_LVLCheck.Get <string>("_arg2");

        m_LVLCheck = null;

        m_ResponseCode_Received = responseCode.ToString();
        if (responseCode < 0 || string.IsNullOrEmpty(message) || string.IsNullOrEmpty(signature))
        {
            m_PackageName_Received = "<Failed>";
            return;
        }

        byte[] message_bytes         = System.Text.Encoding.UTF8.GetBytes(message);
        byte[] signature_bytes       = System.Convert.FromBase64String(signature);
        RSACryptoServiceProvider csp = new RSACryptoServiceProvider();

        csp.ImportParameters(m_PublicKey);
        SHA1Managed sha1  = new SHA1Managed();
        bool        match = csp.VerifyHash(sha1.ComputeHash(message_bytes), CryptoConfig.MapNameToOID("SHA1"), signature_bytes);

        if (!match)
        {
            m_ResponseCode_Received = "<Failed>";
            m_PackageName_Received  = "<Invalid Signature>";
            return;
        }

        int    index = message.IndexOf(':');
        string mainData, extraData;

        if (-1 == index)
        {
            mainData  = message;
            extraData = "";
        }
        else
        {
            mainData  = message.Substring(0, index);
            extraData = index >= message.Length ? "" : message.Substring(index + 1);
        }

        string[] vars = mainData.Split('|');                    // response | nonce | package | version | userid | timestamp

        if (vars[0].CompareTo(responseCode.ToString()) != 0)
        {
            m_ResponseCode_Received = "<Failed>";
            m_PackageName_Received  = "<Response Mismatch>";
            return;
        }

        m_ResponseCode_Received = vars[0];
        m_Nonce_Received        = System.Convert.ToInt32(vars[1]);
        m_PackageName_Received  = vars[2];
        m_VersionCode_Received  = System.Convert.ToInt32(vars[3]);
        m_UserID_Received       = vars[4];
        System.Int64 ticks = ConvertEpochSecondsToTicks(System.Convert.ToInt64(vars[5]));
        m_Timestamp_Received = new System.DateTime(ticks).ToLocalTime().ToString();

        if (!string.IsNullOrEmpty(extraData))
        {
            Dictionary <string, string> extrasDecoded = DecodeExtras(extraData);

            if (extrasDecoded.ContainsKey("GR"))
            {
                m_MaxRetry_Received = System.Convert.ToInt32(extrasDecoded["GR"]);
            }
            else
            {
                m_MaxRetry_Received = 0;
            }

            if (extrasDecoded.ContainsKey("VT"))
            {
                ticks = ConvertEpochSecondsToTicks(System.Convert.ToInt64(extrasDecoded["VT"]));
                m_LicenceValidityTimestamp_Received = new System.DateTime(ticks).ToLocalTime().ToString();
            }
            else
            {
                m_LicenceValidityTimestamp_Received = null;
            }

            if (extrasDecoded.ContainsKey("GT"))
            {
                ticks = ConvertEpochSecondsToTicks(System.Convert.ToInt64(extrasDecoded["GT"]));
                m_GracePeriodTimestamp_Received = new System.DateTime(ticks).ToLocalTime().ToString();
            }
            else
            {
                m_GracePeriodTimestamp_Received = null;
            }

            if (extrasDecoded.ContainsKey("UT"))
            {
                ticks = ConvertEpochSecondsToTicks(System.Convert.ToInt64(extrasDecoded["UT"]));
                m_UpdateTimestamp_Received = new System.DateTime(ticks).ToLocalTime().ToString();
            }
            else
            {
                m_UpdateTimestamp_Received = null;
            }

            if (extrasDecoded.ContainsKey("FILE_URL1"))
            {
                m_FileURL1_Received = extrasDecoded["FILE_URL1"];
            }
            else
            {
                m_FileURL1_Received = "";
            }

            if (extrasDecoded.ContainsKey("FILE_URL2"))
            {
                m_FileURL2_Received = extrasDecoded["FILE_URL2"];
            }
            else
            {
                m_FileURL2_Received = "";
            }

            if (extrasDecoded.ContainsKey("FILE_NAME1"))
            {
                m_FileName1_Received = extrasDecoded["FILE_NAME1"];
            }
            else
            {
                m_FileName1_Received = null;
            }

            if (extrasDecoded.ContainsKey("FILE_NAME2"))
            {
                m_FileName2_Received = extrasDecoded["FILE_NAME2"];
            }
            else
            {
                m_FileName2_Received = null;
            }

            if (extrasDecoded.ContainsKey("FILE_SIZE1"))
            {
                m_FileSize1_Received = System.Convert.ToInt32(extrasDecoded["FILE_SIZE1"]);
            }
            else
            {
                m_FileSize1_Received = 0;
            }

            if (extrasDecoded.ContainsKey("FILE_SIZE2"))
            {
                m_FileSize2_Received = System.Convert.ToInt32(extrasDecoded["FILE_SIZE2"]);
            }
            else
            {
                m_FileSize2_Received = 0;
            }
        }
    }
Exemple #32
0
        // called by parse_number when we know that the output is a float,
        // but where there might be some integer overflow. The trick here is to
        // parse using floats from the start.
        // Do not call this function directly as it skips some of the checks from
        // parse_number
        //
        // This function will almost never be called!!!
        //
        // Note: a redesign could avoid this function entirely.
        //
        private static bool parse_float(uint8_t *buf, ParsedJson pj, uint32_t offset, bool found_minus)
        {
            bytechar *p        = (bytechar *)(buf + offset);
            bool      negative = false;

            if (found_minus)
            {
                ++p;
                negative = true;
            }

            double i;

            if (*p == '0')
            {
                // 0 cannot be followed by an integer
                ++p;
                i = 0;
            }
            else
            {
                unsigned_bytechar digit = (unsigned_bytechar)(*p - (bytechar)'0');
                i = digit;
                p++;
                while (is_integer(*p))
                {
                    digit = (unsigned_bytechar)(*p - '0');
                    i     = 10 * i + digit;
                    ++p;
                }
            }

            if ('.' == *p)
            {
                ++p;
                double fractionalweight = 1;
                if (is_integer(*p))
                {
                    unsigned_bytechar digit = (unsigned_bytechar)(*p - '0');
                    ++p;
                    fractionalweight *= 0.1;
                    i = i + digit * fractionalweight;
                }
                else
                {
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                while (is_integer(*p))
                {
                    unsigned_bytechar digit = (unsigned_bytechar)(*p - '0');
                    ++p;
                    fractionalweight *= 0.1;
                    i = i + digit * fractionalweight;
                }
            }

            if (('e' == *p) || ('E' == *p))
            {
                ++p;
                bool negexp = false;
                if ('-' == *p)
                {
                    negexp = true;
                    ++p;
                }
                else if ('+' == *p)
                {
                    ++p;
                }

                if (!is_integer(*p))
                {
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                unsigned_bytechar digit     = (unsigned_bytechar)(*p - '0');
                int64_t           expnumber = digit; // exponential part
                p++;
                if (is_integer(*p))
                {
                    digit     = (unsigned_bytechar)(*p - '0');
                    expnumber = 10 * expnumber + digit;
                    ++p;
                }

                if (is_integer(*p))
                {
                    digit     = (unsigned_bytechar)(*p - '0');
                    expnumber = 10 * expnumber + digit;
                    ++p;
                }

                if (is_integer(*p))
                {
                    digit     = (unsigned_bytechar)(*p - '0');
                    expnumber = 10 * expnumber + digit;
                    ++p;
                }

                if (is_integer(*p))
                {
// we refuse to parse this
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                int exponent = (int)(negexp ? -expnumber : expnumber);
                if ((exponent > 308) || (exponent < -308))
                {
// we refuse to parse this
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                i *= power_of_ten[308 + exponent];
            }

            if (is_not_structural_or_whitespace((byte)*p) != 0)
            {
                return(false);
            }

            double d = negative ? -i : i;
            pj.WriteTapeDouble(d);
#if JSON_TEST_NUMBERS // for unit testing
            foundFloat(d, buf + offset);
#endif
            return(is_structural_or_whitespace((byte)(*p)) != 0);
        }
Exemple #33
0
 /// <summary> CTor</summary>
 /// <param name="dependantTestId">PK value for TestDependencyRule which data should be fetched into this TestDependencyRule object</param>
 /// <param name="testId">PK value for TestDependencyRule which data should be fetched into this TestDependencyRule object</param>
 /// <remarks>The entity is not fetched by this constructor. Use a DataAccessAdapter for that.</remarks>
 public TestDependencyRuleEntity(System.Int64 dependantTestId, System.Int64 testId) : base("TestDependencyRuleEntity")
 {
     InitClassEmpty(null, CreateFields());
     this.DependantTestId = dependantTestId;
     this.TestId          = testId;
 }
Exemple #34
0
 public NewMessage(System.Int64 _id)
 {
     id = _id;
 }
Exemple #35
0
 private int SwigDirectorInterpret__SWIG_1(IntPtr tk, ID_Key key)
 {
     return((int)Interpret(new BStreamFileToolkit(tk, false), key));
 }
Exemple #36
0
 public static unsafe extern int sprintf(byte *str, [NativeStringParam(NativeStringType.Char)] string format, Int64 number);
Exemple #37
0
 public override void SetLength(System.Int64 value)
 {
     _stream.SetLength(value);
 }
 sf_read_int(IntPtr sndfile,
             int[] ptr, sf_count_t items);
 public static Int64 ToInt64(this String Expr, Int64 DefaultValue = 0)
 {
     return(ToInt64Nullable(Expr) ?? DefaultValue);
 }
Exemple #40
0
    public void In(
        [FriendlyName("Target", "The Target variable to be converted.")]
        object Target,

        [FriendlyName("Int Value", "The Target variable represented as an integer.")]
        out int IntValue,

        [FriendlyName("Int 64 Value", "The Target variable represented as a System.Int64.")]
        out System.Int64 Int64Value,

        [FriendlyName("Float Value", "The Target variable represented as a floating-point value.")]
        out float FloatValue,

        [FriendlyName("String Value", "The Target variable represented as a string.")]
        out string StringValue,

        [FriendlyName("Boolean Value", "The Target variable represented as a Boolean (true/false) value.")]
        out bool BooleanValue,

        [FriendlyName("Vector3 Value", "The Target variable represented as a Vector3 value.")]
        out Vector3 Vector3Value,

        [FriendlyName("Float Group Separator", "The character to use between each set of 3 digits (i.e. comma - 1,000,000). Can be blank (i.e. 1000000).")]
        [DefaultValue(","), SocketState(false, false)]
        string FloatGroupSeparator
        )
    {
        int tempIntValue = 0;

        System.Int64 tempInt64Value   = 0;
        float        tempFloatValue   = 0F;
        string       tempStringValue  = Target.ToString();
        bool         tempBooleanValue = false;
        Vector3      tempVector3Value = Vector3.zero;

        // Convert from GameObject
        if (typeof(GameObject) == Target.GetType())
        {
            GameObject tmpTarget = (GameObject)Target;

            if (tmpTarget != null)
            {
                tempIntValue     = 1;
                tempInt64Value   = 1;
                tempFloatValue   = 1F;
                tempBooleanValue = true;
                tempStringValue  = tmpTarget.name;
            }
            else
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = "null";
            }
        }

        // Convert from Enum
        else if (Target is System.Enum)
        {
            tempIntValue     = (int)Target;
            tempInt64Value   = (System.Int64)tempIntValue;
            tempFloatValue   = tempIntValue;
            tempBooleanValue = tempIntValue == 0 ? false : true;
            tempStringValue  = Target.ToString();
        }

        // Convert from Vector2
        else if (typeof(Vector2) == Target.GetType())
        {
            Vector3 tmpTarget = (Vector2)Target;

            if (tmpTarget.ToString() == "(0.0, 0.0)")
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget.ToString();
            }
            else
            {
                tempIntValue     = 1;
                tempInt64Value   = 1;
                tempFloatValue   = 1F;
                tempBooleanValue = true;
                tempStringValue  = tmpTarget.ToString();
            }
        }

        // Convert from Vector3
        else if (typeof(Vector3) == Target.GetType())
        {
            Vector3 tmpTarget = (Vector3)Target;
            tempVector3Value = tmpTarget;

            if (tmpTarget.ToString() == "(0.0, 0.0, 0.0)")
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget.ToString();
            }
            else
            {
                tempIntValue     = 1;
                tempInt64Value   = 1;
                tempFloatValue   = 1F;
                tempBooleanValue = true;
                tempStringValue  = tmpTarget.ToString();
            }
        }

        // Convert from Vector4
        else if (typeof(Vector4) == Target.GetType())
        {
            Vector4 tmpTarget = (Vector4)Target;

            if (tmpTarget.ToString() == "(0.0, 0.0, 0.0, 0.0)")
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget.ToString();
            }
            else
            {
                tempIntValue     = 1;
                tempInt64Value   = 1;
                tempFloatValue   = 1F;
                tempBooleanValue = true;
                tempStringValue  = tmpTarget.ToString();
            }
        }

        // Convert from String
        else if (typeof(string) == Target.GetType())
        {
            string tmpTarget = (string)Target;

            if (tmpTarget == "")
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget;
            }
            else
            {
                string [] components = tmpTarget.Split(',');
                char[]    trimchars  = { '(', ')' };

                if (components.Length >= 3)
                {
                    System.Single.TryParse(components[0].TrimStart(trimchars), out tempVector3Value.x);
                    System.Single.TryParse(components[1], out tempVector3Value.y);
                    System.Single.TryParse(components[2].TrimEnd(trimchars), out tempVector3Value.z);
                }

                int  intNumber     = 1;
                bool canConvertInt = System.Int32.TryParse(tmpTarget, out intNumber);
                if (canConvertInt)
                {
                    tempIntValue = intNumber;
                }
                else
                {
                    tempIntValue = 1;
                }

                System.Int64 int64Number     = 1;
                bool         canConvertInt64 = System.Int64.TryParse(tmpTarget, out int64Number);
                if (canConvertInt64)
                {
                    tempInt64Value = int64Number;
                }
                else
                {
                    tempInt64Value = 1;
                }

                float floatNumber     = 1F;
                bool  canConvertFloat = System.Single.TryParse(tmpTarget, out floatNumber);
                if (canConvertFloat)
                {
                    tempFloatValue = floatNumber;
                }
                else
                {
                    tempFloatValue = 1F;
                }

                bool boolValue      = true;
                bool canConvertBool = System.Boolean.TryParse(tmpTarget, out boolValue);
                if (canConvertBool)
                {
                    tempBooleanValue = boolValue;
                }
                else
                {
                    tempBooleanValue = true;
                }

                tempStringValue = tmpTarget;
            }
        }

        // Convert from TextAsset
        else if (typeof(TextAsset) == Target.GetType())
        {
            TextAsset tmpTextAsset = (TextAsset)Target;

            string tmpTarget = tmpTextAsset.text;

            if (tmpTarget == "")
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget;
            }
            else
            {
                int  intNumber     = 1;
                bool canConvertInt = System.Int32.TryParse(tmpTarget, out intNumber);
                if (canConvertInt)
                {
                    tempIntValue = intNumber;
                }
                else
                {
                    tempIntValue = 1;
                }

                System.Int64 int64Number     = 1;
                bool         canConvertInt64 = System.Int64.TryParse(tmpTarget, out int64Number);
                if (canConvertInt64)
                {
                    tempInt64Value = int64Number;
                }
                else
                {
                    tempInt64Value = 1;
                }

                float floatNumber     = 1F;
                bool  canConvertFloat = System.Single.TryParse(tmpTarget, out floatNumber);
                if (canConvertFloat)
                {
                    tempFloatValue = floatNumber;
                }
                else
                {
                    tempFloatValue = 1F;
                }

                bool boolValue      = true;
                bool canConvertBool = System.Boolean.TryParse(tmpTarget, out boolValue);
                if (canConvertBool)
                {
                    tempBooleanValue = boolValue;
                }
                else
                {
                    tempBooleanValue = true;
                }


                tempStringValue = tmpTarget;
            }
        }

        // Convert from Int
        else if (typeof(int) == Target.GetType())
        {
            int tmpTarget = (int)Target;

            if (tmpTarget == 0)
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget.ToString();
            }
            else
            {
                tempIntValue     = tmpTarget;
                tempInt64Value   = System.Convert.ToInt64(tmpTarget);
                tempFloatValue   = System.Convert.ToSingle(tmpTarget);
                tempBooleanValue = true;
                tempStringValue  = tmpTarget.ToString();
            }
        }

        // Convert from Int64
        else if (typeof(System.Int64) == Target.GetType())
        {
            System.Int64 tmpTarget = (System.Int64)Target;

            if (tmpTarget == 0)
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget.ToString();
            }
            else
            {
                tempIntValue     = System.Convert.ToInt32(tmpTarget);
                tempInt64Value   = tmpTarget;
                tempFloatValue   = System.Convert.ToSingle(tmpTarget);
                tempBooleanValue = true;
                tempStringValue  = tmpTarget.ToString();
            }
        }

        // Convert from Float
        else if (typeof(float) == Target.GetType())
        {
            float tmpTarget = (float)Target;

            if (tmpTarget == 0)
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = tmpTarget.ToString();
            }
            else
            {
                tempIntValue     = System.Convert.ToInt32(tmpTarget);
                tempInt64Value   = System.Convert.ToInt64(tmpTarget);
                tempFloatValue   = tmpTarget;
                tempBooleanValue = true;
                tempStringValue  = tmpTarget.ToString();
            }
        }

        // Convert from Bool
        else if (typeof(bool) == Target.GetType())
        {
            bool tmpTarget = (bool)Target;

            if (tmpTarget == true)
            {
                tempIntValue     = 1;
                tempInt64Value   = 1;
                tempFloatValue   = 1F;
                tempBooleanValue = true;
                tempStringValue  = "True";
            }
            else
            {
                tempIntValue     = 0;
                tempInt64Value   = 0;
                tempFloatValue   = 0F;
                tempBooleanValue = false;
                tempStringValue  = "False";
            }
        }

        // Output results
        IntValue     = tempIntValue;
        Int64Value   = tempInt64Value;
        FloatValue   = tempFloatValue;
        StringValue  = tempStringValue;
        BooleanValue = tempBooleanValue;
        Vector3Value = tempVector3Value;
    }
    public override void OnInspectorGUI(NavGraph target)
    {
        RecastGraph graph = target as RecastGraph;

        bool preEnabled = GUI.enabled;

        //if (graph.forceBounds) {

        graph.useCRecast = GUILayout.Toolbar(graph.useCRecast ?1:0, new GUIContent[2] {
            new GUIContent("C# Recast", "I have translated a portion of Recast to C#, this can be used in a webplayer but is more limited than the C++ version"),
            new GUIContent("C++ Recast", "Use the original C++ version of Recast, faster scanning times and has more features than the C# version, but it can only be used in the editor or on standalone applications (note that you can still scan the graph in the editor and then cache the startup if you want to build for a webplayer)"
                           + "\nTake a look in the docs on RecastGraph.useCRecast for more information on the special considerations when using this mode")
        }) == 1;

        if (graph.useCRecast)
        {
            BuildTarget bt = EditorUserBuildSettings.activeBuildTarget;
            if (bt != BuildTarget.StandaloneOSXIntel)
            {
                if (GUILayout.Button("Note that the C++ version of Recast does not work in your selected build target (" + bt + ")\n" +
                                     "Change build target to standalone (osx) if you want to be able to use C++\n" +
                                     "Click here for more info", AstarPathEditor.helpBox))
                {
                    Application.OpenURL(AstarPathEditor.GetURL("cRecastHelp"));
                }
            }
            else
            {
                if (GUILayout.Button("Note the special considerations when using C++ Recast\nClick here for more info", AstarPathEditor.helpBox))
                {
                    Application.OpenURL(AstarPathEditor.GetURL("cRecastHelp"));
                }
            }

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                GUILayout.Label("C++ Recast can currently not be used on Windows", AstarPathEditor.helpBox);
            }
        }

        System.Int64 estWidth = Mathf.RoundToInt(Mathf.Ceil(graph.forcedBoundsSize.x / graph.cellSize));
        System.Int64 estDepth = Mathf.RoundToInt(Mathf.Ceil(graph.forcedBoundsSize.z / graph.cellSize));

        if (estWidth * estDepth >= 1024 * 1024 || estDepth >= 1024 * 1024 || estWidth >= 1024 * 1024)
        {
            GUIStyle helpBox = GUI.skin.FindStyle("HelpBox");
            if (helpBox == null)
            {
                helpBox = GUI.skin.FindStyle("Box");
            }

            Color preColor = GUI.color;
            if (estWidth * estDepth >= 2048 * 2048 || estDepth >= 2048 * 2048 || estWidth >= 2048 * 2048)
            {
                GUI.color = Color.red;
            }
            else
            {
                GUI.color = Color.yellow;
            }

            GUILayout.Label("Warning : Might take some time to calculate", helpBox);
            GUI.color = preColor;
        }

        GUI.enabled = false;
        EditorGUILayout.LabelField("Width (samples)", estWidth.ToString());

        EditorGUILayout.LabelField("Depth (samples)", estDepth.ToString());

        /*} else {
         *      GUI.enabled = false;
         *      EditorGUILayout.LabelField ("Width (samples)","undetermined");
         *      EditorGUILayout.LabelField ("Depth (samples)","undetermined");
         * }*/
        GUI.enabled = preEnabled;

        graph.cellSize = EditorGUILayout.FloatField(new GUIContent("Cell Size", "Size of one voxel in world units"), graph.cellSize);
        if (graph.cellSize < 0.001F)
        {
            graph.cellSize = 0.001F;
        }

        graph.cellHeight = EditorGUILayout.FloatField(new GUIContent("Cell Height", "Height of one voxel in world units"), graph.cellHeight);
        if (graph.cellHeight < 0.001F)
        {
            graph.cellHeight = 0.001F;
        }

        graph.walkableHeight  = EditorGUILayout.FloatField(new GUIContent("Walkable Height", "Minimum distance to the roof for an area to be walkable"), graph.walkableHeight);
        graph.walkableClimb   = EditorGUILayout.FloatField(new GUIContent("Walkable Climb", "How high can the character climb"), graph.walkableClimb);
        graph.characterRadius = EditorGUILayout.FloatField(new GUIContent("Character Radius", "Radius of the character, it's good to add some margin though"), graph.characterRadius);

        if (graph.useCRecast)
        {
            graph.regionMinSize = EditorGUILayout.IntField(new GUIContent("Min Region Size", "The lowest number of voxles in one area for it not to be deleted"), graph.regionMinSize);
        }

        graph.maxSlope      = EditorGUILayout.Slider(new GUIContent("Max Slope", "Approximate maximum slope"), graph.maxSlope, 0F, 90F);
        graph.maxEdgeLength = EditorGUILayout.FloatField(new GUIContent("Max Edge Length", "Maximum length of one edge in the completed navmesh before it is split. A lower value can often yield better quality graphs"), graph.maxEdgeLength);
        graph.maxEdgeLength = graph.maxEdgeLength < graph.cellSize ? graph.cellSize : graph.maxEdgeLength;

        /*if (!graph.useCRecast) {
         *      graph.erosionRadius = EditorGUILayout.IntSlider ("Erosion radius",graph.erosionRadius,0,256);
         * }*/

        graph.contourMaxError = EditorGUILayout.FloatField(new GUIContent("Max edge error", "Amount of simplification to apply to edges"), graph.contourMaxError);

        graph.rasterizeTerrain = EditorGUILayout.Toggle(new GUIContent("Rasterize Terrain", "Should a rasterized terrain be included"), graph.rasterizeTerrain);
        if (graph.rasterizeTerrain)
        {
            EditorGUI.indentLevel++;
            graph.rasterizeTrees = EditorGUILayout.Toggle(new GUIContent("Rasterize Trees", "Rasterize tree colliders on terrains. " +
                                                                         "If the tree prefab has a collider, that collider will be rasterized. " +
                                                                         "Otherwise a simple box collider will be used and the script will " +
                                                                         "try to adjust it to the tree's scale, it might not do a very good job though so " +
                                                                         "an attached collider is preferable."), graph.rasterizeTrees);
            if (graph.rasterizeTrees)
            {
                EditorGUI.indentLevel++;
                graph.colliderRasterizeDetail = EditorGUILayout.FloatField(new GUIContent("Collider Detail", "Controls the detail of the generated collider meshes. Increasing does not necessarily yield better navmeshes, but lowering will speed up scan"), graph.colliderRasterizeDetail);
                EditorGUI.indentLevel--;
            }

            graph.terrainSampleSize = EditorGUILayout.IntField(new GUIContent("Terrain Sample Size", "Size of terrain samples. A lower value is better, but slower"), graph.terrainSampleSize);
            graph.terrainSampleSize = graph.terrainSampleSize < 1 ? 1 : graph.terrainSampleSize;            //Clamp to at least 1
            EditorGUI.indentLevel--;
        }

        graph.rasterizeMeshes    = EditorGUILayout.Toggle(new GUIContent("Rasterize Meshes", "Should meshes be rasterized and used for building the navmesh"), graph.rasterizeMeshes);
        graph.rasterizeColliders = EditorGUILayout.Toggle(new GUIContent("Rasterize Colliders", "Should colliders be rasterized and used for building the navmesh"), graph.rasterizeColliders);
        if (graph.rasterizeColliders)
        {
            EditorGUI.indentLevel++;
            graph.colliderRasterizeDetail = EditorGUILayout.FloatField(new GUIContent("Collider Detail", "Controls the detail of the generated collider meshes. Increasing does not necessarily yield better navmeshes, but lowering will speed up scan"), graph.colliderRasterizeDetail);
            EditorGUI.indentLevel--;
        }

        graph.mask = EditorGUILayoutx.LayerMaskField("Layer Mask", graph.mask);

        graph.includeOutOfBounds = EditorGUILayout.Toggle(new GUIContent("Include out of bounds", "Should voxels out of bounds, on the Y axis below the graph, be included or not"), graph.includeOutOfBounds);
        Separator();

        graph.forcedBoundsCenter = EditorGUILayout.Vector3Field("Center", graph.forcedBoundsCenter);
        graph.forcedBoundsSize   = EditorGUILayout.Vector3Field("Size", graph.forcedBoundsSize);

        if (GUILayout.Button(new GUIContent("Snap bounds to scene", "Will snap the bounds of the graph to exactly contain all active meshes in the scene")))
        {
            graph.SnapForceBoundsToScene();
            GUI.changed = true;
        }

        Separator();

        tagMaskFoldout = EditorGUILayoutx.UnityTagMaskList(new GUIContent("Tag Mask"), tagMaskFoldout, graph.tagMask);

        Separator();

        graph.showMeshOutline = EditorGUILayout.Toggle(new GUIContent("Show mesh outline", "Toggles gizmos for drawing an outline of the mesh"), graph.showMeshOutline);

        graph.accurateNearestNode = EditorGUILayout.Toggle(new GUIContent("Accurate Nearest Node Queries", "More accurate nearest node queries. See docs for more info"), graph.accurateNearestNode);

        if (GUILayout.Button("Export to file"))
        {
            ExportToFile(graph);
        }

        /*graph.replaceMesh = (Mesh)ObjectField (new GUIContent ("Replacement Mesh","If you make edits to the mesh manually, you can drop the new mesh file here to import it"), graph.replaceMesh,typeof(Mesh),false);
         *
         * if (graph.replaceMesh != null) {
         *      HelpBox ("Note: Graph will be replaced by the mesh");
         * }*/
        //graph.mask = 1 << EditorGUILayout.LayerField ("Mask",(int)Mathf.Log (graph.mask,2));
    }
Exemple #42
0
    public static void SendMsg(int id, ProtoMessage msg)
    {
        if (msgBuffList.Count >= 3)
        {
            Debug.Log("消息队列缓冲已满");
            return;
        }

        proto.MessageHead head = new proto.MessageHead();
        head.pid   = id;
        head.msgid = SerialNumber;

        if (id != ProtoID.C2SLogin)
        {
            head.session_id = SessionId;
            head.gid        = PlayerSys.GetSN();
            if (head.session_id == 0)
            {
                Debug.Log("Send Msg error: Have not session_id");
                return;
            }
        }
        else
        {
            SerialNumber = 1;
            head.msgid   = SerialNumber;
            msgBuffList.Clear();
        }


        byte  headSize = ( byte )head.ByteSize();
        short msgSize  = ( short )msg.ByteSize();

        // 总包大小
        System.Int64 allSize = (System.Int64)(headSize + msgSize + NetMsg.MsgSendHeadSize);
        byte[]       sendBuf = new byte[allSize];

        // 写包头
        sendBuf[0] = ( byte )( uint )(allSize & 0xff);
        sendBuf[1] = ( byte )( uint )((allSize >> 8) & 0xff);
        sendBuf[2] = ( byte )( uint )((allSize >> 16) & 0xff);
        sendBuf[3] = ( byte )( uint )((allSize >> 32) & 0xff);
        sendBuf[4] = headSize;

        // 转换为2进制
        head.Serialize(ProtoHeadBuf, 0);
        msg.Serialize(ProtoDataBuf, 0);

        System.Buffer.BlockCopy(ProtoHeadBuf, 0, sendBuf, NetMsg.MsgSendHeadSize, headSize);
        System.Buffer.BlockCopy(ProtoDataBuf, 0, sendBuf, NetMsg.MsgSendHeadSize + headSize, msgSize);

        // 心跳包不阻塞玩家输入
        if (id != ProtoID.C2SHeartBeat && id != ProtoID.C2SSetCustomSetting)
        {
            NetworkIndicator.Instance.StartActivityIndicator();
        }
        msgBuffList.Add(sendBuf);
        if (msgBuffList.Count == 1)
        {
            Instance.StartCoroutine(OnPost(msgBuffList[0]));
        }

        SerialNumber++;
    }
Exemple #43
0
 ///<summary>
 ///Get conditions by primary key string.
 ///</summary>
 public static ParameterCollection GetConditionsByPrimaryKeyString(string primaryKeyString)
 {
     string[]     primaryKeys = primaryKeyString.Split('|');
     System.Int64 Id          = Convert.ToInt64(primaryKeys[0]);
     return(GetConditionsByPrimaryKey(Id));
 }
Exemple #44
0
    private void _FindPath()
    {
        _ClearAStarGridMap();

        if (null == AStar.startIndex)
        {
            AStar.startIndex = new NodeIndex();
        }

        if (null == AStar.endIndex)
        {
            AStar.endIndex = new NodeIndex();
        }

        _tmpInt = 0;
        for (int i = 0; i < _nodeStatesGrid.Count; i++)
        {
            List <bool> boolList = new List <bool>();
            for (int j = 0; j < _nodeStatesGrid[0].Count; j++)
            {
                if (NodeState.STATES.BLUE == _nodeStatesGrid[i][j].state)
                {
                    if (++_tmpInt > 2)
                    {
                        return;
                    }

                    if (1 == _tmpInt)
                    {
                        AStar.startIndex.x = i;
                        AStar.startIndex.y = j;
                    }
                    else if (2 == _tmpInt)
                    {
                        AStar.endIndex.x = i;
                        AStar.endIndex.y = j;
                    }

                    boolList.Insert(j, true);
                }
                else if (NodeState.STATES.RED == _nodeStatesGrid[i][j].state)
                {
                    boolList.Insert(j, false);
                }
                else                     // WHITE or GREEN
                {
                    boolList.Insert(j, true);
                }
            }
            AStar.gridMap.Insert(i, boolList);
        }

        if (_tmpInt != 2)
        {
            _ClearAStarGridMap();
            return;
        }

        _timeFindPath = System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000;

        AStar.heuristicType = astarMethodType;
        AStar.FindPath();

        _timeFindPath = System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000 - _timeFindPath;
    }
Exemple #45
0
        static void x_CountStep(
            sqlite3_context context,
            int argc,
            sqlite3_value[] argv
            )
        {
            SumCtx p;

            int type;

            Debug.Assert(argc <= 1);
            Mem pMem = sqlite3_aggregate_context(context, -1);//sizeof(*p));

            if (pMem._SumCtx == null)
            {
                pMem._SumCtx = new SumCtx();
            }
            p = pMem._SumCtx;
            if (p.Context == null)
            {
                p.Context = pMem;
            }
            if (argc == 0 || SQLITE_NULL == sqlite3_value_type(argv[0]))
            {
                p.cnt++;
                p.iSum += 1;
            }
            else
            {
                type = sqlite3_value_numeric_type(argv[0]);
                if (p != null && type != SQLITE_NULL)
                {
                    p.cnt++;
                    if (type == SQLITE_INTEGER)
                    {
                        i64 v = sqlite3_value_int64(argv[0]);
                        if (v == 40 || v == 41)
                        {
                            sqlite3_result_error(context, "value of " + v + " handed to x_count", -1);
                            return;
                        }
                        else
                        {
                            p.iSum += v;
                            if (!(p.approx | p.overflow != 0))
                            {
                                i64 iNewSum = p.iSum + v;
                                int s1      = (int)(p.iSum >> (sizeof(i64) * 8 - 1));
                                int s2      = (int)(v >> (sizeof(i64) * 8 - 1));
                                int s3      = (int)(iNewSum >> (sizeof(i64) * 8 - 1));
                                p.overflow = ((s1 & s2 & ~s3) | (~s1 & ~s2 & s3)) != 0 ? 1 : 0;
                                p.iSum     = iNewSum;
                            }
                        }
                    }
                    else
                    {
                        p.rSum  += sqlite3_value_double(argv[0]);
                        p.approx = true;
                    }
                }
            }
        }
Exemple #46
0
 private void SetDestSize(int64 DestSize)
 {
     DestUnpSize = DestSize; FileExtracted = false;
 }
 public SingleResult <VehicleTemperature> GetVehicleTemperature([FromODataUri] System.Int64 VehicleTemperatureID)
 {
     return(SingleResult.Create(_service.Queryable().Where(t => t.VehicleTemperatureID == VehicleTemperatureID)));
 }
Exemple #48
0
 private int SwigDirectorInterpret_special(IntPtr tk, ID_Key key, string special)
 {
     return((int)Interpret_special(new BStreamFileToolkit(tk, false), key, special));
 }
 /// <summary></summary>
 private bool ItemExists([FromODataUri] System.Int64 VehicleTemperatureID)
 {
     return(_service.Query(t => t.VehicleTemperatureID == VehicleTemperatureID).Select().Any());
 }
 sf_write_double(IntPtr sndfile,
                 double[] ptr, sf_count_t items);
Exemple #51
0
 public override System.Int64 Seek(System.Int64 offset, System.IO.SeekOrigin origin)
 {
     throw new NotImplementedException();
     //_outStream.Seek(offset, origin);
 }
Exemple #52
0
 public System.Int64 TestIncInt64(System.Int64 arg)
 {
     return(arg + 1);
 }
 sf_read_double(IntPtr sndfile,
                double[] ptr, sf_count_t items);
 sf_write_int(IntPtr sndfile,
              int[] ptr, sf_count_t items);
Exemple #55
0
 /// <summary>
 /// Gets the value of a System Default as an Int64.
 /// </summary>
 /// <param name="ASystemDefaultName">The System Default for which the value should be returned.</param>
 /// <param name="ADefault">The value that should be returned if the System Default was not found.</param>
 /// <remarks><em>Do not inquire the 'SiteKey' System Default with this Method!</em> Rather, always use the
 /// <see cref="GetSiteKeyDefault"/> Method!</remarks>
 /// <returns>The value of the System Default as an Int64, or the value of <paramref name="ADefault" />
 /// if the specified System Default was not found.</returns>
 public static System.Int64 GetInt64Default(String ASystemDefaultName, System.Int64 ADefault)
 {
     return(TRemote.MSysMan.Common.WebConnectors.GetInt64Default(ASystemDefaultName, ADefault));
 }
Exemple #56
0
 public NewMessage()
 {
     id = 0;
 }
Exemple #57
0
        public static bool parse_number(uint8_t *buf, ParsedJson pj, uint32_t offset, bool found_minus)
        {
            bytechar *p        = (bytechar *)(buf + offset);
            bool      negative = false;

            if (found_minus)
            {
                ++p;
                negative = true;
                if (!is_integer(*p))
                {
                    // a negative sign must be followed by an integer

                    return(false);
                }
            }

            bytechar *startdigits = p;

            int64_t i;

            if (*p == '0')
            {
                // 0 cannot be followed by an integer
                ++p;
                if (is_not_structural_or_whitespace_or_exponent_or_decimal((uint8_t)(*p)))
                {
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                i = 0;
            }
            else
            {
                if (!(is_integer(*p)))
                {
                    // must start with an integer
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                unsigned_bytechar digit = (unsigned_bytechar)(*p - '0');
                i = digit;
                p++;
                // the is_made_of_eight_digits_fast routine is unlikely to help here because
                // we rarely see large integer parts like 123456789
                while (is_integer(*p))
                {
                    digit = (unsigned_bytechar)(*p - '0');
                    i     = 10 * i + digit; // might overflow
                    ++p;
                }
            }

            int64_t exponent = 0;

            if ('.' == *p)
            {
                ++p;
                bytechar *firstafterperiod = p;
                if (is_integer(*p))
                {
                    unsigned_bytechar digit = (unsigned_bytechar)(*p - '0');
                    ++p;
                    i = i * 10 + digit;
                }
                else
                {
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }
#if SWAR_NUMBER_PARSING
                // this helps if we have lots of decimals!
                // this turns out to be frequent enough.
                if (is_made_of_eight_digits_fast(p))
                {
                    i  = i * 100000000 + parse_eight_digits_unrolled(p);
                    p += 8;
                    // exponent -= 8;
                }
#endif
                while (is_integer(*p))
                {
                    unsigned_bytechar digit = (unsigned_bytechar)(*p - '0');
                    ++p;
                    i = i * 10 + digit; // in rare cases, this will overflow, but that's ok because we have parse_highprecision_float later.
                }

                exponent = firstafterperiod - p;
            }

            int digitcount = (int)(p - startdigits - 1);

            int64_t expnumber = 0; // exponential part
            if (('e' == *p) || ('E' == *p))
            {
                ++p;
                bool negexp = false;
                if ('-' == *p)
                {
                    negexp = true;
                    ++p;
                }
                else if ('+' == *p)
                {
                    ++p;
                }

                if (!is_integer(*p))
                {
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                unsigned_bytechar digit = (unsigned_bytechar)(*p - '0');
                expnumber = digit;
                p++;
                while (is_integer(*p))
                {
                    digit     = (unsigned_bytechar)(*p - '0');
                    expnumber = 10 * expnumber + digit;
                    ++p;
                }

                if (is_integer(*p))
                {
                    digit     = (unsigned_bytechar)(*p - '0');
                    expnumber = 10 * expnumber + digit;
                    ++p;
                }

                if (is_integer(*p))
                {
                    digit     = (unsigned_bytechar)(*p - '0');
                    expnumber = 10 * expnumber + digit;
                    ++p;
                }

                if (is_integer(*p))
                {
                    // we refuse to parse this
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false);
                }

                exponent += (negexp ? -expnumber : expnumber);
            }

            i = negative ? -i : i;
            if ((exponent != 0) || (expnumber != 0))
            {
                if ((digitcount >= 19))
                {
                    // this is uncommon!!!
                    // this is almost never going to get called!!!
                    // we start anew, going slowly!!!
                    return(parse_float(buf, pj, offset,
                                       found_minus));
                }

                ///////////
                // We want 0.1e1 to be a float.
                //////////
                if (i == 0)
                {
                    pj.WriteTapeDouble(0.0);
#if JSON_TEST_NUMBERS // for unit testing
                    foundFloat(0.0, buf + offset);
#endif
                }
                else
                {
                    if ((exponent > 308) || (exponent < -308))
                    {
                        // we refuse to parse this
#if JSON_TEST_NUMBERS // for unit testing
                        foundInvalidNumber(buf + offset);
#endif
                        return(false);
                    }

                    double d = i;
                    d *= power_of_ten[308 + exponent];
                    // d = negative ? -d : d;
                    pj.WriteTapeDouble(d);
#if JSON_TEST_NUMBERS // for unit testing
                    foundFloat(d, buf + offset);
#endif
                }
            }
            else
            {
                if ((digitcount >= 18))
                {
                    // this is uncommon!!!
                    return(parse_large_integer(buf, pj, offset,
                                               found_minus));
                }

                pj.WriteTapeInt64(i);
#if JSON_TEST_NUMBERS // for unit testing
                foundInteger(i, buf + offset);
#endif
            }

            return(is_structural_or_whitespace((uint8_t)(*p)) != 0);
        }
Exemple #58
0
        // called by parse_number when we know that the output is an integer,
        // but where there might be some integer overflow.
        // we want to catch overflows!
        // Do not call this function directly as it skips some of the checks from
        // parse_number
        //
        // This function will almost never be called!!!
        //
        static bool parse_large_integer(uint8_t *buf, ParsedJson pj, uint32_t offset, bool found_minus)
        {
            bytechar *p        = (bytechar *)(buf + offset);
            bool      negative = false;

            if (found_minus)
            {
                ++p;
                negative = true;
            }

            uint64_t i;

            if (*p == '0')
            {
                // 0 cannot be followed by an integer
                ++p;
                i = 0;
            }
            else
            {
                unsigned_bytechar digit = (unsigned_bytechar)(*p - '0');
                i = digit;
                p++;
                // the is_made_of_eight_digits_fast routine is unlikely to help here because
                // we rarely see large integer parts like 123456789
                while (is_integer(*p))
                {
                    digit = (unsigned_bytechar)(*p - '0');
                    if (mul_overflow(i, 10, &i))
                    {
#if JSON_TEST_NUMBERS // for unit testing
                        foundInvalidNumber(buf + offset);
#endif
                        return(false); // overflow
                    }

                    if (add_overflow(i, digit, &i))
                    {
#if JSON_TEST_NUMBERS // for unit testing
                        foundInvalidNumber(buf + offset);
#endif
                        return(false); // overflow
                    }

                    ++p;
                }
            }

            if (negative)
            {
                if (i > 0x8000000000000000)
                {
                    // overflows!
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false); // overflow
                }
            }
            else
            {
                if (i >= 0x8000000000000000)
                {
                    // overflows!
#if JSON_TEST_NUMBERS // for unit testing
                    foundInvalidNumber(buf + offset);
#endif
                    return(false); // overflow
                }
            }

            int64_t signed_answer = negative ? -(int64_t)i : (int64_t)i;
            pj.WriteTapeInt64(signed_answer);
#if JSON_TEST_NUMBERS // for unit testing
            foundInteger(signed_answer, buf + offset);
#endif
            return(is_structural_or_whitespace((byte)(*p)) != 0);
        }
 sf_write_short(IntPtr sndfile,
                short[] ptr, sf_count_t items);
 /// <summary> CTor</summary>
 /// <param name="eventId">PK value for EventSurveyTemplate which data should be fetched into this EventSurveyTemplate object</param>
 /// <param name="surveyTemplateId">PK value for EventSurveyTemplate which data should be fetched into this EventSurveyTemplate object</param>
 /// <remarks>The entity is not fetched by this constructor. Use a DataAccessAdapter for that.</remarks>
 public EventSurveyTemplateEntity(System.Int64 eventId, System.Int64 surveyTemplateId) : base("EventSurveyTemplateEntity")
 {
     InitClassEmpty(null, CreateFields());
     this.EventId          = eventId;
     this.SurveyTemplateId = surveyTemplateId;
 }