Ejemplo n.º 1
0
 protected static void UpdateTotalNumberOfRowsReturned(CommandResult item, StatisticsBase info)
 {
     if (info == null || item.RowsReturned == null)
     {
         return;
     }
     info.ContextStatistics.TotalNumberOfRowsReturned += item.RowsReturned.Value;
 }
Ejemplo n.º 2
0
 protected static void UpdateTotalQueryExecutionTime(CommandResult item, StatisticsBase info)
 {
     if (info == null || item.ElapsedMilliseconds == null)
     {
         return;
     }
     info.ContextStatistics.TotalQueryExecutionTime += item.ElapsedMilliseconds.Value;
 }
Ejemplo n.º 3
0
 protected static void UpdateNumberOfTransactions(StatisticsBase info)
 {
     if (info == null)
     {
         return;
     }
     info.ContextStatistics.NumberOfTransactions++;
 }
Ejemplo n.º 4
0
 protected static void UpdateNumberOfQueries(StatisticsBase info)
 {
     if (info == null)
     {
         return;
     }
     info.ContextStatistics.NumberOfQueries++;
 }
Ejemplo n.º 5
0
 protected static void UpdateTotalConnectionOpenTime(StatisticsBase info, CommandConnection connection)
 {
     if (info == null || connection.ClosedAt == null)
     {
         return;
     }
     info.ContextStatistics.TotalConnectionOpenTime +=
         (long)(connection.ClosedAt.Value - connection.AtDateTime).TotalMilliseconds;
 }
Ejemplo n.º 6
0
 protected static void UpdateCommandStatistics(Command item, StatisticsBase info)
 {
     if (info == null)
     {
         return;
     }
     info.CommandStatistics.DeletesCount += item.CommandStatistics.DeletesCount;
     info.CommandStatistics.InsertsCount += item.CommandStatistics.InsertsCount;
     info.CommandStatistics.JoinsCount   += item.CommandStatistics.JoinsCount;
     info.CommandStatistics.LikesCount   += item.CommandStatistics.LikesCount;
     info.CommandStatistics.SelectsCount += item.CommandStatistics.SelectsCount;
     info.CommandStatistics.UpdatesCount += item.CommandStatistics.UpdatesCount;
 }
 /// <summary>
 /// Closes the gadget.
 /// </summary>
 public void CloseGadget()
 {
     try
     {
         logger.Debug("PluginContainer : CloseGadget : Method Exit");
         StatisticsBase.GetInstance().isGadgetClose = true;
         Settings.GetInstance().IsPluginReaded      = true;
         if (mainVm == null)
         {
             mainVm = new MainWindowViewModel();
         }
         mainVm.gadgetclose();
         //commented
         stat.ShowGadgetState(Pointel.Statistics.Core.Utility.StatisticsEnum.GadgetState.Closed);
     }
     catch (Exception GeneralException)
     {
         logger.Error("PluginContainer : CloseGadget Method : Exception Caught : " + GeneralException.Message);
     }
     finally
     {
         logger.Debug("PluginContainer : CloseGadget : Method Exit");
     }
 }
Ejemplo n.º 8
0
        ///// <summary>
        ///// Creates the config.
        ///// </summary>
        //private void CreateConfig()
        //{
        //    XmlDocument doc;
        //    XmlNode[] Nodes = new XmlNode[50];
        //    XmlTextWriter writeUserDetails;
        //    string rootElement = "config";
        //    string loginParamsElement = "StatTickerFive";
        //    try
        //    {
        //        if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
        //                              "\\Pointel\\StatTickerFive"))
        //        {
        //            if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
        //                              "\\Pointel\\StatTickerFive\\config.xml"))
        //            {
        //                XmlDataDocument xmldoc = new XmlDataDocument();
        //                XmlNodeList xmlnode;
        //                FileStream fs = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Pointel\\StatTickerFive\\config.xml", FileMode.Open, FileAccess.Read);
        //                xmldoc.Load(fs);
        //                xmlnode = xmldoc.GetElementsByTagName("dbstatistics");
        //                fs.Close();

        //                if (xmlnode.Count == 0 || xmlnode[0].ChildNodes[0].InnerText == "")
        //                {

        //                    Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
        //                                               "\\Pointel\\StatTickerFive");
        //                    doc = new XmlDocument();

        //                    Nodes[0] = doc.CreateElement("config");
        //                    doc.AppendChild(Nodes[0]);

        //                    Nodes[1] = doc.CreateElement("StatTickerFive");
        //                    Nodes[0].AppendChild(Nodes[1]);

        //                    Nodes[2] = doc.CreateElement("dbstatistics");
        //                    Nodes[1].AppendChild(Nodes[2]);

        //                    #region Statistics properties

        //                    Nodes[3] = doc.CreateElement("db.statname");

        //                    Nodes[4] = doc.CreateElement("db.displayname");
        //                    Nodes[3].AppendChild(Nodes[4]);

        //                    Nodes[5] = doc.CreateElement("db.threshold1");
        //                    Nodes[3].AppendChild(Nodes[5]);

        //                    Nodes[6] = doc.CreateElement("db.threshold2");
        //                    Nodes[3].AppendChild(Nodes[6]);

        //                    Nodes[7] = doc.CreateElement("db.color1");
        //                    Nodes[3].AppendChild(Nodes[7]);

        //                    Nodes[8] = doc.CreateElement("db.color2");
        //                    Nodes[3].AppendChild(Nodes[8]);

        //                    Nodes[9] = doc.CreateElement("db.color3");
        //                    Nodes[3].AppendChild(Nodes[9]);

        //                    Nodes[10] = doc.CreateElement("db.tooltipname");
        //                    Nodes[3].AppendChild(Nodes[10]);

        //                    Nodes[11] = doc.CreateElement("db.format");
        //                    Nodes[3].AppendChild(Nodes[11]);

        //                    Nodes[12] = doc.CreateElement("db.query");
        //                    Nodes[3].AppendChild(Nodes[12]);

        //                    Nodes[2].AppendChild(Nodes[3]);

        //                    #endregion

        //                    Nodes[13] = doc.CreateElement("enable.disable-channels");
        //                    Nodes[1].AppendChild(Nodes[13]);

        //                    #region Enable Disable Channels

        //                    Nodes[14] = doc.CreateElement("statistics.enable-alwaysontop");
        //                    Nodes[13].AppendChild(Nodes[14]);
        //                    Nodes[15] = doc.CreateElement("statistics.enable-ccstat-aid");
        //                    Nodes[13].AppendChild(Nodes[15]);
        //                    Nodes[16] = doc.CreateElement("statistics.enable-log");
        //                    Nodes[13].AppendChild(Nodes[16]);
        //                    Nodes[17] = doc.CreateElement("statistics.enable-maingadget");
        //                    Nodes[13].AppendChild(Nodes[17]);
        //                    Nodes[18] = doc.CreateElement("statistics.enable-menu-button");
        //                    Nodes[13].AppendChild(Nodes[18]);
        //                    Nodes[19] = doc.CreateElement("statistics.enable-mystat-aid");
        //                    Nodes[13].AppendChild(Nodes[19]);
        //                    Nodes[20] = doc.CreateElement("statistics.enable-notification-balloon");
        //                    Nodes[13].AppendChild(Nodes[20]);
        //                    Nodes[21] = doc.CreateElement("statistics.enable-notification-close");
        //                    Nodes[13].AppendChild(Nodes[21]);
        //                    Nodes[22] = doc.CreateElement("statistics.enable-submenu-ccstatistics");
        //                    Nodes[13].AppendChild(Nodes[22]);
        //                    Nodes[23] = doc.CreateElement("statistics.enable-submenu-close-gadget");
        //                    Nodes[13].AppendChild(Nodes[23]);
        //                    Nodes[24] = doc.CreateElement("statistics.enable-submenu-mystatistics");
        //                    Nodes[13].AppendChild(Nodes[24]);
        //                    Nodes[25] = doc.CreateElement("statistics.enable-submenu-ontop");
        //                    Nodes[13].AppendChild(Nodes[25]);
        //                    Nodes[26] = doc.CreateElement("statistics.enable-tag-button");
        //                    Nodes[13].AppendChild(Nodes[26]);
        //                    Nodes[27] = doc.CreateElement("statistics.enable-tag-vertical");
        //                    Nodes[13].AppendChild(Nodes[27]);
        //                    Nodes[28] = doc.CreateElement("statistics.enable-untag-button");
        //                    Nodes[13].AppendChild(Nodes[28]);

        //                    #endregion

        //                    Nodes[29] = doc.CreateElement("statistics.log");
        //                    Nodes[1].AppendChild(Nodes[29]);

        //                    #region Log

        //                    Nodes[30] = doc.CreateElement("statistics.log.conversionpattern");
        //                    Nodes[29].AppendChild(Nodes[30]);

        //                    Nodes[31] = doc.CreateElement("statistics.log.datepattern");
        //                    Nodes[29].AppendChild(Nodes[31]);

        //                    Nodes[32] = doc.CreateElement("statistics.log.filepath");
        //                    Nodes[29].AppendChild(Nodes[32]);

        //                    Nodes[33] = doc.CreateElement("statistics.log.level");
        //                    Nodes[29].AppendChild(Nodes[33]);

        //                    Nodes[34] = doc.CreateElement("statistics.log.maxfilesize");
        //                    Nodes[29].AppendChild(Nodes[34]);

        //                    Nodes[35] = doc.CreateElement("statistics.log.maxrollbacksize");
        //                    Nodes[29].AppendChild(Nodes[35]);

        //                    #endregion

        //                    doc.Save(Environment.CurrentDirectory + @"\config.xml");

        //                    writeUserDetails =
        //                        new XmlTextWriter(
        //                            Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
        //                            "\\Pointel\\StatTickerFive\\config.xml", Encoding.Default);

        //                    writeUserDetails.WriteStartElement(rootElement);

        //                    writeUserDetails.WriteStartElement(loginParamsElement);
        //                    //Genesys Parameters Writing

        //                    #region Stat Properties

        //                    writeUserDetails.WriteStartElement("dbstatistics");
        //                    writeUserDetails.WriteStartElement("db.statname");

        //                    writeUserDetails.WriteElementString("db.displayname", "");
        //                    writeUserDetails.WriteElementString("db.threshold1", "");
        //                    writeUserDetails.WriteElementString("db.threshold2", "");
        //                    writeUserDetails.WriteElementString("db.color1", "");
        //                    writeUserDetails.WriteElementString("db.color2", "");
        //                    writeUserDetails.WriteElementString("db.color3", "");
        //                    writeUserDetails.WriteElementString("db.tooltipname", "");
        //                    writeUserDetails.WriteElementString("db.format", "");
        //                    writeUserDetails.WriteElementString("db.query", "");
        //                    writeUserDetails.WriteEndElement();
        //                    writeUserDetails.WriteEndElement();

        //                    #endregion

        //                    #region Enable Disable Channels

        //                    writeUserDetails.WriteStartElement("enable.disable-channels");

        //                    writeUserDetails.WriteElementString("statistics.enable-alwaysontop", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-ccstat-aid", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-log", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-maingadget", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-menu-button", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-mystat-aid", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-notification-balloon", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-notification-close", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-submenu-ccstatistics", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-submenu-close-gadget", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-submenu-mystatistics", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-submenu-ontop", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-tag-button", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-tag-vertical", "");
        //                    writeUserDetails.WriteElementString("statistics.enable-untag-button", "");

        //                    writeUserDetails.WriteEndElement();

        //                    #endregion

        //                    #region Logs

        //                    writeUserDetails.WriteStartElement("statistics.log");

        //                    writeUserDetails.WriteElementString("statistics.log.conversionpattern", "");
        //                    writeUserDetails.WriteElementString("statistics.log.datepattern", "");
        //                    writeUserDetails.WriteElementString("statistics.log.filepath", "");
        //                    writeUserDetails.WriteElementString("statistics.log.level", "");
        //                    writeUserDetails.WriteElementString("statistics.log.maxfilesize", "");
        //                    writeUserDetails.WriteElementString("statistics.log.maxrollbacksize", "");

        //                    writeUserDetails.WriteEndElement();

        //                    #endregion

        //                    writeUserDetails.WriteEndElement();

        //                    writeUserDetails.Close();
        //                    writeUserDetails = null;
        //                }
        //            }
        //        }


        //    }
        //    catch (Exception GeneralException)
        //    {
        //        System.Windows.Forms.MessageBox.Show("Exception Caught " + GeneralException.Message);
        //    }
        //    finally
        //    {
        //        GC.Collect();
        //    }
        //}

        #endregion

        public void StartStatisticsPipeListerner()
        {
            pipeThread = new Thread(() =>
            {
                //System.Windows.MessageBox.Show("Stat : Show");
                try
                {
                    bool exitCall = false;
                    NamedPipeServerStream namedPipeServerStream = new NamedPipeServerStream("AIDPipe_" + Settings.GetInstance().UserName, PipeDirection.InOut, 2, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);

                    while (true && !exitCall)
                    {
                        byte[] msgBuff;
                        while (true)
                        {
                            namedPipeServerStream.WaitForConnection();
                            if (namedPipeServerStream.IsConnected)
                            {
                                string data = null;
                                msgBuff     = new byte[8];
                                namedPipeServerStream.Read(msgBuff, 0, msgBuff.Length);
                                data = System.Text.Encoding.UTF8.GetString(msgBuff, 0, msgBuff.Length);
                                namedPipeServerStream.Disconnect();

                                Application.Current.Dispatcher.BeginInvoke((Action)(delegate
                                {
                                    try
                                    {
                                        if (data.Contains("1"))
                                        {
                                            //Show Gadget
                                            //System.Windows.MessageBox.Show("Stat : Show");
                                            logger.Debug("IndexPage : StartStatisticsPipeListerner : Show Gadget");
                                            StatisticsBase.GetInstance().isPlugin = true;
                                            if (Settings.GetInstance().mainview == null)
                                            {
                                                //Output = stat.ConfigConnectionEstablish(Host, Port, ApplicationName, UserName, Password, UserName, Settings.GetInstance().ApplicationType, String.Empty, true);
                                                //Output = StatisticsBase.GetInstance().ConfigConnectionEstablish(_dataContext.ApplicationName, _configContainer.ConfServiceObject, _dataContext.UserName, _dataContext.UserName, "StatServer", agentGroup);
                                                Settings.GetInstance().mainview = new MainWindow();
                                                if (Settings.GetInstance().mainVm == null)
                                                {
                                                    Settings.GetInstance().mainVm = new MainWindowViewModel();
                                                }
                                                Settings.GetInstance().mainview.DataContext = Settings.GetInstance().mainVm;
                                            }


                                            Settings.GetInstance().mainview.Show();
                                            Settings.GetInstance().mainVm.dragwindowInitialize(Settings.GetInstance().mainview);
                                        }
                                        else if (data.Contains("2"))
                                        {
                                            //Hide Gadget
                                            //System.Windows.MessageBox.Show("Stat : Hide");
                                            logger.Debug("IndexPage : StartStatisticsPipeListerner : Hide Gadget");
                                            StatisticsBase.GetInstance().isPlugin = true;
                                            if (Settings.GetInstance().mainVm != null)
                                            {
                                                Settings.GetInstance().mainVm.gadgetclose(false);
                                            }
                                        }
                                        if (data.Contains("3"))
                                        {
                                            //CLose Application if (Settings.GetInstance().mainVm == null)
                                            //System.Windows.MessageBox.Show("Stat : Close");
                                            logger.Debug("IndexPage : StartStatisticsPipeListerner : Close Gadget");
                                            StatisticsBase.GetInstance().isPlugin = true;
                                            if (Settings.GetInstance().mainVm != null)
                                            {
                                                Settings.GetInstance().mainVm.gadgetclose();
                                            }
                                            exitCall = true;
                                        }
                                        //if (data.Contains("4"))
                                        //{
                                        //    try
                                        //    {
                                        //        //Microsoft.Windows.Controls.MessageBox.Show("Display Object Config");

                                        //        var queueSelection = IsWindowOpen<Window>("ObjectConfigurations");
                                        //        if (queueSelection != null)
                                        //        {
                                        //            System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                        //            {
                                        //                queueSelection.Close();
                                        //                Settings.GetInstance().QueueConfigWin = new ObjectConfigWindow();
                                        //                Settings.GetInstance().QueueConfigVM = new ObjectConfigWindowViewModel();
                                        //                Settings.GetInstance().QueueConfigWin.DataContext = Settings.GetInstance().QueueConfigVM;
                                        //                Settings.GetInstance().QueueConfigWin.Show();
                                        //            });
                                        //        }
                                        //        else
                                        //        {
                                        //            System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                        //            {
                                        //                Settings.GetInstance().QueueConfigWin = new ObjectConfigWindow();
                                        //                Settings.GetInstance().QueueConfigVM = new ObjectConfigWindowViewModel();
                                        //                Settings.GetInstance().QueueConfigWin.DataContext = Settings.GetInstance().QueueConfigVM;
                                        //                Settings.GetInstance().QueueConfigWin.Show();
                                        //            });
                                        //        }

                                        //        //Microsoft.Windows.Controls.MessageBox.Show("Display Object Config");

                                        //        //var queueSelection = IsWindowOpen<Window>("ObjectConfigurations");
                                        //        //if (queueSelection != null)
                                        //        //{
                                        //        //    System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                        //        //    {
                                        //        //        Microsoft.Windows.Controls.MessageBox.Show("VM not null queue selection not null");
                                        //        //        queueSelection.Close();
                                        //        //        ObjectConfigWindow objView = new ObjectConfigWindow();
                                        //        //        objView.DataContext = Settings.GetInstance().QueueConfigVM;
                                        //        //        objView.Show();
                                        //        //    });
                                        //        //}
                                        //        //else
                                        //        //{
                                        //        //    System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                        //        //    {
                                        //        //        Microsoft.Windows.Controls.MessageBox.Show("VM not null queue selection null");
                                        //        //        ObjectConfigWindow objView = new ObjectConfigWindow();
                                        //        //        Settings.GetInstance().QueueConfigVM = new ObjectConfigWindowViewModel();
                                        //        //        objView.DataContext = Settings.GetInstance().QueueConfigVM;
                                        //        //        objView.Show();
                                        //        //    });
                                        //        //}


                                        //        ////if (Settings.GetInstance().ObjectConfigVM == null)
                                        //        ////{
                                        //        ////    Microsoft.Windows.Controls.MessageBox.Show("VM null");
                                        //        ////    ObjectConfigWindow objView = new ObjectConfigWindow();
                                        //        ////    Settings.GetInstance().ObjectConfigVM = new ObjectConfigWindowViewModel();
                                        //        ////    Settings.GetInstance().ObjectConfigVM.LoadObjectConfiguration();
                                        //        ////    objView.DataContext = Settings.GetInstance().ObjectConfigVM;
                                        //        ////    objView.Show();
                                        //        ////}
                                        //        ////else
                                        //        ////{
                                        //        ////    Microsoft.Windows.Controls.MessageBox.Show("VM not null ");

                                        //        ////    foreach (Window currentwindow in System.Windows.Application.Current.Windows)
                                        //        ////    {
                                        //        ////        if (currentwindow.Title == "ObjectConfigurations")
                                        //        ////        {
                                        //        ////            currentwindow.Show();
                                        //        ////        }
                                        //        ////    }
                                        //        ////    var queueSelection = IsWindowOpen<Window>("ObjectConfigurations");
                                        //        ////        if (queueSelection != null)
                                        //        ////        {
                                        //        ////            Microsoft.Windows.Controls.MessageBox.Show("VM not null queue selection not null");
                                        //        ////            queueSelection.Close();
                                        //        ////            ObjectConfigWindow objView = new ObjectConfigWindow();
                                        //        ////            objView.DataContext = Settings.GetInstance().ObjectConfigVM;
                                        //        ////            objView.Show();
                                        //        ////        }
                                        //        ////        else
                                        //        ////        {
                                        //        ////            Microsoft.Windows.Controls.MessageBox.Show("VM not null queue selection null");
                                        //        ////            ObjectConfigWindow objView = new ObjectConfigWindow();
                                        //        ////            objView.DataContext = Settings.GetInstance().ObjectConfigVM;
                                        //        ////            objView.Show();
                                        //        ////        }

                                        //        ////}
                                        //    }
                                        //    catch (Exception ex)
                                        //    {
                                        //        //Microsoft.Windows.Controls.MessageBox.Show("Exception opening : " + ex.Message);
                                        //        logger.Error("IndexPage : StartStatisticsPipeListerner Method : " + ex.Message);
                                        //    }
                                        //}
                                    }
                                    catch (Exception ex)
                                    {
                                        //System.Windows.MessageBox.Show("Indexpage 1 : " + ex.Message);
                                        logger.Error("IndexPage : StartStatisticsPipeListerner Method : " + ex.Message);
                                    }
                                }));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //System.Windows.MessageBox.Show("Indexpage : " + ex.Message);
                    logger.Error("IndexPage : StartStatisticsPipeListerner Method : " + ex.Message);
                }
            });
            pipeThread.Start();
        }
        /// <summary>
        /// Called when [next].
        /// </summary>
        /// <param name="value">The value.</param>
        public void OnNext(IStatisticsCollection value)
        {
            Request       statreq = new Request();
            List <string> tempThresholdValues;
            List <Color>  tempThresholdColors;

            try
            {
                logger.Debug("AgentStatisticsSubscriber : OnNext Method : Entry");
                if (value != null)
                {
                    if (value.AgentStatistics != null && value.AgentStatistics.Count != 0)
                    {
                        try
                        {
                            foreach (IAgentStatistics agentstat in value.AgentStatistics)
                            {
                                string[] configuredstat = value.StatisticsCommon.AgentStatistics.Split(',');
                                {
                                    foreach (string configstat in configuredstat)
                                    {
                                        if (configstat == agentstat.TempStatName)
                                        {
                                            string statName   = agentstat.StatisticsName.ToString();
                                            string filter     = agentstat.FilterName.ToString();
                                            string serverName = agentstat.ServerName.ToString();
                                            string format     = agentstat.StatisticsFormat.ToString();

                                            logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : ReferenceId - " + agentstat.ReferenceID);
                                            logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : StatName - " + statName);
                                            logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : ServerName - " + serverName);

                                            IMessage response;
                                            if (!StatisticsSetting.GetInstance().isAdmin)
                                            {
                                                if (agentstat.ReferenceID < StatisticsSetting.GetInstance().BAttributeReferenceId)
                                                {
                                                    logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : AgentEmpId - " + StatisticsSetting.GetInstance().AgentEmpId);
                                                    response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().AgentEmpId,
                                                                                   StatisticObjectType.Agent, statName, value.StatisticsCommon.NotifySeconds,
                                                                                   filter, value.StatisticsCommon.Insensitivity, agentstat.ReferenceID, serverName);
                                                }
                                                else
                                                {
                                                    //logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : AgentEmpId - " + StatisticsSetting.GetInstance().AgentEmpId);
                                                    response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().AgentEmpId,
                                                                                   StatisticObjectType.Agent, value.StatisticsCommon.NotifySeconds,
                                                                                   filter, configstat, agentstat.ReferenceID, serverName);
                                                }
                                            }
                                            else
                                            {
                                                if (!StatisticsSetting.GetInstance().RequestIds.Contains(agentstat.ReferenceID))
                                                {
                                                    StatisticsSetting.GetInstance().RequestIds.Add(agentstat.ReferenceID);
                                                }
                                                response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().IndividualAgent,
                                                                               StatisticObjectType.Agent, statName, value.StatisticsCommon.NotifySeconds,
                                                                               filter, value.StatisticsCommon.Insensitivity, agentstat.ReferenceID, serverName);
                                            }

                                            if (response != null)
                                            {
                                                statVariables = new StatVariables();
                                                switch (response.Id)
                                                {
                                                case EventStatisticOpened.MessageId:
                                                    EventStatisticOpened info;
                                                    info = (EventStatisticOpened)response;
                                                    statVariables.Statfilter  = filter;
                                                    statVariables.StatType    = StatisticObjectType.Agent.ToString();
                                                    statVariables.DisplayName = agentstat.DisplayName;
                                                    statVariables.Tooltip     = agentstat.ToolTipName;
                                                    statVariables.Statformat  = format;
                                                    statVariables.ObjectType  = agentstat.TempStatName;
                                                    statVariables.ObjectID    = StatisticsSetting.GetInstance().AgentEmpId;
                                                    statVariables.ReferenceId = info.ReferenceId.ToString();

                                                    tempThresholdValues = new List <string>();
                                                    tempThresholdValues.Add(agentstat.ThresholdLevelOne);
                                                    tempThresholdValues.Add(agentstat.ThresholdLevelTwo);

                                                    tempThresholdColors = new List <Color>();
                                                    tempThresholdColors.Add(agentstat.StatColor);
                                                    tempThresholdColors.Add(agentstat.ThresholdColorOne);
                                                    tempThresholdColors.Add(agentstat.ThresholdColorTwo);

                                                    StatisticsBase.GetInstance().IsMyStats = true;

                                                    if (!StatisticsSetting.GetInstance().ListRequestIds.Contains(agentstat.ReferenceID))
                                                    {
                                                        StatisticsSetting.GetInstance().ListRequestIds.Add(agentstat.ReferenceID);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().ThresholdValues.ContainsKey(agentstat.ReferenceID.ToString()))
                                                    {
                                                        StatisticsSetting.GetInstance().ThresholdValues.Add(agentstat.ReferenceID.ToString(), tempThresholdValues);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().ThresholdColors.ContainsKey(agentstat.ReferenceID.ToString()))
                                                    {
                                                        StatisticsSetting.GetInstance().ThresholdColors.Add(agentstat.ReferenceID.ToString(), tempThresholdColors);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().DictAllStats.ContainsKey(info.ReferenceId.ToString()))
                                                    {
                                                        StatisticsSetting.GetInstance().DictAllStats.Add(info.ReferenceId.ToString(), agentstat.TempStatName);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().agentStatisticsPluginHolder.ContainsKey(info.ReferenceId))
                                                    {
                                                        StatisticsSetting.GetInstance().agentStatisticsPluginHolder.Add(info.ReferenceId, statVariables);
                                                    }

                                                    StatisticsSetting.GetInstance().FinalAgentPackageID.Add(agentstat.ReferenceID);
                                                    break;

                                                case EventError.MessageId:
                                                    EventError eventError = (EventError)response;
                                                    logger.Error("AgentStatisticsSubscriber : OnNext Method : " + eventError.StringValue);
                                                    break;
                                                }
                                                statVariables = null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception generalException)
                        {
                            logger.Error("AgentStatisticsSubscriber : OnNext Method : " + generalException.Message);
                        }
                        finally
                        {
                            GC.Collect();
                        }
                    }
                }
            }
            catch (Exception GeneralException)
            {
                logger.Error("AgentStatisticsSubscriber : OnNext Method : " + GeneralException.Message);
            }
            finally
            {
                logger.Debug("AgentStatisticsSubscriber : OnNext Method : Exit");
                statreq = null;
            }
        }
        //#region Create StatserverConnection

        ///// <summary>
        ///// Creates the connection.
        ///// </summary>
        ///// <param name="host">The host.</param>
        ///// <param name="port">The port.</param>
        ///// <param name="backupHost">The backup host.</param>
        ///// <param name="backupPort">The backup port.</param>
        ///// <param name="addpServerTimeOut">The addp server time out.</param>
        ///// <param name="addpClientTimeOut">The addp client time out.</param>
        ///// <param name="agentIdentifier">The agent identifier.</param>
        ///// <param name="timeOut">The time out.</param>
        ///// <param name="attempts">The attempts.</param>
        ///// <returns></returns>
        //public StatServerProtocol CreateConnection(string host, string port, string backupHost,
        //    string backupPort, int addpServerTimeOut, int addpClientTimeOut, string agentIdentifier,
        //    int timeOut, short attempts)
        //{
        //    StatServerProtocol protocol = null;
        //    try
        //    {
        //        logger.Debug("ReportingServer : CreateConnection Method: Entry");
        //        logger.Info("Reporting Server AddpServerTimeOut : " + addpServerTimeOut);
        //        logger.Info("Reporting Server AddpClientTimeOut : " + addpClientTimeOut);
        //        Settings.statisticsProperties.Uri = new Uri("tcp://" + host + ":" + port);
        //        Settings.statisticsProperties.ClientName = "StatTicker_" + agentIdentifier;

        //        Settings.statisticsProperties.FaultTolerance = FaultToleranceMode.WarmStandby;
        //        Settings.statisticsProperties.WarmStandbyTimeout = timeOut;
        //        Settings.statisticsProperties.WarmStandbyAttempts = attempts;
        //        Settings.statisticsProperties.WarmStandbyUri = new Uri("tcp://" + backupHost +
        //            ":" + backupPort);

        //        Settings.statisticsProperties.UseAddp = true;
        //        Settings.statisticsProperties.AddpServerTimeout = addpServerTimeOut;
        //        Settings.statisticsProperties.AddpClientTimeout = addpClientTimeOut;
        //        Settings.statisticsProperties.AddpTrace = "both";


        //        Settings.rptProtocolManager.Register(Settings.statisticsProperties);

        //        protocol = (StatServerProtocol)Settings.rptProtocolManager[StatisticsSetting.StatServer];

        //        protocol.Received += StatisticsBase.GetInstance().ReportingSuccessMessage;

        //        //Settings.reportingBroker = new EventBrokerService(Settings.rptProtocolManager.Receiver);

        //        //Settings.reportingBroker.Activate();

        //        //Settings.reportingBroker.Register(StatisticsBase.GetInstance().ReportingSuccessMessage);

        //        Settings.rptProtocolManager[StatisticsSetting.StatServer].Open();


        //        if (Settings.rptProtocolManager[StatisticsSetting.StatServer].State == ChannelState.Opened)
        //        {
        //            logger.Trace("ReportingServer : CreateConnection Method : StatServer Connection Opened : " + Settings.statisticsProperties.ClientName);
        //        }
        //        else
        //        {
        //            logger.Warn("ReportingServer : CreateConnection Method: StatServer Connection Closed");
        //        }
        //    }
        //    catch (ProtocolException protocolException)
        //    {
        //        if (protocolException.Message == "Exception occured during channel opening")
        //        {
        //            logger.Error("ReportingServer : CreateConnection Method: " + protocolException.Message);
        //        }
        //    }
        //    catch (Exception generalException)
        //    {
        //        logger.Error("ReportingServer : CreateConnection Method: " + generalException.Message);
        //    }
        //    finally
        //    {
        //        logger.Debug("ReportingServer : CreateConnection Method: Exit");
        //        Settings.statisticsProperties = null;
        //        GC.Collect();
        //    }
        //    return protocol;
        //}

        //public void CloseStatServer()
        //{
        //    try
        //    {
        //        if (Settings.rptProtocolManager[StatisticsSetting.StatServer].State == ChannelState.Opened)
        //        {
        //            logger.Info("ReportingServer : Stat server protocol state : " + Settings.rptProtocolManager[StatisticsSetting.StatServer].State.ToString());
        //            Settings.rptProtocolManager[StatisticsSetting.StatServer].Close();
        //            logger.Info("ReportingServer : Stat server protocol has been closed.");
        //        }
        //        else
        //            logger.Info("ReportingServer : Stat server protocol is in " + Settings.rptProtocolManager[StatisticsSetting.StatServer].State + " state.");
        //    }

        //    catch (Exception ex)
        //    {
        //        logger.Error("Error occurred while closing the " + "Stat server protocol : " + ex.Message);
        //    }
        //}

        //#endregion

        #region Create StatserverConnection

        /// <summary>
        /// Creates the connection.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <param name="backupHost">The backup host.</param>
        /// <param name="backupPort">The backup port.</param>
        /// <param name="addpServerTimeOut">The addp server time out.</param>
        /// <param name="addpClientTimeOut">The addp client time out.</param>
        /// <param name="agentIdentifier">The agent identifier.</param>
        /// <param name="timeOut">The time out.</param>
        /// <param name="attempts">The attempts.</param>
        /// <returns></returns>
        public void CreateConnection(Uri primaryUri, Uri backupUri, int addpServerTimeOut, int addpClientTimeOut, string agentIdentifier, int timeout, short attempts, string protocolName)
        {
            if (Settings.statProtocols == null)
            {
                Settings.statProtocols = new List <StatServerProtocol>();
            }
            try
            {
                logger.Debug("ReportingServer : CreateConnection Method: Entry");
                logger.Info("Reporting Server : CreateConnection Method AddpServerTimeOut : " + addpServerTimeOut);
                logger.Info("Reporting Server : CreateConnection Method AddpClientTimeOut : " + addpClientTimeOut);
                logger.Info("Reporting Server : CreateConnection Method primaryUri : " + primaryUri);
                logger.Info("Reporting Server : CreateConnection Method StatProtocol Name : " + protocolName);
                Settings.statisticsProperties            = new StatServerConfiguration(protocolName);
                Settings.statisticsProperties.Uri        = primaryUri;
                Settings.statisticsProperties.ClientName = "StatTicker_" + agentIdentifier;

                Settings.statisticsProperties.FaultTolerance      = FaultToleranceMode.WarmStandby;
                Settings.statisticsProperties.WarmStandbyTimeout  = timeout;
                Settings.statisticsProperties.WarmStandbyAttempts = attempts;
                Settings.statisticsProperties.WarmStandbyUri      = backupUri;
                Settings.statisticsProperties.UseAddp             = true;
                Settings.statisticsProperties.AddpServerTimeout   = addpServerTimeOut;
                Settings.statisticsProperties.AddpClientTimeout   = addpClientTimeOut;
                Settings.statisticsProperties.AddpTrace           = "both";


                Settings.rptProtocolManager.Register(Settings.statisticsProperties);
                if (Settings.statProtocols != null)
                {
                    Settings.statProtocols.Add((StatServerProtocol)Settings.rptProtocolManager[protocolName]);
                }
                Settings.rptProtocolManager[protocolName].Received += StatisticsBase.GetInstance().ReportingSuccessMessage;

                //Settings.reportingBroker = new EventBrokerService(Settings.rptProtocolManager.Receiver);

                //Settings.reportingBroker.Activate();

                //Settings.reportingBroker.Register(StatisticsBase.GetInstance().ReportingSuccessMessage);

                Settings.rptProtocolManager[protocolName].Open();


                if (Settings.rptProtocolManager[protocolName].State == ChannelState.Opened)
                {
                    if (StatisticsSetting.GetInstance().serverNames == null)
                    {
                        StatisticsSetting.GetInstance().serverNames = new Dictionary <string, bool>();
                    }
                    if (!StatisticsSetting.GetInstance().serverNames.ContainsKey(protocolName))
                    {
                        StatisticsSetting.GetInstance().serverNames.Add(protocolName, true);
                    }
                    logger.Trace("ReportingServer : CreateConnection Method : StatServer Connection Opened");
                    logger.Info("Reporting Server : CreateConnection Method Stat Server Protocol : " + protocolName + "opened");
                }
                else
                {
                    logger.Warn("ReportingServer : CreateConnection Method: StatServer Connection Closed");
                    logger.Warn("Reporting Server : CreateConnection Method Stat Server Protocol : " + protocolName + "closed");
                }
            }
            catch (ProtocolException protocolException)
            {
                if (protocolException.Message == "Exception occured during channel opening")
                {
                    logger.Error("ReportingServer : CreateConnection Method: " + protocolException.Message);
                }
            }
            catch (Exception generalException)
            {
                logger.Error("ReportingServer : CreateConnection Method: " + generalException.Message);
            }
            finally
            {
                logger.Debug("ReportingServer : CreateConnection Method: Exit");
                Settings.statisticsProperties = null;
                GC.Collect();
            }
        }
Ejemplo n.º 11
0
 public static void CloseStatProtocol()
 {
     StatisticsBase.GetInstance().CloseStatistics();
 }
        /// <summary>
        /// Called when [next].
        /// </summary>
        /// <param name="value">The value.</param>
        public void OnNext(IStatisticsCollection value)
        {
            Request       statreq = new Request();
            List <string> tempThresholdValues;
            List <Color>  tempThresholdColors;
            int           tempRefid = StatisticsSetting.GetInstance().ReferenceId + 150;

            try
            {
                logger.Debug("VQStatisticsSubscriber : OnNext Method : Entry");
                if (value != null)
                {
                    if (value.VirtualQueueStatistics != null && value.VirtualQueueStatistics.Count != 0)
                    {
                        try
                        {
                            string[] VQueues = value.StatisticsCommon.VQueueObjects.Split(',');
                            foreach (string vqueue in VQueues)
                            {
                                StatisticsSetting.GetInstance().VQueueListCollections.Add(vqueue);
                            }

                            foreach (IVirtualQueueStatistics vqstat in value.VirtualQueueStatistics)
                            {
                                string[] configuredstat = value.StatisticsCommon.VQueueStatistics.Split(',');
                                {
                                    foreach (string configstat in configuredstat)
                                    {
                                        if (configstat == vqstat.TempStatName)
                                        {
                                            for (int VQIndex = 0; VQIndex < StatisticsSetting.GetInstance().VQueueListCollections.Count; VQIndex++)
                                            {
                                                string   Dilimitor = "_@";
                                                string[] vq_Switch = StatisticsSetting.GetInstance().VQueueListCollections[VQIndex].Split(new[] { Dilimitor }, StringSplitOptions.None);

                                                string statName   = vqstat.StatisticsName.ToString();
                                                string filter     = vqstat.FilterName.ToString();
                                                string serverName = vqstat.ServerName.ToString();
                                                string format     = vqstat.StatisticsFormat.ToString();

                                                //if (string.Compare(vqstat.TempStatName, vq_Switch[2].ToString(), true) == 0)
                                                {
                                                    logger.Info("VQStatisticsSubscriber : OnNext Method : Request : ReferenceId - " + tempRefid);
                                                    logger.Info("VQStatisticsSubscriber : OnNext Method : Request : StatName - " + statName);
                                                    logger.Info("VQStatisticsSubscriber : OnNext Method : Request : VQueueName - " + vq_Switch[0] + "@" + vq_Switch[1]);
                                                    logger.Info("VQStatisticsSubscriber : OnNext Method : Request : serverName - " + serverName);
                                                    IMessage response;
                                                    if (tempRefid < StatisticsSetting.GetInstance().BAttributeReferenceId)
                                                    {
                                                        response = statreq.StatRequest(value.StatisticsCommon.TenantName, vq_Switch[0] + "@" + vq_Switch[1],
                                                                                       StatisticObjectType.Queue, statName, value.StatisticsCommon.NotifySeconds,
                                                                                       filter, value.StatisticsCommon.Insensitivity, tempRefid, serverName);
                                                    }
                                                    else
                                                    {
                                                        response = statreq.StatRequest(value.StatisticsCommon.TenantName, vq_Switch[0] + "@" + vq_Switch[1],
                                                                                       StatisticObjectType.Queue, value.StatisticsCommon.NotifySeconds,
                                                                                       filter, configstat, tempRefid, serverName);
                                                    }


                                                    logger.Info("VQStatisticsSubscriber : OnNext Method : Request : " + response.ToString());

                                                    if (response != null)
                                                    {
                                                        statVariables = new StatVariables();
                                                        switch (response.Id)
                                                        {
                                                        case EventStatisticOpened.MessageId:
                                                            EventStatisticOpened info;
                                                            info = (EventStatisticOpened)response;
                                                            statVariables.Statfilter = filter;
                                                            statVariables.StatType   = StatisticObjectType.Queue.ToString();
                                                            //statVariables.DisplayName = vqstat.DisplayName;
                                                            statVariables.Tooltip     = vqstat.ToolTipName;
                                                            statVariables.Statformat  = format;
                                                            statVariables.ObjectType  = vqstat.TempStatName;
                                                            statVariables.ReferenceId = info.ReferenceId.ToString();

                                                            string[] tempQueueName = StatisticsSetting.GetInstance().VQueueListCollections[VQIndex].Split(new[] { Dilimitor }, StringSplitOptions.None);
                                                            statVariables.DisplayName = vqstat.DisplayName;
                                                            if (StatisticsBase.GetInstance().QueueDisplayName == StatisticsEnum.ACDDisplayName.Queue.ToString() || StatisticsBase.GetInstance().QueueDisplayName == StatisticsEnum.ACDDisplayName.RoutingPoint.ToString())
                                                            {
                                                                statVariables.ObjectID = tempQueueName[0].ToString();
                                                                statVariables.CCStat   = vqstat.DisplayName + " " + tempQueueName[0].ToString();
                                                            }
                                                            else if (StatisticsBase.GetInstance().QueueDisplayName == StatisticsEnum.ACDDisplayName.Skill.ToString())
                                                            {
                                                                statVariables.ObjectID = tempQueueName[1].ToString();
                                                                statVariables.CCStat   = vqstat.DisplayName + " " + tempQueueName[1].ToString();
                                                            }
                                                            else
                                                            {
                                                                statVariables.ObjectID = tempQueueName[0].ToString();
                                                                statVariables.CCStat   = vqstat.DisplayName + " " + tempQueueName[0].ToString();
                                                            }

                                                            tempThresholdValues = new List <string>();
                                                            tempThresholdValues.Add(vqstat.ThresholdLevelOne);
                                                            tempThresholdValues.Add(vqstat.ThresholdLevelTwo);

                                                            tempThresholdColors = new List <Color>();
                                                            tempThresholdColors.Add(vqstat.StatColor);
                                                            tempThresholdColors.Add(vqstat.ThresholdColorOne);
                                                            tempThresholdColors.Add(vqstat.ThresholdColorTwo);

                                                            StatisticsBase.GetInstance().IsCCStats = true;

                                                            if (!StatisticsSetting.GetInstance().ThresholdValues.ContainsKey(info.ReferenceId.ToString()))
                                                            {
                                                                StatisticsSetting.GetInstance().ThresholdValues.Add(info.ReferenceId.ToString(), tempThresholdValues);
                                                            }

                                                            if (!StatisticsSetting.GetInstance().ThresholdColors.ContainsKey(info.ReferenceId.ToString()))
                                                            {
                                                                StatisticsSetting.GetInstance().ThresholdColors.Add(info.ReferenceId.ToString(), tempThresholdColors);
                                                            }

                                                            if (!StatisticsSetting.GetInstance().DictAllStats.ContainsKey(info.ReferenceId.ToString()))
                                                            {
                                                                StatisticsSetting.GetInstance().DictAllStats.Add(info.ReferenceId.ToString(), vqstat.TempStatName);
                                                            }

                                                            if (!StatisticsSetting.GetInstance().VQStatisticsValueHolder.ContainsKey(info.ReferenceId))
                                                            {
                                                                StatisticsSetting.GetInstance().VQStatisticsValueHolder.Add(info.ReferenceId, statVariables);
                                                            }

                                                            StatisticsSetting.GetInstance().FinalVQPackageID.Add(info.ReferenceId);
                                                            break;

                                                        case EventError.MessageId:
                                                            EventError eventError = (EventError)response;
                                                            logger.Error("VQStatisticsSubscriber : OnNext Method: " + eventError.StringValue);
                                                            break;
                                                        }
                                                        statVariables = null;
                                                    }
                                                    tempRefid++;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception generalException)
                        {
                            logger.Error("VQStatisticsSubscriber : OnNext Method : " + generalException.Message);
                        }
                        finally
                        {
                            GC.Collect();
                        }
                    }
                }
            }
            catch (Exception GeneralException)
            {
                logger.Error("VQStatisticsSubscriber : OnNext Method : " + GeneralException.Message);
            }
            finally
            {
                logger.Debug("VQStatisticsSubscriber : OnNext Method : Exit");
                statreq = null;
            }
        }
        /// <summary>
        /// Shows the gadget.
        /// </summary>
        /// <param name="isStartup"></param>
        public void ShowGadget(bool isStartup)
        {
            bool isOpened = false;

            StatisticsBase.GetInstance().isPlugin      = true;
            StatisticsBase.GetInstance().isGadgetClose = false;

            try
            {
                logger.Debug("PluginContainer : ShowGadget : Method Entry");

                if (StatisticsBase.GetInstance().IsMandatoryFieldsMissing)
                {
                    if (!isStartup)
                    {
                        string Message            = string.Empty;
                        int    CurrentErrrorCount = 1;
                        foreach (string MissingKeys in StatisticsBase.GetInstance().ListMissedValues)
                        {
                            if (CurrentErrrorCount <= (StatisticsBase.GetInstance().ErrorCount == 0 ? 3 : StatisticsBase.GetInstance().ErrorCount))
                            {
                                if (Message == string.Empty)
                                {
                                    Message = "'" + MissingKeys + "' value is Missing";
                                }
                                else
                                {
                                    Message = Message + "\n '" + MissingKeys + "' value is Missing";
                                }
                            }
                            CurrentErrrorCount++;
                        }
                        Views.MessageBox    msgbox        = new Views.MessageBox();
                        MessageBoxViewModel mboxviewmodel = new MessageBoxViewModel("Problem Encountered in Statistics", Message, msgbox, "MainWindow", Settings.GetInstance().Theme);
                        msgbox.DataContext = mboxviewmodel;
                        msgbox.ShowDialog();
                    }
                }
                else if (!isAuthenticated)
                {
                    if (!isStartup)
                    {
                        Views.MessageBox    msgbox        = new Views.MessageBox();
                        MessageBoxViewModel mboxviewmodel = new MessageBoxViewModel("Problem Encountered in Statistics", Settings.GetInstance().DictErrorValues["user.authorization"].ToString(), msgbox, "MainWindow", Settings.GetInstance().Theme);
                        msgbox.DataContext = mboxviewmodel;
                        msgbox.ShowDialog();
                    }
                }
                else
                {
                    Application.Current.Dispatcher.BeginInvoke((Action)(delegate
                    {
                        //foreach (Window appwindow in Application.Current.Windows)
                        //{
                        //    if (appwindow.Title == "StatGadget")
                        //    {
                        //        //
                        //        isOpened = true;
                        //        if (Settings.GetInstance().isMinimized)
                        //        {
                        //            Settings.GetInstance().isMinimized = false;

                        //            appwindow.WindowState = WindowState.Maximized;
                        //            appwindow.Show();
                        //        }
                        //        else
                        //            appwindow.Show();
                        //        stat.ShowGadgetState(Pointel.Statistics.Core.Utility.StatisticsEnum.GadgetState.Opened);

                        //        break;
                        //    }
                        //}

                        MainWindow mainview = new MainWindow();
                        MainWindowViewModel mainVm = new MainWindowViewModel();
                        mainview.DataContext = mainVm;

                        mainview.Show();
                        mainVm.dragwindowInitialize(mainview);


                        if (!isOpened)
                        {
                            // MainWindow mainview = new MainWindow();
                            mainVm = new MainWindowViewModel();
                            mainview.DataContext = mainVm;
                            mainview.Show();
                            stat.ShowGadgetState(Pointel.Statistics.Core.Utility.StatisticsEnum.GadgetState.Opened);
                            // Window window = Application.Current.Windows[0];
                            //comment removed
                            // if (window != null)
                            mainVm.dragwindowInitialize(mainview);
                        }
                    }), DispatcherPriority.Background);
                }
            }
            catch (Exception GeneralException)
            {
                logger.Error("PluginContainer : ShowGadget Method : Exception Caught : " + GeneralException.Message);
            }
            finally
            {
                logger.Debug("PluginContainer : ShowGadget : Method Exit");
            }
        }
Ejemplo n.º 14
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            try
            {
                string AIDValues = string.Empty;
                if (e.Args.Length != 0)
                {
                    string user = string.Empty, pwd = string.Empty, app = string.Empty, host = string.Empty, port = string.Empty, place = string.Empty;
                    //AIDValues = e.Args;
                    //AIDValues = "UserName:Gibran,Password:g,AppName:AID_PHS,Host:192.168.200.125,Port:2020,Place:AP3111,IsConfigQueue:True";
                    string[] Arguments = e.Args[0].Split(',');
                    //string[] Arguments = AIDValues.Split(',');
                    //string samp = "UserName:Alonda, Password:,AppName:AID,Host:192.168.200.125,Port:2020,Place:AP3107";
                    //string[] Arguments = samp.Split(',') ;
                    //foreach (var item in Arguments)
                    //    AIDValues += item + Environment.NewLine;
                    //System.Windows.MessageBox.Show("args: " + string.Join(", ", e.Args));
                    foreach (string args in Arguments)
                    {
                        string[] values;

                        if (!string.IsNullOrEmpty(args))
                        {
                            if (args.Contains(":"))
                            {
                                values = args.Split(':');
                                //System.Windows.MessageBox.Show("StatTickerFive Application StartUp: " + values[1].ToString());

                                switch (values[0])
                                {
                                case "UserName":
                                    user = values[1];
                                    break;

                                case "Password":
                                    pwd = values[1];
                                    break;

                                case "AppName":
                                    app = values[1];
                                    break;

                                case "Host":
                                    host = values[1];
                                    break;

                                case "Port":
                                    port = values[1];
                                    break;

                                case "Place":
                                    place = values[1];
                                    break;

                                case "IsConfigQueue":
                                    Settings.GetInstance().IsQueueSelect = Convert.ToBoolean(values[1]);
                                    break;

                                case "IsGadgetShow":
                                    Settings.GetInstance().IsGadgetShow = Convert.ToBoolean(values[1]);
                                    break;

                                case "AddpServerTimeOut":
                                    Settings.GetInstance().AddpServerTimeOut = Convert.ToInt32(values[1]);
                                    break;

                                case "AddpClientTimeOut":
                                    Settings.GetInstance().AddpClientTimeOut = Convert.ToInt32(values[1]);
                                    break;
                                }
                            }
                        }
                    }

                    // Microsoft.Windows.Controls.MessageBox.Show("Exiting for each");

                    if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(app) && !string.IsNullOrEmpty(host) && !string.IsNullOrEmpty(port) && !string.IsNullOrEmpty(place))
                    {
                        LoginWindowViewModel objLoginVM = new LoginWindowViewModel();
                        objLoginVM.UserName = user;
                        Settings.GetInstance().UserName = user;
                        objLoginVM.Password        = pwd;
                        objLoginVM.ApplicationName = app;
                        objLoginVM.Host            = host;
                        objLoginVM.Port            = port;
                        objLoginVM.Place           = place;
                        Settings.GetInstance().ApplicationType       = Pointel.Statistics.Core.Utility.StatisticsEnum.StatSource.StatServer.ToString();
                        Settings.GetInstance().DefaultAuthentication = Pointel.Statistics.Core.Utility.StatisticsEnum.StatSource.StatServer.ToString();
                        Settings.GetInstance().Theme = "Outlook8";
                        //OutputValues output = new OutputValues();
                        //output = StatisticsBase.GetInstance().ConfigConnectionEstablish(host, port, app, user, pwd, user, "StatServer", String.Empty, true);
                        Helpers.IndexPage objIndexPage = new Helpers.IndexPage();
                        objIndexPage.StartStatisticsPipeListerner();
                        StatisticsBase.GetInstance().isPlugin = true;
                        //Microsoft.Windows.Controls.MessageBox.Show("Login");
                        objLoginVM.Login();
                    }
                    else
                    {
                        LoginUsual();
                        Settings.GetInstance().IsGadgetShow = true;
                    }
                }
                else
                {
                    Settings.GetInstance().IsGadgetShow = true;
                    LoginUsual();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("StatTickerFive Application StartUp: " + ex.Message);
            }
        }