// POST api/worktask public resultInfo AddWorkTask([FromBody] workTaskDataInfo value) { resultInfo _ResultInfo = new resultInfo(); _ResultInfo.message = "任务添加失败"; try { if (DBManager.IsExistWorkTask(value.workItemID)) { _ResultInfo.code = 1; _ResultInfo.message = "此任务已存在"; } else { if (DBManager.InsertIntoWorkTask(value)) { _ResultInfo.code = 0; _ResultInfo.message = "任务添加成功,任务ID:" + value.workItemID; } else { _ResultInfo.code = -1; _ResultInfo.message = "任务添加失败"; } } } catch (Exception ex) { _ResultInfo.code = -1; _ResultInfo.message = "添加失败:" + ex.Message; ClassFunction.WriteLocalLog(ex.Message); } return(_ResultInfo); }
public taskProgress QueryWorkTask(string id) { //整个生产任务的状态,查询错误-100,未找到-1,未开始0、进行中1、已终止2、已完成3 taskProgress _TaskProgress = new taskProgress(); try { workTaskDataInfo _WorkTaskDataInfo = DBManager.GetWorkTaskByWorkItemID(id); if (_WorkTaskDataInfo != null) { switch (_WorkTaskDataInfo.taskStatus) { case 0: _TaskProgress.name = "未开始"; _TaskProgress.status = 0; break; case 1: _TaskProgress.name = "未发送"; _TaskProgress.status = 1; break; case 2: _TaskProgress.name = "发送完成"; _TaskProgress.status = 2; break; case 3: _TaskProgress.name = "制作中"; _TaskProgress.status = 3; break; default: _TaskProgress.name = "未开始"; _TaskProgress.status = 0; break; } } else { _TaskProgress.name = "未找到制作任务"; _TaskProgress.status = -1; } } catch (Exception ex) { _TaskProgress.name = "查询失败:" + ex.Message; _TaskProgress.status = -100; ClassFunction.WriteLocalLog(ex.Message); } return(_TaskProgress); }
public bool Contains(string Input) { foreach (ClassFunction item in Operators) { if (Input.Equals(item.Name, StringComparison.OrdinalIgnoreCase)) { Type extention = item.GetType(); Function = (ClassFunction)Activator.CreateInstance(extention); return(true); } } return(false); }
public LocationRouterPropertyBasedBuilder AddLocationCalculator <TEntity, TOutput>(Expression <Func <TEntity, TOutput> > func, object keyValue, ILocationCalculator calculator) { if (!_locationCalculators.ContainsKey(keyValue)) { var cF = new ClassFunction(); cF.SetFunc(func.Compile()); _typeFinders.Add(typeof(TEntity), cF); _locationCalculators.Add(keyValue, calculator); } else { throw new Exception($"Key already registered : {keyValue}"); } return(this); }
public List <IElement> Analyze(string Input) { List <IElement> elements = new List <IElement>(); FactoryOperators operators = new FactoryOperators(); FactoryFunctions functions = new FactoryFunctions(); int Count = 0; while (Input != "" & Count != 1000) { char first = char.Parse(Input.Substring(0, 1)); //first element from string if (char.IsDigit(first)) // number { double a = GetVal(Input, @"\-{0,1}\d{1,}[\.\,]{0,1}\d{0,}"); elements.Add(new ValueElement(a)); Input = Input.Remove(0, a.ToString().Length); } else if (first == 'x' | first == 'X') // variable { elements.Add(new VariableElement()); Input = Input.Remove(0, 1); } else if (first == '(') // open bracket { if (Input.Length == 1) { throw new Exception("Error in analyze. Lenght line cannot be 1"); } KeyValuePair <string, double> tmp = TryToGetNegative(Input); if (!double.IsNaN(tmp.Value)) { elements.Add(new ValueElement(tmp.Value)); Input = Input.Remove(0, tmp.Key.Length); } else { elements.Add(new OpenBracket()); Input = Input.Remove(0, 1); } } else if (first == ')') // close bracket { elements.Add(new CloseBracket()); Input = Input.Remove(0, 1); } else if (char.IsLetter(first)) { string NameFunction = ""; string tmp = ""; int brackets = 0; do // get function name { NameFunction += tmp; if (Input.Length == 0) { throw new Exception("Error in Analyze. Incoming string ended"); } tmp = Input.Substring(0, 1); //get first element Input = Input.Remove(0, 1); // remove first element from input } while (tmp != "("); brackets++; string Context = ""; do // get context function { Context += tmp; if (Input.Length == 0) { throw new Exception("Error in Analyze. Incoming string ended"); } tmp = Input.Substring(0, 1); Input = Input.Remove(0, 1); if (tmp == "(") { brackets++; } if (tmp == ")") { brackets--; } } while (tmp != ")" | brackets > 0); Context = AlignBrackets(Context); if (functions.Contains(NameFunction)) { ClassFunction element = functions.Function; element.Context = Analyze(Context); elements.Add(element); } else { throw new Exception($"Error in Analyze. Unexpected value '{NameFunction}'"); } } else if (operators.Contains(first)) { elements.Add(operators.Operator); Input = Input.Remove(0, operators.Operator.Name.Length); } else { throw new Exception($"Error in Analyze. Unexpected item '{first.ToString()}'"); } Count++; } return(elements); }
// POST api/user public resultInfo UpdateUser([FromBody] userInfoUpdate value) { resultInfo _ResultInfo = new resultInfo(); StringBuilder msg = new StringBuilder(); try { if (value != null && value.updateUserInfo != null && value.updateUserInfo.Length > 0) { foreach (userInfo item in value.updateUserInfo) { if (item.CRUD == "D")//删除用户 { string userId = DBManager.GetUserID(item.userID); if (userId == null || userId.Length <= 0) { // _ResultInfo.message = "未找到用户:" + item.userID; msg.AppendLine("未找到用户:" + item.userID); _ResultInfo.code = -1; break; } else { if (DBManager.DeleteUserByID(userId)) { // _ResultInfo.message = "用户:" + item.userID + " 删除成功!"; msg.AppendLine("用户:" + item.userID + " 删除成功!"); _ResultInfo.code = 0; LogDataBaseManager.SendUserLogByUDP(Guid.Empty.ToString(), value.updateUserID, value.updateUserName, value.updateIP, "", value.updateUserName + "删除用户:" + item.userID + "成功!", Guid.Empty.ToString(), LogDatabaseDll.LogDatabaseWS.E_Operation.Delete, LogDatabaseDll.LogDatabaseWS.E_System.XStudio); } else { //_ResultInfo.message = "用户:" + item.userID + " 删除失败!"; msg.AppendLine("用户:" + item.userID + " 删除失败!"); _ResultInfo.code = -1; break; } } } else if (item.CRUD == "U" || item.CRUD == "C") { string pass = com.cdv.nova.util.PasswordHelper.decodePassword(item.salt, item.userID, item.password); if (DBManager.UpdateUserInfo(item.userID, pass, item.userName)) { //_ResultInfo.message = "用户:" + item.userID + " 更新成功!"; msg.AppendLine("用户:" + item.userID + " 更新成功!"); _ResultInfo.code = 0; LogDataBaseManager.SendUserLogByUDP(Guid.Empty.ToString(), value.updateUserID, value.updateUserName, value.updateIP, "", value.updateUserName + "更新用户:" + item.userID + " 成功!", Guid.Empty.ToString(), LogDatabaseDll.LogDatabaseWS.E_Operation.Delete, LogDatabaseDll.LogDatabaseWS.E_System.XStudio); } else { //_ResultInfo.message = "用户:" + item.userID + " 更新失败!"; msg.AppendLine("用户:" + item.userID + " 更新失败!"); _ResultInfo.code = -1; break; } } } } else { // _ResultInfo.message = "需要更新的用户信息不能为空!"; msg.AppendLine("需要更新的用户信息不能为空!"); _ResultInfo.code = -1; } } catch (Exception ex) { _ResultInfo.code = -1; // _ResultInfo.message = "用户信息更新失败:" + ex.Message; msg.AppendLine("用户信息更新失败:" + ex.Message); ClassFunction.WriteLocalLog(ex.Message); } _ResultInfo.message = msg.ToString(); return(_ResultInfo); }
public List <IElement> GetNotation(List <IElement> elements) { List <IElement> RList = new List <IElement>(); Stack <IElement> stackElements = new Stack <IElement>(); int brackets = 0; foreach (IElement element in elements) { if (element.Type == ElementType.Value) { RList.Add(element); } else if (element.Type == ElementType.Bracket) { if (element.Name == "(") { brackets++; stackElements.Push(element); } else { if (brackets < 1) { throw new Exception("Bracket not found.Please check brackets and try again"); } else { while (stackElements.Peek().Name != "(") { RList.Add(stackElements.Pop()); } stackElements.Pop(); } } } else if (element.Type == ElementType.Variable) { RList.Add(element); } else if (element.Type == ElementType.Function) { ClassFunction function = (ClassFunction)element; foreach (IElement Item in function.Context) { if (Item.Type == ElementType.Function) { Item.Context = GetNotation(Item.Context); } } function.Context = GetNotation(function.Context); RList.Add(function); } else if (element.Type == ElementType.Operator) { if (stackElements.Count != 0) { IElement last = stackElements.Peek(); if (last.Priority < element.Priority) { stackElements.Push(element); } else { RList.Add(stackElements.Pop()); stackElements.Push(element); } } else { stackElements.Push(element); } } } while (stackElements.Count > 0) { RList.Add(stackElements.Pop()); } return(RList); }