예제 #1
0
        public static void MovePrevVersion(RepositoryItemBase obj, string FileName)
        {
            if (File.Exists(FileName))
            {
                string repoItemTypeFolder = GetSharedRepoItemTypeFolder(obj.GetType());
                string PrevFolder         = Path.Combine(App.UserProfile.Solution.Folder, repoItemTypeFolder, "PrevVersions");
                if (!Directory.Exists(PrevFolder))
                {
                    Directory.CreateDirectory(PrevFolder);
                }
                //TODO: change to usae locale or yyyymmdd...
                string dts      = DateTime.Now.ToString("MM_dd_yyyy_H_mm_ss");
                string repoName = string.Empty;
                if (obj.FileName != null && File.Exists(obj.FileName))
                {
                    repoName = obj.FileName;
                }
                string PrevFileName = repoName.Replace(repoItemTypeFolder, repoItemTypeFolder + @"\PrevVersions") + "." + dts + "." + obj.ObjFileExt;

                if (PrevFileName.Length > 255)
                {
                    PrevFileName = PrevFileName.Substring(0, 250) + new Random().Next(1000).ToString();
                }
                try
                {
                    if (File.Exists(PrevFileName))
                    {
                        File.Delete(PrevFileName);
                    }
                    File.Move(FileName, PrevFileName);
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Save Previous File got error " + ex.Message);
                }
            }
        }
예제 #2
0
        private void WriteRepoItemProperties(XmlTextWriter xml, RepositoryItemBase ri)
        {
            //TODO: handle all the same like fields and make it shared functions

            // Get the properties - need to be ordered so compare/isDirty can work faster
            var properties = ri.GetType().GetMembers().Where(x => x.MemberType == MemberTypes.Property).OrderBy(x => x.Name);

            foreach (MemberInfo mi in properties)
            {
                dynamic v = null;
                IsSerializedForLocalRepositoryAttribute token = Attribute.GetCustomAttribute(mi, typeof(IsSerializedForLocalRepositoryAttribute), false) as IsSerializedForLocalRepositoryAttribute;
                if (token == null)
                {
                    continue;
                }

                //Get tha attr value
                v = ri.GetType().GetProperty(mi.Name).GetValue(ri);
                // Enum might be unknow = not set - so no need to write to xml, like null for object
                if (ri.GetType().GetProperty(mi.Name).PropertyType.IsEnum)
                {
                    string vs = v.ToString();
                    // No need to write enum unknown = null
                    if (vs != "Unknown")
                    {
                        xmlwriteatrr(xml, mi.Name, vs);
                    }
                }
                else
                {
                    if (v != null)
                    {
                        xmlwriteatrr(xml, mi.Name, v.ToString());
                    }
                }
            }
        }
예제 #3
0
        private void CopyCustomizedVariableConfigurations(VariableBase customizedVar, VariableBase originalVar)
        {
            //keep original description values
            VariableBase originalCopy = (VariableBase)originalVar.CreateCopy(false);

            //ovveride original variable configurations with user customizations
            RepositoryItemBase.ObjectsDeepCopy(customizedVar, originalVar);//need to replace 'ObjectsDeepCopy' with AutoMapper and to map on it which values should be overiden
            originalVar.DiffrentFromOrigin   = customizedVar.DiffrentFromOrigin;
            originalVar.MappedOutputVariable = customizedVar.MappedOutputVariable;
            //Fix for Empty variable are not being saved in Run Configuration (when variable has value in BusinessFlow but is changed to empty in RunSet)
            if (customizedVar.DiffrentFromOrigin && string.IsNullOrEmpty(customizedVar.MappedOutputVariable))
            {
                originalVar.Value = customizedVar.Value;
            }

            //Restore original description values
            originalVar.Name               = originalCopy.Name;
            originalVar.Description        = originalCopy.Description;
            originalVar.Tags               = originalCopy.Tags;
            originalVar.SetAsInputValue    = originalCopy.SetAsInputValue;
            originalVar.SetAsOutputValue   = originalCopy.SetAsOutputValue;
            originalVar.LinkedVariableName = originalCopy.LinkedVariableName;
            originalVar.Publish            = originalCopy.Publish;

            //temp solution for release, find better way, issue is with the RepositoryItemBase.ObjectsDeepCopy which causing duplicated optional values
            if (originalVar is VariableSelectionList)
            {
                for (int indx = 0; indx < ((VariableSelectionList)originalVar).OptionalValuesList.Count; indx++)
                {
                    if (((VariableSelectionList)originalVar).OptionalValuesList.Where(x => x.Value == ((VariableSelectionList)originalVar).OptionalValuesList[indx].Value).ToList().Count > 1)
                    {
                        ((VariableSelectionList)originalVar).OptionalValuesList.RemoveAt(indx);
                        indx--;
                    }
                }
            }
        }
예제 #4
0
        public override bool SaveTreeItem(object item, bool saveOnlyIfDirty = false)
        {
            if (item is RepositoryItemBase)
            {
                RepositoryItemBase RI = (RepositoryItemBase)item;
                if (saveOnlyIfDirty && RI.DirtyStatus != eDirtyStatus.Modified)
                {
                    return(false);//no need to Save because not Dirty
                }
                Reporter.ToStatus(eStatusMsgKey.SaveItem, null, RI.ItemName, "item");
                WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(RI);
                Reporter.HideStatusMessage();

                //refresh node header
                PostSaveTreeItemHandler();
                return(true);
            }
            else
            {
                //implement for other item types
                Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "Save operation for this item type was not implemented yet.");
                return(false);
            }
        }
예제 #5
0
        private void DirtyFileAutoSave(RepositoryItemBase itemToSave)
        {
            try
            {
                RepositoryItemBase itemCopy = itemToSave.CreateCopy(false);

                //create smiliar folders structure
                string ItemOriginalpath     = itemToSave.ContainingFolderFullPath;
                string ItemContainingfolder = itemToSave.ContainingFolder;
                string itemAutoSavePath     = ItemOriginalpath.Replace(ItemOriginalpath, mAutoSaveFolderPath);
                itemAutoSavePath = Path.Combine(itemAutoSavePath, ItemContainingfolder);
                if (!Directory.Exists(itemAutoSavePath))
                {
                    Directory.CreateDirectory(itemAutoSavePath);
                }

                //save item
                itemCopy.SaveToFile(Path.Combine(itemAutoSavePath, itemCopy.FileName.ToString()));
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, string.Format("AutoSave: Failed to AutoSave the item:'{0}'", itemToSave.ItemName), ex);
            }
        }
예제 #6
0
        void IDragDrop.Drop(DragInfo Info)
        {
            // first check if we did drag and drop on the same ListView then it is a move - reorder
            if (Info.DragSource == this)
            {
                EventHandler mHandler = SameFrameItemDropped;
                if (mHandler != null)
                {
                    mHandler(Info, new EventArgs());
                }
                else
                {
                    RepositoryItemBase draggedItem = Info.Data as RepositoryItemBase;

                    if (draggedItem != null)
                    {
                        RepositoryItemBase draggedOnItem = DragDrop2.GetRepositoryItemHit(this) as RepositoryItemBase;
                        if (draggedOnItem != null)
                        {
                            DragDrop2.ShuffleControlsItems(draggedItem, draggedOnItem, this);
                        }
                    }
                }
                //if (!(xMoveUpBtn.Visibility == System.Windows.Visibility.Visible)) return;  // Do nothing if reorder up/down arrow are not allowed
                return;
            }

            // OK this is a dropped from external
            EventHandler handler = ItemDropped;

            if (handler != null)
            {
                handler(Info, new EventArgs());
            }
            // TODO: if in same grid then do move,
        }
예제 #7
0
 public override void DuplicateTreeItem(object item)
 {
     if (item is RepositoryItemBase)
     {
         //string newName = ((RepositoryItemBase)item).GetNameForFileName() + "_Copy";
         //if (GingerCore.GeneralLib.InputBoxWindow.GetInputWithValidation("Duplicated Item Name", "Name:", ref newName, System.IO.Path.GetInvalidPathChars()))
         //{
         //    RepositoryItemBase copy = ((RepositoryItemBase)item).CreateCopy();
         //    copy.ItemName = newName;
         //    (WorkSpace.Instance.SolutionRepository.GetItemRepositoryFolder(((RepositoryItemBase)item))).AddRepositoryItem(copy);
         //}
         RepositoryItemBase copiedItem = CopyTreeItemWithNewName((RepositoryItemBase)item);
         if (copiedItem != null)
         {
             copiedItem.DirtyStatus = eDirtyStatus.NoTracked;
             (WorkSpace.Instance.SolutionRepository.GetItemRepositoryFolder(((RepositoryItemBase)item))).AddRepositoryItem(copiedItem);
         }
     }
     else
     {
         //implement for other item types
         Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "Item type " + item.GetType().Name + " - operation for this item type was not implemented yet.");
     }
 }
예제 #8
0
        public override void SaveAllTreeFolderItems()
        {
            List <ITreeViewItem> childNodes = mTreeView.Tree.GetTreeNodeChildsIncludingSubChilds((ITreeViewItem)this);

            int itemsSavedCount = 0;

            foreach (ITreeViewItem node in childNodes)
            {
                if (node != null && node.NodeObject() is RepositoryItemBase)
                {
                    RepositoryItemBase RI = (RepositoryItemBase)node.NodeObject();
                    if (RI != null)
                    {
                        if (RI.IsDirty)
                        {
                            // Try to save only items with file name = standalone xml, avoid items like env app
                            if (!string.IsNullOrEmpty(RI.ContainingFolder))
                            {
                                if (SaveTreeItem(node.NodeObject(), true))
                                {
                                    itemsSavedCount++;
                                }
                            }
                        }
                    }
                }
            }
            if (itemsSavedCount == 0)
            {
                Reporter.ToUser(eUserMsgKeys.StaticWarnMessage, "Nothing found to Save.");
            }
            else
            {
                mTreeView.Tree.SelectItem((ITreeViewItem)this);//in case the event was called from diffrent class
            }
        }
예제 #9
0
        private void ViewActivity(FoundItem activityToViewFoundItem)
        {
            Activity           activity = (Activity)activityToViewFoundItem.OriginObject;
            RepositoryItemBase Parent   = (RepositoryItemBase)activityToViewFoundItem.ParentItemToSave;
            ActivityEditPage   w;

            if (mContext == eContext.RunsetPage)
            {
                w = new ActivityEditPage(activity, General.RepositoryItemPageViewMode.View);
            }
            else if (Parent is BusinessFlow)
            {
                w = new ActivityEditPage(activity, General.RepositoryItemPageViewMode.Child, Parent as BusinessFlow);
            }
            else
            {
                w = new ActivityEditPage(activity, General.RepositoryItemPageViewMode.SharedReposiotry);
            }

            if (w.ShowAsWindow(eWindowShowStyle.Dialog) == true)
            {
                RefreshFoundItemField(activityToViewFoundItem);
            }
        }
        private static RepositoryItemBase GetItemToOverrite(UploadItemSelection itemToUpload)
        {
            RepositoryItemBase itemCopy = itemToUpload.UsageItem.GetUpdatedRepoItem(itemToUpload.UsageItem, itemToUpload.ExistingItem, itemToUpload.SelectedItemPart);

            switch (itemToUpload.ExistingItemType)
            {
            case UploadItemSelection.eExistingItemType.ExistingItemIsParent:
                itemCopy.Guid       = itemToUpload.ExistingItem.Guid;
                itemCopy.ParentGuid = itemToUpload.ExistingItem.ParentGuid;
                itemCopy.ExternalID = itemToUpload.ExistingItem.ExternalID;

                break;

            case UploadItemSelection.eExistingItemType.ExistingItemIsExternalID:

                break;

            case UploadItemSelection.eExistingItemType.ExistingItemIsDuplicate:

                break;
            }

            return(itemCopy);
        }
예제 #11
0
        public override RepositoryItemBase GetUpdatedRepoItem(RepositoryItemBase itemToUpload, RepositoryItemBase existingRepoItem, string itemPartToUpdate)
        {
            Activity updatedActivity = null;

            //update required part
            eItemParts ePartToUpdate = (eItemParts)Enum.Parse(typeof(eItemParts), itemPartToUpdate);

            switch (ePartToUpdate)
            {
            case eItemParts.All:

            case eItemParts.Details:
                updatedActivity = (Activity)itemToUpload.CreateCopy(false);

                if (ePartToUpdate == eItemParts.Details)
                {
                    updatedActivity.Acts      = ((Activity)existingRepoItem).Acts;
                    updatedActivity.Variables = ((Activity)existingRepoItem).Variables;
                }

                break;

            case eItemParts.Actions:
                updatedActivity      = (Activity)existingRepoItem.CreateCopy(false);
                updatedActivity.Acts = ((Activity)itemToUpload).Acts;
                break;

            case eItemParts.Variables:
                updatedActivity           = (Activity)existingRepoItem.CreateCopy(false);
                updatedActivity.Variables = ((Activity)itemToUpload).Variables;
                break;
            }

            return(updatedActivity);
        }
예제 #12
0
        public override void UpdateInstance(RepositoryItemBase instance, string partToUpdate, RepositoryItemBase hostItem = null)
        {
            Activity activityInstance = (Activity)instance;
            //Create new instance of source
            Activity newInstance = (Activity)this.CreateInstance();


            newInstance.IsSharedRepositoryInstance = true;

            //update required part
            eItemParts ePartToUpdate = (eItemParts)Enum.Parse(typeof(eItemParts), partToUpdate);

            switch (ePartToUpdate)
            {
            case eItemParts.All:
            case eItemParts.Details:
                newInstance.Guid                  = activityInstance.Guid;
                newInstance.ParentGuid            = activityInstance.ParentGuid;
                newInstance.ExternalID            = activityInstance.ExternalID;
                newInstance.ActivitiesGroupID     = activityInstance.ActivitiesGroupID;
                newInstance.TargetApplication     = activityInstance.TargetApplication;
                newInstance.Active                = activityInstance.Active;
                newInstance.VariablesDependencies = activityInstance.VariablesDependencies;
                if (ePartToUpdate == eItemParts.Details)
                {
                    //keep other parts
                    newInstance.Acts      = activityInstance.Acts;
                    newInstance.Variables = activityInstance.Variables;
                }
                if (instance.ExternalID == this.ExternalID)
                {
                    AddExistingSelectionListVariabelesValues(newInstance, activityInstance);    //increase selection list vars values- needed for GingerATS integration so based on External ID
                }
                if (hostItem != null)
                {
                    //replace old instance object with new
                    int originalIndex = ((BusinessFlow)hostItem).Activities.IndexOf(activityInstance);
                    ((BusinessFlow)hostItem).Activities.Remove(activityInstance);
                    ((BusinessFlow)hostItem).Activities.Insert(originalIndex, newInstance);
                }
                break;

            case eItemParts.Actions:
                activityInstance.Acts = newInstance.Acts;
                break;

            case eItemParts.Variables:
                activityInstance.Variables = newInstance.Variables;
                break;
            }
        }
예제 #13
0
 protected eImageType GetSourceControlImage(RepositoryItemBase repositoryItem)
 {
     return(GetSourceControlImageByPath(repositoryItem.FilePath));
 }
예제 #14
0
        private async void Init()
        {
            try
            {
                xProcessingIcon.Visibility = Visibility.Visible;
                if (SourceControlIntegration.BusyInProcessWhileDownloading)
                {
                    Reporter.ToUser(eUserMsgKeys.StaticInfoMessage, "Please wait for current process to end.");
                    return;
                }
                SourceControlIntegration.BusyInProcessWhileDownloading = true;

                await Task.Run(() =>
                {
                    //set paths to ignore:
                    List <string> pathsToIgnore = new List <string>();
                    pathsToIgnore.Add("PrevVersions");
                    pathsToIgnore.Add("RecentlyUsed.dat");
                    pathsToIgnore.Add("AutoSave");
                    pathsToIgnore.Add("Recover");
                    if (App.UserProfile.Solution != null && App.UserProfile.Solution.ExecutionLoggerConfigurationSetList != null && App.UserProfile.Solution.ExecutionLoggerConfigurationSetList.Count > 0)
                    {
                        pathsToIgnore.Add(Ginger.Run.ExecutionLogger.GetLoggerDirectory(App.UserProfile.Solution.ExecutionLoggerConfigurationSetList[0].ExecutionLoggerConfigurationExecResultsFolder));
                    }
                    HTMLReportsConfiguration reportConfig = App.UserProfile.Solution.HTMLReportsConfigurationSetList.Where(x => (x.IsSelected == true)).FirstOrDefault();
                    if (reportConfig != null)
                    {
                        pathsToIgnore.Add(Ginger.Reports.GingerExecutionReport.ExtensionMethods.GetReportDirectory(reportConfig.HTMLReportsFolder));
                    }

                    mFiles = SourceControlIntegration.GetPathFilesStatus(App.UserProfile.Solution.SourceControl, mPath, pathsToIgnore);
                    //set items name and type
                    Parallel.ForEach(mFiles, SCFI =>
                    {
                        try
                        {
                            if (SCFI.Path.ToUpper().Contains(".GINGER.") && SCFI.Path.ToUpper().Contains(".XML"))
                            {
                                NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer();
                                //unserialize the item
                                RepositoryItemBase item = newRepositorySerializer.DeserializeFromFile(SCFI.Path);
                                SCFI.Name = item.ItemName;
                            }
                            else
                            {
                                SCFI.Name = SCFI.Path.Substring(SCFI.Path.LastIndexOf('\\') + 1);
                            }
                        }
                        catch (Exception ex)
                        {
                            if (SCFI.Path.Contains('\\') && (SCFI.Path.LastIndexOf('\\') + 1 < SCFI.Path.Length - 1))
                            {
                                SCFI.Name = SCFI.Path.Substring(SCFI.Path.LastIndexOf('\\') + 1);
                            }
                            Reporter.ToLog(eAppReporterLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                        }

                        if (string.IsNullOrEmpty(SCFI.Path))
                        {
                            SCFI.FileType = "";
                        }
                        else if (SCFI.Path.ToUpper().Contains("AGENTS"))
                        {
                            SCFI.FileType = "Agent";
                        }
                        else if (SCFI.Path.ToUpper().Contains("BUSINESSFLOWS"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow);
                        }
                        else if (SCFI.Path.ToUpper().Contains("DOCUMENTS"))
                        {
                            SCFI.FileType = "Document";
                        }
                        else if (SCFI.Path.ToUpper().Contains("ENVIRONMENTS"))
                        {
                            SCFI.FileType = "Environment";
                        }
                        else if (SCFI.Path.ToUpper().Contains("EXECUTIONRESULTS"))
                        {
                            SCFI.FileType = "Execution Result";
                        }
                        else if (SCFI.Path.ToUpper().Contains("RUNSET"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.RunSet);
                        }
                        else if (SCFI.Path.ToUpper().Contains("ACTIONS"))
                        {
                            SCFI.FileType = "Action";
                        }
                        else if (SCFI.Path.ToUpper().Contains("ACTIVITIESGROUPS"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup);
                        }
                        else if (SCFI.Path.ToUpper().Contains("ACTIVITIES"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.Activity);
                        }
                        else if (SCFI.Path.ToUpper().Contains("VARIABLES"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.Variable);
                        }
                        else if (SCFI.Path.ToUpper().Contains("REPORTTEMPLATE"))
                        {
                            SCFI.FileType = "Report Template";
                        }
                        else if (SCFI.Path.Contains("ApplicationAPIModel"))
                        {
                            SCFI.FileType = "Application API Model";
                        }
                        else if (SCFI.Path.Contains("GlobalAppModelParameter"))
                        {
                            SCFI.FileType = "Global Applications Model Parameter";
                        }
                    });
                });

                CheckInFilesGrid.DataSourceList = mFiles;
            }
            finally
            {
                xProcessingIcon.Visibility = Visibility.Collapsed;
                SourceControlIntegration.BusyInProcessWhileDownloading = false;
            }
        }
예제 #15
0
        //[Ignore]
        //[TestMethod]  [Timeout(60000)]
        //public void NewRepositorySerializer_ReadOldXML()
        //{
        //    // Using new SR2 to load and write old XML but load old object, save with the style


        //    //Arrange
        //    //GingerCore.Repository.RepositorySerializerInitilizer OldSR = new GingerCore.Repository.RepositorySerializerInitilizer();


        //    //GingerCore.Repository.RepositorySerializerInitilizer.InitClassTypesDictionary();
        //    NewRepositorySerializer RS2 = new NewRepositorySerializer();

        //    string fileName = Common.getGingerUnitTesterDocumentsFolder() + @"Repository\BigFlow1.Ginger.BusinessFlow.xml";

        //    //Act
        //    string txt = System.IO.File.ReadAllText(fileName);
        //    BusinessFlow BF = (BusinessFlow)NewRepositorySerializer.DeserializeFromText(txt);

        //    //load with new
        //    // BusinessFlow BF = (BusinessFlow)RS2.DeserializeFromFile(fileName);
        //    //Serialize to new style
        //    //string s = RS2.SerializeToString(BF);
        //    // cretae from new style SR2
        //    BusinessFlow BF2 = (BusinessFlow)RS2.DeserializeFromText(typeof(BusinessFlow), txt, filePath: fileName);

        //    //to test the compare change something in b like below
        //    // BF2.Activities[5].Description = "aaa";
        //    // BF2.Activities.Remove(BF2.Activities[10]);

        //    //Assert

        //    // System.IO.File.WriteAllText(@"c:\temp\BF1.xml", s);
        //   // Assert.AreEqual(78, BF.Activities.Count);
        //    //Assert.AreEqual(78, BF2.Activities.Count);

        //    CompareRepoItem(BF, BF2);
        //}

        private void CompareRepoItem(RepositoryItemBase a, RepositoryItemBase b)
        {
            var props = a.GetType().GetProperties();

            foreach (PropertyInfo PI in props)
            {
                var token = PI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute));
                if (token != null)
                {
                    Console.WriteLine("compare: " + a.ToString() + " " + PI.Name);

                    object aProp = PI.GetValue(a);
                    object bProp = b.GetType().GetProperty(PI.Name).GetValue(b);

                    if (aProp == null && bProp == null)
                    {
                        continue;
                    }


                    if (aProp.ToString() != bProp.ToString())
                    {
                        throw new Exception("Items no match tostring: " + a.ItemName + " attr: " + PI.Name + " a=" + aProp.ToString() + " b=" + bProp.ToString());
                    }

                    //if (aProp != bProp)
                    //{
                    //    throw new Exception("Items no match: " + a.ItemName + " attr: " + PI.Name + " a=" + aProp.ToString() + " b=" + bProp.ToString());
                    //}
                }
            }

            var fields = a.GetType().GetFields();

            foreach (FieldInfo FI in fields)
            {
                var token = FI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute));
                if (token != null)
                {
                    Console.WriteLine("compare: " + a.ToString() + " " + FI.Name);

                    object aFiled = FI.GetValue(a);
                    object bField = b.GetType().GetField(FI.Name).GetValue(b);

                    if (aFiled == null && bField == null)
                    {
                        continue;
                    }

                    if (aFiled.ToString() != bField.ToString())
                    {
                        throw new Exception("Items no match tostring: " + a.ItemName + " attr: " + FI.Name + " a=" + aFiled.ToString() + " b=" + bField.ToString());
                    }

                    //if (aFiled != bField)
                    //{
                    //    throw new Exception("Items no match: " + a.ItemName + " attr: " + FI.Name + " a=" + aFiled.ToString() + " b=" + bField.ToString());
                    //}

                    if (aFiled is IObservableList)
                    {
                        if (((IObservableList)aFiled).Count != ((IObservableList)bField).Count)
                        {
                            throw new Exception("Items in list count do not match: " + a.ItemName + " attr: " + FI.Name + " a=" + aFiled.ToString() + " b=" + bField.ToString());
                        }
                        var aList = ((IObservableList)aFiled).GetEnumerator();
                        var bList = ((IObservableList)bField).GetEnumerator();



                        while (aList.MoveNext())
                        {
                            bList.MoveNext();
                            RepositoryItemBase o1 = (RepositoryItemBase)aList.Current;
                            RepositoryItemBase o2 = (RepositoryItemBase)bList.Current;
                            CompareRepoItem(o1, o2);
                        }
                    }
                }
            }
        }
예제 #16
0
 public void SetReportData(RepositoryItemBase item)
 {
 }
        /// <summary>
        /// Paste the Copied or Cut Items
        /// </summary>
        /// <param name="containerControl">The UI control which paste is done on (DataGrid/TreeView/ListView)</param>
        /// <param name="propertiesToSet">List of properties PropertyName-Value to set in reflection to they paste item</param>
        public static void PasteItems(IClipboardOperations containerControl, List <Tuple <string, object> > propertiesToSet = null, int currentIndex = -1, Context context = null)
        {
            bool IsValidActionPlatform = true;

            ((Control)containerControl).Dispatcher.Invoke(() =>
            {
                try
                {
                    if (CopiedorCutItems.Count > 0)
                    {
                        Reporter.ToStatus(eStatusMsgKey.PasteProcess, null, string.Format("Performing paste operation for {0} items...", CopiedorCutItems.Count));

                        if (CutSourceList != null)
                        {
                            //CUT
                            //first remove from cut source
                            foreach (RepositoryItemBase item in CopiedorCutItems)
                            {
                                //clear from source
                                CutSourceList.Remove(item);
                                if (currentIndex > 0)
                                {
                                    currentIndex--;
                                }
                                //set needed properties if any
                                SetProperties(item, propertiesToSet);
                                if (!containerControl.GetSourceItemsAsIList().Contains(item))//Not cut & paste on same grid
                                {
                                    //set unique name
                                    GingerCoreNET.GeneralLib.General.SetUniqueNameToRepoItem(containerControl.GetSourceItemsAsList(), item);
                                }
                                //check action platform before copy
                                if (!ActionsFactory.IsValidActionPlatformForActivity(item, context))
                                {
                                    IsValidActionPlatform = false;
                                    continue;
                                }
                                //paste on target and select
                                containerControl.SetSelectedIndex(AddItemAfterCurrent(containerControl, item, currentIndex));
                                //Trigger event for changing sub classes fields
                                containerControl.OnPasteItemEvent(PasteItemEventArgs.ePasteType.PasteCutedItem, item);
                            }

                            //clear so will be past only once
                            CutSourceList = null;
                            CopiedorCutItems.Clear();
                        }
                        else
                        {
                            //COPY
                            //paste on target
                            foreach (RepositoryItemBase item in CopiedorCutItems)
                            {
                                RepositoryItemBase copiedItem = item.CreateCopy();
                                //set unique name
                                GingerCoreNET.GeneralLib.General.SetUniqueNameToRepoItem(containerControl.GetSourceItemsAsList(), copiedItem, "_Copy");
                                //set needed properties if any
                                SetProperties(copiedItem, propertiesToSet);

                                //check action platform before copy
                                if (!ActionsFactory.IsValidActionPlatformForActivity(copiedItem, context))
                                {
                                    IsValidActionPlatform = false;
                                    continue;
                                }
                                //add and select
                                containerControl.SetSelectedIndex(AddItemAfterCurrent(containerControl, copiedItem, currentIndex));
                                //Trigger event for changing sub classes fields
                                containerControl.OnPasteItemEvent(PasteItemEventArgs.ePasteType.PasteCopiedItem, copiedItem);
                            }
                        }
                    }
                    else
                    {
                        Reporter.ToStatus(eStatusMsgKey.PasteProcess, null, "No items found to paste");
                    }
                    if (!IsValidActionPlatform)
                    {
                        Reporter.ToUser(eUserMsgKey.MissingTargetApplication, "Unable to copy actions with different platform.");
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "Operation Failed, make sure the copied/cut items type and destination type is matching." + System.Environment.NewLine + System.Environment.NewLine + "Error: " + ex.Message);
                    //CutSourceList = null;
                    //CopiedorCutItems.Clear();
                }
                finally
                {
                    Reporter.HideStatusMessage();
                }
            });
        }
예제 #18
0
        public VariableEditPage(VariableBase v, bool setGeneralConfigsAsReadOnly = false, eEditMode mode = eEditMode.BusinessFlow, RepositoryItemBase parent = null)
        {
            InitializeComponent();

            this.Title = "Edit " + GingerDicser.GetTermResValue(eTermResKey.Variable);
            mVariable  = v;
            mVariable.SaveBackup();
            editMode = mode;
            mParent  = parent;

            App.ObjFieldBinding(txtVarName, TextBox.TextProperty, mVariable, VariableBase.Fields.Name);
            App.ObjFieldBinding(txtVarDescritpion, TextBox.TextProperty, mVariable, VariableBase.Fields.Description);
            App.ObjFieldBinding(txtFormula, TextBox.TextProperty, mVariable, VariableBase.Fields.Formula, BindingMode.OneWay);
            App.ObjFieldBinding(txtCurrentValue, TextBox.TextProperty, mVariable, VariableBase.Fields.Value, BindingMode.OneWay);
            App.ObjFieldBinding(cbSetAsInputValue, CheckBox.IsCheckedProperty, mVariable, VariableBase.Fields.SetAsInputValue);
            App.ObjFieldBinding(cbSetAsOutputValue, CheckBox.IsCheckedProperty, mVariable, VariableBase.Fields.SetAsOutputValue);

            if (mode == eEditMode.Global)
            {
                cbSetAsInputValue.Visibility  = Visibility.Hidden;
                cbSetAsOutputValue.Visibility = Visibility.Hidden;
            }
            else
            {
                cbSetAsInputValue.Visibility  = Visibility.Visible;
                cbSetAsOutputValue.Visibility = Visibility.Visible;
            }
            if (setGeneralConfigsAsReadOnly)
            {
                txtVarName.IsReadOnly        = true;
                txtVarDescritpion.IsReadOnly = true;
                cbSetAsInputValue.IsEnabled  = false;
                cbSetAsOutputValue.IsEnabled = false;
            }

            mVariable.PropertyChanged += mVariable_PropertyChanged;
            LoadVarPage();

            SetLinkedVarCombo();

            if (mVariable.Tags == null)
            {
                mVariable.Tags = new ObservableList <Guid>();
            }
            TagsViewer.Init(mVariable.Tags);

            if (editMode == eEditMode.BusinessFlow || editMode == eEditMode.Activity)
            {
                SharedRepoInstanceUC.Init(mVariable, App.BusinessFlow);
            }
            else
            {
                SharedRepoInstanceUC.Visibility = Visibility.Collapsed;
                SharedRepoInstanceUC_Col.Width  = new GridLength(0);
            }
        }
        public Boolean UploadItemToRepository(Context context, UploadItemSelection itemToUpload)
        {
            try
            {
                RepositoryItemBase item         = itemToUpload.UsageItem;
                string             itemFileName = string.Empty;
                RepositoryItemBase itemCopy     = null;
                bool isOverwrite = false;
                if (itemToUpload.ItemUploadType == UploadItemSelection.eItemUploadType.Overwrite)
                {
                    isOverwrite = true;
                    itemCopy    = GetItemToOverrite(itemToUpload);
                }
                else
                {
                    itemCopy = (RepositoryItemBase)item.CreateCopy(false);
                }

                itemCopy.UpdateItemFieldForReposiotryUse();



                bool blockingIssuesHandled = HandleItemValidationIssues(context, itemToUpload, itemCopy, ref isOverwrite);

                if (blockingIssuesHandled == false)
                {
                    itemToUpload.ItemUploadStatus = UploadItemSelection.eItemUploadStatus.FailedToUpload;
                    return(false);
                }

                if (isOverwrite)
                {
                    WorkSpace.Instance.SolutionRepository.MoveSharedRepositoryItemToPrevVersion(itemToUpload.ExistingItem);

                    RepositoryFolderBase repositoryFolder = WorkSpace.Instance.SolutionRepository.GetRepositoryFolderByPath(itemToUpload.ExistingItem.ContainingFolderFullPath);
                    if (repositoryFolder != null)
                    {
                        repositoryFolder.AddRepositoryItem(itemCopy);
                    }
                }
                else
                {
                    WorkSpace.Instance.SolutionRepository.AddRepositoryItem(itemCopy);
                }

                itemToUpload.UsageItem.IsSharedRepositoryInstance = true;

                if (itemToUpload.ExistingItemType == UploadItemSelection.eExistingItemType.ExistingItemIsParent && itemToUpload.ItemUploadType == UploadItemSelection.eItemUploadType.New)
                {
                    itemToUpload.UsageItem.ParentGuid = Guid.Empty;
                }

                itemToUpload.ItemUploadStatus = UploadItemSelection.eItemUploadStatus.Uploaded;
                return(true);
            }
            catch (Exception e)
            {
                Reporter.ToLog(eLogLevel.ERROR, "failed to upload the repository item", e);
                itemToUpload.ItemUploadStatus = UploadItemSelection.eItemUploadStatus.FailedToUpload;
                return(false);
            }
        }
        private bool HandleItemValidationIssues(Context context, UploadItemSelection selectedItem, RepositoryItemBase itemCopy, ref bool isOverwrite)
        {
            bool blockingIssuesHandled           = true;
            List <ItemValidationBase> itemIssues = ItemValidationBase.GetAllIssuesForItem(selectedItem);

            if (itemIssues != null && itemIssues.Count > 0)
            {
                foreach (ItemValidationBase issue in itemIssues)
                {
                    switch (issue.mIssueType)
                    {
                    case ItemValidationBase.eIssueType.MissingVariables:
                        if (issue.Selected)
                        {
                            foreach (string missingVariableName in issue.missingVariablesList)
                            {
                                VariableBase missingVariable = context.BusinessFlow.GetHierarchyVariableByName(missingVariableName);

                                if (missingVariable != null)
                                {
                                    ((Activity)itemCopy).Variables.Add(missingVariable);
                                }
                            }

                            selectedItem.Comment = "Missing " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " added to " + GingerDicser.GetTermResValue(eTermResKey.Activity);
                        }
                        else
                        {
                            selectedItem.Comment = "Uploaded without adding missing " + GingerDicser.GetTermResValue(eTermResKey.Variables);
                        }
                        break;

                    case ItemValidationBase.eIssueType.DuplicateName:
                        if (issue.Selected)
                        {
                            isOverwrite          = false;
                            itemCopy.ItemName    = issue.ItemNewName;
                            selectedItem.Comment = "Uploaded with new newm" + issue.ItemNewName;
                        }
                        else
                        {
                            selectedItem.Comment  = "Can not upload the item with same name";
                            blockingIssuesHandled = false;    // if user do not accept new name, upload can not proceed for the item
                        }
                        break;
                    }
                }
            }
            return(blockingIssuesHandled);
        }
        public RepositoryItemUsagePage(RepositoryItemBase repoItem, bool includeOriginal = true, RepositoryItemBase originalItem = null)
        {
            InitializeComponent();

            mRepoItem        = repoItem;
            mIncludeOriginal = includeOriginal;
            if (originalItem != null)
            {
                mOriginalItem = originalItem;
            }
            else
            {
                mOriginalItem = mRepoItem;
            }

            FindUsages();

            usageGrid.DataSourceList = RepoItemUsages;
            SetUsagesGridView();
        }
        // static string mGingerVersion;
        // static long mGingerVersionAsLong = 0;

        public void SaveToFile(RepositoryItemBase ri, string FileName)
        {
            string txt = SerializeToString(ri);

            File.WriteAllText(FileName, txt);
        }
예제 #23
0
        public static void SetUniqueNameToRepoItem(ObservableList <RepositoryItemBase> itemsList, RepositoryItemBase item, string suffix = "")
        {
            string originalName = item.ItemName;

            if (itemsList.Where(x => x.ItemName == item.ItemName).FirstOrDefault() == null)
            {
                return;//name is unique
            }

            if (!string.IsNullOrEmpty(suffix))
            {
                item.ItemName = item.ItemName + suffix;
                if (itemsList.Where(x => x.ItemName == item.ItemName).FirstOrDefault() == null)
                {
                    return;//name with Suffix is unique
                }
            }

            int counter = 1;

            while (itemsList.Where(x => x.ItemName == item.ItemName).FirstOrDefault() != null)
            {
                counter++;
                if (!string.IsNullOrEmpty(suffix))
                {
                    item.ItemName = originalName + suffix + counter.ToString();
                }
                else
                {
                    item.ItemName = originalName + counter.ToString();
                }
            }
        }
예제 #24
0
        private async void Init()
        {
            try
            {
                xProcessingIcon.Visibility = Visibility.Visible;
                if (SourceControlIntegration.BusyInProcessWhileDownloading)
                {
                    Reporter.ToUser(eUserMsgKey.StaticInfoMessage, "Please wait for current process to end.");
                    return;
                }
                SourceControlIntegration.BusyInProcessWhileDownloading = true;

                await Task.Run(() =>
                {
                    mFiles = SourceControlIntegration.GetPathFilesStatus(WorkSpace.Instance.Solution.SourceControl, mPath);
                    //set items name and type
                    Parallel.ForEach(mFiles, SCFI =>
                    {
                        try
                        {
                            if (SCFI.Path.ToUpper().Contains(".GINGER.") && SCFI.Path.ToUpper().Contains(".XML") && SCFI.Status != SourceControlFileInfo.eRepositoryItemStatus.Deleted)
                            {
                                NewRepositorySerializer newRepositorySerializer = new NewRepositorySerializer();
                                //unserialize the item
                                RepositoryItemBase item = newRepositorySerializer.DeserializeFromFile(SCFI.Path);
                                SCFI.Name = item.ItemName;
                            }
                            else
                            {
                                SCFI.Name = SCFI.Path.Substring(SCFI.Path.LastIndexOf('\\') + 1);
                            }
                        }
                        catch (Exception ex)
                        {
                            //TODO: fix the path changes
                            if (SCFI.Path.Contains('\\') && (SCFI.Path.LastIndexOf('\\') + 1 < SCFI.Path.Length - 1))
                            {
                                SCFI.Name = SCFI.Path.Substring(SCFI.Path.LastIndexOf('\\') + 1);
                            }
                            Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                        }

                        if (string.IsNullOrEmpty(SCFI.Path))
                        {
                            SCFI.FileType = "";
                        }
                        else if (SCFI.Path.ToUpper().Contains("AGENTS"))
                        {
                            SCFI.FileType = "Agent";
                        }
                        else if (SCFI.Path.ToUpper().Contains("BUSINESSFLOWS"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow);
                        }
                        else if (SCFI.Path.ToUpper().Contains("DOCUMENTS"))
                        {
                            SCFI.FileType = "Document";
                        }
                        else if (SCFI.Path.ToUpper().Contains("ENVIRONMENTS"))
                        {
                            SCFI.FileType = "Environment";
                        }
                        else if (SCFI.Path.ToUpper().Contains("EXECUTIONRESULTS"))
                        {
                            SCFI.FileType = "Execution Result";
                        }
                        else if (SCFI.Path.ToUpper().Contains("RUNSET"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.RunSet);
                        }
                        else if (SCFI.Path.ToUpper().Contains("ACTIONS"))
                        {
                            SCFI.FileType = "Action";
                        }
                        else if (SCFI.Path.ToUpper().Contains("ACTIVITIESGROUPS"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup);
                        }
                        else if (SCFI.Path.ToUpper().Contains("ACTIVITIES"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.Activity);
                        }
                        else if (SCFI.Path.ToUpper().Contains("VARIABLES"))
                        {
                            SCFI.FileType = GingerDicser.GetTermResValue(eTermResKey.Variable);
                        }

                        else if (SCFI.Path.Contains("ApplicationAPIModel"))
                        {
                            SCFI.FileType = "Application API Model";
                        }
                        else if (SCFI.Path.Contains("GlobalAppModelParameter"))
                        {
                            SCFI.FileType = "Global Applications Model Parameter";
                        }
                    });
                });

                CheckInFilesGrid.DataSourceList = mFiles;
            }
            finally
            {
                xProcessingIcon.Visibility = Visibility.Collapsed;
                SourceControlIntegration.BusyInProcessWhileDownloading = false;
            }
        }
예제 #25
0
        public void CheckPropertyChangedTriggered()
        {
            // Scan all RIs for each prop marked with [IsSerializedForLocalRepositoryAttribute] try to change and verify prop changed triggered

            //Arrange

            // Get all Repository items
            IEnumerable <Type> list = GetRepoItems();

            ErrCounter = 0;

            //Act
            foreach (Type type in list)
            {
                Console.WriteLine("CheckPropertyChangedTriggered for type: " + type.FullName);
                if (type.IsAbstract)
                {
                    continue;
                }
                RepositoryItemBase RI = (RepositoryItemBase)Activator.CreateInstance(type);
                RI.PropertyChanged += RIPropertyChanged;
                RI.StartDirtyTracking();

                // Properties
                foreach (PropertyInfo PI in RI.GetType().GetProperties())
                {
                    var token = PI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute));
                    if (token == null)
                    {
                        continue;
                    }
                    Console.WriteLine("CheckPropertyChangedTriggered for property: " + PI.Name);
                    object newValue = GetNewValue(PI.PropertyType, PI.GetValue(RI));
                    if (newValue != null)
                    {
                        RI.DirtyStatus = eDirtyStatus.NoChange;
                        prop           = null;
                        PI.SetValue(RI, newValue);
                        CheckChanges(RI, PI.Name, newValue);
                    }
                }


                // Fields
                foreach (FieldInfo FI in RI.GetType().GetFields())
                {
                    var token = FI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute));
                    if (token == null)
                    {
                        continue;
                    }
                    Console.WriteLine("CheckPropertyChangedTriggered for property: " + FI.Name);
                    object newValue = GetNewValue(FI.FieldType, FI.GetValue(RI));
                    if (newValue != null)
                    {
                        RI.DirtyStatus = eDirtyStatus.NoChange;
                        prop           = null;
                        FI.SetValue(RI, newValue);
                        CheckChanges(RI, FI.Name, newValue);
                    }
                }
            }
            //Assert
            Assert.AreEqual(0, ErrCounter);
        }
예제 #26
0
 public void OnPasteItemEvent(PasteItemEventArgs.ePasteType pasteType, RepositoryItemBase item)
 {
     PasteItemEvent?.Invoke(new PasteItemEventArgs(pasteType, item));
 }
        private static int AddItemAfterCurrent(IClipboardOperations containerControl, RepositoryItemBase item, int currentIndex = -1)
        {
            int insertIndex = 0;

            //adding the new item after current selected item
            if (currentIndex == -1 || containerControl.GetSourceItemsAsIList().CurrentItem != null)
            {
                currentIndex = containerControl.GetSourceItemsAsIList().IndexOf((RepositoryItemBase)containerControl.GetSourceItemsAsIList().CurrentItem);
            }

            if (currentIndex >= 0)
            {
                insertIndex = currentIndex + 1;
            }

            containerControl.GetSourceItemsAsIList().Insert(insertIndex, item);

            return(insertIndex);
        }
예제 #28
0
        public override void UpdateInstance(RepositoryItemBase instance, string partToUpdate, RepositoryItemBase hostItem = null)
        {
            VariableBase variableBaseInstance = (VariableBase)instance;

            //Create new instance of source
            VariableBase newInstance = (VariableBase)this.CreateInstance();

            newInstance.IsSharedRepositoryInstance = true;

            //update required part
            VariableBase.eItemParts ePartToUpdate = (VariableBase.eItemParts)Enum.Parse(typeof(VariableBase.eItemParts), partToUpdate);
            switch (ePartToUpdate)
            {
            case eItemParts.All:
                //case eItemParts.Details:
                newInstance.Guid       = variableBaseInstance.Guid;
                newInstance.ParentGuid = variableBaseInstance.ParentGuid;
                newInstance.ExternalID = variableBaseInstance.ExternalID;
                //if (ePartToUpdate == eItemParts.Details)
                //{
                //}
                if (hostItem != null)
                {
                    //replace old instance object with new
                    int originalIndex = 0;

                    //TODO: Fix the issues
                    if (hostItem is Activity)
                    {
                        originalIndex = ((Activity)hostItem).GetVariables().IndexOf(variableBaseInstance);
                        ((Activity)hostItem).GetVariables().Remove(variableBaseInstance);
                        ((Activity)hostItem).GetVariables().Insert(originalIndex, newInstance);
                    }
                    else
                    {
                        originalIndex = ((BusinessFlow)hostItem).GetVariables().IndexOf(variableBaseInstance);
                        ((BusinessFlow)hostItem).GetVariables().Remove(variableBaseInstance);
                        ((BusinessFlow)hostItem).GetVariables().Insert(originalIndex, newInstance);
                    }
                }
                break;
            }
        }
예제 #29
0
 private void DeleteGlobalParam(RepositoryItemBase globalParamToDelete)
 {
     WorkSpace.Instance.SolutionRepository.DeleteRepositoryItem(globalParamToDelete);
 }
예제 #30
0
        public override RepositoryItemBase GetUpdatedRepoItem(RepositoryItemBase itemToUpload, RepositoryItemBase existingRepoItem, string itemPartToUpdate)
        {
            VariableBase updatedVariable = null;

            //update required part
            eItemParts ePartToUpdate = (eItemParts)Enum.Parse(typeof(VariableBase.eItemParts), itemPartToUpdate);

            switch (ePartToUpdate)
            {
            case eItemParts.All:
                updatedVariable = (VariableBase)itemToUpload.CreateCopy(false);

                break;
            }

            return(updatedVariable);
        }