Ejemplo n.º 1
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            string _loggerType = _logger.LoggerType;

            ILog logger = ObjectBuildFactory <ILog> .Instance(_loggerType);

            var contents = new List <Content>();

            for (int i = 1; i < 10; i++)
            {
                contents.Add(new Content {
                    ID = i, Title = $"{logger.Info("test")}的标题", Contents = $"{i}的内容", Status = 1, Add_time = DateTime.Now.AddDays(-i)
                });
            }
            return(View(new ContentViewModel {
                Contents = contents
            }));

            // return View(new ContentViewModel { Contents =new List<Content> { contents } });


            // logger.Info("test");


            return(View(new ContentViewModel {
                Contents = contents
            }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create different concrete thread by different ThreadName
        /// </summary>
        public static ParentThread <T> createThread(string FullThreadName, CancellationTokenSource _tokenSource, ICloneable _threadParameter)
        {
            ParentThread <T> thread;

            thread = ObjectBuildFactory <ParentThread <T> > .Instance(FullThreadName, new object[] { _tokenSource, _threadParameter });

            return(thread);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initial again when all of the digits have been used.
 /// </summary>
 public static void SetReInitial()
 {
     // Set 3 status to false
     lock (LockUnusedSet)
     {
         UnusedSetStatus = false;
     }
     lock (LockUsedSet)
     {
         UsedSetStatus = false;
     }
     lock (LockExceptionSet)
     {
         ExceptionSetStatus = false;
     }
     // Clear nodes of 3 Sets
     lock (LockUsedSet)
     {
         if (_UsedSet == null)
         {
             _UsedSet = ObjectBuildFactory <PINs.Algorithm.ISet <int> > .Instance(SystemConfiguration.AlgorithmClassName);
         }
         else
         {
             _UsedSet.Clear(SystemConfiguration.UsedDigitDataSet);
         }
     }
     lock (LockUnusedSet)
     {
         if (_UnusedSet == null)
         {
             _UnusedSet = ObjectBuildFactory <PINs.Algorithm.ISet <int> > .Instance(SystemConfiguration.AlgorithmClassName);
         }
         else
         {
             _UnusedSet.Clear(SystemConfiguration.UnusedDigitDataSet);
         }
     }
     lock (LockExceptionSet)
     {
         if (_ExceptionSet == null)
         {
             _ExceptionSet = ObjectBuildFactory <PINs.Algorithm.ISet <int> > .Instance(SystemConfiguration.AlgorithmClassName);
         }
         else
         {
             _ExceptionSet.Clear(SystemConfiguration.ExceptionDigitDataSet);
         }
     }
 }
        /// <summary>
        /// Traverse RootPath
        /// </summary>
        /// <returns>If RootPath is not exists ,don't need execute next step</returns>
        public override bool CheckParameter()
        {
            bool rtn = System.IO.Directory.Exists(param.OriginalRootPath);

            if (rtn)
            {
                //SuccessRecorder = ObjectBuildFactory<IHistoryRecorder>.Instance(SystemConfiguration.HistorRecorderClassName,new object[] { SystemConfiguration.SuccessHistoryName, true });
                SuccessRecorder = ObjectBuildFactory <IHistoryRecorder> .Instance(SystemConfiguration.GetValue("HistorRecorderClassName"), new object[] { SystemConfiguration.GetValue("SuccessHistoryName"), true });
            }
            else
            {
                LoggerHelper.Warn("[" + param.OriginalRootPath + "] is Exists.\r\n");
            }
            return(rtn);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Clear all digits
        /// </summary>
        /// <param name="FileName">filename which include fullpath/DataBase connection /......</param>
        public void Clear(string FileName)
        {
            Clear();
            lock (Lockobject)
            {
                ClearObject = ObjectBuildFactory <IClearData> .Instance(SystemConfiguration.ClearDataClassName);

                if (ClearObject != null)
                {
                    ClearObject.SetClearObject(RBTree);
                }
            }
            if (ClearObject != null)
            {
                ClearObject.Clear(FileName);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Judage if data initial.
        /// </summary>
        /// <param name="FileName">filename which include fullpath/DataBase connection /......</param>
        public bool IsInitial(string FileName)
        {
            lock (Lockobject)
            {
                InitialObject = ObjectBuildFactory <IDataInitial> .Instance(SystemConfiguration.DataInitialClass);

                if (InitialObject != null)
                {
                    InitialObject.SetInitialObject(RBTree);
                }
            }
            if (InitialObject != null)
            {
                return(InitialObject.IsInitial(FileName));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Load PIN data from a physical file/DataBase /......
        /// </summary>
        /// <param name="FileName">filename which include fullpath/DataBase connection /......</param>
        /// <returns>Operation is sucessful,return true otherwise false</returns>
        public bool Load(string FileName)
        {
            lock (Lockobject)
            {
                LoadObject = ObjectBuildFactory <ILoadData> .Instance(SystemConfiguration.LoadDataClassName);

                if (LoadObject != null)
                {
                    LoadObject.SetLoadObject(RBTree);
                }
            }
            if (LoadObject != null)
            {
                return(LoadObject.Load(FileName));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///  Save all of nodes to a physical file/Database/.....
        /// </summary>
        /// <param name="FileName">filename which include fullpathDataBase connection /......</param>
        /// <returns>Operation is sucessful,return true otherwise false</returns>
        public bool Save(string FileName)
        {
            lock (Lockobject)
            {
                SaveObject = ObjectBuildFactory <ISaveData <int> > .Instance(SystemConfiguration.SaveDataClassName);

                if (SaveObject != null)
                {
                    SaveObject.SetSaveObject(RBTree);
                }
            }
            if (SaveObject != null)
            {
                return(SaveObject.Save(FileName));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initial Log instance
        /// By DIP, dynamic create log class
        /// </summary>
        /// <param name="obj"></param>
        public static void Initial(Object obj, string FullLogClassName)
        {
            if (log == null)
            {
                try
                {
                    lock (LockObect) {
                        log = ObjectBuildFactory <ILog> .Instance(FullLogClassName);

                        if (log != null)
                        {
                            log.SetObject(obj);
                        }
                    }
                }
                catch
                {
                    log = null;
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Check RootPath
        /// </summary>
        /// <returns>If RootPath is not exists ,don't need execute next step</returns>
        public override bool CheckParameter()
        {
            bool rtn = System.IO.Directory.Exists(param.OriginalRootPath);

            if (rtn)
            {
                SuccessRecorder = ObjectBuildFactory <IHistoryRecorder> .Instance(SystemConfiguration.GetValue("HistorRecorderClassName"), new object[] { SystemConfiguration.GetValue("SuccessHistoryName"), true });

                //FailRecorder = ObjectBuildFactory<IHistoryRecorder>.Instance(SystemConfiguration.HistorRecorderClassName, new object[] { SystemConfiguration.FailHistoryName, true });
            }
            else
            {
                LoggerHelper.Warn("[" + param.OriginalRootPath + "] is Exists.");
            }
            if (param.OriginalRootPath.Trim().ToLower() == param.OutputRootPath.Trim().ToLower())
            {
                LoggerHelper.Warn("Origina Directory is not allowed to be the same as Output Directory . Please choose another Output Directory.\r\n");
                rtn = false;
            }
            return(rtn);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initial Log instance
        /// By DIP, dynamic create log class
        /// </summary>
        /// <param name="obj"></param>
        public static void Initial(Object obj)
        {
            if (log == null)
            {
                try
                {
                    lock (LockObect) {
                        log = ObjectBuildFactory <ILog> .Instance(SystemConfiguration.LoggerClassName);

                        if (log != null)
                        {
                            log.SetObject(obj);
                        }
                    }
                }
                catch
                {
                    log = null;
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initial 3 Set
        /// </summary>
        public static void Initial()
        {
            //create 3 Set Objects by DIP,dynamic create class
            lock (LockUsedSet)
            {
                if (_UsedSet == null)
                {
                    _UsedSet = ObjectBuildFactory <PINs.Algorithm.ISet <int> > .Instance(SystemConfiguration.AlgorithmClassName);
                }
            }
            lock (LockUnusedSet)
            {
                if (_UnusedSet == null)
                {
                    _UnusedSet = ObjectBuildFactory <PINs.Algorithm.ISet <int> > .Instance(SystemConfiguration.AlgorithmClassName);
                }
            }
            lock (LockExceptionSet)
            {
                if (_ExceptionSet == null)
                {
                    _ExceptionSet = ObjectBuildFactory <PINs.Algorithm.ISet <int> > .Instance(SystemConfiguration.AlgorithmClassName);
                }
            }
            //Juage: if 1st execute this program
            if (!_UnusedSet.IsInitial(SystemConfiguration.UnusedDigitDataSet) ||
                !_UsedSet.IsInitial(SystemConfiguration.UsedDigitDataSet) ||
                !_ExceptionSet.IsInitial(SystemConfiguration.ExceptionDigitDataSet)

                )
            {
                //1st time execute this program
                //generated 3 Set
                //......
                Debug("prepare unused set ...\r\n");
                for (int i = SystemConfiguration.MinDigit; i <= SystemConfiguration.MaxDigit; i++)
                {
                    lock (LockExceptionSet)
                    {
                        _UnusedSet.Insert(i);
                    }
                }
                Debug("Unused set is OK ...\r\n");
                lock (LockUnusedSet)
                {
                    UnusedSetStatus = true;
                }
                lock (LockUsedSet)
                {
                    UsedSetStatus = true;  //UsedSet contains 0 data.
                }
                lock (LockExceptionSet)
                {
                    ExceptionSetStatus = true; //ExceptionSet contains 0 data.
                }
                Debug("All of digit Set is OK ...\r\n");
                LoggerHelper.Info("Digits' Set is prepared.\r\n");

                //Save node to somewhere, now they are physical files.
                _UnusedSet.Save(SystemConfiguration.UnusedDigitDataSet);
                Debug("Unused set is saved  to file...\r\n");
                _ExceptionSet.Save(SystemConfiguration.ExceptionDigitDataSet);
                Debug("exception set is saved to file...\r\n");
                _UsedSet.Save(SystemConfiguration.UsedDigitDataSet);
                Debug("used set is saved to file...\r\n");
            }
            else
            {
                //not first execute this program
                if ((UsedSetStatus == false) && (UnusedSetStatus == false) && (ExceptionSetStatus == false))
                {
                    //not initial
                    //Load data to 3 Set from somewhere ,now they are physical files.
                    _ExceptionSet.Load(SystemConfiguration.ExceptionDigitDataSet);
                    lock (LockExceptionSet)
                    {
                        ExceptionSetStatus = true;
                    }
                    Debug("excepiton set is loaded ...\r\n");

                    _UsedSet.Load(SystemConfiguration.UsedDigitDataSet);
                    lock (LockUsedSet)
                    {
                        UsedSetStatus = true;
                    }
                    Debug("used set is loaded ...\r\n");

                    _UnusedSet.Load(SystemConfiguration.UnusedDigitDataSet);
                    lock (LockUnusedSet)
                    {
                        UnusedSetStatus = true;
                    }
                    Debug("unused set id loaded ...\r\n");
                }
            }
        }