コード例 #1
0
 private void Apply_Click(object sender, EventArgs e)
 {
     DateTime selectedDate = (DateTime)DatePicker.Value;
     Connect cx = new Connect();
     if (Connect.cookies.Count == 0)
         cx.Sync("");
     cx.GETPage(@"/claroline/notification_date.php?fday=" + selectedDate.Day + "&fmonth=" + selectedDate.Month + "&fyear=" + selectedDate.Year + "&askBy=index.php");
     //TODO : UPDATE DES STATUS...
     NavigationService.GoBack();
 }
コード例 #2
0
        private void PushIntoDB(string[][] result, String type)
        {
            iCampusViewModel VM = App.ViewModel;
            Cours coursToUpdate;

            switch (type)
            {
                #region CASE COURS
                case "Cours":
                    foreach (string[] array in result)
                    {
                        Cours toPushC = new Cours { sysCode = array[0], title = array[1], titular = array[3], notified = (array[4] == "hot") };
                        VM.AddCours(toPushC);
                    }
                    VM.ClearCoursList();

                    if (RefreshAll)
                    {
                        RefreshAll = false;
                        Connect cx = new Connect();
                        foreach (Cours item in VM.AllCours)
                        {
                            //cx.Sync(item.url);
                        }
                    }
                    break;
                #endregion
                #region CASE SECTION
                case "Section":
                    coursToUpdate = (from Cours _cours in VM.AllCours where _cours.sysCode == result[0][4] select _cours).First();

                    foreach (string[] array in result)
                    {
                        switch (array[0])
                        {
                            case "Documents et liens":

                                Connect cx = new Connect();
                                coursToUpdate.isDnL = true;
                                coursToUpdate.dnlNotif = (array[4] == "hot");
                                cx.Sync(array[1].Replace("&","&"));
                                break;

                            case "Annonces":
                                coursToUpdate.isAnn = true;
                                coursToUpdate.annNotif = (array[4] == "hot");
                                (new Connect()).Sync(array[1].Replace("&", "&"));
                                break;

                            default:
                                break;
                        }
                    }
                    //VM.AddCours(coursToUpdate);
                    break;
                #endregion
                #region CASE DOC
                case "Docs":
                    coursToUpdate = (from Cours _cours in VM.AllCours where _cours.sysCode == result[0][7] select _cours).First();

                    foreach (string[] array in result)
                    {
                        string[] name = array[0].Split('.');

                        Documents toPush = new Documents()
                        {
                            url = array[1],
                            Description = array[5],
                            notified = (array[6] == "hot"),
                            Cours = coursToUpdate
                        };

                        switch (array[2])
                        {
                            case "document": //Dossier
                                toPush.path = array[0].Trim();
                                toPush.IsFolder = true;
                                toPush.date = DateTime.Today;
                                (new Connect()).Sync(array[1].Replace("&", "&"));
                                break;

                            case "backends": //Fichier
                                string[] date = array[4].Split('.');
                                string[] partialSize = array[3].Replace(" ", " ").Replace('.', ',').Split(' ');
                                switch (partialSize[1])
                                {
                                    case "Ko":
                                        partialSize[1] = "E+3";
                                        break;
                                    case "Mo":
                                        partialSize[1] = "E+6";
                                        break;
                                    case "Go":
                                        partialSize[1] = "E+9";
                                        break;
                                    default:
                                        partialSize[1] = "";
                                        break;
                                }
                                if (name.Length > 2)
                                {
                                    for (int i = 1; i < name.Length - 1; i++)
                                    {
                                        name[0] += " "+name[i];
                                    }
                                }
                                toPush.path = name[0].Trim();
                                toPush.IsFolder = false;
                                toPush.Extension = name.Last().Trim();
                                toPush.size = Double.Parse(partialSize[0] + partialSize[1]);
                                toPush.date = new DateTime(int.Parse(date[2]), int.Parse(date[1]), int.Parse(date[0]));
                                break;

                            default:
                                break;
                        }
                        if (array[8] != null)
                        {
                            toPush.RootFolder = (from Documents _root in VM.AllFolders where _root.path == result[0][8] select _root).First();
                            toPush.IsRoot = false;
                        }
                        else
                        {
                            toPush.IsRoot = true;
                        }
                        //Debug.WriteLine("Adding Document" + toPush.Name + "\r" + toPush.IsRoot);
                        VM.AddDocument(toPush);
                    }
                    //VM.AddCours(coursToUpdate);
                    break;
                #endregion

                #region CASE ANNONCE
                case "Annonces":
                    coursToUpdate = (from Cours _cours in VM.AllCours where _cours.sysCode == result[0][4] select _cours).First();
                    foreach (string[] array in result)
                    {
                        Annonce AnnToPush = new Annonce()
                        {
                            title = array[0],
                            content = array[1],
                            notified = (array[3] == "hot"),
                            Cours = coursToUpdate,
                            date = DateTime.Parse(array[2])
                        };
                        //Debug.WriteLine("Adding "+ AnnToPush.title +" to DB (depend of " +  AnnToPush.Cours.sysCode);
                        VM.AddAnnonce(AnnToPush);
                    }
                    VM.ClearAnnsOfCours(coursToUpdate);
                    break;
                #endregion

                default:
                    break;
            }
        }