Block Call Using CallKit - call

How i add Contact in Directory, i had add contact in CallDirectoryHander Class it's working fine, but when i want to add phone number dynamic from view Controller Page, then not block call .
I had try following code to Add contact in directory in view Controller
let cnctNumber = phoneNumber.text
let contentIs = CXCallDirectoryExtensionContext()
//self.addBlockingPhoneNumbers(to: contentIs )
numberContact = countryCode + self.phoneNumber.text!
let numberFromString = Int64(numberContact)
let phoneNumber : CXCallDirectoryPhoneNumber = CXCallDirectoryPhoneNumber(numberFromString!)
contentIs.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
contentIs.completeRequest()
reloadDirectory()//To reload Directory

Related

Get Active Directory Object Description Value

I'm trying to get the "Description" attribute of a user object in our domain but it's resulting to a blank value even if it has a value in Active Directory Users and Computers.
I'm using the following code. I can't remember where I got it though. I modified it to quickly call it in other functions.
function Getattrib(srchattrib, user, resattrib)
{
var srchou = "OU=TheUsers,DC=MainDom,DC=net";
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=ADsDSOObject");
var rs = conn.Execute("<LDAP://"+srchou+">;("+srchattrib+"="+user+");"+resattrib+"");
var i;
if (!rs.EOF)
{
rs.MoveFirst();
while(!rs.EOF)
{
return rs.Fields.Item(resattrib);
rs.MoveNext();
}
}
}
It works perfectly when I do this:
TexBox1.value = Getattrib('cn', 'James Sullivan', 'displayName');
But when I use:
TexBox1.value = Getattrib('cn', 'James Sullivan', 'description');
Nothing comes up. I made sure that James has a description in the object properties in Active Directory between Display Name and Office.

'Anonymous user' error after passing data with Angular to Rest

I am a beginner in Angular and Rest and I have a problem. I have a form in Django template and I want to pass data with Angular, receive it with Rest and process it. Angular knows to pass (post) the data by url to:
url(r'^api/nowyPacjent/$', CreateNewPatient.as_view(), name="api_tempPatient"),
The CreateNewPatient class looks like this:
class CreateNewPatient(generics.ListCreateAPIView):
model = TempPatient
queryset = TempPatient.objects.all()
serializer_class = CreateNewPatientSerializer
and the serializer looks like this:
class CreateNewPatientSerializer(serializers.Serializer):
name = serializers.CharField(max_length=30)
surname = serializers.CharField(max_length=70)
phone = serializers.CharField(max_length=15, required=False)
age = serializers.IntegerField(max_value=99, min_value=1, required=False)
company = serializers.PrimaryKeyRelatedField(many=False, queryset=Company.objects.all())
therapyStart = serializers.DateField(required=False)
def create(self, validated_data):
if 'therapyStart' in validated_data:
therapy_start = validated_data['therapyStart']
else:
therapy_start = datetime.date.today()
if 'age' in validated_data:
patient_age = validated_data['age']
else:
patient_age = 1;
if 'phone' in validated_data:
patient_phone = validated_data['phone']
else:
patient_phone = ''
newTempPatient = TempPatient(
name = validated_data['name'],
surname = validated_data['surname'],
company = validated_data['company'],
therapyStart = therapy_start,
age = patient_age,
phone = patient_phone
)
newTempPatient.save()
newPatient = Patient(
name=validated_data['name'],
surname=validated_data['surname'],
phone=patient_phone,
age=patient_age
)
newPatient.save()
user=None
request = self.context.get('request')
if request and hasattr(request,"user"):
user=request.user
newTherapyGroup = TherapyGroup.objects.create(
start = therapy_start,
patient = newPatient,
therapist = Therapist.objects.get(user = user),
company = validated_data['company']
)
newTherapyGroup.save()
return newTempPatient
Everything is fine - after submitting the template form the patient is created - until the code tries to get logged user from the request (just after the last if statement of the serializer). Then I receive the 'AnonymousUser' error and cannot create final model instance. I've tried to pass the data to the Django views and then use the Rest's serializer. However, the error occurred again. I've searched for the answer but nothing was helpful. Please, notice that I don't want to authenticate the logged user but to get data about him.
I think the problem is that Angular somehow loose information about CSRF token and log session and that is the reason of both errors (that is only my assumption).
Below is how Angular config looks like. NewPatientCtrl is responsible for mentioned form and model is one of the form element (and it works fine).
angular.module('pacjent', ['ngMessages', 'ui.bootstrap', 'datetime'])
.constant('companyListApi','http://localhost:8000/finanse/api/list/')
.constant('tempPatientApi','http://localhost:8000/pacjent/api/nowyPacjent/')
.factory('ModelUtils', ModelUtils)
.factory('newPatientFormApi',newPatientFormApi )
.factory('companyApi', companyApi)
.factory('mySharedService', mySharedService)
.controller('PacjentCtrl', PacjentCtrl)
.controller('NewPatientCtrl', NewPatientCtrl)
.controller('ModalInstanceCtrl', ModalInstanceCtrl)
.config(function($interpolateProvider, $httpProvider) {
$interpolateProvider.startSymbol('{[{');
$interpolateProvider.endSymbol('}]}');
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
})
The interesting thing is that this code works perfect on my colleague's system (Windows 7, Chrome) - the user data is gathered perfectly. However, I've tested it on three different systems (Windows 7 x64, Xubuntu 14.04, Ubuntu 14) and several browsers (Firefox, Chromium) on my PCs and the same error occurs.
Thank you a lot for any comments and advice. Sorry also for any non-professional statements.
it is because of this line:
user=request.user
# ...
therapist = Therapist.objects.get(user = user),
you are trying to get a therapist from your database with an Anynomous user in your ORM - it means a user who is not logged in.
you need is_authenticated() in your check:
if request and hasattr(request,"user") and request.user.is_authenticated():
user=request.user
newTherapyGroup = TherapyGroup.objects.create(
start = therapy_start,
patient = newPatient,
therapist = Therapist.objects.get(user=user),
company = validated_data['company']
)
newTherapyGroup.save()

AngularJS: Getting siblings of routed item

Ok so I'm using routing to drill down into a specific item based on it's ID (but also capturing it's category)
$http.get('http://something.co.uk/?category='+$routeParams.storyCat+'&id='+$routeParams.storyID)
This gives a URL of http://website.co.uk/index.html#/category/103 with the story details coming from the data on the server based on the ID of the item you clicked.
The following functions are then run on swipe (using angular-touch) which increase or decrease the ID by one, showing the next or previous story.
$scope.nextStory = function () {
var storyID = Number($routeParams.storyID);
var storyCat = $routeParams.storyCat;
var path = '/' + storyCat + '/' + (storyID + 1 );
$location.path(path);
};
$scope.previousStory = function () {
var storyID = Number($routeParams.storyID);
var storyCat = $routeParams.storyCat;
var path = '/' + storyCat + '/' + (storyID - 1 );
$location.path(path);
};
The problem with this is that it literally just goes up and down the ID's. I need it to only go through ID's which match the Category of the item you are on.
For example if you click into story ID 95, which is in a category called "Bags" and then you swipe left, I need it to not simply show story 96 which might be in a different category, but instead find the next story within "Bags" and show that one.
Can this even be done using AngularJS and routing or do I need a completely different approach?

How to get latest and adjacent records from the datastore?

I have movies datastore, each record there has its own id as key name like below:
12345
32453
12154
78873
34543
I would like to allow user to browse movies one by one. Firstly, the latest movie should be shown (database has field added with date and time). How to get that from the datastore?
Upd. I can do it like below:
movies = Movies.query()
movies.order(-Movies.added)
for movie in movies.fetch(1):
self.response.out.write(movie.key.id())
But I don't like it - in order to get key I request the whole record.
Secondly, if some other movie is shown (for ex., 12154), user should be able to go to previous movie (id 32453) and next movie (id 78873). Of course, if last movie is shown, there will not be next movie; and if first movie is shown, there will not be previous movie. So, the question is how to get key names of next and previous movies?
Upd. If current movie shown is 12154, then I should generate links like example.com/movie/32453 for previous movie and example.com/movie/78873 for the next one.
Upd. I've tried something like below:
next_movie = Movies.query(Movies.added < movie.added)
next_movie = next_movie.order(-Movies.added)
next_movie = next_movie.get()
if next_movie:
next_url = next_movie.key.id()
else:
next_url = ''
prev_movie = Movies.query(Movies.added > movie.added)
prev_movie = prev_movie.order(-Movies.added)
prev_movie = prev_movie.get()
if prev_movie:
prev_url = prev_movie.key.id()
else:
prev_url = ''
But it doesn't work well... next_url seems to be OK, but prev_url always the same. Here is my test database content (-Movies.added order):
id added
503035: 2012-08-05 19:49:51.259000
475537: 2012-08-05 19:49:51.238000
677539: 2012-08-05 19:49:51.218000
566355: 2012-08-05 19:49:51.197000
557850: 2012-08-05 19:49:51.176000
670146: 2012-08-05 19:49:51.155000
581030: 2012-08-05 19:49:51.135000
464561: 2012-08-05 19:49:51.114000
507817: 2012-08-05 19:49:51.092000
First you need a property on your movie entity that would represent "lateness", e.g. a date filed when movie was inserted in database.
Then you should use query with descending sort on this field.
To skip to next/previous you should use Query Cursors.
the following codes works well:
next_movie = Movies.query(Movies.added < movie.added)
next_movie = next_movie.order(-Movies.added)
next_movie = next_movie.get(keys_only = True)
if next_movie:
next_url = next_movie.id()
else:
next_url = ''
prev_movie = Movies.query(Movies.added > movie.added)
prev_movie = prev_movie.order(Movies.added)
prev_movie = prev_movie.get(keys_only = True)
if prev_movie:
prev_url = prev_movie.id()
else:
prev_url = ''
return next_url, prev_url

SqlCacheDependecy command notification not working

I been trying to get sqlcachedependecy working, but it doesn't appear to work
I got the proper settings in my web.config and also global.asa, however when I run this query and the changes are made to the database from either with in or outside the web site the cached objects are not updated please someone help? I know its not because this query is querying a view, because I tested this using straight SqlDependecy and the notification works fine.
public IQueryable<VictoryList> GetVictoryList()
{
string cacheKey = HttpContext.Current.User.Identity.Name + "victoryCacheKey";
IQueryable<VictoryList> cachednews = (IQueryable<VictoryList>)HttpContext.Current.Cache.Get(cacheKey);
if (cachednews == null)
{
var results = from v in _datacontext.ViewVictoryLists
orderby _datacontext.GetNewId()
select new VictoryList
{
MemberID = v.MemberID,
Username = v.Aspnetusername,
Location = v.Location,
DaimokuGoal = v.DaimokuGoal,
PreviewImageID = v.PreviewImageID,
TotalDaimoku = v.TotalDaimoku,
TotalDeterminations = v.TotalDeterminations,
DeterminationID = v.DeterminationID,
DeterminationName = v.DeterminationName
};
results = results.ToList().AsQueryable();
SqlCacheDependencyAdmin.EnableNotifications(_datacontext.Connection.ConnectionString);
SqlCacheDependency dependency =
new SqlCacheDependency(_datacontext.GetCommand(results) as SqlCommand);
HttpContext.Current.Cache.Insert(cacheKey, results, dependency);
return results;
}
return cachednews;
}
According to the stated Limitations for creating a query for notification, listed at msdn...
The statement must not reference a view.

Resources