コード例 #1
0
ファイル: FunctionTestForm.cs プロジェクト: WZWGeorge/RTDB
        private void  组搜索ToolStripMenuItemClick(object sender, EventArgs e)
        {
            InitVariableUi(Displaytype.Variable);
            VariableBase digitalVariable = _iVariableDesignRepository.FindVariableByPath(toolStripTextBox1.Text);

            dataGridView_Avaiable.Rows.Clear();
            if (digitalVariable != null)
            {
                AddVarToListview(digitalVariable, dataGridView_Avaiable);
            }
        }
コード例 #2
0
 private void grdMain_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.Column.Header.ToString() == nameof(VariableBase.Name))
     {
         VariableBase selectedVarb = (VariableBase)grdVariables.CurrentItem;
         if (selectedVarb.Name != selectedVarb.NameBeforeEdit)
         {
             UpdateVariableNameChange(selectedVarb);
         }
     }
 }
コード例 #3
0
        public void TestActivityVariablesSyncWithRepo()
        {
            string variableName = "ACTVAR1";
            string initialValue = "123";
            string updatedValue = "abc123";

            mBF = new BusinessFlow()
            {
                Name = "TestActvVarSync", Active = true
            };
            mBF.Activities = new ObservableList <Activity>();

            VariableString V1 = new VariableString()
            {
                Name = variableName, InitialStringValue = initialValue
            };

            // add variable to the activity
            Activity activity = new Activity()
            {
                ActivityName = "Activity1"
            };

            activity.AddVariable(V1);

            // add business flow to the solution repository
            mSolutionRepository.AddRepositoryItem(mBF);

            // prepare to add the variable to the shared repository
            UploadItemSelection uploadItemSelection = new UploadItemSelection()
            {
                UsageItem = V1, ItemUploadType = UploadItemSelection.eItemUploadType.New
            };

            SharedRepositoryOperations.UploadItemToRepository(uploadItemSelection);

            // find the newly added variable in the shared repo
            VariableBase   sharedVariableBase = (from x in mSolutionRepository.GetAllRepositoryItems <VariableBase>() where x.Name == variableName select x).SingleOrDefault();
            VariableString sharedV1           = (VariableString)sharedVariableBase;

            //update the new value in the shared repo variable
            sharedV1.InitialStringValue = updatedValue;

            //sync the updated instance with the business flow instance
            sharedV1.UpdateInstance(V1, "All", activity);

            // get the updated value from the business flow
            VariableString V2 = (VariableString)activity.Variables[0];

            //Assert
            Assert.AreEqual(1, activity.Variables.Count);
            Assert.AreNotSame(V1, V2);
            Assert.AreEqual(updatedValue, V2.InitialStringValue);
        }
コード例 #4
0
        public void Create()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));

            Assert.NotNull(Local1);
            Assert.Equal(typeof(int), Local1.DataType);
            Assert.Equal("Local1", Local1.Name);
        }
コード例 #5
0
        private void VariablesGrid_grdMain_MouseDoubleClick(object sender, EventArgs e)
        {
            VariableBase selectedVarb = (VariableBase)grdVariables.CurrentItem;
            selectedVarb.NameBeforeEdit = selectedVarb.Name;

            VariableEditPage w = new VariableEditPage(selectedVarb, false);
            w.ShowAsWindow(eWindowShowStyle.Dialog);

            if (selectedVarb.NameBeforeEdit != selectedVarb.Name)
                UpdateVariableNameChange(selectedVarb);
        }
コード例 #6
0
        public void Call()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method  = TestType.CreateMethod("TestMethod");
            IMethodBuilder Method2 = TestType.CreateMethod("TestMethod2");
            VariableBase   Local1  = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2  = Method.CreateLocal("Local2", typeof(int));

            Assert.DoesNotThrow(() => Method.This.Call(Method2, null));
        }
コード例 #7
0
        private void CopyBusFlowVariables(object sender, RoutedEventArgs e)
        {
            if (grdVariables.CurrentItem != null)
            {
                if (Reporter.ToUser(eUserMsgKey.AskIfShareVaribalesInRunner) == Amdocs.Ginger.Common.eUserMsgSelection.Yes)
                {
                    int countMatchingBfs = 0;

                    List <VariableBase> selectedVars = grdVariables.Grid.SelectedItems.Cast <VariableBase>().ToList();
                    foreach (GingerRunner runner in WorkSpace.Instance.RunsetExecutor.Runners)
                    {
                        List <BusinessFlow> matchingBfs = runner.BusinessFlows.Where(x => x.Guid == mBusinessFlow.Guid).ToList();
                        countMatchingBfs += matchingBfs.Count;
                        foreach (BusinessFlow bf in matchingBfs)
                        {
                            foreach (VariableBase selectedVar in selectedVars)
                            {
                                VariableBase matchingVar = bf.GetBFandActivitiesVariabeles(true).Where(x => x.Guid == selectedVar.Guid).FirstOrDefault();
                                if (matchingVar != null)
                                {
                                    String originalValue   = matchingVar.Value;
                                    String originalFormula = matchingVar.Formula;

                                    VariableBase copiedVar = (VariableBase)selectedVar.CreateCopy();;
                                    if (selectedVar.ParentType == "Business Flow")
                                    {
                                        int indexSelected = bf.Variables.IndexOf(matchingVar);
                                        bf.Variables.Remove(matchingVar);
                                        bf.Variables.Insert(indexSelected, copiedVar);
                                    }
                                    if (selectedVar.ParentType == "Activity")
                                    {
                                        Activity a             = (Activity)bf.GetActivity(selectedVar.ParentGuid);
                                        int      indexSelected = a.Variables.IndexOf(matchingVar);
                                        a.Variables.Remove(matchingVar);
                                        a.Variables.Insert(indexSelected, copiedVar);
                                    }
                                    if (copiedVar.Formula != originalFormula || copiedVar.Value != originalValue) //variable was changed
                                    {
                                        copiedVar.VarValChanged      = true;
                                        copiedVar.DiffrentFromOrigin = true;
                                    }
                                }
                            }
                        }
                    }
                    Reporter.ToUser(eUserMsgKey.CopiedVariableSuccessfully, countMatchingBfs - 1);
                }
            }
            else
            {
                Reporter.ToUser(eUserMsgKey.ShareVariableNotSelected);
            }
        }
コード例 #8
0
        private void grdMain_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            RefreshVariablesNames();

            VariableBase selectedVarb = (VariableBase)grdVariables.CurrentItem;

            if (selectedVarb.Name != selectedVarb.NameBeforeEdit)
            {
                UpdateVariableNameChange(selectedVarb);
            }
        }
コード例 #9
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="leftHandSide">Left hand side</param>
        /// <param name="value">Value to store</param>
        public Assign(VariableBase leftHandSide, object value)
        {
            if (leftHandSide == null)
            {
                throw new ArgumentNullException("leftHandSide");
            }
            LeftHandSide = leftHandSide;
            var tempValue = value as VariableBase;

            RightHandSide = tempValue == null?MethodBase.CurrentMethod.CreateConstant(value) : tempValue;
        }
コード例 #10
0
        private void InsertNewVarTreeItem(TreeViewItem parentTvi, VariableBase vb)
        {
            TreeViewItem tvi           = new TreeViewItem();
            string       VarExpression = "{Var Name=" + vb.Name + "}";

            SetItemView(tvi, vb.Name, VarExpression, "@Variable_16x16.png");
            parentTvi.Items.Add(tvi);
            tvi.MouseDoubleClick += tvi_MouseDoubleClick;
            tvi.Selected         += UpdateHelpForVariables;
            tvi.Tag = vb;
        }
コード例 #11
0
        /// <summary>
        /// 粘贴变量
        /// </summary>
        /// <param name="source">需要粘贴的变量</param>
        /// <param name="absolutePath">粘贴变量的目标组</param>
        /// <param name="isCopy">是否为复制,true为复制,false为剪切</param>
        /// <param name="pasteMode">粘贴模式,0:默认模式,重复则返回,1:如果重复则替换,2:如果重复则两个变量都保留,3:如果重复则放弃</param>
        /// <returns>如果默认模式下且有相同变量名称存在返回变量新名称,否则返回粘贴变量名称</returns>
        public virtual string PasteVariable(VariableBase source, string absolutePath, bool isCopy,
                                            uint pasteMode = 0)
        {
            if (source == null)
            {
                throw new ArgumentNullException(Resource1.VariableRepository_PasteVariable_sourceVariable);
            }

            VariableGroup desGroup = VariableRepository.FindGroupByPath(absolutePath);

            if (desGroup == null)
            {
                throw new ArgumentNullException(Resource1.VariableRepository_PasteVariable_desGroup);
            }

            if (IsExistName(source.Name, desGroup) && (pasteMode == 0))
            {
                return(GetDefaultName(desGroup, source.Name)); //保留两个变量后新的变量名
            }

            if (pasteMode <= 2)
            {
                if (pasteMode == 1) //替换
                {
                    //如果变量的位置与目标位置相同,无需替换,直接返回
                    if (source.ParentGroup.AbsolutePath == absolutePath)
                    {
                        return(source.Name);
                    }
                    RemoveVariable(source.Name, desGroup.AbsolutePath);
                }
                if (isCopy)
                {
                    VariableBase var = ObjectCopier.Clone(source);
                    var.ParentGroup = desGroup;

                    if (pasteMode == 2) //同时保留两个
                    {
                        var.Name = GetDefaultName(desGroup, source.Name);
                    }
                    AddVariable(var);
                }
                else
                {
                    if (pasteMode == 2) //同时保留两个
                    {
                        source.Name = GetDefaultName(desGroup, source.Name);
                    }
                    MoveVariable(source.AbsolutePath, desGroup.AbsolutePath);
                }
            }
            return(source.Name);
        }
コード例 #12
0
        private static void SetupEnd(IMethodBuilder method, VariableBase returnValue, IPropertyBuilder aspectusEnding)
        {
            VariableBase endingArgs = method.NewObj(typeof(Ending).GetConstructor(new Type[0]));

            endingArgs.Call(typeof(Ending).GetProperty("MethodName").GetSetMethod(), new object[] { method.Name });
            if (method.ReturnType != typeof(void) && returnValue.DataType != null && returnValue.DataType.IsValueType)
            {
                endingArgs.Call(typeof(Ending).GetProperty("ReturnValue").GetSetMethod(),
                                new object[] { method.Box(returnValue) });
            }
            else if (method.ReturnType != typeof(void))
            {
                endingArgs.Call(typeof(Ending).GetProperty("ReturnValue").GetSetMethod(), new object[] { returnValue });
            }
            VariableBase parameterList = endingArgs.Call(typeof(Ending).GetProperty("Parameters").GetGetMethod());

            for (int x = 1; x < method.Parameters.Count; ++x)
            {
                if (method.Parameters.ElementAt(x).DataType != null &&
                    method.Parameters.ElementAt(x).DataType.IsValueType)
                {
                    parameterList.Call(typeof(List <object>).GetMethod("Add"),
                                       new object[] { method.Box(method.Parameters.ElementAt(x)) });
                }
                else
                {
                    parameterList.Call(typeof(List <object>).GetMethod("Add"),
                                       new object[] { method.Parameters.ElementAt(x) });
                }
            }

            VariableBase eventsThis      = method.Cast(method.This, typeof(IEvents));
            Type         eventHelperType = typeof(DelegateExtensions);

            MethodInfo[] methods = eventHelperType.GetMethods()
                                   .Where(x => x.GetParameters().Length == 3)
                                   .ToArray();
            MethodInfo tempMethod = methods.Length > 0 ? methods[0] : null;

            tempMethod = tempMethod.MakeGenericMethod(new[] { typeof(Ending) });
            method.Call(null, tempMethod, new object[] { aspectusEnding, eventsThis, endingArgs });
            if (method.ReturnType != typeof(void))
            {
                VariableBase tempReturnValue = endingArgs.Call(typeof(Ending).GetProperty("ReturnValue").GetGetMethod());
                VariableBase tempNull        = method.CreateLocal("TempNull", typeof(object));
                If           If = method.If(tempReturnValue, Comparison.NotEqual, tempNull);
                {
                    returnValue.Assign(tempReturnValue);
                }
                method.SetCurrentMethod();
                If.EndIf();
            }
        }
コード例 #13
0
        public void While()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Utilities.Reflection.Emit.Commands.While While = Method.While(Local1, Utilities.Reflection.Emit.Enums.Comparison.Equal, Local2);
            Method.EndWhile(While);
            Assert.NotNull(While);
        }
コード例 #14
0
        public void AddVariableTest()
        {
            RepositoryConfig           variableRepositoryConfig = null;                                   // TODO: 初始化为适当的值
            EfVariableDesignRepository target = new EfVariableDesignRepository(variableRepositoryConfig); // TODO: 初始化为适当的值
            VariableBase variable             = null;                                                     // TODO: 初始化为适当的值
            VariableBase expected             = null;                                                     // TODO: 初始化为适当的值
            VariableBase actual;

            actual = target.AddVariable(variable);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
コード例 #15
0
 public void AddVariable(VariableBase v)
 {
     if (v != null)
     {
         if (string.IsNullOrEmpty(v.Name))
         {
             v.Name = "NewVar";
         }
         SetUniqueVariableName(v);
         Variables.Add(v);
     }
 }
コード例 #16
0
        private void ShowHideEditPage(VariableBase variabelToEdit)
        {
            if (variabelToEdit != null)
            {
                xBackToListGrid.Visibility = Visibility.Visible;
                mVarBeenEdit = variabelToEdit;
                BindingHandler.ObjFieldBinding(xSelectedItemTitleText, TextBlock.TextProperty, mVarBeenEdit, nameof(VariableBase.Name));
                BindingHandler.ObjFieldBinding(xSelectedItemTitleText, TextBlock.ToolTipProperty, mVarBeenEdit, nameof(VariableBase.Name));

                bool showAsReadOnly = false;
                if (mPageViewMode == General.eRIPageViewMode.View)
                {
                    showAsReadOnly = true;
                    xEditAndValueChangeOperationsPnl.Visibility = Visibility.Collapsed;
                }
                else
                {
                    xEditAndValueChangeOperationsPnl.Visibility = Visibility.Visible;
                    BindingHandler.ObjFieldBinding(xResetValueBtn, ucButton.VisibilityProperty, mVarBeenEdit, nameof(VariableBase.SupportResetValue), bindingConvertor: new BooleanToVisibilityConverter(), BindingMode.OneWay);
                    BindingHandler.ObjFieldBinding(xAutoValueBtn, ucButton.VisibilityProperty, mVarBeenEdit, nameof(VariableBase.SupportAutoValue), bindingConvertor: new BooleanToVisibilityConverter(), BindingMode.OneWay);
                    mVarBeenEdit.NameBeforeEdit = mVarBeenEdit.Name;
                    mVarBeenEdit.SaveBackup();
                }

                if (mVariabelsParent is Solution)
                {
                    mVariabelEditPage = new VariableEditPage(mVarBeenEdit, mContext, showAsReadOnly, VariableEditPage.eEditMode.Global);
                }
                else if (mVariabelsParent is BusinessFlow)
                {
                    mVariabelEditPage = new VariableEditPage(mVarBeenEdit, mContext, showAsReadOnly, VariableEditPage.eEditMode.Default);
                }
                else if (mVariabelsParent is Activity)
                {
                    if (mPageViewMode == General.eRIPageViewMode.View)
                    {
                        mVariabelEditPage = new VariableEditPage(mVarBeenEdit, mContext, showAsReadOnly, VariableEditPage.eEditMode.View);
                    }
                    else
                    {
                        mVariabelEditPage = new VariableEditPage(mVarBeenEdit, mContext, showAsReadOnly, VariableEditPage.eEditMode.Default);
                    }
                }
                xMainFrame.SetContent(mVariabelEditPage);
            }
            else
            {
                xBackToListGrid.Visibility = Visibility.Collapsed;
                mVariabelEditPage          = null;
                xMainFrame.SetContent(mVariabelsListView);
            }
        }
コード例 #17
0
 /// <summary>
 /// Sets up a property (List)
 /// </summary>
 /// <param name="Method">Method builder</param>
 /// <param name="BaseType">Base type for the object</param>
 /// <param name="ReturnValue">Return value</param>
 /// <param name="Property">Property info</param>
 /// <param name="Mapping">Mapping info</param>
 private void SetupListProperty(IMethodBuilder Method, Type BaseType, VariableBase ReturnValue, IProperty Property, IMapping Mapping)
 {
     Utilities.Reflection.Emit.FieldBuilder Field       = Fields.Find(x => x.Name == Property.DerivedFieldName);
     Utilities.Reflection.Emit.FieldBuilder FieldLoaded = Fields.Find(x => x.Name == Property.DerivedFieldName + "_Loaded");
     Utilities.Reflection.Emit.Commands.If  If1         = Method.If((VariableBase)SessionField, Comparison.NotEqual, null);
     {
         Utilities.Reflection.Emit.Commands.If If2 = Method.If(Field, Comparison.Equal, null);
         {
             Utilities.Reflection.Emit.Commands.If If3 = Method.If(FieldLoaded, Comparison.Equal, Method.CreateConstant(false));
             {
                 //Load data
                 VariableBase IDValue      = Method.This.Call(BaseType.GetProperty(Mapping.IDProperty.Name).GetGetMethod());
                 VariableBase IDParameter  = Method.NewObj(typeof(EqualParameter <>).MakeGenericType(Mapping.IDProperty.Type), new object[] { IDValue, "ID", "@" });
                 VariableBase PropertyList = Method.NewObj(typeof(List <IParameter>));
                 PropertyList.Call("Add", new object[] { IDParameter });
                 MethodInfo LoadPropertiesMethod = typeof(Session).GetMethod("LoadListProperties");
                 LoadPropertiesMethod = LoadPropertiesMethod.MakeGenericMethod(new Type[] { BaseType, Field.DataType.GetGenericArguments()[0] });
                 VariableBase ReturnVal = ((VariableBase)SessionField).Call(LoadPropertiesMethod, new object[] { Method.This, Property.Name, PropertyList.Call("ToArray") });
                 Field.Assign(ReturnVal);
                 FieldLoaded.Assign(true);
             }
             If3.EndIf();
         }
         If2.EndIf();
         PropertyInfo CountProperty = Field.DataType.GetProperty("Count");
         Utilities.Reflection.Emit.Commands.If If4 = Method.If(Field.Call(CountProperty.GetGetMethod()), Comparison.Equal, Method.CreateConstant(0));
         {
             Utilities.Reflection.Emit.Commands.If If3 = Method.If(FieldLoaded, Comparison.Equal, Method.CreateConstant(false));
             {
                 //Load data
                 VariableBase IDValue      = Method.This.Call(BaseType.GetProperty(Mapping.IDProperty.Name).GetGetMethod());
                 VariableBase IDParameter  = Method.NewObj(typeof(EqualParameter <>).MakeGenericType(Mapping.IDProperty.Type), new object[] { IDValue, "ID", "@" });
                 VariableBase PropertyList = Method.NewObj(typeof(List <IParameter>));
                 PropertyList.Call("Add", new object[] { IDParameter });
                 MethodInfo LoadPropertiesMethod = typeof(Session).GetMethod("LoadProperties");
                 LoadPropertiesMethod = LoadPropertiesMethod.MakeGenericMethod(new Type[] { BaseType, Field.DataType.GetGenericArguments()[0] });
                 VariableBase ReturnVal = ((VariableBase)SessionField).Call(LoadPropertiesMethod, new object[] { Method.This, Property.Name, PropertyList.Call("ToArray") });
                 Field.Assign(ReturnVal);
                 FieldLoaded.Assign(true);
             }
             If3.EndIf();
         }
         If4.EndIf();
         Utilities.Reflection.Emit.Commands.If If5 = Method.If(Field, Comparison.Equal, null);
         {
             Field.Assign(Method.NewObj(typeof(List <>).MakeGenericType(Property.Type).GetConstructor(Type.EmptyTypes)));
         }
         If5.EndIf();
     }
     If1.EndIf();
     ReturnValue.Assign(Field);
 }
コード例 #18
0
 /// <summary>
 /// 更新变量存储模型属性
 /// </summary>
 /// <param name="variable">变量</param>
 /// <param name="parentGroupId">父祖Id</param>
 public virtual void PullCopyProperty(VariableBase variable, int parentGroupId)
 {
     Name             = variable.Name;
     Description      = variable.Description;
     IsAddressable    = variable.IsAddressable;
     IsInitValueSaved = variable.IsInitValueSaved;
     IsRecordEvent    = variable.IsRecordEvent;
     IsValueSaved     = variable.IsValueSaved;
     ValueType        = (int)variable.ValueType;
     VariableType     = (int)variable.VariableType;
     ParentId         = parentGroupId;
     OperateProperty  = (int)variable.OperateProperty;
 }
コード例 #19
0
        public void UpdateVariableNameChange(VariableBase variable)
        {
            if (variable == null)
            {
                return;
            }

            switch (mVariablesLevel)
            {
            case eVariablesLevel.Solution:
                ObservableList <BusinessFlow> allBF = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>();
                foreach (BusinessFlow bfl in allBF)
                {
                    bfl.SetUniqueVariableName(variable);
                    foreach (Activity activity in bfl.Activities)
                    {
                        foreach (Act action in activity.Acts)
                        {
                            bool changedwasDone = false;
                            VariableBase.UpdateVariableNameChangeInItem(action, variable.NameBeforeEdit, variable.Name, ref changedwasDone);
                        }
                    }
                }
                break;

            case eVariablesLevel.BusinessFlow:
                BusinessFlow bf = (BusinessFlow)mVariablesParentObj;
                bf.SetUniqueVariableName(variable);
                foreach (Activity activity in bf.Activities)
                {
                    foreach (Act action in activity.Acts)
                    {
                        bool changedwasDone = false;
                        VariableBase.UpdateVariableNameChangeInItem(action, variable.NameBeforeEdit, variable.Name, ref changedwasDone);
                    }
                }
                break;

            case eVariablesLevel.Activity:
                Activity activ = (Activity)mVariablesParentObj;
                activ.SetUniqueVariableName(variable);
                foreach (Act action in activ.Acts)
                {
                    bool changedwasDone = false;
                    VariableBase.UpdateVariableNameChangeInItem(action, variable.NameBeforeEdit, variable.Name, ref changedwasDone);
                }
                break;
            }

            variable.NameBeforeEdit = variable.Name;
        }
コード例 #20
0
        public void TryCatch()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Utilities.Reflection.Emit.Commands.Try   Try   = Method.Try();
            Utilities.Reflection.Emit.Commands.Catch Catch = Method.Catch(typeof(Exception));
            Method.EndTry();
            Assert.NotNull(Try);
            Assert.NotNull(Catch);
        }
コード例 #21
0
        public void AddGlobalStringVariable()
        {
            //Arrange
            string name = "str1";

            //Act
            GlobalVariablesPOM globalVariablesPOM = mGingerAutomator.MainWindowPOM.GotoGlobalVariables();

            globalVariablesPOM.AddStringVariable(name);
            VariableBase v = (from x in Ginger.App.UserProfile.Solution.Variables where x.Name == name select x).SingleOrDefault();

            //Assert
            Assert.AreEqual(name, v.Name, "Var Name");
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        private void SetupEnd(IMethodBuilder Method, VariableBase ReturnValue, IPropertyBuilder AspectusEnding)
        {
            VariableBase EndingArgs = Method.NewObj(typeof(Ending).GetConstructor(new Type[0]));

            EndingArgs.Call(typeof(Ending).GetProperty("MethodName").GetSetMethod(), new object[] { Method.Name });
            if (Method.ReturnType != typeof(void) && ReturnValue.DataType != null && ReturnValue.DataType.IsValueType)
            {
                EndingArgs.Call(typeof(Ending).GetProperty("ReturnValue").GetSetMethod(), new object[] { Method.Box(ReturnValue) });
            }
            else if (Method.ReturnType != typeof(void))
            {
                EndingArgs.Call(typeof(Ending).GetProperty("ReturnValue").GetSetMethod(), new object[] { ReturnValue });
            }
            VariableBase ParameterList = EndingArgs.Call(typeof(Ending).GetProperty("Parameters").GetGetMethod());

            for (int x = 1; x < Method.Parameters.Count; ++x)
            {
                if (Method.Parameters[x].DataType != null && Method.Parameters[x].DataType.IsValueType)
                {
                    ParameterList.Call(typeof(List <object>).GetMethod("Add"), new object[] { Method.Box(Method.Parameters[x]) });
                }
                else
                {
                    ParameterList.Call(typeof(List <object>).GetMethod("Add"), new object[] { Method.Parameters[x] });
                }
            }

            VariableBase IEventsThis     = Method.Cast(Method.This, typeof(IEvents));
            Type         EventHelperType = typeof(Utilities.Events.EventHelper);

            MethodInfo[] Methods = EventHelperType.GetMethods()
                                   .Where <MethodInfo>(x => x.GetParameters().Length == 3)
                                   .ToArray();
            MethodInfo TempMethod = Methods.Length > 0 ? Methods[0] : null;

            TempMethod = TempMethod.MakeGenericMethod(new Type[] { typeof(Ending) });
            Method.Call(null, TempMethod, new object[] { AspectusEnding, IEventsThis, EndingArgs });
            if (Method.ReturnType != typeof(void))
            {
                VariableBase TempReturnValue             = EndingArgs.Call(typeof(Ending).GetProperty("ReturnValue").GetGetMethod());
                VariableBase TempNull                    = Method.CreateLocal("TempNull", typeof(object));
                Utilities.Reflection.Emit.Commands.If If = Method.If(TempReturnValue, Utilities.Reflection.Emit.Enums.Comparison.NotEqual, TempNull);
                {
                    ReturnValue.Assign(TempReturnValue);
                }
                Method.SetCurrentMethod();
                If.EndIf();
            }
        }
コード例 #24
0
        private static void SetupMethod(Type baseType, IMethodBuilder method, IPropertyBuilder aspectusStarting,
                                        IPropertyBuilder aspectusEnding, IPropertyBuilder aspectusException,
                                        MethodInfo baseMethod)
        {
            if (baseMethod == null)
            {
                baseMethod = baseType.GetMethod(method.Name);
            }
            method.SetCurrentMethod();
            Label        endLabel    = method.Generator.DefineLabel();
            VariableBase returnValue = method.ReturnType != typeof(void)
                                           ? method.CreateLocal("FinalReturnValue", method.ReturnType)
                                           : null;
            Try Try = method.Try();
            {
                SetupStart(method, endLabel, returnValue, aspectusStarting);
                _aspects.ForEach(x => x.SetupStartMethod(method, baseType));
                var parameters = new List <ParameterBuilder>();
                method.Parameters.For(1, method.Parameters.Count - 1, x => parameters.Add(x));
                if (method.ReturnType != typeof(void) && baseMethod != null)
                {
                    returnValue.Assign(method.This.Call(baseMethod, parameters.ToArray()));
                }
                else if (baseMethod != null)
                {
                    method.This.Call(baseMethod, parameters.ToArray());
                }
                SetupEnd(method, returnValue, aspectusEnding);
                _aspects.ForEach(x => x.SetupEndMethod(method, baseType, returnValue));
                method.Generator.MarkLabel(endLabel);
            }
            Catch Catch = Try.StartCatchBlock(typeof(System.Exception));

            {
                SetupException(method, Catch, aspectusException);
                _aspects.ForEach(x => x.SetupExceptionMethod(method, baseType));
                Catch.Rethrow();
            }
            Try.EndTryBlock();

            if (method.ReturnType != typeof(void))
            {
                method.Return(returnValue);
            }
            else
            {
                method.Return();
            }
        }
コード例 #25
0
        private void ReplaceVarWithValue(string p, string[] a)
        {
            string VarName = null;
            string tmp     = mValueCalculated;

            string suba = string.Join(" ", new ArraySegment <string>(a, 1, a.Length - 1));

            string[] ParamVal = suba.Split('=');
            {
                string ParamName = ParamVal[0];
                string Val       = suba.Substring(suba.IndexOf('=') + 1);
                switch (ParamName)
                {
                case "Name":
                    VarName = Val;
                    break;

                default:
                    // TODO err unknown param
                    break;
                }
            }

            string       VarValue;
            VariableBase vb = null;

            if (BF != null)
            {
                vb = BF.GetHierarchyVariableByName(VarName);
            }
            else
            {
                vb = (from v1 in WorkSpace.UserProfile.Solution.Variables where v1.Name == VarName select v1).FirstOrDefault();
            }

            if (vb != null)
            {
                VarValue         = vb.Value;
                mValueCalculated = tmp.Replace(p, VarValue);
            }

            //Use VBS instead of below
            else
            {
                //TODO: throw excpetion, log handler
                VarValue         = "!!!" + GingerDicser.GetTermResValue(eTermResKey.Variable) + " Not found!!! - " + a[1] + " <<<<<<<<<";
                mValueCalculated = VarValue;
            }
        }
コード例 #26
0
        /// <summary>
        /// 添加变量到DataGridView
        /// </summary>
        /// <param name="variable">变量</param>
        /// <param name="dataGridView"></param>
        protected void AddVarToListview(VariableBase variable, DataGridView dataGridView)
        {
            var row = new DataGridViewRow();

            row.CreateCells(dataGridView);
            var tableList = variable.VariableToDictionary();

            for (var i = 0; i < dataGridView.Columns.Count; i++)
            {
                row.Cells[i].Value = tableList.ContainsKey(dataGridView.Columns[i].Name.ToLower())
                                         ? tableList[dataGridView.Columns[i].Name.ToLower()]
                                         : "N/A";
            }
            dataGridView.Rows.Add(row); //增加一个新行
        }
コード例 #27
0
        private void EditVar(object sender, RoutedEventArgs e)
        {
            if (xVariablesGrid.CurrentItem != null && xVariablesGrid.CurrentItem.ToString() != "{NewItemPlaceholder}")
            {
                VariableBase selectedVarb = (VariableBase)xVariablesGrid.CurrentItem;
                selectedVarb.NameBeforeEdit = selectedVarb.Name;

                VariableEditPage w = new VariableEditPage(selectedVarb, mContext, false, VariableEditPage.eEditMode.SharedRepository);
                w.ShowAsWindow(eWindowShowStyle.Dialog);
            }
            else
            {
                Reporter.ToUser(eUserMsgKey.AskToSelectVariable);
            }
        }
コード例 #28
0
 public void SetItem(object item)
 {
     if (item is VariableBase)
     {
         mVariable = (VariableBase)item;
     }
     else if (item is ucButton)
     {
         mVariable = (VariableBase)(((ucButton)item).Tag);
     }
     else if (item is MenuItem)
     {
         mVariable = (VariableBase)(((MenuItem)item).Tag);
     }
 }
コード例 #29
0
        private void EditVar()
        {
            VariableBase     varToEdit       = (VariableBase)grdVariables.CurrentItem;
            string           originalFormula = varToEdit.Formula;
            string           originalValue   = varToEdit.Value;
            VariableEditPage w = new VariableEditPage(varToEdit, true);

            w.ShowAsWindow(eWindowShowStyle.Dialog);
            if (varToEdit.Formula != originalFormula || varToEdit.Value != originalValue)//varibale was changed
            {
                varToEdit.VarValChanged      = true;
                varToEdit.DiffrentFromOrigin = true;
            }
            UpdateEditVariablesTabVisual();
        }
        private void LoadGridData()
        {
            //TODO: check if Summary view is used...
            switch (mWindowMode)
            {
            case eWindowMode.Configuration:
                grdVariables.Title = "'" + mBusinessFlow.Name + "' Run " + GingerDicser.GetTermResValue(eTermResKey.Variables);
                ObservableList <VariableBase> bfInputVariables = mBusinessFlow.GetBFandActivitiesVariabeles(true, true);
                grdVariables.DataSourceList = VariableBase.SortByMandatoryInput(bfInputVariables);

                //**Legacy--- set the Variabels can be used- user should use Global Variabels/ Output Variabels instead
                ObservableList <string> optionalVars = new ObservableList <string>();
                optionalVars.Add(string.Empty);    //default value for clear selection
                foreach (VariableBase var in ((GingerExecutionEngine)mGingerRunner.Executor).GetPossibleOutputVariables(WorkSpace.Instance.RunsetExecutor.RunSetConfig, mBusinessFlow, includeGlobalVars: true, includePrevRunnersVars: false))
                {
                    optionalVars.Add(var.Name);
                }
                //allow setting  vars options only to variables types which supports setting value
                foreach (VariableBase inputVar in bfInputVariables)
                {
                    if (inputVar.SupportSetValue)
                    {
                        inputVar.PossibleVariables = optionalVars;
                    }
                }

                //Set Output Variabels can be used
                ObservableList <VariableBase> optionalOutputVars = new ObservableList <VariableBase>();
                foreach (VariableBase outputVar in ((GingerExecutionEngine)mGingerRunner.Executor).GetPossibleOutputVariables(WorkSpace.Instance.RunsetExecutor.RunSetConfig, mBusinessFlow, includeGlobalVars: false, includePrevRunnersVars: true))
                {
                    optionalOutputVars.Add(outputVar);
                }
                //allow setting output vars options only to variables types which supports setting value
                foreach (VariableBase inputVar in bfInputVariables)
                {
                    if (inputVar.SupportSetValue)
                    {
                        inputVar.PossibleOutputVariables = optionalOutputVars;
                    }
                }
                break;

            case eWindowMode.SummaryView:
                grdVariables.Title          = "'" + mBusinessFlowExecSummary.BusinessFlowName + "' Run " + GingerDicser.GetTermResValue(eTermResKey.Variables);
                grdVariables.DataSourceList = mBusinessFlowExecSummary.ExecutionVariabeles;
                break;
            }
        }
コード例 #31
0
 public override void BindToForm(VariableBase extension)
 {
     throw new NotImplementedException();
 }