AppDelegate.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. //
  2. // AppDelegate.m
  3. // AntsContract
  4. //
  5. // Created by Ray on 12/16/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "AppDelegate.h"
  9. #import "ACNetwork.h"
  10. //#import "AFHTTPSessionManager.h"
  11. @interface AppDelegate ()
  12. @end
  13. @implementation AppDelegate
  14. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  15. // Override point for customization after application launch.
  16. self.bEnable_Cache = true;
  17. [self leakingTest];
  18. return YES;
  19. }
  20. -(void)leakingTest
  21. {
  22. // return;
  23. return;
  24. {
  25. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Sign out"];
  26. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  27. NSDictionary* json = nil;
  28. NSString *zipfile = [[NSBundle mainBundle]pathForResource:@"GEIC - Home Improvement Contract 2017" ofType:@"pdf"];
  29. //// NSData* data = [NSData dataWithContentsOfFile: filePath];
  30. json = [ACNetwork save_document:zipfile];
  31. dispatch_async(dispatch_get_main_queue(), ^{
  32. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  33. // if([[logout_json valueForKey:@"result"] intValue]==2)
  34. // {
  35. // self.welcomeLabel.text=@"Not sign in";
  36. // // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
  37. // [bbitem setTitle:@"Sign in"];
  38. //
  39. // self.buttonHIC.enabled = false;
  40. // self.buttonSRL.enabled = false;
  41. // self.coverView.hidden = false;
  42. // }
  43. // else
  44. // {
  45. // [RAUtils message_alert:[logout_json valueForKey:@"err_msg"] title:@"Sign out" controller:self] ;
  46. // }
  47. if([[json valueForKey:@"result"] intValue]==2)
  48. {
  49. // [weakSelf.navigationController popToRootViewControllerAnimated:false];
  50. // if(weakSelf.OnSave)
  51. // weakSelf.OnSave(pdffile);
  52. }
  53. else
  54. {
  55. // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save document" controller:self] ;
  56. }
  57. });
  58. });
  59. }
  60. // {
  61. //
  62. //
  63. //
  64. //
  65. // // self.uploadProgress.progress = 0;
  66. //
  67. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  68. //
  69. //
  70. // {
  71. //
  72. // // UIAlertView * waitalert = [[UIAlertView alloc] initWithTitle:@"wait" message:@"uploading" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
  73. // // [waitalert show];
  74. ////
  75. //// // NSData *imageData = UIImagePNGRepresentation(self.imgview.image);
  76. ////
  77. //// AFHTTPRequestSerializer* serializer=[AFHTTPRequestSerializer serializer] ;
  78. ////
  79. ////
  80. ////
  81. //// NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  82. ////
  83. //// if(appDelegate.user!=nil)
  84. //// [params setValue:appDelegate.user forKey:@"user"];
  85. //// // if(appDelegate.contact_id!=nil)
  86. //// // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  87. //// if(appDelegate.password!=nil)
  88. //// [params setValue:appDelegate.password forKey:@"password"];
  89. ////
  90. ////
  91. //// [params setValue:[AESCrypt AES128Encrypt:appDelegate.user key:@"usai2010"] forKey:@"user"];
  92. //// [params setValue:[AESCrypt AES128Encrypt:appDelegate.password key:@"usai2010"] forKey:@"password"];
  93. ////
  94. //// [params setValue:@"deviceMain" forKey:@"_operate"];
  95. ////
  96. ////
  97. //// UIDevice * dev = [UIDevice currentDevice];
  98. //// NSUUID* uuid =dev.identifierForVendor;
  99. ////#if TARGET_IPHONE_SIMULATOR//模拟器
  100. //// [params setValue:@"simulator_uuid" forKey:@"deviceid"];
  101. ////#elif TARGET_OS_IPHONE//真机
  102. //// [params setValue:uuid.UUIDString forKey:@"deviceid"];
  103. ////#endif
  104. //
  105. //
  106. ////
  107. //// NSMutableString *body=[[NSMutableString alloc]init];
  108. // //参数的集合的所有key的集合
  109. //// NSArray *keys= [params allKeys];
  110. ////// DebugLog(@"================parms==================");
  111. //// //遍历keys
  112. //// for(int i=0;i<[keys count];i++)
  113. //// {
  114. //// //得到当前key
  115. //// NSString *key=[keys objectAtIndex:i];
  116. //// //如果key不是pic,说明value是字符类型,比如name:Boris
  117. //// if(![key isEqualToString:@"pic"])
  118. //// {
  119. //// // //添加分界线,换行
  120. //// // [body appendFormat:@"%@\r\n",MPboundary];
  121. //// //添加字段名称,换2行
  122. //// [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
  123. //// //添加字段的值
  124. //// [body appendFormat:@"%@\r\n",[params objectForKey:key]];
  125. ////// DebugLog(@"parameter: key=%@ value=%@",key,[params objectForKey:key]);
  126. //// }
  127. //// }
  128. //// DebugLog(@"================parms==================");
  129. //
  130. //
  131. //
  132. //// NSString *filePath = [[NSBundle mainBundle]pathForResource:@"GEIC - Home Improvement Contract 2017" ofType:@"pdf"];
  133. //// NSData* data = [NSData dataWithContentsOfFile: filePath];
  134. ////
  135. //// NSMutableURLRequest *request = [serializer multipartFormRequestWithMethod:@"POST" URLString:@"http://192.168.0.155/phpcms/admin.php" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  136. //// [formData appendPartWithFileData:data name:@"upfile" fileName:@"leak test" mimeType:@"application/zip"];
  137. //// } error:nil];
  138. //
  139. //
  140. // // NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:WEBSERVICE_URL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  141. // // [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test" mimeType:@"image/png"];
  142. // // } error:nil];
  143. // //
  144. // AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  145. //
  146. //
  147. //
  148. // //manager.responseSerializer.acceptableContentTypes = [self.operationManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
  149. //
  150. // //manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
  151. //
  152. // //
  153. // NSProgress *progress = nil;
  154. //
  155. // NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
  156. //
  157. // // [progress removeObserver:self forKeyPath:@"fractionCompleted"];
  158. //
  159. //
  160. //// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  161. //
  162. // if (error) {
  163. //
  164. //// NSString* err_msg = [error localizedDescription];
  165. //// DebugLog(@"%@",err_msg);// [self.view updateWithMessage:[NSString stringWithFormat:@"Error : %@!", error.debugDescription]];
  166. ////
  167. ////
  168. //// NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  169. ////
  170. //// DebugLog(@"data string: %@",str);
  171. //// [RAUtils message_alert:@"Can not connect to server please try again." title:@"Save document" controller:weakSelf] ;
  172. //
  173. // } else {
  174. //// DebugLog(@"response ");
  175. //
  176. //
  177. //
  178. //// NSData *data = [NSJSONSerialization dataWithJSONObject:(NSDictionary*)responseObject options:kNilOptions error:nil];
  179. ////
  180. //// // 再将NSData转为字符串
  181. //// NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  182. ////
  183. //// // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  184. ////
  185. //// DebugLog(@"data string: %@",jsonStr);
  186. ////
  187. //// NSDictionary* json = responseObject;
  188. ////
  189. ////
  190. ////
  191. ////
  192. //// if([[json valueForKey:@"result"] intValue]==2)
  193. //// {
  194. ////
  195. //// [weakSelf.navigationController popToRootViewControllerAnimated:false];
  196. //// //
  197. //// //
  198. //// if(weakSelf.OnSave)
  199. //// weakSelf.OnSave(pdffile);
  200. ////
  201. ////
  202. //// }
  203. //// else
  204. //// {
  205. //// [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save document" controller:self] ;
  206. //// }
  207. //
  208. //
  209. // }
  210. // // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  211. // }];
  212. //
  213. //
  214. //
  215. //
  216. // // [self.uploadProgress setProgressWithUploadProgressOfTask:uploadTask animated:true];
  217. // //
  218. //
  219. //
  220. //
  221. //
  222. //
  223. //
  224. // [uploadTask resume];
  225. //
  226. // }
  227. // }
  228. }
  229. - (void)applicationWillResignActive:(UIApplication *)application {
  230. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  231. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
  232. }
  233. - (void)applicationDidEnterBackground:(UIApplication *)application {
  234. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  235. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  236. }
  237. - (void)applicationWillEnterForeground:(UIApplication *)application {
  238. // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
  239. }
  240. - (void)applicationDidBecomeActive:(UIApplication *)application {
  241. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  242. }
  243. - (void)applicationWillTerminate:(UIApplication *)application {
  244. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  245. }
  246. -(void) Login:(NSString* )user pwd:(NSString*) pwd
  247. {
  248. self.user = user;
  249. self.password = pwd;
  250. self.bLogin = true;
  251. }
  252. -(void) Logout
  253. {
  254. // MainViewController * main_vc= (MainViewController*)self.main_vc;
  255. // [main_vc logoutOrder];
  256. //
  257. //
  258. // [main_vc hideMenu];
  259. // [main_vc switchToHome];
  260. self.user = nil;
  261. self.password=nil;
  262. self.bLogin = false;
  263. // self.user_icon=nil;
  264. // self.user_type = USER_ROLE_UNKNOWN;
  265. // self.bLogin = false;
  266. // self.contact_id=nil;
  267. // self.customerInfo = nil;
  268. // self.order_code = nil;
  269. //
  270. // [self.recent_model removeAllObjects];
  271. //
  272. // [self SetMode:nil];
  273. }
  274. @end