예제 #1
0
 public void SaveBuild(Build build)
 {
     if (build != null)
     {
         context.Builds.Add(build);
         context.SaveChanges();
     }
 }
예제 #2
0
 public bool RestoreUser(UserCache user, ref string message)
 {
     if (user != null)
     {
         if (user.deleted == true)
         {
             user.deleted   = false;
             user.userToken = Validator.GenerateHash(40);
             context.Users.Update(user);
             context.SaveChanges();
             Log.Info("User account was restored.", user.userId);
             return(true);
         }
         else
         {
             message = "An account with email ->'" + user.userEmail + "' already exists.";
             Log.Warn(message);
         }
     }
     return(false);
 }
예제 #3
0
파일: Log.cs 프로젝트: NeytChi/yobi-wi
 public static void WriteLogMessage(LogMessage log)
 {
     if (Logging != LogLevel.OFF)
     {
         if (!string.IsNullOrEmpty(log.message))
         {
             if (log.message.Length > 2000)
             {
                 log.message = log.message.Substring(0, 2000);
             }
         }
         else
         {
             Error("Log->message - is null or emply, call WriteLogMessage()");
             return;
         }
         log.userComputer = UserComputer;
         log.createdAt    = DateTime.Now;
         log.threadId     = Thread.CurrentThread.ManagedThreadId;
         if (Config.logFiles)
         {
             ChangeLogFile(log.createdAt);
             System.Diagnostics.Debug.WriteLine(log.message);
             Writer.WriteAsync
             (
                 "Created at: " + log.createdAt + " | " +
                 log.level + " | " +
                 "Message: " + log.message + " | " +
                 "UID: " + log.userId + " | " +
                 "UIP: " + log.userIP + " | " +
                 "TID: " + log.threadId + " | " +
                 "UPC: " + log.userComputer + " | " +
                 "\r\n"
             );
             Writer.Flush();
         }
         blocker.WaitOne();
         context.Logs.AddAsync(log);
         context.SaveChanges();
         blocker.Release();
     }
     else
     {
         System.Diagnostics.Debug.WriteLine(log.message);
     }
 }
예제 #4
0
        public ActionResult <dynamic> Delete([FromQuery] string hash)
        {
            string message       = "";
            Build  buildToDelete = context.Builds.Where(build
                                                        => build.buildHash == hash &&
                                                        build.buildDeleted == false).FirstOrDefault();

            if (buildToDelete != null)
            {
                buildToDelete.buildDeleted = true;
                context.Builds.Update(buildToDelete);
                context.SaveChanges();
                Log.Info("Delete build, buildId ->" + buildToDelete.buildId + ".");
                return(new { success = true });
            }
            else
            {
                message = "Server can't define build.";
            }
            return(Return500Error(message));
        }