iSalesNetwork.m 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541
  1. //
  2. // iSalesNetwork.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 14-6-20.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "iSalesNetwork.h"
  9. #import "RAUtils.h"
  10. #import "OLDataProvider.h"
  11. @implementation iSalesNetwork
  12. +(void) LoadImage:(NSString*) url into:(UIImageView*) container
  13. {
  14. DebugLog(@"LoadImage:(NSString*) url in:(UIImageView*) container");
  15. NSString* file_name=[url lastPathComponent];
  16. NSData* img_data = [iSalesDB load_cached_img:file_name];
  17. if(img_data==nil)
  18. {
  19. DebugLog(@"IMG NOT CACHED %@",file_name);
  20. img_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
  21. [iSalesDB cache_img:img_data :file_name ];
  22. //load from internet;
  23. }
  24. if(img_data!=nil)
  25. {
  26. UIImage * img =[UIImage imageWithData:img_data];
  27. if(img==nil)
  28. DebugLog(@"UIIMAGE IS NIL! %@",file_name);
  29. else
  30. container.image =img;
  31. }
  32. else
  33. {
  34. DebugLog(@"IMG DOWNLOAD FAILED! %@",file_name);
  35. }
  36. }
  37. //+(NSData*)fake_json:(NSString*) url
  38. //{
  39. // NSString* jsonfile = nil;
  40. // if([url isEqualToString:URL_UPDATE_AUTH])
  41. // {
  42. // jsonfile=@"login";
  43. //
  44. // }
  45. // else if([url isEqualToString:URL_REQUEST_CATMENU])
  46. // {
  47. // jsonfile=@"categorymenu";
  48. // }
  49. // else if([url isEqualToString:URL_LOAD_HOME])
  50. // {
  51. // jsonfile=@"homepage";
  52. // }
  53. // else if([url isEqualToString:URL_SEARCH])
  54. // {
  55. // jsonfile=@"search";
  56. // }
  57. // else if([url isEqualToString:URL_CATEGORY_LOADMORE])
  58. // {
  59. // jsonfile=@"category_more";
  60. // }else if([url isEqualToString:URL_ITEM_DETAIL])
  61. // {
  62. // jsonfile=@"detail";
  63. // }else if([url isEqualToString:URL_CART])
  64. // {
  65. // jsonfile=@"cart";
  66. // }else if([url isEqualToString:URL_ORDER_LIST])
  67. // {
  68. // jsonfile=@"orderlist";
  69. // }
  70. //// else if([url isEqualToString:URL_ORDER_INFO])
  71. //// {
  72. //// jsonfile=@"orderinfo";
  73. //// }
  74. //// else if([url isEqualToString:URL_ORDER_INFO])
  75. //// {
  76. //// jsonfile=@"orderinfo2label";
  77. //// }
  78. //
  79. //
  80. //
  81. // NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:jsonfile ofType:@"json" ]];
  82. // NSMutableString *result = [[NSMutableString alloc] initWithData:json encoding:NSUTF8StringEncoding];
  83. //
  84. // DebugLog(@"result: \n%@",result);
  85. // return json;
  86. //}
  87. +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params //delegate:(id < NSURLConnectionDelegate >)delegate
  88. {
  89. int retry = 0;
  90. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  91. if(appDelegate.user!=nil)
  92. [params setValue:appDelegate.user forKey:@"user"];
  93. if(appDelegate.password!=nil)
  94. [params setValue:appDelegate.password forKey:@"password"];
  95. if(appDelegate.ipad_perm!=nil)
  96. [params setValue:appDelegate.ipad_perm forKey:@"ipad_perm"];
  97. [params setValue:appDelegate.build forKey:@"app_ver"];
  98. UIDevice * dev = [UIDevice currentDevice];
  99. NSUUID* uuid =dev.identifierForVendor;
  100. [params setValue:uuid.UUIDString forKey:@"idfv"];
  101. repeat:{
  102. // return [self fake_json:url];
  103. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  104. //分界线的标识符
  105. NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
  106. //根据url初始化request
  107. NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
  108. cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  109. timeoutInterval:JSON_TIMEOUT];
  110. //分界线 --AaB03x
  111. NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
  112. //结束符 AaB03x--
  113. NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
  114. //要上传的图片
  115. // UIImage *image=[params objectForKey:@"pic"];
  116. //得到图片的data
  117. // NSData* data = UIImagePNGRepresentation(image);
  118. //http body的字符串
  119. NSMutableString *body=[[NSMutableString alloc]init];
  120. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  121. // [params setValue:@"handset_login" forKey:@"action"];
  122. // [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
  123. // [params setValue:appDelegate.sessionid forKey:@"sessionid"];
  124. // [params setValue:password forKey:@"password"];
  125. // [params setValue:[NSString stringWithFormat:@"%d",ver] forKey:@"auth_ver"];
  126. // [headers setValue:headQuerlString forKey:@"param"];
  127. //参数的集合的所有key的集合
  128. NSArray *keys= [params allKeys];
  129. DebugLog(@"================parms==================");
  130. //遍历keys
  131. for(int i=0;i<[keys count];i++)
  132. {
  133. //得到当前key
  134. NSString *key=[keys objectAtIndex:i];
  135. //如果key不是pic,说明value是字符类型,比如name:Boris
  136. if(![key isEqualToString:@"pic"])
  137. {
  138. //添加分界线,换行
  139. [body appendFormat:@"%@\r\n",MPboundary];
  140. //添加字段名称,换2行
  141. [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
  142. //添加字段的值
  143. [body appendFormat:@"%@\r\n",[params objectForKey:key]];
  144. DebugLog(@"parameter: key=%@ value=%@",key,[params objectForKey:key]);
  145. }
  146. }
  147. DebugLog(@"================parms==================");
  148. ////添加分界线,换行
  149. [body appendFormat:@"%@\r\n",MPboundary];
  150. //声明pic字段,文件名为boris.png
  151. [body appendFormat:@"Content-Disposition: form-data; name=\"pic\"; filename=\"boris.png\"\r\n"];
  152. //声明上传文件的格式
  153. [body appendFormat:@"Content-Type: image/png\r\n\r\n"];
  154. //声明结束符:--AaB03x--
  155. NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
  156. //声明myRequestData,用来放入http body
  157. NSMutableData *myRequestData=[NSMutableData data];
  158. //将body字符串转化为UTF8格式的二进制
  159. [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
  160. //将image的data加入
  161. // [myRequestData appendData:data];
  162. //加入结束符--AaB03x--
  163. [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
  164. //设置HTTPHeader中Content-Type的值
  165. NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
  166. //设置HTTPHeader
  167. [request setValue:content forHTTPHeaderField:@"Content-Type"];
  168. // 关闭keep alive
  169. [request setValue:@"close" forHTTPHeaderField:@"Connection"];
  170. //设置Content-Length
  171. [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
  172. //设置http body
  173. [request setHTTPBody:myRequestData];
  174. //http method
  175. [request setHTTPMethod:@"POST"];
  176. NSHTTPURLResponse* urlResponse = nil;
  177. NSError *error = [[NSError alloc] init];
  178. NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
  179. DebugLog(@"url: %@",url);
  180. DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
  181. if (responseData==nil) {
  182. DebugLog(@"response error:%@", [error localizedDescription]);
  183. NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
  184. //#define RESULT_FALSE 0
  185. //#define RESULT_TRUE 2
  186. //#define RESULT_NET_ERROR -3
  187. //#define RESULT_NET_NOTAVAILABLE -4
  188. //#define RESULT_ERROR -5
  189. //#define RESULT_LOCALFILE_ERROR -7
  190. //#define RESULT_USERAUTH_ERROR -9
  191. //#define RESULT_UPDATE_USERAUTH_ERROR -11
  192. //#define RESULT_SESSION_EXPIRED -13
  193. //#define RESULT_VER_LOW
  194. // NSString * moreinfo = error.description ;
  195. NSString* err_msg = [error localizedDescription];
  196. //-----------------retry 3 times for error code -1005------------------------
  197. if(error.code==-1005&&retry<3)
  198. {
  199. retry++;
  200. goto repeat;
  201. }
  202. //-----------------end retry 3 times for error code -1005------------------------
  203. NSDictionary* error_json = [RAUtils error_dict:error];
  204. [ret setObject:error_json forKey:@"err_obj"];
  205. NSString* resp_msg= nil;
  206. if(err_msg.length==0)
  207. {
  208. err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
  209. resp_msg = err_msg;
  210. }
  211. [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
  212. [ret setValue:err_msg forKey:@"err_msg"];
  213. [ret setValue:resp_msg forKey:@"resp_msg"];
  214. [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
  215. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
  216. options:0
  217. error:nil];
  218. if(![url isEqualToString:URL_ERR_LOG])
  219. {
  220. [iSalesNetwork err_log:[RAUtils base64en:[RAUtils dict2string:params]] result:[RAUtils base64en:[RAUtils dict2string:ret]] module:url];
  221. }
  222. return jsonData;
  223. }
  224. else
  225. {
  226. NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
  227. DebugLog(@"data string: %@",str);
  228. NSError *error1 = [[NSError alloc] init];
  229. NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
  230. if(jsobj==nil)// 服务器返回不是json
  231. {
  232. jsobj=[[NSMutableDictionary alloc] init];
  233. [jsobj setValue:@"1" forKey:@"result"];
  234. }
  235. int result=[[jsobj valueForKey:@"result"] intValue];
  236. UIApplication * app = [UIApplication sharedApplication];
  237. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  238. NSString* mode =[jsobj valueForKey:@"mode"];
  239. [appDelegate SetMode:mode];
  240. switch (result) {
  241. case 0:
  242. [jsobj setValue:MSG_USERAUTH_ERROR forKey:@"err_msg"];
  243. break;
  244. case 1:
  245. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  246. break;
  247. case 2:
  248. [jsobj setValue:MSG_SUCCESS forKey:@"err_msg"];
  249. break;
  250. case 8:
  251. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  252. break;
  253. case 9:
  254. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  255. break;
  256. default:
  257. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  258. break;
  259. }
  260. if([appDelegate.build intValue]< [[jsobj valueForKey:@"min_ver"]intValue])
  261. {
  262. [jsobj setValue:@"9" forKey:@"result"];
  263. [jsobj setValue:MSG_VER_LOW forKey:@"err_msg"];
  264. }
  265. if(![url isEqualToString:URL_ERR_LOG]&&result!=2)
  266. {
  267. [iSalesNetwork err_log:[RAUtils base64en:[RAUtils dict2string:params]] result:[RAUtils base64en:str] module:url];
  268. }
  269. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
  270. options:0
  271. error:nil];
  272. return jsonData;
  273. }
  274. return responseData;
  275. }
  276. }
  277. +(NSString*)DataTOjsonString:(id)object
  278. {
  279. NSString *jsonString = nil;
  280. NSError *error;
  281. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object
  282. options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
  283. error:&error];
  284. if (! jsonData) {
  285. NSLog(@"Got an error: %@", error);
  286. } else {
  287. jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  288. }
  289. return jsonString;
  290. }
  291. //+(NSDictionary*)request_Editor:(NSString*) sourceid editor:(NSString*)editor
  292. //{
  293. //
  294. //}
  295. +(NSDictionary*) delete_portfoliolist:(NSString* ) listid
  296. {
  297. if(![self IsNetworkAvailable])
  298. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  299. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  300. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  301. if(appDelegate.user!=nil)
  302. [params setValue:appDelegate.user forKey:@"user"];
  303. if(appDelegate.contact_id!=nil)
  304. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  305. if(appDelegate.password!=nil)
  306. [params setValue:appDelegate.password forKey:@"password"];
  307. [params setValue:listid forKey:@"tearsheetsId"];
  308. // [params setValue:editor forKey:@"editor"];
  309. NSData* json=[self get_json:URL_PORTFOLIOLIST_REMOVE parameters:params];
  310. if(json!=nil)
  311. {
  312. NSError *error=nil;
  313. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  314. return jsobj;
  315. }
  316. else
  317. return nil;
  318. }
  319. +(NSDictionary*) portfolio_remove:(NSString* ) item_ids
  320. {
  321. if(![self IsNetworkAvailable])
  322. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  323. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  324. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  325. if(appDelegate.user!=nil)
  326. [params setValue:appDelegate.user forKey:@"user"];
  327. if(appDelegate.contact_id!=nil)
  328. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  329. if(appDelegate.password!=nil)
  330. [params setValue:appDelegate.password forKey:@"password"];
  331. [params setValue:item_ids forKey:@"portfolioId"];
  332. // [params setValue:editor forKey:@"editor"];
  333. NSData* json=[self get_json:URL_PORTFOLIO_REMOVE parameters:params];
  334. if(json!=nil)
  335. {
  336. NSError *error=nil;
  337. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  338. int result = [[jsobj valueForKey:@"result"] intValue];
  339. if (result==2)
  340. {
  341. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  342. [appDelegate update_count_mark];
  343. }
  344. return jsobj;
  345. }
  346. else
  347. return nil;
  348. }
  349. +(NSDictionary*) watchlist_remove:(NSString* ) item_ids
  350. {
  351. if(![self IsNetworkAvailable])
  352. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  353. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  354. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  355. if(appDelegate.user!=nil)
  356. [params setValue:appDelegate.user forKey:@"user"];
  357. if(appDelegate.contact_id!=nil)
  358. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  359. if(appDelegate.password!=nil)
  360. [params setValue:appDelegate.password forKey:@"password"];
  361. [params setValue:item_ids forKey:@"collectId"];
  362. // [params setValue:editor forKey:@"editor"];
  363. NSData* json=[self get_json:URL_WATCHLIST_REMOVE parameters:params];
  364. if(json!=nil)
  365. {
  366. NSError *error=nil;
  367. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  368. int result = [[jsobj valueForKey:@"result"] intValue];
  369. if (result==2)
  370. {
  371. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  372. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  373. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  374. [appDelegate update_count_mark];
  375. }
  376. return jsobj;
  377. }
  378. else
  379. return nil;
  380. }
  381. +(NSDictionary*) move_cart2wish:(NSString* ) item_ids
  382. {
  383. if(![self IsNetworkAvailable])
  384. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  385. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  386. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  387. if(appDelegate.user!=nil)
  388. [params setValue:appDelegate.user forKey:@"user"];
  389. if(appDelegate.contact_id!=nil)
  390. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  391. if(appDelegate.password!=nil)
  392. [params setValue:appDelegate.password forKey:@"password"];
  393. if(appDelegate.order_code!=nil)
  394. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  395. [params setValue:item_ids forKey:@"cartItemId"];
  396. // [params setValue:editor forKey:@"editor"];
  397. NSData* json=[self get_json:URL_CART2WISH parameters:params];
  398. if(json!=nil)
  399. {
  400. NSError *error=nil;
  401. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  402. int result = [[jsobj valueForKey:@"result"] intValue];
  403. if (result==2)
  404. {
  405. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  406. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  407. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  408. [appDelegate update_count_mark];
  409. }
  410. return jsobj;
  411. }
  412. else
  413. return nil;
  414. }
  415. +(NSDictionary*) move_wish2cart:(NSString* ) item_ids
  416. {
  417. if(![self IsNetworkAvailable])
  418. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  419. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  420. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  421. if(appDelegate.user!=nil)
  422. [params setValue:appDelegate.user forKey:@"user"];
  423. if(appDelegate.contact_id!=nil)
  424. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  425. if(appDelegate.password!=nil)
  426. [params setValue:appDelegate.password forKey:@"password"];
  427. if(appDelegate.order_code!=nil)
  428. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  429. [params setValue:item_ids forKey:@"collectId"];
  430. // [params setValue:editor forKey:@"editor"];
  431. NSData* json=[self get_json:URL_WISH2CART parameters:params];
  432. if(json!=nil)
  433. {
  434. NSError *error=nil;
  435. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  436. int result = [[jsobj valueForKey:@"result"] intValue];
  437. if (result==2)
  438. {
  439. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  440. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  441. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  442. [appDelegate update_count_mark];
  443. }
  444. return jsobj;
  445. }
  446. else
  447. return nil;
  448. }
  449. +(NSDictionary*) cart_remove:(NSString* ) item_ids
  450. {
  451. if(![self IsNetworkAvailable])
  452. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  453. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  454. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  455. if(appDelegate.user!=nil)
  456. [params setValue:appDelegate.user forKey:@"user"];
  457. if(appDelegate.contact_id!=nil)
  458. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  459. if(appDelegate.password!=nil)
  460. [params setValue:appDelegate.password forKey:@"password"];
  461. if(appDelegate.order_code!=nil)
  462. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  463. [params setValue:item_ids forKey:@"cartItemId"];
  464. // [params setValue:editor forKey:@"editor"];
  465. NSData* json=[self get_json:URL_CART_REMOVE parameters:params];
  466. if(json!=nil)
  467. {
  468. NSError *error=nil;
  469. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  470. int result = [[jsobj valueForKey:@"result"] intValue];
  471. if (result==2)
  472. {
  473. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  474. [appDelegate update_count_mark];
  475. }
  476. return jsobj;
  477. }
  478. else
  479. return nil;
  480. }
  481. +(NSDictionary*) cart_check:(NSString* ) item_ids
  482. {
  483. return nil;
  484. if(![self IsNetworkAvailable])
  485. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  486. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  487. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  488. if(appDelegate.user!=nil)
  489. [params setValue:appDelegate.user forKey:@"user"];
  490. if(appDelegate.contact_id!=nil)
  491. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  492. if(appDelegate.password!=nil)
  493. [params setValue:appDelegate.password forKey:@"password"];
  494. [params setValue:item_ids forKey:@"cartItemId"];
  495. // [params setValue:editor forKey:@"editor"];
  496. NSData* json=[self get_json:URL_CART_CHECK parameters:params];
  497. if(json!=nil)
  498. {
  499. NSError *error=nil;
  500. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  501. return jsobj;
  502. }
  503. else
  504. return nil;
  505. }
  506. +(NSDictionary*)create_Address:(NSMutableDictionary*)params
  507. {
  508. if(![self IsNetworkAvailable])
  509. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  510. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  511. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  512. if(appDelegate.user!=nil)
  513. [params setValue:appDelegate.user forKey:@"user"];
  514. if(appDelegate.contact_id!=nil)
  515. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  516. if(appDelegate.password!=nil)
  517. [params setValue:appDelegate.password forKey:@"password"];
  518. // [params setValue:sourceid forKey:@"sourceid"];
  519. // [params setValue:editor forKey:@"editor"];
  520. NSData* json=[self get_json:URL_ADDRESS_SAVE parameters:params];
  521. if(json!=nil)
  522. {
  523. NSError *error=nil;
  524. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  525. return jsobj;
  526. }
  527. else
  528. return nil;
  529. }
  530. +(NSDictionary*)copy_Order:(NSString*) order_code
  531. {
  532. if(![self IsNetworkAvailable])
  533. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  534. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  535. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  536. if(appDelegate.user!=nil)
  537. [params setValue:appDelegate.user forKey:@"user"];
  538. if(appDelegate.contact_id!=nil)
  539. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  540. if(appDelegate.password!=nil)
  541. [params setValue:appDelegate.password forKey:@"password"];
  542. // NSString* ssaved = @"false";
  543. // if(saved)
  544. // ssaved=@"true";
  545. // [params setValue:@"true" forKey:@"saved"];
  546. [params setValue:order_code forKey:@"code"];
  547. // [params setValue:sourceid forKey:@"sourceid"];
  548. // [params setValue:editor forKey:@"editor"];
  549. NSData* json=[self get_json:URL_COPY_ORDER parameters:params];
  550. if(json!=nil)
  551. {
  552. NSError *error=nil;
  553. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  554. return jsobj;
  555. }
  556. else
  557. return nil;
  558. }
  559. +(NSDictionary*)sign_Order:(NSString*) order_code path:(NSString*)path
  560. {
  561. if(![self IsNetworkAvailable])
  562. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  563. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  564. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  565. if(appDelegate.user!=nil)
  566. [params setValue:appDelegate.user forKey:@"user"];
  567. if(appDelegate.contact_id!=nil)
  568. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  569. if(appDelegate.password!=nil)
  570. [params setValue:appDelegate.password forKey:@"password"];
  571. // NSString* ssaved = @"false";
  572. // if(saved)
  573. // ssaved=@"true";
  574. // [params setValue:@"true" forKey:@"saved"];
  575. [params setValue:order_code forKey:@"orderCode"];
  576. [params setValue:path forKey:@"picpath"];
  577. // [params setValue:sourceid forKey:@"sourceid"];
  578. // [params setValue:editor forKey:@"editor"];
  579. NSData* json=[self get_json:URL_SIGN_ORDER parameters:params];
  580. if(json!=nil)
  581. {
  582. NSError *error=nil;
  583. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  584. return jsobj;
  585. }
  586. else
  587. return nil;
  588. }
  589. +(NSDictionary*)commit_Order:(NSString*) order_code //saved:(bool) saved
  590. {
  591. if(![self IsNetworkAvailable])
  592. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  593. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  594. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  595. if(appDelegate.user!=nil)
  596. [params setValue:appDelegate.user forKey:@"user"];
  597. if(appDelegate.contact_id!=nil)
  598. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  599. if(appDelegate.password!=nil)
  600. [params setValue:appDelegate.password forKey:@"password"];
  601. // NSString* ssaved = @"false";
  602. // if(saved)
  603. // ssaved=@"true";
  604. [params setValue:@"true" forKey:@"saved"];
  605. [params setValue:order_code forKey:@"orderCode"];
  606. // [params setValue:sourceid forKey:@"sourceid"];
  607. // [params setValue:editor forKey:@"editor"];
  608. NSData* json=[self get_json:URL_COMMIT_ORDER parameters:params];
  609. if(json!=nil)
  610. {
  611. NSError *error=nil;
  612. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  613. return jsobj;
  614. }
  615. else
  616. return nil;
  617. }
  618. +(NSDictionary*)open_Order:(NSString*) order_code
  619. {
  620. if(![self IsNetworkAvailable])
  621. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  622. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  623. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  624. if(appDelegate.user!=nil)
  625. [params setValue:appDelegate.user forKey:@"user"];
  626. // if(appDelegate.contact_id!=nil)
  627. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  628. if(appDelegate.password!=nil)
  629. [params setValue:appDelegate.password forKey:@"password"];
  630. [params setValue:order_code forKey:@"orderCode"];
  631. // [params setValue:sourceid forKey:@"sourceid"];
  632. // [params setValue:editor forKey:@"editor"];
  633. NSData* json=[self get_json:URL_OPEN_ORDER parameters:params];
  634. if(json!=nil)
  635. {
  636. NSError *error=nil;
  637. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  638. int result = [[jsobj valueForKey:@"result"] intValue];
  639. if (result==2)
  640. {
  641. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  642. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  643. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  644. [appDelegate update_count_mark];
  645. }
  646. return jsobj;
  647. }
  648. else
  649. return nil;
  650. }
  651. +(NSDictionary*)delete_Order:(NSString*) order_id
  652. {
  653. if(![self IsNetworkAvailable])
  654. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  655. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  656. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  657. if(appDelegate.user!=nil)
  658. [params setValue:appDelegate.user forKey:@"user"];
  659. // if(appDelegate.contact_id!=nil)
  660. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  661. if(appDelegate.password!=nil)
  662. [params setValue:appDelegate.password forKey:@"password"];
  663. [params setValue:order_id forKey:@"orderId"];
  664. // [params setValue:sourceid forKey:@"sourceid"];
  665. // [params setValue:editor forKey:@"editor"];
  666. NSData* json=[self get_json:URL_DELETE_ORDER parameters:params];
  667. if(json!=nil)
  668. {
  669. NSError *error=nil;
  670. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  671. return jsobj;
  672. }
  673. else
  674. return nil;
  675. }
  676. +(NSDictionary*)cancel_Order:(NSString*) order_id
  677. {
  678. if(![self IsNetworkAvailable])
  679. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  680. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  681. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  682. if(appDelegate.user!=nil)
  683. [params setValue:appDelegate.user forKey:@"user"];
  684. // if(appDelegate.contact_id!=nil)
  685. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  686. if(appDelegate.password!=nil)
  687. [params setValue:appDelegate.password forKey:@"password"];
  688. [params setValue:order_id forKey:@"orderId"];
  689. // [params setValue:sourceid forKey:@"sourceid"];
  690. // [params setValue:editor forKey:@"editor"];
  691. NSData* json=[self get_json:URL_CANCEL_ORDER parameters:params];
  692. if(json!=nil)
  693. {
  694. NSError *error=nil;
  695. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  696. return jsobj;
  697. }
  698. else
  699. return nil;
  700. }
  701. +(NSDictionary*)release_Order:(NSString*) order_code
  702. {
  703. if(![self IsNetworkAvailable])
  704. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  705. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  706. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  707. if(appDelegate.user!=nil)
  708. [params setValue:appDelegate.user forKey:@"user"];
  709. // if(appDelegate.contact_id!=nil)
  710. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  711. if(appDelegate.password!=nil)
  712. [params setValue:appDelegate.password forKey:@"password"];
  713. [params setValue:order_code forKey:@"orderCode"];
  714. // [params setValue:sourceid forKey:@"sourceid"];
  715. // [params setValue:editor forKey:@"editor"];
  716. NSData* json=[self get_json:URL_RELEASE_ORDER parameters:params];
  717. if(json!=nil)
  718. {
  719. NSError *error=nil;
  720. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  721. if([[jsobj valueForKey:@"result"]intValue]==2)
  722. { [appDelegate SetSo:nil];
  723. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  724. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  725. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  726. [appDelegate update_count_mark];
  727. }
  728. return jsobj;
  729. }
  730. else
  731. return nil;
  732. }
  733. +(NSDictionary*)update_OrderCustomer:(NSString*) order_code customerinfo:(NSMutableDictionary*)info
  734. {
  735. if(![self IsNetworkAvailable])
  736. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  737. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  738. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  739. if(appDelegate.user!=nil)
  740. [info setValue:appDelegate.user forKey:@"user"];
  741. // if(appDelegate.contact_id!=nil)
  742. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  743. if(appDelegate.password!=nil)
  744. [info setValue:appDelegate.password forKey:@"password"];
  745. [info setValue:order_code forKey:@"orderCode"];
  746. // [params setValue:sourceid forKey:@"sourceid"];
  747. // [params setValue:editor forKey:@"editor"];
  748. NSData* json=[self get_json:URL_UPDATE_ORDERCUSTOMER parameters:info];
  749. if(json!=nil)
  750. {
  751. NSError *error=nil;
  752. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  753. return jsobj;
  754. }
  755. else
  756. return nil;
  757. }
  758. +(NSDictionary*)saveandcommit_Order:(NSMutableDictionary*)params
  759. {
  760. if(![self IsNetworkAvailable])
  761. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  762. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  763. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  764. if(appDelegate.user!=nil)
  765. [params setValue:appDelegate.user forKey:@"user"];
  766. if(appDelegate.contact_id!=nil)
  767. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  768. if(appDelegate.password!=nil)
  769. [params setValue:appDelegate.password forKey:@"password"];
  770. if(appDelegate.order_code!=nil)
  771. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  772. // NSDictionary* customerinfo= appDelegate.customerInfo;
  773. //
  774. // NSArray* keys=[customerinfo allKeys];
  775. // for(int i=0;i<keys.count;i++)
  776. // {
  777. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  778. // }
  779. //
  780. // [params setValue:sourceid forKey:@"sourceid"];
  781. // [params setValue:editor forKey:@"editor"];
  782. NSData* json=[self get_json:URL_COMMIT_ORDER parameters:params];
  783. if(json!=nil)
  784. {
  785. NSError *error=nil;
  786. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  787. if([[jsobj valueForKey:@"result"]intValue]==2)
  788. [appDelegate SetSo:nil];
  789. return jsobj;
  790. }
  791. else
  792. return nil;
  793. }
  794. +(NSDictionary*)update_Customer:(NSMutableDictionary*)params
  795. {
  796. if(![self IsNetworkAvailable])
  797. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  798. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  799. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  800. if(appDelegate.user!=nil)
  801. [params setValue:appDelegate.user forKey:@"user"];
  802. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  803. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  804. // else
  805. if(appDelegate.contact_id!=nil)
  806. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  807. if(appDelegate.password!=nil)
  808. [params setValue:appDelegate.password forKey:@"password"];
  809. // NSDictionary* customerinfo=nil;
  810. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  811. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  812. // else
  813. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  814. //
  815. // appDelegate.customerInfo;
  816. // NSArray* keys=[customerinfo allKeys];
  817. // for(int i=0;i<keys.count;i++)
  818. // {
  819. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  820. // }
  821. // [params setValue:sourceid forKey:@"sourceid"];
  822. // [params setValue:editor forKey:@"editor"];
  823. NSData* json=[self get_json:URL_CUSTOMER_UPDATE parameters:params];
  824. if(json!=nil)
  825. {
  826. NSError *error=nil;
  827. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  828. return jsobj;
  829. }
  830. else
  831. return nil;
  832. }
  833. +(NSDictionary*)save_newCustomer:(NSMutableDictionary*)params
  834. {
  835. if(![self IsNetworkAvailable])
  836. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  837. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  838. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  839. if(appDelegate.user!=nil)
  840. [params setValue:appDelegate.user forKey:@"user"];
  841. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  842. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  843. // else
  844. if(appDelegate.contact_id!=nil)
  845. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  846. if(appDelegate.password!=nil)
  847. [params setValue:appDelegate.password forKey:@"password"];
  848. // NSDictionary* customerinfo=nil;
  849. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  850. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  851. // else
  852. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  853. //
  854. // appDelegate.customerInfo;
  855. // NSArray* keys=[customerinfo allKeys];
  856. // for(int i=0;i<keys.count;i++)
  857. // {
  858. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  859. // }
  860. // [params setValue:sourceid forKey:@"sourceid"];
  861. // [params setValue:editor forKey:@"editor"];
  862. NSData* json=[self get_json:URL_CUSTOMER_SAVE parameters:params];
  863. if(json!=nil)
  864. {
  865. NSError *error=nil;
  866. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  867. return jsobj;
  868. }
  869. else
  870. return nil;
  871. }
  872. +(NSDictionary*)save_Order:(NSMutableDictionary*)params
  873. {
  874. if(![self IsNetworkAvailable])
  875. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  876. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  877. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  878. if(appDelegate.user!=nil)
  879. [params setValue:appDelegate.user forKey:@"user"];
  880. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  881. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  882. // else
  883. if(appDelegate.contact_id!=nil)
  884. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  885. if(appDelegate.password!=nil)
  886. [params setValue:appDelegate.password forKey:@"password"];
  887. if(appDelegate.order_code!=nil)
  888. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  889. // NSDictionary* customerinfo=nil;
  890. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  891. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  892. // else
  893. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  894. //
  895. // appDelegate.customerInfo;
  896. // NSArray* keys=[customerinfo allKeys];
  897. // for(int i=0;i<keys.count;i++)
  898. // {
  899. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  900. // }
  901. // [params setValue:sourceid forKey:@"sourceid"];
  902. // [params setValue:editor forKey:@"editor"];
  903. NSData* json=[self get_json:URL_SAVE_ORDER parameters:params];
  904. if(json!=nil)
  905. {
  906. NSError *error=nil;
  907. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  908. [appDelegate SetSo:[jsobj valueForKey:@"so#"]];
  909. return jsobj;
  910. }
  911. else
  912. return nil;
  913. }
  914. +(NSDictionary*)request_Editor:(NSString*) request_url params:(NSMutableDictionary*)params
  915. {
  916. if(![self IsNetworkAvailable])
  917. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  918. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  919. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  920. if(appDelegate.user!=nil)
  921. [params setValue:appDelegate.user forKey:@"user"];
  922. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  923. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  924. // else
  925. if(appDelegate.contact_id!=nil)
  926. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  927. if(appDelegate.password!=nil)
  928. [params setValue:appDelegate.password forKey:@"password"];
  929. if(appDelegate.order_code!=nil)
  930. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  931. // [params setValue:sourceid forKey:@"sourceid"];
  932. // [params setValue:editor forKey:@"editor"];
  933. NSData* json=[self get_json:request_url parameters:params];
  934. if(json!=nil)
  935. {
  936. NSError *error=nil;
  937. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  938. return jsobj;
  939. }
  940. else
  941. return nil;
  942. }
  943. //+(NSDictionary*)request_OrderInfo:(NSString*) orderid
  944. //{
  945. // if(![self IsNetworkAvailable])
  946. // return nil;
  947. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  948. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  949. // if(appDelegate.user!=nil)
  950. // [params setValue:appDelegate.user forKey:@"user"];
  951. // if(appDelegate.password!=nil)
  952. // [params setValue:appDelegate.password forKey:@"password"];
  953. // [params setValue:orderid forKey:@"orderid"];
  954. // NSData* json=[self get_json:URL_ORDER_INFO parameters:params];
  955. // NSError *error=nil;
  956. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  957. // return jsobj;
  958. //}
  959. +(NSDictionary*)request_OrderList:(int ) offset limit :(int)limit keywords :(NSString* ) keywords status:(NSString*) status_code customer:(NSString*) customer
  960. {
  961. if(![self IsNetworkAvailable])
  962. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  963. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  964. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  965. if(appDelegate.user!=nil)
  966. [params setValue:appDelegate.user forKey:@"user"];
  967. if(appDelegate.contact_id!=nil)
  968. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  969. if(appDelegate.password!=nil)
  970. [params setValue:appDelegate.password forKey:@"password"];
  971. [params setValue:[NSString stringWithFormat:@"%d",offset ] forKey:@"offset"];
  972. [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  973. [params setValue:keywords forKey:@"keyWord"];
  974. [params setValue:customer forKey:@"customer_filter"];
  975. [params setValue:status_code forKey:@"orderStatus"];
  976. NSData* json=[self get_json:URL_ORDER_LIST parameters:params];
  977. if(json==nil)
  978. return nil;
  979. NSError *error=nil;
  980. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  981. return jsobj;
  982. }
  983. +(NSDictionary*)request_PDFList:(int ) offset limit:(int)limit keywords:(NSString* ) keywords
  984. {
  985. if(![self IsNetworkAvailable])
  986. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  987. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  988. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  989. if(appDelegate.user!=nil)
  990. [params setValue:appDelegate.user forKey:@"user"];
  991. if(appDelegate.contact_id!=nil)
  992. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  993. if(appDelegate.password!=nil)
  994. [params setValue:appDelegate.password forKey:@"password"];
  995. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  996. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  997. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  998. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  999. // [params setValue:filter forKey:@"filter"];
  1000. [params setValue:keywords forKey:@"keyWord"];
  1001. [params setValue:[NSString stringWithFormat:@"%d",limit] forKey:@"limit"];
  1002. [params setValue:[NSString stringWithFormat:@"%d",offset] forKey:@"offset"];
  1003. NSData* json=[self get_json:URL_DM_LIST parameters:params];
  1004. if(json==nil)
  1005. return nil;
  1006. NSError *error=nil;
  1007. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1008. return jsobj;
  1009. }
  1010. +(NSDictionary*)direct_save_TearSheet:(NSString*) request_url name:(NSString*)name delete:(NSString* )ids
  1011. {
  1012. if(![self IsNetworkAvailable])
  1013. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1014. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1015. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1016. if(appDelegate.user!=nil)
  1017. [params setValue:appDelegate.user forKey:@"user"];
  1018. if(appDelegate.contact_id!=nil)
  1019. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1020. if(appDelegate.password!=nil)
  1021. [params setValue:appDelegate.password forKey:@"password"];
  1022. [params setValue:request_url forKey:@"pdfUrl"];
  1023. [params setValue:name forKey:@"pdfName"];
  1024. [params setValue:ids forKey:@"itemIds"];
  1025. NSData* json=[self get_json:URL_REQUEST_DM parameters:params];
  1026. if(json==nil)
  1027. return nil;
  1028. NSError *error=nil;
  1029. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1030. return jsobj;
  1031. }
  1032. +(NSDictionary*)request_TearSheet:(NSString*) request_url
  1033. {
  1034. if(![self IsNetworkAvailable])
  1035. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1036. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1037. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1038. if(appDelegate.user!=nil)
  1039. [params setValue:appDelegate.user forKey:@"user"];
  1040. if(appDelegate.contact_id!=nil)
  1041. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1042. if(appDelegate.password!=nil)
  1043. [params setValue:appDelegate.password forKey:@"password"];
  1044. [params setValue:request_url forKey:@"pdfUrl"];
  1045. NSData* json=[self get_json:URL_REQUEST_DM parameters:params];
  1046. if(json==nil)
  1047. return nil;
  1048. NSError *error=nil;
  1049. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1050. return jsobj;
  1051. }
  1052. +(NSDictionary*)save_TearSheet:(NSString*) path name:(NSString*)name delete:(NSString* )ids
  1053. {
  1054. if(![self IsNetworkAvailable])
  1055. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1056. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1057. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1058. if(appDelegate.user!=nil)
  1059. [params setValue:appDelegate.user forKey:@"user"];
  1060. if(appDelegate.contact_id!=nil)
  1061. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1062. if(appDelegate.password!=nil)
  1063. [params setValue:appDelegate.password forKey:@"password"];
  1064. [params setValue:path forKey:@"pdfPath"];
  1065. [params setValue:name forKey:@"pdfName"];
  1066. [params setValue:ids forKey:@"itemIds"];
  1067. NSData* json=[self get_json:URL_SAVE_DM parameters:params];
  1068. if(json==nil)
  1069. return nil;
  1070. NSError *error=nil;
  1071. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1072. return jsobj;
  1073. }
  1074. +(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module //device:(NSString*) device
  1075. {
  1076. if(![self IsNetworkAvailable])
  1077. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1078. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1079. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1080. if(appDelegate.user!=nil)
  1081. [params setValue:appDelegate.user forKey:@"user"];
  1082. [params setValue:up_params forKey:@"upparam"];
  1083. [params setValue:result forKey:@"result"];
  1084. [params setValue:module forKey:@"interfac"];
  1085. [params setValue:[RAUtils base64en:[RAUtils dict2string: [RAUtils device_info]]] forKey:@"device"];
  1086. // [params setValue:module forKey:@"module"];
  1087. // [[UIDevice currentDevice] name];
  1088. NSData* json=[self get_json:URL_ERR_LOG parameters:params];
  1089. if(json==nil)
  1090. return nil;
  1091. NSError *error=nil;
  1092. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1093. return jsobj;
  1094. }
  1095. +(NSDictionary*)request_ContactList:(int) offset limit:(int)limit keywords:(NSString*) keywords type:(NSString*) contact_type adv_search:(NSDictionary*)upparams
  1096. {
  1097. if(![self IsNetworkAvailable])
  1098. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1099. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1100. if(upparams!=nil)
  1101. params = [upparams mutableCopy];
  1102. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1103. if(appDelegate.user!=nil)
  1104. [params setValue:appDelegate.user forKey:@"user"];
  1105. if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  1106. [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1107. else
  1108. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1109. if(appDelegate.password!=nil)
  1110. [params setValue:appDelegate.password forKey:@"password"];
  1111. [params setValue:[NSString stringWithFormat:@"%d",offset ] forKey:@"offset"];
  1112. [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  1113. [params setValue:contact_type forKey:@"contactType"];
  1114. [params setValue:keywords forKey:@"keyword"];
  1115. NSString* url=nil;
  1116. if([contact_type isEqualToString:@"Sales_Order_Ship_To"])
  1117. url=URL_SHIPTO_LIST;
  1118. else
  1119. url=URL_CONTACT_LIST;
  1120. NSData* json=[self get_json:url parameters:params];
  1121. if(json==nil)
  1122. return nil;
  1123. NSError *error=nil;
  1124. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1125. return jsobj;
  1126. }
  1127. +(NSDictionary*)request_OrderDetail:(NSString* ) orderid
  1128. {
  1129. if(![self IsNetworkAvailable])
  1130. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1131. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1132. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1133. if(appDelegate.user!=nil)
  1134. [params setValue:appDelegate.user forKey:@"user"];
  1135. if(appDelegate.contact_id!=nil)
  1136. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1137. if(appDelegate.password!=nil)
  1138. [params setValue:appDelegate.password forKey:@"password"];
  1139. [params setValue:orderid forKey:@"orderId"];
  1140. // [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  1141. NSData* json=[self get_json:URL_ORDER_DETAIL parameters:params];
  1142. if(json==nil)
  1143. return nil;
  1144. NSError *error=nil;
  1145. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1146. return jsobj;
  1147. }
  1148. +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count
  1149. {
  1150. if(![self IsNetworkAvailable])
  1151. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1152. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1153. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1154. if(appDelegate.user!=nil)
  1155. [params setValue:appDelegate.user forKey:@"user"];
  1156. if(appDelegate.contact_id!=nil)
  1157. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1158. if(appDelegate.password!=nil)
  1159. [params setValue:appDelegate.password forKey:@"password"];
  1160. if(appDelegate.order_code!=nil)
  1161. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1162. [params setValue:item_id forKey:@"product_id"];
  1163. [params setValue:[NSString stringWithFormat:@"%d",count] forKey:@"count"];
  1164. NSDictionary* customerinfo= appDelegate.customerInfo;
  1165. NSArray* keys=[customerinfo allKeys];
  1166. for(int i=0;i<keys.count;i++)
  1167. {
  1168. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1169. }
  1170. NSData* json=[self get_json:URL_ADD_TO_CART parameters:params];
  1171. if(json==nil)
  1172. return nil;
  1173. NSError *error=nil;
  1174. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1175. int result = [[jsobj valueForKey:@"result"] intValue];
  1176. if (result==2)
  1177. {
  1178. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1179. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1180. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1181. [appDelegate update_count_mark];
  1182. }
  1183. return jsobj;
  1184. }
  1185. +(NSDictionary*) add_toCart_byName:(NSString* ) model_name
  1186. {
  1187. if(![self IsNetworkAvailable])
  1188. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1189. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1190. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1191. if(appDelegate.user!=nil)
  1192. [params setValue:appDelegate.user forKey:@"user"];
  1193. if(appDelegate.contact_id!=nil)
  1194. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1195. if(appDelegate.password!=nil)
  1196. [params setValue:appDelegate.password forKey:@"password"];
  1197. if(appDelegate.order_code!=nil)
  1198. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1199. [params setValue:model_name forKey:@"product_name"];
  1200. [params setValue:[NSString stringWithFormat:@"%d",-1] forKey:@"count"];
  1201. NSDictionary* customerinfo= appDelegate.customerInfo;
  1202. NSArray* keys=[customerinfo allKeys];
  1203. for(int i=0;i<keys.count;i++)
  1204. {
  1205. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1206. }
  1207. NSData* json=[self get_json:URL_ADD_TO_CART parameters:params];
  1208. if(json==nil)
  1209. return nil;
  1210. NSError *error=nil;
  1211. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1212. int result = [[jsobj valueForKey:@"result"] intValue];
  1213. if (result==2||result==8)
  1214. {
  1215. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1216. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1217. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1218. [appDelegate update_count_mark];
  1219. }
  1220. return jsobj;
  1221. }
  1222. //+(NSDictionary*) new_Customer
  1223. //{
  1224. // if(![self IsNetworkAvailable])
  1225. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1226. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1227. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1228. // if(appDelegate.user!=nil)
  1229. // [params setValue:appDelegate.user forKey:@"user"];
  1230. //// if(appDelegate.contact_id!=nil)
  1231. //// [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1232. // if(appDelegate.password!=nil)
  1233. // [params setValue:appDelegate.password forKey:@"password"];
  1234. //
  1235. //// if(appDelegate.order_code!=nil)
  1236. //// [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1237. //
  1238. //
  1239. // NSDictionary* customerinfo= appDelegate.customerInfo;
  1240. //
  1241. // NSArray* keys=[customerinfo allKeys];
  1242. // for(int i=0;i<keys.count;i++)
  1243. // {
  1244. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1245. // }
  1246. //
  1247. // NSData* json=[self get_json:URL_CUSTOMER_EDIT parameters:params];
  1248. // if(json==nil)
  1249. // return nil;
  1250. // NSError *error=nil;
  1251. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1252. // return jsobj;
  1253. //}
  1254. +(NSDictionary*) new_Order
  1255. {
  1256. if(![self IsNetworkAvailable])
  1257. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1258. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1259. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1260. if(appDelegate.user!=nil)
  1261. [params setValue:appDelegate.user forKey:@"user"];
  1262. if(appDelegate.contact_id!=nil)
  1263. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1264. if(appDelegate.password!=nil)
  1265. [params setValue:appDelegate.password forKey:@"password"];
  1266. if(appDelegate.order_code!=nil)
  1267. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1268. NSDictionary* customerinfo= appDelegate.customerInfo;
  1269. NSArray* keys=[customerinfo allKeys];
  1270. for(int i=0;i<keys.count;i++)
  1271. {
  1272. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1273. }
  1274. NSData* json=[self get_json:URL_NEW_ORDER parameters:params];
  1275. if(json==nil)
  1276. return nil;
  1277. NSError *error=nil;
  1278. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1279. int result = [[jsobj valueForKey:@"result"] intValue];
  1280. if (result==2)
  1281. {
  1282. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1283. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1284. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1285. [appDelegate update_count_mark];
  1286. }
  1287. [appDelegate SetSo:[jsobj valueForKey:@"soId"]];
  1288. return jsobj;
  1289. }
  1290. +(NSDictionary*) add_toPortfolio:(NSString* ) item_id
  1291. {
  1292. if(![self IsNetworkAvailable])
  1293. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1294. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1295. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1296. if(appDelegate.user!=nil)
  1297. [params setValue:appDelegate.user forKey:@"user"];
  1298. if(appDelegate.contact_id!=nil)
  1299. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1300. if(appDelegate.password!=nil)
  1301. [params setValue:appDelegate.password forKey:@"password"];
  1302. [params setValue:item_id forKey:@"product_id"];
  1303. NSData* json=[self get_json:URL_ADD_TO_PORTFOLIO parameters:params];
  1304. if(json==nil)
  1305. return nil;
  1306. NSError *error=nil;
  1307. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1308. int result = [[jsobj valueForKey:@"result"] intValue];
  1309. if (result==2)
  1310. {
  1311. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1312. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1313. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1314. [appDelegate update_count_mark];
  1315. }
  1316. return jsobj;
  1317. }
  1318. +(NSDictionary*) add_toWatchList:(NSString* ) item_id
  1319. {
  1320. if(![self IsNetworkAvailable])
  1321. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1322. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1323. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1324. if(appDelegate.user!=nil)
  1325. [params setValue:appDelegate.user forKey:@"user"];
  1326. if(appDelegate.contact_id!=nil)
  1327. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1328. if(appDelegate.password!=nil)
  1329. [params setValue:appDelegate.password forKey:@"password"];
  1330. [params setValue:item_id forKey:@"product_id"];
  1331. NSData* json=[self get_json:URL_ADD_TO_WATCHLIST parameters:params];
  1332. if(json==nil)
  1333. return nil;
  1334. NSError *error=nil;
  1335. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1336. int result = [[jsobj valueForKey:@"result"] intValue];
  1337. if (result==2)
  1338. {
  1339. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1340. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1341. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1342. [appDelegate update_count_mark];
  1343. }
  1344. return jsobj;
  1345. }
  1346. +(NSDictionary*) cart_setPrice:(NSString*) cart_id price:(float) price discount:(float) discount notes:(NSString*) notes
  1347. {
  1348. if(![self IsNetworkAvailable])
  1349. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1350. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1351. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1352. if(appDelegate.user!=nil)
  1353. [params setValue:appDelegate.user forKey:@"user"];
  1354. if(appDelegate.contact_id!=nil)
  1355. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1356. if(appDelegate.password!=nil)
  1357. [params setValue:appDelegate.password forKey:@"password"];
  1358. [params setValue:cart_id forKey:@"cartitem_id"];
  1359. [params setValue:notes forKey:@"item_note"];
  1360. [params setValue:[NSString stringWithFormat:@"%f",price] forKey:@"price"];
  1361. [params setValue:[NSString stringWithFormat:@"%f",discount] forKey:@"discount"];
  1362. NSData* json=[self get_json:URL_CART_SET_PRICE parameters:params];
  1363. if(json==nil)
  1364. return nil;
  1365. NSError *error=nil;
  1366. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1367. return jsobj;
  1368. }
  1369. +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount
  1370. {
  1371. if(![self IsNetworkAvailable])
  1372. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1373. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1374. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1375. if(appDelegate.user!=nil)
  1376. [params setValue:appDelegate.user forKey:@"user"];
  1377. if(appDelegate.contact_id!=nil)
  1378. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1379. if(appDelegate.password!=nil)
  1380. [params setValue:appDelegate.password forKey:@"password"];
  1381. [params setValue:watchlist_id forKey:@"item_id"];
  1382. [params setValue:[NSString stringWithFormat:@"%f",price] forKey:@"price"];
  1383. [params setValue:[NSString stringWithFormat:@"%f",discount] forKey:@"discount"];
  1384. NSData* json=[self get_json:URL_PORTFOLIO_SET_PRICE parameters:params];
  1385. if(json==nil)
  1386. return nil;
  1387. NSError *error=nil;
  1388. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1389. return jsobj;
  1390. }
  1391. +(NSDictionary*) cart_setGeneralNote:(NSString*) order_code notes:(NSString*) notes
  1392. {
  1393. if(![self IsNetworkAvailable])
  1394. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1395. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1396. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1397. if(appDelegate.user!=nil)
  1398. [params setValue:appDelegate.user forKey:@"user"];
  1399. if(appDelegate.contact_id!=nil)
  1400. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1401. if(appDelegate.password!=nil)
  1402. [params setValue:appDelegate.password forKey:@"password"];
  1403. [params setValue:order_code forKey:@"orderCode"];
  1404. if(notes.length==0)
  1405. notes=@"";
  1406. [params setValue:notes forKey:@"comments"];
  1407. NSData* json=[self get_json:URL_CART_GENERAL_NOTES parameters:params];
  1408. if(json==nil)
  1409. return nil;
  1410. NSError *error=nil;
  1411. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1412. return jsobj;
  1413. }
  1414. +(NSDictionary*) cart_setItemNote:(NSString*) cart_id notes:(NSString*) notes
  1415. {
  1416. if(![self IsNetworkAvailable])
  1417. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1418. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1419. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1420. if(appDelegate.user!=nil)
  1421. [params setValue:appDelegate.user forKey:@"user"];
  1422. if(appDelegate.contact_id!=nil)
  1423. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1424. if(appDelegate.password!=nil)
  1425. [params setValue:appDelegate.password forKey:@"password"];
  1426. [params setValue:cart_id forKey:@"cartitem_id"];
  1427. if(notes.length==0)
  1428. notes=@"";
  1429. [params setValue:notes forKey:@"notes"];
  1430. NSData* json=[self get_json:URL_CART_ITEM_NOTES parameters:params];
  1431. if(json==nil)
  1432. return nil;
  1433. NSError *error=nil;
  1434. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1435. return jsobj;
  1436. }
  1437. +(NSDictionary*) cart_setFree:(NSString*) cart_id isfree:(bool) isfree
  1438. {
  1439. if(![self IsNetworkAvailable])
  1440. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1441. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1442. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1443. if(appDelegate.user!=nil)
  1444. [params setValue:appDelegate.user forKey:@"user"];
  1445. if(appDelegate.contact_id!=nil)
  1446. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1447. if(appDelegate.password!=nil)
  1448. [params setValue:appDelegate.password forKey:@"password"];
  1449. [params setValue:cart_id forKey:@"cartitem_id"];
  1450. NSString* free=nil;
  1451. if(isfree)
  1452. free=@"true";
  1453. else
  1454. free=@"false";
  1455. [params setValue:free forKey:@"free_giveaway"];
  1456. NSData* json=[self get_json:URL_CART_SET_PRICE parameters:params];
  1457. if(json==nil)
  1458. return nil;
  1459. NSError *error=nil;
  1460. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1461. return jsobj;
  1462. }
  1463. +(NSDictionary*) cart_setQTY:(NSString*) cart_id value:(int) value
  1464. {
  1465. if(![self IsNetworkAvailable])
  1466. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1467. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1468. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1469. if(appDelegate.user!=nil)
  1470. [params setValue:appDelegate.user forKey:@"user"];
  1471. if(appDelegate.contact_id!=nil)
  1472. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1473. if(appDelegate.password!=nil)
  1474. [params setValue:appDelegate.password forKey:@"password"];
  1475. [params setValue:cart_id forKey:@"cartitem_id"];
  1476. [params setValue:[NSString stringWithFormat:@"%d",value] forKey:@"inputInt"];
  1477. NSData* json=[self get_json:URL_CART_INCRESEMENT parameters:params];
  1478. if(json==nil)
  1479. return nil;
  1480. NSError *error=nil;
  1481. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1482. return jsobj;
  1483. }
  1484. +(NSDictionary*) cart_incresement:(NSString*) cart_id increse:(bool) increse
  1485. {
  1486. if(![self IsNetworkAvailable])
  1487. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1488. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1489. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1490. if(appDelegate.user!=nil)
  1491. [params setValue:appDelegate.user forKey:@"user"];
  1492. if(appDelegate.contact_id!=nil)
  1493. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1494. if(appDelegate.password!=nil)
  1495. [params setValue:appDelegate.password forKey:@"password"];
  1496. [params setValue:cart_id forKey:@"cartitem_id"];
  1497. if(increse)
  1498. [params setValue:@"1" forKey:@"incrementType"];
  1499. else
  1500. [params setValue:@"0" forKey:@"incrementType"];
  1501. NSData* json=[self get_json:URL_CART_INCRESEMENT parameters:params];
  1502. if(json==nil)
  1503. return nil;
  1504. NSError *error=nil;
  1505. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1506. return jsobj;
  1507. }
  1508. +(NSDictionary*)request_Cart
  1509. {
  1510. NSLog(@"iSalesNetwork::request_Cart");
  1511. if(![self IsNetworkAvailable])
  1512. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1513. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1514. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1515. if(appDelegate.user!=nil)
  1516. [params setValue:appDelegate.user forKey:@"user"];
  1517. // if(appDelegate.contact_id!=nil)
  1518. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1519. if(appDelegate.password!=nil)
  1520. [params setValue:appDelegate.password forKey:@"password"];
  1521. if(appDelegate.order_code!=nil)
  1522. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1523. NSData* json=[self get_json:URL_CART parameters:params];
  1524. if(json==nil)
  1525. return nil;
  1526. NSError *error=nil;
  1527. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1528. int result = [[jsobj valueForKey:@"result"] intValue];
  1529. if (result==2)
  1530. {
  1531. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1532. //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  1533. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1534. [appDelegate update_count_mark];
  1535. }
  1536. return jsobj;
  1537. }
  1538. +(NSDictionary*)request_Portfolio
  1539. {
  1540. if(![self IsNetworkAvailable])
  1541. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1542. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1543. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1544. if(appDelegate.user!=nil)
  1545. [params setValue:appDelegate.user forKey:@"user"];
  1546. if(appDelegate.contact_id!=nil)
  1547. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1548. if(appDelegate.password!=nil)
  1549. [params setValue:appDelegate.password forKey:@"password"];
  1550. [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
  1551. [params setValue:[NSString stringWithFormat:@"%d",9999 ] forKey:@"limit"];
  1552. NSData* json=[self get_json:URL_PORTFOLIO parameters:params];
  1553. if(json==nil)
  1554. return nil;
  1555. NSError *error=nil;
  1556. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1557. int result = [[jsobj valueForKey:@"result"] intValue];
  1558. if (result==2)
  1559. {
  1560. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1561. //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  1562. appDelegate.port_count =[[jsobj valueForKey:@"count"] intValue];
  1563. [appDelegate update_count_mark];
  1564. }
  1565. return jsobj;
  1566. }
  1567. +(NSDictionary*)request_WatchList
  1568. {
  1569. if(![self IsNetworkAvailable])
  1570. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1571. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1572. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1573. if(appDelegate.user!=nil)
  1574. [params setValue:appDelegate.user forKey:@"user"];
  1575. if(appDelegate.contact_id!=nil)
  1576. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1577. if(appDelegate.password!=nil)
  1578. [params setValue:appDelegate.password forKey:@"password"];
  1579. [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
  1580. [params setValue:[NSString stringWithFormat:@"%d",9999 ] forKey:@"limit"];
  1581. NSData* json=[self get_json:URL_WATCHLIST parameters:params];
  1582. if(json==nil)
  1583. return nil;
  1584. NSError *error=nil;
  1585. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1586. int result = [[jsobj valueForKey:@"result"] intValue];
  1587. if (result==2)
  1588. {
  1589. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1590. appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  1591. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1592. [appDelegate update_count_mark];
  1593. }
  1594. return jsobj;
  1595. }
  1596. +(NSDictionary*)request_ItemDetail: (NSString* ) item_id model_name:(NSString*) model_name category_id:(NSString*) category_id use_name :(bool) use_name
  1597. {
  1598. if(![self IsNetworkAvailable])
  1599. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1600. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1601. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1602. if(appDelegate.user!=nil)
  1603. [params setValue:appDelegate.user forKey:@"user"];
  1604. if(appDelegate.contact_id!=nil)
  1605. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1606. if(appDelegate.password!=nil)
  1607. [params setValue:appDelegate.password forKey:@"password"];
  1608. if(appDelegate.order_code!=nil)
  1609. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1610. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1611. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1612. if(use_name)
  1613. [params setValue:model_name forKey:@"product_name"];
  1614. else
  1615. [params setValue:item_id forKey:@"product_id"];
  1616. [params setValue:category_id forKey:@"category"];
  1617. if(appDelegate.offline_mode)
  1618. return [OLDataProvider offline_model:params];
  1619. NSData* json=[self get_json:URL_ITEM_DETAIL parameters:params];
  1620. if(json==nil)
  1621. return nil;
  1622. NSError *error=nil;
  1623. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1624. return jsobj;
  1625. }
  1626. //+(NSDictionary*)category_LoadMore: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(int)offset
  1627. //{
  1628. // if(![self IsNetworkAvailable])
  1629. // return nil;
  1630. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1631. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1632. // if(appDelegate.user!=nil)
  1633. // [params setValue:appDelegate.user forKey:@"user"];
  1634. // if(appDelegate.contact_id!=nil)
  1635. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1636. // if(appDelegate.password!=nil)
  1637. // [params setValue:appDelegate.password forKey:@"password"];
  1638. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1639. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1640. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1641. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1642. // [params setValue:[NSString stringWithFormat:@"%d",offset] forKey:@"offset"];
  1643. // [params setValue:filter forKey:@"filter"];
  1644. // [params setValue:keyword forKey:@"keyword"];
  1645. //
  1646. //
  1647. // NSData* json=[self get_json:URL_CATEGORY_LOADMORE parameters:params];
  1648. // if(json==nil)
  1649. // return nil;
  1650. // NSError *error=nil;
  1651. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1652. // return jsobj;
  1653. //
  1654. //}
  1655. +(NSDictionary*)Category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price
  1656. {
  1657. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1658. if(![self IsNetworkAvailable])
  1659. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1660. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1661. if(appDelegate.user!=nil)
  1662. [params setValue:appDelegate.user forKey:@"user"];
  1663. if(appDelegate.contact_id!=nil)
  1664. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1665. if(appDelegate.password!=nil)
  1666. [params setValue:appDelegate.password forKey:@"password"];
  1667. if(appDelegate.order_code!=nil)
  1668. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1669. [params setValue:alert forKey:@"alert"];
  1670. [params setValue:qty forKey:@"sold_by_qty"];
  1671. [params setValue:available forKey:@"available"];
  1672. [params setValue:price forKey:@"price"];
  1673. [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1674. [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1675. [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1676. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1677. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1678. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  1679. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  1680. [params setValue:filter forKey:@"filter"];
  1681. [params setValue:keyword forKey:@"keyword"];
  1682. if(appDelegate.offline_mode)
  1683. return [OLDataProvider offline_category:params];
  1684. NSData* json=[self get_json:URL_CATEGORY parameters:params];
  1685. if(json==nil)
  1686. return nil;
  1687. NSError *error=nil;
  1688. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1689. return jsobj;
  1690. }
  1691. +(NSDictionary*)Search:(long ) offset limit :(long)limit keywords :(NSString*) keywords
  1692. {
  1693. if(![self IsNetworkAvailable])
  1694. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1695. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1696. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1697. if(appDelegate.user!=nil)
  1698. [params setValue:appDelegate.user forKey:@"user"];
  1699. if(appDelegate.contact_id!=nil)
  1700. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1701. if(appDelegate.password!=nil)
  1702. [params setValue:appDelegate.password forKey:@"password"];
  1703. if(appDelegate.order_code!=nil)
  1704. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1705. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1706. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1707. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1708. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1709. // [params setValue:filter forKey:@"filter"];
  1710. [params setValue:keywords forKey:@"keyword"];
  1711. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  1712. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  1713. NSData* json=[self get_json:URL_SEARCH parameters:params];
  1714. if(json==nil)
  1715. return nil;
  1716. NSError *error=nil;
  1717. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1718. return jsobj;
  1719. }
  1720. +(NSDictionary*)ItemSearch:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert available:(NSString*)available
  1721. {
  1722. // for debug
  1723. // return [RAUtils error_json:RESULT_NET_ERROR err_msg:nil];
  1724. //return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1725. if(![self IsNetworkAvailable])
  1726. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1727. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1728. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1729. if(appDelegate.user!=nil)
  1730. [params setValue:appDelegate.user forKey:@"user"];
  1731. if(appDelegate.contact_id!=nil)
  1732. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1733. if(appDelegate.password!=nil)
  1734. [params setValue:appDelegate.password forKey:@"password"];
  1735. if(appDelegate.order_code!=nil)
  1736. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1737. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1738. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1739. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1740. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1741. // [params setValue:filter forKey:@"filter"];
  1742. [params setValue:covertype forKey:@"covertype"];
  1743. [params setValue:ctgid forKey:@"ctgId"];
  1744. [params setValue:modelname forKey:@"modelName"];
  1745. [params setValue:modeldescrip forKey:@"modelDescription"];
  1746. [params setValue:alert forKey:@"alert"];
  1747. [params setValue:available forKey:@"available"];
  1748. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  1749. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  1750. NSData* json=[self get_json:URL_ITEM_SEARCH parameters:params];
  1751. if(json==nil)
  1752. return nil;
  1753. NSError *error=nil;
  1754. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1755. return jsobj;
  1756. }
  1757. //+(NSDictionary*)Search: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword
  1758. //{
  1759. // if(![self IsNetworkAvailable])
  1760. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1761. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1762. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1763. // if(appDelegate.user!=nil)
  1764. // [params setValue:appDelegate.user forKey:@"user"];
  1765. // if(appDelegate.contact_id!=nil)
  1766. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1767. // if(appDelegate.password!=nil)
  1768. // [params setValue:appDelegate.password forKey:@"password"];
  1769. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1770. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1771. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1772. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1773. // [params setValue:filter forKey:@"filter"];
  1774. // [params setValue:keyword forKey:@"keyword"];
  1775. //
  1776. //
  1777. // NSData* json=[self get_json:URL_SEARCH parameters:params];
  1778. // if(json==nil)
  1779. // return nil;
  1780. // NSError *error=nil;
  1781. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1782. // return jsobj;
  1783. //}
  1784. +(NSDictionary*)retrieve_password: (NSString*) user email:(NSString*) email
  1785. {
  1786. if(![self IsNetworkAvailable])
  1787. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1788. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1789. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1790. // if(appDelegate.user!=nil)
  1791. // [params setValue:appDelegate.user forKey:@"user"];
  1792. // if(appDelegate.contact_id!=nil)
  1793. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1794. // if(appDelegate.password!=nil)
  1795. // [params setValue:appDelegate.password forKey:@"password"];
  1796. [params setValue:user forKey:@"username"];
  1797. [params setValue:email forKey:@"email"];
  1798. NSData* json=[self get_json:URL_RETRIEVE_PASS parameters:params];
  1799. if(json==nil)
  1800. return nil;
  1801. NSError *error=nil;
  1802. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1803. return jsobj;
  1804. }
  1805. +(NSDictionary*)load_HomePage:(int) price_template customid:(int) customid
  1806. {
  1807. if(![self IsNetworkAvailable])
  1808. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1809. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1810. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1811. if(appDelegate.user!=nil)
  1812. [params setValue:appDelegate.user forKey:@"user"];
  1813. if(appDelegate.contact_id!=nil)
  1814. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1815. if(appDelegate.password!=nil)
  1816. [params setValue:appDelegate.password forKey:@"password"];
  1817. [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1818. [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1819. NSData* json=[self get_json:URL_LOAD_HOME parameters:params];
  1820. if(json==nil)
  1821. return nil;
  1822. NSError *error=nil;
  1823. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1824. return jsobj;
  1825. }
  1826. +(NSDictionary*)logout
  1827. {
  1828. if(![self IsNetworkAvailable])
  1829. {
  1830. NSLog(@"NET ERR");
  1831. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1832. // return nil;
  1833. }
  1834. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1835. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1836. if(appDelegate.user!=nil)
  1837. [params setValue:appDelegate.user forKey:@"user"];
  1838. if(appDelegate.password!=nil)
  1839. [params setValue:appDelegate.password forKey:@"password"];
  1840. NSData* json=[self get_json:URL_LOGOUT parameters:params];
  1841. //if(json==nil)
  1842. if(json==nil)
  1843. return nil;
  1844. NSError *error=nil;
  1845. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1846. int result = [[jsobj valueForKey:@"result"] intValue];
  1847. if (result==2)
  1848. {
  1849. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1850. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1851. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1852. [appDelegate update_count_mark];
  1853. appDelegate.can_show_price =false;
  1854. appDelegate.can_see_price =false;
  1855. appDelegate.can_create_portfolio =false;
  1856. appDelegate.can_create_order =false;
  1857. appDelegate.can_cancel_order =false;
  1858. appDelegate.can_set_cart_price =false;
  1859. appDelegate.can_delete_order =false;
  1860. appDelegate.can_submit_order =false;
  1861. appDelegate.can_set_tearsheet_price =false;
  1862. appDelegate.can_update_contact_info = false;
  1863. appDelegate.save_order_logout = false;
  1864. appDelegate.submit_order_logout = false;
  1865. appDelegate.alert_sold_in_quantities = false;
  1866. appDelegate.ipad_perm =nil ;
  1867. appDelegate.user_type = USER_ROLE_UNKNOWN;
  1868. [appDelegate SetSo:nil];
  1869. [appDelegate set_main_button_panel];
  1870. }
  1871. return jsobj;
  1872. }
  1873. +(NSDictionary*)request_Cagegory
  1874. {
  1875. // NSLog(@"@@@@@@@@@@@@@@@@@@@LOADING CATEGORY MENU");
  1876. if(![self IsNetworkAvailable])
  1877. {
  1878. NSLog(@"NET ERR");
  1879. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1880. // return nil;
  1881. }
  1882. NSData* json=[self get_json:URL_REQUEST_CATMENU parameters:nil];
  1883. //if(json==nil)
  1884. if(json==nil)
  1885. return nil;
  1886. NSError *error=nil;
  1887. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1888. return jsobj;
  1889. }
  1890. +(int)Authorize : (NSString*) user password:(NSString*) password{
  1891. if(![self IsNetworkAvailable])
  1892. return RESULT_NET_NOTAVAILABLE;
  1893. // if(![ApexMobileNetwork IsHostAvailable:URL_UPDATE_AUTH])
  1894. // return RESULT_NET_ERROR;
  1895. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  1896. long ver =[defaults integerForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  1897. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1898. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1899. if(appDelegate.duid !=nil)
  1900. [params setValue:appDelegate.duid forKey:@"udid"];
  1901. [params setValue:@"handset_login" forKey:@"action"];
  1902. // [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
  1903. [params setValue:user forKey:@"user"];
  1904. [params setValue:password forKey:@"password"];
  1905. [params setValue:[NSString stringWithFormat:@"%ld",ver] forKey:@"auth_ver"];
  1906. #ifdef TEST
  1907. [params setValue:@"true" forKey:@"is_debug"];
  1908. #else
  1909. [params setValue:@"false" forKey:@"is_debug"];
  1910. #endif
  1911. NSData* json= nil;
  1912. if(appDelegate.offline_mode)
  1913. {
  1914. json= [NSJSONSerialization dataWithJSONObject:[OLDataProvider offline_login:params] options:kNilOptions error:nil];
  1915. }
  1916. else
  1917. {
  1918. json =[self get_json:URL_UPDATE_AUTH parameters:params];
  1919. }
  1920. if(json==nil)
  1921. return RESULT_NET_ERROR;
  1922. int ret = [self parse_authinfo:json user:user password:password];
  1923. DebugLog(@"parse_authinfo return %d ",ret);
  1924. return ret;
  1925. }
  1926. +(NSDictionary*)update_customer_img: (NSString*) contactid img_url:(NSString*) url
  1927. {
  1928. if(![self IsNetworkAvailable])
  1929. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1930. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1931. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1932. if(appDelegate.user!=nil)
  1933. [params setValue:appDelegate.user forKey:@"user"];
  1934. // if(appDelegate.contact_id!=nil)
  1935. if(appDelegate.password!=nil)
  1936. [params setValue:appDelegate.password forKey:@"password"];
  1937. [params setValue:contactid forKey:@"contactId"];
  1938. [params setValue:url forKey:@"business_card"];
  1939. // [params setValue:[NSNumber numberWithInt:index ] forKey:@"index"];
  1940. NSData* json=[self get_json:URL_UPDATE_CUSTOMER_BCARD parameters:params];
  1941. if(json==nil)
  1942. return nil;
  1943. NSError *error=nil;
  1944. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1945. return jsobj;
  1946. }
  1947. +(NSDictionary*)request_PendingOrder:(NSString *)contactid
  1948. {
  1949. if(![self IsNetworkAvailable])
  1950. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1951. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1952. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1953. if(appDelegate.user!=nil)
  1954. [params setValue:appDelegate.user forKey:@"user"];
  1955. // if(appDelegate.contact_id!=nil)
  1956. if(appDelegate.password!=nil)
  1957. [params setValue:appDelegate.password forKey:@"password"];
  1958. [params setValue:contactid forKey:@"contactId"];
  1959. NSData* json=[self get_json:URL_CUSTOMER_PENDINGORDER parameters:params];
  1960. if(json==nil)
  1961. return nil;
  1962. NSError *error=nil;
  1963. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1964. return jsobj;
  1965. }
  1966. +(NSDictionary*)request_CustomerInfo:(NSString* ) contactid
  1967. {
  1968. if(![self IsNetworkAvailable])
  1969. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1970. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1971. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1972. if(appDelegate.user!=nil)
  1973. [params setValue:appDelegate.user forKey:@"user"];
  1974. // if(appDelegate.contact_id!=nil)
  1975. if(appDelegate.password!=nil)
  1976. [params setValue:appDelegate.password forKey:@"password"];
  1977. [params setValue:contactid forKey:@"contactId"];
  1978. NSData* json=[self get_json:URL_CUSTOMER_INFO parameters:params];
  1979. if(json==nil)
  1980. return nil;
  1981. NSError *error=nil;
  1982. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1983. return jsobj;
  1984. }
  1985. +(int)parse_authinfo : (NSData *) json user:(NSString*) user password:(NSString*) password
  1986. {
  1987. DebugLog(@"parse_authinfo");
  1988. NSError *error=nil;
  1989. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1990. if(jsobj)
  1991. {
  1992. UIApplication * app = [UIApplication sharedApplication];
  1993. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1994. int result = [[jsobj valueForKey:@"result"] intValue];
  1995. if (result<0)
  1996. return result;
  1997. if(result!=AP_USER_AUTH&& result!=9)
  1998. {
  1999. DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
  2000. [appDelegate Logout];
  2001. return RESULT_FALSE;
  2002. }
  2003. NSDictionary* objheader = [jsobj objectForKey:@"header"];
  2004. NSString* required_ver=[jsobj objectForKey:@"min_ver"] ;
  2005. user=[objheader objectForKey:@"username"] ;
  2006. DebugLog(@"required_ver=%@ ",required_ver);
  2007. // NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  2008. // NSString* versionNum =[infoDict valueForKey:@"CFBundleVersion"];
  2009. // versionNum = [NSString stringWithFormat:@"A%@",versionNum];
  2010. int ibadge = [[objheader valueForKey:@"badge"] intValue];
  2011. // if([ibadge isEqual:[NSNull null]])
  2012. // strbadge=@"0";
  2013. // if(ibadge==nil)
  2014. // ibadge=@"0";
  2015. // if([strbadge isEqualToString:@"null"])
  2016. // strbadge=@"0";
  2017. app.applicationIconBadgeNumber = ibadge;//[strbadge intValue];
  2018. // BOOL bigger = [appDelegate.build compare:required_ver] ;
  2019. if([appDelegate.build intValue]<[required_ver intValue])
  2020. return RESULT_VER_LOW;
  2021. // appDelegate.sessionid = [objheader valueForKey:@"sessionid"];
  2022. appDelegate.user = user;
  2023. appDelegate.password = password;
  2024. appDelegate.user_type = [[objheader valueForKey:@"user_type"] intValue];
  2025. appDelegate.user_icon =[objheader valueForKey:@"user_img"] ;
  2026. appDelegate.bLogin = true;
  2027. if(appDelegate.user_type==USER_ROLE_CUSTOMER)
  2028. {
  2029. appDelegate.customerInfo = [objheader objectForKeyedSubscript:@"customerInfo"];
  2030. appDelegate.contact_id = [objheader valueForKey:@"customer_cid"];
  2031. appDelegate.order_code =[objheader valueForKey:@"orderCode"];
  2032. }
  2033. NSString* mode =[jsobj valueForKey:@"mode"] ;
  2034. [appDelegate SetMode:mode];
  2035. appDelegate.cart_count = [[objheader valueForKey:@"cart_count"] intValue];
  2036. appDelegate.wish_count =[[objheader valueForKey:@"wish_count"] intValue];
  2037. appDelegate.port_count =[[objheader valueForKey:@"portfolio_count"] intValue];
  2038. [appDelegate update_count_mark];
  2039. appDelegate.can_show_price =[[objheader valueForKey:@"can_show_price"] boolValue];
  2040. appDelegate.can_see_price =[[objheader valueForKey:@"can_see_price"] boolValue];
  2041. appDelegate.can_create_portfolio =[[objheader valueForKey:@"can_create_portfolio"] boolValue];
  2042. appDelegate.can_create_order =[[objheader valueForKey:@"can_create_order"] boolValue];
  2043. appDelegate.can_cancel_order =[[objheader valueForKey:@"can_cancel_order"] boolValue];
  2044. appDelegate.can_set_cart_price =[[objheader valueForKey:@"can_set_cart_price"] boolValue];
  2045. appDelegate.can_delete_order =[[objheader valueForKey:@"can_delete_order"] boolValue];
  2046. appDelegate.can_update_contact_info =[[objheader valueForKey:@"can_update_contact_info"] boolValue];
  2047. appDelegate.can_submit_order =[[objheader valueForKey:@"can_submit_order"] boolValue];
  2048. appDelegate.can_set_tearsheet_price =[[objheader valueForKey:@"can_set_tearsheet_price"] boolValue];
  2049. appDelegate.save_order_logout =[[objheader valueForKey:@"save_order_logout"] boolValue];
  2050. appDelegate.submit_order_logout =[[objheader valueForKey:@"submit_order_logout"] boolValue];
  2051. appDelegate.alert_sold_in_quantities = [[objheader valueForKey:@"alert_sold_in_quantities"] boolValue];
  2052. appDelegate.ipad_perm =[objheader valueForKey:@"ipad_perm"] ;
  2053. [appDelegate set_main_button_panel];
  2054. // DebugLog(@"sessionid=%@ ",appDelegate.sessionid);
  2055. // if ([[objheader valueForKey:@"update"] boolValue]==false)
  2056. // {
  2057. // // no update on the server;
  2058. // return RESULT_TRUE;
  2059. // }
  2060. // int Auth_InfoVer = [[objheader valueForKey:@"ver"] intValue];
  2061. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  2062. // [defaults removeObjectForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  2063. // [defaults setInteger:Auth_InfoVer forKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  2064. // [defaults synchronize];
  2065. //
  2066. // NSDictionary* objfuncs = [jsobj objectForKey:@"functions"];
  2067. // NSArray* keys= [objfuncs allKeys];
  2068. /*
  2069. db.setTransactionSuccessful();
  2070. db.endTransaction();
  2071. */
  2072. return RESULT_TRUE;
  2073. }
  2074. // NSDictionary *weatherInfo = [jsobj objectForKey:@"weatherinfo"];
  2075. // txtView.text = [NSString stringWithFormat:@"今天是 %@ %@ %@ 的天气状况是:%@ %@ ",[weatherInfo objectForKey:@"date_y"],[weatherInfo objectForKey:@"week"],[weatherInfo objectForKey:@"city"], [weatherInfo objectForKey:@"weather1"], [weatherInfo objectForKey:@"temp1"]];
  2076. // DebugLog(@"weatherInfo字典里面的内容为--》%@", weatherDic );
  2077. return RESULT_USERAUTH_ERROR;
  2078. }
  2079. +(bool) IsNetworkAvailable
  2080. {
  2081. if (([Reachability reachabilityForInternetConnection].currentReachabilityStatus == NotReachable) &&
  2082. ([Reachability reachabilityForLocalWiFi].currentReachabilityStatus == NotReachable))
  2083. return false;
  2084. return true;
  2085. }
  2086. //+(NSString *)flattenHTML:(NSString *)html trimWhiteSpace:(BOOL)trim
  2087. //{
  2088. // NSScanner *theScanner = [NSScanner scannerWithString:html];
  2089. // NSString *text = nil;
  2090. //
  2091. // while ([theScanner isAtEnd] == NO) {
  2092. // // find start of tag
  2093. // [theScanner scanUpToString:@"<" intoString:NULL] ;
  2094. // // find end of tag
  2095. // [theScanner scanUpToString:@">" intoString:&text] ;
  2096. // // replace the found tag with a space
  2097. // //(you can filter multi-spaces out later if you wish)
  2098. // html = [html stringByReplacingOccurrencesOfString:
  2099. // [ NSString stringWithFormat:@"%@>", text]
  2100. // withString:@""];
  2101. // }
  2102. //
  2103. // return trim ? [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] : html;
  2104. //}
  2105. //
  2106. //+(NSString *)flattenURL:(NSString *)url trimWhiteSpace:(BOOL)trim
  2107. //{
  2108. // NSScanner *theScanner = [NSScanner scannerWithString:url];
  2109. // NSString *text = nil;
  2110. //
  2111. // while ([theScanner isAtEnd] == NO) {
  2112. // // find start of tag
  2113. // [theScanner scanUpToString:@"/" intoString:NULL] ;
  2114. // // find end of tag
  2115. // [theScanner scanUpToString:@"/" intoString:&text] ;
  2116. // // replace the found tag with a space
  2117. // //(you can filter multi-spaces out later if you wish)
  2118. // url = [url stringByReplacingOccurrencesOfString:
  2119. // [ NSString stringWithFormat:@"%@", text]
  2120. // withString:@""];
  2121. // }
  2122. //
  2123. // return trim ? [url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] : url;
  2124. //}
  2125. @end