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);
            }
        }
        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);
              }
        }
        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);
            }
        }
        /// <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);
        }
        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 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);
              }
        }
示例#7
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();
        }
示例#8
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();
        }