Beispiel #1
0
        //public static SalesContext db = new SalesContext();

        //public static Customer CloneCustomer(Customer SelectedItem)
        //{
        //    using (var db = new SalesContext())
        //    {
        //        var item = db.Customers.Find(SelectedItem.Id);
        //        item.CustomerRank = CustomerRanks.Where(p => p.Id == item.CustomerRankID).Single();
        //        return item;
        //    }
        //}

        #endregion

        #region Asset
        public async static Task GetAllAssets()
        {
            Assets.Clear();
            AssetCategories.Clear();
            using (var db = new SalesContext())
            {
                var result  = await(from c in db.Assets select c).ToListAsync();
                var result1 = await(from c in db.AssetCategories.Include("Assets") select c).ToListAsync();
                var result2 = await(from c in db.Departments.Include("Assets") select c).ToListAsync();
                var result3 = await(from c in db.InstallationLocations.Include("Assets") select c).ToListAsync();
                foreach (Asset item in result)
                {
                    Assets.Add(item);
                }
                foreach (AssetCategory item in result1)
                {
                    AssetCategories.Add(item);
                }
                foreach (Department item in result2)
                {
                    Departments.Add(item);
                }
                foreach (InstallationLocation item in result3)
                {
                    InstallationLocations.Add(item);
                }
            }
        }
        private void SetAssets()
        {
            Assets.Clear();
            ExpandoObject ex;

            if (TryGetMetadataValue("thumbnails", out ex))
            {
                if (ex != null)
                {
                    foreach (object o in ex)
                    {
                        string[]       str1 = new[] { "source", "small", "medium", "large" };
                        string[]       str2 = new[] { ":thumbnail{0}", ":thumbnail{0}small", ":thumbnail{0}medium", ":thumbnail{0}large" };
                        IList <object> lms  = (IList <object>)o;
                        int            cnt  = 0;
                        foreach (object thumb in lms)
                        {
                            IDictionary <string, object> dic = (IDictionary <string, object>)o;
                            for (int x = 0; x < str1.Length; x++)
                            {
                                if (dic.ContainsKey(str1[x]))
                                {
                                    string rname = string.Format(str2[x], cnt == 0 ? string.Empty : cnt.ToString());
                                    Assets.Add(FromThumbnail(rname, thumb));
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Assets.Clear();
                var assets = await DataStore.GetAsync(true);

                foreach (var asset in assets)
                {
                    Assets.Add(asset);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Unload this instance.
        /// </summary>
        internal void Unload()
        {
            foreach (var d in Assets.Select(kvp => kvp.Value).OfType <IDisposable>())
            {
                d.Dispose();
            }

            Assets.Clear();
        }
Beispiel #5
0
 public override void OnStopServer()
 {
     base.OnStopServer();
     Players.Clear();
     Assets.Clear();
     if (Assets.offlineScene.IsSet() && !Assets.offlineScene.SceneName.Equals(SceneManager.GetActiveScene().name))
     {
         LoadSceneRoutine(Assets.offlineScene.SceneName, false).Forget();
     }
 }
Beispiel #6
0
 public void SetCmsAssets(List <CmsAsset> assets)
 {
     _cmsAlbum.Assets = assets;
     Assets.Clear();
     if (_cmsAlbum.Assets != null)
     {
         foreach (var asset in _cmsAlbum.Assets)
         {
             Assets.Add(new CmsAssetVM(asset));
         }
     }
 }
        private void ServiceChanged()
        {
            UiDispatcher.Invoke(delegate
            {
                Assets.Clear();

                if (ServiceSelected != null)
                {
                    M.SendAsync(new AssetNetworkRequestMessage(ServiceSelected?.Network));
                }
            });
        }
Beispiel #8
0
        public BaseFileSetRequest(CommandArgs args, Connection conn)
            : base(args, conn)
        {
            Assets.Clear();
            conn.Read(Assets);

            if (Assets.Count == 0)
            {
                Assets.Clear();
                conn.Write(Assets);
                conn.EndResponse();
                Invalid = true;
            }
        }
Beispiel #9
0
        public DownloadRequest(CommandArgs args, Connection conn)
            : base(args, conn)
        {
            TargetDir = conn.ReadLine();
            conn.Read(Revisions);
            conn.Read(Assets);

            if (Assets.Count == 0 || Revisions.Count == 0)
            {
                Assets.Clear();
                conn.Write(Assets);
                conn.EndResponse();
                Invalid = true;
            }
        }
        public async Task <FileSystemResult <IFile> > CreateAssetAsync(string name, Stream readstream, CancellationToken token, IProgress <FileProgress> progress, Dictionary <string, object> properties)
        {
            string ext = Path.GetExtension(name);

            if ((ext != "png") && (ext != "jpg") && (ext != "jpeg") && (ext != "gif"))
            {
                return(new FileSystemResult <IFile>("Google Drive only supports 'thumbnail' asset, acceptable formats are, jpg, png and gif"));
            }
            string mime;

            switch (ext)
            {
            case "png":
                mime = "image/png";
                break;

            case "jpeg":
            case "jpg":
                mime = "image/jpeg";
                break;

            default:
                mime = "image/gif";
                break;
            }
            MemoryStream ms = new MemoryStream();
            await readstream.CopyToAsync(ms, 16384, token);

            MemoryFile file = new MemoryFile(FullName + ":thumbnail", "thumbnail", mime, ms.ToArray());
            File       f    = new File {
                Thumbnail = new File.ThumbnailData {
                    MimeType = mime, Image = Convert.ToBase64String(ms.ToArray())
                }
            };
            string url = GooglePatch.FormatRest(Id);
            FileSystemResult <string> ex = await FS.OAuth.CreateMetadataStream <string>(url, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(f)), "application/json", new HttpMethod("PATCH"));

            if (!ex.IsOk)
            {
                return(new FileSystemResult <IFile>(ex.Error));
            }
            Assets.Clear();
            Assets.Add(file);
            return(new FileSystemResult <IFile>(file));
        }
Beispiel #11
0
        private void RefreshAssets()
        {
            if (IsBusy)
            {
                return;
            }

            Assets.Clear();
            IsBusy     = true;
            pageNumber = 1;

            Task.Run(async() =>
            {
                var result = await LoadAssetsAsync(pageNumber);
                Assets.AddRange(result);
            });
            IsBusy = false;
        }
        private void SetAssets()
        {
            List <object> ex = null;

            Assets.Clear();
            if (TryGetMetadataValue("assets", out ex))
            {
                foreach (ExpandoObject ob in ex)
                {
                    AmazonFile f = new AmazonFile(string.Empty, FS)
                    {
                        Parent = null
                    };
                    f.SetData(JsonConvert.SerializeObject(ob));
                    Assets.Add(f);
                }
            }
        }
Beispiel #13
0
        private async Task Fetch(bool nextPage)
        {
            if (IsFetching)
            {
                return;
            }
            if (Assets.Count > 500)
            {
                return;
            }
            if (CurrentPage == 0)
            {
                Assets.Clear();
            }
            if (nextPage)
            {
                CurrentPage++;
            }
            IsFetching = true;
            try
            {
                var assets = await(string.IsNullOrEmpty(SearchQuery)
                    ? ImageClientService.GetMainGalery(CurrentPage)
                    : ImageClientService.SearchMainGalery(SearchQuery, CurrentPage));

                foreach (var asset in assets)
                {
                    if (asset.ShouldDisplay)
                    {
                        Assets.Add(asset);
                    }
                }
            }
            catch (Exception e)
            {
                await Page.DisplayAlert("Error", e.Message, "Dismiss");
            }
            finally
            {
                IsFetching = false;
            }
        }
        private void SetAssets()
        {
            Assets.Clear();
            ExpandoObject ex;

            if (TryGetMetadataValue("thumbnail", out ex))
            {
                IDictionary <string, object> dic = ex;
                if (dic.ContainsKey("image"))
                {
                    byte[] image = Convert.FromBase64String((string)dic["image"]);
                    string mime  = string.Empty;
                    if (dic.ContainsKey("mimeType"))
                    {
                        mime = (string)dic["mimeType"];
                    }
                    MemoryFile f = new MemoryFile(FullName + ":thumbnail", "thumbnail", mime, image);
                    Assets.Add(f);
                }
            }
        }
Beispiel #15
0
        public void ValidateAssets(bool alwaysGenerateNewAssetId = false)
        {
            if (TemporaryAssets.Count == 0)
            {
                return;
            }

            try
            {
                // Make sure we are suspending notifications before updating all assets
                Assets.SuspendCollectionChanged();

                Assets.Clear();

                // Get generated output items
                var outputItems = new AssetItemCollection();

                // Create a resolver from the package
                var resolver = AssetResolver.FromPackage(this);
                resolver.AlwaysCreateNewId = alwaysGenerateNewAssetId;

                // Clean assets
                AssetCollision.Clean(TemporaryAssets, outputItems, resolver, false);

                // Add them back to the package
                foreach (var item in outputItems)
                {
                    Assets.Add(item);
                }

                TemporaryAssets.Clear();
            }
            finally
            {
                // Restore notification on assets
                Assets.ResumeCollectionChanged();
            }
        }
 public override void UpdateFilter(HierarchyType hierarchyType, SearchFilter searchFilter, bool showFoldersFirst)
 {
     ItemsWantedShown = ListMode ? kDefaultRowsShownListMode : (kDefaultRowsShown * m_Grid.columns);
     Assets.Clear();
 }
Beispiel #17
0
 public void Reset()
 {
     Assets.Clear();
 }
Beispiel #18
0
        /// <summary>
        /// This function will be called to load scene async
        /// </summary>
        /// <param name="sceneName"></param>
        /// <param name="online"></param>
        /// <returns></returns>
        private async UniTaskVoid LoadSceneRoutine(string sceneName, bool online)
        {
            if (loadSceneAsyncOperation == null)
            {
                // If doNotDestroyOnSceneChanges not TRUE still not destroy this game object
                // But it will be destroyed after scene loaded, if scene is offline scene
                if (!doNotDestroyOnSceneChanges)
                {
                    DontDestroyOnLoad(gameObject);
                }

                if (online)
                {
                    foreach (LiteNetLibPlayer player in Players.Values)
                    {
                        player.IsReady = false;
                        player.SubscribingObjects.Clear();
                        player.SpawnedObjects.Clear();
                    }
                    Assets.Clear(true);
                }

                if (LogDev)
                {
                    Logging.Log(LogTag, "Loading Scene: " + sceneName + " is online: " + online);
                }
                if (Assets.onLoadSceneStart != null)
                {
                    Assets.onLoadSceneStart.Invoke(sceneName, online, 0f);
                }

                loadSceneAsyncOperation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
                while (loadSceneAsyncOperation != null && !loadSceneAsyncOperation.isDone)
                {
                    if (Assets.onLoadSceneProgress != null)
                    {
                        Assets.onLoadSceneProgress.Invoke(sceneName, online, loadSceneAsyncOperation.progress);
                    }
                    await UniTask.Yield();
                }
                loadSceneAsyncOperation = null;

                if (online)
                {
                    Assets.Initialize();
                    if (LogDev)
                    {
                        Logging.Log(LogTag, "Loaded Scene: " + sceneName + " -> Assets.Initialize()");
                    }
                    if (IsClient)
                    {
                        // If it is host (both client and server) wait for client connection id before proceed server scene load
                        while (ClientConnectionId < 0)
                        {
                            await UniTask.Yield();
                        }
                    }
                    if (IsServer)
                    {
                        ServerSceneName = sceneName;
                        Assets.SpawnSceneObjects();
                        if (LogDev)
                        {
                            Logging.Log(LogTag, "Loaded Scene: " + sceneName + " -> Assets.SpawnSceneObjects()");
                        }
                        OnServerOnlineSceneLoaded();
                        if (LogDev)
                        {
                            Logging.Log(LogTag, "Loaded Scene: " + sceneName + " -> OnServerOnlineSceneLoaded()");
                        }
                        SendServerSceneChange(sceneName);
                        if (LogDev)
                        {
                            Logging.Log(LogTag, "Loaded Scene: " + sceneName + " -> SendServerSceneChange()");
                        }
                    }
                    if (IsClient)
                    {
                        OnClientOnlineSceneLoaded();
                        if (LogDev)
                        {
                            Logging.Log(LogTag, "Loaded Scene: " + sceneName + " -> OnClientOnlineSceneLoaded()");
                        }
                        SendClientReady();
                        if (LogDev)
                        {
                            Logging.Log(LogTag, "Loaded Scene: " + sceneName + " -> SendClientReady()");
                        }
                    }
                }
                else if (!doNotDestroyOnSceneChanges)
                {
                    // Destroy manager's game object if loaded scene is not online scene
                    Destroy(gameObject);
                }

                if (LogDev)
                {
                    Logging.Log(LogTag, "Loaded Scene: " + sceneName + " is online: " + online);
                }
                if (Assets.onLoadSceneFinish != null)
                {
                    Assets.onLoadSceneFinish.Invoke(sceneName, online, 1f);
                }
            }
        }
Beispiel #19
0
        public void Pay(int amount, IAssetHolder payee, Bank bank)
        {
            LogEvent("Pay", amount);

            if (amount < 0)
            {
                throw new ApplicationException("Can't pay less than 0");
            }

            if ((Money - amount) < 0)
            {
                // can't afford it

                var sumReached = false;

                while (sumReached == false)
                {
                    var assetToSellBuilding = Properties.Where(b => b.BuildingCount > 0)
                                              .Where(c => c.MonopolySet.Max(m => (((Property)m).BuildingCount)) == c.BuildingCount)
                                              .OrderBy(o => Genetics.GetGeneExpression(GeneType.ImprovementValue, o))
                                              .FirstOrDefault();

                    if (assetToSellBuilding != null)
                    {
                        Money += assetToSellBuilding.SellBuilding();

                        if ((Money - amount) >= 0)
                        {
                            sumReached = true;
                        }
                    }
                    else // no buildings, start mortgaging
                    {
                        var assetForMortaging = Assets.Where(x => x.Mortgaged == false)
                                                .OrderBy(o => Genetics.GetGeneExpression(GeneType.PropertyValue, o))
                                                .FirstOrDefault();

                        if (assetForMortaging != null)
                        {
                            Money += assetForMortaging.MortgageAsset();

                            if ((Money - amount) >= 0)
                            {
                                sumReached = true;
                            }
                        }
                        else
                        {
                            // Nothing more to mortgage, broke!
                            break;
                        }
                    }
                }

                if (sumReached == false)
                {
                    // Couldn't pay. Hand over all assets to debtor

                    if (payee is FreeParking || payee is Bank)
                    {
                        foreach (var asset in Assets)
                        {
                            asset.Owner = bank;
                            bank.Assets.Add(asset);
                            asset.UnmortgageAsset();
                        }
                    }
                    else
                    {
                        foreach (var asset in Assets)
                        {
                            asset.Owner = payee;
                            payee.Assets.Add(asset);
                        }
                    }

                    Assets.Clear();

                    // Lose get out of jail free cards

                    while (GetOutOfJailFreeCards.Count > 0)
                    {
                        GetOutOfJailFreeCards.Dequeue();
                    }

                    // All money turned over

                    payee.Receive(Money);
                    Money = 0;

                    Status = PlayerStatus.Bankrupt;
                    LogEvent("Bankrupt trying to pay ", amount);

                    return;
                }
            }

            Money -= amount;
            payee.Receive(amount);
        }