Пример #1
0
        async Task IStatistics.UpdateStats(string StatStorName, Dictionary <int, RequestStats> Data)
        {
            try
            {
                ActorId StoreId = StatStorName.ToActorId();
                Dictionary <int, RequestStats> Stored = await StoreId.LoadGeneric <Dictionary <int, RequestStats> >();

                if (Stored == null)
                {
                    Stored = new Dictionary <int, RequestStats>();
                }
                if (Data != null)
                {
                    foreach (int k in Data.Keys)
                    {
                        if (!Stored.ContainsKey(k))
                        {
                            Stored.Add(k, new RequestStats(k));
                        }
                        Stored[k].CompressedSize += Data[k].CompressedSize;
                        Stored[k].NumCalls       += Data[k].NumCalls;
                        Stored[k].TotalTime      += Data[k].TotalTime;
                        Stored[k].TotalSize      += Data[k].TotalSize;
                    }
                    await Stored.SaveGeneric(StoreId);
                }
            }
            catch (Exception E)
            {
                this.Log(E);
                throw (E);
            }
        }
Пример #2
0
        public Thing Add(Thing thing)
        {
            var total      = _currentStoredCount + thing.Hitpoints;
            var difference = total - _max;

            Thing remainder = null;

            if (difference > 0)
            {
                remainder           = _game.CreateAtPosition(thing.Config.TypeOfThing, Vector2Int.zero);
                remainder.Hitpoints = difference;
                thing.Hitpoints     = _max - _currentStoredCount;
            }

            // any existing items of same type
            if (Stored.Any(t => t.Config.TypeOfThing == thing.Config.TypeOfThing))
            {
                var totalInStorage = Stored.Where(t => t.Config.TypeOfThing == thing.Config.TypeOfThing).Sum(t => t.Hitpoints);
                var toRemove       = Stored.Where(t => t.Config.TypeOfThing == thing.Config.TypeOfThing).ToList();

                foreach (var remove in toRemove)
                {
                    _game.Remove(remove);
                }

                thing.Hitpoints += totalInStorage;
            }

            thing.transform.SetParent(transform);
            thing.transform.localPosition = Vector3.zero;

            return(remainder);
        }
        // Stored
        private CustomSerialization.Protobuf.Msg.Stored StoredToProto(Stored stored)
        {
            var msg = new CustomSerialization.Protobuf.Msg.Stored();

            msg.Value = stored.Value;
            return(msg);
        }
Пример #4
0
        public ActionResult <IEnumerable <string> > AddItemToStore([FromBody] AddItemToStore form)

        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            string currentUserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var    _clientid     = Guid.Parse(currentUserId);

            var AddItem = new Stored
            {
                Item_SerialNumber   = form.Item_SerialNumber,
                Item_Count          = form.Item_Count,
                Item_EmployeeEntery = _clientid,
                Item_EnteryDate     = form.Item_EnteryDate,
                Item_IsUsed         = form.Item_IsUsed,
                Item_Model          = form.Item_Model,
                Item_Name           = form.Item_Name,
                Item_Part           = form.Item_Part
            };

            _context.Stored.Add(AddItem);

            _context.SaveChanges();
            return(Ok(new Response
            {
                Message = "Done !",
                Data = AddItem,
                Error = false
            }));
        }
Пример #5
0
        private void OnButtonClick(object sender, RoutedEventArgs e)
        {
            Stored.Get <bool>("surveyHide").Value = !Stored.Get <bool>("surveyHide").Value;

            /*if (Application.Current.MainWindow is MainWindow window) {
             *  window.ShortSurveyLink.IsShown = false;
             * }*/
        }
Пример #6
0
        public override dynamic CreateFromJSON(string value)
        {
            if (value.Contains($"{Name}."))
            {
                return(GetValue(value.Replace($"{Name}.", "")).Value);
            }

            return(Stored.CreateFromJSON(value));
        }
Пример #7
0
        public override dynamic CreateFromJSON(string value)
        {
            var arr  = (JArray)JsonConvert.DeserializeObject(value);
            var data = new List <dynamic>();

            foreach (var var in arr)
            {
                data.Add(Stored.CreateFromJSON(JsonConvert.SerializeObject(var)));
            }
            return(data);
        }
Пример #8
0
 // produce or hint monsters
 public Monster CreateMonster(int x, int y, int playerLevel)
 {
     if (Stored.ContainsKey(y * Width + x) && Stored[y * Width + x] != null)
     {
         return(Stored[y * Width + x]);
     }
     if (monDict.ContainsKey(y * Width + x) && monDict[y * Width + x] != null)
     {
         return(monDict[y * Width + x].Create(playerLevel));
     }
     return(null);
 }
Пример #9
0
 public void Init()
 {
     if (_store == null)
     {
         _store = new PlayerPrefsKeyValueStore();
     }
     if (_currentSave == null)
     {
         _currentSave = new JsonFileStored <SavedGameData>(Path.Combine(Application.persistentDataPath, "Save.json"), () => new SavedGameData
         {
             ActiveCampaignName = _defaultCampaignKey,
             Campaigns          = new CampaignsProgressData {
                 { _defaultCampaignKey, new CampaignLevelScores() }
             }
         });
     }
     _store.Put(_versionKey, _version);
 }
Пример #10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Товары в наличие: ");
            Sales s = new Sales(1, "Table", 5, 500, true);

            s.Print();
            Console.WriteLine("");
            Console.WriteLine("Осталось на складе: ");
            Stored st = new Stored(1, "Table", 3, 500, true, 2);

            st.Print();
            Console.WriteLine("");
            Console.WriteLine("Перемещено товара");
            Moving m = new Moving(1, "Table", 2, "Shop");

            m.Print();
            Console.WriteLine("");
            Console.WriteLine("Получено товара: ");
            GoodReceipt gr = new GoodReceipt(1, "Table", 3, 400.5);

            gr.Print();
        }
Пример #11
0
 void Start()
 {
     // Am Anfang werden soviele Einträge erstellt, wie es Roboter gibt. Die Roboter speichern ihre Daten dann am Index ihrer eigenen ID
     for (int i = 0; i < GameObject.FindGameObjectsWithTag("GameController")[0].GetComponent<LevelCreator>().NrOfRobots; i++)
     {
         Stored Default = new Stored();
         MarkedByRobot.Add(Default);
     }
 }
Пример #12
0
 public static void Write <T>(this Stored <T> s, Action <T> update) => s.Write(item => { update(item); return(item); });
Пример #13
0
 /// <summary>
 /// Basic constructor.
 /// </summary>
 public Config()
 {
     stored = new Stored(0);
 }
Пример #14
0
 public override string GetDataSource()
 {
     return(Stored.GetDataSource());
 }