public void Initialize(RepositoryJsonDataSource dataSourceRepository, IStatusReporter statusReporter) {
			this.dataSourceRepository = dataSourceRepository;
			this.statusReporter = statusReporter;

			try {
				bool createdNewFile = this.dataSnapshotSerializer.Initialize(this.dataSourceRepository.RootPath,
					"Sq1.Widgets.DataSourcesTree.DataSourceTreeDataSnapshot.json", "Workspaces",
					Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName, true, true);
				this.dataSnapshot = this.dataSnapshotSerializer.Deserialize();
				if (createdNewFile) {
					this.dataSnapshotSerializer.Serialize();
				}
			} catch (Exception ex) {
				Assembler.PopupException(" DataSourcesTreeControl.Initialize()", ex);
			}
			
			this.populateDataSourcesIntoTreeListView();

			this.dataSourceRepository.OnItemAdded += new EventHandler<NamedObjectJsonEventArgs<DataSource>>(dataSourceRepository_OnDataSourceAdded);
			this.dataSourceRepository.OnItemRenamed += new EventHandler<NamedObjectJsonEventArgs<DataSource>>(dataSourceRepository_OnDataSourceRenamed);
			this.dataSourceRepository.OnItemCanBeRemoved += new EventHandler<NamedObjectJsonEventArgs<DataSource>>(dataSourceRepository_OnDataSourceCanBeRemoved);
			this.dataSourceRepository.OnItemRemovedDone += new EventHandler<NamedObjectJsonEventArgs<DataSource>>(dataSourceRepository_OnDataSourceRemovedDone);
			this.dataSourceRepository.OnSymbolAdded += new EventHandler<DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolAdded);
			this.dataSourceRepository.OnSymbolRenamed += new EventHandler<DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolRenamed);
			this.dataSourceRepository.OnSymbolCanBeRemoved += new EventHandler<DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolCanBeRemoved);
			this.dataSourceRepository.OnSymbolRemovedDone += new EventHandler<DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolRemovedDone);
		}
		public void Initialize(string rootPath,
		            string subfolder = "DataSources",
		            IStatusReporter statusReporter = null,
					bool createNonExistingPath = true) {
			
			this.StatusReporter = statusReporter;
			
			string msig = "RepositoryFoldersNoJson::Initialize("
					+ "rootPath=[" + rootPath + "], subfolder=[" + subfolder + "]: ";
			
			if (string.IsNullOrEmpty(rootPath)) {
				string msg = "rootPath.IsNullOrEmpty(" + rootPath + ")";
				this.ThrowOrPopup(msig + msg);
			}

			//if (string.IsNullOrEmpty(subfolder) == false && subfolder.EndsWith(Path.DirectorySeparatorChar) == false) subfolder += Path.DirectorySeparatorChar;
			this.Subfolder = subfolder;
			
			//if (rootPath.EndsWith(Path.DirectorySeparatorChar) == false) rootPath += Path.DirectorySeparatorChar;
			this.RootPath = rootPath;

			if (Directory.Exists(this.AbsPath) == false) {
				if (createNonExistingPath == false) {
					string msg = "Directory.Exists(" + this.AbsPath + ")=false AND createPath=false";
					throw new Exception(msig + msg);
				}
				try {
					Directory.CreateDirectory(this.AbsPath);
				} catch (Exception e) {
					string msg = "FAILED_TO Directory.CreateDirectory(" + this.AbsPath + ")";
					throw new Exception(msig + msg);
				}
			}
		}
        public void Initialize(RepositoryJsonDataSource dataSourceRepository, IStatusReporter statusReporter)
        {
            this.dataSourceRepository = dataSourceRepository;
            this.statusReporter       = statusReporter;

            try {
                bool createdNewFile = this.dataSnapshotSerializer.Initialize(this.dataSourceRepository.RootPath,
                                                                             "Sq1.Widgets.DataSourcesTree.DataSourceTreeDataSnapshot.json", "Workspaces",
                                                                             Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName, true, true);
                this.dataSnapshot = this.dataSnapshotSerializer.Deserialize();
                if (createdNewFile)
                {
                    this.dataSnapshotSerializer.Serialize();
                }
            } catch (Exception ex) {
                Assembler.PopupException(" DataSourcesTreeControl.Initialize()", ex);
            }

            this.populateDataSourcesIntoTreeListView();

            this.dataSourceRepository.OnItemAdded          += new EventHandler <NamedObjectJsonEventArgs <DataSource> >(dataSourceRepository_OnDataSourceAdded);
            this.dataSourceRepository.OnItemRenamed        += new EventHandler <NamedObjectJsonEventArgs <DataSource> >(dataSourceRepository_OnDataSourceRenamed);
            this.dataSourceRepository.OnItemCanBeRemoved   += new EventHandler <NamedObjectJsonEventArgs <DataSource> >(dataSourceRepository_OnDataSourceCanBeRemoved);
            this.dataSourceRepository.OnItemRemovedDone    += new EventHandler <NamedObjectJsonEventArgs <DataSource> >(dataSourceRepository_OnDataSourceRemovedDone);
            this.dataSourceRepository.OnSymbolAdded        += new EventHandler <DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolAdded);
            this.dataSourceRepository.OnSymbolRenamed      += new EventHandler <DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolRenamed);
            this.dataSourceRepository.OnSymbolCanBeRemoved += new EventHandler <DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolCanBeRemoved);
            this.dataSourceRepository.OnSymbolRemovedDone  += new EventHandler <DataSourceSymbolEventArgs>(dataSourceRepository_OnSymbolRemovedDone);
        }
 /// <summary>
 /// 讀取單一學期成績,包含科目成績、領域成績。
 /// </summary>
 public static void ReadSemesterScore(this List <StudentScore> students,
                                      int schoolYear,
                                      int semester,
                                      IStatusReporter reporter)
 {
     new SemesterScoreReader(students, schoolYear, semester, GetReporter(reporter)).Read();
 }
示例#5
0
 public WorkerQueue(SubSyncSettings settings, IWorkerProvider workerProvider, IStatusReporter statusReporter)
 {
     this.settings       = settings;
     this.workerProvider = workerProvider;
     this.statusReporter = statusReporter;
     workerThread        = new Thread(ProcessQueue);
 }
		public virtual void Initialize(DataSource dataSource, StreamingProvider streamingProvider, OrderProcessor orderProcessor, IStatusReporter connectionStatus) {
			this.DataSource = dataSource;
			this.StreamingProvider = streamingProvider;
			this.OrderProcessor = orderProcessor;
			this.StatusReporter = connectionStatus;
			this.AccountAutoPropagate.Initialize(this);
		}
示例#7
0
        /*----------------------------------------------------------------------------
        *       %%Function:GetOptionsTextValueMappingFromControl
        *       %%Qualified:ArbWeb.ArbWebControl_Selenium.GetOptionsTextValueMappingFromControl
        *  ----------------------------------------------------------------------------*/
        private static Dictionary <string, string> GetOptionsTextValueMappingFromControl(
            IWebElement selectElement,
            IStatusReporter srpt)
        {
            string sHtml = selectElement.GetAttribute("innerHTML");

            HtmlDocument html = new HtmlDocument();

            html.LoadHtml(sHtml);

            HtmlNodeCollection          options = html.DocumentNode.SelectNodes("//option");
            Dictionary <string, string> mp      = new Dictionary <string, string>();

            if (options != null)
            {
                foreach (HtmlNode option in options)
                {
                    string sValue = option.GetAttributeValue("value", null);
                    string sText  = option.InnerText.Trim();

                    if (mp.ContainsKey(sText))
                    {
                        srpt?.AddMessage(
                            $"How strange!  Option '{sText}' shows up more than once in the options list!",
                            MSGT.Warning);
                    }
                    else
                    {
                        mp.Add(sText, sValue);
                    }
                }
            }

            return(mp);
        }
示例#8
0
        /*----------------------------------------------------------------------------
        *       %%Function:FSetSelectControlValue
        *       %%Qualified:ArbWeb.ArbWebControl_Selenium.FSetSelectControlValue
        *  ----------------------------------------------------------------------------*/
        public static bool FSetSelectedOptionValueForControlName(IWebDriver driver, IStatusReporter srpt, string sName, string sValue)
        {
            srpt.LogData($"FSetSelectControlValue for name {sName}", 5, MSGT.Body);

            SelectElement select    = new SelectElement(driver.FindElement(By.Name(sName)));
            string        sOriginal = select.SelectedOption.GetProperty("value");
            bool          fChanged  = false;

            if (String.Compare(sOriginal, sValue, true) != 0)
            {
                try
                {
                    select.SelectByValue(sValue);
                }
                catch
                {
                    return(false);
                }
                fChanged = true;
            }

            srpt.LogData($"Return: {fChanged}", 5, MSGT.Body);

            return(fChanged);
        }
示例#9
0
        /// <summary>
        /// Действие сцены
        /// </summary>
        public void Scene(IUserInput userInput, IStatusReporter statusReporter)
        {
            BattleActionHistory = new List <DoBattleAction>();
            BattleActions       = new Dictionary <UserCommand, DoBattleAction>()
            {
                { UserCommand.Attack, Attack },
                { UserCommand.GiveUp, GiveUp },
                { UserCommand.GetStat, GetStat },
                { UserCommand.NoCommand, Boo }
            };

            for ( ; ;)
            {
                foreach (var castle in Castles)
                {
                    UserCommand userCommand = UserCommand.Attack;
                    if (!IsAction)
                    {
                        return;
                    }

                    do
                    {
                        statusReporter.WriteLine($"ход героев замка {castle} ({Utils.EnumValueToString<CastleOwner>(castle.Owner)})");

                        if (castle.Owner == CastleOwner.User)
                        {
                            userCommand = userInput.GetUserCommand(statusReporter);
                            statusReporter.Clear();
                        }
                        /*пользователь будет делать ходы, пока функция не вернёт false*/
                    }while(BattleActions[userCommand](Units, Units, statusReporter));
                }
            }
        }
        private UpdateController createControllerWithUpdatesToInstall(IStatusReporter reporter)
        {
            var updateClient = getUpdateClientWithUpdatesToInstall(new[] { "4269002", "2267602" });
            var controller   = createController(null, null, updateClient, null, null, reporter);

            return(controller);
        }
示例#11
0
        public RobotLauncher(int turnTime, IStatusReporter statusReporter)
        {
            _statusReporter = statusReporter;
            _robot          = new RobotPlayer();

            TurnTime = turnTime;
        }
 public SemesterScoreReader(List <StudentScore> students, int schoolYear, int semester, IStatusReporter reporter)
 {
     Students   = students.ToDictionary();
     SchoolYear = schoolYear;
     Semester   = semester;
     Reporter   = reporter;
 }
示例#13
0
 public AttendScoreSaver(List <StudentScore> students,
                         IEnumerable <string> filterSubject,
                         IStatusReporter reporter)
 {
     Reporter      = reporter;
     Students      = students;
     FilterSubject = new UniqueSet <string>(filterSubject);
 }
示例#14
0
 public void Initialize(string rootPath, string subfolder,
                        IStatusReporter statusReporter,
                        RepositoryCustomMarketInfo marketInfoRepository, OrderProcessor orderProcessor)
 {
     base.Initialize(rootPath, subfolder, statusReporter, this.dataSourceDeserializedInitializePriorToAdding);
     this.MarketInfoRepository = marketInfoRepository;
     this.OrderProcessor       = orderProcessor;
 }
        /// <summary>
        /// 儲存單學期成績,包含科目、領域(僅會儲存 SemesterData.Empty 學期)。
        /// </summary>
        /// <param name="students"></param>
        public static void SaveSemesterScore(this List <StudentScore> students, IStatusReporter reporter)
        {
            new SemesterScoreSaver(students, GetReporter(reporter)).Save();

            EventHandler eh = FISCA.InteractionService.PublishEvent("CalculationHelper.SaveSemesterScore");

            eh(null, EventArgs.Empty);
        }
示例#16
0
 public Assembler InitializedWithSame(IStatusReporter mainForm)
 {
     if (this.StatusReporter == mainForm)
     {
         return(Assembler.InstanceInitialized);
     }
     return(this.Initialize(mainForm));
 }
 public AttendScoreReader(List <StudentScore> students, int schoolYear, int semester, IEnumerable <string> filterSubject, IStatusReporter reporter)
 {
     Students      = students.ToDictionary();
     SchoolYear    = schoolYear;
     Semester      = semester;
     FilterSubject = new UniqueSet <string>(filterSubject);
     Reporter      = reporter;
 }
 public override List <double> Train(INetwork network, IDataSet data, IStatusReporter statusHolder)
 {
     vSetStart = (int)((1 - vSetPercentage) * data.PatternCount);
     Normalizor.GetMinMaxActivationWithMargin(network.Activation.MinValue, network.Activation.MaxValue,
                                              out minValidOutput, out maxValidOutput);
     isRecursiveNet = network is RecursiveNetwork;
     return(base.Train(network, data, statusHolder));
 }
 /// <summary>
 /// 讀取修課成績相關資料,包含課程成績、評量成績。
 /// </summary>
 /// <param name="students">學生清單。</param>
 /// <param name="schoolYear">學年度。</param>
 /// <param name="semester">學期。</param>
 /// <param name="filterSubject">讀取資料的科目。</param>
 /// <param name="reporter">進度回報。</param>
 public static void ReadAttendScore(this List <StudentScore> students,
                                    int schoolYear,
                                    int semester,
                                    IEnumerable <string> filterSubject,
                                    IStatusReporter reporter)
 {
     new AttendScoreReader(students, schoolYear, semester, filterSubject, GetReporter(reporter)).Read();
     GC.Collect();
 }
示例#20
0
        public void Initialize(OrderProcessor orderProcessor, IStatusReporter statusReporter, DockPanel mainFormDockPanel)
        {
            base.Initialize(statusReporter, mainFormDockPanel);
            this.orderProcessor = orderProcessor;

            //this.executionTree.Initialize(this.orderProcessor.DataSnapshot.OrdersAll.SafeCopy);
            this.ExecutionTreeControl.InitializeWithShadowTreeRebuilt(this.orderProcessor.DataSnapshot.OrdersTree);
            this.ExecutionTreeControl.PopulateAccountsMenuFromBrokerProvider(Assembler.InstanceInitialized.RepositoryJsonDataSource.CtxAccountsAllCheckedFromUnderlyingBrokerProviders);
        }
        private static IStatusReporter GetReporter(IStatusReporter reporter)
        {
            IStatusReporter rep = reporter;

            if (reporter == null)
            {
                rep = new EmptyStatusReport();
            }
            return(rep);
        }
示例#22
0
        /// <summary>
        /// Замок признаёт поражение
        /// </summary>
        /// <param name="attackGroup"></param>
        /// <param name="enemyGroup"></param>
        /// <param name="statusReporter"></param>
        /// <returns>возврат - повторить ход</returns>
        public bool GiveUp(Units attackGroup, Units enemyGroup, IStatusReporter statusReporter)
        {
            statusReporter.WriteLine($"Замок {attackGroup.First().Home} признаёт поражение.");
            foreach (var defeatUnit in Units.ByCastle(attackGroup.First().Home))
            {
                defeatUnit.Life = 0;
            }

            return(false);
        }
        public List <StudentScore> Read()
        {
            #region 讀取成績計算規則。
            IStatusReporter Rep = Reporter;
            Rep.Feedback("讀取成績計算規則...", 0);

            UniqueSet <string> ruleids = new UniqueSet <string>();
            foreach (StudentScore each in Students)
            {
                if (!string.IsNullOrEmpty(each.RefCalculationRuleID))
                {
                    if (!ruleids.Contains(each.RefCalculationRuleID))
                    {
                        ruleids.Add(each.RefCalculationRuleID);
                    }
                }

                JHClassRecord cr = each.Class;
                if (cr != null)
                {
                    if (string.IsNullOrEmpty(cr.RefScoreCalcRuleID))
                    {
                        continue;
                    }

                    if (!ruleids.Contains(cr.RefScoreCalcRuleID))
                    {
                        ruleids.Add(cr.RefScoreCalcRuleID);
                    }
                }
            }

            FunctionSpliter <string, JHScoreCalcRuleRecord> spliter = new FunctionSpliter <string, JHScoreCalcRuleRecord>(10, Util.MaxThread);
            spliter.Function = delegate(List <string> idsPart)
            {
                return(JHScoreCalcRule.SelectByIDs(idsPart));
            };
            spliter.ProgressChange = delegate(int progress)
            {
                Rep.Feedback("讀取成績計算規則...", Util.CalculatePercentage(ruleids.Count, progress));
            };
            StudentScore.SetRuleMapping(spliter.Execute(ruleids.ToList()));

            List <StudentScore> noRule = new List <StudentScore>();
            foreach (StudentScore each in Students)
            {
                if (each.CalculationRule == null)
                {
                    noRule.Add(each);
                }
            }
            return(noRule);

            #endregion
        }
示例#24
0
 public WorkerProvider(
     ILogger logger,
     HashSet <string> subtitleExtensions,
     ISubtitleProvider subtitleProvider,
     IStatusReporter <WorkerStatus> statusReporter)
 {
     this.logger             = logger;
     this.subtitleProvider   = subtitleProvider;
     this.statusReporter     = statusReporter;
     this.subtitleExtensions = subtitleExtensions;
 }
示例#25
0
 public static void GetCastleStatistics(this Units units, IStatusReporter statusReporter)
 {
     statusReporter.WriteLine($"общая сила замка {units.UnitsOperatoin.GetDamage()}");
     statusReporter.WriteLine($"общая защита замка {units.UnitsOperatoin.GetProtectionLevel()}");
     foreach (var unitGroup in units.GroupBy(unit => unit.GroupIndex))
     {
         statusReporter.WriteLine($"группировка {unitGroup.First().GroupIndex}");
         statusReporter.WriteLine($"общая сила {units.UnitsOperatoin.GetDamageGroup(unitGroup.First().GroupIndex)}");
         statusReporter.WriteLine($"общая защита {units.UnitsOperatoin.GetGroupProtectionLevel(unitGroup.First().GroupIndex)}");
     }
 }
		public void Initialize(RepositoryDllJsonStrategy strategyRepository, IStatusReporter statusReporter) {
			this.strategyRepository = strategyRepository;
			this.statusReporter = statusReporter;
			
			bool createdNewFile = this.dataSnapshotSerializer.Initialize(this.strategyRepository.RootPath,
				"Sq1.Widgets.StrategiesTree.StrategiesTreeDataSnapshot.json", "Workspaces",
				Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName, false, true);
			this.dataSnapshot = this.dataSnapshotSerializer.Deserialize();
			
			this.populateStrategyRepositoryIntoTreeListView();
		}
示例#27
0
        /*----------------------------------------------------------------------------
        *       %%Function:WaitForControl
        *       %%Qualified:ArbWeb.ArbWebControl_Selenium.WaitForControl
        *  ----------------------------------------------------------------------------*/
        public static bool WaitForControl(IWebDriver driver, IStatusReporter srpt, string sid)
        {
            if (sid == null)
            {
                return(true);
            }

            WebDriverWait wait    = new WebDriverWait(driver, new TimeSpan(0, 0, 5));
            IWebElement   element = wait.Until(theDriver => theDriver.FindElement(By.Id(sid)));

            return(element != null);
        }
示例#28
0
        /*----------------------------------------------------------------------------
        *       %%Function:FClickControl
        *       %%Qualified:ArbWeb.ArbWebControl_Selenium.FClickControl
        *  ----------------------------------------------------------------------------*/
        private static bool FClickControl(IStatusReporter srpt, IWebDriver driver, IWebElement element, string sidWaitFor = null)
        {
            element?.Click();

            if (sidWaitFor != null)
            {
                return(WaitForControl(driver, srpt, sidWaitFor));
            }

            WaitForPageLoad(srpt, driver, 2000);
            return(true);
        }
示例#29
0
        public void Initialize(RepositoryDllJsonStrategy strategyRepository, IStatusReporter statusReporter)
        {
            this.strategyRepository = strategyRepository;
            this.statusReporter     = statusReporter;

            bool createdNewFile = this.dataSnapshotSerializer.Initialize(this.strategyRepository.RootPath,
                                                                         "Sq1.Widgets.StrategiesTree.StrategiesTreeDataSnapshot.json", "Workspaces",
                                                                         Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName, false, true);

            this.dataSnapshot = this.dataSnapshotSerializer.Deserialize();

            this.populateStrategyRepositoryIntoTreeListView();
        }
示例#30
0
        /// <summary>
        /// Отображает содержание по группировкам (замок, группы)
        /// </summary>
        /// <param name="statusReporter"></param>
        public void ShowNamesGroup(IStatusReporter statusReporter)
        {
            statusReporter.WriteLine($"Замок {this.First().Home}");
            statusReporter.WriteLine($"воинов {Count}");

            var unitsGroups = this.ToLookup(unit => unit.GroupIndex);

            statusReporter.WriteLine($"Группировок в замке {unitsGroups.Count()}");

            foreach (var unitGroup in unitsGroups.OrderBy(ug => ug.Key))
            {
                statusReporter.WriteLine($"{unitGroup.Key}) {unitGroup.Select(unit => unit.ToString()).Aggregate((u,g) => $"{u}, {g}")}");
            }
        }
示例#31
0
        public UpdateController(ILocalConfiguration config, IHttpClient httpClient, IUpdateClient updateClient,
                                ITaskHandler taskHandler, IStatusReporter reporter, IReportStorage reportStorage, ITimeFrameDecision timeFrameDecision)
        {
            mStopServiceEvent = new ManualResetEvent(false);

            LocalConfig         = config;
            WebHttpClient       = httpClient;
            WindowsUpdateClient = updateClient;
            WindowsTaskHandler  = taskHandler;
            Reporter            = reporter;
            ReportStorage       = reportStorage;
            TimeFrameDecision   = timeFrameDecision;

            Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        }
        public void UpdateState(GameField newField, PlayerSide side, IStatusReporter statusReporter, IResultSender <GameTurn> sender)
        {
            Side            = side;
            _curField       = newField;
            _statusReporter = statusReporter;
            _sender         = sender;

            _turns         = new List <GameTurn>();
            _requiredJumps = GameTurnUtils.FindRequiredJumps(_curField, Side);

            DoJumpsContinue = false;

            _statusReporter.Status = string.Format("{0}: {1}", Side, _requiredJumps.Any()
                ? Resources.WpfPlayer_JumpTurn_Start
                : Resources.WpfPlayer_SimpleTurn);
        }
示例#33
0
        public void Initialize(string rootPath,
                               string subfolder = "DataSources",
                               IStatusReporter statusReporter = null,
                               Func <string, DATASOURCE, bool> checkIfValidAndShouldBeAddedAfterDeserialized = null,
                               string mask = "*.json",
                               bool createNonExistingPath = true, bool createNonExistingFile = true)
        {
            this.StatusReporter = statusReporter;

            string msig = "RepositoryJsonsInFolder<" + OfWhat + ">::Initialize("
                          + "rootPath=[" + rootPath + "], subfolder=[" + subfolder + "],"
                          + " mask=[" + mask + "],"
                          + " createNonExistingPath=[" + createNonExistingPath + "],"
                          + " createNonExistingFile=[" + createNonExistingFile + "]): ";

            if (string.IsNullOrEmpty(rootPath))
            {
                string msg = "rootPath.IsNullOrEmpty(" + rootPath + ")";
                Assembler.PopupException(msg + msig);
                return;
            }

            //if (string.IsNullOrEmpty(subfolder) == false && subfolder.EndsWith(Path.DirectorySeparatorChar) == false) subfolder += Path.DirectorySeparatorChar;
            this.Subfolder = subfolder;

            //if (rootPath.EndsWith(Path.DirectorySeparatorChar) == false) rootPath += Path.DirectorySeparatorChar;
            this.RootPath = rootPath;
            this.Mask     = mask;

            if (Directory.Exists(this.AbsPath) == false)
            {
                if (createNonExistingPath == false)
                {
                    string msg = "Directory.Exists(" + this.AbsPath + ")=false AND createPath=false";
                    throw new Exception(msig + msg);
                    return;
                }
                try {
                    Directory.CreateDirectory(this.AbsPath);
                } catch (Exception e) {
                    string msg = "FAILED_TO Directory.CreateDirectory(" + this.AbsPath + ")";
                    throw new Exception(msig + msg);
                    return;
                }
            }
            this.CheckIfValidAndShouldBeAddedAfterDeserialized = checkIfValidAndShouldBeAddedAfterDeserialized;
        }
示例#34
0
文件: Worker.cs 项目: anffna/SubSync
 public Worker(
     string filePath,
     ILogger logger,
     IWorkerQueue workerQueue,
     ISubtitleProvider subtitleProvider,
     IStatusReporter <WorkerStatus> statusReporter,
     HashSet <string> subtitleExtensions,
     int retryCount = 0)
 {
     this.filePath           = filePath;
     this.logger             = logger;
     this.workerQueue        = workerQueue;
     this.subtitleProvider   = subtitleProvider;
     this.statusReporter     = statusReporter;
     this.subtitleExtensions = subtitleExtensions;
     this.retryCount         = retryCount;
 }
		public virtual void Initialize(DataSource dataSource, IStatusReporter statusReporter) {
			this.StatusReporter = statusReporter;
			this.InitializeFromDataSource(dataSource);
			this.SubscribeSolidifier();
		}
		public void Initialize(string dataSourcesAbspath, OrderProcessor orderProcessor, IStatusReporter statusReporter) {
			//if (this.HasBarDataStore) {
			//    this.BarsFile = new BarsFile(FolderForBarDataStore);
			//}
			this.DataSourcesAbspath = dataSourcesAbspath;
			this.DataSourceAbspath = Path.Combine(this.DataSourcesAbspath, this.Name);
			this.BarsRepository = new RepositoryBarsSameScaleInterval(this.DataSourceAbspath, this.ScaleInterval, true);
			
			//this.BarsFolderPerst = new BarsFolder(this.FolderForBarDataStore, this.ScaleInterval, true, "dts");

			// works only for deserialized providers; for a newDataSource they are NULLs to be assigned in DataSourceEditor 
			if (this.StaticProvider != null) {
				this.StaticProvider.Initialize(this, dataSourcesAbspath);
			}
			if (this.StreamingProvider != null) {
				this.StreamingProvider.Initialize(this, statusReporter);
				if (this.BrokerProvider != null) {
					this.BrokerProvider.Initialize(this, this.StreamingProvider, orderProcessor, statusReporter);
				}
			}
		}
		public Assembler Initialize(IStatusReporter mainForm) {
			if (this.StatusReporter != null && this.StatusReporter != mainForm) {
				string msg = "Assembler.InstanceInitialized.StatusReporter[" + this.StatusReporter + "] != mainForm[" + mainForm + "]";
				msg += "; you initialize the StatusReporter once per lifetime;"
					+ " if you need to re-initialize singleton with new IStatusReporter then refactor it"
					+ " and introduce Reset(IStatusReporter) method which won't throw this;"
					+ " or you can just set Assembler.InstanceInitialized.StatusReporter={your different IStatusReporter}"
					+ " to use Assembler.PopupException(), but no guarantee that OrderProcessor and DataSourceRepository will work properly";
				throw new Exception();
			}
			this.StatusReporter = mainForm;
			
			bool createdNewFile = this.RepositoryCustomSymbolInfo.Initialize(this.AppDataPath, "SymbolInfo.json", "", null);
			List<SymbolInfo> symbolInfosNotUsed = this.RepositoryCustomSymbolInfo.Deserialize();
			
			createdNewFile = this.MarketInfoRepository.Initialize(this.AppDataPath, "MarketInfo.json", "", null);
			this.MarketInfoRepository.Deserialize();
			
			this.RepositoryDllJsonStrategy.Initialize(this.AppDataPath, this.AppStartupPath);

			this.RepositoryDllStaticProvider.InitializeAndScan(this.AppStartupPath);
			this.RepositoryDllStreamingProvider.InitializeAndScan(this.AppStartupPath);
			this.RepositoryDllBrokerProvider.InitializeAndScan(this.AppStartupPath);
			this.RepositoryDllReporters.InitializeAndScan(this.AppStartupPath);
			
			this.WorkspacesRepository.Initialize(this.AppDataPath, "Workspaces", this.StatusReporter);
			this.WorkspacesRepository.ScanFolders();

			this.OrderProcessor.Initialize(this.AppDataPath, this.StatusReporter);

			//v1 this.RepositoryJsonDataSource.Initialize(this.AppDataPath);
			//v1 this.RepositoryJsonDataSource.DataSourcesDeserialize(this.MarketInfoRepository, this.OrderProcessor, this.StatusReporter);
			
			this.RepositoryJsonDataSource.Initialize(this.AppDataPath, "DataSources",
				this.StatusReporter, this.MarketInfoRepository, this.OrderProcessor);
			this.RepositoryJsonDataSource.DeserializeJsonsInFolder();

			createdNewFile = this.AssemblerDataSnapshotSerializer.Initialize(this.AppDataPath, "AssemblerDataSnapshot.json", "", null);
			this.AssemblerDataSnapshot = this.AssemblerDataSnapshotSerializer.Deserialize();
			
			return Assembler.InstanceInitialized;
		}
		public Assembler InitializedWithSame(IStatusReporter mainForm) {
			if (this.StatusReporter == mainForm) return Assembler.InstanceInitialized;
			return this.Initialize(mainForm);
		}
		protected ScriptExecutor(ChartShadow chartShadow, Strategy strategy, 
		                         OrderProcessor orderProcessor, IStatusReporter statusReporter) : this() {
			this.Initialize(chartShadow, strategy, orderProcessor, statusReporter);
		}
		public void Initialize(string rootPath, IStatusReporter mainForm) {
			//if (rootPath.EndsWith(Path.DirectorySeparatorChar) == false) rootPath += Path.DirectorySeparatorChar;
			this.DataSnapshot.Initialize(rootPath);
			this.StatusReporter = mainForm;
		}
		public void Initialize(ChartShadow chartShadow,
		                       Strategy strategy, OrderProcessor orderProcessor, IStatusReporter statusReporter) {

			string msg = " at this time, FOR SURE this.Bars==null, strategy.Script?=null";
			this.ChartShadow = chartShadow;
			this.Strategy = strategy;
			this.OrderProcessor = orderProcessor;
			this.StatusReporter = statusReporter;

			if (this.Strategy != null) {
				if (this.Bars != null) {
					this.Strategy.ScriptContextCurrent.Symbol = this.Bars.Symbol;
					this.Strategy.ScriptContextCurrent.DataSourceName = this.DataSource.Name;
				}
				if (this.Strategy.Script == null) {
					msg = "I will be compiling this.Strategy.Script when in ChartFormsManager.StrategyCompileActivatePopulateSliders()";
					//} else if (this.Bars == null) {
					//	msg = "InitializeStrategyAfterDeserialization will Script.Initialize(this) later with bars";
				} else {
					this.Strategy.Script.Initialize(this);
				}
			}
			this.ExecutionDataSnapshot.Initialize();
			// Executor.Bars are NULL in ScriptExecutor.ctor() and NOT NULL in SetBars
			//this.Performance.Initialize();
			this.MarketSimStreaming.Initialize();
		}