public async Task <AbbigliamentoECommerceEntity.User> GetUser(string pId) { FirestoreDb db = CreateInstanceDB(); AbbigliamentoECommerceEntity.User wUser = new AbbigliamentoECommerceEntity.User(); var appSettings = ConfigurationManager.AppSettings; string wApiKey = appSettings["FirebaseApiKey"] ?? "Not Found"; // var authProvider = new FirebaseAuthProvider(new FirebaseConfig(wApiKey)); try { //recupero del uid utente per recuperare tutte le info del'utente loggato DocumentReference wDocRef = db.Collection("user").Document(pId); DocumentSnapshot snapshot = await wDocRef.GetSnapshotAsync(); if (snapshot.Exists) { wUser.Address = snapshot.ContainsField("Address") ? snapshot.GetValue <string>("Address") : ""; wUser.City = snapshot.ContainsField("City") ? snapshot.GetValue <string>("City") : ""; wUser.cognome = snapshot.ContainsField("cognome") ? snapshot.GetValue <string>("cognome") : ""; wUser.DateOfBirth = snapshot.ContainsField("DateOfBirth") ? snapshot.GetValue <DateTime>("DateOfBirth") : DateTime.MinValue; wUser.District = snapshot.ContainsField("District") ? snapshot.GetValue <string>("District") : ""; wUser.email = snapshot.ContainsField("email") ? snapshot.GetValue <string>("email") : ""; wUser.Id = pId; wUser.nome = snapshot.ContainsField("nome") ? snapshot.GetValue <string>("nome") : ""; wUser.Ruolo = snapshot.ContainsField("Ruolo") ? snapshot.GetValue <string>("Ruolo") : "cliente"; wUser.TelefoneNumber = snapshot.ContainsField("TelefoneNumber") ? snapshot.GetValue <string>("TelefoneNumber") : ""; } } catch (Exception ex) { throw; } return(wUser); }
public static async Task <Dictionary <string, object> > SetInitDataAsync(string type, string name, string email) { FirestoreDb firestore = FirestoreDb.Create("photogw2"); var collection = firestore.Collection("BackupRestoreRecord").Document(); var snapshot = await collection.GetSnapshotAsync(); var DateStart = DateTime.Now.ToUniversalTime(); Dictionary <string, object> data = new Dictionary <string, object> { { "DateStart", DateStart }, { "User", name }, { "Email", email }, { "Type", type } }; await collection.SetAsync(data); return(new Dictionary <string, object> { { "id", collection.Id }, { "date", DateStart } }); }
public async Task <HttpResponseMessage> IsDeleted(MT_Specilities SCMD) { Db = con.SurgeryCenterDb(SCMD.Slug); SpecilityResponse Response = new SpecilityResponse(); try { Dictionary <string, object> initialData = new Dictionary <string, object> { { "Spec_Is_Deleted", SCMD.Spec_Is_Deleted }, { "Spec_Modify_Date", con.ConvertTimeZone(SCMD.Spec_TimeZone, Convert.ToDateTime(SCMD.Spec_Modify_Date)) } }; DocumentReference docRef = Db.Collection("MT_Specilities").Document(SCMD.Spec_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = SCMD; } else { Response.Status = con.StatusNotUpdate; Response.Message = con.MessageNotUpdate; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
//recupera il prodotto tramite uid per la gestione del dettaglio prodotto public async Task <Product> GetProductById(string pId) { Product wProd = new Product(); FirestoreDb db = CreateInstanceDB(); DocumentReference wDocRef = db.Collection("prodotto").Document(pId); DocumentSnapshot documentSnapshot = await wDocRef.GetSnapshotAsync(); if (documentSnapshot.Exists) { wProd.UId = documentSnapshot.Id; wProd.categoria = documentSnapshot.ContainsField("categoria") ? documentSnapshot.GetValue <string>("categoria") : ""; wProd.colore = documentSnapshot.ContainsField("colore") ? documentSnapshot.GetValue <string>("colore") : ""; wProd.marca = documentSnapshot.ContainsField("marca") ? documentSnapshot.GetValue <string>("marca") : ""; wProd.nome = documentSnapshot.ContainsField("nome") ? documentSnapshot.GetValue <string>("nome") : ""; wProd.prezzo = documentSnapshot.ContainsField("prezzo") ? documentSnapshot.GetValue <double>("prezzo") : 0; wProd.taglia = documentSnapshot.ContainsField("taglia") ? documentSnapshot.GetValue <string>("taglia") : ""; wProd.UrlDownloadWeb = documentSnapshot.ContainsField("urlDownloadWeb") ? documentSnapshot.GetValue <string>("urlDownloadWeb") : ""; wProd.descrizione = documentSnapshot.ContainsField("descrizione") ? documentSnapshot.GetValue <string>("descrizione") : ""; wProd.Quantity = documentSnapshot.ContainsField("Quantity") ? documentSnapshot.GetValue <int>("Quantity") : 0; } return(wProd); }
public void CreateTarget_Query() { var client = new FakeFirestoreClient(); var db = FirestoreDb.Create("project", "db", client); var query = db.Collection("col").Limit(10); var expected = new Target { TargetId = WatchStream.WatchTargetId, Query = new QueryTarget { Parent = db.DocumentsPath, StructuredQuery = new StructuredQuery { From = { new CollectionSelector { CollectionId = "col" } }, Limit = 10 } } }; var actual = WatchStream.CreateTarget(query); Assert.Equal(expected, actual); }
private async void removerToolStripMenuItem_Click(Object sender, EventArgs e) { if (MessageBox.Show("Tem certeza que deseja excluir o parceiro?", "Confirmar exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { 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 documentReference = db.Collection("benefits").Document(invoiceID); await documentReference.DeleteAsync(); try { await loadInvoicesAsync(); } catch { } } else { } }
public async Task <HttpResponseMessage> CreateAsync(MT_Document_Category DCMD) { Db = con.SurgeryCenterDb(DCMD.Slug); DocuCategoryResponse Response = new DocuCategoryResponse(); try { List <string> List = new List <string>(); UniqueID = con.GetUniqueKey(); DCMD.DOC_Unique_ID = UniqueID; DCMD.DOC_Create_Date = con.ConvertTimeZone(DCMD.DOC_TimeZone, Convert.ToDateTime(DCMD.DOC_Create_Date)); DCMD.DOC_Modify_Date = con.ConvertTimeZone(DCMD.DOC_TimeZone, Convert.ToDateTime(DCMD.DOC_Modify_Date)); DocumentReference docRef = Db.Collection("MT_Document_Category").Document(UniqueID); WriteResult Result = await docRef.SetAsync(DCMD); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = DCMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public void Update() { var db = FirestoreDb.Create("project", "db", new FakeFirestoreClient()); var batch = db.StartBatch(); var doc = db.Document("col/doc"); var updates = new Dictionary <FieldPath, object> { { new FieldPath("a.b", "f.g"), 7 }, { FieldPath.FromDotSeparatedString("h.m"), new Dictionary <string, object> { { "n.o", 7 } } } }; batch.Update(doc, updates); var expectedWrite = new Write { CurrentDocument = new V1Beta1.Precondition { Exists = true }, Update = new Document { Name = doc.Path, Fields = { { "a.b", CreateMap("f.g", CreateValue(7)) }, { "h", CreateMap("m", CreateMap("n.o", CreateValue(7)))} } }, UpdateMask = new DocumentMask { FieldPaths = { "`a.b`.`f.g`", "h.m" } } }; AssertWrites(batch, (expectedWrite, true)); }
public async Task <HttpResponseMessage> GetActualURL(MT_Patient_Forms_URLs PMD) { Db = con.SurgeryCenterDb(PMD.Slug); PFURLResponse Response = new PFURLResponse(); try { MT_Patient_Booking Pbooking = new MT_Patient_Booking(); Query ObjQuery = Db.Collection("MT_Patient_Forms_URLs").WhereEqualTo("PFU_Is_Active", true).WhereEqualTo("PFU_Dummy_URL", PMD.PFU_Dummy_URL); QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null) { MT_Patient_Forms_URLs PFU = new MT_Patient_Forms_URLs(); foreach (DocumentSnapshot docsnap in ObjQuerySnap.Documents) { PFU = docsnap.ConvertTo <MT_Patient_Forms_URLs>(); } Response.AURL = PFU.PFU_Actual_URL; Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; } else { Response.Status = con.StatusDNE; Response.Message = con.MessageDNE; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <IDataResult <User> > GetByEmail(string email) { FirestoreDb firestoreDb = FirestoreDb.Create(FirebaseConstants.DATABASE); Query userQuery = firestoreDb.Collection(FirebaseConstants.USER_COLLECTION).WhereEqualTo("Email", email); QuerySnapshot userSnapshots = await userQuery.GetSnapshotAsync(); User user = null; foreach (DocumentSnapshot document in userSnapshots.Documents) { Dictionary <string, object> data = document.ToDictionary(); string documentId = document.Id; string firstName = data["FirstName"].ToString(); string lastName = data["LastName"].ToString(); string _email = data["Email"].ToString(); string userID = data["UserID"].ToString(); string userName = data["UserName"].ToString(); string profileImage = data["ProfileImage"].ToString(); string token = data["Token"].ToString(); string about = data["About"].ToString(); Uri uriImage = null; if (profileImage != null) { uriImage = new Uri(profileImage); } user = new User(firstName, lastName, _email, "", userName, userID, uriImage, about, documentId); } if (user != null) { return(new SuccessDataResult <User>(user)); } return(new ErrorDataResult <User>(user)); }
public async Task RunTransactionAsync_RollbackAndRetry() { var client = new TransactionTestingClient(2, CreateRpcException(StatusCode.Aborted)); var db = FirestoreDb.Create("proj", "db", client); var result = await db.RunTransactionAsync(CreateCountingCallback()); // Two failures were retries, so our callback executed 3 times. Assert.Equal(3, result); var expectedCommitRequests = new[] { CreateCommitRequest("transaction 1"), CreateCommitRequest("transaction 2; retrying transaction 1"), CreateCommitRequest("transaction 3; retrying transaction 2") }; var expectedRollbackRequests = new[] { CreateRollbackRequest("transaction 1"), CreateRollbackRequest("transaction 2; retrying transaction 1"), }; Assert.Equal(expectedCommitRequests, client.CommitRequests); Assert.Equal(expectedRollbackRequests, client.RollbackRequests); }
public async Task <HttpResponseMessage> AlreadyExist(MT_Surgical_Procedure_Templates SPMD) { Db = con.SurgeryCenterDb(SPMD.Slug); TemplateResponse Response = new TemplateResponse(); try { Query ObjQuery = Db.Collection("MT_Surgical_Procedure_Templates").WhereEqualTo("SPT_Is_Active", true).WhereEqualTo("SPT_Is_Deleted", false).WhereEqualTo("SPT_Template_Name", SPMD.SPT_Template_Name); QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null) { if (ObjQuerySnap.Documents.Count == 0) { Response.Exist = true; } else { Response.Exist = false; } Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; } else { Response.Status = con.StatusDNE; Response.Message = con.MessageDNE; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
internal RoundRobinPool(int size, string projectId) { ICredential credential = GoogleCredential.GetApplicationDefault(); _pool = Enumerable .Range(0, size) .Select(_ => CreateFirestoreDb()) .ToArray(); FirestoreDb CreateFirestoreDb() { // This code forces each channel to really use a different network connection. // Without this, different .NET Channel objects can end up using the same underlying // connection due to pooling in the C-core layer of gRPC. // Note: it would be nice to have a simpler way of doing this. var channel = new Channel( FirestoreClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials(), new ChannelOption[] { new ChannelOption("grpc_gcp.client_channel.id", Guid.NewGuid().ToString()) }); var client = FirestoreClient.Create(channel); return(FirestoreDb.Create(projectId, client)); } }
public async Task <HttpResponseMessage> Edit(MT_PatientIntakeTiming PIMD) { Db = con.SurgeryCenterDb(PIMD.Slug); PatInTimingResponse Response = new PatInTimingResponse(); try { Dictionary <string, object> initialData = new Dictionary <string, object> { { "PITT_Time", PIMD.PITT_Time }, { "PITT_Modify_Date", con.ConvertTimeZone(PIMD.PITT_TimeZone, Convert.ToDateTime(PIMD.PITT_Modify_Date)) }, }; DocumentReference docRef = Db.Collection("MT_PatientIntakeTiming").Document(PIMD.PITT_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = PIMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <HttpResponseMessage> CreateAsync(MT_Notifications NSMD) { Db = con.SurgeryCenterDb(NSMD.Slug); NotificationsResponse Response = new NotificationsResponse(); try { List <Notification_Action> ActionList = new List <Notification_Action>(); UniqueID = con.GetUniqueKey(); NSMD.NFT_Unique_ID = UniqueID; NSMD.NFT_Create_Date = con.ConvertTimeZone(NSMD.NFT_TimeZone, Convert.ToDateTime(NSMD.NFT_Create_Date)); NSMD.NFT_Modify_Date = con.ConvertTimeZone(NSMD.NFT_TimeZone, Convert.ToDateTime(NSMD.NFT_Modify_Date)); NSMD.NFT_Actions = ActionList; DocumentReference docRef = Db.Collection("MT_Notifications").Document(UniqueID); WriteResult Result = await docRef.SetAsync(NSMD); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = NSMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.AddAuthentication().AddJwtBearer(option => { option.IncludeErrorDetails = true; option.Authority = "https://securetoken.google.com/groover-3b82a"; option.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = "https://securetoken.google.com/groover-3b82a", ValidateAudience = true, ValidAudience = "groover-3b82a", ValidateLifetime = true, }; }); services.AddSingleton(typeof(FirebaseApp), FirebaseApp.Create()); services.AddSingleton(typeof(FirestoreDb), FirestoreDb.Create("groover-3b82a")); services.AddScoped <IPlacesService, PlacesService>(); services.AddScoped <IPlacesDao <GrooverAdm.DataAccess.Firestore.Model.Place>, PlacesFirestoreDao>(); services.AddScoped <IPlaceMapper <GrooverAdm.DataAccess.Firestore.Model.Place>, PlaceMapper>(); services.AddScoped <GrooverAdm.Business.Services.SpotifyService>(); services.AddScoped <GrooverAdm.Business.Services.LastFmService>(); services.AddScoped <GrooverAdm.Business.Services.User.IUserService, GrooverAdm.Business.Services.User.UserService>(); services.AddScoped <IUserDao <GrooverAdm.DataAccess.Firestore.Model.User>, GrooverAdm.DataAccess.Firestore.Dao.UserFirestoreDao>(); services.AddScoped <IUserMapper <GrooverAdm.DataAccess.Firestore.Model.User>, UserMapper>(); }
// Opdracht a: Maak een webpagina met een overzicht van alle klanten public async Task <IActionResult> Index() { db = FirestoreDatabase.LoadDatabase(); // Fetch collection genaamd klanten CollectionReference coll = db.Collection("Klanten"); List <DocumentKlant> documentKlantLijst = new List <DocumentKlant>(); // Maak snapshot van hele klanten collection QuerySnapshot alleKlanten = await coll.GetSnapshotAsync(); foreach (DocumentSnapshot document in alleKlanten.Documents) { DocumentKlant documentKlant = new DocumentKlant { DocumentId = document.Id, Klant = document.ConvertTo <Klant>() }; documentKlantLijst.Add(documentKlant); } return(View(documentKlantLijst)); }
private async Task <string> GetDocumentId(string collectionName, string serviceName) { FirestoreDb db = connection.GetFirestoreDb(); CollectionReference colRef = db .Collection(collectionName); Query query = colRef .WhereEqualTo("ServiceName", serviceName); string docId = string.Empty; QuerySnapshot snapshot = await query.GetSnapshotAsync(); foreach (DocumentSnapshot ds in snapshot.Documents) { if (ds.Exists) { docId = ds.Id; } } return(docId); }
public async Task <HttpResponseMessage> CreateAsync(MT_Insurance_Company ICMD) { Db = con.SurgeryCenterDb(ICMD.Slug); InsurCompanyResponse Response = new InsurCompanyResponse(); try { List <MT_Insurance_Company> SpelitiesList = new List <MT_Insurance_Company>(); UniqueID = con.GetUniqueKey(); ICMD.INC_Unique_ID = UniqueID; ICMD.INC_Create_Date = con.ConvertTimeZone(ICMD.INC_TimeZone, Convert.ToDateTime(ICMD.INC_Create_Date)); ICMD.INC_Modify_Date = con.ConvertTimeZone(ICMD.INC_TimeZone, Convert.ToDateTime(ICMD.INC_Modify_Date)); DocumentReference docRef = Db.Collection("MT_Insurance_Company").Document(UniqueID); WriteResult Result = await docRef.SetAsync(ICMD); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = ICMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public void GetThreads(Guid curThread) { if (Session["curUser"] == null) { return; } db = FirestoreDb.Create("cen-project-d757f"); chatRef = db.Collection("chatThreads"); if (curThread != new Guid()) { GetThread(curThread); return; } var x = chatRef.OrderByDescending("milliseconds"); QuerySnapshot qs = x.GetSnapshotAsync().Result; StringBuilder s = new StringBuilder(); int i = 1; foreach (DocumentSnapshot snapshot in qs.Documents) { s.AppendLine("<div id=\"thread" + i.ToString() + "\" runat=\"server\" class=\"box\">"); s.AppendLine("<div style=\"height:100px;width:500px;bottom:0;position:absolute;background:linear-gradient(to bottom, transparent 0%, white 90%);\"></div><h4 style=\"color: darkslategray;\"><a href=\"Chat.aspx?tid=" + snapshot.Id + "\">" + snapshot.GetValue <string>("title") + "</a></h4><p style=\"color:lightslategrey; text-overflow:clip\">"); s.AppendLine("Posted by user: "******"postedBy")); s.AppendLine(" at: " + new DateTime(1970, 1, 1).AddMilliseconds(snapshot.GetValue <double>("milliseconds")).ToString()); s.AppendLine("<br/><br/>"); s.AppendLine(snapshot.GetValue <string>("message")); s.AppendLine("</p></div>"); s.AppendLine("<br/><br/>"); i++; } threadList.InnerHtml = s.ToString(); }
public async Task <ActionResult> Index() { string Path = AppDomain.CurrentDomain.BaseDirectory + @"greenpaperdev-firebase-adminsdk-8k2y5-fb46e63414.json"; Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Path); FirestoreDb db = FirestoreDb.Create("greenpaperdev"); List <Clinic> ClinicList = new List <Clinic>(); //Query Qref = db.Collection("users").WhereEqualTo("StudentName", "Suvidhi"); Query Qref = db.Collection("clinics"); QuerySnapshot snap = await Qref.GetSnapshotAsync(); foreach (DocumentSnapshot docsnap in snap) { Clinic clinic = docsnap.ConvertTo <Clinic>(); if (docsnap.Exists) { ClinicList.Add(clinic); } } return(View(ClinicList)); }
public async Task <HttpResponseMessage> IsActive(MT_RelationToParent RPMD) { Db = con.SurgeryCenterDb(RPMD.Slug); RelaToParentResponse Response = new RelaToParentResponse(); try { Dictionary <string, object> initialData = new Dictionary <string, object> { { "Rtop_Is_Active", RPMD.Rtop_Is_Active }, { "Rtop_Modify_Date", con.ConvertTimeZone(RPMD.Rtop_TimeZone, Convert.ToDateTime(RPMD.Rtop_Modify_Date)) } }; DocumentReference docRef = Db.Collection("MT_RelationToParent").Document(RPMD.Rtop_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = RPMD; } else { Response.Status = con.StatusNotUpdate; Response.Message = con.MessageNotUpdate; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task GetSnapshotAsync_NoDocuments() { var mock = new Mock <FirestoreClient> { CallBase = true }; var request = new RunQueryRequest { Parent = "projects/proj/databases/db/documents", StructuredQuery = new StructuredQuery { Select = new Projection { Fields = { Field("Name") } }, From = { new CollectionSelector { CollectionId = "col" } } } }; var responses = new[] { new RunQueryResponse { ReadTime = CreateProtoTimestamp(1, 2) } }; mock.Setup(c => c.RunQuery(request, It.IsAny <CallSettings>())).Returns(new FakeQueryStream(responses)); var db = FirestoreDb.Create("proj", "db", mock.Object); var query = db.Collection("col").Select("Name"); var snapshot = await query.GetSnapshotAsync(); Assert.Empty(snapshot.Documents); Assert.Same(query, snapshot.Query); Assert.Equal(new Timestamp(1, 2), snapshot.ReadTime); mock.VerifyAll(); }
public async Task <GameStarFSDTO[]> Get() { string path = AppDomain.CurrentDomain.BaseDirectory + @"pauseproject.json"; Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", path); database = FirestoreDb.Create("pauseproject-349dd"); var res = await GetCollection(); string filepath = AppDomain.CurrentDomain.BaseDirectory; using (StreamWriter file = new System.IO.StreamWriter(filepath + @"\..\..\..\Data\users.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, res); } using (var r = new ChoJSONReader(filepath + @"\..\..\..\Data\users.json")) { using (var w = new ChoCSVWriter(filepath + @"\..\..\..\Data\" + "users.csv").WithFirstLineHeader()) { w.Write(r); } } return(res); }
public async Task <HttpResponseMessage> AddAttachment() { MT_Knowledger_Base KCMD = GetImages(); Db = con.SurgeryCenterDb(KCMD.Slug); KnowledgeBaseResponse Response = new KnowledgeBaseResponse(); try { MT_Knowledger_Base KBase = new MT_Knowledger_Base(); List <KBAttachment> AttcList = new List <KBAttachment>(); Query Qty = Db.Collection("MT_Knowledger_Base").WhereEqualTo("KNB_Is_Deleted", false).WhereEqualTo("KNB_Is_Active", true).WhereEqualTo("KNB_Unique_ID", KCMD.KNB_Unique_ID); QuerySnapshot ObjQuerySnap = await Qty.GetSnapshotAsync(); if (ObjQuerySnap != null) { KBase = ObjQuerySnap.Documents[0].ConvertTo <MT_Knowledger_Base>(); if (KBase.KNB_Document != null) { foreach (KBAttachment kbatt in KBase.KNB_Document) { AttcList.Add(kbatt); } } } if (KCMD.KNB_Document != null) { foreach (KBAttachment kbatt in KCMD.KNB_Document) { kbatt.KBA_Unique_ID = con.GetUniqueKey(); kbatt.KBA_Create_Date = con.ConvertTimeZone(kbatt.KBA_TimeZone, Convert.ToDateTime(kbatt.KBA_Create_Date)); kbatt.KBA_Modify_Date = con.ConvertTimeZone(kbatt.KBA_TimeZone, Convert.ToDateTime(kbatt.KBA_Modify_Date)); AttcList.Add(kbatt); } } KCMD.KNB_Document = AttcList; Dictionary <string, object> initialData = new Dictionary <string, object> { { "KNB_Modify_Date", con.ConvertTimeZone(KCMD.KNB_TimeZone, Convert.ToDateTime(KCMD.KNB_Modify_Date)) }, { "KNB_Document", KCMD.KNB_Document }, }; DocumentReference docRef = Db.Collection("MT_Knowledger_Base").Document(KCMD.KNB_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = KCMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <HttpResponseMessage> AddSuggestion(MT_Knowledger_Base KCMD) { Db = con.SurgeryCenterDb(KCMD.Slug); Boolean IsExist = false; KnowledgeBaseResponse Response = new KnowledgeBaseResponse(); try { List <Suggestion> suggestion = new List <Suggestion>(); Query qry = Db.Collection("MT_Knowledger_Base").WhereEqualTo("KNB_Is_Deleted", false).WhereEqualTo("KNB_Is_Active", true).WhereEqualTo("KNB_Unique_ID", KCMD.KNB_Unique_ID); QuerySnapshot ObjQuerySnap = await qry.GetSnapshotAsync(); if (ObjQuerySnap != null) { MT_Knowledger_Base KB = ObjQuerySnap.Documents[0].ConvertTo <MT_Knowledger_Base>(); if (KB.KNB_Suggestions != null) { foreach (Suggestion sug in KB.KNB_Suggestions) { if (sug.SG_User_ID == KCMD.KNB_Suggestions[0].SG_User_ID) { sug.SG_Is_Useful = KCMD.KNB_Suggestions[0].SG_Is_Useful; sug.SG_User_ID = KCMD.KNB_Suggestions[0].SG_User_ID; suggestion.Add(sug); IsExist = true; } else { suggestion.Add(sug); } } } } if (KCMD.KNB_Suggestions != null && IsExist == false) { foreach (Suggestion sug in KCMD.KNB_Suggestions) { suggestion.Add(sug); } } Dictionary <string, object> initialData = new Dictionary <string, object> { { "KNB_Suggestions", suggestion }, { "KNB_Modify_Date", con.ConvertTimeZone(KCMD.KNB_TimeZone, Convert.ToDateTime(KCMD.KNB_Modify_Date)) }, { "KNB_TimeZone", KCMD.KNB_TimeZone } }; DocumentReference docRef = Db.Collection("MT_Knowledger_Base").Document(KCMD.KNB_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = KCMD; } else { Response.Status = con.StatusNotUpdate; Response.Message = con.MessageNotUpdate; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
static private async Task DeleteCloudPlayer(string playerId) { FirestoreDb db = InitializeDataBase(); DocumentReference reference = db.Collection("players").Document(playerId); await reference.DeleteAsync(); }
public ProfilePage() { db = FirestoreDb.Create("nodereview-73781"); InitializeComponent(); getSnapshot(); }
public async Task <HttpResponseMessage> EditAction(MT_Patient_Intake PIMD) { Db = con.SurgeryCenterDb(PIMD.Slug); PatientIntakeResponse Response = new PatientIntakeResponse(); try { List <Notification_Action> ActionList = new List <Notification_Action>(); Query ObjQuery = Db.Collection("MT_Patient_Intake").WhereEqualTo("PIT_Is_Deleted", false).WhereEqualTo("PIT_Is_Active", true).WhereEqualTo("PIT_Unique_ID", PIMD.PIT_Unique_ID); QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null) { MT_Patient_Intake noti = ObjQuerySnap.Documents[0].ConvertTo <MT_Patient_Intake>(); if (noti.PIT_Actions != null) { foreach (Notification_Action action in noti.PIT_Actions) { if (action.NFA_Unique_ID == PIMD.PIT_Actions[0].NFA_Unique_ID) { action.NFA_Action_Type = PIMD.PIT_Actions[0].NFA_Action_Type; action.NFA_Action_Title = PIMD.PIT_Actions[0].NFA_Action_Title; action.NFA_Action_Icon = PIMD.PIT_Actions[0].NFA_Action_Icon; action.NFA_Action_Subject = PIMD.PIT_Actions[0].NFA_Action_Subject; action.NFA_Be_Af = PIMD.PIT_Actions[0].NFA_Be_Af; action.NFA_Days = PIMD.PIT_Actions[0].NFA_Days; action.NFA_DayOrWeek = PIMD.PIT_Actions[0].NFA_DayOrWeek; action.NFA_Message = PIMD.PIT_Actions[0].NFA_Message; action.NFA_Modify_Date = con.ConvertTimeZone(PIMD.PIT_Actions[0].NFA_TimeZone, Convert.ToDateTime(PIMD.PIT_Actions[0].NFA_Modify_Date)); action.NFA_TimeZone = PIMD.PIT_Actions[0].NFA_TimeZone; ActionList.Add(action); } else { ActionList.Add(action); } } } } Dictionary <string, object> initialData = new Dictionary <string, object> { { "PIT_Actions", ActionList }, { "PIT_Modify_Date", con.ConvertTimeZone(PIMD.PIT_TimeZone, Convert.ToDateTime(PIMD.PIT_Modify_Date)) }, { "PIT_TimeZone", PIMD.PIT_TimeZone } }; DocumentReference docRef = Db.Collection("MT_Patient_Intake").Document(PIMD.PIT_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = PIMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <IActionResult> Details(string id) { if (id == null) { return(View()); } if (!await _userService.IsUserInGroup(User.GetUserID(), id)) { ViewData["URL"] = Request.Host.ToString() + Request.Path; return(View("Unauthorized")); } string credential_path = @"C:\Users\ghrey\Downloads\ScrumManager-c7ce2bf2810c.json"; Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credential_path); FirestoreDb db = FirestoreDb.Create("scrummanager"); var data = await db.Collection("groups").Document(id).GetSnapshotAsync(); var group = data.ConvertTo <Group>(); var groupVM = new GroupVM(group); foreach (var u in groupVM.Users) { if (!u.Value.Roles.Contains("Writer")) { continue; } var logData = await db.Collection("logs") .WhereEqualTo("UserID", u.Key) .WhereGreaterThanOrEqualTo("Date", DateTime.Now.ToUniversalTime().Date) .WhereLessThan("Date", DateTime.Now.AddDays(1).ToUniversalTime().Date) .GetSnapshotAsync(); var logDoc = logData.FirstOrDefault(); if (logDoc != null) { var log = logDoc.ConvertTo <Log>(); groupVM.Logs.Add(log.DocId, log); } else { groupVM.Logs.Add(u.Value.DisplayName, new Log() { UserName = u.Value.DisplayName, UserID = u.Key }); } } var query = db.Collection("logs") .WhereEqualTo("GroupID", id) .WhereGreaterThanOrEqualTo("Date", DateTime.Now.ToUniversalTime().Date) .WhereLessThan("Date", DateTime.Now.AddDays(1).ToUniversalTime().Date); var hubChannel = id + "_" + DateTime.Now.ToString("yyyyMMdd"); var UserID = User.GetUserID(); groupVM.UserID = UserID; _listener = query.Listen(async snapshot => { foreach (DocumentChange change in snapshot.Changes) { var log = change.Document.ConvertTo <Log>(); if (log.UserID == UserID) { continue; } if (change.ChangeType.ToString() == "Added") { await _logHub.LogAdded(hubChannel, log); } else if (change.ChangeType.ToString() == "Modified") { await _logHub.LogModified(hubChannel, log); } else if (change.ChangeType.ToString() == "Removed") { await _logHub.LogRemoved(hubChannel, log); } } }); return(View(groupVM)); }