过期

来源:互联网 发布:英文手写字体知乎 编辑:程序博客网 时间:2024/04/27 20:31

-(BOOL)checkClientAvailable{

    

    BOOL success = YES;

    NSDictionary *deviceAuthoDic = [NSDictionarydictionaryWithContentsOfFile:[CataloggetAuthoFilePath]];

    if (deviceAuthoDic) {

        NSInteger clientRenewType = [[deviceAuthoDicobjectForKey:@"clientRenewType"]integerValue];

        if (clientRenewType == 1) {

            success = YES;

        }

        else{

            NSDate *nowDate = [NSDatedate];

            NSTimeInterval beginDate = [[deviceAuthoDicobjectForKey:@"beginDate"]doubleValue];

            if ( beginDate > [nowDate timeIntervalSince1970]){ //在可使用期内

                 NSTimeInterval endDate = [[deviceAuthoDicobjectForKey:@"endDate"] doubleValue];

                if ([nowDate timeIntervalSince1970] > endDate) {

                    NSTimeInterval endDateExtend = [[deviceAuthoDicobjectForKey:@"endDateExtend"] doubleValue];

                    NSTimeInterval time = [[NSDatedateWithTimeIntervalSince1970:endDateExtend] timeIntervalSinceDate:nowDate];

                    NSInteger day = time/86400;

                    NSString *message  = [NSStringstringWithFormat:@"证书还有%d天过期",day];

                    UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"提示"message:message delegate:selfcancelButtonTitle:@"确定"otherButtonTitles: nil];

                    [alertView show];

                    [alertView release];

                    if ([nowDate timeIntervalSince1970] > endDateExtend) {

                        UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"方正慧云单机版已过期" message:@"请更新新版本"delegate:self cancelButtonTitle:@"确定"otherButtonTitles: nil];

                        [alertView show];

                        [alertView release];

                        success = NO;

                    }

                    

                }

                

            }

            else{

                NSString *useTime = [NSStringstringWithFormat:@"客户端在%@之后才可使用",[NSDatedateWithTimeIntervalSince1970:beginDate]];

                UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"提示"message:useTime delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil,nil];

                [alert show];

                [alert release];

            }

   

           

           

        }


    }

      return success;

}


//是否过期

- (BOOL)isOutOfDate

{

    return NO;

    NSDate *now = [NSDatedate];

    NSDateComponents *component = [[NSDateComponentsalloc] init];

    [component setDay:1];

    [component setMonth:5];

    [component setYear:2013];

    NSCalendar *gregorian = [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];

    NSDate *theDay = [gregorian dateFromComponents:component];

    

    if ([now compare:theDay] ==NSOrderedAscending) {

        return NO;

    }

    

    [component release];

    [gregorian release];

    

    return YES;


}