Exemple #1
14
        private void btnDelete_Click_1(object sender, EventArgs e)
        {
            string message = String.Empty;
            StudentServiceClient studentService = new StudentServiceClient();
            if (studentService.DismissStudent(studentSelected.StudentId, ref message)) {
                LogServiceClient logService = new LogServiceClient();
                studentSelected.Dismissed = true;
                string json = JsonConvert.SerializeObject(studentSelected);
                Log log = new Log
                {
                    CLUD = "D",
                    LogDate = DateTime.Now,
                    TableName = "Students",
                    UserId = GlobalClass.user.UserId,
                    UserName = GlobalClass.user.UserName,
                    PassedData = json
                };
                logService.AddLogs(log);

            }

            MessageBox.Show(this, "Student Dismissed");
        }
        static void Main(string[] args)
        {
            //configure
            Sdk.LOG_SERVICE_APP_UNICID = "4F59CB0433Z1C221869268";
            Sdk.LOG_SERVICE_API_KEY    = "4F59695A496E4853357468";

            //initialise service callback (passing true will make all service call to be performed asynchronously)
            LogServiceClient.Initialise(new LogNotifactionReceiver(), true);

            //save log with custom fields
            Dictionary <String, String> custom_fields = new Dictionary <string, string>();

            custom_fields.Add("Calibre", "58");
            custom_fields.Add("FPS", "110");
            LogServiceClient.warn("C#", "a log from c#", "*****@*****.**", custom_fields);


            //save log without fields
            LogServiceClient.warn("C#", "a log from c#", "*****@*****.**");

            //get logs by page (first page)
            LogServiceClient.get(1);

            //delete log
            LogServiceClient.delete(38);
        }
Exemple #3
0
        public static void WriteLogAsync(this LogServiceClient client, string message, long timeStamp
                                         , LogLevel logLevel       = LogLevel.Error
                                         , string action           = null, string accountId = null
                                         , string hostName         = null, string clientIp  = null
                                         , ServiceType serviceType = ServiceType.Unknown, Developer developer  = Developer.Undefined
                                         , Exception exception     = null, IDictionary <string, string> extras = null)
        {
            var mingLog = new MingLog()
            {
                Message   = message,
                TimeStamp = timeStamp,

                HostName    = hostName,
                ClientIp    = clientIp,
                ServiceType = serviceType,
                Developer   = developer,
                Action      = action,
                Level       = logLevel,
                AccountId   = accountId,
                Stack       = exception?.StackTrace,
            };

            if (extras != null)
            {
                foreach (var i in extras)
                {
                    mingLog.Extras.Add(extras);
                }
            }

            client.WriteLogAsync(mingLog);
        }
        private static void ProcessRobot(object state)
        {
            var process = state as WebRobotProcess;
            var robot   = process.WebRobot;

            try
            {
                robot.InitializeHttpCommand();
                robot.Status = WebRobotManagementStatus.RUNNING;
                robot.Start();

                // ended
                Thread.CurrentThread.Abort();
            }
            catch (ThreadAbortException abort)
            {
                robot.Status = WebRobotManagementStatus.STOPPED;
            }
            catch (Exception ex)
            {
                robot.Status = WebRobotManagementStatus.ERROR;
                Log.Error("Oso Fx: " + robot.Name + " robot", ex);
                LogServiceClient log = new LogServiceClient();
                log.WriteLog(new WebRobotStreamLogLine[]
                {
                    new WebRobotStreamLogLine
                    {
                        Line      = ex.ToString(),
                        RobotName = robot.Name,
                        Timestamp = DateTime.Now
                    }
                });
            }
        }
        void LogToService(LogDetails logDetails)
        {
            LogServiceClient client = null;

            try
            {
                client = new LogServiceClient(WebConfigurationManager.AppSettings[Constants.FINLOGSERVICE_ENDPOINT]);
                client.Open();
                client.CreateLogEntry(logDetails);
            }
            finally
            {
                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    try
                    {
                        client.Close();
                    }
                    catch
                    {
                    }
                }
                client = null;
            }
        }
Exemple #6
0
        private void butLogin_Click(object sender, EventArgs e)
        {
            UserServiceClient userService = new UserServiceClient();
            string message = String.Empty;
            if (txtPassword.Text.Equals("Enter Password")||txtPassword.Text.Equals(String.Empty) || txtUsername.Text.Equals("Enter Username")|| txtUsername.Text.Equals(String.Empty))
            {
                MessageBox.Show(this, "Username and Password is Required", "Required Fields");

            }
            else
            {
                if (userService.AuthenticateUser(txtUsername.Text, txtPassword.Text, ref message))
                {
                    //try
                    //{
                        eSAR.UserServiceRef.User u = new eSAR.UserServiceRef.User();
                        u = userService.GetUser(txtUsername.Text);
                        LoggedUser lu = new LoggedUser();

                        lu.UserId = u.UserId;
                        lu.UserName = u.UserName;
                        lu.LastName = u.LastName;
                        lu.FirstName = u.FirstName;
                        lu.MiddleName = u.MiddleName;
                        lu.UserType = u.UserTypeCode;

                        GlobalClass.UserLoggedIn = true;
                        GlobalClass.user = lu;
                        GlobalClass.currentsy = userService.GetCurrentSy();
                    GlobalClass.userTypeCode = lu.UserType;

                    LogServiceClient logService = new LogServiceClient();
                    string json = JsonConvert.SerializeObject(lu);
                    Log log = new Log
                    {
                        CLUD = "L",
                        LogDate = DateTime.Now,
                        TableName = "Users",
                        UserId = GlobalClass.user.UserId,
                        UserName = GlobalClass.user.UserName,
                        PassedData = json
                    };
                    logService.AddLogs(log);
                    Close();
                    //}
                    //catch (Exception ex)
                    //{
                    //    Console.WriteLine("Login Failed");
                    //}
                }
                else MessageBox.Show(this, message, "Login Failed");
                //frmLogIn FrmLogin = new frmLogIn();
                //FrmLogin.Show();
            }
            //this.Show();
            //frmLogIn FrmLogin = new frmLogIn();
            //FrmLogin.Show();
        }
Exemple #7
0
            public ConnectionWithContext(C1Connection connection)
            {
                _client = new LogServiceClient(connection.Binding, connection.EndpointAddress);
                _operationContextScope = new OperationContextScope(_client.InnerChannel);

                var           mhg       = new MessageHeader <string>(connection._authenticationInfo.AuthToken);
                MessageHeader authToken = mhg.GetUntypedHeader("AuthToken", "Composite.Logger");

                OperationContext.Current.OutgoingMessageHeaders.Add(authToken);
            }
Exemple #8
0
 public static void WriteLogAsync(this LogServiceClient client, string message, DateTime?timeStamp = null
                                  , LogLevel logLevel       = LogLevel.Error
                                  , string action           = null, string accountId = null
                                  , string hostName         = null, string clientIp  = null
                                  , ServiceType serviceType = ServiceType.Unknown, Developer developer  = Developer.Undefined
                                  , Exception exception     = null, IDictionary <string, string> extras = null)
 {
     client.WriteLogAsync(message, (timeStamp?.ToTickTimeStamp() ?? DateTime.Now.ToTickTimeStamp())
                          , logLevel
                          , action, accountId, hostName, clientIp, serviceType, developer, exception, extras);
 }
Exemple #9
0
        private static LogServiceClient CreateBasicHttpConnection(string url)
        {
            var uri = new Uri(url);

            var binding = CreateBasicHttpBinding(url);

            var endPoindAddress = new EndpointAddress(uri);

            var client = new LogServiceClient(binding, endPoindAddress);

            return(client);
        }
Exemple #10
0
        public LogSource(string sourceClassName)
        {
            this.SourceClassName = sourceClassName;

            var config = RantaConfigManager.GetConfig();

            this.ServiceClient = new LogServiceClient("LogServiceEndpoint");

            if (config != null)
            {
                this.AppId = config.AppId;
            }
        }
 private void TrySendLogToAdministratorPanel(string log)
 {
     try
     {
         var adminPanel = new LogServiceClient("LOG");
         adminPanel.RecieveLog(_networkNode.GetId().Id, log);
         adminPanel.Close();
     }
     catch (Exception ex)
     {
         EventLogHelper.WriteErrorToEventLog(ex);
     }
 }
Exemple #12
0
        public static void FatalError(this LogServiceClient client, string message
                                      , string action           = null, string accountId = null
                                      , ServiceType serviceType = ServiceType.Unknown, Developer developer  = Developer.Undefined
                                      , Exception exception     = null, IDictionary <string, string> extras = null)
        {
            //Default logLevel,timeStamp,hostName,clientIp
            var logLevel  = LogLevel.Fatal;
            var timeStamp = DateTime.Now.ToTickTimeStamp();
            var hostName  = GetHostName();
            var clientIp  = GetClientIp();

            client.WriteLogAsync(message, timeStamp, logLevel
                                 , action, accountId, hostName, clientIp, serviceType, developer, exception, extras);
        }
Exemple #13
0
        protected void btnAddLog_Click(object sender, EventArgs e)
        {
            Log lg = new Log();
            LogServiceClient lsc = new LogServiceClient();

            lg.TeamName    = txtL_TeamName.Text;
            lg.Position    = Convert.ToInt32(txtL_Pos.Text);
            lg.MatchPlayed = Convert.ToInt32(txtL_MPlayed.Text);
            lg.Wins        = Convert.ToInt32(txtL_Wins.Text);
            lg.Loose       = Convert.ToInt32(txtL_Lose.Text);
            lg.Draws       = Convert.ToInt32(txtL_Draws.Text);
            lg.Points      = Convert.ToInt32(txtL_Points.Text);
            lg.League_ID   = 1;
            string res = lsc.CreateLog(lg);
        }
 public void Write(LogEvent log)
 {
     using (LogServiceClient client = new LogServiceClient())
     {
         LogService.LogEvent l = new LogService.LogEvent();
         l.AppId = log.AppId;
         l.Caption = log.Caption;
         l.IPAddress = log.IPAddress;
         l.Level = (LogService.LogLevel)log.Level;
         l.LogTime = log.LogTime;
         l.Message = log.Message;
         l.Reporter = log.Reporter;
         l.SystemInfo = log.SystemInfo;
         client.Write(l);
     }
 }
Exemple #15
0
 /// <summary>
 /// 获取一个Client实例(单例)
 /// </summary>
 /// <param name="serviceUrl"></param>
 /// <returns></returns>
 public static LogServiceClient GetClient(string serviceUrl)
 {
     if (!string.IsNullOrEmpty(serviceUrl))
     {
         if (!ClientCache.ContainsKey(serviceUrl))
         {
             lock (syncObj)
             {
                 if (!ClientCache.ContainsKey(serviceUrl))
                 {
                     var channel = new Channel(serviceUrl, ChannelCredentials.Insecure);
                     ClientCache[serviceUrl] = new LogServiceClient(channel);
                 }
             }
         }
         return(ClientCache[serviceUrl]);
     }
     return(null);
 }
Exemple #16
0
        public static void RunService()
        {
            try
            {
                // Start WCF REST Service
                ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IWebRobotService), new WebHttpBinding(), "");
                host.Description.Behaviors.Find <ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;
                host.Description.Behaviors.Find <ServiceDebugBehavior>().HttpHelpPageEnabled            = false;

                host.Open();
                PingService();
                Log.Info("OsoFx Service is running at " + ConfigurationManager.AppSettings["OsoFx.ServiceUrl"]);
                Console.WriteLine("OsoFx Service is running at {0}", ConfigurationManager.AppSettings["OsoFx.ServiceUrl"]);
                Console.WriteLine("Press ANY KEY to exit");
                Console.Read();
                host.Close();

                LogServiceClient logclient = new LogServiceClient();
                logclient.WriteLog(new WebRobotStreamLogLine[]
                {
                    new WebRobotStreamLogLine
                    {
                        Line      = "service closed",
                        RobotName = "all",
                        Timestamp = DateTime.Now
                    }
                });
                logclient.PingStatus("all", WebRobotManagementStatus.STOPPED);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                Log.Error(ex);
            }
        }
Exemple #17
0
        public Fliter()
        {
            #region init parms
            this.shortTimeSpan = int.Parse(System.Configuration.ConfigurationManager.AppSettings["shortTimeSpan"]);
            this.shortTimeQueryTimes = int.Parse(System.Configuration.ConfigurationManager.AppSettings["shortTimeQueryTimes"]);
            this.timesForOneDay = int.Parse(System.Configuration.ConfigurationManager.AppSettings["timesForOneDay"]);

            this.WhiteList = new List<WhiteNote>();
            this.BlackList = new List<BlackNote>();
            this.TodayLogList = new List<QueryLog>();
            this.LastHundreLogList = new List<QueryLog>();
            #endregion

            #region 同步黑白名单
            FliterServiceClient fClient = new FliterServiceClient();
            LogServiceClient lClient = new LogServiceClient();

            lClient.Open();
            fClient.Open();

            this.BlackList = fClient.GetBlackNoteList().Where(n => n.Flg).ToList();
            this.WhiteList = fClient.GetWhiteNoteList().Where(n => n.Flg).ToList();
            #endregion
        }
        private static LogServiceClient CreateBasicHttpConnection(string url)
        {
            var uri = new Uri(url);

            var binding = new BasicHttpBinding("BasicHttpBinding_ILogService");

            var endPoindAddress = new EndpointAddress(uri);

            var client = new LogServiceClient(binding, endPoindAddress);

            return client;
        }
            public ConnectionWithContext(C1Connection connection)
            {
                _client = new LogServiceClient(connection.Binding, connection.EndpointAddress);
                _operationContextScope = new OperationContextScope(_client.InnerChannel);

                var mhg = new MessageHeader<string>(connection._authenticationInfo.AuthToken);
                MessageHeader authToken = mhg.GetUntypedHeader("AuthToken", "Composite.Logger");

                OperationContext.Current.OutgoingMessageHeaders.Add(authToken);
            }
 private async void QueryLogExec()
 {
     LogService.LogServiceClient lc = new LogServiceClient();
     this.count = int.Parse(System.Configuration.ConfigurationManager.AppSettings["logCount"]);
     try
     {
         lc.Open();
         //TODO Set the method async, set UI waiting.
         var queryTask = lc.QueryLogQueryTakeAsync(this.QueryLogArgs, 0, count, this.IsWithKeepLine);
         this.QueryLogList = (await queryTask).OrderByDescending(l => l.OptionDate).ToList();
     }
     catch (Exception ex)
     {
         Messenger.Default.Send<GenericMessage<string>>(new GenericMessage<string>(ex.Message), "querySysLogError");
     }
     finally
     {
         lc.Close();
     }
     //TODO Set UI to be free.
 }
Exemple #21
0
        //Create Dynamic Log List table
        //private void CreateDynamicTable(int Rows, List<Log> log)
        //{
        //    PlaceHolder1.Controls.Clear();
        //    // Fetch the number of Rows and Columns for the table
        //    // using the properties
        //    int tblRows = Rows;
        //    // Create a Table and set its properties
        //    Table tbl = new Table();
        //    // Add the table to the placeholder control
        //    PlaceHolder1.Controls.Add(tbl);
        //    // Now iterate through the table and add your controls
        //    for (int i = 0; i <= tblRows; i++)
        //    {
        //        TableRow tr = new TableRow();
        //        for (int j = 0; j < 7; j++)
        //        {
        //            if (i == 0) //Header Row
        //            {
        //                TableCell headerCell = new TableCell();
        //                TextBox txtHeader = new TextBox();
        //                txtHeader.CssClass = "width: 1%";
        //                txtHeader.ReadOnly = true;
        //                if ( j == 0) //Position
        //                {
        //                    txtHeader.Text = "Position";
        //                }
        //                else if (j == 1) //Team
        //                {
        //                    txtHeader.Text = "Tean Name";
        //                }
        //                else if (j == 2) //Match Played
        //                {
        //                    txtHeader.Text = "Match Played";
        //                }
        //                else if (j == 3) //Draws
        //                {
        //                    txtHeader.Text = "Draws";
        //                }
        //                else if (j == 4) //Wins
        //                {
        //                    txtHeader.Text = "Wins";
        //                }
        //                else if (j == 5) //Loose
        //                {
        //                    txtHeader.Text = "Lose";
        //                }
        //                else if (j == 6) //Points
        //                {
        //                    txtHeader.Text = "Point";
        //                }
        //                // Add the control to the TableCell
        //                headerCell.Controls.Add(txtHeader);
        //                // Add the TableCell to the TableRow
        //                tr.Cells.Add(headerCell);
        //            }
        //            else
        //            {
        //                int Index = i - 1;
        //                TableCell tc = new TableCell();
        //                TextBox txtBox = new TextBox();
        //                if (j == 0) //Position
        //                {
        //                    txtBox.Text = Convert.ToString(Index);
        //                }
        //                else if (j == 1) //Team
        //                {
        //                    txtBox.Text = log[Index].TeamName;
        //                }
        //                else if (j == 2) //Match Played
        //                {
        //                    txtBox.Text = Convert.ToString(log[Index].MatchPlayed);
        //                }
        //                else if (j == 3) //Draws
        //                {
        //                    txtBox.Text = Convert.ToString(log[Index].Draws);
        //                }
        //                else if (j == 4) //Wins
        //                {
        //                    txtBox.Text = Convert.ToString(log[Index].Wins);
        //                }
        //                else if (j == 5) //Loose
        //                {
        //                    txtBox.Text = Convert.ToString(log[Index].Loose);
        //                }
        //                else if (j == 6) //Points
        //                {
        //                    txtBox.Text = Convert.ToString(log[Index].Points);
        //                }
        //                // Add the control to the TableCell
        //                tc.Controls.Add(txtBox);
        //                // Add the TableCell to the TableRow
        //                tr.Cells.Add(tc);
        //            }
        //        }
        //        // Add the TableRow to the Table
        //        tbl.Rows.Add(tr);
        //    }

        //    // This parameter helps determine in the LoadViewState event,
        //    // whether to recreate the dynamic controls or not

        //    ViewState["dynamictable"] = true;
        //}

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string           L_ID      = Convert.ToString(Request.QueryString["LeagueID"]);
            LogServiceClient logClient = new LogServiceClient();

            if (txtPos.Value != "")
            {
                Log newLog = new Log();
                newLog.Position    = Convert.ToInt32(txtPos.Value);
                newLog.TeamName    = Convert.ToString(txtTeam.Value);
                newLog.MatchPlayed = Convert.ToInt32(txtPlays.Value);
                newLog.Draws       = Convert.ToInt32(txtDraws.Value);
                newLog.Wins        = Convert.ToInt32(txtWins.Value);
                newLog.Loose       = Convert.ToInt32(txtLoose.Value);
                newLog.Points      = Convert.ToInt32(txtPoints.Value);
                newLog.League_ID   = Convert.ToInt32(L_ID);
                string Log1 = logClient.CreateLog(newLog);
            }
            if (txtPos_2.Value != "")
            {
                Log newLog_1 = new Log();
                newLog_1.Position    = Convert.ToInt32(txtPos_2.Value);
                newLog_1.TeamName    = Convert.ToString(txtTeam_2.Value);
                newLog_1.MatchPlayed = Convert.ToInt32(txtPlays_2.Value);
                newLog_1.Draws       = Convert.ToInt32(txtDraws_2.Value);
                newLog_1.Wins        = Convert.ToInt32(txtWins_2.Value);
                newLog_1.Loose       = Convert.ToInt32(txtLoose_2.Value);
                newLog_1.Points      = Convert.ToInt32(txtPoints_2.Value);
                newLog_1.League_ID   = Convert.ToInt32(L_ID);
                string Log_1 = logClient.CreateLog(newLog_1);
            }

            if (txtPos_3.Value != "")
            {
                Log newLog_2 = new Log();
                newLog_2.Position    = Convert.ToInt32(txtPos_3.Value);
                newLog_2.TeamName    = Convert.ToString(txtTeam_3.Value);
                newLog_2.MatchPlayed = Convert.ToInt32(txtPlays_3.Value);
                newLog_2.Draws       = Convert.ToInt32(txtDraws_3.Value);
                newLog_2.Wins        = Convert.ToInt32(txtWins_3.Value);
                newLog_2.Loose       = Convert.ToInt32(txtLoose_3.Value);
                newLog_2.Points      = Convert.ToInt32(txtPoints_3.Value);
                newLog_2.League_ID   = Convert.ToInt32(L_ID);
                string Log_2 = logClient.CreateLog(newLog_2);
            }

            if (txtPos_4.Value != "")
            {
                Log newLog_3 = new Log();
                newLog_3.Position    = Convert.ToInt32(txtPos_4.Value);
                newLog_3.TeamName    = Convert.ToString(txtTeam_4.Value);
                newLog_3.MatchPlayed = Convert.ToInt32(txtPlays_4.Value);
                newLog_3.Draws       = Convert.ToInt32(txtDraws_4.Value);
                newLog_3.Wins        = Convert.ToInt32(txtWins_4.Value);
                newLog_3.Loose       = Convert.ToInt32(txtLoose_4.Value);
                newLog_3.Points      = Convert.ToInt32(txtPoints_4.Value);
                newLog_3.League_ID   = Convert.ToInt32(L_ID);
                string Log_3 = logClient.CreateLog(newLog_3);
            }

            if (txtPos_5.Value != "")
            {
                Log newLog_4 = new Log();
                newLog_4.Position    = Convert.ToInt32(txtPos_5.Value);
                newLog_4.TeamName    = Convert.ToString(txtTeam_5.Value);
                newLog_4.MatchPlayed = Convert.ToInt32(txtPlays_5.Value);
                newLog_4.Draws       = Convert.ToInt32(txtDraws_5.Value);
                newLog_4.Wins        = Convert.ToInt32(txtWins_5.Value);
                newLog_4.Loose       = Convert.ToInt32(txtLoose_5.Value);
                newLog_4.Points      = Convert.ToInt32(txtPoints_5.Value);
                newLog_4.League_ID   = Convert.ToInt32(L_ID);
                string Log_4 = logClient.CreateLog(newLog_4);
            }

            if (txtPos_6.Value != "")
            {
                Log newLog_5 = new Log();
                newLog_5.Position    = Convert.ToInt32(txtPos_6.Value);
                newLog_5.TeamName    = Convert.ToString(txtTeam_6.Value);
                newLog_5.MatchPlayed = Convert.ToInt32(txtPlays_6.Value);
                newLog_5.Draws       = Convert.ToInt32(txtDraws_6.Value);
                newLog_5.Wins        = Convert.ToInt32(txtWins_6.Value);
                newLog_5.Loose       = Convert.ToInt32(txtLoose_6.Value);
                newLog_5.Points      = Convert.ToInt32(txtPoints_6.Value);
                newLog_5.League_ID   = Convert.ToInt32(L_ID);
                string Log_5 = logClient.CreateLog(newLog_5);
            }

            if (txtPos_7.Value != "")
            {
                Log newLog_6 = new Log();
                newLog_6.Position    = Convert.ToInt32(txtPos_7.Value);
                newLog_6.TeamName    = Convert.ToString(txtTeam_7.Value);
                newLog_6.MatchPlayed = Convert.ToInt32(txtPlays_7.Value);
                newLog_6.Draws       = Convert.ToInt32(txtDraws_7.Value);
                newLog_6.Wins        = Convert.ToInt32(txtWins_7.Value);
                newLog_6.Loose       = Convert.ToInt32(txtLoose_7.Value);
                newLog_6.Points      = Convert.ToInt32(txtPoints_7.Value);
                newLog_6.League_ID   = Convert.ToInt32(L_ID);
                string Log_6 = logClient.CreateLog(newLog_6);
            }

            if (txtPos_8.Value != "")
            {
                Log newLog_7 = new Log();
                newLog_7.Position    = Convert.ToInt32(txtPos_8.Value);
                newLog_7.TeamName    = Convert.ToString(txtTeam_8.Value);
                newLog_7.MatchPlayed = Convert.ToInt32(txtPlays_8.Value);
                newLog_7.Draws       = Convert.ToInt32(txtDraws_8.Value);
                newLog_7.Wins        = Convert.ToInt32(txtWins_8.Value);
                newLog_7.Loose       = Convert.ToInt32(txtLoose_8.Value);
                newLog_7.Points      = Convert.ToInt32(txtPoints_8.Value);
                newLog_7.League_ID   = Convert.ToInt32(L_ID);
                string Log_7 = logClient.CreateLog(newLog_7);
            }


            Response.Redirect("LeagueLog.aspx?L_ID=" + L_ID);
        }
Exemple #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         //gt_LogByLeagueID
         leag_ID = Convert.ToString(Request.QueryString["LeagueID"]);
         LogServiceClient logClient = new LogServiceClient();
         List <Log>       logList   = new List <Log>();
         logList = logClient.gt_LogByLeagueID(leag_ID);
         int Counter  = 0;
         int LogCount = logList.Count();
         foreach (Log lg in logList)
         {
             if (Counter != LogCount)
             {
                 if (Counter == 0)
                 {
                     txtPos.Value    = Convert.ToString(lg.Position);
                     txtTeam.Value   = Convert.ToString(lg.TeamName);
                     txtPlays.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws.Value  = Convert.ToString(lg.Draws);
                     txtWins.Value   = Convert.ToString(lg.Wins);
                     txtLoose.Value  = Convert.ToString(lg.Loose);
                     txtPoints.Value = Convert.ToString(lg.Points);
                 }
                 else
                 if (Counter == 1)
                 {
                     txtPos_2.Value    = Convert.ToString(lg.Position);
                     txtTeam_2.Value   = Convert.ToString(lg.TeamName);
                     txtPlays_2.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws_2.Value  = Convert.ToString(lg.Draws);
                     txtWins_2.Value   = Convert.ToString(lg.Wins);
                     txtLoose_2.Value  = Convert.ToString(lg.Loose);
                     txtPoints_2.Value = Convert.ToString(lg.Points);
                 }
                 else
                 if (Counter == 2)
                 {
                     txtPos_3.Value    = Convert.ToString(lg.Position);
                     txtTeam_3.Value   = Convert.ToString(lg.TeamName);
                     txtPlays_3.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws_3.Value  = Convert.ToString(lg.Draws);
                     txtWins_3.Value   = Convert.ToString(lg.Wins);
                     txtLoose_3.Value  = Convert.ToString(lg.Loose);
                     txtPoints_3.Value = Convert.ToString(lg.Points);
                 }
                 else
                 if (Counter == 3)
                 {
                     txtPos_4.Value    = Convert.ToString(lg.Position);
                     txtTeam_4.Value   = Convert.ToString(lg.TeamName);
                     txtPlays_4.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws_4.Value  = Convert.ToString(lg.Draws);
                     txtWins_4.Value   = Convert.ToString(lg.Wins);
                     txtLoose_4.Value  = Convert.ToString(lg.Loose);
                     txtPoints_4.Value = Convert.ToString(lg.Points);
                 }
                 else
                 if (Counter == 4)
                 {
                     txtPos_5.Value    = Convert.ToString(lg.Position);
                     txtTeam_5.Value   = Convert.ToString(lg.TeamName);
                     txtPlays_5.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws_5.Value  = Convert.ToString(lg.Draws);
                     txtWins_5.Value   = Convert.ToString(lg.Wins);
                     txtLoose_5.Value  = Convert.ToString(lg.Loose);
                     txtPoints_5.Value = Convert.ToString(lg.Points);
                 }
                 else
                 if (Counter == 5)
                 {
                     txtPos_6.Value    = Convert.ToString(lg.Position);
                     txtTeam_6.Value   = Convert.ToString(lg.TeamName);
                     txtPlays_6.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws_6.Value  = Convert.ToString(lg.Draws);
                     txtWins_6.Value   = Convert.ToString(lg.Wins);
                     txtLoose_6.Value  = Convert.ToString(lg.Loose);
                     txtPoints_6.Value = Convert.ToString(lg.Points);
                 }
                 else
                 if (Counter == 6)
                 {
                     txtPos_7.Value    = Convert.ToString(lg.Position);
                     txtTeam_7.Value   = Convert.ToString(lg.TeamName);
                     txtPlays_7.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws_7.Value  = Convert.ToString(lg.Draws);
                     txtWins_7.Value   = Convert.ToString(lg.Wins);
                     txtLoose_7.Value  = Convert.ToString(lg.Loose);
                     txtPoints_7.Value = Convert.ToString(lg.Points);
                 }
                 else
                 if (Counter == 7)
                 {
                     txtPos_8.Value    = Convert.ToString(lg.Position);
                     txtTeam_8.Value   = Convert.ToString(lg.TeamName);
                     txtPlays_8.Value  = Convert.ToString(lg.MatchPlayed);
                     txtDraws_8.Value  = Convert.ToString(lg.Draws);
                     txtWins_8.Value   = Convert.ToString(lg.Wins);
                     txtLoose_8.Value  = Convert.ToString(lg.Loose);
                     txtPoints_8.Value = Convert.ToString(lg.Points);
                 }
                 else
                 {
                     continue;
                 }
                 Counter++;
             }
             else
             {
                 continue;
             }
         }
         //CreateDynamicTable(logList.Count(), logList);
     }
 }
Exemple #23
0
        public Task FliterBlackNote(bool SyncWhiteNotes, bool SyncBlackNotes)
        {
            return Task.Run(() =>
            {
                lock (this)
                {
                    FliterServiceClient fClient = new FliterServiceClient();

                    LogServiceClient lClient = new LogServiceClient();
                    try
                    {
                        lClient.Open();
                        fClient.Open();
                        if (SyncBlackNotes)
                        {
                            //定时同步黑名单
                            this.BlackList = fClient.GetBlackNoteList().ToList();
                        }
                        if (SyncWhiteNotes)
                        {
                            //定时同步白名单
                            this.WhiteList = fClient.GetWhiteNoteList().ToList();
                        }

                        //获取日志
                        NewLogList = lClient.LastQueryLogQuery(this.LastId, false);
                        if (NewLogList.Count() > 0)
                        {
                            this.LastId = NewLogList.Max(n => n.Id);
                        }

                        //添加至对应的列表中
                        this.TodayLogList.AddRange(NewLogList);
                        this.LastHundreLogList.AddRange(NewLogList);

                        //删除过期黑名单
                        foreach (var n in BlackList)
                        {
                            if (n.Reason == "当日查询过多!" && DateTime.Now.Subtract(n.CreateDate).TotalDays > 1)
                            {
                                fClient.DelBlackNote(n);
                                continue;
                            }
                            if (n.Reason == "短时间内频繁查询。" && DateTime.Now.Subtract(n.CreateDate).TotalSeconds > this.shortTimeSpan)
                            {
                                fClient.DelBlackNote(n);
                            }
                        }

                        //删除本地日志中的过期项
                        //if (this.LastHundreLogList.Count() > 100)
                        //{
                        //    this.LastHundreLogList.RemoveRange(0, this.LastHundreLogList.Count() - 100);
                        //}
                        this.LastHundreLogList.RemoveAll(n => DateTime.Now.Subtract(n.OptionDate).TotalSeconds > this.shortTimeSpan);
                        this.TodayLogList.RemoveAll(n => DateTime.Now.Subtract(n.OptionDate).TotalDays > 1);
                        //while (this.TodayLogList.Count() > 0 && DateTime.Now.Subtract(this.TodayLogList[0].OptionDate).TotalDays > 1)
                        //{
                        //    this.TodayLogList.RemoveAt(0);
                        //}
                        BlackList.RemoveAll(n => n.Reason == "当日查询过多!" && DateTime.Now.Subtract(n.CreateDate).TotalDays > 1);
                        BlackList.RemoveAll(n => n.Reason == "短时间内频繁查询。" && DateTime.Now.Subtract(n.CreateDate).TotalSeconds > this.shortTimeSpan);

                        //筛选黑名单
                        var todayDic = GetCountDic(TodayLogList);
                        var lastDic = GetCountDic(LastHundreLogList);

                        //检测是否在白名单内
                        foreach (var k in todayDic.Keys)
                        {
                            if (this.WhiteList.Any(n => n.Feature == k.Feature && n.Mold == k.Mold))
                            {
                                //todayDic.Remove(k);
                                todayDic[k] = 0;
                            }
                        }
                        foreach (var k in lastDic.Keys)
                        {
                            if (this.WhiteList.Any(n => n.Feature == k.Feature && n.Mold == k.Mold))
                            {
                                //lastDic.Remove(k);
                                lastDic[k] = 0;
                            }
                        }
                        //添加至黑名单中(封装新的方法)
                        foreach (var note in todayDic)
                        {
                            if (note.Value > this.timesForOneDay)
                            {
                                // AddToBlackNote(note.Key);
                                var newNote = new BlackNote
                                {
                                    CreateDate = DateTime.Now,
                                    Feature = note.Key.Feature,
                                    Mold = note.Key.Mold,
                                    Flg = true,
                                    Reason = "当日查询过多!",
                                };
                                if (fClient.AddBlackNote(newNote) == 1)
                                {
                                    this.BlackList.Add(newNote);
                                }
                            }

                        }
                        foreach (var note in lastDic)
                        {
                            if (note.Value > this.shortTimeQueryTimes)
                            {
                                var newNote = new BlackNote
                                {
                                    CreateDate = DateTime.Now,
                                    Reason = "短时间内频繁查询。",
                                    Flg = true,
                                    Feature = note.Key.Feature,
                                    Mold = note.Key.Mold,
                                    UpdateDate = DateTime.Now,
                                    Id = 0
                                };
                                var ret = fClient.AddBlackNote(newNote);
                                if (ret == 1)
                                //if (fClient.AddBlackNote(newNote) == 1)
                                {
                                    this.BlackList.Add(newNote);
                                }
                            }
                        }
                        lClient.Close();
                        fClient.Close();
                    }
                    catch (Exception ex)
                    {
                        Messenger.Default.Send<DialogMessage>(new DialogMessage(string.Format("An error was happend on {0}:\r\n{1}", "add black note", ex.Message), null), "showMsg");
                    }
                    finally
                    {
                        lClient.Abort();
                        fClient.Abort();
                    }
                }
            }
             );
        }
Exemple #24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            RegistrationServiceClient registrationService = new RegistrationServiceClient();
            LogServiceClient logService = new LogServiceClient();
            if (ExistingSchedRemove.Count > 0)
            {
                if (registrationService.DeleteLoadedSubjects(controlStudentId, SY, ExistingSchedRemove.ToArray()))
                {

                    foreach (StudentSubject ss in ExistingSchedRemove)
                    {
                        string json = JsonConvert.SerializeObject(ss);
                        Log log = new Log
                        {
                            CLUD = "D",
                            LogDate = DateTime.Now,
                            TableName = "StudentSubject",
                            UserId = GlobalClass.user.UserId,
                            UserName = GlobalClass.user.UserName,
                            PassedData = json
                        };
                        logService.AddLogs(log);
                    }
                    MessageBox.Show(this, "Adding Student Subjects Successful .");
                    Close();
                }
                else
                {
                    MessageBox.Show(this, "Student Subjects Adding Failed.");
                    Close();
                }
            }
            if (subjects.Count > 0)
            {
                if (registrationService.ControlSubjects(controlStudentId, SY, subjects.ToArray()))
                {
                    foreach (StudentSubject ss in subjects)
                    {
                        string json = JsonConvert.SerializeObject(ss);
                        Log log = new Log
                        {
                            CLUD = "C",
                            LogDate = DateTime.Now,
                            TableName = "StudentSubject",
                            UserId = GlobalClass.user.UserId,
                            UserName = GlobalClass.user.UserName,
                            PassedData = json
                        };
                        logService.AddLogs(log);
                    }
                    MessageBox.Show(this, "Adding Student Subjects Successful .");
                    Close();
                }
                else
                {
                    MessageBox.Show(this, "Student Subjects Adding Failed.");
                    Close();
                }
            }
        }
Exemple #25
0
 private void Log(string clud, string table, Object obj)
 {
     LogServiceClient logService = new LogServiceClient();
     string json = JsonConvert.SerializeObject(obj);
     Log log = new Log
     {
         CLUD = clud,
         LogDate = DateTime.Now,
         TableName = table,
         UserId = GlobalClass.user.UserId,
         UserName = GlobalClass.user.UserName,
         PassedData = json
     };
     logService.AddLogs(log);
 }
Exemple #26
0
 private static void WriteAsync(this LogServiceClient client, string message)
 {
     // Todo
 }
Exemple #27
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            calculate.Visible = false;
            RegistrationServiceClient registrationService = new RegistrationServiceClient();
            LogServiceClient logService = new LogServiceClient();
            var assessments = registrationService.AssessMe(StudentAssessed);
            if (assessments.Length> 0)
            {
                string json = JsonConvert.SerializeObject(StudentAssessed);
                Log log = new Log
                {
                    CLUD = "C",
                    LogDate = DateTime.Now,
                    TableName = "StudentAssessment",
                    UserId = GlobalClass.user.UserId,
                    UserName = GlobalClass.user.UserName,
                    PassedData = json
                };
                logService.AddLogs(log);

                PrintPane();
                calculate.Visible = true;
            }
        }
Exemple #28
0
        private void Save()
        {
            string szGender = string.Empty;
            string szBloodType = string.Empty;
            bool acad = false;
            if (cmbGender.Text == "Female") szGender = "F";
            if (cmbGender.Text == "Male") szGender = "M";

            if (cmbBloodType.Text == "A") szBloodType = "A";
            if (cmbBloodType.Text == "O") szBloodType = "O";
            if (cmbBloodType.Text == "AB") szBloodType = "AB";
            if (cmbBloodType.Text == "A") szBloodType = "A";
            if (radioAcademic.Checked == true && radioNonAcad.Checked == false) acad = true;
            else if (radioAcademic.Checked == false && radioNonAcad.Checked == true) acad = false;
            else if (radioAcademic.Checked == false && radioNonAcad.Checked == false) acad = false;
            Boolean ret = false;
            string message = String.Empty;

            byte[] bImage = null;
            if (pbImage.BackgroundImage != null) bImage = imageToByteArray(pbImage.BackgroundImage, ImageFormat.Png);

            TeacherServiceClient teacherService = new TeacherServiceClient();

            String fName = txtFirstName.Text;
            String mName = txtMiddleName.Text;
            String lName = txtLastName.Text;

            String cName = fName.Trim() + mName.Trim() + lName.Trim();

            var teachers = teacherService.GetAllTeachers();

            teacherCompare = new List<Teacher>(teachers);

            Teacher teacher = new Teacher()
            {
                TeacherId = txtTeacherID.Text,
                BloodType = szBloodType,
                CivilStatus = cmbCivilState.Text,
                DOB = dtBirth.Value,
                DateOfAppointment = dtAppointment.Value,
                EmailAddress = txtEmailAdd.Text,
                EmploymentStatus = txtEmploymentState.Text,
                DialectSpoken = txtDialect.Text,
                FirstName = txtFirstName.Text,
                MiddleName = txtMiddleName.Text,
                LastName = txtLastName.Text,
                Gender = szGender,
                HeightCm = int.Parse(txtHeight.Text),
                WeightKg = double.Parse(txtWeight.Text),
                MobileNo = txtCellphone.Text,
                PAMunicipality = txtPA_Municipality.Text,
                PAProvince = txtPA_Province.Text,
                PARegion = cmbPA_Region.SelectedValue.ToString(),
                PAStreetName = txtPA_StreetName.Text,
                POBMunicipality = txtPOB_Municipality.Text,
                POBProvince = txtPOB_Province.Text,
                PagIBIGNo = txtPagIbig.Text,
                PhilHealthNo = txtPhilHealth.Text,
                PreviousSchool = txtSchoolReassigned.Text,
                RAMunicipality = txtRes_Municipality.Text,
                RAProvince = txtRes_Province.Text,
                RARegion = cmbRes_Region.SelectedValue.ToString(),
                RAStreetName = txtRes_StreetName.Text,
                ResTelephoneNo = txtRes_TelNo.Text,
                SSSNum = txtSSS.Text,
                SpouseBusinessAdd = txtSpouse_BusinessAdd.Text,
                SpouseEmployerName = txtSpouse_Employer.Text,
                SpouseFirstName = txtSpouse_FirstName.Text,
                SpouseLastName = txtSpouse_LastName.Text,
                SpouseMiddleName = txtSpouse_MiddleName.Text,
                SpouseOccupation = txtSpouse_Occupation.Text,
                SpouseTelephoneNo = txtSpouse_Contact.Text,
                TIN = txtTIN.Text,
                Image = bImage,
                PERAA = txtPERAA.Text,
                Academic = acad,

                TeacherChildrens = teachChild.ToArray(),
                TeacherEducationalBackgrounds = educBack.ToArray(),
                TeacherEligibilities = teachElig.ToArray(),
                WorkExperiences = workExp.ToArray(),
                TrainingSeminars=trainSem.ToArray(),

            };

            if (Op.Equals("edit"))
            {
                ret = teacherService.UpdateTeacher(ref teacher, ref message);
                LogServiceClient logService = new LogServiceClient();
                teacher.TeacherChildrens = null;
                teacher.TeacherEducationalBackgrounds = null;
                teacher.TeacherEligibilities = null;
                teacher.TrainingSeminars = null;
                teacher.WorkExperiences = null;

                Log("U", "Teachers", teacher);

                foreach (TeacherChildren tc in teachChild)
                   Log("U", "TeacherChildren", tc);

                foreach (TeacherEducationalBackground teb in educBack)
                   Log("U", "TeacherEducationalBackground", teb);

                foreach (TeacherEligibility te in teachElig)
                    Log("U", "TeacherEligibilities", te);

                foreach (WorkExperience we in workExp)
                    Log("U", "WorkExperiences", we);

                foreach (TrainingSeminar ts in trainSem)
                   Log("U", "TrainingSeminars", ts);

            }

            else
            {
                foreach (Teacher tc in teacherCompare)
                {
                    String compareString = tc.FirstName.Trim() + tc.MiddleName.Trim() + tc.LastName.Trim();
                    if (cName.Equals(compareString))
                    {
                        MessageBox.Show("Teacher already exist!");
                        break;
                    }
                    else
                    {
                        ret = teacherService.CreateTeacher(ref teacher, ref message);
                        Log("C", "Teachers", teacher);

                    }
                }
            }

               // if (ret)
                MessageBox.Show("Saved Successfully");
            //else
            //    MessageBox.Show("Error Saving");

            Close();
        }