Exemple #1
0
        public void AddOutGoing(BFGTDenseNode2 y)
        {
            Outgoing.Add(new KVP2(y.Level, y));
            y.InDegree++;

            if (!Bound[0].ContainsKey(y.Index))
            {
                Bound[0].Add(y.Index, 1);
            }
            if (!Count[0].ContainsKey(y.Index))
            {
                Count[0].Add(y.Index, 0);
            }

            /*
             * if (!Bound.ContainsKey(0))
             * {
             *  Bound.Add(0, new Dictionary<int, int>());
             *  Bound[0].Add(y.Index, 1);
             * }
             * if (!Count.ContainsKey(0))
             * {
             *  Count.Add(0, new Dictionary<int, int>());
             *  Count[0].Add(y.Index, 0);
             * }*/
        }
Exemple #2
0
        public void Connect(INode node, Velocity traversalVelocity)
        {
            Edge edge = new Edge(this, node, traversalVelocity);

            Outgoing.Add(edge);
            node.Incoming.Add(edge);
        }
        protected override void ProcessOutgoingData(byte[] buff, int start, int len)
        {
            var type = (Utilities.PackType)buff[start];

            switch (type)
            {
            case Utilities.PackType.Udp:
                if (Outgoing != null)
                {
                    if (start == 0)
                    {
                        Outgoing.Enqueue(buff);
                    }
                    else
                    {
                        var buf = new byte[len];
                        Array.Copy(buff, start, buf, 0, len);
                        Outgoing.Enqueue(buf);
                    }
                }
                break;

            case Utilities.PackType.Kcp:
                base.ProcessOutgoingData(buff, start + 1, len - 1);
                break;

            default:
                break;
            }
        }
Exemple #4
0
        public Program(string[] args)
        {
            _baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            In  = new Incoming();
            Out = new Outgoing();

            Options = HBOptions.Parse(args);
            if (string.IsNullOrWhiteSpace(Options.FetchRevision))
            {
                Game = new HGame(Options.GameInfo.FullName);
                if (Options.Compression == null)
                {
                    Options.Compression = Game.Compression;
                }
            }
            if (string.IsNullOrWhiteSpace(Options.OutputDirectory))
            {
                if (Options.GameInfo == null)
                {
                    Options.OutputDirectory = Environment.CurrentDirectory;
                }
                else
                {
                    Options.OutputDirectory = Options.GameInfo.DirectoryName;
                }
            }
            else
            {
                Options.OutputDirectory = Path.Combine(
                    Environment.CurrentDirectory, Options.OutputDirectory);
            }
        }
Exemple #5
0
        public bool CanFire()
        {
            var incoming = Incoming.TrueForAll(a => a.CanFire());
            var outgoing = Outgoing.TrueForAll(a => a.CanFire());

            return(incoming && outgoing);
        }
        public void CalcClientsAndLicensesActived()
        {
            Outgoing oldOutgoing = GetOutgoingByCurrentYearMonth();

            var(clientsActived, devicesActived) = GetCliensAndDevicesActived();

            if (oldOutgoing == null)
            {
                var      today    = DateTime.UtcNow.AddHours(-3);
                Outgoing outgoing = new Outgoing()
                {
                    Year           = today.Year,
                    Month          = today.Month,
                    ClientsActive  = clientsActived,
                    LicensesActive = devicesActived,
                    OutgoingUId    = Guid.NewGuid().ToString()
                };
                _context.Entry <Outgoing>(outgoing).State = EntityState.Added;
                _context.SaveChanges(true);
                _log.Log($"Configuração comercial do mês {outgoing.Month}, ano {outgoing.Year} foi criado.");
            }
            else
            {
                oldOutgoing.ClientsActive  = clientsActived;
                oldOutgoing.LicensesActive = devicesActived;
                _context.Entry <Outgoing>(oldOutgoing).State = EntityState.Modified;

                _context.SaveChanges(true);
                _log.Log($"Configuração comercial do mês {oldOutgoing.Month}, ano {oldOutgoing.Year} foi atualizada, cliente ativos {clientsActived} e dispositivos ativos {devicesActived}.");
            }
        }
Exemple #7
0
        public int AddOutgoing(Outgoing outgoing)
        {
            int result = -1;

            using (SQLiteConnection conn = new SQLiteConnection(sQLiteConnection))
            {
                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(conn))
                {
                    cmd.CommandText = "INSERT INTO TA_OutGoings(OutGoing, Details, Notes, Date, Vist_Id) VALUES (@OutGoing, @Details, @Notes, @Date, @Vist_Id)";
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@OutGoing", outgoing.OutGoing);
                    cmd.Parameters.AddWithValue("@Details", outgoing.Details);
                    cmd.Parameters.AddWithValue("@Notes", outgoing.Notes);
                    cmd.Parameters.AddWithValue("@Date", outgoing.Date);
                    cmd.Parameters.AddWithValue("@Vist_Id", outgoing.Vist_Id);
                    try
                    {
                        result = cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException e)
                    {
                    }
                }
                conn.Close();
            }
            return(result);
        }
Exemple #8
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            int vistId = 0;

            if (comboBoxVists.SelectedIndex > -1)
            {
                vistId = vistsList[comboBoxVists.SelectedIndex].Id;
            }
            OutgoingData outgoingData = new OutgoingData();

            if (int.TryParse(textBoxPrice.Text, out int price))
            {
                Outgoing outgoing = new Outgoing()
                {
                    OutGoing = price,
                    Details  = textBoxDetails.Text,
                    Date     = pickerStartDate.SelectedDate ?? DateTime.Now,
                    Vist_Id  = vistId,
                    Notes    = textBoxNotes.Text
                };

                outgoingData.AddOutgoing(outgoing);

                MessageBox.Show("تم الحفظ");
            }
            else
            {
                MessageBox.Show("تاكد من قيمة المصروف");
            }
        }
Exemple #9
0
        private async Task <Outgoing> PostError(string error)
        {
            Outgoing outgoing = new Outgoing();

            outgoing.responseType = error;
            return(outgoing);
        }
        public override System.Web.Mvc.ActionResult UpdateOutgoing(Outgoing outgoing)
        {
            var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOutgoing);

            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "outgoing", outgoing);
            UpdateOutgoingOverride(callInfo, outgoing);
            return(callInfo);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Outgoing outgoing = db.Outgoings.Find(id);

            db.Outgoings.Remove(outgoing);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "outgoingId,employeeSalary,supplierCost,purchaseFood,tax,utilityBills,transportCost")] Outgoing outgoing)
 {
     if (ModelState.IsValid)
     {
         db.Entry(outgoing).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(outgoing));
 }
Exemple #13
0
        private void AddNewRecord(object sender, EventArgs e)
        {
            if (TextBoxMoneyInt.Text.Length == 0)
            {
                MessageBox.Show("请填写金额。");
                return;
            }

            if (TextBoxMoneyPoint.Text.Length == 1)
                TextBoxMoneyPoint.Text = TextBoxMoneyPoint.Text + "0";

            int money;
            try
            {
                money = int.Parse(TextBoxMoneyInt.Text) * 100 + int.Parse(TextBoxMoneyPoint.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("请正确填写金额。");
                return;
            }
            DateTime today = DateTime.Today;
            DateTime choiceDate = datePicker.Value.Value;
            Outgoing record = new Outgoing { Money = money, Main_id = mTypeId, Sub_id = sTypeId, Time = choiceDate };
            APPDB.Outgoing.InsertOnSubmit(record);

            //清除过期信息
            if (homeInfo.Date != today)
                homeInfo.Daysum = 0;
            //下一周
            if ((today - homeInfo.Weekstart).Days > 7)
            {
                homeInfo.Weeksum = 0;
                homeInfo.Weekstart = today.AddDays(-(int)today.DayOfWeek);
            }
            if (homeInfo.Date.Month != today.Month && homeInfo.Date.Year != today.Year)
            {
                homeInfo.Mouthsum = 0;
            }
            homeInfo.Date = today;

            if (homeInfo.Date.Year == choiceDate.Year)
            {
                if (homeInfo.Date.Month == choiceDate.Month)
                    homeInfo.Mouthsum += money;
                int weekDays=choiceDate.DayOfYear - homeInfo.Weekstart.DayOfYear;
                if (weekDays < 8&&weekDays>0)
                    homeInfo.Weeksum += money;
                if (choiceDate == homeInfo.Date)
                    homeInfo.Daysum += money;
            }

            APPDB.SubmitChanges();
            NavigationService.GoBack();
        }
Exemple #14
0
        /// <summary>
        /// Sends messages to targets.
        /// </summary>
        protected override void Process()
        {
            bool processed;

            do
            {
                ForceProcessing = false;

                bool lockTaken = false;
                try {
                    firstItemLock.Enter(ref lockTaken);

                    T item;
                    if (!Store.TryPeek(out item))
                    {
                        break;
                    }

                    if (!targets.HasCurrentItem)
                    {
                        targets.SetCurrentItem(item);
                    }

                    if (reservedForTargetBlock != null)
                    {
                        break;
                    }

                    processed = targets.OfferItemToTargets();
                    if (processed)
                    {
                        Outgoing.TryTake(out item);
                        DecreaseCounts(item);
                        FirstItemChanged();
                    }
                } finally {
                    if (lockTaken)
                    {
                        firstItemLock.Exit();
                    }
                }
            } while (processed);

            IsProcessing.Value = false;

            // to guard against race condition
            if (ForceProcessing && reservedForTargetBlock == null)
            {
                EnsureProcessing();
            }

            VerifyCompleteness();
        }
Exemple #15
0
 private void PublishWorldState(World world)
 {
     using (var stream = new MemoryStream()) {
         Serializer.Serialize(stream, world);
         var bytes = stream.ToArray();
         var msg   = new NetMQMessage();
         msg.AppendEmptyFrame();
         msg.Append("world");
         msg.Append(bytes);
         Outgoing.Enqueue(msg);
     }
 }
Exemple #16
0
        /// <summary>
        /// Create a new instance of <see cref="PipelineExecutor"/>.
        /// </summary>
        /// <param name="settings">The settings to read data from.</param>
        /// <param name="builder">The builder.</param>
        public PipelineExecutor(ReadOnlySettings settings, IBuilder builder)
        {
            rootBuilder = builder;

            var pipelineBuilder = new PipelineBuilder(settings.Get <PipelineModifications>());

            Incoming = pipelineBuilder.Incoming.AsReadOnly();
            Outgoing = pipelineBuilder.Outgoing.AsReadOnly();

            incomingBehaviors = Incoming.Select(r => r.BehaviorType);
            outgoingBehaviors = Outgoing.Select(r => r.BehaviorType);
        }
Exemple #17
0
 public void Disconnect(INode node)
 {
     for (int i = Outgoing.Count - 1; i >= 0; i--)
     {
         IEdge edge = Outgoing[i];
         if (edge.End == node)
         {
             Outgoing.Remove(edge);
             node.Incoming.Remove(edge);
         }
     }
 }
        /// <summary>
        /// Validates this vertex.
        /// YesNoChoice only accepts trigger YES or NO.
        /// </summary>
        public override bool Validate()
        {
            var invalid = Outgoing.Select(t => t.Trigger).Where(t => t != YES && t != NO).ToList();

            if (invalid.Count != 0)
            {
                Debug.WriteLine("Yes/no choice has invalid transition(s) with trigger: {0}", string.Join(",", invalid));
                return(false);
            }

            return(base.Validate());
        }
Exemple #19
0
        /// <summary>
        /// Takes an item from the queue and sets it as <see cref="CurrentItem"/>.
        /// </summary>
        public void DequeueItem()
        {
            T item;

            if (Outgoing.TryTake(out item))
            {
                DecreaseCounts(item);
                targets.SetCurrentItem(item);

                CurrentItem = item;
            }
        }
Exemple #20
0
        public void UpdateOutgoing(int userId, Outgoing outgoing)
        {
            var exist = _outgoingsRepository.Count(o => o.Id == outgoing.Id && o.UserId == userId) == 1 ? true : false;

            if (!exist)
            {
                throw new AppException("Вам нельзя обновить расход!");
            }
            outgoing.UserId = userId;
            _outgoingsRepository.Update(outgoing);
            //_outgoingsRepository.Save();
        }
        public void DeleteOutgoing(string id)
        {
            Outgoing outgoing = GetOutgoing(id);

            if (outgoing == null)
            {
                return;
            }

            _context.Outgoings.Remove(outgoing);
            _context.SaveChanges();
            _log.Log($"Configuração comercial do mês {outgoing.Month}, ano {outgoing.Year} foi removido.");
        }
        protected async Task ExecuteJob(Schedule state, CancellationToken token)
        {
            int currentJob = mCurrentExecutionId++;

            //mCollector?.Log(LogLevel.Info, "DelayedProcessingJob - Executing schedule " + currentJob);
            state.Context = currentJob;
            var payload = new TransmissionPayload("interserv", "do", "something", options: ProcessOptions.RouteExternal);

            Outgoing.Process(payload);

            //await Task.Delay(TimeSpan.FromSeconds(40), token);
            //mCollector?.Log(LogLevel.Info, "DelayedProcessingJob - Finished executing schedule " + currentJob);
        }
 /// <summary>
 /// Adds an object to the queue.
 /// </summary>
 public void AddData(T data)
 {
     try {
         Outgoing.Add(data);
         Interlocked.Add(ref totalModifiedCount, GetModifiedCount(data));
         if (Interlocked.Increment(ref outgoingCount) == 1)
         {
             EnsureProcessing();
         }
     } catch (InvalidOperationException) {
         VerifyCompleteness();
     }
 }
Exemple #24
0
        public T ConsumeMessage(DataflowMessageHeader messageHeader,
                                ITargetBlock <T> targetBlock, out bool messageConsumed)
        {
            if (!messageHeader.IsValid)
            {
                throw new ArgumentException("The messageHeader is not valid.",
                                            "messageHeader");
            }
            if (targetBlock == null)
            {
                throw new ArgumentNullException("target");
            }

            T result = default(T);

            messageConsumed = false;

            bool lockTaken = false;

            try {
                firstItemLock.Enter(ref lockTaken);

                if (targets.VerifyHeader(messageHeader, targetBlock) &&
                    (reservedForTargetBlock == null ||
                     reservedForTargetBlock == targetBlock))
                {
                    // cannot consume from faulted block, unless reserved
                    if (reservedForTargetBlock == null && IsFaultedOrCancelled)
                    {
                        return(result);
                    }

                    Outgoing.TryTake(out result);
                    messageConsumed = true;
                    DecreaseCounts(result);
                    reservedForTargetBlock = null;
                    FirstItemChanged();
                }
            } finally {
                if (lockTaken)
                {
                    firstItemLock.Exit();
                }
            }

            targets.UnpostponeTarget(targetBlock, messageConsumed);
            EnsureProcessing();
            VerifyCompleteness();

            return(result);
        }
    async Task Process(string messageId, Outgoing outgoing, string name, DateTime expiry)
    {
        if (outgoing.AsyncStreamFactory != null)
        {
            var stream = await outgoing.AsyncStreamFactory().ConfigureAwait(false);
            await ProcessStream(messageId, name, expiry, stream, outgoing.Metadata).ConfigureAwait(false);

            return;
        }

        if (outgoing.StreamFactory != null)
        {
            await ProcessStream(messageId, name, expiry, outgoing.StreamFactory(), outgoing.Metadata).ConfigureAwait(false);

            return;
        }

        if (outgoing.StreamInstance != null)
        {
            await ProcessStream(messageId, name, expiry, outgoing.StreamInstance, outgoing.Metadata).ConfigureAwait(false);

            return;
        }

        if (outgoing.AsyncBytesFactory != null)
        {
            var bytes = await outgoing.AsyncBytesFactory().ConfigureAwait(false);

            await persister.SaveBytes(messageId, name, expiry, bytes, outgoing.Metadata)
            .ConfigureAwait(false);

            return;
        }

        if (outgoing.BytesFactory != null)
        {
            await persister.SaveBytes(messageId, name, expiry, outgoing.BytesFactory(), outgoing.Metadata)
            .ConfigureAwait(false);

            return;
        }

        if (outgoing.BytesInstance != null)
        {
            await persister.SaveBytes(messageId, name, expiry, outgoing.BytesInstance, outgoing.Metadata)
            .ConfigureAwait(false);

            return;
        }
        throw new Exception("No matching way to handle outgoing.");
    }
        protected override unsafe int udp_output(byte *buf, int len, IKCPCB *kcp, void *user)
        {
            byte[] buff = new byte[len + 1];
            Marshal.Copy(new IntPtr(buf), buff, 1, len);
#if PRINTPACK
            printpack($"kcp_output:{buff.Length}:{string.Join(",",buff)}");
#endif
            buff[0] = (byte)Utilities.PackType.Kcp;
            if (Outgoing != null)
            {
                Outgoing.Enqueue(buff);
            }
            return(0);
        }
 /// <summary>
 /// This method is used to send requests to a remote command and wait for a response.
 /// </summary>
 /// <typeparam name="I">The contract interface.</typeparam>
 /// <typeparam name="RQ">The request object type.</typeparam>
 /// <typeparam name="RS">The response object type.</typeparam>
 /// <param name="rq">The request object.</param>
 /// <param name="settings">The request settings. Use this to specifically set the timeout parameters, amongst other settings, or to pass meta data to the calling party.</param>
 /// <param name="routing">The routing options by default this will try internal and then external endpoints.</param>
 /// <param name="principal">This is the principal that you wish the command to be executed under.
 /// By default this is taken from the calling thread if not passed.</param>
 /// <returns>Returns the async response wrapper.</returns>
 public virtual async Task <ResponseWrapper <RS> > Process <I, RQ, RS>(
     RQ rq
     , RequestSettings settings = null
     , ProcessOptions?routing   = default(ProcessOptions?)
     , IPrincipal principal     = null
     )
     where I : IMessageContract
 {
     return(await Outgoing.Process <I, RQ, RS>(rq
                                               , settings
                                               , routing
                                               , principal : principal ?? Thread.CurrentPrincipal
                                               ));
 }
        // GET: Outgoings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Outgoing outgoing = db.Outgoings.Find(id);

            if (outgoing == null)
            {
                return(HttpNotFound());
            }
            return(View(outgoing));
        }
 /// <summary>
 /// This method is used to send requests to a remote command and wait for a response.
 /// </summary>
 /// <typeparam name="RQ">The request object type.</typeparam>
 /// <typeparam name="RS">The response object type.</typeparam>
 /// <param name="channelId"></param>
 /// <param name="messageType"></param>
 /// <param name="actionType"></param>
 /// <param name="rq">The request object.</param>
 /// <param name="settings">The request settings. Use this to specifically set the timeout parameters, amongst other settings, or to pass meta data to the calling party.</param>
 /// <param name="routing">The routing options by default this will try internal and then external endpoints.</param>
 /// <param name="principal">This is the principal that you wish the command to be executed under.
 /// By default this is taken from the calling thread if not passed.</param>
 /// <returns>Returns the async response wrapper.</returns>
 public virtual async Task <ResponseWrapper <RS> > Process <RQ, RS>(
     string channelId, string messageType, string actionType
     , RQ rq
     , RequestSettings settings = null
     , ProcessOptions?routing   = default(ProcessOptions?)
     , IPrincipal principal     = null
     )
 {
     return(await Outgoing.Process <RQ, RS>(
                channelId, messageType, actionType
                , rq
                , settings
                , routing
                , principal : principal ?? Thread.CurrentPrincipal));
 }
        public Task SendMessageAsync(
            Stream messageStream,
            CancellationToken cancellationToken)
        {
            var buffer = new byte[messageStream.Length];

            messageStream.Read(buffer, 0, buffer.Length);

            string json = Encoding.UTF8.GetString(buffer);

            Outgoing.Add(JsonConvert
                         .DeserializeObject <GenericOperationMessage>(json));

            return(Task.CompletedTask);
        }
    async Task ProcessAttachment(TimeSpan?timeToBeReceived, string messageId, Outgoing outgoing, string name)
    {
        var outgoingStreamTimeToKeep = outgoing.TimeToKeep ?? endpointTimeToKeep;
        var timeToKeep = outgoingStreamTimeToKeep(timeToBeReceived);
        var expiry     = DateTime.UtcNow.Add(timeToKeep);

        try
        {
            await Process(messageId, outgoing, name, expiry).ConfigureAwait(false);
        }
        finally
        {
            outgoing.Cleanup?.Invoke();
        }
    }
Exemple #32
0
 public Guid RegisterToSend(string destination, string queue, string subQueue, MessagePayload payload, Guid transactionId)
 {
     if (!Directory.Exists(_outgoingPath))
         Directory.CreateDirectory(_outgoingPath);
     var msgId = GuidCombGenerator.Generate();
     var obj = new Outgoing
     {
         msgId = msgId,
         txId = transactionId,
         address = destination,
         timeToSend = DateTime.Now,
         sentAt = DateTime.Now,
         queue = queue,
         subqueue = subQueue,
         headers = payload.Headers.ToQueryString(),
         data = payload.Data,
         numberOfRetries = 1,
         sizeOfData = payload.Data.Length,
         deliverBy = payload.DeliverBy,
         maxAttempts = payload.MaxAttempts,
     };
     var path = Path.Combine(_outgoingPath, FileUtil.FromTransactionId(transactionId, OutgoingMessageStatus.NotReady.ToString()));
     File.WriteAllText(path, JsonConvert.SerializeObject(obj));
     var bookmark = new MessageBookmark { Bookmark = path };
     _outgoingBookmark = bookmark;
     _logger.DebugFormat("Created output message '{0}' for 'file://{1}/{2}/{3}' as NotReady", msgId, destination, queue, subQueue);
     return msgId;
 }
Exemple #33
0
 partial void InsertOutgoing(Outgoing instance);
Exemple #34
0
 partial void UpdateOutgoing(Outgoing instance);
Exemple #35
0
 partial void DeleteOutgoing(Outgoing instance);