#pragma warning restore CS0649

        public static double?GetOrganizationSentiment(int organizationID, int parentId)
        {
            double?result = null;

            try
            {
                Organization parentOrganization = Organizations.GetOrganization(LoginUser.Anonymous, parentId);

                if (parentOrganization != null && parentOrganization.UseWatson)
                {
                    using (SqlConnection connection = new SqlConnection(LoginUser.GetConnectionString(-1)))
                        using (DataContext db = new DataContext(connection))
                        {
                            Table <OrganizationSentiment> table = db.GetTable <OrganizationSentiment>();
                            double[] rows = (from sentiment in table
                                             where (sentiment.OrganizationID == organizationID) && !sentiment.IsAgent
                                             select sentiment.OrganizationSentimentScore).ToArray();
                            if (rows.Length > 0)
                            {
                                result = rows[0];
                            }
                        }
                }
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("Application", "Exception caught at OrganizationSentiment:" + e.Message + " ----- STACK: " + e.StackTrace.ToString());
                Console.WriteLine(e.ToString());
            }
            return(result);
        }
        static int OrganizationSentiment(int organizationID)
        {
            double result = 0;

            try
            {
                using (SqlConnection connection = new SqlConnection(LoginUser.GetConnectionString(-1)))
                    using (DataContext db = new DataContext(connection))
                    {
                        Table <TicketSentiment> ticketSentimentTable = db.GetTable <TicketSentiment>();
                        result = (from sentiment in ticketSentimentTable where (sentiment.OrganizationID == organizationID) && !sentiment.IsAgent select sentiment.TicketSentimentScore).Average();
                    }
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("Application", "Exception caught at OrganizationSentiment:" + e.Message + " ----- STACK: " + e.StackTrace.ToString());
                Console.WriteLine(e.ToString());
            }
            return((int)Math.Round(result));
        }
Exemplo n.º 3
0
 private void button3_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LoginUser.GetConnectionString());
 }