示例#1
0
        private async void btnOk_Click(Object sender, EventArgs e)
        {
            if (btnPlan.Checked)
            {
                frmContractPlan frm = new frmContractPlan(userID);
                this.Close();
                frm.ShowDialog();
            }
            if (btnFatura.Checked)
            {
                try
                {
                    if (invoiceID == "")
                    {
                        MessageBox.Show("Você deve selecionar ao menos uma fatura!");
                    }
                    else
                    {
                        documentReference = db.Collection("users").Document(userID).Collection("invoices").Document(invoiceID);
                        documentSnapshot  = await documentReference.GetSnapshotAsync();

                        invoices = documentSnapshot.ConvertTo <Invoices>();
                        Query         Query     = db.Collection("plans");
                        QuerySnapshot snapshots = await Query.GetSnapshotAsync();

                        foreach (DocumentSnapshot documentSnapshot in snapshots)
                        {
                            plans = documentSnapshot.ConvertTo <Plans>();
                            if (invoices.planName.Contains(plans.name) && invoices.planName.Contains(plans.type))
                            {
                                planID = documentSnapshot.Id;
                            }
                        }
                        frmFinalizeClient frm = new frmFinalizeClient(userID, planID);
                        this.Close();
                        frm.ShowDialog();
                    }
                }
                catch
                {
                }
            }
            if (btnClient.Checked)
            {
                frmEditClient frm = new frmEditClient(userID);
                this.Close();
                frm.ShowDialog();
            }
        }
    public IEnumerator Co_LoadData <T>(string collectionPath, string documentPath, Action <T, bool> onComplete)
    {
        // 네트워크 연결 불량 시 무시
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            yield break;
        }

        bool isContinue = true;

        DocumentReference docRef = FirebaseFirestore.DefaultInstance.Collection(collectionPath).Document(documentPath);

        docRef.GetSnapshotAsync().ContinueWithOnMainThread(task =>
        {
            DocumentSnapshot snapshot = task.Result;

            if (onComplete != null)
            {
                onComplete(snapshot.ConvertTo <T>(), snapshot.Exists);
            }

            isContinue = false;
        });

        while (isContinue)
        {
            yield return(null);
        }
    }
示例#3
0
        /* await using (ServiceBusClient client = new ServiceBusClient(_configuration["Settings:AzureServiceBusConnectionString"]))
         * {
         *   // create a processor that we can use to process the messages
         *   ServiceBusProcessor processor = client.CreateProcessor("messagetest1", new ServiceBusProcessorOptions());
         */

        public async Task <object> setSuggestion()
        {
            PeopleCountModel _peopleCount = GetPeopleCountFromDB();

            DocumentSnapshot snapshot = await fireStoreDb.Collection("SuggestionHistory").Document("productdataset").GetSnapshotAsync();

            if (snapshot.Exists && _peopleCount != null)
            {
                Dictionary <string, List <ProductModel> > _objects = snapshot.ConvertTo <Dictionary <string, List <ProductModel> > >();
                ProductModel _product = _objects["products"].Where(x => x.ProductName == _peopleCount.ProductName).FirstOrDefault();
                if (_product != null)
                {
                    Int64 nonBuyingPeople = _peopleCount.PeopleCount - _product.SalesCount;

                    decimal notBuyingPercentage = (nonBuyingPeople / _product.TotalCount) * 100;
                    if (notBuyingPercentage < 50)
                    {
                        decimal maxCashbackPrice  = _product.Price - _product.OriginalPrice;
                        decimal suggestedCashback = maxCashbackPrice - 100;
                        string  suggestion        = $"{_peopleCount.ProductName} was watched by total of {_peopleCount.PeopleCount} people. But total sale for this product was {100 - notBuyingPercentage}% . If we provide CASHBACK of ${suggestedCashback} for this product then sales can improve";

                        AddToAzureMessageQueue(suggestion);
                    }
                }
            }
            return(string.Empty);
        }
        public async Task <IActionResult> Producten(string documentId)
        {
            db = FirestoreDatabase.LoadDatabase();

            CollectionReference klantenColl  = db.Collection("Klanten");
            DocumentReference   document     = klantenColl.Document(documentId);
            DocumentSnapshot    klantMetNaam = await document.GetSnapshotAsync();

            DocumentKlant documentKlant = new DocumentKlant
            {
                DocumentId = document.Id,
                Klant      = klantMetNaam.ConvertTo <Klant>()
            };

            Query query = klantenColl.WhereEqualTo("Naam", documentKlant.Klant.Naam);

            FirestoreChangeListener listener = query.Listen(snapshot =>
            {
                foreach (DocumentChange change in snapshot.Changes)
                {
                    DocumentSnapshot documentSnapshot = change.Document;

                    if (documentSnapshot.Exists)
                    {
                        documentKlant.DocumentId = document.Id;
                        documentKlant.Klant      = documentSnapshot.ConvertTo <Klant>();
                    }
                }
            });

            await listener.StopAsync();

            return(View(documentKlant));
        }
        async private void frmEditPlan_Load(Object sender, EventArgs e)
        {
            _width = this.Width;

            string path = AppDomain.CurrentDomain.BaseDirectory + @"pro-vantagens-firebase-adminsdk-5cf5q-82ec44750b.json";

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", path);

            FirestoreDb db = FirestoreDb.Create("pro-vantagens");

            documentReference = db.Collection("plans").Document(planID);
            documentSnapshot  = await documentReference.GetSnapshotAsync();

            plans = documentSnapshot.ConvertTo <Plans>();

            imgPlans.LoadAsync(plans.image);
            imgPlans.SizeMode = PictureBoxSizeMode.StretchImage;


            if (plans.name != "")
            {
                //Dados pessoais
                txtName.Text        = plans.name;
                txtDescription.Text = plans.description;
                cboType.Text        = plans.type;
                txtValue.Text       = plans.value;
                txtPDF.Text         = plans.contract;
            }
            else
            {
                MessageBox.Show("ERRO");
            }
        }
示例#6
0
文件: Firestore.cs 项目: HHIED/CAD
        /// <summary>
        /// Approves a section. Returns true if the section has been approved by everyone.
        /// </summary>
        /// <param name="username">Username approving</param>
        /// <param name="sectionId">Section to approve</param>
        /// <returns>Whether section has been approved by all or not</returns>
        public async Task <Boolean> ApproveSection(string username, string sectionId)
        {
            DocumentReference   docRef   = db.Collection("sections").Document(sectionId);
            CollectionReference userRef  = db.Collection("users");
            DocumentSnapshot    snapshot = await docRef.GetSnapshotAsync();

            if (snapshot.Exists)
            {
                Section section = snapshot.ConvertTo <Section>();
                if (!section.ApprovedBy.Contains(username))
                {
                    section.ApprovedBy.Add(username);
                    await docRef.UpdateAsync("ApprovedBy", FieldValue.ArrayUnion(username));
                }
                QuerySnapshot userSnapshots = await userRef.GetSnapshotAsync();

                if (userSnapshots.Count <= section.ApprovedBy.Count())
                {
                    await docRef.UpdateAsync("ApprovedAt", Timestamp.GetCurrentTimestamp());

                    return(true);
                }
            }
            return(false);
        }
        //public static async Task<List<Solicitud>> GetGrupoFromFireStore(string grupoID){
        public static async Task <GrupoDetalle> GetGrupoFromFireStore(string grupoID)
        {
            GrupoDetalle     grupoDetalle = new GrupoDetalle();
            List <Solicitud> solicitudes  = new List <Solicitud>();

            try{
                FirestoreDb db = conexionDB();

                CollectionReference collection  = db.Collection("Grupos");
                DocumentReference   docRef      = collection.Document(grupoID);
                DocumentSnapshot    documentGpo = await docRef.GetSnapshotAsync();

                if (documentGpo.Exists)
                {
                    grupoDetalle.grupo = documentGpo.ConvertTo <Grupo>();
                }

                Query         capitalQuery         = db.Collection("Solicitudes").WhereEqualTo("grupoID", grupoID);
                QuerySnapshot capitalQuerySnapshot = await capitalQuery.GetSnapshotAsync();

                foreach (DocumentSnapshot document in capitalQuerySnapshot.Documents)
                {
                    Solicitud solicitud = document.ConvertTo <Solicitud>();
                    solicitud.solicitudID = document.Id;
                    solicitudes.Add(solicitud);
                }
            }
            catch (Exception ex) {
                Log.Information("*****Error Exception GetGrupoFromFireStore: {0}", ex.Message);
            }
            grupoDetalle.solicitudes = solicitudes;
            return(grupoDetalle);
        }
    public void MakeMove(string username, string gameId, int fieldIndex, Action <StatusCode> completion)
    {
        DocumentReference gameRef           = db.Collection("games").Document(gameId);
        StatusCode        transactionStatus = StatusCode.OK;

        db.RunTransactionAsync(async transaction => {
            DocumentSnapshot game = await transaction.GetSnapshotAsync(gameRef);

            if (!game.Exists)
            {
                transactionStatus = StatusCode.UNKNWON;
                return(false);
            }

            GameState gameState = game.ConvertTo <GameState>();

            transactionStatus = gameState.MakeMove(username, fieldIndex);
            if (transactionStatus == StatusCode.GAME_FIELD_ALREADY_FULL || transactionStatus == StatusCode.GAME_NOT_YOUR_TURN)
            {
                return(false);
            }

            transaction.Set(gameRef, gameState);
            return(true);
        }).ContinueWithOnMainThread(task => {
            completion(transactionStatus);
        });
    }
        public async Task <bool> verifyAnswer(string email, string userAnswer)
        {
            Boolean connectionResult = connectToFirebase();

            try
            {
                DocumentReference docRef1  = db.Collection("User").Document(email);
                DocumentSnapshot  docSnap1 = await docRef1.GetSnapshotAsync();

                User userObj = docSnap1.ConvertTo <User>();
                if (userAnswer.Equals(userObj.questionAnswered))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CustomException customException = new CustomException();
                customException.errorTitleName     = "Cannot Verify Your Answer,Please Try Again later!!";
                customException.errorMessageToUser = ex.Message;
                throw new FaultException <CustomException>(customException);
            }
        }
示例#10
0
        /// <summary>
        /// Converts the given document and adds it
        /// to the given list of items.
        /// </summary>
        /// <typeparam name="DocumentModel"></typeparam>
        /// <param name="items">The list of items to append to.</param>
        /// /// <param name="snapshot">The document to convert and append.</param>
        private void AddConvertedDocument <DocumentModel>(IList <DocumentModel> items, DocumentSnapshot snapshot) where DocumentModel : class, IFirestoreDocumentModel
        {
            DocumentModel item = snapshot.ConvertTo <DocumentModel>();

            item.Id = snapshot.Id;
            items.Add(item);
        }
        //This method retruns the user selected question at the time of the registration
        public async Task <string> getUserQuestion(string email)
        {
            string security_question = "";

            try
            {
                Boolean connectionResult = connectToFirebase();
                if (connectionResult)
                {
                    DocumentReference docRef1  = db.Collection("User").Document(email);
                    DocumentSnapshot  docSnap1 = await docRef1.GetSnapshotAsync();

                    User userObj = docSnap1.ConvertTo <User>();
                    DocumentReference docRef2  = db.Collection("Questions").Document(userObj.questionSelected.ToString());
                    DocumentSnapshot  docSnap2 = await docRef2.GetSnapshotAsync();

                    DBQuestions question = docSnap2.ConvertTo <DBQuestions>();
                    security_question = question.question;
                }
                return(security_question);
            }
            catch (Exception ex)
            {
                //catch the exception and throw the error on the client
                CustomException customException = new CustomException();
                customException.errorTitleName     = ex.Message;
                customException.errorMessageToUser = "******";
                throw new FaultException <CustomException>(customException);
            }
        }
        public async Task <IActionResult> Get()
        {
            // Create a document with a random ID in the "cities" collection.
            //CollectionReference collection = fireStoreDb.Collection("prevent-fraud");
            //var response = new Response() { Ok = true };
            //await collection.Document("456").CreateAsync(response);

            // Update
            //DocumentReference empRef = fireStoreDb.Collection("prevent-fraud").Document("12345");
            //await empRef.SetAsync(response, SetOptions.Overwrite);


            //DocumentReference document = await collection.AddAsync(city);

            //CollectionReference colRef = fireStoreDb.Collection("prevent-fraud");
            //DocumentReference londonFromDb = fireStoreDb.Document("cities/london");

            //await collection.Document("los-angeles").CreateAsync(city);
            //await colRef.AddAsync(city);

            // Read
            DocumentReference docRef   = fireStoreDb.Collection("prevent-fraud").Document("12345");
            DocumentSnapshot  snapshot = await docRef.GetSnapshotAsync();

            var resp = snapshot.ConvertTo <Response>();

            return(Ok(resp));
        }
示例#13
0
        public async Task <Customer> GetCustomer(String CustomerID)
        {
            Customer customerx = new Customer();

            try
            {
                DocumentSnapshot documentCustomerSnapshot = await Root.Collection("customers").Document(CustomerID).GetSnapshotAsync();

                if (documentCustomerSnapshot != null)
                {
                    customerx = documentCustomerSnapshot.ConvertTo <Customer>();
                    if (customerx != null)
                    {
                        customerx.CustomerID = documentCustomerSnapshot.Id;
                        return(customerx);
                    }
                    else
                    {
                        return(null);
                    }
                }
            } catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            return(null);
        }
示例#14
0
        /// <summary>
        /// Gets the last known Scan Data object
        /// </summary>
        /// <returns></returns>
        public async Task <ScanData> GetScanData()
        {
            await FirestoreSetup();

            ScanData sd = null;

            try {
                ScanDataReference = DBHandle.Document(SCANDATA);
                if (ScanDataReference == null)
                {
                    // ScanData vanished - create a new one.
                    return(await CreateScanData());
                }
                DocumentSnapshot scanDataSnapshot = await ScanDataReference.GetSnapshotAsync();

                if (scanDataSnapshot.Exists)
                {
                    sd = scanDataSnapshot.ConvertTo <ScanData>();
                }
                else
                {
                    Logger.Log("No Scan Data was found, creating a new one and will pick up next invocation");
                    return(await CreateScanData());
                }
            }
            catch (Exception e) {
                Logger.Log("An unknown error ocurred while fetching Scan Data. Aborting.");
                // Some error occurred.
            }
            return(sd);
        }
        public IActionResult Details(string id)
        {
            if (HttpContext.Session.GetString("bt_userToken") != null)
            {
                if (id == null)
                {
                    return(BadRequest());
                }

                DocumentReference docRef   = firestoreDb.Collection("fthTest-users").Document(id);
                DocumentSnapshot  snapshot = docRef.GetSnapshotAsync().GetAwaiter().GetResult();
                if (snapshot.Exists)
                {
                    UserModel usr = snapshot.ConvertTo <UserModel>();
                    usr.Id   = snapshot.Id;
                    usr.date = snapshot.CreateTime.Value.ToDateTime();
                    return(View(usr));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
        public static async Task <Renovacion> GetRenovacionFromFireStore(string _ID)
        {
            Renovacion solicitud = new Renovacion();

            try
            {
                FirestoreDb         db         = conexionDB();
                CollectionReference collection = db.Collection("Renovaciones");
                DocumentReference   docRef     = collection.Document(_ID);
                DocumentSnapshot    document   = await docRef.GetSnapshotAsync();

                if (document.Exists)
                {
                    solicitud             = document.ConvertTo <Renovacion>();
                    solicitud.solicitudID = _ID;
                }
                else
                {
                    solicitud.grupoNombre = "La solicitud con el id " + _ID + " no existe en la FSDB.\r\nVuelva a cargar la página desde la bandeja, si no se muestra información de la solicitud vuelva a cargar los datos de la bandeja";
                }
            }
            catch (Exception ex)
            {
                solicitud.grupoNombre = ex.Message;//Auxiliar para mostrar un mensaje de error
                Log.Information("*****Error Exception GetRenovacionFromFireStore: {0}", ex.Message);
            }
            return(solicitud);
        }
示例#17
0
        public async Task <Team> Login(string user, string password) // provides login to webpage, if retuns null - bad login
        {
            if (password != null || user != null)                    // check existence of properties
            {
                // gets document - your password is your database document ID - try to not hate me, i thought it would be good idea
                DocumentReference docRef   = db.Collection("Team").Document(password);
                DocumentSnapshot  snapshot = await docRef.GetSnapshotAsync();

                if (snapshot.Exists) // check existence of document
                {
                    Team data = snapshot.ConvertTo <Team>();
                    if (data.Members.Count == 1) // members array must have some data in it on writing it in db
                    {
                        data.Members = null;
                    }
                    if (data.Login_username == user) // check valid username
                    {
                        return(data);                // returns team object
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
示例#18
0
        public async Task <Team> GetTeamById(string Id) // gets team object by his ID, never used in release
        {
            DocumentReference docRef   = db.Collection("Team").Document(Id);
            DocumentSnapshot  snapshot = await docRef.GetSnapshotAsync();

            return(snapshot.ConvertTo <Team>());
        }
        public static async Task <bool> TryConsumeAuthCode(ulong guildID, string code)
        {
            CollectionReference authDocument         = Db.Document("_authorizeKeys").Collection(code);
            QuerySnapshot       authDocumentSnapshot = await authDocument.GetSnapshotAsync();

            if (authDocumentSnapshot.Documents.Count > 0)
            {
                DocumentSnapshot  authDoc = authDocumentSnapshot.Documents[0];
                DocumentReference authRef = authDoc.Reference;

                AuthorizationStatus authStatus = authDoc.ConvertTo <AuthorizationStatus>();
                if (authStatus.used)
                {
                    return(false);
                }
                else
                {
                    authStatus.used = true;
                    authStatus.sid  = guildID;
                    await authRef.SetAsync(authStatus);
                    await SetAuthFor(guildID, true);

                    return(true);
                }
            }
            return(false);
        }
示例#20
0
        public async Task <String> GetCourierName(String CourierID)
        {
            DocumentSnapshot nameDoc = await Root.Collection("couriers").Document(CourierID).GetSnapshotAsync();

            String name = nameDoc.ConvertTo <Courier>().Name;

            return(name);
        }
示例#21
0
        private T _ToEntity <T>(DocumentSnapshot snapshot)
            where T : IEntity
        {
            var result = snapshot.ConvertTo <T>();

            result.Id = snapshot.Id;
            return(result);
        }
示例#22
0
        public static Level LevelDocumentToLevelObject(DocumentSnapshot documentSnapshot)
        {
            FirestoreLevel firestoreLevel  = documentSnapshot.ConvertTo <FirestoreLevel>();
            Level          levelBeforeJson = Level.FromFirestoreLevel(firestoreLevel);
            string         levelJson       = JsonUtility.ToJson(levelBeforeJson);

            return(JsonUtility.FromJson <Level>(levelJson));
        }
        /// <summary>
        /// Async method that fetches a member from the database.
        /// </summary>
        /// <return>
        /// A Member object
        ///</returns>
        /// <param name="personalId">Social security number of the person to be fetched.</param>
        public async Task <Member> FetchMemberBySsn(string personalId)
        {
            DocumentReference docRef   = _db.Collection("members").Document(personalId);
            DocumentSnapshot  snapshot = await docRef.GetSnapshotAsync();

            Member member = snapshot.ConvertTo <Member>();

            return(member);
        }
示例#24
0
        private static async Task <GameInstance> GetGameFromCloud(string gameId)
        {
            FirestoreDb       db        = InitializeDataBase();
            DocumentReference reference = db.Collection("games").Document(gameId);
            DocumentSnapshot  snapshot  = await reference.GetSnapshotAsync();

            GameInstance game = snapshot.ConvertTo <GameInstance>();

            return(game);
        }
示例#25
0
        public async Task <PersistedGrant> GetAsync(string key)
        {
            DocumentSnapshot persistedGrant =
                await GetPersistedGrant(nameof(PersistedGrant.Key), key).ConfigureAwait(false);

            _logger.LogDebug("{persistedGrandKey} found in database: {persistedGrantKeyFound}", key,
                             persistedGrant.Exists);

            return(persistedGrant.ConvertTo <PersistedGrant>());
        }
示例#26
0
        public async Task <List <Food> > ListFoods(String RestaurantID)
        {
            DocumentSnapshot documentSnapshot = await Root.Collection("restaurants").Document(RestaurantID).GetSnapshotAsync();

            List <Food> foods;
            Restaurant  restaurant = documentSnapshot.ConvertTo <Restaurant>();

            foods = restaurant.Foods;
            return(foods);
        }
示例#27
0
        static private async Task <Player> GetCloudPlayer(string playerId)
        {
            FirestoreDb       db        = InitializeDataBase();
            DocumentReference reference = db.Collection("players").Document(playerId);
            DocumentSnapshot  snapshot  = await reference.GetSnapshotAsync();

            Player player = snapshot.ConvertTo <Player>();

            return(player);
        }
示例#28
0
        public async Task <bool> validateLogin(AuthUser authUser)
        {
            bool auth_result = false;

            try
            {
                Firebase_Configuration config = new Firebase_Configuration();
                database_configuration = config.connectFireStoreCloudAsync();

                string pepper = System.Configuration.ConfigurationManager.AppSettings["SecureDeskPasswordPepper"];

                //if the database connection is successfull
                if (database_configuration != null)
                {
                    //getting the reference to the collection and then to the specific user
                    DocumentReference documentReference = database_configuration.Collection("User").Document(authUser.User_Auth_Email);

                    //get the snapshot of the user
                    DocumentSnapshot documentSnapshot = await documentReference.GetSnapshotAsync();

                    //convert the obtained snapshot into the User type object .
                    User validUser = documentSnapshot.ConvertTo <User>();

                    //if the user is found then check the credentials
                    if (validUser != null)
                    {
                        //generate the hash password using the SHA512 algorithm
                        string authUserHashedpassword = Password.generateSHA512Hash(authUser.User_Auth_Password, validUser.salt, pepper);

                        //pass the current computer password and the valid user passsword
                        auth_result = BC.Verify(authUserHashedpassword, validUser.password);

                        //return the result of the authentication to the client
                        return(auth_result);
                    }
                    else
                    {
                        //that means the user is not found in the database so return the false
                        return(auth_result);
                    }
                }
                else
                {
                    //error in the database connection
                    return(auth_result);
                }
            }
            catch (Exception ex)
            {
                CustomException customrException = new CustomException();
                customrException.errorMessageToUser = "******";
                customrException.errorTitleName     = "Login Error";
            }
            return(auth_result);
        }
示例#29
0
        private async void frmFinalizeClient_Load(Object sender, EventArgs e)
        {
            monthNow = DateTime.Now.Month.ToString() + '-' + DateTime.Now.Year.ToString();
            if (DateTime.Now.Month < 10)
            {
                monthNow = "0" + monthNow;
            }
            string path = AppDomain.CurrentDomain.BaseDirectory + @"pro-vantagens-firebase-adminsdk-5cf5q-82ec44750b.json";

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", path);

            FirestoreDb db = FirestoreDb.Create("pro-vantagens");

            userReference = db.Collection("users").Document(clientID);
            planReference = db.Collection("plans").Document(planID);
            planSnap      = await planReference.GetSnapshotAsync();

            userSnap = await userReference.GetSnapshotAsync();

            invoiceReference = db.Collection("users").Document(clientID).Collection("invoices").Document(monthNow);
            invoiceSnap      = await invoiceReference.GetSnapshotAsync();


            plans   = planSnap.ConvertTo <Plans>();
            clients = userSnap.ConvertTo <Clients>();

            if (invoiceSnap.Exists)
            {
                invoices              = invoiceSnap.ConvertTo <Invoices>();
                txtHolder.Text        = clients.name;
                txtPlanName.Text      = invoices.planName;
                txtPlanValue.Text     = invoices.value;
                txtAditional.Text     = invoices.aditional.ToString();
                cboPaymentMethod.Text = invoices.paymentMethod;
                txtDueDate.Text       = invoices.dueDate.ToString();
                if (clients.dependents.Count > 0)
                {
                    dependentsList = clients.dependents;
                    for (int x = 0; x < dependentsList.Count; x++)
                    {
                        addDependent();
                    }
                }
            }
            else
            {
                txtHolder.Text    = clients.name;
                txtPlanName.Text  = plans.name + " (" + plans.type + ")";
                txtPlanValue.Text = plans.value;
                txtAditional.Text = "0";
            }

            cboPaymentMethod.DropDownStyle = ComboBoxStyle.DropDownList;
        }
示例#30
0
        static void Main(string[] args)
        {
            BoardPosition boardPosition = new BoardPosition
            {
                Row    = 0,
                Column = 2
            };

            Sudoku.Sudoku.TestFunction(boardPosition, "1111").Wait();
            GameStatus statusSent = new GameStatus
            {
                GamePaused = true
            };

            Sudoku.Sudoku.UpdateCloudGameStatus(statusSent, "1111").Wait();

            FirestoreDb       db             = FirestoreDb.Create("sudoku-87c4a");
            DocumentReference reference      = db.Collection("statuses").Document("1111");
            DocumentSnapshot  snapshot       = reference.GetSnapshotAsync().Result;
            GameStatus        statusReturned = snapshot.ConvertTo <GameStatus>();

            Console.WriteLine(statusReturned);

            BoardMove move = new BoardMove
            {
                Row    = 6,
                Column = 9,
                Value  = 2
            };
            GameStatus gameStatus = new GameStatus
            {
                LastMove = move,
            };
            GameConfig config = new GameConfig
            {
                Difficulty = 1,
                Player1Id  = "1111",
            };

            Sudoku.Sudoku.UpdateCloudGameStatus(gameStatus, "1111").Wait();
            //Sudoku.Sudoku.GetSudokuService().CreateNewGame(config);
            GameInstance game = Sudoku.Sudoku.GetSudokuService().GetGame("62b1e8b7-4f48-45cf-a663-bada78a02155");
            //Sudoku.Sudoku.GetSudokuService().RegisterPlayer("Kellyanne");
            //Player player = Sudoku.Sudoku.GetSudokuService().GetPlayer("45718b06-a9e3-4dd0-ab52-23aeaa2e0136");
            //Console.WriteLine(player.PlayerName);
            //Console.WriteLine(player.Score);

            GameInstance gameInstance = new GameInstance
            {
                Config = config,
                Status = gameStatus,
                GameId = "2222"
            };
        }