Exemplo n.º 1
0
        private void method_11()
        {
            this.class617_7.MaxDecompressedPageSize = 128;
            FileDependencyCollection dependencyCollection = new FileDependencyCollection();

            if (dependencyCollection.Count > 1)
            {
                this.class617_7.MaxDecompressedPageSize = 128 * dependencyCollection.Count;
            }
            this.class617_7.Encrypted = 2;
            MemoryStream  memoryStream = new MemoryStream();
            Class889      class889     = Class889.Create((Stream)memoryStream, this.dxfVersion_0, this.encoding_0);
            List <string> stringList   = new List <string>();

            foreach (FileDependency.Key key in dependencyCollection.Keys)
            {
                if (!stringList.Contains(key.FeatureName))
                {
                    stringList.Add(key.FeatureName);
                }
            }
            class889.vmethod_9(stringList.Count);
            foreach (string str in stringList)
            {
                class889.vmethod_22(str);
            }
            class889.vmethod_9(dependencyCollection.Count);
            DateTime dateTime = new DateTime(1980, 1, 1);

            foreach (FileDependency.Key key in dependencyCollection.Keys)
            {
                FileDependency fileDependency = dependencyCollection[key];
                if (fileDependency.FeatureName == "Acad:Text")
                {
                    string str = DxfTextStyle.smethod_2(Class1043.smethod_2(this.dxfModel_0.Filename), fileDependency.FullFilename);
                    if (!string.IsNullOrEmpty(str) && File.Exists(str))
                    {
                        FileInfo fileInfo = new FileInfo(str);
                        fileDependency.TimeStamp = fileInfo.LastWriteTime;
                        fileDependency.FileSize  = (int)fileInfo.Length;
                    }
                }
                class889.vmethod_22(fileDependency.FullFilename);
                class889.vmethod_22(fileDependency.FoundPath);
                class889.vmethod_22(fileDependency.FingerPrintGuid);
                class889.vmethod_22(fileDependency.VersionGuid);
                class889.vmethod_9(stringList.IndexOf(fileDependency.FeatureName));
                TimeSpan timeSpan = fileDependency.TimeStamp - dateTime;
                class889.vmethod_9((int)timeSpan.TotalSeconds);
                class889.vmethod_9(fileDependency.FileSize);
                class889.vmethod_5(fileDependency.AffectsGraphics ? (short)1 : (short)0);
                class889.vmethod_9(fileDependency.References.Count);
            }
            this.method_23(this.class617_7, memoryStream, false);
        }
        public void AddTestSimpleScenario()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency           fd1        = new FileDependencyMock(@"c:\test1.txt");
            FileDependency           fd2        = new FileDependencyMock(@"c:\test2.txt");

            collection.Add(fd1);
            collection.Add(fd2);

            Assert.IsTrue(collection.Contains(fd1));
            Assert.IsTrue(collection.Contains(fd2));
        }
        public void ContainsTestDependencyFound()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency           fd1        = new FileDependencyMock(@"c:\test1.txt");
            FileDependency           fd2        = new FileDependencyMock(@"c:\test2.txt");

            collection.Add(fd1);
            collection.Add(fd2);

            bool result = collection.Contains(fd1);

            Assert.IsTrue(result);
        }
        public void ContainsTestDependencyNotFound()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency           fd1        = new FileDependencyTestFiller(@"c:\test1.txt");
            FileDependency           fd2        = new FileDependencyTestFiller(@"c:\test2.txt");
            FileDependency           fd3        = new FileDependencyTestFiller(@"c:\test3.txt");

            collection.Add(fd1);
            collection.Add(fd2);

            bool result = collection.Contains(fd3);

            Assert.IsFalse(result);
        }
        public void ContainsTestDependencyFoundCaseOnlyDifferent()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency           fd1        = new FileDependencyTestFiller(@"c:\test1.txt");
            FileDependency           fd2        = new FileDependencyTestFiller(@"c:\test2.txt");
            FileDependency           fd3        = new FileDependencyTestFiller(@"c:\TEST2.txt");

            collection.Add(fd1);
            collection.Add(fd2);

            bool result = collection.Contains(fd3);

            Assert.IsTrue(result);
        }
        public void AddListTestSimpleScenario()
        {
            FileDependencyCollection collection = new FileDependencyCollection();

            FileDependency[] fdList = new FileDependency[2];
            FileDependency   fd1    = new FileDependencyMock(@"c:\test1.txt");
            FileDependency   fd2    = new FileDependencyMock(@"c:\test2.txt");

            fdList[0] = fd1;
            fdList[1] = fd2;

            collection.Add(fdList);

            Assert.IsTrue(collection.Contains(fd1));
            Assert.IsTrue(collection.Contains(fd2));
        }
        public void AddListTestNullValue()
        {
            FileDependencyCollection collection = new FileDependencyCollection();

            try
            {
                collection.Add((FileDependency[])null);

                Assert.IsTrue(false, "Adding a null value to the collection should throw an InvalidOretationException.");
            }
            catch (InvalidOperationException e)
            {
                Console.Write(e);
                // pass if we get here
                Assert.IsTrue(true);
            }
        }
Exemplo n.º 8
0
        // the caller of this method will lock the GridAppDomains, so no worries:
        // no need to lock it here.
        private void GetManifestAndSetupDomain()
        {
            string appDir = ExecutorUtil.GetApplicationDirectory(_CurTi.ApplicationId);

            logger.Debug("AppDir on executor=" + appDir);

            // make sure that by the time the lock was acquired the app domain is still not created
            if (!_GridAppDomains.ContainsKey(_CurTi.ApplicationId))
            {
                // create application domain for newly encountered grid application
                logger.Debug("app dir on executor: " + appDir);

                if (!Directory.Exists(appDir))
                {
                    Directory.CreateDirectory(appDir);
                }

                FileDependencyCollection manifest = _Manager.Executor_GetApplicationManifest(
                    _Credentials, _CurTi.ApplicationId);
                if (manifest != null)
                {
                    foreach (FileDependency dep in manifest)
                    {
                        logger.Debug("Unpacking file: " + dep.FileName + " to " + appDir);
                        dep.UnpackToFolder(appDir);
                    }
                }
                else
                {
                    logger.Warn("Executor_GetApplicationManifest from the Manager returned null");
                }

                CreateSandboxDomain(appDir);

                logger.Info("Created app domain, policy, got instance of GridAppDomain and added to hashtable...all done once for this application");
            }
            else
            {
                logger.Info("I got the lock but this app domain is already created.");
            }
        }
        public void AddTestDuplicatedValue()
        {
            FileDependencyCollection collection = new FileDependencyCollection();
            FileDependency           fd1        = new FileDependencyMock(@"c:\test1.txt");
            FileDependency           fd2        = new FileDependencyMock(@"c:\test1.txt");

            collection.Add(fd1);

            try
            {
                collection.Add(fd2);

                Assert.IsTrue(false, "Adding a duplicate value to the collection should throw an InvalidOretationException.");
            }
            catch (InvalidOperationException e)
            {
                Console.Write(e);
                // pass if we get here
                Assert.IsTrue(true);
            }
        }
Exemplo n.º 10
0
        private void ExecuteThreadInAppDomain()
        {
            byte[] rawThread = null;

            try
            {
                logger.Info("Started ExecuteThreadInAppDomain...");

                logger.Info(string.Format("executing grid thread # {0}.{1}", _CurTi.ApplicationId, _CurTi.ThreadId));

                string appDir = GetApplicationDirectory(_CurTi.ApplicationId);
                logger.Debug("AppDir on executor=" + appDir);

                if (!_GridAppDomains.Contains(_CurTi.ApplicationId))
                {
                    lock (_GridAppDomains)
                    {
                        // make sure that by the time the lock was acquired the app domain is still not created
                        if (!_GridAppDomains.Contains(_CurTi.ApplicationId))
                        {
                            // create application domain for newly encountered grid application
                            logger.Debug("app dir on executor: " + appDir);

                            //before initializing clear dir..
                            foreach (string F in Directory.GetFiles(appDir))
                            {
                                try //becoz exception should not be created for an issue as small as this
                                {
                                    File.Delete(F);
                                }
                                catch (Exception ex)
                                {
                                }
                            }

                            FileDependencyCollection manifest = Manager.Executor_GetApplicationManifest(Credentials, _CurTi.ApplicationId);
                            if (manifest != null)
                            {
                                foreach (FileDependency dep in manifest)
                                {
                                    try //so that IO error does not occur if files already exist
                                    {
                                        logger.Debug("Unpacking file: " + dep.FileName + " to " + appDir);
                                        dep.UnPackToFolder(appDir);
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                            }
                            else
                            {
                                logger.Warn("Executor_GetApplicationManifest from the Manager returned null");
                            }


                            initialize_GridThreadExecutor();

                            _GridAppDomains.Add(
                                _CurTi.ApplicationId,
                                new GridAppDomain(GridThreadApplicationDomain, GridThreadExecutor)
                                );

                            logger.Info("Created app domain, policy, got instance of GridAppDomain and added to hashtable...all done once for this application");
                        }
                        else
                        {
                            logger.Info("I got the lock but this app domain is already created.");
                        }
                    }
                }

                //get thread from manager
                GridAppDomain gad = (GridAppDomain)_GridAppDomains[_CurTi.ApplicationId];

                //if we have an exception in the secondary appdomain, it will raise an exception in this method, since the cross-app-domain call
                //uses remoting internally, and it is just as if a remote method has caused an exception. we have a handler for that below anyway.

                rawThread = Manager.Executor_GetThread(Credentials, _CurTi);
                logger.Debug("Got thread from manager. executing it: " + _CurTi.ThreadId);

                //execute it

                byte[] finishedThread = gad.Executor.ExecuteThread(rawThread);
                logger.Info(string.Format("ExecuteThread returned for thread # {0}.{1}", _CurTi.ApplicationId, _CurTi.ThreadId));


                //set its status to finished
                Manager.Executor_SetFinishedThread(Credentials, _CurTi, finishedThread, null);
                logger.Info(string.Format("Finished executing grid thread # {0}.{1}", _CurTi.ApplicationId, _CurTi.ThreadId));
            }
            catch (ThreadAbortException)
            {
                if (_CurTi != null)
                {
                    logger.Warn(string.Format("aborted grid thread # {0}.{1}", _CurTi.ApplicationId, _CurTi.ThreadId));
                }
                else
                {
                    logger.Warn(string.Format("aborted grid thread # {0}.{1}", null, null));
                }

                Thread.ResetAbort();
            }
            catch (Exception e)
            {
                logger.Warn(string.Format("grid thread # {0}.{1} failed ({2})", _CurTi.ApplicationId, _CurTi.ThreadId, e.GetType()), e);
                try
                {
                    //some exceptions such as Win32Exception caused problems when passed directly into this method.
                    //so better create another new exception object and send it over.
                    Exception eNew = new Exception(e.ToString());
                    Manager.Executor_SetFinishedThread(Credentials, _CurTi, rawThread, eNew);
                }
                catch (Exception ex1)
                {
                    if (_CurTi != null)
                    {
                        logger.Warn("Error trying to set failed thread for App: " + _CurTi.ApplicationId + ", thread=" + _CurTi.ThreadId + ". Original Exception = \n" + e.ToString(), ex1);
                    }
                    else
                    {
                        logger.Warn("Error trying to set failed thread: Original exception = " + e.ToString(), ex1);
                    }
                }
            }
            finally
            {
                _CurTi = null;
                _ReadyToExecute.Set();

                logger.Info("Exited ExecuteThreadInAppDomain...");
            }
        }