コード例 #1
0
        public static IncidentAPIClient GetIncidentAPIClient()
        {
            ServiceClientCredentials creds = new BasicAuthenticationCredentials();
            var client = new IncidentAPIClient(new Uri("YOUR INCIDENT API URL"), creds);

            return(client);
        }
コード例 #2
0
        public static IncidentAPIClient GetIncidentAPIClient()
        {
            ServiceClientCredentials creds = new BasicAuthenticationCredentials();
            var client = new IncidentAPIClient(new Uri(Settings.INCIDENT_API_URL), creds);

            return(client);
        }
コード例 #3
0
        public static IncidentAPIClient GetIncidentAPIClient()
        {
            ServiceClientCredentials creds = new BasicAuthenticationCredentials();
            var client = new IncidentAPIClient(new Uri(CloudConfigurationManager.GetSetting("INCIDENT_API_URL")), creds);

            return(client);
        }
コード例 #4
0
        public async Task <ActionResult> Create([Bind(Include = "City,Created,Description,FirstName,ImageUri,IsEmergency,LastModified,LastName,OutageType,PhoneNumber,Resolved,State,Street,ZipCode")] IncidentViewModel incident, HttpPostedFileBase imageFile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Incident incidentToSave = IncidentMapper.MapIncidentViewModel(incident);

                    using (IncidentAPIClient client = IncidentApiHelper.GetIncidentAPIClient())
                    {
                        var result = client.IncidentOperations.CreateIncident(incidentToSave);
                        Newtonsoft.Json.Linq.JObject jobj = (Newtonsoft.Json.Linq.JObject)result;
                        incidentToSave = jobj.ToObject <Incident>();
                    }

                    //TODO: ADD CODE TO UPLOAD THE BLOB
                    //Now upload the file if there is one
                    if (imageFile != null && imageFile.ContentLength > 0)
                    {
                        //### Add Blob Upload code here #####
                        //Give the image a unique name based on the incident id
                        var imageUrl = await StorageHelper.UploadFileToBlobStorage(incidentToSave.Id, imageFile);

                        //### Add Blob Upload code here #####


                        //### Add Queue code here #####
                        //Add a message to the queue to process this image
                        await StorageHelper.AddMessageToQueue(incidentToSave.Id, imageFile.FileName);

                        //### Add Queue code here #####
                    }

                    ////##### CLEAR CACHE ####
                    //RedisCacheHelper.ClearCache(Settings.REDISCCACHE_KEY_INCIDENTDATA);
                    //##### CLEAR CACHE ####
                    //##### SEND EMAIL #####
                    await SendIncidentEmail(incidentToSave);

                    //##### SEND EMAIL  #####

                    await CreateEvent(incidentToSave);


                    return(RedirectToAction("Index", "Dashboard"));
                }
            }
            catch
            {
                return(View());
            }

            return(View(incident));
        }
コード例 #5
0
        public async Task <ActionResult> Create([Bind(Include = "City,Created,Description,FirstName,ImageUri,IsEmergency,LastModified,LastName,OutageType,PhoneNumber,Resolved,State,Street,ZipCode")] IncidentViewModel incident, HttpPostedFileBase imageFile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Incident incidentToSave = IncidentMappers.MapIncidentViewModel(incident);

                    using (IncidentAPIClient client = IncidentApiHelper.GetIncidentAPIClient())
                    {
                        var result = client.Incident.CreateIncident(incidentToSave);
                        if (!string.IsNullOrEmpty(result))
                        {
                            incidentToSave = JsonConvert.DeserializeObject <Incident>(result);
                        }
                    }

                    //Now upload the file if there is one
                    if (imageFile != null && imageFile.ContentLength > 0)
                    {
                        //### Add Blob Upload code here #####
                        //Give the image a unique name based on the incident id
                        var imageUrl = await StorageHelper.UploadFileToBlobStorage(incidentToSave.ID, imageFile);

                        //### Add Blob Upload code here #####


                        //### Add Queue code here #####
                        //Add a message to the queue to process this image
                        await StorageHelper.AddMessageToQueue(incidentToSave.ID, imageFile.FileName);

                        //### Add Queue code here #####
                    }

                    //##### CLEAR CACHE ####
                    RedisCacheHelper.ClearCache(Settings.REDISCCACHE_KEY_INCIDENTDATA);
                    //##### CLEAR CACHE ####

                    //##### SEND EMAIL #####
                    await SendIncidentEmail(incidentToSave, Url.Action("Index", "Dashboard", null, Request.Url.Scheme));

                    //##### SEND EMAIL  #####

                    return(RedirectToAction("Index", "Dashboard"));
                }
            }
            catch
            {
                return(View());
            }

            return(View(incident));
        }
コード例 #6
0
        public ActionResult Details(string Id)
        {
            IncidentViewModel incidentView = null;

            using (IncidentAPIClient client = IncidentApiHelper.GetIncidentAPIClient())
            {
                var result = client.IncidentOperations.GetById(Id);
                Newtonsoft.Json.Linq.JObject jobj = (Newtonsoft.Json.Linq.JObject)result;
                Incident incident = jobj.ToObject <Incident>();
                incidentView = IncidentMapper.MapIncidentModelToView(incident);
            }

            return(View(incidentView));
        }
コード例 #7
0
        public ActionResult Details(string Id)
        {
            IncidentViewModel incidentView = null;

            using (IncidentAPIClient client = IncidentApiHelper.GetIncidentAPIClient())
            {
                var result = client.Incident.GetById(Id);
                if (!string.IsNullOrEmpty(result))
                {
                    Incident incident = JsonConvert.DeserializeObject <Incident>(result);
                    incidentView = IncidentMappers.MapIncidentModelToView(incident);
                }
            }

            return(View(incidentView));
        }
コード例 #8
0
        public static async Task <bool> CreateAsync(String firstName, String lastName, String street, String city, String state, String zipCode, String phoneNumber, String description, String outageType, Boolean?isEmergency, Stream image, String imageName, String imageType, String tags)
        {
            Boolean added = false;

            try
            {
                Incident newIncident = new Incident();
                newIncident.FirstName   = firstName;
                newIncident.LastName    = lastName;
                newIncident.Street      = street;
                newIncident.City        = city;
                newIncident.State       = state;
                newIncident.ZipCode     = zipCode;
                newIncident.PhoneNumber = phoneNumber;
                newIncident.Description = description;
                newIncident.OutageType  = outageType;
                newIncident.IsEmergency = isEmergency;
                newIncident.Tags        = tags;

                using (IncidentAPIClient client = GetIncidentAPIClient())
                {
                    var result = client.IncidentOperations.CreateIncident(newIncident);
                    Newtonsoft.Json.Linq.JObject jobj = (Newtonsoft.Json.Linq.JObject)result;
                    newIncident = jobj.ToObject <Incident>();
                    added       = true;
                }

                if (image != null)
                {
                    //Give the image a unique name based on the incident id
                    var imageUrl = StorageHelper.UploadFileToBlobStorage(newIncident.Id, image, imageType, imageName);

                    //Add a message to the queue to process this image
                    await StorageHelper.AddMessageToQueue(newIncident.Id, imageName);
                }
            }
            catch (Exception e)
            {
            }
            return(added);
        }
コード例 #9
0
        public static IncidentAPIClient GetIncidentAPIClient()
        {
            var client = new IncidentAPIClient(new Uri(Settings.INCIDENT_API_URL));

            return(client);
        }