Marino Faggiana 8 жил өмнө
parent
commit
bfa65eacd3

+ 3 - 4
iOSClient/AppDelegate.m

@@ -1073,16 +1073,15 @@
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector
 {
 {
     // Verify num error if selectorUploadCameraAllPhoto
     // Verify num error if selectorUploadCameraAllPhoto
-    
     if([selector isEqualToString:selectorUploadCameraAllPhoto]) {
     if([selector isEqualToString:selectorUploadCameraAllPhoto]) {
     
     
-        NSUInteger count = [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", app.activeAccount, selectorUploadCameraAllPhoto,taskIdentifierError, taskIdentifierError]];
+        NSUInteger count = [TableMetadata MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (sessionSelector == %@) AND ((sessionTaskIdentifier == %i) OR (sessionTaskIdentifierPlist == %i))", app.activeAccount, selectorUploadCameraAllPhoto,taskIdentifierError, taskIdentifierError]];
         
         
         if (count >= 10) {
         if (count >= 10) {
             [app messageNotification:@"Troppi errori, invio sospeso" description:@"" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
             [app messageNotification:@"Troppi errori, invio sospeso" description:@"" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
+            
+            return;
         }
         }
-        
-        return;
     }
     }
     
     
     // Add Network queue
     // Add Network queue

+ 2 - 1
iOSClient/FileSystem/CCCoreData.h

@@ -181,7 +181,8 @@
 + (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context;
 + (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context;
 + (NSArray *)getTableAutomaticUploadForAccount:(NSString *)activeAccount selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context;
 + (NSArray *)getTableAutomaticUploadForAccount:(NSString *)activeAccount selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context;
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)activeAccount;
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)activeAccount;
-+ (void)deleteTableAutomaticUploadFromAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context;
++ (void)setTableAutomaticUploadIfExecutingForAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context;
++ (void)deleteTableAutomaticUploadForAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context;
 
 
 // ===== GPS =====
 // ===== GPS =====
 
 

+ 23 - 9
iOSClient/FileSystem/CCCoreData.m

@@ -1470,7 +1470,7 @@
 }
 }
 
 
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Upload =====
+#pragma mark ===== Automatic Upload =====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 
 
 + (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context
 + (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context
@@ -1491,12 +1491,12 @@
         record.assetLocalItentifier = metadataNet.assetLocalItentifier;
         record.assetLocalItentifier = metadataNet.assetLocalItentifier;
         record.date = [NSDate date];
         record.date = [NSDate date];
         record.fileName = metadataNet.fileName;
         record.fileName = metadataNet.fileName;
+        record.isExecuting = [NSNumber numberWithBool:NO];
         record.selector = metadataNet.selector;
         record.selector = metadataNet.selector;
         record.selectorPost = metadataNet.selectorPost;
         record.selectorPost = metadataNet.selectorPost;
         record.serverUrl = metadataNet.serverUrl;
         record.serverUrl = metadataNet.serverUrl;
         record.session = metadataNet.session;
         record.session = metadataNet.session;
         record.priority = [NSNumber numberWithLong:metadataNet.priority];
         record.priority = [NSNumber numberWithLong:metadataNet.priority];
-        record.startUpload = [NSNumber numberWithBool:NO];
         
         
         [context MR_saveToPersistentStoreAndWait];
         [context MR_saveToPersistentStoreAndWait];
     }
     }
@@ -1513,7 +1513,7 @@
     if (context == nil)
     if (context == nil)
         context = [NSManagedObjectContext MR_context];
         context = [NSManagedObjectContext MR_context];
     
     
-    NSArray *records = [TableAutomaticUpload MR_findAllWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@) AND (startUpload == 0)", activeAccount, selector]];
+    NSArray *records = [TableAutomaticUpload MR_findAllWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (selector == %@) AND (isExecuting == 0)", activeAccount, selector]];
     
     
     for (TableAutomaticUpload *record in records) {
     for (TableAutomaticUpload *record in records) {
         
         
@@ -1540,17 +1540,33 @@
 
 
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)activeAccount
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)activeAccount
 {
 {
-    NSUInteger count = [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (startUpload == 0)", activeAccount]];
+    NSUInteger count = [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (isExecuting == 0)", activeAccount]];
     
     
     return count;
     return count;
 }
 }
 
 
-+ (void)deleteTableAutomaticUploadFromAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context
++ (void)setTableAutomaticUploadIfExecutingForAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context
 {
 {
     if (context == nil)
     if (context == nil)
         context = [NSManagedObjectContext MR_context];
         context = [NSManagedObjectContext MR_context];
     
     
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@) AND (fileName == %@) AND (serverUrl == %@)", activeAccount, fileName, serverUrl];
+    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@) AND (fileName == %@) AND (serverUrl == %@) AND (selector == %@)", activeAccount, fileName, serverUrl, selector];
+    TableAutomaticUpload *record = [TableAutomaticUpload MR_findFirstWithPredicate:predicate inContext:context];
+    
+    if (record) {
+        
+        record.isExecuting = [NSNumber numberWithBool:YES];
+        
+        [context MR_saveToPersistentStoreAndWait];
+    }
+}
+
++ (void)deleteTableAutomaticUploadForAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context
+{
+    if (context == nil)
+        context = [NSManagedObjectContext MR_context];
+    
+    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@) AND (fileName == %@) AND (serverUrl == %@) AND (selector == %@)", activeAccount, fileName, serverUrl, selector];
     [TableAutomaticUpload MR_deleteAllMatchingPredicate:predicate inContext:context];
     [TableAutomaticUpload MR_deleteAllMatchingPredicate:predicate inContext:context];
     
     
     [context MR_saveToPersistentStoreAndWait];
     [context MR_saveToPersistentStoreAndWait];
@@ -1564,9 +1580,7 @@
 {
 {
     NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
     NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
         
         
-    TableGPS *record;
-        
-    record = [TableGPS MR_findFirstWithPredicate:[NSPredicate predicateWithFormat:@"(latitude == %@) AND (longitude == %@)", latitude, longitude] inContext:context];
+    TableGPS *record = [TableGPS MR_findFirstWithPredicate:[NSPredicate predicateWithFormat:@"(latitude == %@) AND (longitude == %@)", latitude, longitude] inContext:context];
         
         
     if (!record) {
     if (!record) {
         record = [TableGPS MR_createEntityInContext:context];
         record = [TableGPS MR_createEntityInContext:context];

+ 2 - 2
iOSClient/FileSystem/TableAutomaticUpload+CoreDataProperties.h

@@ -19,12 +19,12 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nullable, nonatomic, copy) NSString *assetLocalItentifier;
 @property (nullable, nonatomic, copy) NSString *assetLocalItentifier;
 @property (nullable, nonatomic, copy) NSDate *date;
 @property (nullable, nonatomic, copy) NSDate *date;
 @property (nullable, nonatomic, copy) NSString *fileName;
 @property (nullable, nonatomic, copy) NSString *fileName;
+@property (nullable, nonatomic, copy) NSNumber *isExecuting;
+@property (nullable, nonatomic, copy) NSNumber *priority;
 @property (nullable, nonatomic, copy) NSString *selector;
 @property (nullable, nonatomic, copy) NSString *selector;
 @property (nullable, nonatomic, copy) NSString *selectorPost;
 @property (nullable, nonatomic, copy) NSString *selectorPost;
 @property (nullable, nonatomic, copy) NSString *serverUrl;
 @property (nullable, nonatomic, copy) NSString *serverUrl;
 @property (nullable, nonatomic, copy) NSString *session;
 @property (nullable, nonatomic, copy) NSString *session;
-@property (nullable, nonatomic, copy) NSNumber *startUpload;
-@property (nullable, nonatomic, copy) NSNumber *priority;
 
 
 @end
 @end
 
 

+ 2 - 2
iOSClient/FileSystem/TableAutomaticUpload+CoreDataProperties.m

@@ -18,11 +18,11 @@
 @dynamic assetLocalItentifier;
 @dynamic assetLocalItentifier;
 @dynamic date;
 @dynamic date;
 @dynamic fileName;
 @dynamic fileName;
+@dynamic isExecuting;
+@dynamic priority;
 @dynamic selector;
 @dynamic selector;
 @dynamic selectorPost;
 @dynamic selectorPost;
 @dynamic serverUrl;
 @dynamic serverUrl;
 @dynamic session;
 @dynamic session;
-@dynamic startUpload;
-@dynamic priority;
 
 
 @end
 @end

+ 2 - 2
iOSClient/Main/CCMain.m

@@ -1397,7 +1397,7 @@
     // Automatic upload
     // Automatic upload
     if([selector isEqualToString:selectorUploadCameraSnapshot] || [selector isEqualToString:selectorUploadCameraAllPhoto]) {
     if([selector isEqualToString:selectorUploadCameraSnapshot] || [selector isEqualToString:selectorUploadCameraAllPhoto]) {
         
         
-        [CCCoreData deleteTableAutomaticUploadFromAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
+        [CCCoreData deleteTableAutomaticUploadForAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
         [app loadTableAutomaticUploadForSelector:selector];
         [app loadTableAutomaticUploadForSelector:selector];
     }
     }
     
     
@@ -1411,7 +1411,7 @@
     // Automatic upload
     // Automatic upload
     if([selector isEqualToString:selectorUploadCameraSnapshot] || [selector isEqualToString:selectorUploadCameraAllPhoto]) {
     if([selector isEqualToString:selectorUploadCameraSnapshot] || [selector isEqualToString:selectorUploadCameraAllPhoto]) {
         
         
-        [CCCoreData deleteTableAutomaticUploadFromAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
+        [CCCoreData deleteTableAutomaticUploadForAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
         [app loadTableAutomaticUploadForSelector:selector];
         [app loadTableAutomaticUploadForSelector:selector];
     }
     }
     
     

+ 4 - 0
iOSClient/Networking/CCNetworking.m

@@ -1358,6 +1358,10 @@
         NSLog(@"[LOG] Upload file %@ - %@ TaskIdentifier %lu", fileName,fileNamePrint, (unsigned long)uploadTask.taskIdentifier);
         NSLog(@"[LOG] Upload file %@ - %@ TaskIdentifier %lu", fileName,fileNamePrint, (unsigned long)uploadTask.taskIdentifier);
     }
     }
 
 
+    // Automatic upload set YES isExecuting
+    if([selector isEqualToString:selectorUploadCameraSnapshot] || [selector isEqualToString:selectorUploadCameraAllPhoto])
+        [CCCoreData setTableAutomaticUploadIfExecutingForAccount:_activeAccount fileName:fileNamePrint serverUrl:serverUrl selector:selector context:_context];
+    
     dispatch_async(dispatch_get_main_queue(), ^{
     dispatch_async(dispatch_get_main_queue(), ^{
         
         
         // refresh main
         // refresh main

+ 1 - 1
iOSClient/cryptocloud.xcdatamodeld/cryptocloud 5.xcdatamodel/contents

@@ -32,12 +32,12 @@
         <attribute name="assetLocalItentifier" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="assetLocalItentifier" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="fileName" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="fileName" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="isExecuting" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="priority" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="priority" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
         <attribute name="selector" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="selector" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="selectorPost" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="selectorPost" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="serverUrl" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="serverUrl" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="session" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="session" optional="YES" attributeType="String" syncable="YES"/>
-        <attribute name="startUpload" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="NO" syncable="YES"/>
     </entity>
     </entity>
     <entity name="TableCertificates" representedClassName="TableCertificates" syncable="YES">
     <entity name="TableCertificates" representedClassName="TableCertificates" syncable="YES">
         <attribute name="certificateLocation" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="certificateLocation" optional="YES" attributeType="String" syncable="YES"/>