void ProfileSvc_ProfileLoaded(AsyncOperationInstance operation)
        {
            ProfileSvc.ProfileLoaded -= ProfileSvc_ProfileLoaded;
            var project = ProfileSvc.ProjectID;

            var paths = Settings.getOptions().Paths;


            if (CM.truncateSyncTable())
            {
                CM.disconnectFromMobileDB();
                SessionMgr.endSession();
                SessionMgr.startSession();
                var workingPaths = SessionMgr.createCleanWorkingCopies(paths);
                CM.connectToMobileDB(workingPaths);
            }
            else
            {
                if (CurrentOperation != null)
                {
                    CurrentOperation.failure("Actions_Error_CouldntTruncateSync", "");
                }
                _Log.Info("Could not truncate Sync Table, aborting clean.");
            }


            if (ProfileSvc.ProjectID != project)
            {
                ProfileSvc.ProjectID = project;
            }
            if (CurrentOperation != null)
            {
                CurrentOperation.success();
            }
        }
Esempio n. 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (deleteTime_ != null)
            {
                hash ^= DeleteTime.GetHashCode();
            }
            if (currentOperation_ != null)
            {
                hash ^= CurrentOperation.GetHashCode();
            }
            if (DisplayName.Length != 0)
            {
                hash ^= DisplayName.GetHashCode();
            }
            if (ServeNodes != 0)
            {
                hash ^= ServeNodes.GetHashCode();
            }
            if (DefaultStorageType != global::Google.Bigtable.Admin.Cluster.V1.StorageType.STORAGE_UNSPECIFIED)
            {
                hash ^= DefaultStorageType.GetHashCode();
            }
            return(hash);
        }
Esempio n. 3
0
 private void btnChu_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtShow.Text))
     {
         currentOperation = CurrentOperation.Chu;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 初始化
 /// </summary>
 public void Init()
 {
     firstNumTxt      = "";
     secondNumTxt     = "";
     currentOperation = CurrentOperation.Default;
     txtShow.Text     = "";
 }
Esempio n. 5
0
 public SimulatedClient(Uri userUri, string userName, string password)
 {
     currentOperation = new CurrentOperation(Log);
     UserUri          = userUri;
     UserName         = userName;
     Password         = password;
 }
Esempio n. 6
0
 public SimulatedChatRoom(PersistentChatEndpoint persistentChatEndpoint, SimulatedClient client, Uri roomUri)
 {
     currentOperation = new CurrentOperation(Log);
     Client           = client;
     this.roomUri     = roomUri;
     session          = new ChatRoomSession(persistentChatEndpoint);
 }
        public GitRepository(string directory)
        {
            _gitDirectory         = Repository.Discover(directory);
            _savedState           = new GitHeadState();
            _statusRepository     = GetRepository();
            this.workingDirectory = _statusRepository.Info.WorkingDirectory;
            _repositoryPath       = _statusRepository.Info.Path;
            _objectPath           = _repositoryPath + "objects\\";
            //using (var repository = GetRepository())
            //{
            //    this.workingDirectory = repository.Info.WorkingDirectory;
            //    repositoryPath = repository.Info.Path;
            //}

            _cachedBranchOperation = CurrentOperation.None;
            //_changesetManager = new GitChangesetManager();
            //_lastTipId = repository.Head.Tip.sha;
            Refresh();
            _gitEventObservable = Observable.FromEventPattern(ev => _gitfileEvent += ev, ev => _gitfileEvent -= ev)
                                  .Throttle(TimeSpan.FromMilliseconds(2000));
            _gitEventObservable.Subscribe(x => Task.Run(async() => await DecodeGitEvents()));

            _fileChangedEventObservable = Observable.FromEventPattern(ev => _fileEvent += ev, ev => _fileEvent -= ev)
                                          .Throttle(TimeSpan.FromMilliseconds(250));
            _fileChangedEventObservable.Subscribe(x => Task.Run(async() => await FileChangedEvent()));
        }
Esempio n. 8
0
 private void dequeueAndExecute()
 {
     CurrentOperation          = mQueue.Dequeue();
     CurrentOperation.Succeed += onOperationCompleted;
     CurrentOperation.Failed  += onOperationCompleted;
     CurrentOperation.Execute();
 }
Esempio n. 9
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Activity.Expression != null)
            {
                targetCommand.AddParameter("Activity", Activity.Get(context));
            }

            if (Status.Expression != null)
            {
                targetCommand.AddParameter("Status", Status.Get(context));
            }

            if (ProgressId.Expression != null)
            {
                targetCommand.AddParameter("Id", ProgressId.Get(context));
            }

            if (PercentComplete.Expression != null)
            {
                targetCommand.AddParameter("PercentComplete", PercentComplete.Get(context));
            }

            if (SecondsRemaining.Expression != null)
            {
                targetCommand.AddParameter("SecondsRemaining", SecondsRemaining.Get(context));
            }

            if (CurrentOperation.Expression != null)
            {
                targetCommand.AddParameter("CurrentOperation", CurrentOperation.Get(context));
            }

            if (ParentId.Expression != null)
            {
                targetCommand.AddParameter("ParentId", ParentId.Get(context));
            }

            if (Completed.Expression != null)
            {
                targetCommand.AddParameter("Completed", Completed.Get(context));
            }

            if (SourceId.Expression != null)
            {
                targetCommand.AddParameter("SourceId", SourceId.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Esempio n. 10
0
        /// <summary>
        /// This is not very dry.. but It seems to cause a bunch of issues opening repos so fast.
        /// </summary>
        private async Task GitFileEventUpdate()
        {
            using (await _gitStatusMutex.LockAsync())
            {
                Debug.WriteLine("Git File Event Update");
                bool       supressBranchEvent = false;
                var        files      = new Dictionary <string, GitFile>();
                Repository repository = null;
                try
                {
                    //repository = _statusRepository;
                    repository = GetRepository();
                    files      = GetCurrentChangedFiles();

                    //logic getting complicated time to break it out
                    if (_cachedBranchOperation != repository.Info.CurrentOperation)
                    {
                        _cachedBranchOperation = repository.Info.CurrentOperation;
                        _cachedBranchName      = null;
                    }
                    if (string.IsNullOrWhiteSpace(_cachedBranchName) ||
                        !string.Equals(_cachedBranchName, repository.Head.FriendlyName))
                    {
                        var newBranchName = string.IsNullOrWhiteSpace(repository.Head.FriendlyName)
                            ? "master"
                            : repository.Head.FriendlyName;
                        if (string.Equals(_cachedBranchName, newBranchName))
                        {
                            supressBranchEvent = true;
                        }
                        else
                        {
                            _cachedBranchName  = newBranchName;
                            _branchDisplayName = null;
                        }

                        if (!supressBranchEvent)
                        {
                            FireBranchChangedEvent(_cachedBranchName);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error In GetCurrentChangedFiles: " + ex.Message);
                    Thread.Sleep(2000);
                }
                finally
                {
                    repository?.Dispose();
                }
                _changedFiles = files;
                FireFileStatusUpdateEvent(files.Values.ToList());
            }
        }
Esempio n. 11
0
        internal static bool ClassNeeded(CurrentOperation currentOperation)
        {
            if (currentOperation == CurrentOperation.QueryInstanceSync || currentOperation == CurrentOperation.QueryInstanceAsync ||
                currentOperation == CurrentOperation.SubscribeAsync || currentOperation == CurrentOperation.SubscribeSync ||
                currentOperation == CurrentOperation.OperationNamespaceName || currentOperation == CurrentOperation.OperationComputerName)
            {
                return(false);
            }

            return(true);
        }
        public void CurrentOperationHasExpectedPendingOperationValues(string stateFile, CurrentOperation expectedState)
        {
            var path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);

            Touch(path.RepositoryPath, stateFile);

            using (var repo = new Repository(path.RepositoryPath))
            {
                Assert.Equal(expectedState, repo.Info.CurrentOperation);
            }
        }
        public void CurrentOperationHasExpectedPendingOperationValues(string stateFile, CurrentOperation expectedState)
        {
            string path = CloneStandardTestRepo();

            Touch(Path.Combine(path, ".git"), stateFile);

            using (var repo = new Repository(path))
            {
                Assert.Equal(expectedState, repo.Info.CurrentOperation);
            }
        }
Esempio n. 14
0
        public void Execute()
        {
            if (CurrentOperation.Operator == null || CurrentOperation.RhsNumber == null || CurrentOperation.LhsNumber == null)
            {
                return;
            }

            executedValue.SetValue(CurrentOperation.Execute());
            Display = executedValue.ToDisplayString();
            operations.Add(CurrentOperation);
        }
Esempio n. 15
0
        private static List <Operation> GenerateFor(List <Machine> allMachines, List <Material> allMaterials, Batch currentBatch, Job currentJob, int quantity, bool isComplexProduction)
        {
            List <Operation> AllOperations          = new List <Operation>();
            List <Machine>   CurrentCapableMachines = new List <Machine>();

            for (int OperationIndex = 0; OperationIndex < quantity; OperationIndex++)
            {
                int numberOfMaterials = RandomGenerator.MaterialsInOperation();
                Dictionary <Material, int> CurrentMaterialsDemand = new Dictionary <Material, int>();
                for (int MaterialIndex = 0; MaterialIndex < numberOfMaterials && MaterialIndex < allMaterials.Count; MaterialIndex++)
                {
                    CollectionUtils.AddUniqeElementToDictionary(CurrentMaterialsDemand, allMaterials, RandomGenerator.MaterialsDemandInOperation());
                }

                int numberOfMachines = RandomGenerator.MachinesInOperation();
                Dictionary <Machine, int> CurrentCapableMachinesWithProductionTime = new Dictionary <Machine, int>();
                for (int MachineIndex = 0; MachineIndex < numberOfMachines && MachineIndex < allMachines.Count; MachineIndex++)
                {
                    CollectionUtils.AddUniqeElementToDictionary(CurrentCapableMachinesWithProductionTime, allMachines, RandomGenerator.ProductionTimeForMachinesInOperation());
                }

                CurrentCapableMachines = new List <Machine>(CurrentCapableMachinesWithProductionTime.Keys);

                AllOperations.Add(new Operation(OperationIndex, "Operation" + OperationIndex, DateTime.MaxValue, CurrentMaterialsDemand, CurrentCapableMachinesWithProductionTime, null,
                                                MoveFactory.GenerateFor(CurrentCapableMachines), currentBatch, currentJob, RandomGenerator.ColorForChart())); // no setup times yet
            }

            foreach (Operation CurrentOperation in AllOperations)
            {
                List <SetupForBatch> CurrentSetupTimes = new List <SetupForBatch>();
                foreach (Operation PreviousOperation in AllOperations)
                {
                    foreach (Machine CurrentMachine in CurrentOperation.CapableMachinesWithProcessingTime.Keys.ToList())
                    {
                        if (CurrentOperation.Equals(PreviousOperation))
                        {
                            CurrentSetupTimes.Add(new SetupForBatch(CurrentMachine, PreviousOperation, 0));
                        }
                        else if (isComplexProduction)
                        {
                            CurrentSetupTimes.Add(SetupFactory.GenerateComplexProductionFor(CurrentMachine, PreviousOperation));
                        }
                        else
                        {
                            CurrentSetupTimes.Add(SetupFactory.GenerateSmallScaleProductionFor(CurrentMachine, PreviousOperation));
                        }
                    }
                }
                CurrentOperation.SetupTimes = CurrentSetupTimes;
            }

            return(AllOperations);
        }
Esempio n. 16
0
        private void BtnPoint_Click(object sender, RoutedEventArgs e)
        {
            // считываем текущее значение
            string curr = CurrentOperation.Text.ToString();

            if (!curr.Contains(","))
            {
                curr += ",";
            }
            CurrentOperation.Clear();
            CurrentOperation.Text = curr;
        }
 //TODO.. I think I should bea abel to make this private soon
 public void Refresh()
 {
     this.repositoryGraph    = null;
     this._changedFiles      = null;
     this._branchDisplayName = null;
     _cachedBranchName       = null;
     _cachedBranchOperation  = CurrentOperation.None;
     this.remotes            = null;
     this.configs            = null;
     _branchInfoList         = null;
     SetBranchName();
     LoadHeadState();
 }
   /// <summary>
   /// Creates a new instance of a ProjectMerger class
   /// </summary>
   /// <param name="operation">The operation being performed</param>
   /// <param name="referenceResolver">An object to resolve reference conflicts that cannot be auto resolved.</param>
   /// <param name="projectReferenceResolver">An object to resolve project reference conflicts that cannot be auto resolved.</param>
   /// <param name="itemResolver">An object to resolve item conflicts that cannot be auto resolved.</param>
   /// <param name="duplicateReferenceResolver">An object to resolve duplicate references.</param>
   public ProjectMerger(
 CurrentOperation operation,
 IConflictResolver<ProjectReference> projectReferenceResolver,
 IConflictResolver<Reference> referenceResolver,
 IConflictResolver<RawItem> itemResolver,
 IDuplicateResolver<Reference> duplicateReferenceResolver )
   {
       _operation = operation;
         _referenceResolver = referenceResolver;
         _itemResolver = itemResolver;
         _duplicateReferenceResolver = duplicateReferenceResolver;
         _projectReferenceResolver = projectReferenceResolver;
   }
 public static string Local( CurrentOperation operation )
 {
     if ( operation == CurrentOperation.Merge || operation == CurrentOperation.Revert ) {
     return Mine;
       }
       if ( operation == CurrentOperation.Rebase ||
        operation == CurrentOperation.RebaseInteractive ||
        operation == CurrentOperation.RebaseMerge ||
        operation == CurrentOperation.CherryPick ) {
     return Theirs;
       }
       throw new NotSupportedException( "Operation type : " + operation );
 }
Esempio n. 20
0
        private void onOperationCompleted(object sender, EventArgs e)
        {
            CurrentOperation.Succeed -= onOperationCompleted;
            CurrentOperation.Failed  -= onOperationCompleted;
            CurrentOperation.Dispose();
            CurrentOperation = null;

            if (mMainThread != Thread.CurrentThread || !mQueue.Any())
            {
                return;
            }
            dequeueAndExecute();
        }
Esempio n. 21
0
        public static void Shutdown()
        {
            if (IsInit)
            {
                GameLobbyJoinRequested?.Dispose();
                GameLobbyJoinRequested = null;

                CurrentOperation?.Dispose();
                CurrentOperation = null;

                SteamAPI.Shutdown();
                IsInit = false;
            }
        }
Esempio n. 22
0
        public void FilesInfoOnUpdatedOperation(UpdatedOperationEventArgs updatedOperationEventArgs)
        {
            this.SafeInvoke(form => {
                if (_currentOperation == (int)updatedOperationEventArgs.CurrentOperation)
                {
                    return;
                }

                // status text, take the last flag found
                foreach (var name in Enum.GetNames(typeof(CurrentOperation)))
                {
                    CurrentOperation flag = (CurrentOperation)Enum.Parse(typeof(CurrentOperation), name);
                    if (updatedOperationEventArgs.CurrentOperation.HasFlag(flag))
                    {
                        lbStatus.Text = flag.GetAttribute <CurrentOperationAttr>().Name;
                    }
                }

                // blink back color
                lbStatus.UseCustomBackColor = true;
                if (updatedOperationEventArgs.CurrentOperation > 0)
                {
                    Transition.run(lbStatus, "BackColor", ThemeManager.Current.FormBack, ThemeManager.Current.AccentColor, new TransitionType_Flash(3, 400), (o, args) => {
                        lbStatus.BackColor = ThemeManager.Current.AccentColor;
                        lbStatus.Invalidate();
                    });
                }
                else
                {
                    Transition.run(lbStatus, "BackColor", ThemeManager.Current.AccentColor, ThemeManager.Current.FormBack, new TransitionType_Flash(3, 400), (o, args) => {
                        lbStatus.UseCustomBackColor = false;
                        lbStatus.Invalidate();
                    });
                }

                _currentOperation = (int)updatedOperationEventArgs.CurrentOperation;

                if (btStopExecution.Visible != (_currentOperation >= (int)CurrentOperation.Prolint))
                {
                    btStopExecution.Visible = (_currentOperation >= (int)CurrentOperation.Prolint);
                    lbStatus.Width          = lbStatus.Width + (btStopExecution.Visible ? -1 : 1) * btStopExecution.Width;
                }

                if (btBringProcessToFront.Visible != updatedOperationEventArgs.CurrentOperation.HasFlag(CurrentOperation.Run))
                {
                    btBringProcessToFront.Visible = updatedOperationEventArgs.CurrentOperation.HasFlag(CurrentOperation.Run);
                    lbStatus.Width = lbStatus.Width + (btBringProcessToFront.Visible ? -1 : 1) * btBringProcessToFront.Width;
                }
            });
        }
Esempio n. 23
0
        private void BtnEq_Click(object sender, RoutedEventArgs e)
        {
            bool divisionByZero = false;
            // считываем предыдущее значение
            string prev = PrevoisOperation.Text.ToString();
            // считываем текущее значение
            string curr    = CurrentOperation.Text.ToString();
            double tempRes = ToDouble(curr);

            switch (op)
            {
            case SetOperation.Sum:
                op   = SetOperation.Sum;
                res += tempRes;
                break;

            case SetOperation.Minus:
                op   = SetOperation.Minus;
                res -= tempRes;
                break;

            case SetOperation.Mult:
                op   = SetOperation.Mult;
                res *= tempRes;
                break;

            case SetOperation.Div:
                op = SetOperation.Div;
                if ((int)tempRes != 0)
                {
                    res /= tempRes;
                }
                else
                {
                    divisionByZero = true;
                }
                break;
            }
            PrevoisOperation.Text = prev + curr + "=";
            CurrentOperation.Clear();
            if (divisionByZero)
            {
                CurrentOperation.Text = "Деление на ноль невозможно!!!!!";
            }
            else
            {
                CurrentOperation.Text = res.ToString();
            }
        }
Esempio n. 24
0
        private bool SpindelAus(string inPPEventName)
        {
            var spindel_jetzt   = CurrentOperation.GetDataText("SPINDLE_ROT") ?? "NONE";
            var spindel_nachher = NextOperation?.GetDataText("SPINDLE_ROT") ?? "NONE";

            if (spindel_jetzt != spindel_nachher)
            {
                SPINDLE.Value = 5.0;
            }
            else
            {
                SPINDLE.DataVoid();  // #bloc = CLS,[SPINDLE]
            }
            return(true);
        }
Esempio n. 25
0
        /// <summary>
        /// 计算
        /// </summary>
        public void Calculator()
        {
            if (currentOperation == CurrentOperation.Default || secondNumTxt == "")
            {
                return;
            }

            string txtShowValue = "";
            double firstNum     = Convert.ToDouble(firstNumTxt);
            double secondNum    = Convert.ToDouble(secondNumTxt);

            switch (currentOperation)
            {
            case CurrentOperation.Jia:
                txtShowValue = (firstNum + secondNum).ToString();
                break;

            case CurrentOperation.Jian:
                txtShowValue = (firstNum - secondNum).ToString();
                break;

            case CurrentOperation.Cheng:
                txtShowValue = (firstNum * secondNum).ToString();
                break;

            case CurrentOperation.Chu:
                if (secondNum != 0)
                {
                    txtShowValue = (firstNum / secondNum).ToString();
                }
                else
                {
                    MessageBox.Show("除数不能为0!");
                }
                break;

            default:
                break;
            }

            txtShow.Text = txtShowValue;

            //操作键初始化
            firstNumTxt      = txtShowValue;
            secondNumTxt     = "";
            currentOperation = CurrentOperation.Default;
            canClearfirstNum = true;
        }
Esempio n. 26
0
        private void CommonCode_UpdatedFileImportCount(int count, int totalCount)
        {
            progressBar1.Maximum = totalCount;
            progressBar1.Value   = count;
            progressBar1.Visible = true;

            if (count == totalCount)
            {
                btnValidate.Enabled  = true;
                progressBar1.Visible = false;
                Invoke(setCursorMethod, new object[] { Cursors.Default });

                // Operation is finished
                switch (currentOperation)
                {
                case CurrentOperation.check:
                {
                    Trace.WriteLine("FImport.CommonCode_UpdatedFileImportCount: Check is done. Closing import window.");
                    if (InvokeRequired)
                    {
                        BeginInvoke(CallDataBindToDataGrid);
                    }
                    else
                    {
                        CallDataBindToDataGrid();
                    }
                    break;
                }

                case CurrentOperation.import:
                {
                    Trace.WriteLine("FImport.CommonCode_UpdatedFileImportCount: import is done. Closing import window.");
                    currentOperation = CurrentOperation.none;
                    if (InvokeRequired)
                    {
                        BeginInvoke(setVisibleMethod, new object[] { false });
                    }
                    else
                    {
                        Visible = false;
                    }
                    EnableMain();
                    break;
                }
                }
            }
        }
Esempio n. 27
0
        private void OnCancelCurrentOperation()
        {
            if ((CurrentOperation != null) && CurrentOperation.IsRunning)
            {
                var result = DisplayUserPrompt("Confirm Cancel Operation", "Press OK to cancel the current operation, or Cancel otherwise.", UserPromptType.OK_CANCEL);

                if (result == UserPromptResult.OK)
                {
                    DisplayStatusMessage("Cancelling current operation.", StatusMessageType.USER);

                    CurrentOperation.Abort();

                    //set these incase the operation completed handler doesn't clean up properly
                    OperationInProgress = false;
                }
            }
        }
Esempio n. 28
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            // считываем текущее значение
            string curr = CurrentOperation.Text.ToString();
            int    len  = curr.Length;

            if (len == 1)
            {
                curr = "0";
            }
            else
            {
                curr = curr.Remove(curr.Length - 1);
            }
            CurrentOperation.Clear();
            CurrentOperation.Text = curr;
        }
Esempio n. 29
0
        public static void Service()
        {
            SteamAPI.RunCallbacks();

            if (CurrentOperation?.Done ?? false)
            {
                if (CurrentOperation.Failed)
                {
                    CurrentOperation.OnFailed();
                }
                else
                {
                    CurrentOperation.OnSuccess();
                }
                CurrentOperation.Dispose();
                CurrentOperation = null;
            }
        }
Esempio n. 30
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (currentOperation_ != null)
            {
                hash ^= CurrentOperation.GetHashCode();
            }
            hash ^= ColumnFamilies.GetHashCode();
            if (Granularity != global::Google.Bigtable.Admin.Table.V1.Table.Types.TimestampGranularity.MILLIS)
            {
                hash ^= Granularity.GetHashCode();
            }
            return(hash);
        }
        public static string ToString( this MergeType type, CurrentOperation operation )
        {
            switch ( type ) {
            case MergeType.NoChanges:
              return type.ToString();
            case MergeType.BothAdded:
              return "Both Added";
            case MergeType.BothDeleted:
              return "Both Deleted";
            case MergeType.BothModified:
              return "Both Modified";
              }

              List<string> values = new List<string>();

              _addedSuffix = "Added";
              _modifiedSuffix = "Modified";
              _deletedSuffix = "Deleted";

              if ( type.HasFlag( MergeType.LocalAdded ) ) {
            values.Add( Local( operation ) + " " + _addedSuffix );
              }
              if ( type.HasFlag( MergeType.LocalDeleted ) ) {
            values.Add( Local( operation ) + " " + _deletedSuffix );
              }
              if ( type.HasFlag( MergeType.LocalModified ) ) {
            values.Add( Local( operation ) + " " + _modifiedSuffix );
              }
              if ( type.HasFlag( MergeType.IncomingAdded ) ) {
            values.Add( Incoming( operation ) + " " + _addedSuffix );
              }
              if ( type.HasFlag( MergeType.IncomingDeleted ) ) {
            values.Add( Incoming( operation ) + " " + _deletedSuffix );
              }
              if ( type.HasFlag( MergeType.IncomingModified ) ) {
            values.Add( Incoming( operation ) + " " + _modifiedSuffix );
              }
              return string.Join( ", ", values );
        }
Esempio n. 32
0
 public void MergeFrom(Cluster other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Name.Length != 0)
     {
         Name = other.Name;
     }
     if (other.deleteTime_ != null)
     {
         if (deleteTime_ == null)
         {
             deleteTime_ = new global::Google.Protobuf.Timestamp();
         }
         DeleteTime.MergeFrom(other.DeleteTime);
     }
     if (other.currentOperation_ != null)
     {
         if (currentOperation_ == null)
         {
             currentOperation_ = new global::Google.Longrunning.Operation();
         }
         CurrentOperation.MergeFrom(other.CurrentOperation);
     }
     if (other.DisplayName.Length != 0)
     {
         DisplayName = other.DisplayName;
     }
     if (other.ServeNodes != 0)
     {
         ServeNodes = other.ServeNodes;
     }
     if (other.DefaultStorageType != global::Google.Bigtable.Admin.Cluster.V1.StorageType.STORAGE_UNSPECIFIED)
     {
         DefaultStorageType = other.DefaultStorageType;
     }
 }
Esempio n. 33
0
        private void BtnDigit_Click(object sender, RoutedEventArgs e)
        {
            // считываем текущее значение
            string curr = CurrentOperation.Text.ToString();
            Button btn  = (Button)sender;

            // если текущее значение - "0" или была нажата кнопка арифметического действия
            if (curr.Equals("0") || operationExec)
            {
                operationExec = false;
                // запоминаем текущую запись в результат
                res = ToDouble(curr);
                // очищаем поле
                CurrentOperation.Clear();
                // записываем в поле контент кнопки
                CurrentOperation.Text = btn.Content.ToString();
            }
            else // если в поле уже есть записи и не была нажата кнопка арифметического действия
            {
                // сцепляем текущее и новое значение (контент кнопки)
                CurrentOperation.Text = curr + btn.Content.ToString();
            }
        }
        private void SetBranchName(bool supressEvent = false)
        {
            using (var repository = GetRepository())
            {
                //logic getting complicated time to break it out
                if (_cachedBranchOperation != repository.Info.CurrentOperation)
                {
                    _cachedBranchOperation = repository.Info.CurrentOperation;
                    _cachedBranchName      = null;
                }
                if (string.IsNullOrWhiteSpace(_cachedBranchName) ||
                    !string.Equals(_cachedBranchName, repository.Head.FriendlyName))
                {
                    //if ((string.IsNullOrWhiteSpace(repository.Head.FriendlyName) && string.Equals(_cachedBranchName, "master")) )
                    //{

                    var newBranchName = string.IsNullOrWhiteSpace(repository.Head.FriendlyName)
                        ? "master"
                        : repository.Head.FriendlyName;
                    if (string.Equals(_cachedBranchName, newBranchName))
                    {
                        supressEvent = true;
                    }
                    else
                    {
                        _cachedBranchName  = newBranchName;
                        _branchDisplayName = null;
                    }

                    if (!supressEvent)
                    {
                        FireBranchChangedEvent(_cachedBranchName);
                    }
                    //}
                }
            }
        }
Esempio n. 35
0
 public void MergeFrom(Table other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Name.Length != 0)
     {
         Name = other.Name;
     }
     if (other.currentOperation_ != null)
     {
         if (currentOperation_ == null)
         {
             currentOperation_ = new global::Google.Longrunning.Operation();
         }
         CurrentOperation.MergeFrom(other.CurrentOperation);
     }
     columnFamilies_.Add(other.columnFamilies_);
     if (other.Granularity != global::Google.Bigtable.Admin.Table.V1.Table.Types.TimestampGranularity.MILLIS)
     {
         Granularity = other.Granularity;
     }
 }
Esempio n. 36
0
        private static void ProcessProjectFiles(
      CurrentOperation operation,
      string[] conflictPaths,
      DirectoryInfo folder,
      Logger logger,
      string rootFolder )
        {
            var merger = new ProjectMerger(
            operation,
            new UserConflictResolver<ProjectReference>( operation, repositoryRootDirectory: rootFolder ),
            new ReferenceConflictResolver( new UserConflictResolver<Reference>( operation, notResolveOptionText: PackageNotInstalledText, repositoryRootDirectory: rootFolder ) ),
            new UserConflictResolver<RawItem>( operation, repositoryRootDirectory: rootFolder ),
            new UserDuplicateResolver<Reference>( operation, notResolveOptionText: PackageNotInstalledText, repositoryRootDirectory: rootFolder ) );

              foreach ( var conflict in conflictPaths.Where( p => p.EndsWith( ".csproj" ) || p.EndsWith( ".fsproj" ) || p.EndsWith( ".xproj" )) ) {

            var fullConflictPath = Path.Combine( folder.FullName, conflict );
            logger.Info( $"{LogHelper.Header}{Environment.NewLine}Examining concurrent modification for {fullConflictPath}" );

            var baseContent = GitHelper.GetConflictContent( rootFolder, StageLevel.Ancestor, conflict );
            var localContent = GitHelper.GetConflictContent( rootFolder, StageLevel.Ours, conflict );
            var incomingContent = GitHelper.GetConflictContent( rootFolder, StageLevel.Theirs, conflict );

            var conflictFolder = Path.GetDirectoryName( Path.Combine( rootFolder, conflict ) );

            if ( conflictFolder == null ) {
              throw new Exception( "No conflict folder" );
            }

            if ( string.IsNullOrEmpty( localContent ) || string.IsNullOrEmpty( incomingContent ) ) {
              logger.Log( LogLevel.Info, $"Skipping '{conflict}' - no content on one side" );
              continue;
            }

            var localDocument = XDocument.Parse( localContent );
            var incomingDocument = XDocument.Parse( incomingContent );
            var baseDocument = XDocument.Parse( baseContent ?? "<?xml version=\"1.0\" encoding=\"utf - 8\"?><Project/>" );

            var resolved = false;

            try {
              var projectFolder = Path.Combine( folder.FullName, conflictFolder );

              var packagesConfigFilePath = ProjectPackages.GetPackagesConfigFilePath( projectFolder );
              var packagesConfig = ProjectPackages.TryLoadPackagesConfig( packagesConfigFilePath );
              if ( packagesConfig == null ) {
            continue;
              }

              var packageIndex = new ProjectPackages( projectFolder, NuGetExtensions.FindRelativePathOfPackagesFolder( projectFolder ), packagesConfig );

              Item[] items = merger.Merge(
              conflict,
              packageIndex,
              baseDocument,
              localDocument,
              incomingDocument ).ToArray();

              // Now remove everything we have handled, to check if we are done.
              ProjectFile.DeleteItems( localDocument );
              ProjectFile.DeleteItems( incomingDocument );
              ProjectFile.DeleteItems( baseDocument );

              ProjectFile.AddItems( baseDocument, items );
              ProjectFile.AddItems( localDocument, items );
              ProjectFile.AddItems( incomingDocument, items );

              XDocument resolvedDocument = null;

              var localXml = localDocument.ToString();
              var incomingXml = incomingDocument.ToString();
              var baseXml = baseDocument.ToString();

              // Check for any project file changes outside of the references and items.
              if ( localXml == incomingXml ) {
            resolvedDocument = localDocument;
              } else if ( baseXml == localXml ) {
            resolvedDocument = incomingDocument;
              } else if ( baseXml == incomingXml ) {
            resolvedDocument = localDocument;
              }

              if ( resolvedDocument != null ) {
            // We handled all the differences
            using ( var textWriter = new StreamWriter( fullConflictPath ) ) {
              SerialisationHelper.WriteXml( resolvedDocument, textWriter );
            }
            using ( var repository = new Repository( rootFolder ) ) {
              repository.Stage( conflict );
            }

            resolved = true;
              }
            }       catch ( MergeAbortException ) {
              logger.Log( LogLevel.Info, $"Project merge aborted for {conflict}" );
              continue;
            } catch ( UserQuitException ) {
              throw;
            } catch ( Exception exception ) {
              logger.Log( LogLevel.Error, exception, $"Project merge failed for {conflict}{Environment.NewLine}{exception}" );
            }

            if ( resolved ) {
              continue;
            }

              string userQuestionText = $"Could not resolve conflict: {conflict}{Environment.NewLine}Would you like to resolve the conflict with the mergetool?";
              var userQuestion = new UserQuestion<bool>( userQuestionText, UserQuestion<bool>.YesNoOptions() );

              if ( userQuestion.Resolve() ) {

            using ( var repository = new Repository( rootFolder ) ) {
              GitHelper.ResolveWithStandardMergetool(
                repository,
                fullConflictPath,
                baseDocument,
                localDocument,
                incomingDocument,
                logger,
                conflict );
            }
              }
            }
        }
Esempio n. 37
0
        private static void ProcessPackagesConfig(
      CurrentOperation operation,
      string[] conflictPaths,
      DirectoryInfo folder,
      Logger logger,
      string rootFolder )
        {
            var packagesConfigMerger = new PackagesConfigMerger(
            operation,
            new UserConflictResolver<ConfigitPackageReference>( operation, repositoryRootDirectory: rootFolder ) );

              foreach ( var conflict in conflictPaths.Where( p => Path.GetFileName( p ) == "packages.config" ) ) {

            var fullConflictPath = Path.Combine( folder.FullName, conflict );
            logger.Info( $"{LogHelper.Header}{Environment.NewLine}Examining concurrent modification for {fullConflictPath}" );

            var baseContent = GitHelper.GetConflictContent( rootFolder, StageLevel.Ancestor, conflict );
            var localContent = GitHelper.GetConflictContent( rootFolder, StageLevel.Ours, conflict );
            var incomingContent = GitHelper.GetConflictContent( rootFolder, StageLevel.Theirs, conflict );

            // TODO: Is this correct? if base is not null then we have a deletion of the packages config file
            if ( string.IsNullOrEmpty( localContent ) || string.IsNullOrEmpty( incomingContent ) ) {
              logger.Log( LogLevel.Info, $"Skipping '{conflict}' - no content on one side" );
              continue;
            }

            bool resolved = false;

            try {
              var result = packagesConfigMerger.Merge( conflict,
              baseContent == null ? new ConfigitPackageReference[0]:
                                   NuGetExtensions.ReadPackageReferences( baseContent ),
              NuGetExtensions.ReadPackageReferences( localContent ),
              NuGetExtensions.ReadPackageReferences( incomingContent ) ).ToArray();

              result.Write( fullConflictPath );

              using ( var repository = new Repository( rootFolder ) ) {
            repository.Stage( conflict );
            resolved = true;
              }

            } catch ( MergeAbortException ) {
              logger.Log( LogLevel.Info, $"Package merge aborted for {conflict}" );
              continue;
            }
            catch ( UserQuitException ) {
              throw;
            } catch ( Exception exception ) {
              logger.Log( LogLevel.Error, exception, $"Package merge failed for {conflict}{Environment.NewLine}{exception}" );
            }

            if ( resolved ) {
              continue;
            }

              string userQuestionText = $"Could not resolve conflict: {conflict}{Environment.NewLine}Would you like to resolve the conflict with the mergetool?";
              var userQuestion = new UserQuestion<bool>( userQuestionText, UserQuestion<bool>.YesNoOptions() );

            if ( !userQuestion.Resolve() ) {
              continue;
            }

            XDocument localDocument = XDocument.Parse( localContent );
            XDocument theirDocument = XDocument.Parse( incomingContent );
            XDocument baseDocument = baseContent == null ? new XDocument() : XDocument.Parse( baseContent );

            using ( var repository = new Repository( rootFolder ) ) {
              GitHelper.ResolveWithStandardMergetool(
                repository,
                fullConflictPath,
                baseDocument,
                localDocument,
                theirDocument,
                logger,
                conflict );
            }
              }
        }
Esempio n. 38
0
		private void CommonCode_UpdatedFileImportCount(int count, int totalCount)
		{
			progressBar1.Maximum = totalCount;
			progressBar1.Value = count;
			progressBar1.Visible = true;

			if (count == totalCount)
			{
				btnValidate.Enabled = true;
				progressBar1.Visible = false;
				Invoke(setCursorMethod, new object[] { Cursors.Default });

				// Operation is finished
				switch(currentOperation)
				{
					case CurrentOperation.check:
					{
						Trace.WriteLine("FImport.CommonCode_UpdatedFileImportCount: Check is done. Closing import window.");
						if (InvokeRequired)
							BeginInvoke(CallDataBindToDataGrid);
						else
							CallDataBindToDataGrid();
						break;
					}
					case CurrentOperation.import:
					{
						Trace.WriteLine("FImport.CommonCode_UpdatedFileImportCount: import is done. Closing import window.");
						currentOperation = CurrentOperation.none;
						if (InvokeRequired)
							BeginInvoke(setVisibleMethod, new object[] { false });
						else
							Visible = false;
						EnableMain();
						break;
					}
				}
			}
		}
Esempio n. 39
0
 void ICurrentOperation.SetOperation(CurrentOperation currentOperation)
 {
     operation = currentOperation;
 }
 //TODO.. I think I should bea abel to make this private soon
 public void Refresh()
 {
     this.repositoryGraph = null;
     this._changedFiles = null;
     this._branchDisplayName = null;
     _cachedBranchName = null;
     _cachedBranchOperation = CurrentOperation.None;
     this.remotes = null;
     this.configs = null;
     _branchInfoList = null;
     SetBranchName();
     LoadHeadState();
 }
 public static string Incoming( CurrentOperation operation )
 {
     return Local( operation ) == Mine ? Theirs : Mine;
 }
        /// <summary>
        /// This is not very dry.. but It seems to cause a bunch of issues opening repos so fast. 
        /// </summary>
        private async Task GitFileEventUpdate()
        {
            using (await _gitStatusMutex.LockAsync())
            {
                Debug.WriteLine("Git File Event Update");
                bool supressBranchEvent = false;
                var files = new List<GitFile>();
                Repository repository = null;
                try
                {
                    repository = GetRepository();
                    //get changed files
                    var repoFiles = repository.RetrieveStatus(new StatusOptions()
                    {
                        IncludeUnaltered = false,
                        RecurseIgnoredDirs = false
                    });
                    files.AddRange(
                        repoFiles.Where(item => IsChangedStatus(item.State) && !(FileIgnored(item.FilePath)))
                            .Select(item => new GitFile(repository, item)));


                    //logic getting complicated time to break it out
                    if (_cachedBranchOperation != repository.Info.CurrentOperation)
                    {
                        _cachedBranchOperation = repository.Info.CurrentOperation;
                        _cachedBranchName = null;
                    }
                    if (string.IsNullOrWhiteSpace(_cachedBranchName) ||
                        !string.Equals(_cachedBranchName, repository.Head.FriendlyName))
                    {
                        var newBranchName = string.IsNullOrWhiteSpace(repository.Head.FriendlyName)
                            ? "master"
                            : repository.Head.FriendlyName;
                        if (string.Equals(_cachedBranchName, newBranchName))
                        {
                            supressBranchEvent = true;
                        }
                        else
                        {
                            _cachedBranchName = newBranchName;
                            _branchDisplayName = null;
                        }

                        if (!supressBranchEvent)
                        {
                            FireBranchChangedEvent(_cachedBranchName);
                        }

                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error In GetCurrentChangedFiles: " + ex.Message);
                    Thread.Sleep(2000);
                }
                finally
                {
                    repository?.Dispose();
                }
                 _changedFiles = files;
                 FireFileStatusUpdateEvent(files);
            }
        }
        public GitRepository(string directory)
        {
            _gitDirectory = Repository.Discover(directory);
            _savedState = new GitHeadState();
            _statusRepository = GetRepository();
            this.workingDirectory = _statusRepository.Info.WorkingDirectory;
            _repositoryPath = _statusRepository.Info.Path;
            _objectPath = _repositoryPath + "objects\\";

            _cachedBranchOperation = CurrentOperation.None;
            Refresh();
            _gitEventObservable = Observable.FromEventPattern(ev => _gitfileEvent += ev, ev => _gitfileEvent -= ev)
                .Throttle(TimeSpan.FromMilliseconds(2000));
            _gitEventObservable.Subscribe(x => Task.Run(async () => await DecodeGitEvents()));

            _fileChangedEventObservable = Observable.FromEventPattern(ev => _fileEvent += ev, ev => _fileEvent -= ev)
    .Throttle(TimeSpan.FromMilliseconds(250));
            _fileChangedEventObservable.Subscribe(x => Task.Run(async () => await FileChangedEvent()));

        }
        private void SetBranchName(bool supressEvent = false)
        {
            using (var repository = GetRepository())
            {
                //logic getting complicated time to break it out
                if (_cachedBranchOperation != repository.Info.CurrentOperation)
                {
                    _cachedBranchOperation = repository.Info.CurrentOperation;
                    _cachedBranchName = null;
                }
                if (string.IsNullOrWhiteSpace(_cachedBranchName) ||
                    !string.Equals(_cachedBranchName, repository.Head.FriendlyName))
                {
                    //if ((string.IsNullOrWhiteSpace(repository.Head.FriendlyName) && string.Equals(_cachedBranchName, "master")) )
                    //{

                    var newBranchName = string.IsNullOrWhiteSpace(repository.Head.FriendlyName)
                        ? "master"
                        : repository.Head.FriendlyName;
                    if (string.Equals(_cachedBranchName, newBranchName))
                    {
                        supressEvent = true;
                    }
                    else
                    {
                        _cachedBranchName = newBranchName;
                        _branchDisplayName = null;
                    }

                    if (!supressEvent)
                    {
                        FireBranchChangedEvent(_cachedBranchName);
                    }
                    //}

                }
            }
        }
Esempio n. 45
0
        private static void ProcessSolutionFile(
      CurrentOperation operation,
      DirectoryInfo folder,
      Logger logger,
      string rootFolder,
      string conflictPath )
        {
            var fullConflictPath = Path.Combine( folder.FullName, conflictPath );
              logger.Info( $"{LogHelper.Header}{Environment.NewLine}Examining concurrent modification for {fullConflictPath}" );

              var localName = MergeTypeIntegrationExtensions.Local( operation );

              var basePath = fullConflictPath + "_CSMERGE_BASE";
              var minePath = fullConflictPath + "_CSMERGE_" + localName;
              var incomingPath = fullConflictPath + "_CSMERGE_" + MergeTypeIntegrationExtensions.Incoming( operation );

              File.WriteAllText( basePath, GitHelper.GetConflictContent( rootFolder, StageLevel.Ancestor, conflictPath ) );
              File.WriteAllText(
            minePath,
            GitHelper.GetConflictContent(
              rootFolder,
              localName == MergeTypeIntegrationExtensions.Mine ? StageLevel.Ours : StageLevel.Theirs,
              conflictPath ) );

              File.WriteAllText(
            incomingPath,
            GitHelper.GetConflictContent(
              rootFolder,
              localName == MergeTypeIntegrationExtensions.Mine ? StageLevel.Theirs : StageLevel.Ours,
              conflictPath ) );

              // Use SlnTools
              // "Four solution files should be provided, in order:\n   SourceBranch.sln\n   DestinationBranch.sln\n   CommonAncestror.sln\n   Result.sln"
              CWDev.SLNTools.MergeSolutionsCommand command = new CWDev.SLNTools.MergeSolutionsCommand();
              command.Run(
            new[] { minePath, incomingPath, basePath, fullConflictPath },
            new CWDev.SLNTools.MessageBoxErrorReporter() );

              if ( command.MergedHandled ) {
            using ( var repository = new Repository( rootFolder ) ) {
              repository.Stage( conflictPath );
            }
              }

              File.Delete( basePath );
              File.Delete( minePath );
              File.Delete( incomingPath );
        }
Esempio n. 46
0
        internal static bool ClassNeeded(CurrentOperation currentOperation)
        {
            if (currentOperation == CurrentOperation.QueryInstanceSync || currentOperation == CurrentOperation.QueryInstanceAsync ||
                currentOperation == CurrentOperation.SubscribeAsync || currentOperation == CurrentOperation.SubscribeSync ||
                currentOperation == CurrentOperation.OperationNamespaceName || currentOperation == CurrentOperation.OperationComputerName)
            {
                return false;
            }

            return true;
        }
Esempio n. 47
0
   private static void ProcessSolutionFiles(
 CurrentOperation operation,
 string[] conflictPaths,
 DirectoryInfo folder,
 Logger logger,
 string rootFolder)
   {
       foreach (var conflictPath in conflictPaths.Where(cp => cp.ToLowerInvariant().EndsWith(".sln")))
         {
       try
       {
         ProcessSolutionFile(operation, folder, logger, rootFolder, conflictPath);
       }
       catch (Exception e)
       {
         logger.Log(LogLevel.Error, e, "Failed to process solution file " + conflictPath);
       }
         }
   }
        /// <summary>
        /// This is not very dry.. but It seems to cause a bunch of issues opening repos so fast. 
        /// </summary>
        private async Task GitFileEventUpdate()
        {
            using (await _gitStatusMutex.LockAsync())
            {
                Debug.WriteLine("Git File Event Update");
                bool supressBranchEvent = false;
                var files = new Dictionary<string, GitFile>();
                Repository repository = null;
                try
                {
                    //repository = _statusRepository;
                    repository = GetRepository();
                    files = GetCurrentChangedFiles();

                    //logic getting complicated time to break it out
                    if (_cachedBranchOperation != repository.Info.CurrentOperation)
                    {
                        _cachedBranchOperation = repository.Info.CurrentOperation;
                        _cachedBranchName = null;
                    }
                    if (string.IsNullOrWhiteSpace(_cachedBranchName) ||
                        !string.Equals(_cachedBranchName, repository.Head.FriendlyName))
                    {
                        var newBranchName = string.IsNullOrWhiteSpace(repository.Head.FriendlyName)
                            ? "master"
                            : repository.Head.FriendlyName;
                        if (string.Equals(_cachedBranchName, newBranchName))
                        {
                            supressBranchEvent = true;
                        }
                        else
                        {
                            _cachedBranchName = newBranchName;
                            _branchDisplayName = null;
                        }

                        if (!supressBranchEvent)
                        {
                            FireBranchChangedEvent(_cachedBranchName);
                        }

                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error In GetCurrentChangedFiles: " + ex.Message);
                    Thread.Sleep(2000);
                }
                finally
                {
                    repository?.Dispose();
                }
                 _changedFiles = files;
                FireFileStatusUpdateEvent(files.Values.ToList());
            }
        }