Exemple #1
0
        /// <summary>
        /// Handles the deletion of the passed target
        /// </summary>
        /// <param name="target">The file or directory to be deleted</param>
        /// <param name="mt">Multithreading configuration</param>
        /// <param name="log">Logging configuration</param>
        /// <param name="output">Output enabled</param>
        /// <returns>An error code based on how the operation turned out</returns>
        public static int Delete(Target target, MultithreadingSetup mt, Logging log, bool output)
        {
            int retval = (int) ErrorCodes.Success;

            if (target.Exists)
            {
                // Create empty directory for mirroring
                string emptyDir = SystemTempDir + @"\FilExile_temp$";
                string secondEmptyDir = "";
                Directory.CreateDirectory(emptyDir);

                // Sometimes there's an extra backslash on the end of the path
                // and we need to trim it off
                if (target.Path.EndsWith(@"\"))
                    target.Path = target.Path.TrimEnd('\\');

                if (target.IsDirectory)
                {
                    _robocopyCommand = PrepareRobocopyCommand(mt, log, emptyDir, target.Path);
                }
                else
                {
                    // For single files there is an extra step we have to take...
                    // We need to create another temporary directory. We are going to use Robocopy
                    // to place the file in this temporary directory by itself. This is to
                    // prevent the actual diretory mirror command from wiping out everything else
                    // where the file was found.
                    secondEmptyDir = SystemTempDir + @"\FilExile_singleFile_temp$";
                    Directory.CreateDirectory(secondEmptyDir);

                    string fileCopyCmd = PrepareFileCopyCommand(target.ParentDirectory, secondEmptyDir, target.FileName);
                    RunRobocopy(fileCopyCmd, output);

                    _robocopyCommand = PrepareRobocopyCommand(mt, log, emptyDir, secondEmptyDir);
                }

                // This is where the main deletion operation occurs - Uses Robocopy to mirror
                // the empty directory we created onto the target. This will make any files within
                // the target appear as "extra files" and forcibly remove them via Robocopy which
                // can handle all sorts of nasty files that Windows will sometimes choke on
                RunRobocopy(_robocopyCommand, output);

                // Delete the temporary directory/directories created
                if (Directory.Exists(emptyDir))
                {
                    Directory.Delete(emptyDir);
                }
                if (Directory.Exists(secondEmptyDir))
                {
                    Directory.Delete(secondEmptyDir);
                }
            }
            else
            {
                retval = (int) ErrorCodes.NotFound;
            }

            return retval;
        }
        public OpenDNSInterface(Logging Log)
        {
            m_Log = Log;

            m_Updater = new Updater(m_CurrentVersion);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            InitializeComponent();
        }
 public EditMatchSession(
     Logging.LoggingInterfaces.ITracer logger,
     LocalDatabaseWrapper context,
     SessionData sessionData,
     MatchSession session,
     bool matchEndMode)
 {
     this.logger = logger;
     this.context = context;
     matchmediaData = sessionData.Item1;
     matchmediaDataCopy = matchmediaData.Clone();
     playersData = sessionData.Item2;
     playersDataCopy = playersData.Clone();
     this.session = session;
     this.matchEndMode = matchEndMode;
     InitializeComponent();
 }
        static void Main()
        {
            // Make sure our log directory exists
            if (!Directory.Exists(sLogPath)) Directory.CreateDirectory(sLogPath);

            // Create our Logger
            m_Log = new Logging(sLogFileName, sLogPath, true);
            m_Log.SetLogging(Logging.LOGTYPE.DEBUG);

            m_Log.Log(Logging.LOGTYPE.DEBUG, "In Main()");

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            m_Log.Log(Logging.LOGTYPE.DEBUG, "Aquire Mutex");

            bool bOk = false;
            System.Threading.Mutex mSingle = new System.Threading.Mutex(true, "OpenDNSInterface", out bOk);

            if (!bOk)
            {
                m_Log.Log(Logging.LOGTYPE.DEBUG, "Attempting to kill other instances");

                // NOTE: Used to kill this instance, now kill existing instance. This allows upgrade
                // to be smoother so latest is running if it is started on top of old one...
                //MessageBox.Show("Another instance of OpenDNS DNSCrypt Client is already running.");

                // Close running application
                foreach (Process p in Process.GetProcessesByName("OpenDNSInterface"))
                {
                    p.Kill();
                }

                //return;
            }

            m_Log.Log(Logging.LOGTYPE.DEBUG, "App Run()");

            Application.Run(new OpenDNSInterface(m_Log));

            // Makes sure the program doesn't prematurely garbage collect the mutex
            // resulting in the ability to run the exe again...
            GC.KeepAlive(mSingle);
        }
        // Triangulate
        // "Input" is a list of Vector2's that hold the point data to be triangulated.
        //(Vector2 is not shown but is a structure that has two floating points members X and Y).
        // "VertsPerContour" is an array that determines where to break up the contours in the
        //list of points in Input. VertsPerContour must sum to the number of entries in Input.
        //
        //Note: Outer contours must be given in counter-clockwise order while inner contours
        //      (holes) must be given in clock-wise order.
        //
        //Returns true on successfull triangulation, false on failure or error
        //
        public static unsafe bool Triangulate(Vector2[] Input, int[] VertsPerContour, ref Logging.Logger log)
        {
            InvalidPolygon = false;
            Indices = new List<int>();

            IntPtr tess = IntPtr.Zero;

            // create tesselation object
            if (glControl == null)
            {
                glControl = new OpenTK.GLControl();
            }

            tess = Glu.NewTess();

            // register tesselation callbacks
            Glu.TessCallback(tess, TessCallback.TessBegin, new BeginCallbackDelegate(BeginCallback));
            Glu.TessCallback(tess, TessCallback.TessEdgeFlag, new EdgeFlagCallbackDelegate(EdgeCallback));
            Glu.TessCallback(tess, TessCallback.TessVertex, new VertexCallbackDelegate (VertexCallback));
            Glu.TessCallback(tess, TessCallback.TessEnd, new EndCallbackDelegate(EndCallback));
            Glu.TessCallback(tess, TessCallback.TessCombine, new CombineCallbackDelegate(CombineCallback));
            Glu.TessCallback(tess, TessCallback.TessError, new ErrorCallbackDelegate(ErrorCallback));

            //copy input into a linear array of floats
            double[] Vertices = new double[3 * Input.Length];
            for(int v=0;v<Input.Length;v++)
            {
                Vertices[v*3+0] = Input[v].X;
                Vertices[v*3+1] = Input[v].Y;
                Vertices[v*3+2] = 0.0;
            }

            // begin polygon
            Glu.TessBeginPolygon(tess, IntPtr.Zero);

            // go through the contours
            int CurrentContour = 0;
            int VertsThisContour = 0;

            for(int v=0;v<Input.Length;v++)
            {
                if(v == 0)
                    Glu.TessBeginContour(tess);

                // pass the corresponding vertex to the tesselator object
                double[] VertsToPass = new double[3];
                VertsToPass[0] = Vertices[v * 3 + 0];
                VertsToPass[1] = Vertices[v * 3 + 1];
                VertsToPass[2] = Vertices[v * 3 + 2];
                Glu.TessVertex(tess,VertsToPass,v);

                if(InvalidPolygon)
                    break;

                VertsThisContour++;

                if(VertsThisContour >= VertsPerContour[CurrentContour])
                {
                    VertsThisContour = 0;
                    Glu.TessEndContour(tess);

                    CurrentContour++;

                    if(CurrentContour < (long)VertsPerContour.Length)
                    {
                        Glu.TessBeginContour(tess);
                    }
                }
            }

            if(InvalidPolygon)
            {
                // destroy the tesselation object
                Glu.DeleteTess(tess);
                tess = IntPtr.Zero;

                return false; //error in polygon definition
            }
            else
            {
                try
                {
                    // end polygon
                    Glu.TessEndPolygon(tess);

                    // destroy the tessellation object
                    Glu.DeleteTess(tess);
                    tess = IntPtr.Zero;

                    //The Indices object is now valid.
                }
                catch {
                    log.Warning("Triangulator", "Failed to delete tesslator");
                }
                return true;
            }
        }
Exemple #6
0
 public ChunkDrawer(ref Logging.Logger log)
 {
     this.log = log;
 }
Exemple #7
0
 public void Log(object sender, Logging.LogEventArgs e)
 {
     if (InvokeRequired)
     {
         var hnd = new EventHandler<Logging.LogEventArgs>(Log);
         Invoke(hnd, new object[] { sender, e });
         return;
     }
     //logText.AppendText(e.Text + Environment.NewLine);
     //logText.SelectionStart = logText.TextLength;
     //logText.ScrollToCaret();
 }
Exemple #8
0
		public override string Format(Logging.LogEntity log)
		{
			throw new NotImplementedException();
		}
 public LoggerTrackingChannel(TrackingParameters parameters, Logging.ILogger logger)
 {
     m_Logger = logger;
     m_Parameters = parameters;
 }
 protected void log(Logging.LoggingLevel level, string msg, params object[] args)
 {
     Logging.Log(level, string.Format("[{0}:{1}] - {2}", Name, ClientId, string.Format(msg, args)));
 }
 protected void log(Logging.LoggingLevel level, string msg)
 {
     log(level, msg, "");
 }
 public LoggerTrackingService(Logging.ILogger logger)
 {
     m_Logger = logger;
 }
Exemple #13
0
        /// <summary>
        /// Takes the two passed directories and creates Robocopy arguments to mirror the
        /// empty directory onto the target diretory
        /// </summary>
        /// <param name="mt">Multithreading struct (enabled, numThreads)</param>
        /// <param name="log">Logging struct (enabled, logfile)</param>
        /// <param name="emptyDir">Empty directory to mirror from</param>
        /// <param name="targetDir">Targeted directory to be eliminated</param>
        /// <returns>Prepared Robocopy arguments to mirror the emptyDir onto the targetDir</returns>
        private static string PrepareRobocopyCommand(MultithreadingSetup mt, Logging log, string emptyDir, string targetDir)
        {
            string retVal = string.Empty;

            retVal += "\"" + emptyDir + "\" \"" + targetDir + "\" /MIR /NJH /NP";

            if (mt.ThreadingEnabled)
            {
                if (mt.NumThreads < 1 || mt.NumThreads > 128)
                    mt.NumThreads = 8;
                retVal += " /MT:" + mt.NumThreads;
            }

            if (!string.IsNullOrEmpty(log.LogTo) && log.Enabled)
            {
                retVal += @" /TEE /V /LOG+:" + log.LogTo + "\"";
            }

            return retVal;
        }
Exemple #14
0
        private void Log(string title,Logging.LoggingEntery.EnteryTypes ET)
        {
            string SubSendor;
            if (this.ProtocolParameters.Name==null)
            {
                SubSendor = this.GetType().Name;
            }
            else
            {
                SubSendor = string.Format("{0}({1})",this.GetType().Name,this.ProtocolParameters.Name);
            }

            Logging.Log.LogEntery(new Logging.LoggingEntery("OctoTipPlus Appilcation",SubSendor ,title,ET));
        }
Exemple #15
0
 protected void ProtocolLog(string Title,string Messege , Logging.LoggingEntery.EnteryTypes ET)
 {
     Logging.Log.LogEntery(new Logging.LoggingEntery(this.GetType().Name,this.ProtocolParameters.Name,Title,Messege,ET));
 }