コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TtsEspHelper"/> class.
        /// </summary>
        /// <param name="language">Language.</param>
        /// <param name="voicePath">Voice font path.</param>
        /// <param name="langDllPath">Language dll path.</param>
        /// <param name="langDataPath">Language data path.</param>
        /// <param name="mode">Process mode.</param>
        public TtsEspHelper(Language language, string voicePath, string langDllPath,
            string langDataPath, ProcessMode mode)
        {
            if (string.IsNullOrEmpty(voicePath))
            {
                voicePath = null;
            }

            if (string.IsNullOrEmpty(langDllPath))
            {
                langDllPath = null;
            }

            if (string.IsNullOrEmpty(langDataPath))
            {
                langDataPath = null;
            }

            _language = language;
            if (string.IsNullOrEmpty(langDllPath) && string.IsNullOrEmpty(langDataPath))
            {
                _engine = new SP.TtsEngine((SP.Language)language, voicePath);
            }
            else if (string.IsNullOrEmpty(langDataPath))
            {
                _engine = new SP.TtsEngine((SP.Language)language, voicePath, langDllPath);
            }
            else
            {
                _engine = new SP.TtsEngine((SP.Language)language, voicePath, langDllPath, langDataPath);
            }

            _mode = mode;
        }
コード例 #2
0
 private void SetDefaultValues()
 {
     this.ExecutionMode = ProcessMode.GuidMode;
     this.ServerIP      = "192.168.3.169";
     this.TransferMode  = TransMode.HTTP;
     this.PortNumber    = "8080";
 }
コード例 #3
0
        public IProcessor CreateProcessor(ProcessMode mode)
        {
            IProcessor processor;

            switch (mode)
            {
            case ProcessMode.compress:
            {
                processor = new Compressor();
                break;
            }

            case ProcessMode.decompress:
            {
                processor = new Decompressor();
                break;
            }

            default:
            {
                throw new Exception("Неверный режим работы программы!");
            }
            }
            return(processor);
        }
コード例 #4
0
        public void JobProcessStress_3(ProcessMode mode)
        {
            var archetype = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(EcsTestData2), typeof(EcsTestData3));

            var entities = new NativeArray <Entity>(StressTestEntityCount, Allocator.Temp);

            m_Manager.CreateEntity(archetype, entities);
            for (int i = 0; i < entities.Length; i++)
            {
                m_Manager.SetComponentData(entities[i], new EcsTestData(i));
            }

            Schedule <Process3>(mode);

            for (int i = 0; i < entities.Length; i++)
            {
                Assert.AreEqual(0, m_Manager.GetComponentData <EcsTestData2>(entities[i]).value0);
                Assert.AreEqual(0, m_Manager.GetComponentData <EcsTestData3>(entities[i]).value0);
                Assert.AreEqual(0, m_Manager.GetComponentData <EcsTestData3>(entities[i]).value1);

                Assert.AreEqual(i, m_Manager.GetComponentData <EcsTestData2>(entities[i]).value1);
                Assert.AreEqual(i, m_Manager.GetComponentData <EcsTestData3>(entities[i]).value2);
            }

            entities.Dispose();
        }
コード例 #5
0
        void DimentionAnalyse()
        {
            var control = new DimentionAnalyseControl();
            var vm      = new DimentionAnalyseControlViewModel()
            {
                IsBusy = true
            };

            control.DataContext = vm;
            OpenView("Dimention Analyse(" + ProcessMode.ToString() + "):" + GetHeader(), control);
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Save();
                    var rl = TargetObject.GetDimentionAnalyse();


                    App.Current.Dispatcher.Invoke(() =>
                    {
                        vm.LoadData(rl);
                    });
                }
                catch (Exception ex)
                {
                    LogSupport.Error(ex);
                }
            }).ContinueWith((t) =>
            {
                vm.IsBusy = false;
            });
        }
コード例 #6
0
        void Surface()
        {
            var control = new SurfaceControl();
            var vm      = new SurfaceControlViewModel()
            {
                IsBusy = true
            };

            control.DataContext = vm;
            OpenView("3 Matrix Analyse(" + ProcessMode.ToString() + "):" + GetHeader(), control);
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Save();
                    Dictionary <string, List <Tuple <double, double, double> > > rl = TargetObject.Get3DCurve();


                    App.Current.Dispatcher.Invoke(() =>
                    {
                        vm.LoadData(rl);
                    });
                }
                catch (Exception ex)
                {
                    LogSupport.Error(ex);
                }
            }).ContinueWith((t) =>
            {
                vm.IsBusy = false;
            });
        }
コード例 #7
0
        void TimeTrend()
        {
            if (!CanStart())
            {
                return;
            }
            var control = new DistributeTrendControl();
            var vm      = control.DataContext as DistributeTrendViewModel;

            vm.IsTimeMode = true;
            OpenView("Trend Time(" + ProcessMode.ToString() + "):" + GetHeader(), control);
            Task.Factory.StartNew(() =>
            {
                Save();
                var ml = TargetObject.GetMarketDataList();
                var tl = TargetObject.GetDistributeTrendByTime(ml);
                App.Current.Dispatcher.Invoke(() =>
                {
                    vm.LoadData(tl);
                });
            }).ContinueWith((t) =>
            {
                vm.IsBusy = false;
            });
        }
コード例 #8
0
        public NodeScheduler(ProcessMode mode)
        {
            ProcessMode = mode;

            SetProcess(ProcessMode == ProcessMode.Idle);
            SetPhysicsProcess(ProcessMode == ProcessMode.Physics);
        }
コード例 #9
0
 private void SetLogEntryProperties(Net.Logging.LogEvent entry)
 {
     entry.User     = CurrentUser.UserName;
     entry.Computer = ClientIpAddress;
     entry.Source   = ClientApplicationName;
     entry.Category = ProcessMode.ToString();
 }
コード例 #10
0
        void MarketSurface()
        {
            if (!CanStart())
            {
                return;
            }
            var control = new DistributeSurfaceControl();
            var vm      = new DistributeSurfaceViewModel()
            {
                IsBusy = true
            };

            control.DataContext = vm;
            OpenView("Trend Market(" + ProcessMode.ToString() + "):" + GetHeader(), control);
            Task.Factory.StartNew(() =>
            {
                try {
                    Save();
                    var ml = TargetObject.GetMarketDataList();
                    var tl = TargetObject.GetDistributeTrendByMarket(ml);
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        vm.LoadData(tl);
                    });
                }
                catch (Exception ex)
                {
                    LogSupport.Error(ex);
                }
            }).ContinueWith((t) =>
            {
                vm.IsBusy = false;
            });
        }
コード例 #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            hash ^= interactions_.GetHashCode();
            hash ^= ioMappings_.GetHashCode();
            hash ^= tags_.GetHashCode();
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            hash ^= authors_.GetHashCode();
            if (ProcessMode != 0)
            {
                hash ^= ProcessMode.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #12
0
        public void Process(ProcessMode processMode, AnimationClip prioritize, EePreviewAvatar previewSetup)
        {
            var clipDictionary    = GatherAnimations(processMode);
            var animationPreviews = ToPrioritizedList(clipDictionary, prioritize);

            _eeRenderingCommands.GenerateSpecific(animationPreviews, previewSetup);
        }
コード例 #13
0
        private void GetSelected(ProcessMode process)
        {
            if (!GetActiveSchoolYear())
            {
                return;
            }
            GridView gridView = ListGridControl.FocusedView as GridView;

            if (gridView == null)
            {
                return;
            }

            object item = gridView.GetRow(gridView.FocusedRowHandle);

            campaignGroupBl.MapToViewModel(item);

            if (process == ProcessMode.Update)
            {
                CampaignGroupEditForm editForm = new CampaignGroupEditForm(campaignGroupBl);
                editForm.ShowDialog();
                RefreshWhenChanged();
            }
            else if (process == ProcessMode.Delete)
            {
                CampaignGroupDeleteForm deleteForm = new CampaignGroupDeleteForm(campaignGroupBl);
                deleteForm.ShowDialog();
                campaignGroupBl.ResetVmParams();
                RefreshWhenChanged();
            }

            //todo create roster management con
            //todo close this
            //todo show roster management con
        }
コード例 #14
0
        public SimpleStreamNode(ProcessMode mode, Stream stream)
        {
            this.ThreadMainLock  = new object();
            this.ThreadReadLock  = new object();
            this.ThreadWriteLock = new object();

            this.QueueSyncRoot    = new object();
            this.ProcessSyncRoot  = new object();
            this.OpenedWaitHandle = new StateWaitHandle(true, () => this.Connected == true);
            this.ClosedWaitHandle = new StateWaitHandle(false, () => this.Connected == false);

            this.Mode       = mode;
            this.BaseStream = stream;

            this.ThreadMain  = null;
            this.ThreadRead  = null;
            this.ThreadWrite = null;

            this.Running   = false;
            this.Closing   = false;
            this.Stopping  = false;
            this.Connected = false;

            this.Queue           = new List <PacketOperation <T> >();
            this.QueueResetEvent = new ManualResetEventSlim();
        }
コード例 #15
0
            public void Process(int[] instructions)
            {
                State = instructions.ToArray();

                for (_pointer = 0, _isProcessing = true; _isProcessing;)
                {
                    var paramCodeString = ParamCode.ToString().PadLeft(5, Convert.ToChar("0"));
                    var paramCodeArray  = paramCodeString.ToArray();

                    _paramModes = new ProcessMode[3];

                    string lastTwoFromParamCode = paramCodeArray[3] + paramCodeArray[4].ToString();
                    _paramModes[0] = GetProcessModeForParam(paramCodeArray[2]);
                    _paramModes[1] = GetProcessModeForParam(paramCodeArray[1]);
                    _paramModes[2] = GetProcessModeForParam(paramCodeArray[0]);

                    var opCode = Int32.Parse(lastTwoFromParamCode);


                    if (_operations.ContainsKey(opCode))
                    {
                        _operations[opCode]();
                    }
                    else
                    {
                        throw new Exception($"{opCode} OpCode Not Found");
                    }
                }
            }
コード例 #16
0
        public static IScheduler GetScheduler([NotNull] this Node node, ProcessMode mode)
        {
            Ensure.Any.IsNotNull(node, nameof(node));

            IScheduler scheduler;

            switch (mode)
            {
            case ProcessMode.Physics:
                scheduler = GetPhysicsScheduler(node);
                break;

            case ProcessMode.Idle:
                scheduler = GetIdleScheduler(node);
                break;

            case ProcessMode.Disable:
                scheduler = null;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }

            return(scheduler);
        }
コード例 #17
0
    public void AllExportXml()
    {
        if (Directory.Exists(m_Window.SettingUI.XmlExportDirectory))
        {
            Directory.Delete(m_Window.SettingUI.XmlExportDirectory, true);
            AssetDatabase.Refresh();
        }
        if (!Directory.Exists(m_Window.SettingUI.XmlExportDirectory))
        {
            Directory.CreateDirectory(m_Window.SettingUI.XmlExportDirectory);
            AssetDatabase.Refresh();
        }

        m_ExportProcessMode = ProcessMode.AllExportXml;
        m_ProcessResults.Clear();
        m_ShowCount = 0;
        m_ProcessResults.Add("###<color=#ffffff>导出Excel为Xml文件</color>");

        if (m_ProcessThread != null)
        {
            m_ProcessThread.Abort();
            m_ProcessThread = null;
        }

        m_ProcessThread = new Thread(ExportXmlProcess);
        m_ProcessThread.Start();
    }
コード例 #18
0
        private void rbCommandMode_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton rb = (sender as RadioButton);

            switch (rb.Name)
            {
            case "rbDefault":
                processMode = ProcessMode.Default;
                break;

            case "rbShotAt":
                processMode = ProcessMode.ShotAt;
                break;

            case "rbCreatedAt":
                processMode = ProcessMode.CreatedAt;
                break;

            case "rbUpdateAt":
                processMode = ProcessMode.UpdatedAt;
                break;

            default:
                break;
            }
        }
コード例 #19
0
        private void GetSelected(ProcessMode process)
        {
            GridView gridView = ListGridControl.FocusedView as GridView;

            if (gridView == null)
            {
                return;
            }

            object item = gridView.GetRow(gridView.FocusedRowHandle);

            sectionBl.MapToViewModel(item);

            if (process == ProcessMode.Update)
            {
                SectionEditForm editForm = new SectionEditForm(sectionBl);
                editForm.ShowDialog();
                RefreshWhenChanged();
            }
            else
            {
                SectionDeleteForm deleteForm = new SectionDeleteForm(sectionBl);
                deleteForm.ShowDialog();
                sectionBl.ResetVmParams();
                RefreshWhenChanged();
            }
        }
コード例 #20
0
ファイル: SampleAttribute.cs プロジェクト: kitfka/AlleyCat
        public SampleAttribute(
            string key,
            string displayName,
            Option <string> description,
            Option <Texture> icon,
            string target,
            TimeSpan period,
            ProcessMode processMode,
            ITimeSource timeSource,
            Map <string, IAttribute> children,
            bool active,
            ILoggerFactory loggerFactory) : base(
                key,
                displayName,
                description,
                icon,
                target,
                false,
                children,
                active,
                loggerFactory)
        {
            Ensure.That(timeSource, nameof(timeSource)).IsNotNull();

            Period      = period;
            ProcessMode = processMode;
            TimeSource  = timeSource;
        }
コード例 #21
0
        public AnimationStateManager(
            AnimationPlayer player,
            AnimationTree animationTree,
            Option <IAnimationGraphFactory> graphFactory,
            Option <IAnimationControlFactory> controlFactory,
            ProcessMode processMode,
            ITimeSource timeSource,
            bool active,
            ILoggerFactory loggerFactory) : base(player, processMode, timeSource, active, loggerFactory)
        {
            Ensure.That(animationTree, nameof(animationTree)).IsNotNull();

            AnimationTree = animationTree;

            GraphFactory   = graphFactory.IfNone(() => new AnimationGraphFactory());
            ControlFactory = controlFactory.IfNone(() => new AnimationControlFactory());

            Context = new AnimationGraphContext(
                Player,
                AnimationTree,
                OnAdvance,
                GraphFactory,
                ControlFactory,
                loggerFactory);

            _graph = GraphFactory.TryCreate((AnimationRootNode)AnimationTree.TreeRoot, Context).IfNone(() =>
                                                                                                       throw new ArgumentException(
                                                                                                           "Failed to create animation graph from the specified animation tree.",
                                                                                                           nameof(animationTree)));

            AnimationTree.ProcessMode = AnimationTree.AnimationProcessMode.Manual;

            this.LogDebug("Using graph factory: {}.", GraphFactory);
            this.LogDebug("Using control factory: {}.", ControlFactory);
        }
コード例 #22
0
        public async Task ProcessAsync(ProcessMode processMode, CancellationToken token)
        {
            var start = await _cursorService.GetValueAsync(_processor.CursorName);

            var end = await _cursorService.GetMinimumAsync(_processor.DependencyCursorNames);

            int commitCount;

            do
            {
                var commits = await _enumerator.GetCommitsAsync(
                    start,
                    end,
                    _processor.BatchSize);

                var entityCount = commits.Sum(x => x.Entities.Count);
                commitCount = commits.Count;

                if (commits.Any())
                {
                    var min = commits.Min(x => x.CommitTimestamp);
                    var max = commits.Max(x => x.CommitTimestamp);
                    start = max;
                    _logger.LogInformation(
                        "Fetched {CommitCount} commits ({EntityCount} {EntityName}) between {Min:O} and {Max:O}.",
                        commitCount,
                        entityCount,
                        typeof(TEntity).Name,
                        min,
                        max);
                }
                else
                {
                    _logger.LogInformation("No more commits were found within the bounds.");
                }

                switch (processMode)
                {
                case ProcessMode.Sequentially:
                    await ProcessSequentiallyAsync(commits, token);

                    break;

                case ProcessMode.TaskQueue:
                    await ProcessTaskQueueAsync(commits, token);

                    break;

                default:
                    throw new NotImplementedException();
                }

                if (commits.Any())
                {
                    _logger.LogInformation("Cursor {CursorName} moving to {Start:O}.", _processor.CursorName, start);
                    await _cursorService.SetValueAsync(_processor.CursorName, start);
                }
            }while (commitCount > 0);
        }
コード例 #23
0
        public Parameters(string[] args)
        {
            Validation(args);

            Mode             = (ProcessMode)Enum.Parse(typeof(ProcessMode), args[0]);
            PathToSourceFile = args[1];
            PathToResultFile = args[2];
        }
コード例 #24
0
        public void JobProcessStress_4_WithEntity(ProcessMode mode, [Values(0, 1, 1000)] int entityCount)
        {
            var entities = PrepareData(entityCount);

            Schedule <Process4Entity>(mode);

            CheckResultsAndDispose(entities, 4, true);
        }
コード例 #25
0
 public ProcessManager(string inputFile, string outputFile, ProcessMode mode)
 {
     m_inputFile   = inputFile;
     m_outputFile  = outputFile;
     m_processMode = mode;
     m_compressor  = new Compressors.GZipCompressor();
     InitializePlan();
 }
コード例 #26
0
        public void JobProcessStress_3(ProcessMode mode, [Values(0, 1, 1000)] int entityCount)
        {
            var entities = PrepareData(entityCount);

            Schedule <Process3>(mode);

            CheckResultsAndDispose(entities, 3, false);
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TtsEspHelper"/> class.
 /// </summary>
 /// <param name="serviceProvider">ServiceProvider.</param>
 /// <param name="language">Language.</param>
 /// <param name="mode">Process mode.</param>
 public TtsEspHelper(SP.ServiceProvider serviceProvider, Language language, ProcessMode mode)
 {
     Helper.ThrowIfNull(serviceProvider);
     _serviceProvider = serviceProvider;
     _engine = serviceProvider.Engine;
     _language = language;
     _mode = mode;
 }
コード例 #28
0
        public void JobProcessMixedStress_6([Values] CallMode call, [Values] ProcessMode mode, [Values(0, 1, 1000)] int entityCount)
        {
            var archetype = m_Manager.CreateArchetype(typeof(EcsIntElement), typeof(EcsIntElement2), typeof(EcsIntElement3), typeof(EcsTestData), typeof(EcsTestData2), typeof(EcsTestData3));

            var entities = new NativeArray <Entity>(entityCount, Allocator.Temp);

            m_Manager.CreateEntity(archetype, entities);

            if (call == CallMode.System)
            {
                if (mode == ProcessMode.Parallel)
                {
                    (new Process6Mixed()).Schedule(EmptySystem).Complete();
                }
                else if (mode == ProcessMode.Run)
                {
                    (new Process6Mixed()).Run(EmptySystem);
                }
                else
                {
                    (new Process6Mixed()).ScheduleSingle(EmptySystem).Complete();
                }
            }
            else
            {
                var query = m_Manager.CreateEntityQuery(typeof(EcsIntElement), typeof(EcsIntElement2), typeof(EcsIntElement3), typeof(EcsTestData), typeof(EcsTestData2), typeof(EcsTestData3));
                if (mode == ProcessMode.Parallel)
                {
                    (new Process6Mixed()).Schedule(query).Complete();
                }
                else if (mode == ProcessMode.Run)
                {
                    (new Process6Mixed()).Run(query);
                }
                else
                {
                    (new Process6Mixed()).ScheduleSingle(query).Complete();
                }
            }

            for (int i = 0; i < entities.Length; i++)
            {
                {
                    var expectedResult = 1;
                    Assert.AreEqual(expectedResult, m_Manager.GetBuffer <EcsIntElement>(entities[i]).Length);
                    Assert.AreEqual(expectedResult, m_Manager.GetBuffer <EcsIntElement2>(entities[i]).Length);
                    Assert.AreEqual(expectedResult, m_Manager.GetBuffer <EcsIntElement3>(entities[i]).Length);
                }

                {
                    var expectedResult = entities[i].Index + i;
                    Assert.AreEqual(expectedResult, m_Manager.GetComponentData <EcsTestData>(entities[i]).value);
                    Assert.AreEqual(expectedResult, m_Manager.GetComponentData <EcsTestData2>(entities[i]).value1);
                    Assert.AreEqual(expectedResult, m_Manager.GetComponentData <EcsTestData3>(entities[i]).value2);
                }
            }
            entities.Dispose();
        }
コード例 #29
0
 public ImmediateLocomotion(
     Spatial target,
     ProcessMode processMode,
     ITimeSource timeSource,
     bool active,
     ILoggerFactory loggerFactory) : base(target, timeSource, active, loggerFactory)
 {
     ProcessMode = processMode;
 }
コード例 #30
0
 public ProcessClass(object filelist, ProcessMode mode, int SampleRate, int CodeRate, string Formate)
 {
     Environment.CurrentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     PValue   = -1;
     Mode     = mode;
     FileList = filelist;
     SR       = SampleRate;
     CR       = CodeRate;
     FM       = Formate;
 }
コード例 #31
0
        public void JobProcessStress_4_WithEntity([Values] ProcessMode mode, [Values(0, 1, 1000)] int entityCount)
        {
            var entities = PrepareData(entityCount);

#if UNITY_ZEROPLAYER
            (new Process4Entity()).Schedule(EmptySystem);
#else
            Schedule <Process4Entity>(mode);
#endif
            CheckResultsAndDispose(entities, 4, true);
        }
コード例 #32
0
 private void RadioButton_Checked(object sender, RoutedEventArgs e)
 {
     if ((sender as RadioButton).Tag != null)
     {
         this.Mode = (ProcessMode)Int32.Parse((sender as RadioButton).Tag.ToString());
         learnTypeStack.IsEnabled = this.Mode != ProcessMode.ProcessLearned;
     }
     else
     {
         this.Mode = ProcessMode.Learn;
     }
 }
コード例 #33
0
 protected void readXml(string fileName) {
     StreamReader sr = new StreamReader(fileName);
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(sr.ReadToEnd());
     sr.Close();
     XmlNode node = null;
     foreach (XmlNode n in doc.ChildNodes) {
         if (n.Name == "instances") {
             _dataSetName = n.Attributes[0].Value;
             _dataSourceName = n.Attributes[1].Value;
             if (n.Attributes[2].Value == "text")
                 _media = MediaType.Text;
             else if (n.Attributes[2].Value == "image")
                 _media = MediaType.Image;
             else if (n.Attributes[2].Value == "video")
                 _media = MediaType.Video;
             else if (n.Attributes[2].Value == "audio")
                 _media = MediaType.Audio;
             if (n.Attributes[3].Value == "learn")
                 _opMode = OperationMode.Learn;
             else if (n.Attributes[3].Value == "validate")
                 _opMode = OperationMode.Validate;
             else if (n.Attributes[3].Value == "classify")
                 _opMode = OperationMode.Classify;
             if (n.Attributes[4].Value == "batch")
                 _procMode = ProcessMode.Batch;
             else if (n.Attributes[4].Value == "online")
                 _procMode = ProcessMode.Batch;
             node = n;
             break;
         }
     }
     //parse the IOs
     foreach (XmlNode n in node.ChildNodes) {
         if (n.Name == "input") {
             _sc.InputConditioners.Add(new ScaleAndOffset(
                 double.Parse(n.Attributes[1].Value),
                 double.Parse(n.Attributes[2].Value)));
         } else if (n.Name == "output") {
             _sc.OutputConditioners.Add(new ScaleAndOffset(
                 double.Parse(n.Attributes[1].Value),
                 double.Parse(n.Attributes[2].Value)));
         }
     }
 }
コード例 #34
0
ファイル: CmdInput.cs プロジェクト: nguyenhuuhuy/mygeneration
		private void Parse(string[] args) 
		{
			int numargs = args.Length;
			string arg;

			if (numargs == 0) 
			{
				this._showHelp = true;
				return;
			}

			for (int i = 0; i < numargs; i++) 
			{
				arg = args[i];

				switch (arg)
                {
                    case "-internaluse":
                        this._internalUse = true;
                        break;
                    case "-installvs2005":
                        this._installVS2005 = true;
                        break;
                    case "-tc":
                    case "-testconnection":
                        this._mode = ProcessMode.MyMeta;
                        if (numargs > (i + 2))
                        {
                            this._connType = args[++i];
                            this._connString = args[++i];
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
					case "-aio":
					case "-addintrinsicobject":
						if (numargs > (i+3)) 
						{
							string assembly = args[++i];
							string classpath = args[++i];
							string varname = args[++i];

							ZeusIntrinsicObject iobj = new ZeusIntrinsicObject(assembly, classpath, varname);
							this._intrinsicObjects.Add(iobj);
						}
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-rio":
					case "-removeintrinsicobject":
                        if (numargs > (i + 1))
                        {
                            string varname = args[++i];
                            foreach (ZeusIntrinsicObject zio in ZeusConfig.Current.IntrinsicObjects)
                            {
                                if (zio.VariableName == varname && !_intrinsicObjectsToRemove.Contains(zio))
                                {
                                    this._intrinsicObjectsToRemove.Add(zio);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
					case "-r":
					case "-relative":
						this._makeRelative = true;
						break;
					case "-s":
					case "-silent":
						this._silent = true;
						break;
					case "-?":
					case "-h":
					case "-help":
						this._showHelp = true;
						break;
					case "-l":
					case "-logfile":
						this._enableLog = true;
						if (numargs > (i+1)) 
							this._pathLog = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-o":
					case "-outfile":
						if (numargs > (i+1)) 
							this._pathOutput = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-p":
					case "-project":
						this._mode = ProcessMode.Project;
						if (numargs > (i+1)) 
							this._pathProject = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-mumd":
                    case "-mergeusermetadata":
                        this._mode = ProcessMode.MyMeta;
                        this._metaDataMerge = true;
                        if (numargs > (i + 5))
                        {
                            this._metaDataFile1 = args[++i];
                            this._metaDatabase1 = args[++i];
                            this._metaDataFile2 = args[++i];
                            this._metaDatabase2 = args[++i];
                            this._metaDataFileMerged = args[++i];
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
                    case "-m":
                    case "-pf":
                    case "-module":
                    case "-projectfolder":
						if (numargs > (i+1)) 
						{
							string data = args[++i];
							if (!_moduleNames.Contains(data))
								this._moduleNames.Add(data);
						}
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
                        break;
                    case "-rti":
                    case "-recordtemplateinstance":
                        if (numargs > (i + 1))
                        {
                            this._projectItemToRecord = args[++i];
                            this._mode = ProcessMode.Project;
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
                    case "-ti":
                    case "-templateinstance":
                        if (numargs > (i + 1))
                        {
                            string data = args[++i];
                            if (!_projectItems.Contains(data))
                                this._projectItems.Add(data);
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
					case "-i":
					case "-inputfile":
						this._mode = ProcessMode.Template;
						if (numargs > (i+1)) 
							this._pathXmlData = args[++i];
						else  
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-t":
					case "-template":
						this._mode = ProcessMode.Template;
						if (numargs > (i+1)) 
							this._pathTemplate = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-c":
					case "-collect":
						this._mode = ProcessMode.Template;
						if (numargs > (i+1)) 
							this._pathCollectXmlData = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-e":
					case "-timeout":
						if (numargs > (i+1)) 
						{
							try 
							{
								this._timeout = Int32.Parse(args[++i]);
							}
							catch 
							{
								this._timeout = -1;
							}
						}
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					default:
						_valid = false;
						this._errorMessage = "Invalid argument: " + arg;
						break;
				}
			}

			if (this._makeRelative) 
			{
				if (this._pathCollectXmlData != null)
					this._pathCollectXmlData = Zeus.FileTools.MakeAbsolute(this._pathCollectXmlData, FileTools.ApplicationPath);
				if (this._pathLog != null)
                    this._pathLog = Zeus.FileTools.MakeAbsolute(this._pathLog, FileTools.ApplicationPath);
				if (this._pathOutput != null)
                    this._pathOutput = Zeus.FileTools.MakeAbsolute(this._pathOutput, FileTools.ApplicationPath);
				if (this._pathProject != null)
                    this._pathProject = Zeus.FileTools.MakeAbsolute(this._pathProject, FileTools.ApplicationPath);
				if (this._pathTemplate != null)
                    this._pathTemplate = Zeus.FileTools.MakeAbsolute(this._pathTemplate, FileTools.ApplicationPath);
				if (this._pathXmlData != null)
                    this._pathXmlData = Zeus.FileTools.MakeAbsolute(this._pathXmlData, FileTools.ApplicationPath);
                if (this._metaDataFile1 != null)
                    this._metaDataFile1 = Zeus.FileTools.MakeAbsolute(this._metaDataFile1, FileTools.ApplicationPath);
                if (this._metaDataFile2 != null)
                    this._metaDataFile2 = Zeus.FileTools.MakeAbsolute(this._metaDataFile2, FileTools.ApplicationPath);
                if (this._metaDataFileMerged != null)
                    this._metaDataFileMerged = Zeus.FileTools.MakeAbsolute(this._metaDataFileMerged, FileTools.ApplicationPath);
			}


			// Validate required fields are filled out for the selected mode.
			if (_valid) 
			{
                if (this.Mode == ProcessMode.MyMeta) 
                {
                    if (this._metaDataMerge)
                    {
                        if (!System.IO.File.Exists(_metaDataFile1) || !System.IO.File.Exists(_metaDataFile2))
                        {
                            _valid = false;
                            this._errorMessage = "The two source files must exist for the merge to work!";
                        }
                    }
                }
				else if (this._mode == ProcessMode.Project) 
				{
					if (this._pathProject == null)
					{
						_valid = false;
						this._errorMessage = "Project Path Required";
					}
					else 
					{
						try 
						{
							this._project = new ZeusProject(this._pathProject);
							this._project.Load();
						}
						catch (Exception ex)
						{
							this._project = null;
							this._valid = false;
							this._errorMessage = ex.Message;
						}
					}


                    if (this._pathTemplate != null)
                    {
                        try
                        {
                            this._template = new ZeusTemplate(this._pathTemplate);
                        }
                        catch (Exception ex)
                        {
                            this._template = null;
                            this._valid = false;
                            this._errorMessage = ex.Message;
                        }
                    }
				}
				else if (this._mode == ProcessMode.Template) 
				{
					if ( (this._pathTemplate == null) && (this._pathXmlData == null) )
					{
						_valid = false;
						this._errorMessage = "Template path or XML input path required.";
					}
					else 
					{
						if (this._pathTemplate != null)
						{
							try 
							{
								this._template = new ZeusTemplate(this._pathTemplate);
							}
							catch (Exception ex)
							{
								this._template = null;
								this._valid = false;
								this._errorMessage = ex.Message;
							}
						}

						if ( (this._valid) && (this._pathXmlData != null) )
						{
							try 
							{
								this._savedInput = new ZeusSavedInput(this._pathXmlData);
								this._savedInput.Load();

								if (this._template == null) 
								{
									this._template = new ZeusTemplate(this._savedInput.InputData.TemplatePath);
								}
							}
							catch (Exception ex)
							{
								this._savedInput = null;
								this._template = null;
								this._valid = false;
								this._errorMessage = ex.Message;
							}
						}

						if ( (this._valid) && (this._pathCollectXmlData != null) )
						{
							try 
							{
								this._inputToSave = new ZeusSavedInput(this._pathCollectXmlData);
								this._inputToSave.InputData.TemplatePath = this._template.FilePath + this._template.FileName;
								this._inputToSave.InputData.TemplateUniqueID = this._template.UniqueID;
							}
							catch (Exception ex)
							{
								this._inputToSave = null;
								this._valid = false;
								this._errorMessage = ex.Message;
							}
						}
					}
				}

			}
		}
コード例 #35
0
        } // GetChildItems

        /// <summary>
        /// Since we can't do include and exclude filtering on items we have to
        /// do the recursion ourselves. We get each child name and see if it matches
        /// the include and exclude filters. If the child is a container we recurse
        /// into that container.
        /// </summary>
        ///
        /// <param name="providerInstance">
        /// The instance of the provider to use.
        /// </param>
        /// 
        /// <param name="path">
        /// The path to the item to get the children from.
        /// </param>
        ///
        /// <param name="recurse">
        /// Recurse into sub-containers when getting children.
        /// </param>
        ///
        /// <param name="context">
        /// The context under which the command is running.
        /// </param>
        /// 
        /// <param name="childrenNotMatchingFilterCriteria">
        /// The count of items that do not match any include/exclude criteria.
        /// </param> 
        /// 
        /// <param name="processMode">Indicates if this is a Enumerate/Remove operation</param>
        /// 
        /// <param name="skipIsItemContainerCheck">a hint used to skip IsItemContainer checks</param>
        ///
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// 
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// 
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// 
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        /// 
        private void ProcessPathItems(
            CmdletProvider providerInstance,
            string path,
            bool recurse,
            CmdletProviderContext context,
            out int childrenNotMatchingFilterCriteria,
            ProcessMode processMode = ProcessMode.Enumerate,
            bool skipIsItemContainerCheck = false)
        {
            ContainerCmdletProvider containerCmdletProvider = GetContainerProviderInstance(providerInstance);
            childrenNotMatchingFilterCriteria = 0;

            Dbg.Diagnostics.Assert(
                providerInstance != null,
                "The caller should have verified the providerInstance");

            Dbg.Diagnostics.Assert(
                path != null,
                "The caller should have verified the path");

            Dbg.Diagnostics.Assert(
                context != null,
                "The caller should have verified the context");

            // Construct the include filter

            Collection<WildcardPattern> includeMatcher =
                SessionStateUtilities.CreateWildcardsFromStrings(
                    context.Include,
                    WildcardOptions.IgnoreCase);


            // Construct the exclude filter

            Collection<WildcardPattern> excludeMatcher =
                SessionStateUtilities.CreateWildcardsFromStrings(
                    context.Exclude,
                    WildcardOptions.IgnoreCase);

            // If the item is a container we have to filter its children
            // Use a hint + lazy evaluation to skip a container check

            if (skipIsItemContainerCheck || IsItemContainer(providerInstance, path, context))
            {
                CmdletProviderContext newContext =
                    new CmdletProviderContext(context);

                Collection<PSObject> childNameObjects = null;
                System.Collections.Generic.Dictionary<string, bool> filteredChildNameDictionary = null;

                try
                {
                    // Get all the child names
                    GetChildNames(
                        providerInstance,
                        path,
                        (recurse) ? ReturnContainers.ReturnAllContainers : ReturnContainers.ReturnMatchingContainers,
                        newContext);
                    newContext.WriteErrorsToContext(context);
                    childNameObjects = newContext.GetAccumulatedObjects();


                    // The code above initially retrieves all of the containers so that it doesn't limit the recursion,
                    // but then emits the non-matching container further down. The public API doesn't support a way to
                    // differentiate the two, so we need to do a diff.
                    // So if there was a filter, do it again to get the fully filtered items.
                    if (recurse && (providerInstance.IsFilterSet()))
                    {
                        newContext.RemoveStopReferral();
                        newContext = new CmdletProviderContext(context);
                        filteredChildNameDictionary = new System.Collections.Generic.Dictionary<string, bool>();

                        GetChildNames(
                            providerInstance,
                            path,
                            ReturnContainers.ReturnMatchingContainers,
                            newContext);
                        var filteredChildNameObjects = newContext.GetAccumulatedObjects();

                        foreach (PSObject filteredChildName in filteredChildNameObjects)
                        {
                            string filteredName = filteredChildName.BaseObject as string;
                            if (filteredName != null)
                            {
                                filteredChildNameDictionary[filteredName] = true;
                            }
                        }
                    }
                }
                finally
                {
                    newContext.RemoveStopReferral();
                }

                // Now loop through all the child objects matching the filters and recursing
                // into containers
                for (int index = 0; index < childNameObjects.Count; ++index)
                {
                    // Making sure to obey the StopProcessing.
                    if (context.Stopping)
                    {
                        return;
                    }

                    string childName = childNameObjects[index].BaseObject as string;

                    if (childName == null)
                    {
                        continue;
                    }

                    // Generate the provider path for the child

                    string qualifiedPath = MakePath(providerInstance, path, childName, context);

                    if (qualifiedPath == null)
                    {
                        continue;
                    }

                    bool isIncludeMatch = !context.SuppressWildcardExpansion &&
                        SessionStateUtilities.MatchesAnyWildcardPattern(
                            childName,
                            includeMatcher,
                            true);

                    if (isIncludeMatch)
                    {
                        if (!SessionStateUtilities.MatchesAnyWildcardPattern(
                            childName,
                            excludeMatcher,
                            false))
                        {
                            bool emitItem = true;
                            if (filteredChildNameDictionary != null)
                            {
                                bool isChildNameInDictionary = false;
                                emitItem = filteredChildNameDictionary.TryGetValue(childName, out isChildNameInDictionary);
                            }

                            if (emitItem)
                            {
                                if (processMode == ProcessMode.Delete)
                                {
                                    containerCmdletProvider.RemoveItem(qualifiedPath, false, context);
                                }
                                else if (processMode != ProcessMode.Delete)
                                {
                                    // The object is a match so get it and write it out.
                                    GetItemPrivate(providerInstance, qualifiedPath, context);
                                }
                            }
                        }
                        else
                        {
                            childrenNotMatchingFilterCriteria++;
                        }
                    }
                    else
                    {
                        childrenNotMatchingFilterCriteria++;
                    }

                    // Now recurse if it is a container
                    if (recurse && IsItemContainer(providerInstance, qualifiedPath, context))
                    {
                        // Making sure to obey the StopProcessing.
                        if (context.Stopping)
                        {
                            return;
                        }

                        // The item is a container so recurse into it.
                        ProcessPathItems(providerInstance, qualifiedPath, recurse, context, out childrenNotMatchingFilterCriteria, processMode, skipIsItemContainerCheck: true);
                    }
                } // for each childName
            }
            else
            {
                // The path is not a container so write it out if its name
                // matches the filter

                string childName = path;
                childName = GetChildName(providerInstance, path, context, true);

                // Write out the object if it is a match

                bool isIncludeMatch =
                    SessionStateUtilities.MatchesAnyWildcardPattern(
                        childName,
                        includeMatcher,
                        true);

                if (isIncludeMatch)
                {
                    if (!SessionStateUtilities.MatchesAnyWildcardPattern(
                            childName,
                            excludeMatcher,
                            false))
                    {
                        if (processMode != ProcessMode.Delete)
                        {
                            // The object is a match so get it and write it out.
                            GetItemPrivate(providerInstance, path, context);
                        }
                        else
                        {
                            // The object is a match so, remove it. 
                            containerCmdletProvider.RemoveItem(path, recurse, context);
                        }
                    }
                }
            }
        } // ProcessPathItems
コード例 #36
0
ファイル: Database.cs プロジェクト: Fedorm/core-master
        private void ProcessAllInternal(IEnumerable<IEntity> data, ProcessMode mode, SqliteTransaction tran, bool inTran)
        {
            string[] columns = null;
            var cmd = new SqliteCommand[4];
            String tableName = null;

            try
            {
                foreach (IEntity obj in data)
                {
                    if (cmd[0] == null)
                    {
                        EntityType type = obj.EntityType;
                        columns = GetColumns(type);
                        String fNames = "";
                        String fParameters = "";
                        String fFields = "";
                        foreach (string column in columns)
                        {
                            if (!String.IsNullOrEmpty(fNames))
                            {
                                fNames = fNames + ",";
                                fParameters = fParameters + ",";
                                fFields = fFields + ",";
                            }
                            fNames = fNames + column;
                            fParameters = fParameters + "@" + column;
                            fFields = fFields + String.Format("[{0}] = @{0}", column);
                        }
                        fNames = fNames + ",IsTombstone,IsDirty";
                        fParameters = fParameters + ",@IsTombstone,@IsDirty";
                        fFields = fFields + ",[IsTombstone] = @IsTombstone, [IsDirty] = @IsDirty";
                        
                        tableName = type.TableName;

                        cmd[0] = new SqliteCommand(String.Format("INSERT INTO [_{0}]({1}) VALUES({2})", tableName, fNames, fParameters), ActiveConnection, tran);
                        cmd[1] = new SqliteCommand(String.Format("UPDATE [_{0}] SET {1} WHERE [Id] = @Id", tableName, fFields), ActiveConnection, tran);
                        foreach (string column in columns)
                        {
                            cmd[0].Parameters.Add("@" + column, _supportedTypes[GetType(type.GetPropertyType(column))].DbType);
                            cmd[1].Parameters.Add("@" + column, _supportedTypes[GetType(type.GetPropertyType(column))].DbType);
                        }
                        cmd[0].Parameters.Add("@IsTombstone", System.Data.DbType.Boolean);
                        cmd[0].Parameters.Add("@IsDirty", System.Data.DbType.Boolean);
                        cmd[1].Parameters.Add("@IsTombstone", System.Data.DbType.Boolean);
                        cmd[1].Parameters.Add("@IsDirty", System.Data.DbType.Boolean);

                        cmd[2] = new SqliteCommand(String.Format("SELECT Id FROM [_{0}] WHERE [Id] = @Id", tableName), ActiveConnection, tran);
                        cmd[2].Parameters.Add("@Id", System.Data.DbType.String);

                        cmd[3] = new SqliteCommand(String.Format("DELETE FROM [_{0}] WHERE [Id] = @Id", tableName), ActiveConnection, tran);
                        cmd[3].Parameters.Add("@Id", System.Data.DbType.String);
                    }

                    //row id
                    DbRef id;
                    if (mode == ProcessMode.InitialLoad || mode == ProcessMode.ServerChanges)
                        id = DbRef.CreateInstance(tableName, ((ISqliteEntity)obj).EntityId);
                    else
                        id = DbRef.FromString(obj.GetValue(columns[0]).ToString());

                    int idx = 0; //insert 
                    if (mode != ProcessMode.InitialLoad)
                    {
                        if (((ISqliteEntity)obj).IsTombstone)
                        {
                            idx = mode == ProcessMode.ServerChanges ? 3 : 1;
                        }
                        else
                        {
                            cmd[2].Parameters[0].Value = id;
                            if (cmd[2].ExecuteScalar() != null)
                                idx = 1; //update
                        }
                    }

                    //assign values
                    if (idx > 2) //delete
                    {
                        cmd[idx].Parameters[0].Value = id;
                    }
                    else
                    {
                        int n = 0;
                        foreach (string column in columns)
                        {
                            cmd[idx].Parameters[n].Value = obj.GetValue(column);
                            n++;
                        }
                        cmd[idx].Parameters[n].Value = ((ISqliteEntity)obj).IsTombstone ? 1 : 0; //IsTombstone
                        var entity = (ISqliteEntity)obj;
                        cmd[idx].Parameters[n + 1].Value =
                            mode == ProcessMode.LocalChanges && (entity.IsNew() || entity.IsModified())
                            ? 1 : 0;  //isDirty
                    }

                    if (mode == ProcessMode.LocalChanges && inTran)
                        CopyTranObject(obj, tran, tableName, id.ToString(), idx);

                    cmd[idx].ExecuteNonQuery();
                }
            }
            finally
            {
                foreach (var c in cmd)
                {
                    c.Dispose();
                }
            }

            foreach (SqliteCommand c in cmd)
            {
                if (c != null)
                    c.Dispose();
            }
        }
コード例 #37
0
ファイル: Database.cs プロジェクト: Fedorm/core-master
        public void ProcessData(IEnumerable<IEntity> data, ProcessMode mode, SqliteTransaction tran = null)
        {
            bool inTran = tran != null;
            var toRemoveFromCache = new List<Guid>();

            try
            {
                foreach (IEnumerable<IEntity> lst in GetBlock(data.GetEnumerator()))
                {
                    if (!inTran)
                        tran = ActiveConnection.BeginTransaction();
                    ProcessAllInternal(lst, mode, tran, mode == ProcessMode.LocalChanges);
                    if (!inTran)
                        tran.Commit();

                    if (mode == ProcessMode.ServerChanges)
                    {
                        foreach (ISqliteEntity e in lst)
                            toRemoveFromCache.Add(e.EntityId);
                    }

                    GC.Collect();
                }
                Cache.Clear(toRemoveFromCache);
            }
            catch
            {
                if (tran != null && !inTran)
                    tran.Rollback();
                throw;
            }
        }
コード例 #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TtsEspHelper"/> class.
 /// </summary>
 /// <param name="language">Language.</param>
 /// <param name="voicePath">Voice font path.</param>
 /// <param name="mode">Process mode.</param>
 public TtsEspHelper(Language language, string voicePath, ProcessMode mode) :
     this(language, voicePath, string.Empty, string.Empty, mode)
 {
 }