Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //var _sourceDirectory = ConfigurationManager.AppSettings["SourceDirectory"];
            var _destinationDirectory = ConfigurationManager.AppSettings["DestinationPath"];

            var _sourceDirectory = AppDomain.CurrentDomain.BaseDirectory + @"\Data";

            //check source directory existence
            if (!Directory.Exists(_sourceDirectory))
            {
                Console.WriteLine("The source directory does not exist.");
                Console.ReadKey();
                return;
            }

            //Get all the files from source directory
            String[] files = Directory.GetFiles(_sourceDirectory);

            //Read all the files and get data
            var dataToBeComputed = Utility.ReadInputFiles(files);

            Console.WriteLine(string.Format("\nTotal records prior to Calculation : {0}", dataToBeComputed.Count));

            //Calculate Average age countrywise
            var computedData = new ComputeEngine().CalculateAverageAge(dataToBeComputed);

            Console.WriteLine(string.Format("Total records post Calculation : {0}", computedData.Count));

            //Write output data to json file
            Utility.WriteOutputJsonFile(_destinationDirectory, computedData);
            Console.ReadKey();
        }
Exemplo n.º 2
0
    public Document(FractalSettings settings)
        : base(NSObject.AllocAndInitInstance("Document"))
    {
        m_settings = settings;

        AppDelegate app = NSApplication.sharedApplication().delegate_().To<AppDelegate>();

        m_engine = new ComputeEngine(m_settings);
        m_palette = app.DefaultPalette;
    }
Exemplo n.º 3
0
    private Document(IntPtr instance)
        : base(instance)
    {
        m_settings.Area = 400*400;
        m_settings.MaxDwell = 200;
        m_settings.Extent = new Rect(
            new Complex(BigFloat.DefaultLeft, BigFloat.DefaultTop),
            new Complex(BigFloat.DefaultRight, BigFloat.DefaultBottom));

        AppDelegate app = NSApplication.sharedApplication().delegate_().To<AppDelegate>();

        m_engine = new ComputeEngine(m_settings);
        m_palette = app.DefaultPalette;
    }
Exemplo n.º 4
0
        public override void Run()
        {
            while (!_stopping)
            {
                CloudStorageAccount account = CloudStorageAccount.Parse(
                    CloudConfigurationManager.GetSetting("TaskStorage")
                    );

                var blobClient = account.CreateCloudBlobClient();
                var container  = blobClient.GetContainerReference("Requests");
                container.CreateIfNotExists();

                var item = container.ListBlobs().FirstOrDefault();
                if (item == null)
                {
                    Thread.Sleep(5);
                }

                var blob    = new CloudBlockBlob(item.Uri);
                var request = JsonConvert.DeserializeObject <ComputationRequest>(blob.DownloadText());

                string title = null;
                string text  = null;

                title = "Task computing started";
                text  = JsonConvert.SerializeObject(request, Formatting.Indented);

                SendEmail(request, title, text);

                ComputationResult result = null;
                try
                {
                    using (ComputeEngine engine = new ComputeEngine())
                    {
                        result = engine.calculate(request);
                    }
                    title = "Task computing complete";
                    text  = result.ToString();
                }
                catch (Exception ex)
                {
                    title = "Task computing failed";
                    text  = ex.Message;
                }

                SendEmail(request, title, text);
            }
        }
Exemplo n.º 5
0
 public void Setup()
 {
     _engine   = new ComputeEngine();
     _computer = new IntCodeComputer();
     _computer.AddEngine(_engine);
 }
 public void SetUp()
 {
     this.instancesResource = ComputeEngine.Connect().Service.Instances;
 }
Exemplo n.º 7
0
    // document().undoManager().setActionName should be called after this is called.
    public void updateSettings(Wrapper wrapper)
    {
        FractalSettings newSettings = (FractalSettings) wrapper.Value;

        if (newSettings != m_settings)
        {
            Wrapper oldSettings = Wrapper.Create(m_settings);
            undoManager().registerUndoWithTarget_selector_object(this, "updateSettings:", oldSettings);

            m_engine.Abort();
            m_settings = newSettings;
            m_engine = new ComputeEngine(m_settings);

            NSNotificationCenter.defaultCenter().postNotificationName_object(
                StateChanged, DocChange.Create(this, ChangeType.Settings));
        }
    }
Exemplo n.º 8
0
    public bool readFromData_ofType_error(NSData data, NSString typeName, IntPtr outError)
    {
        bool read = false;

        try
        {
            using (MemoryStream stream = new MemoryStream(data.bytes()))
            {
                var doc = new XmlDocument();
                doc.Load(stream);

                DoParseXml(doc);
                m_engine = new ComputeEngine(m_settings);

                Marshal.WriteIntPtr(outError, IntPtr.Zero);
                read = true;

                NSNotificationCenter.defaultCenter().postNotificationName_object(
                    StateChanged, DocChange.Create(this, ChangeType.All));
            }
        }
        catch (Exception e)
        {
            Console.Error.WriteLine("{0}", e);

            NSMutableDictionary userInfo = NSMutableDictionary.Create();
            userInfo.setObject_forKey(NSString.Create("Couldn't read the document."), Externs.NSLocalizedDescriptionKey);
            userInfo.setObject_forKey(NSString.Create(e.Message), Externs.NSLocalizedFailureReasonErrorKey);

            NSObject error = NSError.errorWithDomain_code_userInfo(Externs.Cocoa3Domain, 1, userInfo);
            Marshal.WriteIntPtr(outError, error);
        }

        return read;
    }