int main ()
{
	People_t people[MAX_SIZE];
	Appointment_t appointment[MAX_SIZE];
	char fpeople[]="people.txt";
	char fpeoplereqs[]="peoplereqs.txt";
	char foutput[]="output.txt";
	int size;
	int app_size;
	int i;
	size = get_people(fpeople,people,MAX_SIZE);
	app_size = get_appointments(fpeoplereqs,appointment,MAX_SIZE);

	if(app_size == size)
	{	
		write_names(appointment,app_size,people,size);
		size = check_appointments(appointment,size);
		sort_appointments(appointment,size);
		write_appointments(foutput,appointment,size);
			
	}
	else printf("appointments size and people size are not the same please check it \n");
	
	return 0;
}
int main(void)
{
	char file1[STRING_SIZE]="People.txt";
	char file2[STRING_SIZE]="AppointmentReqs.txt";
	char file3[STRING_SIZE]="Appointments.txt";
	int size_appoint,
		size_peop,
		new_size;
	People_t people[SIZE_OF_ARRAY];
	Appointment_t appointments[SIZE_OF_ARRAY];
	
	size_peop=get_people(file1,people,MAX_SIZE);
	
	size_appoint=get_appointments(file2,appointments,MAX_SIZE);
	
	write_names(appointments,size_appoint,people,size_peop);
	
	new_size=check_appointments(appointments,size_appoint);
	
	sort_appointments(appointments,new_size);
	
	write_appointments(file3,appointments,new_size);
	
	return 0;
}
int
main(void)
{
	People_t people[5];
	Appointment_t appointments[5];
	int size_people,size_app,new_size_app;

	size_people=get_people("People.txt",people,5);
	size_app=get_appointments("AppointmentReqs.txt",appointments,5);

	write_names(appointments,size_app,people,size_people);

	new_size_app=check_appointments(appointments,size_app);

	sort_appointments(appointments,new_size_app);

	write_appointments("Appointments.txt",appointments,new_size_app);

	return 0;
}
Пример #4
0
    // Handler to process HTTP::GET requests.
    // Replies to the request with data.
    void odata_test_service::handle_get(http_request message)
    {
        try
        {
            bool is_async = false;
            auto prefer_header = message.headers().find(U("Prefer"));
            if (prefer_header != message.headers().end())
            {
                if (prefer_header->second.find(U("respond-async")) != ::odata::utility::string_t::npos)
                {
                    is_async = true;
                }
            }


            auto parsed_uri = m_uri_parser->parse_uri(message.relative_uri());

            odata_message_writer writer(m_model, m_service_root);
            odata_context_url_builder context_url_builder(m_model, m_service_root);
            odata_metadata_builder metadata_builder(m_model, m_service_root);
            ::odata::utility::string_t content;
            if (parsed_uri->is_service_document())
            {
                // Write service document
                content = writer.write_service_document(m_service_document);
            }
            else if (parsed_uri->is_metadata_document())
            {
                // Write metadata document
                content = writer.write_metadata_document();
            }
            else
            {
                if (parsed_uri->path()->size() >= 1)
                {
                    if (parsed_uri->path()->segment_at(0)->segment_type() == odata_path_segment_type::EntitySet)
                    {
                        auto entity_set_segment = parsed_uri->path()->segment_at(0)->as<odata_entity_set_segment>();
                        if (entity_set_segment->entity_set()->get_name() == U("People"))
                        {
                            if (parsed_uri->path()->size() == 1)
                            {
                                auto people = get_people();
                                auto context_url = context_url_builder.get_context_uri_for_collection_of_entities(entity_set_segment->entity_set());
                                people->set_context_url(context_url);
                   
                                if (is_async)
                                {
                                    std::unordered_map<string_t, string_t> headers;
                                    headers[U("OData-Version")] = U("4.0");
                                    headers[U("Content-Type")] = U("application/json;odata.metadata=full");

                                    content = writer.write_asynchronous_odata_value(people, 200, U("OK"), headers);
                                }
                                else
                                {
                                    content = writer.write_odata_value(people);
                                }
                            }
                            else if (parsed_uri->path()->segment_at(1)->segment_type() == odata_path_segment_type::Key)
                            {
                                auto key_segment = parsed_uri->path()->segment_at(1)->as<odata_key_segment>();
                                auto key = key_segment->keys()[0].second->as<::odata::utility::string_t>();

                                auto single_person = get_single_people(key);
                                single_person->set_is_top_level(true);
                                auto context_url = context_url_builder.get_context_uri_for_entity(entity_set_segment->entity_set());
                                single_person->set_context_url(context_url);
                                
                                auto id = metadata_builder.get_entity_id(single_person, entity_set_segment->entity_set());
                                single_person->set_id(id);

                                auto read_link = metadata_builder.get_read_link(single_person, entity_set_segment->entity_set());
                                single_person->set_read_link(read_link);

                                auto edit_link = metadata_builder.get_edit_link(single_person, entity_set_segment->entity_set());
                                single_person->set_edit_link(edit_link);



                                content = writer.write_odata_value(single_person);
                            }
                        }
                    }
                }
            }

            message.reply(status_codes::OK, content).then(std::bind(&handle_error, std::placeholders::_1));
        }
        catch (::odata::core::odata_exception &e)
        {
            message.reply(status_codes::BadRequest, U("Exception: ") + e.what()).then(std::bind(&handle_error, std::placeholders::_1));
        }
        ////Get odata objects from resorce and odata_path
        //

    }