Example #1
0
        public object UserList(int flowNodeId = 0, int flowDataId = 0, int flowId = 0, int flowStep = 1)
        {
            if (flowNodeId == 0 && flowId == 0)
            {
                throw new ArgumentException("缺少参数flowNodeId或FlowId");
            }

            FlowNode flowNode = null;
            FlowData flowData = null;

            if (flowNodeId > 0)
            {
                flowNode = Core.FlowNodeManager.Get(flowNodeId);
            }
            else if (flowId > 0)
            {
                var flow = Core.FlowManager.Get(flowId);
                flowNode = flow.GetStep(flowStep);
            }
            if (flowDataId > 0)
            {
                flowData = Core.FlowDataManager.Get(flowDataId);
            }
            return(Core.FlowNodeManager.GetUserList(flowNode, flowData, CurrentUser).Select(e => new UserViewModel(e)));
        }
Example #2
0
        public bool CanSubmit(FlowData flowData, int userId)
        {
            if (flowData.Completed)
            {
                return(false);
            }

            var flowNodeData = flowData.GetLastNodeData();

            if (flowNodeData.FlowNode.FreeFlowId == 0)
            {
                return(false);
            }

            var freeFlowData = flowNodeData.FreeFlowData;

            if (freeFlowData == null)
            {
                //如果用户是该主流程的处理人,则可以submit
                if (userId == flowNodeData.UserId)
                {
                    return(true);
                }
            }
            else
            {
                if (freeFlowData.Completed)
                {
                    return(flowNodeData.UserId == userId);
                }
                //就算提交过,也可以转发给其他人
                return(freeFlowData.Nodes.Any(e => e.UserId == userId));
            }
            return(false);
        }
Example #3
0
        public IEnumerable <User> GetUserList(FlowNode node, FlowData flowData = null, User currentUser = null)
        {
            var parameter = new UserParameter
            {
                UserIds  = node?.UserIds,
                TitleIds = node?.JobTitleIds,
            };

            if (node != null)
            {
                if (node.LimitMode == DepartmentLimitMode.Assign)
                {
                    parameter.DepartmentIds = node.DepartmentIds;
                }
                else if (node.LimitMode == DepartmentLimitMode.Poster)
                {
                    if (flowData != null)
                    {
                        var firstNodeData = flowData.GetFirstNodeData();
                        var user          = Core.UserManager.GetModel(firstNodeData.UserId);
                        parameter.DepartmentIds = user.DepartmentIds;
                    }
                    else if (currentUser != null)
                    {
                        parameter.DepartmentIds = currentUser.DepartmentIds;
                    }
                }
                else if (node.LimitMode == DepartmentLimitMode.Self)
                {
                    parameter.DepartmentIds = currentUser.DepartmentIds;
                }
            }
            return(Core.UserManager.GetList(parameter));
        }
Example #4
0
        private async Task <Result> DeleteConfigsWithProcessors(string flowName, IEnumerable <IFlowDeploymentProcessor> processors)
        {
            Ensure.NotNull(flowName, "flowName");

            // Ensure no other generation process is going with the same flow with generation locks per flows
            var generationLock = this.GenerationLocks.GetLock(flowName);

            if (generationLock == null)
            {
                return(new FailedResult($"config for flow '{flowName}' is being generated, please try again later."));
            }

            using (generationLock)
            {
                using (Logger.BeginScope(("datax/runtimeConfigGeneration/flowConfigsDelete", new Dictionary <string, string>()
                {
                    { "flowName", flowName }
                })))
                {
                    // Call Storage client to get back the associated flow config
                    var config = await FlowData.GetByName(flowName);

                    Ensure.NotNull(config, "config", $"could not find flow for flow name:'{flowName}'");

                    // Initialize a deploy session
                    var session = new FlowDeploymentSession(config);

                    // Run through a chain of processors
                    await processors.ChainTask(p => p.Delete(session));

                    // Return result
                    return(session.Result);
                }
            }
        }
Example #5
0
        public FieldMapData GetMapData(int flow, int level)
        {
            FlowData  flowData  = flowsInitializer.Data.Flows[flow];
            LevelData levelData = flowData.Levels[level];

            FieldMapData data = mapDataFactory.Create(levelData);

            float r = Random.value;

            if (data.HorizontalFields.GetLength(0) == data.VerticalFields.GetLength(1))
            {
                if (r < 0.25f)
                {
                    data.ReflectByDiagonal();
                }
                else if (r < 0.5f)
                {
                    data.ReflectByContrdiagonal();
                }
                else if (r < 0.75f)
                {
                    data.ReflectByCenter();
                }
            }
            else if (r < 0.5f)
            {
                data.ReflectByCenter();
            }

            return(data);
        }
Example #6
0
        public FlowNodeData CreateNextNodeData(FlowData flowData, int toUserId, int extendId = 0)
        {
            var lastNodeData = flowData.GetLastNodeData();
            var flowNode     = flowData.Flow.GetNextStep(lastNodeData == null ? 0 : lastNodeData.FlowNodeId);

            return(CreateNodeData(flowData.ID, flowNode, toUserId, extendId));
        }
        protected override void Init()
        {
            var flow = this.flow;

                        #if UNITY_MOBILE
            if (this.flowMobileOnly != null)
            {
                flow = this.flowMobileOnly;
            }
                        #endif
                        #if UNITY_STANDALONE
            if (this.flowStandaloneOnly != null)
            {
                flow = this.flowStandaloneOnly;
            }
                        #endif

            FlowSystem.SetData(flow);

            this.defaults.AddRange(flow.GetDefaultScreens());
            this.windows.AddRange(flow.GetAllScreens());

            base.Init();

            this.OnStart();
        }
    void Compute(ComputeBuffer buffer, int count)
    {
        FlowData[] flowData = new FlowData[count];
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                int index = i * width + j;
                flowData[index].AmountIn = _flowGridIn[i, j];
            }
        }

        buffer.SetData(flowData);

        flowCompute.SetBuffer(0, "flowData", buffer);

        int threadGroupsX = Mathf.CeilToInt(count / (float)ThreadGroupSize);
        int threadGroupsY = Mathf.CeilToInt(threadGroupsX / (float)ThreadGroupSize);

        flowCompute.Dispatch(0, threadGroupsX, threadGroupsY, 1);

        buffer.GetData(flowData);

        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                int index = i * width + j;
                _flowGridIn[i, j] = flowData[index].AmountOut;
            }
        }

        Debug.Log($"threadGroups [{threadGroupsX}, {threadGroupsY}]");
    }
        public void AddFlowInfo(FlowData flowData)
        {
            if (_projectsData.TryGetValue(flowData.ProjectId, out var project))
            {
                if (!project.ContainsKey(flowData.Codename))
                {
                    project.Add(flowData.Codename, flowData.Url);
                }
                else
                {
                    project[flowData.Codename] = flowData.Url;
                }

                _projectsData[flowData.ProjectId] = project;
            }
            else
            {
                _projectsData.Add(flowData.ProjectId, new Dictionary <string, string>
                {
                    {
                        flowData.Codename,
                        flowData.Url
                    }
                });
            }
        }
        private string GenerateValidFlowName(string displayName)
        {
            if (string.IsNullOrWhiteSpace(displayName))
            {
                displayName = Guid.NewGuid().ToString().Trim(new[] { '-', '{', '}' });
            }

            // Ensure name contains only Alpha-numeric chars.
            string flowName = Regex.Replace(displayName, "[^A-Za-z0-9]", "").ToLower();

            // Check to make sure the flowName doesn't already exist.
            // The flowName needs to be unique since this name is used to create Azure resources.
            var existingNames = FlowData.GetAll().Result.Where(x => x.Name.Equals(flowName, StringComparison.OrdinalIgnoreCase)).Select(y => y.Name.ToLower()).ToList();

            if (existingNames.Count != 0)
            {
                int index       = 1;
                var newFlowName = flowName.ToLower() + index.ToString();
                while (existingNames.Contains(newFlowName))
                {
                    index       = index++;
                    newFlowName = flowName.ToLower() + index.ToString();
                }
                flowName = newFlowName;
            }

            return(flowName);
        }
Example #11
0
        public object Model(int id = 0, int infoId = 0)
        {
            if (id == 0 && infoId == 0)
            {
                throw new Exception("缺少参数ID或InfoID");
            }
            FlowData flowData = null;

            if (id > 0)
            {
                flowData = Core.FlowDataManager.Get(id);
            }
            else if (infoId > 0)
            {
                var info = Core.FormInfoManager.GetModel(infoId);
                flowData = info.FlowData;
            }
            if (flowData == null)
            {
                return(BadRequest("参数不正确,没有获取到流程数据"));
            }
            var flowNodeData = flowData.GetUserLastNodeData(Identity.ID);
            var lastNodeData = flowData.GetLastNodeData();

            return(new
            {
                flowData,
                flowNodeData = lastNodeData,
                freeFlowNodeData = lastNodeData.GetLastFreeNodeData(Identity.ID),
                canBack = Core.FlowDataManager.CanBack(flowData),
                canSubmitFlow = Core.FlowDataManager.CanSubmit(flowData, flowNodeData),
                canComplete = Core.FlowDataManager.CanComplete(flowData.Flow, lastNodeData),
                canSubmitFreeFlow = Core.FreeFlowDataManager.CanSubmit(flowData, Identity.ID),
            });
        }
Example #12
0
        public IHttpActionResult SaveTempData(FlowData data)
        {
            var instanceId = Convert.ToInt32(data.InstanceId);
            var value      = data.BusinessData;
            var result     = _instance.ModifyTempData(instanceId, value);

            return(Ok(result));
        }
        public void Init()
        {
            _pipeline = new Mock <IPipelineInternal>();
            _logger   = new Mock <ILogger <FlowData> >();
            var evidenceLogger = new Mock <ILogger <Evidence> >();

            _flowData = new FlowData(_logger.Object, _pipeline.Object,
                                     new Evidence(evidenceLogger.Object));
        }
Example #14
0
        public void AddFlow(string text, string color, int x, int y)
        {
            FlowData fw = new FlowData();

            fw.Text  = text;
            fw.Color = color;
            fw.X     = x;
            fw.Y     = y;
            fw.Time  = 16 + text.Length / 2;
            flows.Add(fw);
        }
Example #15
0
        public static void Run(FlowData data)
        {
            UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", data.version, VersionInfo.BUNDLE_VERSION), 0f);
            var type = data.GetType();

            while (data.version < VersionInfo.BUNDLE_VERSION)
            {
                var nextVersion = data.version + 1;

                try {
                    // Try to find upgrade method
                    var methodName = "UpgradeTo" + nextVersion.ToSmallWithoutTypeString();
                    var methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public);
                    if (methodInfo != null)
                    {
                        var result = (bool)methodInfo.Invoke(data, null);
                        if (result == true)
                        {
                            // Need to recompile
                            var prevData = FlowSystem.GetData();
                            FlowSystem.SetData(data);
                            UnityEngine.UI.Windows.Plugins.FlowCompiler.CompilerSystem.currentNamespace = data.namespaceName;
                            var path = UnityEditor.AssetDatabase.GetAssetPath(data);
                            UnityEngine.UI.Windows.Plugins.FlowCompiler.CompilerSystem.Generate(path, recompile: true);
                            FlowSystem.SetData(prevData);
                        }

                        if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                        {
                            UnityEngine.Debug.Log("[UPGRADE] Invoked: `" + methodName + "`, version " + nextVersion);
                        }
                    }
                    else
                    {
                        if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                        {
                            UnityEngine.Debug.Log("[UPGRADE] Method `" + methodName + "` was not found: version " + nextVersion + " skipped");
                        }
                    }

                    UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", data.version, nextVersion), 0.5f);
                } catch (UnityException) {
                } finally {
                    UnityEditor.EditorUtility.ClearProgressBar();
                }

                data.version = nextVersion;
                UnityEditor.EditorUtility.SetDirty(data);
            }

            UnityEditor.EditorUtility.DisplayProgressBar("Upgrading", string.Format("Migrating from {0} to {1}", data.version, VersionInfo.BUNDLE_VERSION), 1f);
            UnityEditor.EditorUtility.ClearProgressBar();
        }
Example #16
0
 public FlowNodeData SubmitToUser(FlowData flowData, int toUserId, int flowNodeId = 0)
 {
     if (flowNodeId > 0)
     {
         var flowNode = Core.FlowNodeManager.Get(flowNodeId);
         return(Core.FlowNodeDataManager.CreateNodeData(flowData.ID, flowNode, toUserId));
     }
     else
     {
         return(Core.FlowNodeDataManager.CreateNextNodeData(flowData, toUserId));
     }
 }
Example #17
0
 FlowData Compare(FlowData best, FlowData candidate)
 {
     if (best == null || candidate.MessagesInFlight < best.MessagesInFlight)
     {
         return(candidate);
     }
     if (candidate.MessagesInFlight == best.MessagesInFlight)
     {
         return(random.Next(2) == 0 ? best : candidate);
     }
     return(best);
 }
Example #18
0
        public bool CanSubmit(FlowData flowData, FlowNodeData flowNodeData)
        {
            if (flowData.Completed)
            {
                return(false);
            }
            if (flowData.Nodes == null || flowData.Nodes.Count == 0)
            {
                return(true);
            }

            return(flowNodeData != null && Core.FlowNodeDataManager.CanSubmit(flowNodeData));
        }
Example #19
0
 public void Setup(int id, FlowData data)
 {
                 #if UNITY_EDITOR
     if (id >= 0)
     {
         this.windowId = id;
     }
     if (this.audio == null)
     {
         this.audio = new Audio.Window();
     }
     this.audio.flowData = data;
                 #endif
 }
Example #20
0
        public int Save(FlowData flowData)
        {
            var entity = DB.FlowDatas.FirstOrDefault(e => e.ID == flowData.ID);

            if (entity == null)
            {
                DB.FlowDatas.Add(flowData);
            }
            else
            {
                DB.Entry(entity).CurrentValues.SetValues(flowData);
            }
            DB.SaveChanges();
            return(flowData.ID);
        }
    public string FindShortestQueue(string[] receiverAddresses)
    {
        FlowData best = null;

        foreach (var address in receiverAddresses)
        {
            // This instance is not yet tracked, so assume it has shortest queue.
            if (!data.TryGetValue(address, out var candidate))
            {
                return(address);
            }
            best = Compare(best, candidate);
        }
        return(best.Address);
    }
Example #22
0
        /// <summary>
        /// 是否可以退回
        /// </summary>
        public bool CanBack(FlowData flowData)
        {
            if (flowData.Nodes.Count == 0)
            {
                return(false);
            }
            if (flowData.Nodes.Count == 1 && flowData.Nodes[0].Submited)
            {
                return(false);
            }
            var lastNodeData = flowData.GetLastNodeData();
            var lastNode     = flowData.Flow.GetFirstNode();

            return(lastNodeData.FlowNodeId != lastNode.ID);
        }
Example #23
0
        public bool CanCancel(FlowData flowData, FlowNodeData flowNodeData)
        {
            if (flowNodeData == null || !flowNodeData.Submited)
            {
                return(false);
            }
            //var childNodeData = flowData.Nodes.OrderBy(e => e.ID).FirstOrDefault(e => e.ParentId == flowNodeData.ID);
            //if (childNodeData != null)
            //{
            //    return false;
            //}
            var nextNodeData = flowData.GetNextNodeData(flowNodeData.ID);

            //否则判断当前步骤的下一步是否已经提交,如果提交,则不能撤回
            return(nextNodeData == null || (!nextNodeData.HasChanged() && !flowData.Nodes.Any(e => e.ParentId == nextNodeData.ID)));
        }
Example #24
0
        public FlowData GetBaseFlow()
        {
            FlowData flow = null;

            for (int i = 0; i < this.flow.Length; ++i)
            {
                var item = this.flow[i];
                if (item.IsValid() == false)
                {
                    continue;
                }

                flow = item.flow;
            }

            return(flow);
        }
Example #25
0
        /// <summary>
        /// Save a flow with the gui input
        /// </summary>
        /// <param name="flowConfig"></param>
        /// <returns></returns>
        public async Task <Result> SaveFlowConfig(FlowGuiConfig flowConfig)
        {
            var config = await ConfigBuilder.Build(flowConfig);

            var existingFlow = await FlowData.GetByName(config.Name);

            Result result = null;

            if (existingFlow != null)
            {
                existingFlow.Gui = config.Gui;
                existingFlow.CommonProcessor.Template            = config.CommonProcessor.Template;
                existingFlow.CommonProcessor.SparkJobTemplateRef = config.CommonProcessor.SparkJobTemplateRef;
                existingFlow.DisplayName = config.DisplayName;
                config = existingFlow;
                result = await FlowData.UpdateGuiForFlow(config.Name, config.Gui);

                if (result.IsSuccess)
                {
                    result = await FlowData.UpdateCommonProcessorForFlow(config.Name, config.CommonProcessor);
                }
            }
            else
            {
                result = await this.FlowData.Upsert(config);
            }

            if (result.IsSuccess)
            {
                // pass the generated config back with the result
                var properties = new Dictionary <string, object>()
                {
                    { FlowConfigPropertyName, config }
                };

                if (result.Properties != null)
                {
                    result.Properties.AppendDictionary(properties);
                }
                else
                {
                    result.Properties = properties;
                }
            }
            return(result);
        }
Example #26
0
        private FlowData CreateFlowData(int flowId, FormInfo info)
        {
            var entity = DB.FlowDatas.FirstOrDefault(e => e.InfoId == info.ID && e.FormId == info.FormId && e.FlowId == flowId);

            if (entity == null)
            {
                entity = new FlowData
                {
                    FlowId = flowId,
                    InfoId = info.ID,
                    FormId = info.FormId,
                };
                DB.FlowDatas.Add(entity);
                DB.SaveChanges();
            }
            return(entity);
        }
Example #27
0
        /// <summary>
        /// 控制流程实例的流转
        /// </summary>
        /// qiy     16.04.29
        /// yaoy    16.07.27 移除流程引擎中开始流程方法
        /// <param name="data">流程数据</param>
        /// <returns></returns>
        public bool Process(FlowData data)
        {
            var          _action = new Action();
            InstanceInfo instance;

            ActionInfo action = _action.Get(data.ActionId);

            instance = _instance.Get(data.InstanceId.Value);
            IFindUser finduser = FindUser.CreateStrategy(action);

            instance.CurrentNode = action.Transfer;
            instance.CurrentUser = finduser.FindUser(data);
            instance.ProcessTime = DateTime.Now;
            instance.ProcessUser = User.User.CurrentUserId;

            if (action.Type == ActionInfo.TypeEnum.完成)
            {
                instance.Status = InstanceInfo.StatusEnum.完成;
            }
            else if (action.Type == ActionInfo.TypeEnum.终止)
            {
                instance.Status = InstanceInfo.StatusEnum.终止;
            }

            if (instance.Status != InstanceInfo.StatusEnum.正常)
            {
                instance.EndTime = DateTime.Now;
            }

            Log _log = new Log();

            _log.Add(new LogInfo
            {
                InstanceId  = instance.InstanceId,
                NodeId      = action.NodeId,
                ActionId    = action.ActionId,
                ProcessUser = instance.ProcessUser,
                ProcessTime = instance.ProcessTime,
                InOpinion   = data.InOpinion,
                ExOpinion   = data.ExOpinion
            });

            return(_instance.Modify(instance));
        }
Example #28
0
        public bool CanComplete(FlowData flowData, User user)
        {
            if (flowData.Completed)
            {
                return(false);
            }

            var lastNodeData = flowData.GetLastNodeData();

            if (lastNodeData.FlowNode.FreeFlowId == 0)
            {
                return(false);
            }
            if (lastNodeData.FreeFlowData == null || lastNodeData.FreeFlowData.Completed)
            {
                return(false);
            }
            return(lastNodeData.FlowNode.FreeFlow.IsCompleteUser(user));
        }
        /// <summary>
        /// Disable a batch job in the config
        /// </summary>
        /// <returns></returns>
        private async Task <Result> DisableBatchConfig(FlowConfig config, int index)
        {
            var existingFlow = await FlowData.GetByName(config.Name).ConfigureAwait(false);

            Result result = null;

            if (existingFlow != null)
            {
                var gui = config.GetGuiConfig();

                var batch = gui.BatchList[index];
                batch.Disabled = true;

                config.Gui = JObject.FromObject(gui);
                result     = await FlowData.UpdateGuiForFlow(config.Name, config.Gui).ConfigureAwait(false);
            }

            return(result);
        }
        /// <summary>
        /// Update the last processed time for a batch job in the config
        /// </summary>
        /// <returns></returns>
        private async Task <Result> UpdateLastProcessedTime(FlowConfig config, int index, long value)
        {
            var existingFlow = await FlowData.GetByName(config.Name).ConfigureAwait(false);

            Result result = null;

            if (existingFlow != null)
            {
                var gui = config.GetGuiConfig();

                var batch = gui.BatchList[index];
                batch.Properties.LastProcessedTime = value.ToString(CultureInfo.InvariantCulture);

                config.Gui = JObject.FromObject(gui);
                result     = await FlowData.UpdateGuiForFlow(config.Name, config.Gui).ConfigureAwait(false);
            }

            return(result);
        }