public async Task <IActionResult> OnPostAsync(List <IFormFile> files) { if (files.Count == 0) { return(Page()); } foreach (var file in files) { using (var ms = new MemoryStream()) { file.CopyTo(ms); ms.Seek(0, SeekOrigin.Begin); var auth = new FirebaseAuthProvider(new FirebaseConfig("")); var a = await auth.SignInWithEmailAndPasswordAsync("*****@*****.**", ""); var url = await new FirebaseStorage(".appspot.com", new FirebaseStorageOptions { AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken), ThrowOnCancel = true }) .Child("data") .Child(file.FileName) .PutAsync(ms); ImgUrl.Add(url); } } return(Page()); }
/// <summary> /// Returns true if Image instances are equal /// </summary> /// <param name="other">Instance of Image to be compared</param> /// <returns>Boolean</returns> public bool Equals(Image other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( ImgUrl == other.ImgUrl || ImgUrl != null && ImgUrl.Equals(other.ImgUrl) ) && ( University == other.University || University != null && University.Equals(other.University) )); }
void ReleaseDesignerOutlets() { if (Title != null) { Title.Dispose(); Title = null; } if (Price != null) { Price.Dispose(); Price = null; } if (ImgUrl != null) { ImgUrl.Dispose(); ImgUrl = null; } if (Summary != null) { Summary.Dispose(); Summary = null; } if (Specification != null) { Specification.Dispose(); Specification = null; } }
/// <summary> /// 下一张 /// </summary> private void NextPic() { _currentIndex = ImgUrl.FindIndex(v => v.ChatIndex == _chatIndex); if (_currentIndex == -1) { return; } if (_currentIndex >= ImgUrl.Count - 1) { _currentIndex = ImgUrl.Count - 1; TipsText = "已经是最后一张"; TipsVisibility = Visibility.Visible; Application.Current.Dispatcher.Invoke(Timing); } else { _currentIndex++; _chatIndex = ImgUrl[_currentIndex].ChatIndex; var img = ImgUrl[_currentIndex]; if ((img.IsBurn == burnMsg.isBurnMsg.yesBurn && img.IsRead == burnMsg.IsReadImg.notRead) || (img.IsRead == burnMsg.IsReadImg.read && img.IsEffective == burnMsg.IsEffective.NotEffective)) { NextPic(); } else { _oldIndex = _currentIndex; UpdateImage(); } } }
/// <summary> /// 上一张 /// </summary> private void PrePic() { _currentIndex = ImgUrl.FindIndex(v => v.ChatIndex == _chatIndex); switch (_currentIndex) { case -1: return; case 0: TipsText = "已经是第一张"; TipsVisibility = Visibility.Visible; Application.Current.Dispatcher.Invoke(Timing); break; default: _currentIndex--; _chatIndex = ImgUrl[_currentIndex].ChatIndex; var img = ImgUrl[_currentIndex]; if ((img.IsBurn == burnMsg.isBurnMsg.yesBurn && img.IsRead == burnMsg.IsReadImg.notRead) || (img.IsRead == burnMsg.IsReadImg.read && img.IsEffective == burnMsg.IsEffective.NotEffective)) { PrePic(); } else { _oldIndex = _currentIndex; UpdateImage(); } break; } }
public async Task <ImgUrl> GetImgURL(Loids loid, int size = 500) { WebClient wc = new WebClient(); string ApiJson = await wc.DownloadStringTaskAsync($"https://api.meek.moe/{GetLoid(loid)}"); ApiResponse ar = JsonConvert.DeserializeObject <ApiResponse>(ApiJson); ImgUrl iu = new ImgUrl { Url = ar.Url, ProxyUrl = $"https://api.meek.moe/im/?image={ar.Url}&resize={size}", Creator = ar.Creator }; return(iu); }
public string GetImageUrl() { try { var url = (Url)mongoCollection.FindOneAs(typeof(Url), Query.EQ("category", "notAdded")); // This gives ImgUrl = url.image; ImgID = url._id; ImgUrlNrml = url.image; HttpWebRequest request = WebRequest.Create(ImgUrl) as HttpWebRequest; // instruct the server to return headers only request.Method = "HEAD"; // make the connection try { HttpWebResponse response = request.GetResponse() as HttpWebResponse; HttpStatusCode status = response.StatusCode; } catch (Exception) { UpdateBuilder updateBuilder2 = MongoDB.Driver.Builders.Update .Set("category", "notFound"); mongoCollection.Update(Query.EQ("_id", BsonObjectId.Parse(ImgID)), updateBuilder2); Page_Load(null, EventArgs.Empty); } if (ImgUrl.Contains("_normal")) { ImgUrl = ImgUrl.Replace("_normal", ""); } return(ImgUrl); } catch (Exception) { radioButtonList.Visible = false; btn.Visible = false; Response.Write("Db Query Error"); return("http://www.dioceseofmarquette.org/images/images/404.png"); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (ImgUrl != null) { hashCode = hashCode * 59 + ImgUrl.GetHashCode(); } if (University != null) { hashCode = hashCode * 59 + University.GetHashCode(); } return(hashCode); } }
public override bool Equals(System.Object otherCake) { if (!(otherCake is Cupcake)) { return(false); } else { Cupcake newCupcake = (Cupcake)otherCake; bool IdEquality = Id.Equals(newCupcake.Id); bool NameEquality = Name.Equals(newCupcake.Name); bool DescriptionEquality = Description.Equals(newCupcake.Description); bool PriceEquality = Price.Equals(newCupcake.Price); bool CakeEquality = Cake.Equals(newCupcake.Cake); bool FrostingEquality = Frosting.Equals(newCupcake.Frosting); bool ToppingEquality = Topping.Equals(newCupcake.Topping); bool InventoryEquality = Inventory.Equals(newCupcake.Inventory); bool ImgUrlEquality = ImgUrl.Equals(newCupcake.ImgUrl); return(IdEquality && NameEquality && DescriptionEquality && PriceEquality && CakeEquality && FrostingEquality && ToppingEquality && InventoryEquality && ImgUrlEquality); } }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="executionContext">The execution context.</param> protected override void Execute(CodeActivityContext executionContext) { // Create the tracing service ITracingService tracingService = executionContext.GetExtension <ITracingService>(); if (tracingService == null) { throw new InvalidPluginExecutionException("Failed to retrieve tracing service."); } tracingService.Trace("Entered " + _activityName + ".Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}", executionContext.ActivityInstanceId, executionContext.WorkflowInstanceId); // Create the context IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); if (context == null) { throw new InvalidPluginExecutionException("Failed to retrieve workflow context."); } tracingService.Trace(_activityName + ".Execute(), Correlation Id: {0}, Initiating User: {1}", context.CorrelationId, context.InitiatingUserId); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); try { //set default outputs to false, blank, whatever PlateFound.Set(executionContext, false); ContactFound.Set(executionContext, false); ContactId.Set(executionContext, Guid.Empty.ToString()); ContactName.Set(executionContext, string.Empty); PlateNum.Set(executionContext, string.Empty); ImgUrl.Set(executionContext, string.Empty); //create the webrequest object and execute it System.Net.WebRequest req = System.Net.WebRequest.Create(Endpoint.Get(executionContext)); //must set the content type for json req.ContentType = "application/json"; //must set method to post req.Method = "GET"; //get the response System.Net.WebResponse resp = req.GetResponse(); Stream responseStream = CopyAndClose(resp.GetResponseStream()); // Do something with the stream StreamReader reader = new StreamReader(responseStream, Encoding.UTF8); String responseString = reader.ReadToEnd(); tracingService.Trace("json response: {0}", responseString); responseStream.Position = 0; //deserialize the response to a myjsonresponse object JsonResponse myResponse = new JsonResponse(); System.Runtime.Serialization.Json.DataContractJsonSerializer deserializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(myResponse.GetType()); myResponse = deserializer.ReadObject(responseStream) as JsonResponse; if (myResponse.Results.Length > 0) { //plate detected string platenum = myResponse.Results[0].Plate; PlateFound.Set(executionContext, true); PlateNum.Set(executionContext, platenum); //set image path var uri = new Uri(Endpoint.Get(executionContext)); string image = string.Format("{0}://{1}:{2}{3}", uri.Scheme, uri.Host, uri.Port, myResponse.Image); ImgUrl.Set(executionContext, image); //search for the contact //this should probably search for other matches if it can't find a result for the "best" match tracingService.Trace("entering 'contact search'", ""); tracingService.Trace("building fetch", ""); string fetchXml = @"<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'> <entity name='contact'> <attribute name='fullname'/> <filter type='and'> <condition attribute='lpa_platenumber' value='{0}' operator='eq'/> </filter> </entity> </fetch> "; fetchXml = string.Format(fetchXml, platenum); tracingService.Trace("prepared fetchxml: {0}", fetchXml); tracingService.Trace("retrieving contacts", ""); EntityCollection contacts = service.RetrieveMultiple(new FetchExpression(fetchXml)); if (contacts.Entities.Count == 1) { ContactFound.Set(executionContext, true); ContactId.Set(executionContext, contacts.Entities[0].Id.ToString()); ContactName.Set(executionContext, contacts.Entities[0]["fullname"].ToString()); } } } catch (WebException exception) { string str = string.Empty; if (exception.Response != null) { using (StreamReader reader = new StreamReader(exception.Response.GetResponseStream())) { str = reader.ReadToEnd(); } exception.Response.Close(); } if (exception.Status == WebExceptionStatus.Timeout) { throw new InvalidPluginExecutionException( "The timeout elapsed while attempting to issue the request.", exception); } throw new InvalidPluginExecutionException(String.Format(CultureInfo.InvariantCulture, "A Web exception ocurred while attempting to issue the request. {0}: {1}", exception.Message, str), exception); } catch (FaultException <OrganizationServiceFault> e) { tracingService.Trace("Exception: {0}", e.ToString()); // Handle the exception. throw; } catch (Exception e) { tracingService.Trace("Exception: {0}", e.ToString()); throw; } tracingService.Trace("Exiting " + _activityName + ".Execute(), Correlation Id: {0}", context.CorrelationId); }