public List <FunctionItem> GetFunctions(int Personid) { List <FunctionItem> functions = new List <FunctionItem>(); FunctionItem function = new FunctionItem(); using (SqlCommand sqlCommand = new SqlCommand( @"select fun.*, ft.[Name] from PersonFunction as pf join Person as p on pf.PersonId = p.PersonId join [Function] as fun on pf.FunctionId = fun.FunctionId join FunctionType as ft on fun.FuntionTypeId = ft.FunctionTypeId where p.PersonId = @id", cnn)) { sqlCommand.Parameters.AddWithValue("@id", Personid); using (SqlDataReader reader = sqlCommand.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { function = new FunctionItem(); function.FunctionId = Convert.ToInt32(reader["FunctionId"]); string name = reader["Name"].ToString().Trim(); function.FunctionType = Enum.GetValues(typeof(FunctionType)).Cast <FunctionType>().Where(x => x.ToString().CompareTo(name) == 0).FirstOrDefault(); function.PriceItems.Add(new PriceItem(PriceItemType.STANDARD, float.Parse(reader["PriceStandard"].ToString()))); string time = reader["Time"].ToString(); function.Time = DateTime.ParseExact(time, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).TimeOfDay; functions.Add(function); } } reader.Close(); } } return(functions); }
protected void btnSave_ServerClick(object sender, EventArgs e) { string strFuncName = txt_FunctionName.Value.Trim(); string strValue = txt_Value.Value.Trim(); string strTip = txt_Tip.Value.Trim(); string strImage = txt_Image.Value.Trim(); FunctionItem funcObj = FunctionItem.Get(nId); if (null == funcObj) { funcObj = new FunctionItem(); funcObj.ParentId = nParentId; funcObj.Level = nParentId == -1 ? -1 : (FunctionItem.Get(nParentId).Level + 1); } funcObj.Name = strFuncName; funcObj.Value = strValue; funcObj.Tip = strTip; funcObj.IconName = strImage; funcObj.Target = sel_Target.SelectedValue; funcObj.Width = Util.ParseInt(txt_Width.Value.Trim(), 0); funcObj.Height = Util.ParseInt(txt_Height.Value.Trim(), 0); funcObj.IsResize = rb_IsResizeYes.Checked ? Constants.Yes : Constants.No; funcObj.IsToMove = rb_IsToMoveYes.Checked ? Constants.Yes : Constants.No; funcObj.IsShowInTaskBar = rb_IsShowInTaskBarYes.Checked ? Constants.Yes : Constants.No; funcObj.IsIncludeMinBox = rb_IsIncludeMinBoxYes.Checked ? Constants.Yes : Constants.No; funcObj.IsIncludeMaxBox = rb_IsIncludeMaxBoxYes.Checked ? Constants.Yes : Constants.No; HEntityCommon.HEntity(funcObj).EntitySave(); PageUtil.PageAlert(this.Page, "保存成功!"); PageUtil.PageAppendScript(this.Page, "top.windowFactory.refreshRoot();top.windowFactory.closeTopFocusForm();"); }
public static ParForm New(MainModel m, FunctionItem x) { // cleanup Forms List <Item> closedKeys = new List <Item>(); foreach (Item y in Forms.Keys) { if (!Forms[y].Visible) { closedKeys.Add(y); } } foreach (Item y in closedKeys) { Forms.Remove(y); } ParForm f = null; Forms.TryGetValue(x, out f); if (f == null) { f = new ParForm(m); } f.Reset(x); Forms[x] = f; if (f.WindowState == FormWindowState.Minimized) { f.WindowState = FormWindowState.Normal; } f.Show(); f.BringToFront(); return(f); }
static FunctionItem CreateMethodItem(Method m) { var result = new FunctionItem(m); if (m.IsGenericDefinition && m.GenericParameterizations.Count() > 0) { var ptItems = new ParameterizationCollection(m.GenericParameterizations); for (int i = 0; i < ptItems.Children.Count; i++) { var ptRoot = ptItems.Children[i] as FunctionItem; if (ptRoot != null) { var method = (Method)ptRoot.Object; var param = method.GenericArguments.FirstOrDefault(); if (param is GenericParameterType && param.Parent == m.GenericType) { ptItems.Children.RemoveAt(i); ptRoot.AddChild(new DefinitionCollection(m)); ptRoot.AddChild(ptItems); result = ptRoot; break; } } } } return(result); }
public FpCell(FunctionItem f, int index, MainModel Model) : base(f.p[index], typeof(double)) { this.f = f; i = index; this.Model = Model; }
public int AddFunction(FunctionItem function, int PersonId) { int functionId = -1; int functionTypeId = GetFunctionTypeId(function.FunctionType.ToString()); string SQL = @"INSERT INTO [dbo].[Function] ([PriceStandard],[Time],[FuntionTypeId]) OUTPUT Inserted.FunctionId VALUES(@PriceStandard, @Time, @FuntionTypeId)"; using (SqlCommand sqlCommand = new SqlCommand(SQL, cnn)) { sqlCommand.Parameters.AddWithValue("@PriceStandard", function.PriceItems.Where(x => x.PriceItemType == PriceItemType.STANDARD).FirstOrDefault().Price); sqlCommand.Parameters.AddWithValue("@Time", function.Time); sqlCommand.Parameters.AddWithValue("@FuntionTypeId", functionTypeId); using (SqlDataReader reader = sqlCommand.ExecuteReader()) { if (reader.HasRows && reader.Read()) { functionId = Convert.ToInt32(reader["FunctionId"]); } reader.Close(); } } function.FunctionId = functionId; AddPersonFunction(functionId, PersonId); return(functionId); }
public void RequiredFunctionAdd(FunctionItem functionItem) { if (_requiredFunctions.Contains(functionItem)) { return; } _requiredFunctions.Add(functionItem); }
public void ProvidedAdd(FunctionItem functionItem) { if (_providedFunctions.Contains(functionItem)) { return; } _providedFunctions.Add(functionItem); }
private void Process( FunctionItem function, bool noCompile, bool noAssemblyValidation, string gitSha, string gitBranch, string buildConfiguration, bool forceBuild ) { switch (Path.GetExtension(function.Project).ToLowerInvariant()) { case "": // inline project; nothing to do break; case ".csproj": // set function language function.Language = "csharp"; // build C# function StartLogPerformance($"FunctionBuilder.Build() for {function.FullName}"); try { new FunctionBuilder( new FunctionBuilderDependencyProvider(_builder, Settings, _existingPackages), BuildEventsConfig ).Build( function, noCompile, noAssemblyValidation, gitSha, gitBranch, buildConfiguration, forceBuild ); } finally { StopLogPerformance(); } break; case ".js": ProcessJavascript( function, noCompile, noAssemblyValidation, gitSha, gitBranch, buildConfiguration ); break; default: LogError("could not determine the function language"); return; } }
private int BuildFunctionItemDict() { foreach (var kv in functionDict) { int code = kv.Key; var function = kv.Value; List <FieldItem> requestFields = new List <FieldItem>(); if (function.Param != null) { foreach (var paramitem in function.Param) { FieldItem fieldItem = new FieldItem { Name = paramitem.Name, Require = (paramitem.Require == "N") ? FieldRequireType.No : FieldRequireType.Yes }; var fieldType = paramitem.Type; SetFieldAttribute(paramitem.Type, ref fieldItem); requestFields.Add(fieldItem); } } List <FieldItem> responseField = new List <FieldItem>(); if (function.Response != null) { foreach (var item in function.Response) { var fieldItem = new FieldItem { Name = item.Name }; var fieldType = item.Type; SetFieldAttribute(item.Type, ref fieldItem); responseField.Add(fieldItem); } } FunctionItem functionItem = new FunctionItem { Code = code, RequestFields = requestFields, ResponseFields = responseField }; if (!functionItemDict.ContainsKey(code)) { functionItemDict.Add(code, functionItem); } } return(0); }
private void Process( FunctionItem function, bool noCompile, bool noAssemblyValidation, string gitSha, string gitBranch, string buildConfiguration ) { switch (Path.GetExtension(function.Project).ToLowerInvariant()) { case "": // inline project; nothing to do break; case ".csproj": ProcessDotNet( function, noCompile, noAssemblyValidation, gitSha, gitBranch, buildConfiguration ); break; case ".js": ProcessJavascript( function, noCompile, noAssemblyValidation, gitSha, gitBranch, buildConfiguration ); break; case ".sbt": ScalaPackager.ProcessScala( function, noCompile, noAssemblyValidation, gitSha, gitBranch, buildConfiguration, Settings.OutputDirectory, _existingPackages, GIT_INFO_FILE, _builder ); break; default: LogError("could not determine the function language"); return; } }
public ConnectionCode HeartBeat() { FunctionItem functionItem = ConfigManager.Instance.GetFunctionConfig().GetFunctionItem(FunctionCode.HeartBeat); if (functionItem == null || functionItem.RequestFields == null || functionItem.RequestFields.Count == 0) { return(ConnectionCode.ErrorLogin); } CT2BizMessage bizMessage = new CT2BizMessage(); //初始化 bizMessage.SetFunction((int)FunctionCode.HeartBeat); bizMessage.SetPacketType(CT2tag_def.REQUEST_PACKET); //业务包 CT2Packer packer = new CT2Packer(2); packer.BeginPack(); foreach (FieldItem item in functionItem.RequestFields) { packer.AddField(item.Name, item.Type, item.Width, item.Scale); } foreach (FieldItem item in functionItem.RequestFields) { switch (item.Name) { case "user_token": packer.AddStr(LoginManager.Instance.LoginUser.Token); break; default: break; } } packer.EndPack(); unsafe { bizMessage.SetContent(packer.GetPackBuf(), packer.GetPackLen()); } int retCode = _t2SDKWrap.SendSync(bizMessage); packer.Dispose(); bizMessage.Dispose(); if (retCode < 0) { logger.Error("心跳检测失败"); return(ConnectionCode.ErrorConn); } return(ConnectionCode.Success); }
private void ButtonRemove(object sender, RoutedEventArgs e) { if (selectedPerson != null && selectedFunction != null) { serviceData.DeleteFunction(selectedFunction.FunctionId); selectedPerson.FunctionTypes.Remove(selectedFunction); listFuntion.Items.Refresh(); selectedFunction = null; } }
public bool AddFunction(FunctionItem function, int PersonId) { int FunctionId = dataBase.AddFunction(function, PersonId); if (FunctionId == -1) { return(false); } return(true); }
public void SEARCH_BY_LEVEL_TEST() { var symbolsTable = new VectorSymbolTable(); var func = new FunctionItem() { Lexeme = "Func1" }; var proc = new ProcItem() { Lexeme = "Proc1" }; var item1 = new IdentificatorItem() { Lexeme = "x", Type = ItemType.Boolean, Level = 1 }; var item2 = new IdentificatorItem() { Lexeme = "a", Type = ItemType.Integer, Level = 2 }; var item3 = new IdentificatorItem() { Lexeme = "b", Type = ItemType.Integer, Level = 2 }; for (int i = 0; i < 5; i++) { symbolsTable.Insert(new IdentificatorItem() { Lexeme = "Item " + i, Type = ItemType.Boolean }); } symbolsTable.Insert(func); symbolsTable.Insert(item1); symbolsTable.Insert(proc); symbolsTable.Insert(item2); symbolsTable.Insert(item3); var result = symbolsTable.SearchByLevel(item1.Lexeme, 1); Assert.AreEqual(result, item1); result = symbolsTable.SearchByLevel(item2.Lexeme, 1); Assert.IsNull(result); result = symbolsTable.SearchByLevel(item1.Lexeme, 2); Assert.IsNull(result); result = symbolsTable.SearchByLevel(item2.Lexeme, 2); Assert.AreEqual(result, item2); result = symbolsTable.SearchByLevel(item3.Lexeme, 2); Assert.AreEqual(result, item3); }
private void ButtonAdd(object sender, RoutedEventArgs e) { if (selectedPerson != null && ComboBoxFuntionTyp.SelectedItem != null && !string.IsNullOrEmpty(TextBoxPrice.Text) && !string.IsNullOrEmpty(TextBoxTime.Text)) { FunctionItem item = new FunctionItem((FunctionType)ComboBoxFuntionTyp.SelectedItem, new PriceItem(PriceItemType.STANDARD, float.Parse(TextBoxPrice.Text, CultureInfo.InvariantCulture.NumberFormat)), new TimeSpan(0, Convert.ToInt32(TextBoxTime.Text), 0)); selectedPerson.FunctionTypes.Add(item); serviceData.AddFunction(item, selectedPerson.PersonId); listFuntion.Items.Refresh(); } }
public void INDEXER_TEST() { var collection = new SymbolTableItemCollection(); var item = new FunctionItem { Lexeme = "func" }; collection.Add(item); Assert.AreEqual(collection[0], item); }
private void OnDelete(object sender, RoutedEventArgs e) { if (lastObject != null && lastObject is FunctionItem) { FunctionItem item = lastObject as FunctionItem; if (FunctionItems.Contains(item)) { FunctionItems.Remove(item); } } DeleteButton.Visibility = Visibility.Collapsed; }
public FunctionForm(MainModel Model, FunctionItem old) { // // Required for Windows Form Designer support // InitializeComponent(); this.Model = Model; parForm = new ParForm(Model); oldItem = old; Reset(); }
public void ValidateFunction(FunctionItem function) { var index = 0; foreach (var source in function.Sources) { AtLocation($"{++index}", () => { switch (source) { case TopicSource topicSource: ValidateSourceParameter(topicSource.TopicName, "AWS::SNS::Topic"); break; case ScheduleSource scheduleSource: // no references to validate break; case RestApiSource apiGatewaySource: // no references to validate break; case S3Source s3Source: ValidateSourceParameter(s3Source.Bucket, "AWS::S3::Bucket"); break; case SqsSource sqsSource: ValidateSourceParameter(sqsSource.Queue, "AWS::SQS::Queue"); break; case AlexaSource alexaSource: break; case DynamoDBSource dynamoDBSource: ValidateSourceParameter(dynamoDBSource.DynamoDB, "AWS::DynamoDB::Table"); break; case KinesisSource kinesisSource: ValidateSourceParameter(kinesisSource.Kinesis, "AWS::Kinesis::Stream"); break; case CloudWatchEventSource cloudWatchRuleSource: break; } }); } }
public void SEARCH_ITEM_TEST() { var collection = new SymbolTableItemCollection(); var innerCollection = GetInternalCollection(collection); var item = new FunctionItem { Lexeme = "func" }; collection.Add(item); Assert.IsTrue(innerCollection.Count == 1); Assert.AreEqual(innerCollection[0], item); var searchResult = collection.Search(item.Lexeme); Assert.AreEqual(searchResult[0], item); }
public void Start(object sender, EventArgs e) { Stop(); f = ((FunctionItem)function.SelectedItem); X = double.NaN; Y = double.NaN; double.TryParse(x.Text, out X); double.TryParse(y.Text, out Y); if (f != null) { thread = new Thread(new ThreadStart(DoEval)); thread.Name = "Evaluation Thread"; Evaluate.Enabled = false; thread.Start(); //DoEvalDebug(); Thread.Sleep(0); } }
public void REMOVE_UNTIL_TEST() { var symbolsTable = new VectorSymbolTable(); var func1 = new FunctionItem() { Lexeme = "Func1" }; var func2 = new FunctionItem() { Lexeme = "Func2" }; symbolsTable.Insert(func1); for (int i = 0; i < 5; i++) { symbolsTable.Insert(new IdentificatorItem() { Lexeme = "Item " + i, Type = ItemType.Boolean, Level = 1 }); } symbolsTable.Insert(func2); for (int i = 5; i < 8; i++) { symbolsTable.Insert(new IdentificatorItem() { Lexeme = "Item " + i, Type = ItemType.Boolean, Level = 2 }); } symbolsTable.RemoveUntil(2); Assert.IsTrue(symbolsTable.Items.Contains(func1)); Assert.IsTrue(symbolsTable.Items.Contains(func2)); var lexemes = symbolsTable.Items.Select(item => item.Lexeme); for (int i = 5; i < 8; i++) { Assert.IsFalse(lexemes.Contains("Item " + i)); } }
public void Reset(FunctionItem item) { this.item = item; grid.ColumnsCount = 2; grid.RowsCount = item.p.Length + 1; grid[0, 0] = new SourceGrid2.Cells.Real.Header("n"); grid[0, 1] = new SourceGrid2.Cells.Real.ColumnHeader("p[n]"); for (int r = 0; r < item.p.Length; r++) { grid[r + 1, 0] = new SourceGrid2.Cells.Real.RowHeader(r); grid[r + 1, 1] = new SourceGrid2.Cells.Real.Cell(item.p[r], typeof(double)); } grid.Columns[0].AutoSizeMode = SourceGrid2.AutoSizeMode.MinimumSize; grid.Columns[1].AutoSizeMode = SourceGrid2.AutoSizeMode.MinimumSize; grid.AutoSize(); }
public override void OnClick(SourceGrid2.PositionEventArgs e) { base.OnClick(e); ItemsGrid g = (ItemsGrid)e.Grid; ParForm f = (g[e.Position.Row, 2].Tag) as ParForm; FunctionItem x = (FunctionItem)(g[e.Position.Row, 0].Tag); if (f != null) { if (f.IsDisposed) { f = new ParForm(((ItemsGrid)e.Grid).MainModel); f.Reset(x); } f.Show(); f.BringToFront(); } }
public SourceForm(GraphControl graph, FunctionItem old, MainForm mainform) { // // Required for Windows Form Designer support // InitializeComponent(); this.graph = graph; parForm = new ParForm(); paritem = new FunctionItem(); oldItem = old; this.mainform = mainform; lineStyle.DropDownStyle = ComboBoxStyle.DropDownList; for (DashStyle s = DashStyle.Solid; s < DashStyle.Custom; s++) { lineStyle.Items.Add(s.ToString()); } lineStyle.SelectedIndex = 0; }
public void Reset() { function.Items.Clear(); foreach (FunctionItem x in FunctionItem.FunctionItems(Model.Items)) { function.Items.Add(x); } function.Invalidate(); if (function.Items.Count > 0) { function.SelectedIndex = 0; Evaluate.Enabled = true; } else { function.SelectedItem = null; Evaluate.Enabled = false; } }
public static FunctionItem CreateFunctionItem(string name, int? parentItemId, int sort, bool isLeaf, bool isButtion, string naviUrl, string description = null, bool isValid = true, string imageUrl = null) { var functionItem = new FunctionItem { Name = name, ParentItemId = parentItemId, IsLeaf = isLeaf, IsButton = isButtion, NaviUrl = naviUrl, Description = description, IsValid = isValid, ImageUrl = imageUrl, Sort = sort, }; functionItem.GenerateNewIdentity(); return functionItem; }
public void ADD_NEW_ITEMS_TEST() { var collection = new SymbolTableItemCollection(); var internalCollection = GetInternalCollection(collection); var item1 = new FunctionItem { Lexeme = "func" }; var item2 = new ProcItem { Lexeme = "proc" }; collection.Add(item1); collection.Add(item2); Assert.IsTrue(internalCollection.Count == 2); Assert.IsTrue(collection.Count == 2); Assert.AreEqual(internalCollection[0], item1); Assert.AreEqual(internalCollection[1], item2); }
public static string Process( FunctionItem function, bool skipCompile, bool noAssemblyValidation, string gitSha, string gitBranch, string buildConfiguration, bool showOutput ) { function.Language = "scala"; var projectDirectory = Path.GetDirectoryName(function.Project); // check if we need a default handler if (function.Function.Handler == null) { throw new Exception("The function handler cannot be empty for Scala functions."); } // compile function and create assembly if (!skipCompile) { ProcessLauncher.Execute( "sbt", new[] { "assembly" }, projectDirectory, showOutput ); } // check if we need to set a default runtime if (function.Function.Runtime == null) { function.Function.Runtime = "java8"; } // check if the project zip file was created var scalaOutputJar = Path.Combine(projectDirectory, "target", "scala-2.12", "app.jar"); return(scalaOutputJar); }
//When the modal is created public override void Init(object initData) { FunctionItem item = (FunctionItem)initData; switch (item.Key) { case 1: //Connectivity ShowInternetConnectivityInfo(); break; case 2: //Device Info ShowDeviceInfo(); break; case 3: //Screen Info ShowDeviceScreenInfo(); break; } }
private void ProcessJavascript( FunctionItem function, bool noCompile, bool noAssemblyValidation, string gitSha, string gitBranch, string buildConfiguration ) { if (noCompile) { return; } Console.WriteLine($"=> Building function {Settings.InfoColor}{function.Name}{Settings.ResetColor} [{function.Function.Runtime}]"); var buildFolder = Path.GetDirectoryName(function.Project); var hash = Directory.GetFiles(buildFolder, "*", SearchOption.AllDirectories).ComputeHashForFiles(file => Path.GetRelativePath(buildFolder, file)); var package = Path.Combine(Settings.OutputDirectory, $"function_{_builder.FullName}_{function.LogicalId}_{hash}.zip"); _existingPackages.Remove(package); CreatePackage(package, gitSha, gitBranch, buildFolder); _builder.AddArtifact($"{function.FullName}::PackageName", package); }
private FunctionItem[] _GetSon(FunctionItem _parentFunction) { List<FunctionItem> ltSon = new List<FunctionItem>(); foreach (FunctionItem son in AllFunctions) { if (son.ParentId == _parentFunction.Id) { ltSon.Add(son); ltSon.AddRange(_GetSon(son)); } } return ltSon.ToArray(); }