Esempio n. 1
0
        internal virtual Replication ReplicationWithDatabase(Database db, Uri remote, bool
                                                             push, bool create, bool start)
        {
            foreach (Replication replicator in replications)
            {
                if (replicator.GetLocalDatabase() == db && replicator.GetRemoteUrl().Equals(remote
                                                                                            ) && replicator.IsPull() == !push)
                {
                    return(replicator);
                }
            }
            if (!create)
            {
                return(null);
            }
            Replication replicator_1 = null;
            bool        continuous   = false;

            if (push)
            {
                replicator_1 = new Pusher(db, remote, continuous, GetWorkExecutor());
            }
            else
            {
                replicator_1 = new Puller(db, remote, continuous, GetWorkExecutor());
            }
            replications.AddItem(replicator_1);
            if (start)
            {
                replicator_1.Start();
            }
            return(replicator_1);
        }
Esempio n. 2
0
 void Inputs()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         if (puller != null)
         {
             pull        = puller.GetComponent <Puller>();
             rb.velocity = (pull.transform.position - transform.position) * pull.pullForce;
             audioSrc.PlayOneShot(flySound);
         }
         if (launcher != null)
         {
             launch       = launcher.GetComponent <LauncherScript>();
             rb.velocity += Vector3.up * launch.force;
             audioSrc.PlayOneShot(dingSound);
         }
         if (canUseDetonator())
         {
             GameObject lab = GameObject.FindGameObjectWithTag("Lab");
             audioSrc.PlayOneShot(distantExplosionSound);
             Instantiate(hugeExplosionPrefab, lab.transform.position, lab.transform.rotation);
             lab.gameObject.SetActive(false);
             detonatorUsed = true;
         }
     }
     if (Input.GetKeyDown(KeyCode.Z))
     {
         audioSrc.pitch = (audioSrc.pitch == 0.75f ? 1f : 0.75f);
     }
     if (Input.GetKeyDown(KeyCode.X))
     {
         audioSrc.pitch = (audioSrc.pitch == 1.5f ? 1f : 1.5f);
     }
 }
Esempio n. 3
0
        public void Registe(string subject, string group, ExtraListenerConfig config)
        {
            var consumer = PullConsumers.DefaultConsumer(subject, group, config.Mode, _appCode, _metaServer);
            var puller   = new Puller((DefaultPullConsumer)consumer, config, _handler);

            if (PULLERS.TryAdd($"{subject}/{group}", puller))
            {
                puller.Start();
            }
        }
Esempio n. 4
0
    public void SetPuller(Puller newPuller)
    {
        puller = newPuller;

        if (newPuller != null) {
            transform.parent = newPuller.transform.parent;
        } else {
            transform.parent = null;
        }
    }
Esempio n. 5
0
    public static void UpdatePullers(Puller target)
    {
        target.gameObject.layer = LayerMask.NameToLayer("Puller");

        Collider2D  collider2D  = target.GetComponent <Collider2D>();
        Rigidbody2D rigidbody2D = target.GetComponent <Rigidbody2D>();

        if (collider2D != null)
        {
            DestroyImmediate(collider2D);
        }

        if (rigidbody2D != null)
        {
            DestroyImmediate(rigidbody2D);
        }

        BoxCollider2D boxCollider2D = target.gameObject.AddComponent <BoxCollider2D>();

        boxCollider2D.isTrigger            = true;
        boxCollider2D.size                 = new Vector2(0.2f, 0.2f);
        rigidbody2D                        = target.gameObject.AddComponent <Rigidbody2D>();
        rigidbody2D.bodyType               = RigidbodyType2D.Kinematic;
        rigidbody2D.collisionDetectionMode = CollisionDetectionMode2D.Continuous;

        Transform content   = target.transform.Find("content");
        Transform pullerEnd = content.transform.Find("puller_end");

        collider2D  = pullerEnd.GetComponent <Collider2D>();
        rigidbody2D = pullerEnd.GetComponent <Rigidbody2D>();

        if (collider2D != null)
        {
            DestroyImmediate(collider2D);
        }

        if (rigidbody2D != null)
        {
            DestroyImmediate(rigidbody2D);
        }

        boxCollider2D                      = pullerEnd.gameObject.AddComponent <BoxCollider2D>();
        boxCollider2D.isTrigger            = true;
        boxCollider2D.size                 = new Vector2(0.2f, 0.2f);
        rigidbody2D                        = pullerEnd.gameObject.AddComponent <Rigidbody2D>();
        rigidbody2D.bodyType               = RigidbodyType2D.Kinematic;
        rigidbody2D.collisionDetectionMode = CollisionDetectionMode2D.Continuous;
        pullerEnd.gameObject.layer         = LayerMask.NameToLayer("Puller");
    }
Esempio n. 6
0
        public void Initialize()
        {
            var utxoHash = _utxoSet.GetBlockHashAsync().GetAwaiter().GetResult();

            while (true)
            {
                _Tip = Chain.GetBlock(utxoHash);
                if (_Tip != null)
                {
                    break;
                }
                utxoHash = _utxoSet.Rewind().GetAwaiter().GetResult();
            }
            Puller.SetLocation(Tip);
            bip9 = new ThresholdConditionCache(_Validator.ConsensusParams);
        }
Esempio n. 7
0
        private void btnScrapp_Click(object sender, EventArgs e)
        {
            if (productInfoList.Count == 0)
            {
                MessageBox.Show("Selected Sheet is empty");
                return;
            }
            SqlServerOperation operation = SqlServerOperation.Instance;

            operation.SetDataSets(dataSets.SelectedItem.ToString(), tblName.SelectedItem.ToString());

            bool    updateFlag = updCheck.Checked;
            Browser browser    = new Browser(Browser.Type.CHROME, false);
            Puller  dataPuller = new Puller();

            foreach (var info in productInfoList)
            {
                try
                {
                    if (!templates.ContainsKey(info.Template))
                    {
                        if (!ReadTemplate(info.Template))
                        {
                            Log.Exception("Scrapping failed for " + info.Url);
                            continue;
                        }
                    }
                    DataModel dataModel = templates[info.Template];
                    if (staticRb.Checked)
                    {
                        StaticSite target = new StaticSite(browser, dataModel.name, info.Url, dataModel, 1, info.LastPageNo, info.Name, dataModel.nextPageSelectorElement, int.Parse(siteLoad.Text), int.Parse(pageLoad.Text), dataModel.siteActions, dataModel.pageActions);
                        dynamic    sitena = dataPuller.PullData(target, updateFlag);
                    }
                    else
                    {
                        DynamicSite target = new DynamicSite(browser, dataModel.name, info.Url, dataModel, info.Url, urlSplitterTb.Text, int.Parse(incTb.Text), info.Name, int.Parse(siteLoad.Text), int.Parse(pageLoad.Text), dataModel.siteActions, dataModel.pageActions, 1, info.LastPageNo);
                        dynamic     sitena = dataPuller.PullData(target, updateFlag);
                    }
                }
                catch (Exception ex)
                {
                    Log.Exception("Scrapping failed for " + info.Url);
                }
            }
            MessageBox.Show("Scrapping has been completed !!");
        }
Esempio n. 8
0
        public BlockResult ExecuteNextBlock(CancellationToken cancellationToken)
        {
            BlockResult result = new BlockResult();

            try
            {
                using (watch.Start(o => Validator.PerformanceCounter.AddBlockFetchingTime(o)))
                {
                    while (true)
                    {
                        result.Block = Puller.NextBlock(cancellationToken);
                        if (result.Block != null)
                        {
                            break;
                        }
                        else
                        {
                            while (true)
                            {
                                var hash     = UTXOSet.Rewind().GetAwaiter().GetResult();
                                var rewinded = Chain.GetBlock(hash);
                                if (rewinded == null)
                                {
                                    continue;
                                }
                                _Tip = rewinded;
                                Puller.SetLocation(rewinded);
                                break;
                            }
                        }
                    }
                }

                this.AcceptBlock(result);
            }
            catch (ConsensusErrorException ex)
            {
                result.Error = ex.ConsensusError;
            }
            return(result);
        }
Esempio n. 9
0
        private void drawParallepiped()
        {
            double height, width, length;
            int    angle;

            if (
                double.TryParse(numericUpDown3.Value.ToString(), out height)
                & double.TryParse(numericUpDown4.Value.ToString(), out width)
                & double.TryParse(numericUpDown5.Value.ToString(), out length)
                & int.TryParse(numericUpDown6.Value.ToString(), out angle)
                )
            {
                height /= 100;
                width  /= 100;
                length /= 100;


                Pekok.SolidWorks.OpenDoc();

                Pekok.SolidWorks.swDoc.ClearSelection();
                Pekok.SolidWorks.swDoc.SketchManager.Insert3DSketch(false);

                Pekok.Figure.Parallelepiped circle = new Pekok.Figure.Parallelepiped(0, 0, 0,
                                                                                     length, 0, 0,
                                                                                     length + width / Math.Tan(angle * Math.PI / 180), width, 0);

                object[] ss = circle.draw(Pekok.SolidWorks.swDoc.SketchManager);
                foreach (object b in ss)
                {
                    ((SketchSegment)b).Select(true);
                }

                Feature f = Puller.Extrude(Pekok.SolidWorks.swDoc, height);
                if (f != null)
                {
                    isCreatedCub = true;
                }
                Pekok.SolidWorks.swDoc.ClearSelection();
            }
        }
Esempio n. 10
0
            async void Pull()
            {
                string link = await Puller.New_Pull(DBVid?.VideoId ?? "");

                if (!string.IsNullOrEmpty(link))
                {
                    IMediaFile mediaFile = new MediaFile(link, MediaFileType.Audio, ResourceAvailability.Remote)
                    {
                        Metadata = new MediaFileMetadata
                        {
                            Title  = "ecks dee",
                            Artist = "Volunteer Park Trust",
                            Album  = "Walking Tour"
                        }
                    };
                    //mediaFile = await CrossMediaManager.Current.MediaExtractor.ExtractMediaInfo(mediaFile);
                    await CrossMediaManager.Current.Play(mediaFile);

                    CrossMediaManager.Current.MediaNotificationManager.StartNotification(mediaFile);
                    CrossMediaManager.Current.MediaNotificationManager.UpdateNotifications(mediaFile, MediaPlayerStatus.Playing);
                }
            }
Esempio n. 11
0
        private void drawPentagon(PointD center, PointD vertex, double height, int ii)
        {
            Pekok.SolidWorks.swDoc.Extension.SelectByID2(TOP, "PLANE", 0, 0, 0, false, 0, null, 0);

            Pekok.SolidWorks.swDoc.SketchManager.InsertSketch(false);

            object[] sss = Pekok.SolidWorks.swDoc.SketchManager.CreatePolygon(center.X, center.Y, center.Z, vertex.X, vertex.Y, vertex.Z, 5, true);

            foreach (object b in sss)
            {
                ((SketchSegment)b).Select(true);
            }

            Pekok.SolidWorks.swDoc.SketchManager.InsertSketch(true);

            Pekok.SolidWorks.swDoc.Extension.SelectByID2("Sketch" + ii, "SKETCH", 0, 0, 0, false, 0, null, 0);
            Pekok.SolidWorks.swDoc.ClearSelection2(true);
            Pekok.SolidWorks.swDoc.Extension.SelectByID2("Sketch" + ii, "SKETCH", 0, 0, 0, false, 4, null, 0);

            Feature g = Puller.Cut(Pekok.SolidWorks.swDoc, height);

            Pekok.SolidWorks.swDoc.ClearSelection();
        }
Esempio n. 12
0
    public static void ApplyMask(Puller target)
    {
        Transform parent    = target.transform.parent;
        Match     match     = Regex.Match(parent.name, @"(\d+)");
        string    layer     = match.Value;
        int       layerId   = SortingLayer.NameToID(layer);
        Transform content   = target.transform.Find("content");
        Transform pullerEnd = content.transform.Find("puller_end");

        Vector3 direction = pullerEnd.localPosition;

        direction   = direction.normalized;
        direction.z = 0;

        float distance = Vector3.Distance(content.transform.localPosition, pullerEnd.localPosition);


        SpriteRenderer[] renderers = content.GetComponentsInChildren <SpriteRenderer>();
        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
            renderers[i].sortingLayerID  = layerId;
        }

        Transform mask = target.transform.Find("mask");

        mask.right         = direction;
        mask.localPosition = direction * (distance / 2);
        mask.localScale    = new Vector3(distance, mask.localScale.y, 1);

        SpriteMask spriteMask = mask.GetComponent <SpriteMask>();

        spriteMask.frontSortingLayerID = layerId;
        spriteMask.frontSortingOrder   = 0;
        spriteMask.backSortingLayerID  = layerId;
        spriteMask.backSortingOrder    = -1;
    }
Esempio n. 13
0
        // This is used by the listener
        internal Replication ReplicationWithProperties(IDictionary <string, object> properties)
        {
            // Extract the parameters from the JSON request body:
            // http://wiki.apache.org/couchdb/Replication

            bool push, createTarget;
            var  results = new Dictionary <string, object>()
            {
                { "database", null },
                { "remote", null },
                { "headers", null },
                { "authorizer", null }
            };

            Status result = ParseReplicationProperties(properties, out push, out createTarget, results);

            if (result.IsError)
            {
                throw Misc.CreateExceptionAndLog(Log.To.Listener, result.Code, TAG, "Failed to create replication");
            }

            object continuousObj = properties.Get("continuous");
            bool   continuous    = false;

            if (continuousObj is bool)
            {
                continuous = (bool)continuousObj;
            }

            var         scheduler = new SingleTaskThreadpoolScheduler();
            Replication rep       = null;

            if (push)
            {
                rep = new Pusher((Database)results["database"], (Uri)results["remote"], continuous, new TaskFactory(scheduler));
            }
            else
            {
                rep = new Puller((Database)results["database"], (Uri)results["remote"], continuous, new TaskFactory(scheduler));
            }

            rep.Filter       = properties.Get("filter") as string;
            rep.FilterParams = properties.Get("query_params").AsDictionary <string, object>();
            rep.DocIds       = properties.Get("doc_ids").AsList <string>();
            rep.Headers      = new Dictionary <string, string>();
            foreach (var header in results.Get("headers").AsDictionary <string, string>())
            {
                if (header.Key.ToLowerInvariant() == "cookie")
                {
                    var cookie = default(Cookie);
                    if (CookieParser.TryParse(header.Value, ((Uri)results["remote"]).GetLeftPart(UriPartial.Authority), out cookie))
                    {
                        rep.SetCookie(cookie.Name, cookie.Value, cookie.Path, cookie.Expires, cookie.Secure, cookie.HttpOnly);
                    }
                    else
                    {
                        Log.To.Listener.W(TAG, "Invalid cookie string received ({0}), ignoring...", header.Value);
                    }
                }
                else
                {
                    rep.Headers.Add(header.Key, header.Value);
                }
            }
            rep.Headers       = results.Get("headers").AsDictionary <string, string>();
            rep.Authenticator = results.Get("authorizer") as IAuthenticator;
            if (push)
            {
                ((Pusher)rep).CreateTarget = createTarget;
            }

            var db = (Database)results["database"];

            // If this is a duplicate, reuse an existing replicator:
            var activeReplicators = default(IList <Replication>);
            var existing          = default(Replication);

            if (db.ActiveReplicators.AcquireTemp(out activeReplicators))
            {
                existing = activeReplicators.FirstOrDefault(x => x.LocalDatabase == rep.LocalDatabase &&
                                                            x.RemoteUrl == rep.RemoteUrl && x.IsPull == rep.IsPull &&
                                                            x.RemoteCheckpointDocID().Equals(rep.RemoteCheckpointDocID()));
            }


            return(existing ?? rep);
        }
Esempio n. 14
0
        internal Replication ReplicationWithProperties(IDictionary <string, object> properties)
        {
            // Extract the parameters from the JSON request body:
            // http://wiki.apache.org/couchdb/Replication

            bool push, createTarget;
            var  results = new Dictionary <string, object>()
            {
                { "database", null },
                { "remote", null },
                { "headers", null },
                { "authorizer", null }
            };

            Status result = ParseReplicationProperties(properties, out push, out createTarget, results);

            if (result.IsError)
            {
                throw new CouchbaseLiteException(result.Code);
            }

            object continuousObj = properties.Get("continuous");
            bool   continuous    = false;

            if (continuousObj is bool)
            {
                continuous = (bool)continuousObj;
            }

            var         scheduler = new SingleTaskThreadpoolScheduler();
            Replication rep       = null;

            if (push)
            {
                rep = new Pusher((Database)results["database"], (Uri)results["remote"], continuous, new TaskFactory(scheduler));
            }
            else
            {
                rep = new Puller((Database)results["database"], (Uri)results["remote"], continuous, new TaskFactory(scheduler));
            }

            rep.Filter         = properties.Get("filter") as string;
            rep.FilterParams   = properties.Get("query_params") as IDictionary <string, object>;
            rep.DocIds         = properties.Get("doc_ids") as IEnumerable <string>;
            rep.RequestHeaders = results.Get("headers") as IDictionary <string, object>;
            rep.Authenticator  = results.Get("authorizer") as IAuthenticator;
            if (push)
            {
                ((Pusher)rep).CreateTarget = createTarget;
            }

            var db = (Database)results["database"];

            // If this is a duplicate, reuse an existing replicator:
            var existing = db.ActiveReplicators.FirstOrDefault(x => x.LocalDatabase == rep.LocalDatabase &&
                                                               x.RemoteUrl == rep.RemoteUrl && x.IsPull == rep.IsPull &&
                                                               x.RemoteCheckpointDocID().Equals(rep.RemoteCheckpointDocID()));


            return(existing ?? rep);
        }
Esempio n. 15
0
 private void OnEnable()
 {
     this.target = base.target as Puller;
 }
Esempio n. 16
0
 private void Awake()
 {
     this.puller = this.GetComponentInParent <Puller>();
 }
Esempio n. 17
0
 protected override void Awake()
 {
     base.Awake();
     puller = GetComponent <Puller>();
 }
Esempio n. 18
0
 protected override void Awake()
 {
     base.Awake();
     animator = GetComponent <Animator>();
     puller   = GetComponentInChildren <Puller>();
 }
Esempio n. 19
0
		public virtual void TestRunReplicationWithError()
		{
            var mockHttpClientFactory = new AlwaysFailingClientFactory();
			var dbUrlString = "http://fake.test-url.com:4984/fake/";
            var remote = new Uri(dbUrlString);
            var continuous = false;
            var r1 = new Puller(database, remote, continuous, mockHttpClientFactory, manager.workExecutor);
			Assert.IsFalse(r1.Continuous);

            RunReplication(r1);

			// It should have failed with a 404:
            Assert.AreEqual(ReplicationStatus.Stopped, r1.Status);			
			Assert.AreEqual(0, r1.CompletedChangesCount);
			Assert.AreEqual(0, r1.ChangesCount);
			Assert.IsNotNull(r1.LastError);
		}
Esempio n. 20
0
 public void RegisterNewPuller(Puller puller)
 {
     this.pullers.Add(puller);
 }
Esempio n. 21
0
 internal Replication ReplicationWithDatabase(Database db, Uri remote, bool push, 
     bool create, bool start)
 {
     foreach (Replication replicator in replications)
     {
         if (replicator.GetLocalDatabase() == db && replicator.GetRemoteUrl().Equals(remote
             ) && replicator.IsPull() == !push)
         {
             return replicator;
         }
     }
     if (!create)
     {
         return null;
     }
     Replication replicator_1 = null;
     bool continuous = false;
     if (push)
     {
         replicator_1 = new Pusher(db, remote, continuous, GetWorkExecutor());
     }
     else
     {
         replicator_1 = new Puller(db, remote, continuous, GetWorkExecutor());
     }
     replications.AddItem(replicator_1);
     if (start)
     {
         replicator_1.Start();
     }
     return replicator_1;
 }
Esempio n. 22
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestRunReplicationWithError()
		{
			HttpClientFactory mockHttpClientFactory = new _HttpClientFactory_516();
			string dbUrlString = "http://fake.test-url.com:4984/fake/";
			Uri remote = new Uri(dbUrlString);
			bool continuous = false;
			Replication r1 = new Puller(database, remote, continuous, mockHttpClientFactory, 
				manager.GetWorkExecutor());
			NUnit.Framework.Assert.IsFalse(r1.IsContinuous());
			RunReplication(r1);
			// It should have failed with a 404:
			NUnit.Framework.Assert.AreEqual(Replication.ReplicationStatus.ReplicationStopped, 
				r1.GetStatus());
			NUnit.Framework.Assert.AreEqual(0, r1.GetCompletedChangesCount());
			NUnit.Framework.Assert.AreEqual(0, r1.GetChangesCount());
			NUnit.Framework.Assert.IsNotNull(r1.GetLastError());
		}