Beispiel #1
0
        /* C R E A T E  N E W  W I N D O W */
        /*----------------------------------------------------------------------------
            %%Function: CreateNewWindow
            %%Qualified: AzLog.AzLogWindow.CreateNewWindow
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public static AzLogWindow CreateNewWindow(AzLogModel azlm, string sViewName, AzLogFilter azlf, ILogClient ilc)
        {
            AzLogWindow azlw = new AzLogWindow();

            azlw.SetView(sViewName);
            azlw.m_azlv = new AzLogView(azlw);
            azlw.m_azlv.SetFilter(azlf);

            // propagate the filter values we were given into the textboxes on our window
            AzLogFilter.AzLogFilterCondition azlfc;

            azlfc = azlf.Operations[0].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Gte)
                azlw.m_ebStart.Text = azlfc.RHS.Dttm(null).ToString("MM/dd/yy HH:mm");

            azlfc = azlf.Operations[1].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Lt)
                azlw.m_ebEnd.Text = azlfc.RHS.Dttm(null).ToString("MM/dd/yy HH:mm");

            azlw.m_ilc = ilc;
            azlw.m_azlm = azlm;
            azlw.m_azlv.BuildView(azlw.m_azlm, new CompareLogEntryTickCount(azlw.m_azlm));

            azlw.m_lvLog.VirtualListSize = azlw.m_azlv.Length;

            return azlw;
        }
        /* F E T C H  P A R T I T I O N  F O R  D A T E */

        /*----------------------------------------------------------------------------
        *       %%Function: FetchPartitionForDateAsync
        *       %%Qualified: AzLog.AzLogModel.FetchPartitionForDateAsync
        *       %%Contact: rlittle
        *
        *   for text files, its all or nothing (there's no query on top of the file)
        *   so when they ask for any data, they get all data. we will just remember
        *   internally if they have already been given all of our data
        *  ----------------------------------------------------------------------------*/
        public async Task <bool> FetchPartitionForDateAsync(AzLogModel azlm, DateTime dttm)
        {
            if (m_fDataLoaded || m_fDataLoading)
            {
                return(true);
            }

            m_fDataLoading = true;

            // since they asked for this dttm, at least tell them we're pending
            azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Pending);

            foreach (AzLogView azlv in azlm.Listeners)
            {
                azlv.BeginAsyncData();
            }

            await LoadCompleteModel(azlm);

            azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Complete);

            foreach (AzLogView azlv in azlm.Listeners)
            {
                azlv.CompleteAsyncData();
            }

            m_fDataLoaded  = true;
            m_fDataLoading = false;
            return(true);
        }
Beispiel #3
0
        /*----------------------------------------------------------------------------
        *       %%Function: FGetMinMacDateTime
        *       %%Qualified: AzLog.AzLogAzureBlob.FGetMinMacDateTime
        *
        *  ----------------------------------------------------------------------------*/
        public bool FGetMinMacDateTime(AzLogModel azlm, out DateTime dttmMin, out DateTime dttmMax)
        {
            dttmMin = DateTime.MaxValue;
            dttmMax = DateTime.MinValue;

            return(false);
        }
Beispiel #4
0
        public void TestSortTwoPartitions(string sPartition, Int64[] rg, string sPartition2, Int64[] rg2)
        {
            AzLogModel azlm = new AzLogModel();

            azlm.AddTestDataPartition(DateTime.Parse(sPartition), rg, null);
            azlm.AddTestDataPartition(DateTime.Parse(sPartition2), rg2, null);
            List <Int64> pls = new List <Int64>();

            foreach (Int64 n in rg)
            {
                pls.Add(n);
            }

            foreach (Int64 n in rg2)
            {
                pls.Add(n);
            }

            pls.Sort();

            BuildView(azlm, new CompareLogEntryTickCount(azlm));

            for (int i = 0; i < pls.Count; i++)
            {
                Assert.AreEqual(pls[i], AzleItem(i).EventTickCount);
            }
        }
Beispiel #5
0
        /* C R E A T E  N E W  W I N D O W */

        /*----------------------------------------------------------------------------
        *       %%Function: CreateNewWindow
        *       %%Qualified: AzLog.AzLogWindow.CreateNewWindow
        *       %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        public static AzLogWindow CreateNewWindow(AzLogModel azlm, string sViewName, AzLogFilter azlf, ILogClient ilc)
        {
            AzLogWindow azlw = new AzLogWindow();

            if (String.IsNullOrEmpty(sViewName))
            {
                sViewName = "Default";
            }

            azlw.SetView(sViewName);
            azlw.m_azlv = new AzLogView(azlw);
            azlw.m_azlv.SetFilter(azlf);

            // propagate the filter values we were given into the textboxes on our window
            AzLogFilter.AzLogFilterCondition azlfc;

            azlfc = azlf.Operations[0].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Gte)
            {
                azlw.m_ebStart.Text = azlfc.RHS.Dttm(null).ToLocalTime().ToString("MM/dd/yy HH:mm");
            }

            azlfc = azlf.Operations[1].Condition;
            if (azlfc.LHS.Source == AzLogFilter.AzLogFilterValue.DataSource.DttmRow && azlfc.Comparison == AzLogFilter.AzLogFilterCondition.CmpOp.Lt)
            {
                azlw.m_ebEnd.Text = azlfc.RHS.Dttm(null).ToLocalTime().ToString("MM/dd/yy HH:mm");
            }

            azlw.m_ilc  = ilc;
            azlw.m_azlm = azlm;
            azlw.m_azlv.BuildView(azlw.m_azlm, new CompareLogEntryTickCount(azlw.m_azlm));
            // azlw.m_lvLog.VirtualListSize = azlw.m_azlv.Length;
            azlw.m_lvLog.SetVirtualListSize(azlw.m_azlv.Length);
            return(azlw);
        }
Beispiel #6
0
        /* D O  F E T C H */

        /*----------------------------------------------------------------------------
        *       %%Function: DoFetch
        *       %%Qualified: AzLog.AzLogWindow.DoFetch
        *       %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        private void DoFetch(object sender, EventArgs e)
        {
            DateTime dttmMin, dttmMac;

            AzLogModel.FillMinMacFromStartEnd(m_ebStart.Text, m_ebEnd.Text, out dttmMin, out dttmMac);

            // update our filter so we will see this

            // we intimately know which items to edit. if this ever turns out to be false, then we will have to find
            // the right parts of the filter, or just rebuild it. but that will be slower (ack)
            AzLogFilter.AzLogFilterOperation azlfo = m_azlv.Filter.Operations[0]; // start is first item, end is last


            if (azlfo.Op != AzLogFilter.AzLogFilterOperation.OperationType.Value || azlfo.Condition.LHS.Source != AzLogFilter.AzLogFilterValue.DataSource.DttmRow)
            {
                throw new Exception("did not find correct value type in filter");
            }

            azlfo.Condition.RHS.OValue = dttmMin; // update our filter to include the new date range, otherwise the model will get new data and we won't show it

            azlfo = m_azlv.Filter.Operations[1];  // start is first item, end is last


            if (azlfo.Op != AzLogFilter.AzLogFilterOperation.OperationType.Value || azlfo.Condition.LHS.Source != AzLogFilter.AzLogFilterValue.DataSource.DttmRow)
            {
                throw new Exception("did not find correct value type in filter");
            }

            azlfo.Condition.RHS.OValue = dttmMac; // update our filter to include the new date range, otherwise the model will get new data and we won't show it
            m_azlv.RebuildView();

            m_azlm.FFetchPartitionsForDateRange(dttmMin, dttmMac);
        }
Beispiel #7
0
        /* F E T C H  P A R T I T I O N  F O R  D A T E */

        /*----------------------------------------------------------------------------
        *       %%Function: FetchPartitionForDateAsync
        *       %%Qualified: AzLog.AzLogModel.FetchPartitionForDateAsync
        *       %%Contact: rlittle
        *
        *   Fetch the partition for the given dttm (assumes that the hour is also
        *   filled in)
        *  ----------------------------------------------------------------------------*/
        public async Task <bool> FetchPartitionForDateAsync(AzLogModel azlm, DateTime dttm)
        {
            TableQuery <AzLogEntryEntity> tq =
                new TableQuery <AzLogEntryEntity>().Where(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal,
                                                       AzLogModel.SPartitionFromDate(dttm, dttm.Hour)));

            TableQuerySegment <AzLogEntryEntity> azleSegment = null;

            azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Pending);

            foreach (AzLogView azlv in azlm.Listeners)
            {
                azlv.BeginAsyncData();
            }

            while (azleSegment == null || azleSegment.ContinuationToken != null)
            {
                azleSegment = await m_azt.Table.ExecuteQuerySegmentedAsync(tq, azleSegment?.ContinuationToken);

                int iFirst, iLast;

                azlm.AddSegment(azleSegment, out iFirst, out iLast);

                azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Complete);
            }
            foreach (AzLogView azlv in azlm.Listeners)
            {
                azlv.CompleteAsyncData();
            }

            return(true);
        }
Beispiel #8
0
        /* L O A D  D A T A S O U R C E */

        /*----------------------------------------------------------------------------
        *       %%Function: LoadDatasource
        *       %%Qualified: AzLog.AzLogDatasourceSupport.LoadDatasource
        *       %%Contact: rlittle
        *
        *   Load the named datasource. This handles figuring out the datasource
        *   type and loading the correct type. Regurns an interface to the datasource
        *  ----------------------------------------------------------------------------*/
        public static IAzLogDatasource LoadDatasource(AzLogModel azlm, string sRegRoot, string sName)
        {
            // first, figure out what type of datasource this is
            Settings.SettingsElt[] _rgsteeDatasource =
            {
                new Settings.SettingsElt("Type", Settings.Type.Str, "", ""),
            };

            string sKey = String.Format("{0}\\Datasources\\{1}", sRegRoot, sName);

            // save everything we need to be able to recreate ourselves
            Settings ste = new Settings(_rgsteeDatasource, sKey, "ds");

            ste.Load();
            string         sType = ste.SValue("Type");
            DatasourceType dt;

            dt = TypeFromString(sType);
            switch (dt)
            {
            case DatasourceType.TextFile:
                return(AzLogFile.LoadFileDatasource(null, sRegRoot, sName));

            case DatasourceType.AzureTable:
                return(AzLogAzureTable.LoadAzureDatasource(null, sRegRoot, sName));

            case DatasourceType.AzureBlob:
                return(AzLogAzureBlob.LoadAzureDatasource(null, sRegRoot, sName));

            default:
                throw new Exception("unknown datasourcetype");
            }
        }
Beispiel #9
0
        /* C R E A T E  V I E W  F O R  C O L L E C T I O N */

        /*----------------------------------------------------------------------------
        *       %%Function: CreateViewForCollection
        *       %%Qualified: AzLog.AzLog.CreateViewForCollection
        *       %%Contact: rlittle
        *
        *   Create a window with the initial query parameters from this screen
        *  ----------------------------------------------------------------------------*/
        private void CreateViewForCollection(object sender, EventArgs e)
        {
            if (m_azlm == null)
            {
                m_azlm = new AzLogModel();

                // load all of our datasources and attach them
                foreach (IAzLogDatasource iazlds in m_azlc.Sources)
                {
                    if (!iazlds.FOpen(null, s_sRegRoot))
                    {
                        throw new Exception(String.Format("couldn't open datasource {0}", iazlds.ToString()));
                    }

                    m_azlm.AttachDatasource(iazlds);
                }
            }

            // figure out the timespan being requested
            DateTime dttmMin, dttmMac;

            if (m_cbAllDates.Checked)
            {
                if (!m_azlm.FGetMinMacDateRange(out dttmMin, out dttmMac))
                {
                    MessageBox.Show("Cannot automatically set date range -- this option only works when at least one datasource is a file. Setting date range to today.");

                    dttmMin = DateTime.Today;
                    dttmMac = dttmMin.AddDays(1);
                }
            }
            else
            {
                AzLogModel.FillMinMacFromStartEnd(m_ebStart.Text, m_ebEnd.Text, out dttmMin, out dttmMac);
            }

            AzLogFilter azlf = new AzLogFilter();

            // create a basic filter based on the range they asked for
            azlf.Add(new AzLogFilter.AzLogFilterCondition(AzLogFilter.AzLogFilterValue.ValueType.DateTime, AzLogFilter.AzLogFilterValue.DataSource.DttmRow, AzLogEntry.LogColumn.Nil,
                                                          AzLogFilter.AzLogFilterCondition.CmpOp.Gte, dttmMin));
            azlf.Add(new AzLogFilter.AzLogFilterCondition(AzLogFilter.AzLogFilterValue.ValueType.DateTime, AzLogFilter.AzLogFilterValue.DataSource.DttmRow, AzLogEntry.LogColumn.Nil,
                                                          AzLogFilter.AzLogFilterCondition.CmpOp.Lt, dttmMac));
            azlf.Add(AzLogFilter.AzLogFilterOperation.OperationType.And);

            AzLogWindow azlw = AzLogWindow.CreateNewWindow(m_azlm, m_azlc.DefaultView, azlf, this);

            azlw.Show();

            m_azlm.AddView(azlw.View);

            // we don't know what partition we're going to find this data in, so launch a query
            // from the first partition for this date range
            //m_azlm.FFetchPartitionsForDateRange(dttmMin, nHourMin, dttmMac, nHourMac);
            m_azlm.FFetchPartitionsForDateRange(dttmMin, dttmMac);
        }
Beispiel #10
0
        public AzLog()
        {
            m_azlm = new AzLogModel();

            InitializeComponent();
            PopulateAccounts();
            m_ste = new Settings(_rgsteeApp, "Software\\Thetasoft\\AzLog", "App");
            m_ste.Load();
            m_sDefaultView = m_ste.SValue("DefaultView");
        }
Beispiel #11
0
        public static void TestFillMinMacFromStartEnd(string sStart, string sEnd, string sDttmMinExpected, string sDttmMacExpected)
        {
            DateTime dttmMin = DateTime.Parse(sDttmMinExpected);
            DateTime dttmMac = DateTime.Parse(sDttmMacExpected);
            DateTime dttmMinActual, dttmMacActual;

            AzLogModel.FillMinMacFromStartEnd(sStart, sEnd, out dttmMinActual, out dttmMacActual);
            Assert.AreEqual(dttmMin, dttmMinActual);
            Assert.AreEqual(dttmMac, dttmMacActual);
        }
Beispiel #12
0
        /* L O A D  A Z U R E  D A T A S O U R C E */

        /*----------------------------------------------------------------------------
        *       %%Function: LoadAzureDatasource
        *       %%Qualified: AzLog.AzLogAzureTable.LoadAzureDatasource
        *       %%Contact: rlittle
        *
        *   Loads this azure datasource
        *  ----------------------------------------------------------------------------*/
        public static AzLogAzudreGeneric LoadAzureDatasource(AzLogModel azlm, string sRegRoot, string sName)
        {
            AzLogAzureGeneric azla = new AzLogAzureGeneric();

            if (azla.FLoad(azlm, sRegRoot, sName))
            {
                return(azla);
            }

            return(null);
        }
        /* L O A D  A Z U R E  D A T A S O U R C E */

        /*----------------------------------------------------------------------------
        *       %%Function: LoadAzureDatasource
        *       %%Qualified: AzLog.AzLogAzureTable.LoadAzureDatasource
        *       %%Contact: rlittle
        *
        *   Loads this azure datasource
        *  ----------------------------------------------------------------------------*/
        public static AzLogFile LoadFileDatasource(AzLogModel azlm, string sRegRoot, string sName)
        {
            AzLogFile azlf = new AzLogFile();

            if (azlf.FLoad(azlm, sRegRoot, sName))
            {
                return(azlf);
            }

            return(null);
        }
Beispiel #14
0
        /*----------------------------------------------------------------------------
        *       %%Function: OpenContainer
        *       %%Qualified: AzLog.AzLogAzureBlob.OpenContainer
        *       %%Contact: rlittle
        *
        *   clear all of the views since we are now opening a new blob.
        *  ----------------------------------------------------------------------------*/
        public void OpenContainer(AzLogModel azlm, string sContainerName)
        {
            if (azlm != null)
            {
                foreach (AzLogView azlv in azlm.Listeners)
                {
                    azlv.ClearLog();
                }
            }

            m_azc = m_azcc.GetContainer(sContainerName);
        }
Beispiel #15
0
        private void DoFetchLogEntries(object sender, EventArgs e)
        {
            // figure out the timespan being requested
            DateTime dttmMin, dttmMac;

            AzLogModel.FillMinMacFromStartEnd(m_ebStart.Text, m_ebEnd.Text, out dttmMin, out dttmMac);

            // we don't know what partition we're going to find this data in, so launch a query
            // from the first partition for this date range
            // m_azlm.FFetchPartitionsForDateRange(dttmMin, nHourMin, dttmMac, nHourMac);
            m_azlm.FetchPartitionForDateAsync(dttmMin);
        }
Beispiel #16
0
        /* O P E N  T A B L E */

        /*----------------------------------------------------------------------------
        *       %%Function: OpenSource
        *       %%Qualified: AzLog.AzLogModel.OpenSource
        *       %%Contact: rlittle
        *
        *   clear all of the views since we are now opening a new table.
        *  ----------------------------------------------------------------------------*/
        public void OpenContainer(AzLogModel azlm, string sTableName)
        {
            if (azlm != null)
            {
                foreach (AzLogView azlv in azlm.Listeners)
                {
                    azlv.ClearLog();
                }
            }

            m_azt = m_aztc.GetTable(sTableName);
        }
Beispiel #17
0
        /* F E T C H  P A R T I T I O N  F O R  D A T E */

        /*----------------------------------------------------------------------------
        *       %%Function: FetchPartitionForDateAsync
        *       %%Qualified: AzLog.AzLogModel.FetchPartitionForDateAsync
        *       %%Contact: rlittle
        *
        *   Fetch the partition for the given dttm (assumes that the hour is also
        *   filled in)
        *  ----------------------------------------------------------------------------*/
        public async Task <bool> FetchPartitionForDateAsync(AzLogModel azlm, DateTime dttm)
        {
            List <Uri> pluri = GetBlobList(dttm);

            azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Pending);

            foreach (AzLogView azlv in azlm.Listeners)
            {
                azlv.BeginAsyncData();
            }

            foreach (Uri uri in pluri)
            {
                ICloudBlob icb       = m_azcc.BlobClient.GetBlobReferenceFromServer(uri);
                string     sTempFile = TCore.Util.Filename.SBuildTempFilename(null, null);

                icb.DownloadToFile(sTempFile, FileMode.Create);
                // at this point, we have the file
            }

            // now we can download the blobs -- create CloudBlob for each URI, then DownloadToFile...
            // need to do this async....
#if no
            TableQuery <AzLogEntryEntity> tq =
                new TableQuery <AzLogEntryEntity>().Where(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal,
                                                       AzLogModel.SPartitionFromDate(dttm, dttm.Hour)));

            TableQuerySegment <AzLogEntryEntity> azleSegment = null;
            azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Pending);

            foreach (AzLogView azlv in azlm.Listeners)
            {
                azlv.BeginAsyncData();
            }

            while (azleSegment == null || azleSegment.ContinuationToken != null)
            {
                azleSegment = await m_azc.Container.ExecuteQuerySegmentedAsync(tq, azleSegment?.ContinuationToken);

                int iFirst, iLast;

                azlm.AddSegment(azleSegment, out iFirst, out iLast);

                azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Complete);
            }
            foreach (AzLogView azlv in azlm.Listeners)
            {
                azlv.CompleteAsyncData();
            }
#endif
            return(true);
        }
        public async Task LoadCompleteModel(AzLogModel azlm)
        {
            AzLogEntry[] rgazle = new AzLogEntry[s_cChunkSize]; // do 1k log entry chunks

            using (StreamReader sr = File.OpenText(m_sFilename))
            {
                int iLine = 0;
                int cChunk = 0;
                int iFirst, iLast;

                while (!sr.EndOfStream)
                {
                    string     s    = sr.ReadLine();
                    AzLogEntry azle = null;
                    try
                    {
                        azle = AzleFromLine(s, iLine++);
                    }
                    catch
                    {
                    }

                    if (azle == null)
                    {
                        continue;
                    }

                    DateTime dttm = AzLogModel.DttmFromPartition(azle.Partition);
                    if (m_dttmFirst > dttm)
                    {
                        m_dttmFirst = dttm;
                    }
                    if (m_dttmLast < dttm)
                    {
                        m_dttmLast = dttm;
                    }

                    rgazle[cChunk++] = azle;

                    if (cChunk >= s_cChunkSize)
                    {
                        azlm.AddSegment(rgazle, cChunk, out iFirst, out iLast);
                        cChunk = 0;
                    }
                }
                if (cChunk > 0)
                {
                    azlm.AddSegment(rgazle, cChunk, out iFirst, out iLast);
                }
            }
        }
Beispiel #19
0
        /* F  L O A D */

        /*----------------------------------------------------------------------------
        *       %%Function: FLoad
        *       %%Qualified: AzLog.AzLogAzureBlob.FLoad
        *       %%Contact: rlittle
        *
        *   Load the information about this datasource, but don't actually open it
        *   (doesn't ping the net or validate information)
        *  ----------------------------------------------------------------------------*/
        public bool FLoad(AzLogModel azlm, string sRegRoot, string sName)
        {
            string sKey = String.Format("{0}\\Datasources\\{1}", sRegRoot, sName);

            // save everything we need to be able to recreate ourselves
            Settings ste = new Settings(_rgsteeDatasource, sKey, "ds");

            ste.Load();
            m_sAccountName   = ste.SValue("AccountName");
            m_sContainerName = ste.SValue("Container");
            m_sName          = sName;

            return(true);
        }
Beispiel #20
0
        /* F  O P E N */

        /*----------------------------------------------------------------------------
        *       %%Function: FOpen
        *       %%Qualified: AzLog.AzLogAzureBlob.FOpen
        *       %%Contact: rlittle
        *
        *   Actually open the datasource, connecting to the source
        *  ----------------------------------------------------------------------------*/
        public bool FOpen(AzLogModel azlm, string sRegRoot)
        {
            try
            {
                OpenAccount(m_sAccountName, GetAccountKey(sRegRoot, m_sAccountName));
                OpenContainer(azlm, m_sContainerName);
            }
            catch (Exception exc)
            {
                MessageBox.Show(String.Format("Couldn't open azure datasource {0}: {1}", m_sName, exc.Message));
                return(false);
            }
            return(true);
        }
        public bool FGetMinMacDateTime(AzLogModel azlm, out DateTime dttmMin, out DateTime dttmMac)
        {
            if (!m_fDataLoaded)
            {
                LoadCompleteModel(azlm).Wait();

                m_fDataLoaded  = true;
                m_fDataLoading = false;
            }

            dttmMin = m_dttmFirst;
            dttmMac = m_dttmLast.AddDays(1);

            return(true);
        }
        /* F  L O A D */

        /*----------------------------------------------------------------------------
        *       %%Function: FLoad
        *       %%Qualified: AzLog.AzLogAzureTable.FLoad
        *       %%Contact: rlittle
        *
        *   Load the information about this datasource, but don't actually open it
        *   (doesn't ping the net or validate information)
        *  ----------------------------------------------------------------------------*/
        public bool FLoad(AzLogModel azlm, string sRegRoot, string sName)
        {
            string sKey = String.Format("{0}\\Datasources\\{1}", sRegRoot, sName);

            // save everything we need to be able to recreate ourselves
            Settings ste = new Settings(_rgsteeDatasource, sKey, "ds");

            ste.Load();
            m_sFilename = ste.SValue("FileName");
            m_sName     = sName;

            m_tlc = TextLogConverter.CreateFromConfig(ste.SValue("LogTextFormat"));

            return(true);
        }
Beispiel #23
0
        /* B U M P  D T T M  F I L T E R */

        /*----------------------------------------------------------------------------
        *       %%Function: BumpDttmFilter
        *       %%Qualified: AzLog.AzLogWindow.BumpDttmFilter
        *       %%Contact: rlittle
        *
        *   Bump forward or backward the datetime filter by the given nHours. fStart
        *   determines if we are bumping the start or end of the range
        *  ----------------------------------------------------------------------------*/
        private void BumpDttmFilter(TextBox eb, int nHours, bool fStart)
        {
            // figure out the timespan being requested
            DateTime dttmMin, dttmMac;

            AzLogModel.FillMinMacFromStartEnd(eb.Text, eb.Text, out dttmMin, out dttmMac);

            // update our filter so we will see this

            // we intimately know which items to edit. if this ever turns out to be false, then we will have to find
            // the right parts of the filter, or just rebuild it. but that will be slower (ack)
            AzLogFilter.AzLogFilterOperation azlfo = m_azlv.Filter.Operations[fStart ? 0 : 1]; // start is first item, end is last

            if (azlfo.Op != AzLogFilter.AzLogFilterOperation.OperationType.Value ||
                !azlfo.Condition.RHS.FEvaluate(AzLogFilter.AzLogFilterCondition.CmpOp.Eq, new AzLogFilter.AzLogFilterValue(dttmMac), null))
            {
                throw new Exception("did not find correct end date value in filter");
            }

            // now add an hour to the end
            dttmMac = dttmMac.AddHours(nHours);
            azlfo.Condition.RHS.OValue = dttmMac; // update our filter to include the new date range, otherwise the model will get new data and we won't show it
            m_azlv.RebuildView();
            // 10/26/2015 9:00

            eb.Text = dttmMac.ToLocalTime().ToString("MM/dd/yyyy HH:mm");

            // at this point, all our changes were to "dttmMac" (dttmMin started out same as dttmMac...so we could just
            // blissfully use dttmMac.  But for the fetch, it matters if we are growing or shrinking our range
            if (fStart)
            {
                if (nHours < 0)
                {
                    m_azlm.FFetchPartitionsForDateRange(dttmMac, dttmMin); // i know, confusing. but we modified dttmMac...
                }
            }
            else
            {
                if (nHours > 0)
                {
                    m_azlm.FFetchPartitionsForDateRange(dttmMin, dttmMac);
                }
            }
        }
Beispiel #24
0
        public void TestMessageSplit(string sPartition, string sMessage, string[] rgsExpected)
        {
            AzLogModel azlm = new AzLogModel();

            m_azlf = new AzLogFilter(); // just get a default empty one

            azlm.AddTestDataPartition(DateTime.Parse(sPartition), new Int64[] { 10 }, new string[] { sMessage });

            BuildView(azlm, new CompareLogEntryTickCount(azlm));

            AzLogEntry azle = AzleItem(0);

            Assert.AreEqual(rgsExpected[0], azle.Message);
            Assert.AreEqual(rgsExpected[1], azle.Message0);
            Assert.AreEqual(rgsExpected[2], azle.Message1);
            Assert.AreEqual(rgsExpected[3], azle.Message2);
            Assert.AreEqual(rgsExpected[4], azle.Message3);
            Assert.AreEqual(rgsExpected[5], azle.Message4);
            Assert.AreEqual(rgsExpected[6], azle.Message5);
            Assert.AreEqual(rgsExpected[7], azle.Message6);
            Assert.AreEqual(rgsExpected[8], azle.Message7);
            Assert.AreEqual(rgsExpected[9], azle.Message8);
        }
Beispiel #25
0
        /* B U I L D  V I E W */
        /*----------------------------------------------------------------------------
            %%Function: BuildView
            %%Qualified: AzLog.AzLogView.BuildView
            %%Contact: rlittle

            Build the current view (or rebuild the current view). Use the given
            IComparer to sort items.

            (REMEMBER: the IComparer is always going to compare two indexes since
            it has to go through a level of indirection to get to the actual model
            data.  The difference is going to be calculated based on specific
            underlying AzLogEntry fields)
        ----------------------------------------------------------------------------*/
        public void BuildView(AzLogModel azlm, IComparer<int> icle)
        {
            m_icle = icle;
            m_azlm = azlm;
            RebuildView();
        }
Beispiel #26
0
 public Task <bool> FetchPartitionForDateAsync(AzLogModel azlm, DateTime dttm)
 {
     throw new NotImplementedException();
 }
Beispiel #27
0
 public bool FOpen(AzLogModel azlm, string sRegRoot)
 {
     throw new NotImplementedException();
 }
Beispiel #28
0
        public void TestSortTwoPartitions(string sPartition, Int64[] rg, string sPartition2, Int64[] rg2)
        {
            AzLogModel azlm = new AzLogModel();

            azlm.AddTestDataPartition(DateTime.Parse(sPartition), rg, null);
            azlm.AddTestDataPartition(DateTime.Parse(sPartition2), rg2, null);
            List<Int64> pls = new List<Int64>();

            foreach (Int64 n in rg)
                pls.Add(n);

            foreach (Int64 n in rg2)
                pls.Add(n);

            pls.Sort();

            BuildView(azlm, new CompareLogEntryTickCount(azlm));

            for (int i = 0; i < pls.Count; i++)
                Assert.AreEqual(pls[i], AzleItem(i).EventTickCount);
        }
 public void OpenContainer(AzLogModel azlm, string sName)
 {
     throw new Exception("NYI");
 }
Beispiel #30
0
        /* P A R S E  L I N E */

        /*----------------------------------------------------------------------------
        *   %%Function: ParseLine
        *   %%Qualified: AzLog.AzLogFile.TextLogConverter.ParseLine
        *   %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        public AzLogEntry ParseLine(string sLine, int nLine)
        {
            AzLogEntry azle = new AzLogEntry();

            azle.InitMessageParts(10);

            int ilc     = 0;
            int ich     = 0;
            int ichLast = 0;

            int ichMac = sLine.Length;

            while (ilc < m_pltlc.Count)
            {
                ichLast = 0;

                TextLogColumn tlc = m_pltlc[ilc];

                // by definition we are already positioned at the beginning of this column except for possible whitespace
                // skip leading whitespace exc
                while (ich < ichMac && sLine[ich] == ' ')
                {
                    ich++;
                }

                if (ich >= ichMac)
                {
                    if (ilc < m_pltlc.Count)
                    {
                        return(null);
                    }
                    break;
                }
                int ichEnd = 0;

                // look for the separator
                if (tlc.Separator == TextLogColumn.Sep.Comma)
                {
                    if (!FParseQuotedCommaColumn(sLine, ich, ref ichLast, ref ichEnd, ichMac, ilc + 1 == m_pltlc.Count))
                    {
                        return(null);
                    }

                    // else, we'll calculate ichLim below
                }
                else if (tlc.Separator == TextLogColumn.Sep.FixedWidth)
                {
                    if (!FParseFixedWidthColumn(sLine, tlc.Cch, ich, ref ichLast, ref ichEnd, ichMac, ilc + 1 == m_pltlc.Count))
                    {
                        return(null);
                    }
                }

                if (ichLast == 0)
                {
                    if (ilc + 1 == m_pltlc.Count)
                    {
                        ichEnd = ichLast = sLine.Length - 1;
                    }
                    else
                    {
                        char chSep = TextLogColumn.CharFromSep(tlc.Separator);
                        ichLast = sLine.IndexOf(chSep, ich);
                        if (ichLast == -1)
                        {
                            return(null); // couldn't find the separator for this column
                        }
                        ichLast--;        // we want this to point to the last char, not to the separator
                        ichEnd = ichLast;
                    }
                }
                // at this point we have ich pointing to start of string; ichEnd pointing to last char before the separator (maybe a quote),
                // at ichLast pointing to just before the separator (never a quote)
                //, lets trim the string
                int ichFirst = ich;


                if (sLine[ichFirst] == '"' && sLine[ichEnd] == '"')
                {
                    ichFirst++;
                    ichEnd--;
                }

                while (ichEnd > ichFirst && sLine[ichEnd] == ' ')
                {
                    ichEnd--;
                }

                // now we have the string
                if (tlc.Column == AzLogEntry.LogColumn.EventTickCount)
                {
                    DateTime dttm = DateTime.Parse(sLine.Substring(ichFirst, ichEnd - ichFirst + 1));
                    dttm = dttm.ToUniversalTime();

                    azle.SetColumn(AzLogEntry.LogColumn.Partition, dttm.ToString("yyyyMMddHH"));
                    azle.EventTickCount = dttm.Ticks + nLine;
                    if (tlc.ColumnCopy != AzLogEntry.LogColumn.Nil)
                    {
                        azle.SetColumn(tlc.ColumnCopy, dttm.ToString("MM/dd/yyyy HH:mm:ss"));
                    }

                    // and manufacture a partition as well
                    azle.SetColumn(AzLogEntry.LogColumn.Partition, AzLogModel.SPartitionFromDate(dttm, dttm.Hour));
                }
                else
                {
                    azle.SetColumn(tlc.Column, sLine.Substring(ichFirst, ichEnd - ichFirst + 1));
                }

                if (tlc.Separator == TextLogColumn.Sep.FixedWidth)
                {
                    ich = ichLast;
                }
                else
                {
                    ich = ichLast + 2;
                }
                ilc++;
                if (ich >= ichMac)
                {
//                    if (ilc < m_pltlc.Count)
//                        return null;
                    break;
                }
            }

            //
            return(azle);
        }
        /* F  O P E N */

        /*----------------------------------------------------------------------------
        *       %%Function: FOpen
        *       %%Qualified: AzLog.AzLogAzureTable.FOpen
        *       %%Contact: rlittle
        *
        *   Actually open the datasource, connecting to the source
        *  ----------------------------------------------------------------------------*/
        public bool FOpen(AzLogModel azlm, string sRegRoot)
        {
            return(true);
        }
Beispiel #32
0
        /* B U I L D  V I E W */

        /*----------------------------------------------------------------------------
        *       %%Function: BuildView
        *       %%Qualified: AzLog.AzLogView.BuildView
        *       %%Contact: rlittle
        *
        *   Build the current view (or rebuild the current view). Use the given
        *   IComparer to sort items.
        *
        *   (REMEMBER: the IComparer is always going to compare two indexes since
        *   it has to go through a level of indirection to get to the actual model
        *   data.  The difference is going to be calculated based on specific
        *   underlying AzLogEntry fields)
        *  ----------------------------------------------------------------------------*/
        public void BuildView(AzLogModel azlm, IComparer <int> icle)
        {
            m_icle = icle;
            m_azlm = azlm;
            RebuildView();
        }
Beispiel #33
0
        public void TestMessageSplit(string sPartition, string sMessage, string[] rgsExpected)
        {
            AzLogModel azlm = new AzLogModel();

            azlm.AddTestDataPartition(DateTime.Parse(sPartition), new Int64[] {10}, new string[] {sMessage});

            BuildView(azlm, new CompareLogEntryTickCount(azlm));

            AzLogEntry azle = AzleItem(0);

            Assert.AreEqual(rgsExpected[0], azle.Message);
            Assert.AreEqual(rgsExpected[1], azle.Message0);
            Assert.AreEqual(rgsExpected[2], azle.Message1);
            Assert.AreEqual(rgsExpected[3], azle.Message2);
            Assert.AreEqual(rgsExpected[4], azle.Message3);
            Assert.AreEqual(rgsExpected[5], azle.Message4);
            Assert.AreEqual(rgsExpected[6], azle.Message5);
            Assert.AreEqual(rgsExpected[7], azle.Message6);
            Assert.AreEqual(rgsExpected[8], azle.Message7);
            Assert.AreEqual(rgsExpected[9], azle.Message8);
        }