Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. NSMutableArray * vcardIDList = [[[NSMutableArray alloc] initWithCapacity:0] autorelease];
  2. for (int i = 0; i < [[CardManager sharedInstance] businessCardCount]; i++) {
  3.  
  4. BusinessCard * myBusinessCard = [[CardManager sharedInstance] getBusinessCardAtIndex:i];
  5. if (myBusinessCard.isSelected == YES) {
  6. NSMutableDictionary *userID = [[[NSMutableDictionary alloc] initWithCapacity:0] autorelease];
  7. DataObject * firstObject = [[[DataObject alloc] init] autorelease];
  8. firstObject.data = [NSNumber numberWithInt:[myBusinessCard cardId]];
  9. firstObject.type = EDataTypeNumber;
  10. [userID setObject:firstObject forKey:@"vcardID"];
  11. [commMngr deleteVcardList:@"3.0.0" userID:[[NSUserDefaults standardUserDefaults] objectForKey:@"acceptUserID"] vcardIDList:vcardIDList SecretKey:[[NSUserDefaults standardUserDefaults] objectForKey:@"SecurityKey"]];
  12. //Using this method call object
  13.  
  14. -(void)deleteVcardList:(NSString *)versionID userID:(NSString *)userID vcardIDList:(NSArray *)vcardIDList SecretKey:(NSString *)SecretKey{
  15. if(versionID || vcardIDList ||SecretKey ||userID){
  16. WYRequest * pRequest = [[[WYRequest alloc] init] autorelease];
  17. pRequest.type = ERequestTypeDeleteVcardList;
  18. NSMutableDictionary *dataDic = [pRequest passInData];
  19.  
  20.  
  21.  
  22. if (versionID) {
  23. DataObject * verData = [[[DataObject alloc] init] autorelease];
  24. verData.data = versionID;
  25. verData.type = EDataTypeString;
  26. [dataDic setObject:verData forKey:@"versionID"];
  27. }
  28.  
  29. if (userID) {
  30. DataObject * useridData = [[[DataObject alloc] init] autorelease];
  31. useridData.data = userID;
  32. useridData.type = EDataTypeNumber;
  33. [dataDic setObject:useridData forKey:@"userID"];
  34. }
  35.  
  36. if (vcardIDList) {
  37. DataObject * vcardListData = [[[DataObject alloc] init] autorelease];
  38. vcardListData.data = vcardIDList;
  39. vcardListData.type = EDataTypeArrayJSONObj;
  40. [dataDic setObject:vcardListData forKey:@"vcardIDList"];
  41. }
  42.  
  43. if (SecretKey) {
  44. DataObject * SecretKeyData = [[[DataObject alloc] init] autorelease];
  45. SecretKeyData.data = SecretKey;
  46. SecretKeyData.type = EDataTypeString;
  47. [dataDic setObject:SecretKeyData forKey:@"SecretKey"];
  48. }
  49.  
  50. [self addRequest:pRequest];
  51. } else {
  52. //need log
  53. NSLog(@"%@", @"Invalid deleteVcardList");
  54. }
  55.  
  56. Case of success here ::: parameters of the request to the server to remove the contact print out this
  57. {"versionID":"3.0.0","userID":18,"SecretKey":"C9998D538ADF240CCE71CBB52552A107","vcardIDList":[{"vcardID":350},{"vcardID":215},{"vcardID":212}]}
  58.  
  59. I also use this mode do I click statistics I was doing
  60.  
  61.  
  62. { NSDate * now = [NSDate date];
  63. NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
  64. [formatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  65. NSString* receiveTime = [formatter stringFromDate:now];
  66. Action *action=[[Action alloc] init];
  67. action.userType = [NSNumber numberWithInt:0];
  68. action.functionNo = @"A2012080002";
  69. action.actionData = receiveTime;
  70. action.actionName = @"VIPCard"
  71.  
  72. NSMutableDictionary *employes = [NSMutableDictionary dictionary];
  73. [employes setObject:action.userType forKey:@"userType"];
  74. [employes setObject:action.functionNo forKey:@"functionNo"];
  75. [employes setObject:action.actionData forKey:@"actionData"];
  76. [employes setObject:action.actionName forKey:@"actionName"];
  77. NSMutableDictionary *employes1 = [NSMutableDictionary dictionary];
  78. DataObject * firstObject = [[[DataObject alloc] init] autorelease];
  79. firstObject.data = [NSNumber numberWithInt:[employes count]];
  80. firstObject.type = EDataTypeNumber;
  81. [employes1 setObject:firstObject forKey:@"logList"] ;
  82.  
  83.  
  84. [[FunctionArray shareFunctionArray].addCard addObject:employes1];
  85. [action release];
  86.  
  87. - (void)applicationWillEnterForeground:(UIApplication *)application {
  88.  
  89. [commMngr functionLog:@"3.0.0" userID:[[NSUserDefaults standardUserDefaults] objectForKey:@"acceptUserID"]SecretKey:[[NSUserDefaults standardUserDefaults] objectForKey:@"SecurityKey"]logList:temp.addCard];
  90.  
  91. //temp Is a global variable
  92. //addCard Is a variable array
  93. @interface WAVEYNO2AppDelegate : NSObject <UIApplicationDelegate> {FunctionArray *temp;
  94.  
  95. }
  96. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  97. temp=[FunctionArray shareFunctionArray];
  98.  
  99.  
  100.  
  101. //Call this method
  102.  
  103. -(void)functionLog:(NSString *)versionID userID:(NSString *)userID SecretKey:(NSString *)SecretKey logList:(NSArray *)logList{
  104. if(versionID || logList ||SecretKey ||userID){
  105. WYRequest * pRequest = [[[WYRequest alloc] init] autorelease];
  106. pRequest.type = ERequestTypeSubmitFunctionLog;
  107. NSMutableDictionary *dataDic = [pRequest passInData];
  108.  
  109.  
  110.  
  111. if (versionID) {
  112. DataObject * verData = [[[DataObject alloc] init] autorelease];
  113. verData.data = versionID;
  114. verData.type = EDataTypeString;
  115. [dataDic setObject:verData forKey:@"versionID"];
  116. }
  117.  
  118. if (userID) {
  119. DataObject * useridData = [[[DataObject alloc] init] autorelease];
  120. useridData.data = userID;
  121. useridData.type = EDataTypeNumber;
  122. [dataDic setObject:useridData forKey:@"userID"];
  123. }
  124.  
  125. if (logList) {
  126. DataObject * logListData = [[[DataObject alloc] init] autorelease];
  127. logListData.data = logList;
  128. logListData.type = EDataTypeArrayJSONObj;
  129. [dataDic setObject:logListData forKey:@"logList"];
  130. }
  131.  
  132. if (SecretKey) {
  133. DataObject * SecretKeyData = [[[DataObject alloc] init] autorelease];
  134. SecretKeyData.data = SecretKey;
  135. SecretKeyData.type = EDataTypeString;
  136. [dataDic setObject:SecretKeyData forKey:@"SecretKey"];
  137. }
  138.  
  139. [self addRequest:pRequest];
  140. } else {
  141.  
  142. }
  143.  
  144. //Classes involved here
  145. enum DataType {
  146. EDataTypeNone = 0,
  147. EDataTypeString,
  148. EDataTypeNumber,
  149. EDataTypeArray,
  150. EDataTypeArrayJSONObj
  151. };
  152.  
  153. @interface DataObject : NSObject {
  154. enum DataType myType;
  155. id myData;
  156. }
  157.  
  158. -(id)init;
  159. @property (nonatomic, readwrite, assign) enum DataType type;
  160. @property (nonatomic, readwrite, retain) id data;
  161. @end
  162.  
  163.  
  164.  
  165. #import "FunctionArray.h"
  166. static FunctionArray *_functionArray = nil;
  167.  
  168. @implementation FunctionArray
  169.  
  170. @synthesize addCard;
  171.  
  172. +(FunctionArray *)shareFunctionArray
  173. {
  174. if (!_functionArray) {
  175. _functionArray = [[FunctionArray alloc]init];
  176.  
  177. }
  178. return _functionArray;
  179. }
  180.  
  181. Pass the value of my network server format so
  182. {“userID”:17,”userType”:0,SecretKey":"C9998D538ADF240CCE71CBB52552A107"”logList”:[{”functionNo”:20120005,”actionDate”: "2012-08-26 16:19:47",”actionName”;”see”},{”functionNo”:20120005,”actionDate”: "2012-08-26 16:19:47",”actionName”;”shop”},{”functionNo”:20120005,”actionDate”: "2012-08-26 16:19:47",”actionName”;”bus”},{”functionNo”:20120005,”actionDate”: "2012-08-26 16:19:47",”actionName”;”vio”},{”functionNo”:20120005,”actionDate”: "2012-08-26 16:19:47",”actionName”;”vip”},{”functionNo”:20120005,”actionDate”: "2012-08-26 16:19:47",”actionName”;”exit”}]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement