Ejemplo n.º 1
0
        public DataTable CheckPreviousGPX(int UserId, int SchoolId,
                                          int ClassId, DataTable dtNew)
        {
            // Check if the same file is previously uploaded
            // and if there are updated trackpoints in file

            DataTable result = new DataTable();
            DataTable dtPrv  = objStudent.GetPreviousUploadedFile(UserId, UserRoleId);

            if (dtPrv.Rows.Count > 0)
            {
                for (int i = 0; i < dtPrv.Rows.Count; i++)
                {
                    string FilePath = ConfigurationManager.AppSettings["GPXWebPath"].ToString() + SchoolId.ToString() + "/" + ClassId.ToString() + "/" +
                                      UserId.ToString() + "/" + dtPrv.Rows[i]["FileName"].ToString();
                    if (File.Exists(FilePath))
                    {
                        DataTable dtOld = new DataTable();
                        dtOld = LoadGPXWaypoints(FilePath);

                        if (dtOld.Rows.Count > 1 && dtNew.Rows.Count > 1)
                        {
                            int similarrows = MatchingFile(dtOld, dtNew);

                            if (similarrows > 0)
                            {
                                int oldRows = dtOld.Rows.Count;
                                int newRows = dtNew.Rows.Count;

                                if (newRows > oldRows)
                                {
                                    for (int j = 0; j < (newRows - oldRows) - 1; j++)
                                    {
                                        dtNew.Rows[0].Delete();
                                    }
                                    result = dtNew;
                                }

                                break;
                            }
                            else
                            {
                                result = dtNew;
                            }
                        }
                    }
                    else
                    {
                        result = dtNew;
                    }
                }
            }
            else
            {
                result = dtNew;
            }

            return(result);
        }