protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.ChatLayout); //LISTVIEW mListView = FindViewById<ListView> (Resource.Id.listViewBox); mItems = new List<TableMessages> (); string dbPath = System.IO.Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), "ormDMS.db3"); var db = new SQLiteConnection (dbPath); DBRepository dbr = new DBRepository (); var table = db.Query<TableMessages> ("SELECT * FROM TableMessages where codeChauffeur=?",Data.userAndsoft); var i = 0; foreach (var item in table) { mItems.Add (new TableMessages () { texteMessage = item.texteMessage, utilisateurEmetteur = item.utilisateurEmetteur, statutMessage = item.statutMessage, dateImportMessage = item.dateImportMessage, typeMessage = item.typeMessage, Id = item.Id }); i++; } if(i > 6){ View view = LayoutInflater.From (this).Inflate (Resource.Layout.ListeViewDelete, null, false); mListView.AddHeaderView (view); view.Click += Btndeletemsg_Click; } adapter = new ListeViewMessageAdapter (this, mItems); mListView.Adapter = adapter; //EDITTEXT var btnsend = FindViewById<LinearLayout>(Resource.Id.btn_send); btnsend.Click += Btnsend_Click; //STATUT DES MESSAGES RECU TO 1 var tablemsgrecu = db.Query<TableMessages> ("SELECT * FROM TableMessages where statutMessage = 0"); foreach (var item in tablemsgrecu) { var updatestatutmessage = db.Query<TableMessages> ("UPDATE TableMessages SET statutMessage = 1 WHERE statutMessage = 0"); var resintegstatut = dbr.InsertDataStatutMessage (1,DateTime.Now,item.numMessage,"",""); } }
public override void OnStart (Android.Content.Intent intent, int startId) { base.OnStart (intent, startId); DBRepository dbr = new DBRepository (); userAndsoft = dbr.getUserAndsoft (); userTransics = dbr.getUserTransics (); var t = DateTime.Now.ToString("dd_MM_yy"); string dir_log = (Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads)).ToString(); ISharedPreferences pref = Application.Context.GetSharedPreferences("AppInfo", FileCreationMode.Private); string log = pref.GetString("Log", String.Empty); //GetTelId TelephonyManager tel = (TelephonyManager)this.GetSystemService(Context.TelephonyService); var telId = tel.DeviceId; //Si il n'y a pas de shared pref if (log == String.Empty){ log_file = Path.Combine (dir_log, t+"_"+telId+"_log.txt"); ISharedPreferencesEditor edit = pref.Edit(); edit.PutString("Log",log_file); edit.Apply(); }else{ //il y a des shared pref log_file = pref.GetString("Log", String.Empty); if (((File.GetCreationTime(log_file)).CompareTo(DateTime.Now)) > 3) { File.Delete(log_file); log_file = Path.Combine (dir_log, t+"_"+telId+"_log.txt"); ISharedPreferencesEditor edit = pref.Edit(); edit.PutString("Log",log_file); edit.Apply(); log_file = pref.GetString("Log", String.Empty); } } File.AppendAllText(log_file,"[SERVICE] Service Onstart call "+DateTime.Now.ToString("t")+"\n"); DoStuff (); // initialize location manager locMgr = GetSystemService (Context.LocationService) as LocationManager; if (locMgr.AllProviders.Contains (LocationManager.NetworkProvider) && locMgr.IsProviderEnabled (LocationManager.NetworkProvider)) { locMgr.RequestLocationUpdates (LocationManager.NetworkProvider, 2000, 1, this); File.AppendAllText(log_file,"[GPS] Lancer le"+DateTime.Now.ToString("t")+"\n"); } else { File.AppendAllText(log_file,"[GPS] Le GPS est désactiver"+DateTime.Now.ToString("t")+"\n"); } }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView(Resource.Layout.Anomalie); id = Intent.GetStringExtra ("ID"); i = int.Parse(id); type = Intent.GetStringExtra ("TYPE"); DBRepository dbr = new DBRepository (); data = dbr.GetPositionsData (i); Spinner spinner = FindViewById<Spinner> (Resource.Id.spinnerAnomalie); EdittxtRem = FindViewById<EditText>(Resource.Id.edittext); _imageView = FindViewById<ImageView>(Resource.Id.imageView1); Button buttonvalider = FindViewById<Button>(Resource.Id.valider); if (IsThereAnAppToTakePictures ()) { CreateDirectoryForPictures (); Button buttonphoto = FindViewById<Button>(Resource.Id.openCamera); _imageView = FindViewById<ImageView>(Resource.Id.imageView1); buttonphoto.Click += TakeAPicture; } buttonvalider.Click += delegate { Buttonvalider_Click(); }; ; spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected); ArrayAdapter adapter; if (type == "RAM") { adapter = ArrayAdapter.CreateFromResource (this, Resource.Array.anomalieramasselist, Android.Resource.Layout.SimpleSpinnerItem); } else { adapter = ArrayAdapter.CreateFromResource (this, Resource.Array.anomalielivraisonlist, Android.Resource.Layout.SimpleSpinnerItem); } adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner.Adapter = adapter; //REMISE à null de la valeur photo }
void btn_Login_Click () { if (!(user.Text == "")) { //INSTANCE DBREPOSITORY DBRepository dbr = new DBRepository (); var usercheck = dbr.user_Check (user.Text.ToUpper(), password.Text); if (usercheck) { //UPDATE DE LA BDD AVEC CE USER AndHUD.Shared.ShowSuccess(this, "Bienvenue", MaskType.Black, TimeSpan.FromSeconds(2)); dbr.setUserdata (user.Text.ToUpper ()); StartActivity(typeof(HomeActivity)); } else { AndHUD.Shared.ShowError(this, "Mauvais mot de passe", MaskType.Black, TimeSpan.FromSeconds(2)); } } else { AndHUD.Shared.ShowError(this, "Champ user obligatoire", MaskType.Black, TimeSpan.FromSeconds(2)); } }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); id = Intent.GetStringExtra ("ID"); i = int.Parse(id); type = Intent.GetStringExtra ("TYPE"); if (type == "RAM") { tyValide = "RAMCFM"; } else { tyValide = "LIVCFM"; } DBRepository dbr = new DBRepository (); data = dbr.GetPositionsData (i); idprev = dbr.GetidPrev (i); idnext = dbr.GetidNext (i); SetContentView(Resource.Layout.DetailPosition); _gestureDetector = new GestureDetector(this); //AFFICHE DATA codelivraison = FindViewById<TextView>(Resource.Id.codelivraison); commande = FindViewById<TextView>(Resource.Id.commande); infolivraison = FindViewById<TextView>(Resource.Id.infolivraison); title = FindViewById<TextView>(Resource.Id.title); infosupp = FindViewById<TextView>(Resource.Id.infosupp); infoclient = FindViewById<TextView>(Resource.Id.infoclient); client = FindViewById<TextView>(Resource.Id.client); anomaliet = FindViewById<TextView> (Resource.Id.anomaliet); anomalie = FindViewById<TextView> (Resource.Id.infoanomalie); destfinal = FindViewById<TextView> (Resource.Id.destfinal); _imageView = FindViewById<ImageView> (Resource.Id._imageView); btnvalide = FindViewById<Button> (Resource.Id.valide); Button btnanomalie = FindViewById <Button> (Resource.Id.anomalie); btnvalide.Click += Btnvalide_Click; btnanomalie.Click += Btnanomalie_Click; }
void Btnsend_Click (object sender, EventArgs e){ DBRepository dbr = new DBRepository (); var newmessage = FindViewById<TextView>(Resource.Id.editnewmsg); if (newmessage.Text == "") { } else { var resinteg = dbr.InsertDataMessage (Data.userAndsoft,"", newmessage.Text,2, DateTime.Now, 2,0); } string dbPath = System.IO.Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), "ormDMS.db3"); var db = new SQLiteConnection (dbPath); Intent intent = new Intent (this, typeof(MessageActivity)); this.StartActivity (intent); this.OverridePendingTransition (Resource.Animation.abc_slide_in_bottom,Resource.Animation.abc_slide_out_top); }
protected override void OnResume () { base.OnResume (); Task startupWork = new Task (() => { //INSTANCE DBREPOSITORY DBRepository dbr = new DBRepository (); //CREATION DE LA BDD dbr.CreateDB (); //CREATION DES TABLES dbr.CreateTable (); //TEST DE CONNEXION var connectivityManager = (ConnectivityManager)GetSystemService (ConnectivityService); var t = DateTime.Now.ToString ("dd_MM_yy"); string dir_log = (Android.OS.Environment.GetExternalStoragePublicDirectory (Android.OS.Environment.DirectoryDownloads)).ToString (); //Shared Preference ISharedPreferences pref = Application.Context.GetSharedPreferences ("AppInfo", FileCreationMode.Private); string log = pref.GetString ("Log", String.Empty); //GetTelId TelephonyManager tel = (TelephonyManager)this.GetSystemService (Context.TelephonyService); var telId = tel.DeviceId; //Si il n'y a pas de shared pref if (log == String.Empty) { Data.log_file = Path.Combine (dir_log, t + "_" + telId + "_log.txt"); ISharedPreferencesEditor edit = pref.Edit (); edit.PutString ("Log", Data.log_file); edit.Apply (); } else { //il y a des shared pref Data.log_file = pref.GetString ("Log", String.Empty); if (((File.GetCreationTime (Data.log_file)).CompareTo (DateTime.Now)) > 3) { File.Delete (Data.log_file); Data.log_file = Path.Combine (dir_log, t + "_" + telId + "_log.txt"); ISharedPreferencesEditor edit = pref.Edit (); edit.PutString ("Log", Data.log_file); edit.Apply (); Data.log_file = pref.GetString ("Log", String.Empty); } } File.AppendAllText (Data.log_file, "[LAUNCH] DMS lancée le " + DateTime.Now.ToString ("F") + "\n"); bool App_Connec = false; while (!App_Connec) { var activeConnection = connectivityManager.ActiveNetworkInfo; if ((activeConnection != null) && activeConnection.IsConnected) { try { string _url = "http://dms.jeantettransport.com/api/authen?chaufmdp="; var webClient = new WebClient (); webClient.Headers [HttpRequestHeader.ContentType] = "application/json"; string userData = ""; userData = webClient.DownloadString (_url); System.Console.WriteLine ("\n Webclient User Terminé ..."); //GESTION DU XML JsonArray jsonVal = JsonArray.Parse (userData) as JsonArray; var jsonArr = jsonVal; foreach (var row in jsonArr) { var checkUser = dbr.user_AlreadyExist (row ["userandsoft"], row ["usertransics"], row ["mdpandsoft"], "true"); Console.WriteLine ("\n" + checkUser + " " + row ["userandsoft"]); if (!checkUser) { var IntegUser = dbr.InsertDataUser (row ["userandsoft"], row ["usertransics"], row ["mdpandsoft"], "true"); Console.WriteLine ("\n" + IntegUser); } } App_Connec = true; } catch (System.Exception ex) { System.Console.WriteLine (ex); Insights.Report (ex); App_Connec = false; AndHUD.Shared.ShowError (this, "Une erreur c'est produite lors du lancement, réessaie dans 5 secondes", MaskType.Black, TimeSpan.FromSeconds (5)); } } else { App_Connec = false; //AndHUD.Shared.ShowError(this, "Pas de connexion, réessaie dans 5 secondes", MaskType.Black, TimeSpan.FromSeconds(5)); Toast.MakeText (this, "Pas de connexion", ToastLength.Long).Show (); Thread.Sleep (5000); } } }); startupWork.ContinueWith (t => { //Is a user login ? DBRepository dbr = new DBRepository (); var user_Login = dbr.is_user_Log_In (); if (!(user_Login == string.Empty)) { //Data.userAndsoft = user_Login; dbr.setUserdata (user_Login); File.AppendAllText (Data.log_file, "Connexion de " + Data.userAndsoft + " à " + DateTime.Now.ToString ("t") + "\n"); StartActivity (new Intent (Application.Context, typeof(HomeActivity))); } else { StartActivity (new Intent (Application.Context, typeof(MainActivity))); } }, TaskScheduler.FromCurrentSynchronizationContext ()); startupWork.Start (); }
void ComPosNotifMsg () { //recupération des messages webservice //insertion en base //recupation des messages / notifications / POS GPS //Post sur le webservice //maj du badge //API GPS OK string _url = "http://dms.jeantettransport.com/api/WSV3"; string dbPath = System.IO.Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), "ormDMS.db3"); var db = new SQLiteConnection (dbPath); DBRepository dbr = new DBRepository (); var webClient = new WebClient (); try { string content_msg = String.Empty; //ROUTINE INTEG MESSAGE try { //API LIVRER OK string _urlb = "http://dms.jeantettransport.com/api/WSV3?codechauffeur=" + userAndsoft +""; var webClientb = new WebClient (); webClientb.Headers [HttpRequestHeader.ContentType] = "application/json"; //webClient.Encoding = Encoding.UTF8; content_msg = webClientb.DownloadString (_urlb); } catch (Exception ex) { content_msg = "[]"; Insights.Report (ex,Xamarin.Insights.Severity.Error); } if (content_msg != "[]") { JsonArray jsonVal = JsonArray.Parse (content_msg) as JsonArray; var jsonarr = jsonVal; foreach (var item in jsonarr) { if (item["texteMessage"].ToString().Length < 9) { var resinteg = dbr.InsertDataMessage (item ["codeChauffeur"], item ["utilisateurEmetteur"], item ["texteMessage"],0,DateTime.Now,1,item ["numMessage"]); var resintegstatut = dbr.InsertDataStatutMessage(0,DateTime.Now,item ["numMessage"],"",""); alertsms (); }else{ switch(item ["texteMessage"].ToString().Substring(1,9)) { case "%%SUPPLIV": var updatestat = dbr.updatePositionSuppliv((item ["texteMessage"].ToString()).Remove((item ["texteMessage"].ToString()).Length - 3).Substring(11)); dbr.InsertDataStatutMessage (1,DateTime.Now,item ["numMessage"],"",""); dbr.InsertDataMessage (item ["codeChauffeur"], item ["utilisateurEmetteur"],"La position "+(item ["texteMessage"].ToString()).Remove((item ["texteMessage"].ToString()).Length - 3).Substring(11)+" a été supprimée de votre tournée",0,DateTime.Now,1, item ["numMessage"]); File.AppendAllText(log_file,"["+DateTime.Now.ToString("t")+"]"+"[SYSTEM]Réception d'un SUPPLIV à "+DateTime.Now.ToString("t")+"\n"); break; case "%%RETOLIV": var updatestattretour = db.Query<TablePositions>("UPDATE TablePositions SET imgpath = null WHERE numCommande = ?",(item ["texteMessage"].ToString()).Remove((item ["texteMessage"].ToString()).Length - 3).Substring(11)); var resstatutbis = dbr.InsertDataStatutMessage (1,DateTime.Now,item ["numMessage"],"",""); break; case "%%SUPPGRP": var supgrp = db.Query<TablePositions>("DELETE from TablePositions where groupage = ?",(item ["texteMessage"].ToString()).Remove((item ["texteMessage"].ToString()).Length - 3).Substring(11)); var ressupgrp = dbr.InsertDataStatutMessage (1,DateTime.Now,item ["numMessage"],"",""); break; case "%%GETFLOG": //ftp://77.158.93.75 or ftp://10.1.2.75 File.AppendAllText(log_file,"["+DateTime.Now.ToString("t")+"]"+"[SYSTEM]Réception d'un GETFLOG à "+DateTime.Now.ToString("t")+"\n"); Thread thread = new Thread(() => UploadFile("ftp://77.158.93.75",Data.log_file,"DMS","Linuxr00tn","")); thread.Start (); dbr.InsertDataStatutMessage(0,DateTime.Now,item ["numMessage"],"",""); break; case "%%COMMAND": File.AppendAllText(log_file,"["+DateTime.Now.ToString("t")+"]"+"[SYSTEM]Réception d'un COMMAND à "+DateTime.Now.ToString("t")+"\n"); InsertData (); break; default: var resinteg = dbr.InsertDataMessage (item ["codeChauffeur"], item ["utilisateurEmetteur"], item ["texteMessage"],0,DateTime.Now,1,item ["numMessage"]); dbr.InsertDataStatutMessage(0,DateTime.Now,item ["numMessage"],"",""); alertsms (); Console.WriteLine (item ["numMessage"].ToString()); Console.WriteLine (resinteg); break; } } } } //SET des badges dbr.SETBadges(Data.userAndsoft); String datajson = string.Empty; String datagps=string.Empty; String datamsg=string.Empty; String datanotif=string.Empty; datagps = "{\"posgps\":\"" + GPS + "\",\"userandsoft\":\"" + userAndsoft + "\"}"; var tablestatutmessage = db.Query<TableNotifications> ("SELECT * FROM TableNotifications"); //SEND NOTIF foreach (var item in tablestatutmessage) { datanotif += "{\"statutNotificationMessage\":\"" + item.statutNotificationMessage + "\",\"dateNotificationMessage\":\"" + item.dateNotificationMessage + "\",\"numMessage\":\""+item.numMessage+"\",\"numCommande\":\""+item.numCommande+"\",\"groupage\":\""+item.groupage+"\"},"; } //SEND MESSAGE var tablemessage = db.Query<TableMessages> ("SELECT * FROM TableMessages WHERE statutMessage = 2"); foreach (var item in tablemessage) { datamsg += "{\"codeChauffeur\":\"" + item.codeChauffeur + "\",\"texteMessage\":\"" + item.texteMessage + "\",\"utilisateurEmetteur\":\""+item.utilisateurEmetteur+"\",\"dateImportMessage\":\""+item.dateImportMessage+"\",\"typeMessage\":\""+item.typeMessage+"\"},"; } if(datanotif == ""){ datanotif ="{}"; }else{ datanotif = datanotif.Remove(datanotif.Length - 1); } if(datamsg == ""){ datamsg ="{}"; }else{ datamsg = datamsg.Remove(datamsg.Length - 1); } datajson = "{\"suivgps\":"+datagps+",\"statutmessage\":["+datanotif+"],\"Message\":["+datamsg+"]}"; //API MSG/NOTIF/GPS try{ webClient.Headers [HttpRequestHeader.ContentType] = "application/json"; webClient.UploadString (_url,datajson); foreach (var item in tablestatutmessage) { var resultdelete = dbr.deletenotif(item.Id); } foreach (var item in tablemessage) { var updatestatutmessage = db.Query<TableMessages> ("UPDATE TableMessages SET statutMessage = 3 WHERE _Id = ?",item.Id); } } catch (Exception e) { Insights.Report (e,Xamarin.Insights.Severity.Error); File.AppendAllText(log_file,"["+DateTime.Now.ToString("t")+"]"+"[ERROR] POSTMSG/NOTIF/GPS : "+e+" à "+DateTime.Now.ToString("t")+"\n"); } } catch (Exception ex) { Insights.Report (ex,Xamarin.Insights.Severity.Error); Console.Out.Write(ex); File.AppendAllText(log_file,"["+DateTime.Now.ToString("t")+"]"+"[ERROR] ComPosNotifMsg : "+ex+" à "+DateTime.Now.ToString("t")+"\n"); } Console.WriteLine ("\nTask ComPosGps done"); }
void InsertData () { string dbPath = System.IO.Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.Personal), "ormDMS.db3"); var db = new SQLiteConnection(dbPath); DBRepository dbr = new DBRepository (); datedujour = DateTime.Now.ToString("yyyyMMdd"); //récupération de donnée via le webservice string content_integdata = String.Empty; try { string _url = "http://dms.jeantettransport.com/api/commandeWSV3?codechauffeur=" + userTransics + "&datecommande=" + datedujour + ""; var webClient = new WebClient (); webClient.Headers [HttpRequestHeader.ContentType] = "application/json"; content_integdata = webClient.DownloadString (_url); Console.Out.WriteLine ("\nWebclient integdata Terminé"); //intégration des données dans la BDD JsonArray jsonVal = JsonArray.Parse (content_integdata) as JsonArray; var jsonArr = jsonVal; if (content_integdata != "[]") { foreach (var row in jsonArr) { bool checkpos = dbr.pos_AlreadyExist(row["numCommande"],row["groupage"]); if (!checkpos) { var IntegUser = dbr.InsertDataPosition(row["codeLivraison"],row["numCommande"],row["refClient"],row["nomPayeur"],row["nomExpediteur"],row["adresseExpediteur"],row["villeExpediteur"],row["CpExpediteur"],row["dateExpe"],row["nomClient"],row["adresseLivraison"],row["villeLivraison"],row["CpLivraison"],row["dateHeure"],row["poids"],row["nbrPallette"],row["nbrColis"],row["instrucLivraison"],row["typeMission"],row["typeSegment"],row["groupage"],row["ADRCom"],row["ADRGrp"],"0",row["CR"],DateTime.Now.Day,row["Datemission"],row["Ordremission"],row["planDeTransport"],userAndsoft,row["nomClientLivraison"],row["villeClientLivraison"],null); var resintegstatut = dbr.InsertDataStatutMessage (10,DateTime.Now,1,row["numCommande"],row["groupage"]); Console.WriteLine ("\n"+IntegUser); File.AppendAllText(log_file,"["+DateTime.Now.ToString("t")+"][TASK]Intégration d'une position "+IntegUser+" à "+DateTime.Now.ToString("t")+"\n"); } } } //SON if (content_integdata == "[]") { } else { alert (); } } catch (Exception ex) { content_integdata = "[]"; Console.WriteLine ("\n"+ex); File.AppendAllText(log_file,"[ERROR] InserData : "+ex+" à "+DateTime.Now.ToString("t")+"\n"); Insights.Report(ex); } //SET des badges dbr.SETBadges(Data.userAndsoft); //maj des badges fonctions //TODO //verification des groupages et suppression des cloturer //select des grp's string content_grpcloture = String.Empty; var tablegroupage = db.Query<TablePositions> ("SELECT groupage FROM TablePositions group by groupage"); foreach (var row in tablegroupage) { string numGroupage = row.groupage; try { string _urlb = "http://dms.jeantettransport.com/api/groupage?voybdx="+ numGroupage+""; var webClient = new WebClient (); webClient.Headers [HttpRequestHeader.ContentType] = "application/json"; content_grpcloture = webClient.DownloadString (_urlb); JsonValue jsonVal = JsonObject.Parse(content_grpcloture); //JsonArray jsonVal = JsonArray.Parse (content_grpcloture) as JsonArray; //var jsonArr = jsonVal; if (jsonVal["etat"].ToString() == "\"CLO\""){ //suppression du groupage en question si clo var suppgrp = dbr.supp_grp(numGroupage); } } catch (Exception ex) { content_grpcloture = "[]"; Console.WriteLine ("\n"+ex); Insights.Report(ex); File.AppendAllText(log_file,"["+DateTime.Now.ToString("t")+"]"+"[ERROR] Cloture : "+ex+" à "+DateTime.Now.ToString("t")+"\n"); } } Console.WriteLine ("\nTask InsertData done"); //File.AppendAllText(Data.log_file, "Task InsertData done"+DateTime.Now.ToString("t")+"\n"); }
void Btnvalide_Click (object sender, EventArgs e) { DBRepository dbr = new DBRepository (); dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); //afficher le cr si CR //cheque //afficher le champ mémo var viewAD = this.LayoutInflater.Inflate (Resource.Layout.valideDialBox, null); var check1 = viewAD.FindViewById<RadioButton> (Resource.Id.radioButton1); var check2 = viewAD.FindViewById<RadioButton> (Resource.Id.radioButton2); var checkP = viewAD.FindViewById<CheckBox> (Resource.Id.checkBox1); var txtCR = viewAD.FindViewById<TextView> (Resource.Id.textcr); EditText mémo = viewAD.FindViewById<EditText>(Resource.Id.edittext); if (data.CR == "" || data.CR == "0") { check1.Visibility = ViewStates.Gone; check2.Visibility = ViewStates.Gone; txtCR.Visibility = ViewStates.Gone; dialog.SetMessage ("Voulez-vous valider cette position ?"); } else { check1.Visibility = ViewStates.Visible; check2.Visibility = ViewStates.Visible; txtCR.Visibility = ViewStates.Visible; txtCR.Text = data.CR; dialog.SetMessage ("Avez vous perçu le CR,?\n Si oui, valider cette livraison ?"); } if (type =="RAM") { checkP.Visibility = ViewStates.Gone; } //afficher la checkbox si partic dialog.SetView(viewAD); dialog.SetCancelable (true); dialog.SetPositiveButton("Oui", delegate { //case btn check string typecr; if (check2.Checked) { typecr="CHEQUE"; string JSONCHEQUE ="{\"codesuiviliv\":\""+typecr+"\",\"memosuiviliv\":\"cheque\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}"; dbr.insertDataStatutpositions(typecr,"1",typecr,data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSONCHEQUE); } if (check1.Checked) { typecr="ESPECE"; string JSONESPECE ="{\"codesuiviliv\":\""+typecr+"\",\"memosuiviliv\":\"espece\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}"; dbr.insertDataStatutpositions(typecr,"1",typecr,data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSONESPECE); } if (checkP.Checked) { typecr="PARTIC"; string JSONPARTIC ="{\"codesuiviliv\":\""+typecr+"\",\"memosuiviliv\":\"espece\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}"; dbr.insertDataStatutpositions(typecr,"1",typecr,data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSONPARTIC); } //mise du statut de la position à 1 dbr.updatePosition(i,"1","Validée",mémo.Text,tyValide,null); //creation du JSON string JSON ="{\"codesuiviliv\":\""+tyValide+"\",\"memosuiviliv\":\""+mémo.Text+"\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}"; //création de la notification webservice // statut de position dbr.insertDataStatutpositions(tyValide,"1","Validée",data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSON); Intent intent = new Intent (this, typeof(ListeLivraisonsActivity)); intent.PutExtra("TYPE",type); this.StartActivity (intent); }); dialog.SetNegativeButton("Non", delegate { AndHUD.Shared.ShowError(this, "Annulée!", AndroidHUD.MaskType.Clear, TimeSpan.FromSeconds(1)); }); dialog.Show (); }
void Btndeletemsg_Click (object sender, EventArgs e){ DBRepository dbr = new DBRepository (); var newmessage = FindViewById<TextView>(Resource.Id.editnewmsg); string dbPath = System.IO.Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), "ormDMS.db3"); var db = new SQLiteConnection (dbPath); var del = dbr.DropTableMessage(); StartActivity(typeof(MessageActivity)); }
void btn_Login_LongClick () { var connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); DBRepository dbr = new DBRepository (); var activeConnection = connectivityManager.ActiveNetworkInfo; if ((activeConnection != null) && activeConnection.IsConnected) { try { string _url = "http://dms.jeantettransport.com/api/authen?chaufmdp="; var webClient = new WebClient(); webClient.Headers [HttpRequestHeader.ContentType] = "application/json"; string userData=""; userData = webClient.DownloadString(_url); System.Console.WriteLine ("\n Webclient User Terminé ..."); //GESTION DU XML JsonArray jsonVal = JsonArray.Parse (userData) as JsonArray; var jsonArr = jsonVal; foreach (var row in jsonArr) { var checkUser = dbr.user_AlreadyExist(row["userandsoft"],row["usertransics"],row["mdpandsoft"],"true"); Console.WriteLine ("\n"+checkUser+" "+row["userandsoft"]); if (!checkUser) { var IntegUser = dbr.InsertDataUser(row["userandsoft"],row["usertransics"],row["mdpandsoft"],"true"); Console.WriteLine ("\n"+IntegUser); } } } catch (System.Exception ex) { System.Console.WriteLine (ex); Insights.Report(ex); AndHUD.Shared.ShowError(this, "Une erreur c'est produite", MaskType.Black, TimeSpan.FromSeconds(5)); } }else{ //AndHUD.Shared.ShowError(this, "Pas de connexion", MaskType.Black, TimeSpan.FromSeconds(5)); Toast.MakeText (this, "Pas de connexion", ToastLength.Long).Show (); } }
protected override void OnResume() { base.OnResume(); DBRepository dbr = new DBRepository (); dbr.SETBadges(Data.userAndsoft); if (dbr.is_user_Log_In() == "false") { Intent intent = new Intent (this, typeof(MainActivity)); this.StartActivity (intent); this.OverridePendingTransition (Resource.Animation.abc_slide_in_top,Resource.Animation.abc_slide_out_bottom); } var t = DateTime.Now.ToString ("dd_MM_yy"); string dir_log = (Android.OS.Environment.GetExternalStoragePublicDirectory (Android.OS.Environment.DirectoryDownloads)).ToString (); //Shared Preference ISharedPreferences pref = Application.Context.GetSharedPreferences ("AppInfo", FileCreationMode.Private); string log = pref.GetString ("Log", String.Empty); //GetTelId TelephonyManager tel = (TelephonyManager)this.GetSystemService (Context.TelephonyService); var telId = tel.DeviceId; //Si il n'y a pas de shared pref if (log == String.Empty) { Data.log_file = Path.Combine (dir_log, t + "_" + telId + "_log.txt"); ISharedPreferencesEditor edit = pref.Edit (); edit.PutString ("Log", Data.log_file); edit.Apply (); } else { //il y a des shared pref Data.log_file = pref.GetString ("Log", String.Empty); if (((File.GetCreationTime (Data.log_file)).CompareTo (DateTime.Now)) > 3) { File.Delete (Data.log_file); Data.log_file = Path.Combine (dir_log, t + "_" + telId + "_log.txt"); ISharedPreferencesEditor edit = pref.Edit (); edit.PutString ("Log", Data.log_file); edit.Apply (); Data.log_file = pref.GetString ("Log", String.Empty); } } var user = dbr.getUserAndsoft (); dbr.setUserdata (user); var version = this.PackageManager.GetPackageInfo(this.PackageName, 0).VersionName; lblTitle.Text = Data.userAndsoft + " " + version; indicatorTimer = new System.Timers.Timer(); indicatorTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnIndicatorTimerHandler); indicatorTimer.Interval = 1000; indicatorTimer.Enabled = true; indicatorTimer.Start(); }
void Btn_Config_LongClick (object sender, View.LongClickEventArgs e) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Deconnexion"); builder.SetMessage("Voulez-vous vous déconnecter ?"); builder.SetCancelable(false); builder.SetPositiveButton("Annuler", delegate { }); builder.SetNegativeButton("Déconnexion", delegate { DBRepository dbr = new DBRepository (); dbr.logout(); Data.userAndsoft = null; Data.userTransics = null; File.AppendAllText(Data.log_file, "["+DateTime.Now.ToString("t")+"]"+"[LOGOUT]Coupure du service le "+DateTime.Now.ToString("G")+"\n"); StopService ( new Intent (this, typeof(ProcessDMS)).PutExtra("userAndsoft",Data.userAndsoft).PutExtra("userTransics",Data.userTransics) ); Intent intent = new Intent (this, typeof(MainActivity)); this.StartActivity (intent); this.OverridePendingTransition (Resource.Animation.abc_slide_in_top,Resource.Animation.abc_slide_out_bottom); }); builder.Show(); }
void Buttonvalider_Click () { if (txtspinner == "Choisir une anomalie") { } else { txtRem = EdittxtRem.Text; switch (txtspinner) { case "Livre avec manquant": codeanomalie = "LIVRMQ"; break; case "Livre avec reserves pour avaries": codeanomalie = "LIVRCA"; break; case "Livre mais recepisse non rendu": codeanomalie = "LIVDOC"; break; case "Livre avec manquants + avaries": codeanomalie = "LIVRMA"; break; case "Refuse pour avaries": codeanomalie = "RENAVA"; break; case "Avise (avis de passage)": codeanomalie = "RENAVI"; break; case "Rendu non livre : complement adresse": codeanomalie = "RENCAD"; break; case "Refus divers ou sans motifs": codeanomalie = "RENDIV"; break; case "Refuse manque BL": codeanomalie = "RENDOC"; break; case "Refuse manquant partiel": codeanomalie = "RENMQP"; break; case "Refuse non commande": codeanomalie = "RENDIV"; break; case "Refuse cause port du": codeanomalie = "RENSPD"; break; case "Refuse cause contre remboursement": codeanomalie = "RENDRB"; break; case "Refuse livraison trop tardive": codeanomalie = "RENTAR"; break; case "Rendu non justifie": codeanomalie = "RENNJU"; break; case "Fermeture hebdomadaire": codeanomalie = "RENFHB"; break; case "Non charge": codeanomalie = "RENNCG"; break; case "Inventaire": codeanomalie = "RENINV"; break; case "Ramasse pas faite": codeanomalie = "RAMPFT"; break; case "Positions non chargees": codeanomalie = "RENNCG"; break; case "Avis de passage": codeanomalie = "RENAVI"; break; case "Ramasse diverse": codeanomalie = "RAMDIV"; break; case "Restaure en non traite": codeanomalie = "RESTNT"; break; default: break; } DBRepository dbr = new DBRepository (); //mise du statut de la position à 1 if (txtspinner == "Restaure en non traite") { dbr.updatePosition (i, "0", txtspinner, txtRem, codeanomalie, null); } else { dbr.updatePosition (i, "2", txtspinner, txtRem, codeanomalie, null); } //creation du JSON string JSON = "{\"codesuiviliv\":\"" + codeanomalie + "\",\"memosuiviliv\":\"" + txtRem + "\",\"libellesuiviliv\":\"" + txtspinner + "\",\"commandesuiviliv\":\"" + data.numCommande + "\",\"groupagesuiviliv\":\"" + data.groupage + "\",\"datesuiviliv\":\"" + DateTime.Now.ToString ("dd/MM/yyyy HH:mm") + "\",\"posgps\":\"" + Data.GPS + "\"}"; //création de la notification webservice // statut de position dbr.insertDataStatutpositions (codeanomalie, "2", txtspinner, data.numCommande, txtRem, DateTime.Now.ToString ("dd/MM/yyyy HH:mm"), JSON); string compImg = String.Empty; Task.Factory.StartNew ( () => { try { var imgpath = dbr.GetPositionsData (i); Android.Graphics.Bitmap bmp = Android.Graphics.BitmapFactory.DecodeFile (imgpath.imgpath); Bitmap rbmp = Bitmap.CreateScaledBitmap (bmp, bmp.Width / 5, bmp.Height / 5, true); compImg = imgpath.imgpath.Replace (".jpg", "-1_1.jpg"); using (var fs = new FileStream (compImg, FileMode.OpenOrCreate)) { rbmp.Compress (Android.Graphics.Bitmap.CompressFormat.Jpeg, 100, fs); } //ftp://77.158.93.75 ftp://10.1.2.75 Data.Instance.UploadFile ("ftp://77.158.93.75", compImg, "DMS", "Linuxr00tn", ""); } catch (Exception ex) { Console.WriteLine ("\n" + ex); } } ); Intent intent = new Intent (this, typeof(ListeLivraisonsActivity)); intent.PutExtra ("TYPE", type); this.StartActivity (intent); this.OverridePendingTransition (Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } }
protected override void OnActivityResult (int requestCode, Result resultCode, Intent data) { base.OnActivityResult (requestCode, resultCode, data); DBRepository dbr = new DBRepository (); // Make it available in the gallery Intent mediaScanIntent = new Intent (Intent.ActionMediaScannerScanFile); Uri contentUri = Uri.FromFile (Data._file); mediaScanIntent.SetData (contentUri); SendBroadcast (mediaScanIntent); // Display in ImageView. We will resize the bitmap to fit the display. // Loading the full sized image will consume to much memory // and cause the application to crash. int height = Resources.DisplayMetrics.HeightPixels; int width = _imageView.Height ; Data.bitmap = Data._file.Path.LoadAndResizeBitmap (width, height); if (Data.bitmap != null) { _imageView.SetImageBitmap (Data.bitmap); dbr.updateposimgpath (i,Data._file.Path); Data.bitmap = null; } // Dispose of the Java side bitmap. //GC.Collect(); }