public void ToBinary()
        {
            DateTime d1 = new DateTime(2009, 1, 4);
            var a = d1.ToBinary();
            var b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = new DateTime(2008, 6, 19);
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = new DateTime(2008, 6, 19, 0, 0, 0, DateTimeKind.Utc);
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = DateTime.Now;
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = DateTime.UtcNow;
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);

            d1 = DateTime.Today;
            a = d1.ToBinary();
            b = DateTimeExtensions.ToBinary(d1);
            Assert.AreEqual(a, b);
        }
 /// <summary>
 /// Generates a shared session ID
 /// </summary>
 /// <param name="serverId">The server ID</param>
 /// <param name="sessionId">The session ID</param>
 /// <param name="sessionTimestamp">The session data timestamp</param>
 /// <returns>A well-formated shared session ID</returns>
 public static string GetFullSessionID(string serverId, string sessionId, DateTime sessionTimestamp)
 {
     return String.Format("{0}/{1}/{2}",
         sessionId,
         serverId,
         sessionTimestamp.ToBinary());
 }
Example #3
0
    public void CreateDefaultPref()
    {
        PlayerPrefs.SetInt("GamePlayCount", GamePlayCount);
        PlayerPrefs.SetInt("TotalCoins", GameGlobalVariablesManager.InitCoins);
        PlayerPrefs.SetInt("TotalCrystals", TotalCrystals);
        PlayerPrefs.SetInt("EnergyAvailable", GameGlobalVariablesManager.InitEnergyAvailable);
        PlayerPrefs.SetInt("PlayerLevel", GameGlobalVariablesManager.PlayerLevel);
        PlayerPrefs.SetInt("SwordLevel", GameGlobalVariablesManager.SwordLevel);
        PlayerPrefs.SetInt("ArmorLevel", GameGlobalVariablesManager.ArmorLevel);
        PlayerPrefs.SetInt("KnifeCount", GameGlobalVariablesManager.InitKnifeCount);
        PlayerPrefs.SetInt("BombsCount", GameGlobalVariablesManager.InitBombsCount);
        PlayerPrefs.SetInt("CycloneCount", GameGlobalVariablesManager.InitCycloneCount);
        PlayerPrefs.SetInt("LevelsCleared", GameGlobalVariablesManager.InitLevelsCleared);

        currentDate = System.DateTime.Now;
        LastSavedTime = currentDate.ToBinary().ToString();
        LastDailyBonusTime = LastSavedTime;
        LastEnergyBonusTime = LastSavedTime;
        PlayerPrefs.SetString("LastSavedTime", LastSavedTime);
        PlayerPrefs.SetString("FirstDailyBonusTime", LastSavedTime);
        PlayerPrefs.SetString("LastDailyBonusTime", LastDailyBonusTime);
        PlayerPrefs.SetString("LastEnergyBonusTime", LastEnergyBonusTime);
        PlayerPrefs.SetInt("DayCount", DayCount);

        PlayerPrefs.Save();
    }
        public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            var connection = GetConnection();
            var min = (double)userInactiveSinceDate.ToBinary();
            const double max = double.MaxValue;
            var key = string.Empty;
            switch (authenticationOption)
            {
                case ProfileAuthenticationOption.All:
                    key = GetProfilesKey();
                    break;
                case ProfileAuthenticationOption.Anonymous:
                    key = GetProfilesKeyAnonymous();
                    break;
                case ProfileAuthenticationOption.Authenticated:
                    key = GetProfilesKeyAuthenticated();
                    break;
            }

            var inactiveUsersTask = connection.SortedSets.Range(_redisDb, key, min, max);
            var inactiveUsers = connection.Wait(inactiveUsersTask);
            var count = 0;

            Parallel.ForEach(inactiveUsers, result =>
            {
                var profileResult = new string(Encoding.Unicode.GetChars(result.Key));
                var parts = profileResult.Split(':');
                var username = parts[0];
                var isAuthenticated = Convert.ToBoolean(parts[1]);
                if (DeleteProfile(username, isAuthenticated))
                    Interlocked.Increment(ref count);
            });

            return count;
        }
 public static VerificationToken Generate(DateTime timestamp)
 {
     var data = new byte[DataLength];
     new RNGCryptoServiceProvider().GetBytes(data);
     Array.Copy(BitConverter.GetBytes(timestamp.ToBinary()), data, sizeof(long));
     return new VerificationToken(data);
 }
Example #6
0
        /// <summary>
        /// Creates a new timespan definition
        /// </summary>
        /// <param name="myFrom">The point in time where the timespan begins</param>
        /// <param name="myTo">The point in time where the timespan ends</param>
        public TimeSpanDefinition(DateTime myFrom, DateTime myTo)
        {
            From = myFrom;
            _fromConverted = From.ToBinary();

            To = myTo;
            _toConverted = To.ToBinary();
        }
        static string LogPath(string appPath, DateTime now)
        {
            if (string.IsNullOrEmpty(appPath)) throw new ArgumentNullException("appPath");

            var logPath = Path.GetFullPath(Path.Combine(appPath, @"..\Private\Logs\Exceptions\", now.ToString("yy-MM-dd")));
            Directory.CreateDirectory(logPath);
            return Path.Combine(logPath, now.ToBinary() + ".xml");
        }
Example #8
0
 void IArchByteBoxWriter.wDateTime(DateTime DT, bool isBinary)
 {
     byte[] @Byte = null;
     if (isBinary)
         @Byte = BitConverter.GetBytes(DT.ToBinary());
     else
         @Byte = BitConverter.GetBytes(DT.Ticks);
     nMStream.Write(@Byte, 0, @Byte.Length);
 }
		protected void CheckThrowDatePriorToLast(DateTime appending) {
			if (this.DateTimes.Count == 0) return;
			DateTime lastDateTime = this.LastStaticDate;
			if (lastDateTime.ToBinary() < appending.ToBinary()) return;

			string msg = "#3 Can not append time[" + appending + "] should be > this.Date["
				+ (this.DateTimes.Count - 1) + "]=[" + lastDateTime + "]";
			throw new Exception(msg);
		}
Example #10
0
        public static string MakeETag(string UID, DateTime pLastModified)
        {
            byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(UID + "/" + pLastModified.ToBinary()));

            StringBuilder pendingETag = new StringBuilder();
            for (int i = 0; i < hash.Length; ++i)
                pendingETag.Append(hash[i].ToString("X2"));

            return "\"" + pendingETag.ToString() + "\"";
        }
Example #11
0
 public static int Write(BinaryWriter writer, DateTime dateTime, int tick, string component, string thread, string message)
 {
     writer.Write(dateTime.ToBinary());
     writer.Write(tick);
     writer.Write(component);
     writer.Write(thread);
     writer.Write(message);
     writer.Flush();
     return (int)writer.BaseStream.Position;
 }
Example #12
0
        public static int Write(BinaryWriter writer, DateTime dateTime, TraceEventType eventType, int tick,
			LogComponent component, string thread, string header, string message)
        {
            writer.Write(dateTime.ToBinary());
            writer.Write((int)eventType);
            writer.Write(tick);
            writer.Write((byte)component);
            writer.Write(thread);
            writer.Write(header);
            writer.Write(message);
            writer.Flush();
            return (int)writer.BaseStream.Position;
        }
Example #13
0
        public DataAddress[] GetHistoricalPathRoots(IServiceAddress root, string pathName, DateTime time, int maxCount)
        {
            InspectNetwork();

            // Check machine is in the schema,
            MachineProfile machine = CheckMachineInNetwork(root);
            // Check it's root,
            if (!machine.IsRoot)
                throw new NetworkAdminException("Machine '" + root + "' is not a root");

            // Perform the command,
            RequestMessage request = new RequestMessage("getPathHistorical");
            request.Arguments.Add(pathName);
            request.Arguments.Add(time.ToBinary());
            request.Arguments.Add(time.ToBinary());

            ResponseMessage m = (ResponseMessage) Command(root, ServiceType.Root, request);
            if (m.HasError)
                throw new NetworkAdminException(m.ErrorMessage);

            // Return the data address array,
            return (DataAddress[])m.ReturnValue;
        }
Example #14
0
 public bool Send(int udpPort, string strType, string strSend, DateTime timeStamp)
 {
   if (socket == null)
     socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
   try
   {
     byte[] sendbuf = Encoding.UTF8.GetBytes(string.Format("{0}|{1}|{2}~", strType, strSend, timeStamp.ToBinary()));
     IPEndPoint endPoint = new IPEndPoint(hostIP, udpPort);
     socket.SendTo(sendbuf, endPoint);
     return true;
   }
   catch (SocketException se)
   {
     Log.Info("UDPHelper: Send port {0}: {1} - {2}", udpPort, se.ErrorCode, se.Message);
     return false;
   }
 }
Example #15
0
 /// <summary>
 /// Write message to a file
 /// </summary>
 /// <param name="text"></param>
 /// <param name="InputStyle"></param>
 /// <param name="owner"></param>
 /// <param name="directory"></param>
 /// <param name="time"></param>
 public static void Log(string text, Client.ContentLine.MessageStyle InputStyle, Graphics.Window owner, string directory, DateTime time)
 {
     try
     {
         if (!Directory.Exists(Configuration.Logs.logs_dir))
         {
             Directory.CreateDirectory(Configuration.Logs.logs_dir);
         }
         if (!Directory.Exists(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName))
         {
             System.IO.Directory.CreateDirectory(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName);
         }
         if (!Directory.Exists(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName + Path.DirectorySeparatorChar + validpath(owner, directory)))
         {
             Directory.CreateDirectory(Configuration.Logs.logs_dir + Path.DirectorySeparatorChar + owner._Network.ServerName + Path.DirectorySeparatorChar + validpath(owner, directory));
         }
         if (Configuration.Logs.logs_txt)
         {
             string stamp = "";
             if (Configuration.Scrollback.chat_timestamp)
             {
                 stamp = Configuration.Scrollback.format_date.Replace("$1", time.ToString(Configuration.Scrollback.timestamp_mask));
             }
             Core.IO.InsertText(stamp + Protocol.DecodeText(Core.RemoveSpecial(text)) + "\n", _getFileName(owner, directory, time) + ".txt");
         }
         if (Configuration.Logs.logs_html)
         {
             string stamp = "";
             if (Configuration.Scrollback.chat_timestamp)
             {
                 stamp = Configuration.Scrollback.format_date.Replace("$1", time.ToString(Configuration.Scrollback.timestamp_mask));
             }
             Core.IO.InsertText("<font size=\"" + Configuration.CurrentSkin.FontSize.ToString() + "px\" face=" + Configuration.CurrentSkin.LocalFont + ">" + System.Web.HttpUtility.HtmlEncode(stamp + Protocol.DecodeText(Core.RemoveSpecial(text))) + "</font><br>\n", _getFileName(owner, directory, time) + ".html");
         }
         if (Configuration.Logs.logs_xml)
         {
             Core.IO.InsertText("<line time=\"" + time.ToBinary().ToString() + "\" style=\"" + InputStyle.ToString() + "\">" + System.Web.HttpUtility.HtmlEncode(Protocol.DecodeText(Core.RemoveSpecial(text))) + "</line>\n", _getFileName(owner, directory, time) + ".xml");
         }
     }
     catch (Exception fail)
     {
         Core.handleException(fail);
     }
 }
Example #16
0
        public string TransformToJavaScript(Stream source, DateTime lastModified, string resourcePath)
        {
            //Compute Cache Key

            var timestamp = lastModified.ToBinary();
            var cacheKey = timestamp.ToString() + resourcePath;

            if (!Cache.Exists(cacheKey)) {
                Logger.Debug(String.Format("Inserting cache entry for {0}", cacheKey));

                var css = Underlying.TransformToJavaScript(source, lastModified, resourcePath);
                var dependancies = new[] { resourcePath };

                Cache.Insert(cacheKey, dependancies, css);

                return css;
            }
            Logger.Debug(String.Format("Retrieving cache entry {0}", cacheKey));
            return Cache.Retrieve(cacheKey);
        }
Example #17
0
		private string GetFutureAccessToken(DateTime expiresOn, int numberOfDays, string user)
		{
			using (var aes = new AesManaged())
			{
				aes.Padding = PaddingMode.PKCS7;

				if (string.IsNullOrWhiteSpace(BlogConfig.FuturePostsEncryptionKey))
				{
					// Setting the encryption key will invalidate the previous generated links,
					// but here it is null anyway, to this is not a problem.
					BlogConfig.FuturePostsEncryptionKey = Convert.ToBase64String(aes.Key);
				}
				else
					aes.Key = Convert.FromBase64String("cxL93ropkZOh5aY+ghhUw+tVVs4/CmhtCCQqUeG4po4=");

				using (var memoryStream = new MemoryStream())
				{
					using (var cryptoStream = new CryptoStream(memoryStream, aes.CreateEncryptor(), CryptoStreamMode.Write))
					{
						using (var writer = new BinaryWriter(cryptoStream))
						{
							writer.Write(expiresOn.ToBinary());
							writer.Write(numberOfDays);
							writer.Write(user);
							writer.Flush();
						}
						cryptoStream.Flush();
					}
					var encrypted = memoryStream.ToArray();
					var iv = aes.IV;

					var result = new byte[iv.Length + encrypted.Length];
					iv.CopyTo(result, 0);
					encrypted.CopyTo(result, iv.Length);

					return Convert.ToBase64String(result);
				}
			}
		}
Example #18
0
 public static void WriteSimplely(this ProtoWriter protoWriter, DateTime value)
 {
     protoWriter.WriteSimplely(value.ToBinary());
 }
Example #19
0
        public void Send(Endpoint endpoint, DateTime processAgainAt, object[] msgs)
        {
            if (HaveStarted == false)
                throw new InvalidOperationException("Cannot send a message before transport is started");

            var message = GenerateMsmqMessageFromMessageBatch(msgs);
            var bytes = new List<byte>(message.Extension);
            bytes.AddRange(BitConverter.GetBytes(processAgainAt.ToBinary()));
            message.Extension = bytes.ToArray();
            message.AppSpecific = (int)MessageType.TimeoutMessageMarker;

            SendMessageToQueue(message, endpoint);
        }
Example #20
0
        private CacheInfo TrySaveToDisk(XmlDocument doc, string url, DateTime utcExpiry)
        {
            string fileName = null;

            if (_directoryOnDisk != null)
            {
                XmlComment comment = doc.CreateComment(string.Format(CultureInfo.InvariantCulture, "{0}@{1}", utcExpiry.ToBinary(), url));
                doc.InsertBefore(comment, doc.DocumentElement);

                fileName = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}_{1:x8}.feed",
                    GetTempFileNamePrefixFromUrl(url),
                    Guid.NewGuid().GetHashCode());

                try
                {
                    doc.Save(Path.Combine(_directoryOnDisk, fileName));
                }
                catch
                {
                    // can't save to disk - not a problem
                    fileName = null;
                }
            }

            return new CacheInfo(doc, utcExpiry, fileName);
        }
Example #21
0
 private void SlabsListLoading(object sender, DoWorkEventArgs e)
 {
     try {
         var currentDate = new DateTime(dateTimeFrom.Value.Date.Ticks, DateTimeKind.Local);
         var from = currentDate.ToBinary();
         var to = currentDate.AddDays(1).ToBinary();
         slabsList.Slabs = client.GetSlabInfosByTimeInterval(from, to);
         if (slabsList.StandartSizes == null) {
             slabsList.StandartSizes = client.GetStandartSizes();
         }
         if (slabsList.Regulations == null) {
             slabsList.Regulations = client.GetRegulations();
         }
     }
     catch (Exception ex) {
         MessageBox.Show(@"Ошибка при обновлении информации: " + ex.Message);
         lock (slabsList) {
             slabsList.Slabs = null;
             slabsList.Regulations = null;
         }
         if (client != null && client.IsConnected) {
             client.Disconnect();
         }
     }
 }
 public void Append(DateTime value)
 {
     var binary = value.ToBinary();
     Writer.Write(binary);
 }
 public void SetTime(DateTime time)
 {
     Interlocked.Exchange(ref lastHit, time.ToBinary());
 }
        void LeeSeisanUno()
        {
            int i,iii,j,jj,k,kk,kkk,nucan=0,fin=0;
            int totbyt,adicion=0,nuletra,vacio,cuvacio;
            int an2, me2, di2, ho2, mi2, se2, ms2, nuto;
            double seg,dt;
            int traslapo, inicio;
            int largo, lara;
            long ll0, ll;
            double tinicio=0,tifinal=0,tie,facra,dd1,dd2,dd;

            byte[] bit2 = new byte[2];
            byte[] bit4 = new byte[4];
            byte[] byy = new byte[1000];

            short[] tipbyte = new short[1];
            int[] numu = new int[1]; ;
            short[] bby=new short[1];
            int[][] cuu=new int[1][];
            char[][] cc;
            double[] tii=new double[1];
            double[] rat = new double[1]; ;
            string[] esta = new string[1]; ;
            string[] estt = new string[Ma];
            char[] compo = new char[1];
            int[] cus;
            double[] tims;

            bool si;
            string nom, ca, ca2;

            nom = listBox1.SelectedItem.ToString();
            if (!File.Exists(nom)) return;

            try
            {
                FileInfo ar = new FileInfo(nom);
                BinaryReader br0 = new BinaryReader(ar.OpenRead());
                while (br0.PeekChar() != -1)
                {
                    br0.ReadBytes(34);
                    ca = Encoding.ASCII.GetString(br0.ReadBytes(3));
                    nucan = int.Parse(ca.Substring(0, 3));
                    numu = new int[nucan];
                    tipbyte = new short[nucan];
                    if (nucan > 12) fin = nucan;
                    else fin = 12;
                    br0.ReadBytes(143);
                    do
                    {
                        ca = Encoding.ASCII.GetString(br0.ReadBytes(88));
                        if (char.IsLetter(ca[0])) break;
                    } while (!char.IsLetter(ca[0]));

                    for (jj = 0; jj < nucan; jj++)
                    {
                        numu[jj] = int.Parse(ca.Substring(43, 7));
                        if (ca[76] == '4') tipbyte[jj] = 4;
                        else tipbyte[jj] = 2;
                        try
                        {
                            br0.ReadBytes(960);
                        }
                        catch
                        {
                        }
                        totbyt = numu[jj] * tipbyte[jj];
                        br0.ReadBytes(totbyt);
                        if (jj == nucan - 1) break;
                        br0.ReadBytes(8);
                        ca = Encoding.ASCII.GetString(br0.ReadBytes(88));
                        //le = ca.Substring(0, 6);
                    }
                    break;// provi
                }// while
                br0.Close();

                cuu = new int[nucan][];
                cc = new char[nucan][];
                for (iii = 0; iii < nucan; iii++)
                {
                    cuu[iii] = new int[numu[iii]];
                    cc[iii] = new char[3];
                }
                tii = new double[nucan];
                rat = new double[nucan];
                esta = new string[nucan];
                compo = new char[nucan];
                bby = new short[nucan];

                BinaryReader br = new BinaryReader(ar.OpenRead());

                try
                {
                    br.ReadBytes(1060);
                    if (fin > 30)
                    {
                        adicion = 88 * (int)(Math.Ceiling((fin - 30.0) / 3.0));
                        br.ReadBytes(adicion);
                    }
                }
                catch
                {
                }

                for (iii = 0; iii < nucan; iii++)
                {
                    ca2 = Encoding.ASCII.GetString(br.ReadBytes(88));
                    if (char.IsLetter(ca2[8])) nuletra = 8;
                    else nuletra = 7;
                    esta[iii] = ca2.Substring(0, 3) + ca2.Substring(nuletra, 1);
                    if (ca2[8] == 'N') compo[iii] = 'n';
                    else if (ca2[8] == 'E') compo[iii] = 'e';
                    else compo[iii] = 'z';
                    an2 = int.Parse(ca2.Substring(10, 2));
                    if (ca2[9] == '1') an2 += 2000;
                    else an2 += 1900;
                    me2 = int.Parse(ca2.Substring(17, 2));
                    di2 = int.Parse(ca2.Substring(20, 2));
                    ho2 = int.Parse(ca2.Substring(23, 2));
                    mi2 = int.Parse(ca2.Substring(26, 2));
                    seg = double.Parse(ca2.Substring(29, 6));
                    se2 = (int)(seg);
                    ms2 = (int)((double)(seg - se2) * 1000.0);
                    DateTime fee1 = new DateTime(an2, me2, di2, ho2, mi2, se2, ms2);
                    ll = fee1.ToBinary();
                    tii[iii] = ((double)(ll)-Feisuds)/10000000.0+UTdisp*3600.0;
                    if (tinicio == 0) tinicio=tii[iii];
                    else if (tinicio > tii[iii]) tinicio = tii[iii];
                    rat[iii] = double.Parse(ca2.Substring(36,6));
                    if (rat[iii] <= 0)
                    {
                        MessageBox.Show("Rata de muestreo <= 0??");
                        br.Close();
                        return;
                    }
                    dt = 1.0/rat[iii];
                    dd = tii[iii] + numu[iii] * dt;
                    if (tifinal < dd) tifinal = dd;

                    bby[iii] = tipbyte[iii];
                    try
                    {
                        br.ReadBytes(960);
                    }
                    catch
                    {
                    }
                    if (tipbyte[iii] == 4)
                    {
                        for (kkk = 0; kkk < numu[iii]; kkk++)
                            cuu[iii][kkk] = br.ReadInt32();
                    }
                    else
                    {
                        for (kkk = 0; kkk < numu[iii]; kkk++)
                            cuu[iii][kkk] = (int)(br.ReadInt16());
                    }
                    br.ReadBytes(8);
                }// for iii

                br.Close();
            }//try
            catch
            {
                NoMostrar = true;
                MessageBox.Show("*** ERROR!! ( quizas mas de 30 estaciones?? )");
            }

            nuto = 0;
            si = false;
            for (j = 0; j < nucan; j++)
            {
                if (nuto > 0)
                {
                    for (k = 0; k < nuto; k++)
                    {
                        if (string.Compare(estt[k].Substring(0,4),esta[j].Substring(0,4)) == 0 || esta[j].Substring(0, 4) == "XXXX")
                        {
                            si = true;
                            break;
                        }
                    }
                }
                if (si == false)
                {
                    estt[nuto] = esta[j];
                    ga[nutra + nuto] = 1;
                    comp[nutra + nuto] = compo[j];
                    nuto += 1;
                }
                else si = false;
            }

            // aqui se van a asignar los datos a cada estacion sucesivamente.
            for (iii = 0; iii < nuto; iii++)
            {
                lara = 0;
                tie = 0;
                facra = 0;
                vacio = 0;
                traslapo = 0;
                dd2 = 0;

                for (j = 0; j < nucan; j++)
                {
                    if (estt[iii].Substring(0, 4) == esta[j].Substring(0, 4))
                    {
                        if (lara > 0)
                        {
                            dd1 = tii[j];
                            if (dd1 - dd2 > (facra + 0.005) && dd2 > 0)
                            {
                                siRoto[nutra] = true;
                                vacio += (int)((dd1 - dd2) * rat[j]);
                            }
                            else if (dd2 - dd1 > (facra + 0.005) && dd2 > 0)
                            {
                                siTraslapo[nutra] = true;
                                traslapo += (int)((dd2 - dd1) * rat[j]);
                            }
                        }
                        lara += cuu[j].Length;
                        facra = 1.0 / (rat[j]);
                        dd2 = tii[j] + facra * cuu[j].Length;
                        break;
                    }
                }
                //}// for i....

                if (lara > 0)
                {
                    lara += vacio;
                    lara -= traslapo;
                    si = false;
                    /*if (listasei.Count > 0)
                    {
                        for (jj = 0; jj < listasei.Count; jj++)
                        {
                            if (listasei[jj].ToString().Substring(0, 4) == estt[iii].Substring(0, 4))
                            {
                                est[nutra] = listasei[jj].ToString().Substring(5, 4) + " ";
                                si = true;
                                break;
                            }
                        }
                    }*/
                    if (si == false) est[nutra] = estt[iii].Substring(0, 4) + " ";
                    cus = new int[lara];
                    tims = new double[lara];
                    siEst[nutra] = true;
                    tar[nutra] = tardis;
                    //by[nutra] = bby[0][0];// se supone que es multiplexado y todos los datos tienen la misma caracteristica (rata, tipodato, etc!!

                    jj = 0;
                    dd2 = 0;
                    cuvacio = 0;
                    for (j = 0; j < nucan; j++)
                    {
                        //MessageBox.Show(" j=" + j.ToString() + " estt=" + estt[iii] + "esta=" + esta[j]);
                        if (estt[iii].Substring(0, 4) == esta[j].Substring(0, 4))
                        {
                            ra[nutra] = rat[j];// se puede mejorar!!
                            by[nutra] = bby[j];
                            tie = tii[j];
                            facra = 1.0 / (rat[j]);
                            inicio = 0;
                            if (tie - dd2 > (facra + 0.005) && dd2 > 0)
                            {
                                vacio = (int)((tie - dd2) * rat[j]);
                                dd2 += facra;
                                for (kk = 0; kk < vacio; kk++)
                                {
                                    tims[jj] = dd2 + kk * facra;
                                    cus[jj] = cuvacio;
                                    jj += 1;
                                }
                            }
                            else if (dd2 - tie > (facra + 0.005) && dd2 > 0)
                            {
                                traslapo = (int)((dd2 - tie) * rat[j]);
                                inicio = traslapo;
                            }
                            for (kk = inicio; kk < cuu[j].Length; kk++)
                            {
                                tims[jj] = tie + kk * facra;
                                cus[jj] = cuu[j][kk];
                                jj += 1;
                            }
                            facra = 1.0 / (rat[j]);
                            dd2 = tii[j] + facra * cuu[j].Length;
                            cuvacio = cus[jj - 1];
                            break;
                        }
                    }

                    inicio = (int)((tinicio - tims[0]) * ra[nutra]);
                    if (inicio < 0) inicio = 0;
                    if (tims[lara - 1] - tifinal < 0) fin = lara;
                    else fin = (int)(lara - ((tims[lara - 1] - tifinal) * ra[nutra]));
                    //MessageBox.Show("inicio="+inicio.ToString()+" fin="+fin.ToString());
                    if (inicio >= fin) continue;
                    i = fin - inicio;
                    tim[nutra] = new double[i];
                    cu[nutra] = new int[i];
                    kk = 0;
                    for (j = inicio; j < fin; j++)
                    {
                        cu[nutra][kk] = cus[j];
                        tim[nutra][kk++] = tims[j];
                    }
                    nutra += 1;
                } // if lara>0
            }

            return;
        }
        void LeeSeisan()
        {
            //   Rutina que lee el formato SEISAN. La variable con los datos de cuentas, es tridimensional, donde primero se le asigna el numero
            //   de archivo, luego el numero de bloque en el archivo y por ultimo los datos de las cuentas. La
            //   mayoria de las demas variables son bidimensionales, donde se les asigna primero el numero de archivo
            //   y el valor de acuerdo al numero de bloque.

            short[][] bby;
            int[][][] cuu;
            char[][][] cc;
            double[][] tii;
            double[][] rat;
            string[][] esta;
            string[] estt = new string[Ma];
            char[][] compo;
            short[] tipbyte;
            int[] cus;
            double[] tims;

            byte[] bit2 = new byte[2];
            byte[] bit4 = new byte[4];
            byte[] byy = new byte[1000];
            ushort num, cont, cont2, nuarch = 0, arch;
            short nulis, ide, nuseis;
            int i,ii,iii,j,k,kk,kkk,an,me,di,ho,mi,vacio,cuvacio;
            int an2, me2, di2, ho2, mi2, se2, ms2, nuto, nuletra;
            int adicion=0;
            double seg;
            int traslapo,inicio,jj,fin=0,totbyt=0;
            int largo, lara;
            long ll0, ll;
            double tinicio, tifinal, tie, facra, dd1, dd2;
            string li = "", lis = "", nom = "", ca = "", ca2 = "", le = "";
            bool si = false;

            int[] uts, durs, pos, numu, canal;
            char[] tars;
            string[] nomcarp, nomext;
            char[] delim = { ' ', '\t' };
            string[] pa = null;
            bool[] sian, sime, sidi, siho, simi, UNIX;
            string nomarch = "", nomini = "";
            ArrayList listasei = new ArrayList();

            if (cajseis == false) return;
            if (File.Exists(".\\pro\\estaseisan.txt"))
            {
                StreamReader arsei = new StreamReader(".\\pro\\estaseisan.txt");
                while (li != null)
                {
                    try
                    {
                        li = arsei.ReadLine();
                        if (li == null) break;
                        if (char.IsLetterOrDigit(li[0]) && li.Length >= 9) listasei.Add(li);
                    }
                    catch
                    {
                        break;
                    }
                }
                arsei.Close();
            }
            li = "";
            nomarch = ".\\pro\\" + archseis;
            if (!File.Exists(nomarch))
            {
                NoMostrar = true;
                MessageBox.Show("NO EXISTE en PRO el archivo con los datos de las trazas en SEISAN!!");
                return;
            }
            nuseis = 0;
            StreamReader ar2 = new StreamReader(nomarch);
            while (li != null)
            {
                try
                {
                    li = ar2.ReadLine();
                    if (li == null || li[0] == '*') break;
                    nuseis += 1;
                }
                catch
                {
                    break;
                }
            }
            ar2.Close();
            if (nuseis == 0)
            {
                NoMostrar = true;
                MessageBox.Show("Archivo SEISAN vacio?");
                return;
            }
            uts = new int[nuseis];
            durs = new int[nuseis];
            tars = new char[nuseis];
            nomcarp = new string[nuseis];
            nomext = new string[nuseis];
            sian = new bool[nuseis];
            sime = new bool[nuseis];
            sidi = new bool[nuseis];
            siho = new bool[nuseis];
            simi = new bool[nuseis];
            UNIX = new bool[nuseis];
            for (i = 0; i < nuseis; i++) UNIX[i] = false;
            li = "";
            i = 0;
            StreamReader arg = new StreamReader(nomarch);
            while (li != null)
            {
                try
                {
                    li = arg.ReadLine();
                    if (li == null || li[0] == '*') break;
                    pa = li.Split(delim);
                    largo = pa.Length;
                    if (largo >= 6)
                    {
                        sian[i] = false;
                        sime[i] = false;
                        sidi[i] = false;
                        nomcarp[i] = pa[0];
                        if (pa[1][0] == 'A') sian[i] = true;
                        if (pa[1][1] == 'M') sime[i] = true;
                        if (pa[1][2] == 'D') sidi[i] = true;
                        tars[i] = pa[2][0];
                        uts[i] = 3600 * int.Parse(pa[3]);
                        durs[i] = int.Parse(pa[4]);
                        nomext[i] = pa[5];
                        if (largo == 7)
                        {
                            if (pa[6] == "UNIX") UNIX[i] = true;
                        }
                        i += 1;
                    }
                    else
                    {
                        NoMostrar = true;
                        MessageBox.Show("Revise " + nomarch + ". Tal vez hay espacios adicionales??");
                    }
                }
                catch
                {
                    break;
                }
            }
            arg.Close();

            tinicio = 0;
            // nuseis, guarda el numero de estaciones o carpetas de los archivos SEISAN.
            for (ii = 0; ii < nuseis; ii++)
            {
                //i = (ushort)(1 + (totven * 60.0) / durs[ii]);
                cont = 0;
                lis = listBox1.SelectedItem.ToString();
                nulis = (short)(listBox1.SelectedIndex);
                num = (ushort)(durs[ii] / 60.0);
                an = int.Parse(lis.Substring(0, 2));
                if (an < 88) an += 2000;
                else an += 1900;
                me = int.Parse(lis.Substring(3, 2));
                di = int.Parse(lis.Substring(6, 2));
                ho = int.Parse(lis.Substring(9, 2));
                mi = int.Parse(lis.Substring(12, 2));
                DateTime fech1 = new DateTime(an, me, di, ho, mi, 0);
                ll0 = fech1.Ticks;
                tinicio = ((double)(ll0) - Feisuds) / 10000000.0;
                tifinal = tinicio + totven * 60.0;
                if (uts[ii] != 0) ll0 -= (long)(uts[ii] * 10000000.0);

                for (i = 0; i <= num; i++)
                {
                    DateTime fech2 = new DateTime(ll0);
                    ca = nomcarp[ii];
                    if (sian[ii] == true) ca += "\\" + string.Format("{0:yyyy}", fech2);
                    if (sime[ii] == true) ca += "\\" + string.Format("{0:MM}", fech2);
                    if (sidi[ii] == true) ca += "\\" + string.Format("{0:dd}", fech2);
                    if (!Directory.Exists(ca)) continue;
                    DirectoryInfo dir = new DirectoryInfo(ca);
                    le = "*." + nomext[ii];
                    FileInfo[] nn = dir.GetFiles(le);
                    le = string.Format("{0:yyyy}-{0:MM}-{0:dd}-{0:HH}{0:mm}", fech2);
                    nom = "\0";
                    for (jj = 0; jj < nn.Length; jj++)
                    {
                        if (string.Compare(nn[jj].Name.Substring(0, 15), le.Substring(0, 15)) == 0)
                        {
                            nom = ca += "\\" + nn[jj].Name;
                            break;
                        }
                    }
                    if (File.Exists(nom))
                    {
                        //MessageBox.Show("SI EXISTE!!!");
                        si = true;
                        break;
                    }
                    //else MessageBox.Show(" ca="+ca+" le="+le+" largo="+nn.Length.ToString()+"\nnom="+nom);
                    ll0 -= 600000000;
                    nulis -= 1;
                }
                if (si == false)
                {
                    NoMostrar = true;
                    MessageBox.Show("No hay Sismos SEISAN " + (ii + 1).ToString() + " !!!");
                    // return;
                }
                else
                {
                    panel2.Visible = true;
                    j = (ushort)(ii + 1);
                    ca = "Adquiriendo Trazas\n    SEISAN   " + j.ToString();
                    util.Mensaje(panel2, ca, false);
                    ide = nulis;
                    if (ide < 0) continue;
                    nuarch = 0;
                    nomini = nom;
                    do
                    {
                        if (File.Exists(nom)) nuarch += 1;
                        ide += 1;
                        if (ide == listBox1.Items.Count || ide < 0) break;
                        lis = listBox1.Items[ide].ToString();
                        an = int.Parse(lis.Substring(0, 2));
                        if (an < 88) an += 2000;
                        else an += 1900;
                        me = int.Parse(lis.Substring(3, 2));
                        di = int.Parse(lis.Substring(6, 2));
                        ho = int.Parse(lis.Substring(9, 2));
                        mi = int.Parse(lis.Substring(12, 2));
                        DateTime fech3 = new DateTime(an, me, di, ho, mi, 0);
                        ll0 = fech3.Ticks;
                        if (uts[ii] != 0) ll0 -= ((long)(uts[ii] * 10000000.0));
                        DateTime fech4 = new DateTime(ll0);
                        ca = nomcarp[ii];
                        if (sian[ii] == true) ca += "\\" + string.Format("{0:yyyy}", fech4);
                        if (sime[ii] == true) ca += "\\" + string.Format("{0:MM}", fech4);
                        if (sidi[ii] == true) ca += "\\" + string.Format("{0:dd}", fech4);
                        DirectoryInfo dir = new DirectoryInfo(ca);
                        le = "*." + nomext[ii];
                        FileInfo[] nn = dir.GetFiles(le);
                        le = string.Format("{0:yyyy}-{0:MM}-{0:dd}-{0:HH}{0:mm}", fech4);
                        nom = "\0";
                        for (jj = 0; jj < nn.Length; jj++)
                        {
                            if (string.Compare(nn[jj].Name.Substring(0, 15), le.Substring(0, 15)) == 0)
                            {
                                nom = ca += "\\" + nn[jj].Name;
                                break;
                            }
                        }

                        cont += 1;
                        if (cont > totven) break;
                    } while (ide < listBox1.Items.Count);

                    ide = nulis;
                    nom = nomini;
                    cont2 = 0;
                    arch = 0;
                    cuu = new int[nuarch][][];
                    cc = new char[nuarch][][];
                    tii = new double[nuarch][];
                    rat = new double[nuarch][];
                    esta = new string[nuarch][];
                    compo = new char[nuarch][];
                    bby = new short[nuarch][];
                    numu = new int[1];
                    pos = new int[1];
                    tipbyte = new short[1];
                    canal = new int[nuarch];

                    do
                    {
                        if (File.Exists(nom))
                        {
                            try
                            {
                                FileInfo ar = new FileInfo(nom);
                                BinaryReader br0 = new BinaryReader(ar.OpenRead());
                                while (br0.PeekChar() != -1)
                                {
                                    br0.ReadBytes(34);
                                    //br0.ReadBytes(32); // reftek
                                    ca = Encoding.ASCII.GetString(br0.ReadBytes(3));
                                    canal[arch] = int.Parse(ca.Substring(0,3));
                                    numu = new int[canal[arch]];
                                    tipbyte = new short[canal[arch]];
                                    if (canal[arch] > 12) fin = canal[arch];
                                    else fin = 12;
                                    br0.ReadBytes(143);
                                    do
                                    {
                                        ca = Encoding.ASCII.GetString(br0.ReadBytes(88));
                                        if (char.IsLetter(ca[0])) break;
                                    } while (!char.IsLetter(ca[0]));

                                    for (jj = 0; jj < canal[arch]; jj++)
                                    {
                                        numu[jj] = int.Parse(ca.Substring(43, 7));
                                        if (ca[76] == '4') tipbyte[jj] = 4;
                                        else tipbyte[jj] = 2;
                                        try
                                        {
                                            br0.ReadBytes(960);
                                        }
                                        catch
                                        {
                                        }
                                        totbyt = numu[jj] * tipbyte[jj];
                                        br0.ReadBytes(totbyt);
                                        if (jj == canal[arch] - 1) break;
                                        br0.ReadBytes(8);
                                        ca = Encoding.ASCII.GetString(br0.ReadBytes(88));
                                        le = ca.Substring(0, 6);
                                    }
                                    break;// provi
                                }// while
                                br0.Close();

                                cuu[arch] = new int[canal[arch]][];
                                cc[arch] = new char[canal[arch]][];
                                for (iii = 0; iii < canal[arch]; iii++)
                                {
                                    cuu[arch][iii] = new int[numu[iii]];
                                    cc[arch][iii] = new char[3];
                                }
                                tii[arch] = new double[canal[arch]];
                                rat[arch] = new double[canal[arch]];
                                esta[arch] = new string[canal[arch]];
                                compo[arch] = new char[canal[arch]];
                                bby[arch] = new short[canal[arch]];

                                BinaryReader br = new BinaryReader(ar.OpenRead());

                                try
                                {
                                    br.ReadBytes(1060);
                                    if (fin > 30)
                                    {
                                        adicion = 88*(int)(Math.Ceiling((fin-30.0)/3.0));
                                        br.ReadBytes(adicion);
                                    }
                                }
                                catch
                                {
                                }

                                for (iii = 0; iii < canal[arch]; iii++)
                                {
                                    ca2 = Encoding.ASCII.GetString(br.ReadBytes(88));
                                    if (char.IsLetter(ca2[8])) nuletra = 8;
                                    else nuletra = 7;
                                    esta[arch][iii] = ca2.Substring(0,3)+ca2.Substring(nuletra,1);
                                    if (ca2[8] == 'N') compo[arch][iii] = 'n';
                                    else if (ca2[8] == 'E') compo[arch][iii] = 'e';
                                    else compo[arch][iii] = 'z';
                                    an2 = int.Parse(ca2.Substring(10, 2));
                                    if (ca2[9] == '1') an2 += 2000;
                                    else an2 += 1900;
                                    me2 = int.Parse(ca2.Substring(17, 2));
                                    di2 = int.Parse(ca2.Substring(20, 2));
                                    ho2 = int.Parse(ca2.Substring(23, 2));
                                    mi2 = int.Parse(ca2.Substring(26, 2));
                                    seg = double.Parse(ca2.Substring(29, 6));
                                    se2 = (int)(seg);
                                    ms2 = (int)((double)(seg - se2) * 1000.0);
                                    DateTime fee1 = new DateTime(an2, me2, di2, ho2, mi2, se2, ms2);
                                    ll = fee1.ToBinary();
                                    tii[arch][iii] = ((double)(ll) - Feisuds) / 10000000.0;
                                    rat[arch][iii] = double.Parse(ca2.Substring(36, 6));
                                    bby[arch][iii] = tipbyte[iii];
                                    try
                                    {
                                        br.ReadBytes(960);
                                    }
                                    catch
                                    {
                                    }
                                    if (tipbyte[iii] == 4)
                                    {
                                        if (UNIX[ii] == false)
                                        {
                                            for (kkk = 0; kkk < numu[iii]; kkk++)
                                                cuu[arch][iii][kkk] = br.ReadInt32();
                                        }
                                        else
                                        {
                                            for (kkk = 0; kkk < numu[iii]; kkk++)
                                            {
                                                bit4 = br.ReadBytes(4);
                                                Array.Reverse(bit4, 0, 4);
                                                cuu[arch][iii][kkk] = BitConverter.ToInt32(bit4, 0);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (UNIX[ii] == false)
                                        {
                                            for (kkk = 0; kkk < numu[iii]; kkk++)
                                                cuu[arch][iii][kkk] = (int)(br.ReadInt16());
                                        }
                                        else
                                        {
                                            for (kkk = 0; kkk < numu[iii]; kkk++)
                                            {
                                                bit2 = br.ReadBytes(2);
                                                Array.Reverse(bit2, 0, 2);
                                                cuu[arch][iii][kkk] = (int)(BitConverter.ToInt16(bit2, 0));
                                            }
                                        }
                                    }
                                    if (cuu[arch][iii][numu[iii] - 1] == 0)
                                    {
                                        int xxx = cuu[arch][iii][numu[iii] - 50];
                                        int mmm = xxx;
                                        for (kkk = numu[iii] - 49; kkk < numu[iii] - 1; kkk++)
                                        {
                                            if (xxx < cuu[arch][iii][kkk]) xxx = cuu[arch][iii][kkk];
                                            else if (mmm > cuu[arch][iii][kkk]) mmm = cuu[arch][iii][kkk];
                                        }
                                        int diff1 = cuu[arch][iii][numu[iii] - 1] - cuu[arch][iii][numu[iii] - 2];
                                        int diff2 = xxx - mmm;
                                        if (Math.Abs(Math.Abs(diff1) - Math.Abs(diff2)) > 60000.0) cuu[arch][iii][numu[iii] - 1] = cuu[arch][iii][numu[iii] - 2];
                                        //MessageBox.Show(esta[arch][iii]+" xxx="+xxx.ToString()+" mmm="+mmm.ToString()+" dif="+(xxx-mmm).ToString()+"    "+Math.Abs(Math.Abs(diff1)-Math.Abs(diff2)).ToString());
                                    }
                                    br.ReadBytes(8);
                                }

                                br.Close();
                                arch += 1;
                            }
                            catch
                            {
                                NoMostrar = true;
                                MessageBox.Show("*** ERROR!! ( quizas mas de 30 estaciones?? )");
                            }
                        }

                        //MessageBox.Show("arch-1="+arch.ToString()+" esta="+esta[arch-1][0]);

                        ide += 1;
                        if (ide == listBox1.Items.Count || ide < 0) break;
                        lis = listBox1.Items[ide].ToString();
                        an = int.Parse(lis.Substring(0, 2));
                        if (an < 88) an += 2000;
                        else an += 1900;
                        me = int.Parse(lis.Substring(3, 2));
                        di = int.Parse(lis.Substring(6, 2));
                        ho = int.Parse(lis.Substring(9, 2));
                        mi = int.Parse(lis.Substring(12, 2));
                        DateTime fech3 = new DateTime(an, me, di, ho, mi, 0);
                        ll0 = fech3.Ticks;
                        if (uts[ii] != 0) ll0 -= ((long)(uts[ii] * 10000000.0));
                        DateTime fech4 = new DateTime(ll0);
                        ca = nomcarp[ii];
                        if (sian[ii] == true) ca += "\\" + string.Format("{0:yyyy}", fech4);
                        if (sime[ii] == true) ca += "\\" + string.Format("{0:MM}", fech4);
                        if (sidi[ii] == true) ca += "\\" + string.Format("{0:dd}", fech4);
                        DirectoryInfo dir = new DirectoryInfo(ca);
                        le = "*." + nomext[ii];
                        FileInfo[] nn = dir.GetFiles(le);
                        le = string.Format("{0:yyyy}-{0:MM}-{0:dd}-{0:HH}{0:mm}", fech4);
                        nom = "\0";
                        for (jj = 0; jj < nn.Length; jj++)
                        {
                            if (string.Compare(nn[jj].Name.Substring(0, 15), le.Substring(0, 15)) == 0)
                            {
                                nom = ca += "\\" + nn[jj].Name;
                                break;
                            }
                        }
                        cont2 += 1;
                        if (cont2 > totven) break;
                    } while (ide < listBox1.Items.Count);

                    // En este formato no hay informacion de ganancia.

                    // aqui se asigna secuencialmente el nombre de las estaciones a la variable estt. La variable nuto,
                    //lleva la cuenta de las trazas.
                    // MessageBox.Show("arch="+arch.ToString());
                    if (arch > 0)
                    {
                        nuto = 0;
                        for (i = 0; i < arch; i++)
                        {
                            si = false;
                            for (j = 0; j < canal[i]; j++)
                            {
                                if (nuto > 0)
                                {
                                    for (k = 0; k < nuto; k++)
                                    {
                                        if (string.Compare(estt[k].Substring(0, 4), esta[i][j].Substring(0, 4)) == 0 || esta[i][j].Substring(0, 4) == "XXXX")
                                        {
                                            si = true;
                                            break;
                                        }
                                    }
                                }
                                if (si == false)
                                {
                                    estt[nuto] = esta[i][j];
                                    ga[nutra + nuto] = 1;
                                    comp[nutra + nuto] = compo[i][j];
                                    nuto += 1;
                                }
                                else si = false;
                            }
                        }

                        // aqui se van a asignar los datos a cada estacion sucesivamente.
                        for (iii = 0; iii < nuto; iii++)
                        {
                            lara = 0;
                            tie = 0;
                            facra = 0;
                            vacio = 0;
                            traslapo = 0;
                            dd2 = 0;
                            for (i = 0; i < arch; i++)
                            {
                                for (j = 0; j < canal[i]; j++)
                                {
                                    if (estt[iii].Substring(0, 4) == esta[i][j].Substring(0, 4))
                                    {
                                        if (lara > 0)
                                        {
                                            dd1 = tii[i][j];
                                            if (dd1 - dd2 > (facra + 0.005) && dd2 > 0)
                                            {
                                                siRoto[nutra] = true;
                                                vacio += (int)((dd1 - dd2) * rat[i][j]);
                                            }
                                            else if (dd2 - dd1 > (facra + 0.005) && dd2 > 0)
                                            {
                                                siTraslapo[nutra] = true;
                                                traslapo += (int)((dd2 - dd1) * rat[i][j]);
                                            }
                                        }
                                        lara += cuu[i][j].Length;
                                        facra = 1.0 / (rat[i][j]);
                                        dd2 = tii[i][j] + facra * cuu[i][j].Length;
                                        break;
                                    }
                                }
                            }// for i....

                            if (lara > 0)
                            {
                                lara += vacio;
                                lara -= traslapo;
                                si = false;
                                if (listasei.Count > 0)
                                {
                                    for (jj = 0; jj < listasei.Count; jj++)
                                    {
                                        if (listasei[jj].ToString().Substring(0, 4) == estt[iii].Substring(0, 4))
                                        {
                                            est[nutra] = listasei[jj].ToString().Substring(5, 4) + " ";
                                            si = true;
                                            break;
                                        }
                                    }
                                }
                                if (si == false) est[nutra] = estt[iii].Substring(0, 4) + " ";
                                cus = new int[lara];
                                tims = new double[lara];
                                siEst[nutra] = true;
                                tar[nutra] = tars[ii];
                                //by[nutra] = bby[0][0];// se supone que es multiplexado y todos los datos tienen la misma caracteristica (rata, tipodato, etc!!

                                jj = 0;
                                dd2 = 0;
                                cuvacio = 0;
                                for (i = 0; i < arch; i++)
                                {
                                    for (j = 0; j < canal[i]; j++)
                                    {
                                        //MessageBox.Show("i=" + i.ToString() + " j=" + j.ToString() + " estt=" + estt[iii] + "esta=" + esta[i][j]);
                                        if (estt[iii].Substring(0, 4) == esta[i][j].Substring(0, 4))
                                        {
                                            ra[nutra] = rat[i][j];// se puede mejorar!!
                                            by[nutra] = bby[i][j];
                                            tie = tii[i][j];
                                            facra = 1.0 / (rat[i][j]);
                                            inicio = 0;
                                            if (tie - dd2 > (facra + 0.005) && dd2 > 0)
                                            {
                                                vacio = (int)((tie - dd2) * rat[i][j]);
                                                dd2 += facra;
                                                for (kk = 0; kk < vacio; kk++)
                                                {
                                                    //tim[nutra][jj] = dd2 + kk * facra;
                                                    //cu[nutra][jj] = cuvacio;
                                                    tims[jj] = dd2 + kk * facra;
                                                    cus[jj] = cuvacio;
                                                    jj += 1;
                                                }
                                            }
                                            else if (dd2 - tie > (facra + 0.005) && dd2 > 0)
                                            {
                                                traslapo = (int)((dd2 - tie) * rat[i][j]);
                                                inicio = traslapo;
                                            }
                                            for (kk = inicio; kk < cuu[i][j].Length; kk++)
                                            {
                                                tims[jj] = tie + kk * facra;
                                                cus[jj] = cuu[i][j][kk];
                                                jj += 1;
                                            }
                                            facra = 1.0 / (rat[i][j]);
                                            dd2 = tii[i][j] + facra * cuu[i][j].Length;
                                            cuvacio = cus[jj - 1];
                                            break;
                                        }
                                    }
                                }
                                inicio = (int)((tinicio - tims[0]) * ra[nutra]);
                                if (inicio < 0) inicio = 0;
                                if (tims[lara - 1] - tifinal < 0) fin = lara;
                                else fin = (int)(lara - ((tims[lara - 1] - tifinal) * ra[nutra]));
                                if (inicio >= fin) continue;
                                i = fin - inicio;
                                tim[nutra] = new double[i];
                                cu[nutra] = new int[i];
                                kk = 0;
                                for (j = inicio; j < fin; j++)
                                {
                                    cu[nutra][kk] = cus[j];
                                    tim[nutra][kk++] = tims[j];
                                }
                                nutra += 1;
                            } // if lara>0
                        } // iii
                    }
                }
            }// ii: el numero de archivos SEISAN

            panel2.Visible = false;

            return;
        }
Example #26
0
 public static void WritePrimitive(Stream stream, DateTime value)
 {
     long v = value.ToBinary();
     WritePrimitive(stream, v);
 }
 private void CopyTo(byte[] buffer, int index, DateTime value)
 {
     Array.Copy(BitConverter.GetBytes(value.ToBinary()), 0, buffer, index, 8);
 }
Example #28
0
		public void ToBinary ()
		{
			DateTime dt_local = new DateTime (1, DateTimeKind.Local);
			Assert.AreEqual (1, (ulong) dt_local.ToBinary () >> 63, "#1");
			Assert.AreEqual (1, dt_local.Ticks, "#2");

			DateTime dt_utc = new DateTime (1, DateTimeKind.Utc);
			Assert.AreEqual (0x4000000000000001, dt_utc.ToBinary (), "#3");
			Assert.AreEqual (1, dt_utc.Ticks, "#4");

			DateTime dt_unspecified = new DateTime (1, DateTimeKind.Unspecified);
			Assert.AreEqual (1, dt_unspecified.ToBinary (), "#5");
			Assert.AreEqual (1, dt_unspecified.Ticks, "#6");
		}
 public static long Convert(DateTime value, long unused)
 {
     return value.ToBinary();
 }
 protected virtual ArraySegment<byte> SerializeDateTime(DateTime value)
 {
     return new ArraySegment<byte>(BitConverter.GetBytes(value.ToBinary()));
 }