예제 #1
0
        public string[] getFiles(DateTime end)
        {
            List <string> files = new List <string>();

            try
            {
                string[] tablesName = getListOfTableInPeriod("data", end);
                foreach (string table in tablesName)
                {
                    try
                    {
                        files.AddRange(VsDbConnection.getFiles(table, end));
                    }
                    catch (Exception ex)
                    {
                        if (VsDbDelete.setmsg != null)
                        {
                            VsDbDelete.setmsg("ex", "in getFiles  before:" + end + ex.Message + " " + ex.StackTrace);
                        }
                    }
                }//ǹ·Ó·Ø¡ table ·ÕèÍÂÙè㹪èǧ firstTable ¶Ö§ endTable
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(files.ToArray());
        }
예제 #2
0
        private string[] getListOfTableInPeriod(string tableType, DateTime start, DateTime end)
        {
            List <string> dateList = new List <string>();

            int i = 0;

            while (true)
            {
                DateTime addMonths = start.AddMonths(i);
                DateTime inTime    = new DateTime(addMonths.Year, addMonths.Month, 1);

                if (end.CompareTo(inTime) >= 0)
                {
                    dateList.Add(VsDbConnection.DateTimeToTableName(tableType, inTime));
                    i++;
                    continue;
                }
                else
                {
                    break;
                }
            }

            return(dateList.ToArray());
        }
예제 #3
0
        private string[] getListOfTableInPeriod(string tableType, string startStr, string endStr)
        {
            DateTime start = VsDbConnection.tableNameToDateTime(startStr);
            DateTime end   = VsDbConnection.tableNameToDateTime(endStr);

            return(getListOfTableInPeriod(tableType, start, end));
        }
예제 #4
0
        public int deleteMainEventDelete(DateTime end)
        {
            int numDelete = 0;

            string[] tablesName = getListOfTableInPeriod("event", end);
            foreach (string table in tablesName)
            {
                try
                {
                    numDelete += VsDbConnection.deleteMainData(table, end);

                    //¶éÒäÁèÁÕ¢éÍÁÙÅàËÅ×Íã¹µÒÃÒ§¡çãËéźµÒÃÒ§·Ôé§
                    if (VsDbConnection.getNumDataInTable(table) == 0 && !table.Equals(VsDbConnection.DateTimeToTableName("event", DateTime.Now)))
                    {
                        VsDbConnection.deleteTable(table);
                    }
                }
                catch (Exception ex)
                {
                    if (VsDbDelete.setmsg != null)
                    {
                        VsDbDelete.setmsg("ex", "in deleteMainEventDelete  before:" + end + "table" + table + ex.Message + " " + ex.StackTrace);
                    }
                }
            }//ǹ·Ó·Ø¡ table ·ÕèÍÂÙè㹪èǧ firstTable ¶Ö§ endTable

            return(numDelete);
        }
예제 #5
0
        //cMessageBox.Show(ex.Message);onstructor
        //public VsDbDelete(string server, string user, string pass, string Dbprima, string Dbsecon, string hostIp, string fileRootPath)
        //{
        //    mysqlServer = server;
        //    mysqlUser = user;
        //    mysqlPass = pass;
        //    primaryDbName = hostIp;
        //    primaryDbName = Dbprima;
        //    secondaryDbName = Dbsecon;

        //    connString = getConnString(server, user, pass, "", false);
        //    mainDbConnString = getConnString(server, user, pass, Dbprima, false);
        //    clientDbConnString = getConnString(server, user, pass, Dbsecon, false);



        //    VsDbConnection.setConnectionString(mainDbConnString, clientDbConnString);

        //    fileManage = new FileManage(10000, 6);//ÃÍź«éÓ ÃͺÅÐÊÔºÇÔ Ë¡Ãͺ
        //}

        public VsDbDelete(string mainConStr, string clientConStr)
        {
            mainDbConnString   = mainConStr;
            clientDbConnString = clientConStr;
            VsDbConnection.setConnectionString(mainDbConnString, clientDbConnString);

            fileManage = new FileManage(10000, 6);//ÃÍź«éÓ ÃͺÅÐÊÔºÇÔ Ë¡Ãͺ
            // setMsg = new setText;
        }
예제 #6
0
        private int deleteMainDataAndFileEachTable(string table, DateTime end)
        {
            //´Ö§ª×èÍfile ÁÒ¨Ò¡ main DB
            string[] filesName = VsDbConnection.getFiles(table, end);

            //àÍÒ¤èÒ¨Ò¡ä¿Åì config
            AppConfigData config = new AppConfigData();

            config.LoadSettings("app.config");
            string rootDir = config.localHost.Storage;//new FileInfo(filesName[0]).Directory.Parent.Parent.FullName;

            //ź¢éÍÁÙÅã¹ main DB
            int numMainDbDelte = VsDbConnection.deleteMainData(table, end);


            //źfile
            int numFileDelete = fileManage.deleteFile(filesName);

            //¶éÒäÁèÁÕ¢éÍÁÙÅàËÅ×Íã¹µÒÃÒ§¡çãËéźµÒÃÒ§·Ôé§
            if (VsDbConnection.getNumDataInTable(table) == 0)
            {
                if (!table.Equals(VsDbConnection.DateTimeToTableName("data", DateTime.Now)))
                {
                    VsDbConnection.deleteTable(table);
                }
                deleteDirFileOfTable(table, rootDir);
            }

            //à»ÅÕºà·ÕèºÇèÒźä»à·èҡѹÁÑéÂ
            if ((numMainDbDelte != numFileDelete))
            {
                if (VsDbDelete.setmsg != null)
                {
                    VsDbDelete.setmsg("msg", "number dedeted don't match "
                                      + " numMainDbDelte:" + numMainDbDelte + " numFileDelete:" + numFileDelete);
                }
            }

            return(numMainDbDelte);
        }
예제 #7
0
 public int getNumDataInTable(string tableName)
 {
     return(VsDbConnection.getNumDataInTable(tableName));
 }
예제 #8
0
        //###################################################################################################


        public string[] getAllTableName()
        {
            return(VsDbConnection.getAllTableName());
        }
예제 #9
0
        //###################################################################################################
        private string[] getListOfTableInPeriod(string tableType, DateTime end)
        {
            DateTime start = VsDbConnection.getFirstTableInDateTime(tableType);

            return(getListOfTableInPeriod(tableType, start, end));
        }
예제 #10
0
 public int deleteClientData(DateTime end)
 {
     return(VsDbConnection.deleteClientData(end));
 }