/// <summary>
        /// Add custom note to the specified route
        /// </summary>
        public void AddCustomNoteToRoute()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            RunSingleDriverRoundTrip();
            OptimizationsToRemove = new List <string>()
            {
                SDRT_optimization_problem_id
            };

            var noteParameters = new NoteParameters()
            {
                RouteId   = SDRT_route.RouteID,
                AddressId = SDRT_route.Addresses[1].RouteDestinationId != null
                    ? (int)SDRT_route.Addresses[1].RouteDestinationId
                    : 0,
                Format    = "json",
                Latitude  = SDRT_route.Addresses[1].Latitude,
                Longitude = SDRT_route.Addresses[1].Longitude
            };

            var customNotes = new Dictionary <string, string>()
            {
                { "custom_note_type[11]", "slippery" },
                { "custom_note_type[10]", "Backdoor" },
                { "strUpdateType", "dropoff" },
                { "strNoteContents", "test1111" }
            };

            var response = route4Me.addCustomNoteToRoute(noteParameters, customNotes, out string errorString);

            PrintExampleAddressNote(response, errorString);

            RemoveTestOptimizations();
        }
        public void GetAddressNotes(string routeId, int routeDestinationId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            NoteParameters noteParameters = new NoteParameters()
            {
                RouteId   = routeId,
                AddressId = routeDestinationId
            };

            // Run the query
            string errorString;

            AddressNote[] notes = route4Me.GetAddressNotes(noteParameters, out errorString);

            Console.WriteLine("");

            if (notes != null)
            {
                Console.WriteLine("GetAddressNotes executed successfully, {0} notes returned", notes.Length);
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetAddressNotes error: {0}", errorString);
                Console.WriteLine("");
            }
        }
        public void AddAddressNote(string routeId, int addressId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            NoteParameters noteParameters = new NoteParameters()
            {
                RouteId      = routeId,
                AddressId    = addressId,
                Latitude     = 33.132675170898,
                Longitude    = -83.244743347168,
                DeviceType   = DeviceType.Web.Description(),
                ActivityType = StatusUpdateType.DropOff.Description()
            };

            // Run the query
            string      errorString;
            string      contents = "Test Note Contents " + DateTime.Now.ToString();
            AddressNote note     = route4Me.AddAddressNote(noteParameters, contents, out errorString);

            Console.WriteLine("");

            if (note != null)
            {
                Console.WriteLine("AddAddressNote executed successfully");

                Console.WriteLine("Note ID: {0}", note.NoteId);
            }
            else
            {
                Console.WriteLine("AddAddressNote error: {0}", errorString);
            }
        }
Example #4
0
        public async Task <PagingResponse <NoteModel> > GetNotes(NoteParameters noteParameters)
        {
            var queryStringParam = new Dictionary <string, string>
            {
                ["pageNumber"] = noteParameters.PageNumber.ToString(),
                ["searchTerm"] = noteParameters.SearchTerm == null ? "" : noteParameters.SearchTerm,
                ["orderBy"]    = noteParameters.OrderBy
            };

            var response = await _client.GetAsync(QueryHelpers.AddQueryString("/api/notes", queryStringParam));

            var content = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw new ApplicationException(content);
            }

            var pagingResponse = new PagingResponse <NoteModel>
            {
                Items = JsonSerializer.Deserialize <List <NoteModel> >(content, new JsonSerializerOptions {
                    PropertyNameCaseInsensitive = true
                }),
                MetaData = JsonSerializer.Deserialize <MetaData>(response.Headers.GetValues("X-Pagination").First(), new JsonSerializerOptions {
                    PropertyNameCaseInsensitive = true
                })
            };

            return(pagingResponse);
        }
Example #5
0
        public async Task <IActionResult> Get([FromQuery] NoteParameters productParameters)
        {
            var notes = await _repository.GetAllAsync(productParameters);

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(notes.MetaData));

            return(Ok(notes));
        }
Example #6
0
        public async Task <PagedList <NoteModel> > GetAllAsync(NoteParameters parameters)
        {
            var notes = await _context.Notes
                        .Search(parameters.SearchTerm)
                        .Sort(parameters.OrderBy)
                        .ToListAsync();

            return(PagedList <NoteModel>
                   .ToPagedList(notes, parameters.PageNumber, parameters.PageSize));
        }
        public void AddAddressNoteWithFile()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            RunOptimizationSingleDriverRoute10Stops();
            OptimizationsToRemove = new List <string>()
            {
                SD10Stops_optimization_problem_id
            };

            var noteParameters = new NoteParameters()
            {
                RouteId      = SD10Stops_route_id,
                AddressId    = (int)SD10Stops_route.Addresses[1].RouteDestinationId,
                Latitude     = 33.132675170898,
                Longitude    = -83.244743347168,
                DeviceType   = DeviceType.Web.Description(),
                ActivityType = StatusUpdateType.DropOff.Description()
            };

            string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames();

            foreach (string nm in names)
            {
                Console.WriteLine(nm);
            }

            string tempFilePath = null;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Route4MeSDKTest.Resources.test.png"))
            {
                var tempFiles = new TempFileCollection();
                {
                    tempFilePath = tempFiles.AddExtension("png");
                    Console.WriteLine(tempFilePath);
                    using (Stream fileStream = File.OpenWrite(tempFilePath))
                    {
                        stream.CopyTo(fileStream);
                    }
                }
            }

            // Run the query
            string      contents = "Test Note Contents with Attachment " + DateTime.Now.ToString();
            AddressNote note     = route4Me.AddAddressNote(
                noteParameters,
                contents,
                tempFilePath,
                out string errorString);

            PrintExampleAddressNote(note, errorString);

            RemoveTestOptimizations();
        }
        public void AddAddressNoteWithFile(string routeId, int addressId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            NoteParameters noteParameters = new NoteParameters()
            {
                RouteId      = routeId,
                AddressId    = addressId,
                Latitude     = 33.132675170898,
                Longitude    = -83.244743347168,
                DeviceType   = DeviceType.Web.Description(),
                ActivityType = StatusUpdateType.DropOff.Description()
            };

            string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames();

            foreach (string nm in names)
            {
                Console.WriteLine(nm);
            }

            string tempFilePath = null;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Route4MeSDKTest.Resources.test.png"))
            {
                var tempFiles = new TempFileCollection();
                {
                    tempFilePath = tempFiles.AddExtension("png");
                    System.Console.WriteLine(tempFilePath);
                    using (Stream fileStream = File.OpenWrite(tempFilePath))
                    {
                        stream.CopyTo(fileStream);
                    }
                }
            }

            // Run the query
            string      errorString;
            string      contents = "Test Note Contents with Attachment " + DateTime.Now.ToString();
            AddressNote note     = route4Me.AddAddressNote(noteParameters, contents, tempFilePath, out errorString);

            Console.WriteLine("");

            if (note != null)
            {
                Console.WriteLine("AddAddressNoteWithFile executed successfully");

                Console.WriteLine("Note ID: {0}", note.NoteId);
            }
            else
            {
                Console.WriteLine("AddAddressNoteWithFile error: {0}", errorString);
            }
        }
Example #9
0
        public async Task <IActionResult> GetAllNotes([FromQuery] NoteParameters noteParameters)
        {
            var notes = await _noteService.GetNotesAsync(HttpContext.User.Identity?.Name,
                                                         noteParameters, ModelState);

            if (ModelState.ErrorCount > 0)
            {
                return(BadRequest(ModelState));
            }

            return(Ok(notes));
        }
Example #10
0
        public async Task <IEnumerable <NoteDto> > GetNotesAsync(string userId, NoteParameters noteParameters, ModelStateDictionary modelState)
        {
            var notes = await _repositoryManager.Note.GetAllNotesAsync(userId, noteParameters, false);

            if (notes == null)
            {
                _logger.Log(LogLevel.Error, "No notes!");
                modelState.TryAddModelError("empty-notes", "User hadn't been yet created any note");
            }

            return(_mapper.Map <IEnumerable <NoteDto> >(notes));
        }
        /// <summary>
        /// Get activities with the event Note Inserted
        /// </summary>
        public void SearchNoteInserted()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            RunOptimizationSingleDriverRoute10Stops();

            string routeId = SD10Stops_route_id;

            OptimizationsToRemove = new List <string>()
            {
                SD10Stops_optimization_problem_id
            };

            int addressId = (int)SD10Stops_route.Addresses[2].RouteDestinationId;

            var noteParams = new NoteParameters()
            {
                AddressId       = addressId,
                RouteId         = routeId,
                Latitude        = SD10Stops_route.Addresses[2].Latitude,
                Longitude       = SD10Stops_route.Addresses[2].Longitude,
                DeviceType      = "web",
                StrNoteContents = "Note example for Destination",
                ActivityType    = "dropoff"
            };

            var addrssNote = route4Me.AddAddressNote(noteParams, out string errorString0);

            if (addrssNote == null || addrssNote.GetType() != typeof(AddressNote))
            {
                Console.WriteLine(
                    "Cannot add a note to the address." +
                    Environment.NewLine +
                    errorString0);

                RemoveTestOptimizations();
                return;
            }

            var activityParameters = new ActivityParameters
            {
                ActivityType = "note-insert",
                RouteId      = routeId
            };

            // Run the query
            Activity[] activities = route4Me.GetActivities(activityParameters, out string errorString);

            PrintExampleActivities(activities, errorString);
        }
Example #12
0
        public void GetAddressNotes(string routeId = null, int?routeDestinationId = null)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            bool isInnerExample = routeId == null ? true : false;

            if (isInnerExample)
            {
                CreateAddressNote(out routeId, out routeDestinationId);
            }

            var noteParameters = new NoteParameters()
            {
                RouteId   = routeId,
                AddressId = (int)routeDestinationId
            };

            // Run the query
            AddressNote[] notes = route4Me.GetAddressNotes(noteParameters, out string errorString);

            Console.WriteLine("");

            if (notes != null)
            {
                Console.WriteLine(
                    "GetAddressNotes executed successfully, {0} notes returned",
                    notes.Length);

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetAddressNotes error: {0}", errorString);
                Console.WriteLine("");
            }

            if (isInnerExample)
            {
                RemoveTestOptimizations();
            }
        }
Example #13
0
        public void AddAddressNote()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            RunSingleDriverRoundTrip();

            OptimizationsToRemove = new List <string>()
            {
                SDRT_optimization_problem_id
            };

            string routeIdToMoveTo = SDRT_route_id;

            int addressId = (int)SDRT_route.Addresses[1].RouteDestinationId;

            double lat = SDRT_route.Addresses.Length > 1
                ? SDRT_route.Addresses[1].Latitude
                : 33.132675170898;
            double lng = SDRT_route.Addresses.Length > 1
                ? SDRT_route.Addresses[1].Longitude
                : -83.244743347168;

            var noteParameters = new NoteParameters()
            {
                RouteId      = routeIdToMoveTo,
                AddressId    = addressId,
                Latitude     = lat,
                Longitude    = lng,
                DeviceType   = DeviceType.Web.Description(),
                ActivityType = StatusUpdateType.DropOff.Description()
            };

            // Run the query
            string contents = "Test Note Contents " + DateTime.Now.ToString();
            var    note     = route4Me.AddAddressNote(noteParameters, contents, out string errorString);

            PrintExampleAddressNote(note, errorString);

            RemoveTestOptimizations();
        }
Example #14
0
        /// <summary>
        /// Add complex note to the specified route address.
        /// </summary>
        public void AddComplexAddressNote()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            RunSingleDriverRoundTrip();
            OptimizationsToRemove = new List <string>()
            {
                SDRT_optimization_problem_id
            };

            string routeIdToMoveTo = SDRT_route_id;

            int addressId = (SDRT_route != null &&
                             SDRT_route.Addresses.Length > 1 &&
                             SDRT_route.Addresses[1].RouteDestinationId != null)
                ? SDRT_route.Addresses[1].RouteDestinationId.Value
                : 0;

            double lat = SDRT_route.Addresses.Length > 1 ? SDRT_route.Addresses[1].Latitude : 33.132675170898;
            double lng = SDRT_route.Addresses.Length > 1 ? SDRT_route.Addresses[1].Longitude : -83.244743347168;

            var customNotesResponse = route4Me.getAllCustomNoteTypes(out string errorString0);

            Dictionary <string, string> customNotes = null;

            if (customNotesResponse != null && customNotesResponse.GetType() == typeof(CustomNoteType[]))
            {
                var allCustomNotes = (CustomNoteType[])customNotesResponse;

                if (allCustomNotes.Length > 0)
                {
                    customNotes = new Dictionary <string, string>()
                    {
                        {
                            "custom_note_type[" + allCustomNotes[0].NoteCustomTypeID + "]",
                            allCustomNotes[0].NoteCustomTypeValues[0]
                        }
                    };
                }
            }

            var noteParameters = new NoteParameters()
            {
                RouteId         = routeIdToMoveTo,
                AddressId       = addressId,
                Latitude        = lat,
                Longitude       = lng,
                DeviceType      = DeviceType.Web.Description(),
                ActivityType    = StatusUpdateType.DropOff.Description(),
                StrNoteContents = "Test Note Contents " + DateTime.Now.ToString()
            };

            if (customNotes != null)
            {
                noteParameters.CustomNoteTypes = customNotes;
            }

            string tempFilePath = null;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Route4MeSDKTest.Resources.test.png"))
            {
                var tempFiles = new TempFileCollection();
                {
                    tempFilePath = tempFiles.AddExtension("png");

                    Console.WriteLine(tempFilePath);

                    using (Stream fileStream = File.OpenWrite(tempFilePath))
                    {
                        stream.CopyTo(fileStream);
                    }
                }
            }

            noteParameters.StrFileName = tempFilePath;

            var note = route4Me.AddAddressNote(noteParameters, out string errorString);

            PrintExampleAddressNote(note, errorString);

            RemoveTestOptimizations();
        }
Example #15
0
 public async Task <IEnumerable <Note> > GetAllNotesAsync(string userId, NoteParameters noteParameters, bool trackChanges) =>
 await FindByCondition(x => x.UserId == userId, trackChanges)
 .Skip((noteParameters.PageNumber - 1) * noteParameters.PageSize)
 .Take(noteParameters.PageSize)
 .ToListAsync();