public override int Update(FormM form, DFDictionary entity, ref string message)
        {
            var currentUser = Util.GetCurrentUser();

            if (string.IsNullOrWhiteSpace(entity["UserId"]))
            {
                throw new ArgumentNullException("UserId");
            }

            var list = JsonSerializeHelper.DeserializeObject <List <VM_WF_M_USERDEPT> >(Base64StringHelper.ConvertFromBase64String(entity[DFPub.GetKey_GridHiddenValue("grid1")]));

            if (list == null)
            {
                throw new Exception("Invalid grid data");
            }

            WF_M_USERDEPTLoader.DeleteByUserId(entity["UserId"]);
            list.Where(a => a.selected).ToList().ForEach(a =>
            {
                var ud            = new WF_M_USERDEPT();
                ud.PK_GUID        = Guid.NewGuid().ToString();
                ud.DeptId         = a.DeptId;
                ud.UserId         = entity["UserId"];
                ud.CreateUser     = currentUser.UserName;
                ud.CreateTime     = DateTime.Now;
                ud.LastModifyUser = currentUser.UserName;
                ud.LastModifyTime = DateTime.Now;
                WF_M_USERDEPTLoader.Insert(ud);
            });
            message = "保存成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
Beispiel #2
0
            /// <summary>
            /// 将数据库实体转换成界面上的实体
            /// </summary>
            /// <param name="entity"></param>
            public void LoadFromConnector(WF_M_CONNECTOR entity)
            {
                this.id         = entity.ConnectorId;
                this.name       = entity.ConnectorName;
                this.from       = entity.FromStepId;
                this.to         = entity.ToStepId;
                this.strategy   = Pub.GetOriginalSql(entity.Script);
                this.scripttype = entity.ScriptType.GetValueOrDefault().ToString();
                this.ModelId    = entity.ModelId;

                // 默认值
                this.marked = false;
                this.M      = 200;
                this.type   = "lr";
                var dict = JsonSerializeHelper.DeserializeObject <Dictionary <string, string> >(entity.Extend01);

                if (dict != null)
                {
                    if (dict.ContainsKey("M"))
                    {
                        this.M = ParseHelper.ParseDecimal(dict["M"]);
                    }
                    if (dict.ContainsKey("marked"))
                    {
                        this.marked = ParseHelper.ParseBool(dict["marked"]);
                    }
                    if (dict.ContainsKey("type"))
                    {
                        this.type = dict["type"];
                    }
                }
            }
Beispiel #3
0
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new WFException("无效的参数data".GetRes());
            }

            var success = 0;
            var failed  = 0;

            foreach (var a in data)
            {
                // 删除关联性检查
                var ModelId = string.Format("{0}", a["ModelId"]).Trim();
                if (WFDA.Instance.DeleteModel(ModelId))
                {
                    success++;
                }
                else
                {
                    failed++;
                }
            }
            message = string.Format("成功删除 {0} 条记录,失败 {1}。".GetRes(), success, failed);
            return(DFPub.EXECUTE_SUCCESS);
        }
        public DataGridVM GetTree(DFDictionary dict)
        {
            var vm    = new DataGridVM();
            var di    = new DirectoryInfo(DFPub.ConfigFolder);
            var nodes = new List <WFTreeNode>();

            nodes.Add(new WFTreeNode()
            {
                id = "ROOT", pid = string.Empty, text = "所有表单"
            });

            foreach (var item in di.GetFiles("*.xml", SearchOption.AllDirectories).OrderBy(a => a.FullName))
            {
                var el = XElement.Load(item.FullName);
                if (el.Name != "Form")
                {
                    continue;
                }
                nodes.Add(new WFTreeNode()
                {
                    id   = DFPub.GetAttrValue(el, "Name"),
                    pid  = "ROOT",
                    text = string.Format("{0} {1}", DFPub.GetAttrValue(el, "Name"), DFPub.GetAttrValue(el, "Desc"))
                });
            }

            var listStatus = JsonSerializeHelper.DeserializeObject <List <WFTreeNode> >(Base64StringHelper.ConvertFromBase64String(dict["DF_TREE_VIEWSTATE"]));
            var list       = WFTreeHelper.GenerateTree("ROOT", nodes);

            // 下面这段代码就是为了处理保持客户端树的状态
            WFTreeHelper.SetStatus(nodes, listStatus);
            vm.rows = list;
            return(vm);
        }
Beispiel #5
0
            /// <summary>
            /// 将数据库实体转换成界面上的实体
            /// </summary>
            /// <param name="entity"></param>
            public void LoadFromStep(WF_M_STEP entity)
            {
                this.id      = entity.StepId;
                this.name    = entity.StepName;
                this.ModelId = entity.ModelId;

                this.alt  = true;
                this.left = 0;
                this.top  = 0;

                if (entity.StepType == "Start")
                {
                    this.type   = "start";
                    this.width  = 24;
                    this.height = 24;
                }
                else if (entity.StepType == "Stop")
                {
                    this.type   = "end";
                    this.width  = 24;
                    this.height = 24;
                }
                else
                {
                    this.type   = "task";
                    this.width  = 135;
                    this.height = 50;
                }
                this.strategy   = Pub.GetOriginalSql(entity.Script);
                this.scripttype = entity.ScriptType.GetValueOrDefault().ToString();

                // 默认值
                var dict = JsonSerializeHelper.DeserializeObject <Dictionary <string, string> >(entity.Extend01);

                if (dict != null)
                {
                    if (dict.ContainsKey("left"))
                    {
                        this.left = ParseHelper.ParseInt(dict["left"]);
                    }
                    if (dict.ContainsKey("top"))
                    {
                        this.top = ParseHelper.ParseInt(dict["top"]);
                    }
                    if (dict.ContainsKey("width"))
                    {
                        this.width = ParseHelper.ParseInt(dict["width"]);
                    }
                    if (dict.ContainsKey("height"))
                    {
                        this.height = ParseHelper.ParseInt(dict["height"]);
                    }
                    if (dict.ContainsKey("alt"))
                    {
                        this.alt = ParseHelper.ParseBool(dict["alt"]);
                    }
                }
            }
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var user = Util.GetCurrentUser();
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new Exception("无效的参数 data".GetRes());
            }
            if (entity["subAction"] == "DeleteWorkflow")
            {
                using (var db = Pub.DB)
                {
                    var sql = "exec wfsp_delete_instance @InstanceId";
                    db.Execute(sql, data.Select(a => new { InstanceId = a["InstanceId"] }));
                    message = "删除成功".GetRes();
                }
            }
            else if (entity["subAction"] == "CancelWorkflow")
            {
                var engine = NinjectHelper.Get <IEngine>();
                if (engine == null)
                {
                    throw new Exception("找不到 IEngine".GetRes());
                }
                var failed  = 0;
                var success = 0;
                foreach (var item in data)
                {
                    var InstanceId = item["InstanceId"];
                    if (!string.IsNullOrWhiteSpace(InstanceId))
                    {
                        var Instance = WFDA.Instance.GetInstance(InstanceId);
                        if (null != Instance && Instance.InstanceStatus == Pub.Running)
                        {
                            if (engine.AbortWF(Instance.InstanceId, user.UserId, user.UserName))
                            {
                                AbortWF(Instance.InstanceId);
                                success++;
                            }
                            else
                            {
                                failed++;
                            }
                        }
                        else
                        {
                            failed++;
                        }
                    }
                }
                message = string.Format("成功取消流程 {0} 个,失败 {1} 个", success, failed);
            }
            return(DFPub.EXECUTE_SUCCESS);
        }
 public override int Delete(FormM form, DFDictionary entity, ref string message)
 {
     var data = JsonSerializeHelper.DeserializeObject<List<Dictionary<string, string>>>(entity["data"]);
     if (data == null)
     {
         throw new WFException("无效的参数data".GetRes());
     }
     var list = data.Select(a => new { DeptId = a["DeptId"] }).ToList();
     Delete("delete from WF_M_DEPT where DeptId=@DeptId", list);
     message = "删除成功".GetRes();
     return DFPub.EXECUTE_SUCCESS;
 }
        public DataGridVM GetTree(DFDictionary dict)
        {
            var vm         = new DataGridVM();
            var nodes      = Generate(SessionHelper.Get <FormM>("f"));
            var listStatus = JsonSerializeHelper.DeserializeObject <List <WFTreeNode> >(Base64StringHelper.ConvertFromBase64String(dict["DF_TREE_VIEWSTATE"]));
            var list       = WFTreeHelper.GenerateTree("ROOT", nodes);

            // 下面这段代码就是为了处理保持客户端树的状态
            WFTreeHelper.SetStatus(nodes, listStatus);
            vm.rows = list;
            return(vm);
        }
Beispiel #9
0
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new WFException("无效的参数data".GetRes());
            }
            Delete("delete from SM_M_MASTERDEVICE where MasterDeviceId=@MasterDeviceId", data.Select(a => new { MasterDeviceId = a["MasterDeviceId"] }).ToList());
            message = "删除成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new WFException("无效的参数data".GetRes());
            }
            Delete("update  SM_T_PROCESS set ProcessStatus='RECOVER',RecoverTime=getdate() where InstanceId=@InstanceId", data.Select(a => new { InstanceId = a["InstanceId"] }).ToList());
            message = "回收成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new WFException("无效的参数data".GetRes());
            }
            Delete("delete from BT_PaiGongDan where ID=@ID", data.Select(a => new { ID = a["ID"] }).ToList());
            message = "删除成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new WFException("无效的参数data".GetRes());
            }
            Delete("delete from WF_M_MSG_TEMPLATE where PK_GUID=@PK_GUID and IsSystem<>1", data.Select(a => new { PK_GUID = a["PK_GUID"] }).ToList());
            message = "删除成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
        public static List <Dictionary <string, string> > GetParameter()
        {
            var data = HttpContext.Current.Session[DFPub.DF_DATA_EXCHANGE];

            if (data == null || string.IsNullOrWhiteSpace(data.ToString()))
            {
                return(null);
            }
            else
            {
                return(JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(data.ToString()));
            }
        }
 private List<WFTreeNode> QueryTree(DFDictionary dict)
 {
     var root = WF_M_DEPTLoader.Query("ROOT").FirstOrDefault();
     var nodes = WF_M_DEPTLoader.Query(string.Empty).OrderBy(a => a.DeptOrder.GetValueOrDefault()).Select(a => new WFTreeNode()
     {
         pid = a.PDeptId,
         id = a.DeptId,
         text = string.Format("{0} {1}", a.DeptName, a.DeptDisplayText.GetRes())
     }).ToList();
     var listStatus = JsonSerializeHelper.DeserializeObject<List<WFTreeNode>>(Base64StringHelper.ConvertFromBase64String(dict["DF_TREE_VIEWSTATE"]));
     var list = WFTreeHelper.GenerateTree("ROOT", nodes);
     WFTreeHelper.SetStatus(list, listStatus);
     return list;
 }
Beispiel #15
0
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new WFException("无效的参数data".GetRes());
            }
            WF_M_ROLE_MODELLoader.Delete(data.Select(a => new WF_M_ROLE_MODEL()
            {
                ModelId = a["ModelId"], RoleId = a["RoleId"]
            }).ToList());
            message = "删除成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
Beispiel #16
0
        private List <WFTreeNode> QueryModuleTree(DFDictionary dict)
        {
            var root  = WF_M_MODULELoader.Query("ROOT").FirstOrDefault();
            var nodes = WF_M_MODULELoader.Query(string.Empty).OrderBy(a => a.ModuleOrder.GetValueOrDefault()).Select(a => new WFTreeNode()
            {
                pid  = a.PModuleId,
                id   = a.ModuleId,
                text = a.ModuleName
            }).ToList();
            var listStatus = JsonSerializeHelper.DeserializeObject <List <WFTreeNode> >(Base64StringHelper.ConvertFromBase64String(dict["DF_TREE_VIEWSTATE1"]));
            var list       = WFTreeHelper.GenerateTree("ROOT", nodes);

            WFTreeHelper.SetStatus(list, listStatus);
            return(list);
        }
Beispiel #17
0
        public override int Delete(FormM form, DFDictionary entity, ref string message)
        {
            var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);

            if (data == null)
            {
                throw new WFException("无效的参数 data".GetRes());
            }
            using (var db = Pub.DB)
            {
                var sql = "delete from WF_M_STEPEXECUTOR where ExecutorId=@ExecutorId";
                db.Execute(sql, data.Select(a => new { ExecutorId = a["ExecutorId"] }));
            }
            message = "删除成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }
Beispiel #18
0
        public override int Update(FormM form, DFDictionary entity, ref string message)
        {
            try
            {
                var currentUser = Util.GetCurrentUser();
                if (string.IsNullOrWhiteSpace(entity["UserId"]))
                {
                    throw new ArgumentNullException("UserId");
                }

                var list = JsonSerializeHelper.DeserializeObject <List <VM_WF_M_ROLE> >(Base64StringHelper.ConvertFromBase64String(entity[DFPub.GetKey_GridHiddenValue("grid1")]));

                if (list == null)
                {
                    throw new Exception("Invalid grid data");
                }

                using (var db = Pub.DB)
                {
                    var sql = "DELETE FROM WF_M_USERROLE WHERE RoleId=@RoleId and UserId=@UserId";
                    db.Execute(sql, list.Select(a => new { RoleId = a.RoleId, UserId = entity["UserId"] }));

                    db.Insert(list.Where(a => a.selected).Select(a => new WF_M_USERROLE()
                    {
                        UserRoleId     = Guid.NewGuid().ToString(),
                        RoleId         = a.RoleId,
                        UserId         = entity["UserId"],
                        CreateUser     = currentUser.UserName,
                        CreateTime     = DateTime.Now,
                        LastModifyUser = currentUser.UserName,
                        LastModifyTime = DateTime.Now
                    }));

                    message = "保存成功".GetRes();
                    return(DFPub.EXECUTE_SUCCESS);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(DFPub.EXECUTE_ERROR);
            }
        }
 public override int Delete(FormM form, DFDictionary entity, ref string message)
 {
     try
     {
         var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);
         if (data == null)
         {
             throw new ArgumentNullException("data");
         }
         WF_M_MENULoader.Delete(data.Select(a => a["MenuId"]).ToList());
         message = "删除成功".GetRes();
         return(DFPub.EXECUTE_SUCCESS);
     }
     catch (Exception ex)
     {
         message = ex.Message;
         return(DFPub.EXECUTE_ERROR);
     }
 }
Beispiel #20
0
 private List <VM_ColumnMetadata> AddCheckInfo(List <VM_ColumnMetadata> list)
 {
     foreach (var item in list)
     {
         if (!string.IsNullOrWhiteSpace(item.ColumnCheck))
         {
             var dict = JsonSerializeHelper.DeserializeObject <DFDictionary>(item.ColumnCheck);
             item.CheckMustInput      = dict["CheckMustInput"];
             item.CheckNumber         = dict["CheckNumber"];
             item.CheckMaxLength      = dict["CheckMaxLength"];
             item.CheckDate           = dict["CheckDate"];
             item.CheckDateTime       = dict["CheckDateTime"];
             item.CheckTime           = dict["CheckTime"];
             item.DefaultValue        = dict["DefaultValue"];
             item.GetValue            = dict["GetValue"];
             item.IgnoreGetValueError = dict["IgnoreGetValueError"];
         }
     }
     return(list);
 }
Beispiel #21
0
        private int btnSave(FormM form, DFDictionary entity, ref string message)
        {
            var path      = DFPub.RelativeToPhysical(entity["ConfigFile"]);
            var tables    = GetTableConfig(path);
            var tableName = entity["TableName"];
            var t         = tables.FirstOrDefault(a => a.TableName == tableName);

            t.ImportType = entity["ImportType"];
            t.Insert     = entity["Insert"];
            t.Update     = entity["Update"];
            t.CheckExist = entity["CheckExist"];
            var list = GetGridClientData <VM_ColumnMetadata>(entity);

            foreach (var item in list)
            {
                if (!string.IsNullOrWhiteSpace(item.ColumnCheck))
                {
                    var dict = JsonSerializeHelper.DeserializeObject <DFDictionary>(item.ColumnCheck);
                    item.CheckMustInput      = dict["CheckMustInput"];
                    item.CheckNumber         = dict["CheckNumber"];
                    item.CheckMaxLength      = dict["CheckMaxLength"];
                    item.CheckDate           = dict["CheckDate"];
                    item.CheckDateTime       = dict["CheckDateTime"];
                    item.CheckTime           = dict["CheckTime"];
                    item.DefaultValue        = dict["DefaultValue"];
                    item.GetValue            = dict["GetValue"];
                    item.ExecuteDataTable    = dict["ExecuteDataTable"];
                    item.ExecuteSql          = dict["ExecuteSql"];
                    item.DefaultSort         = dict["DefaultSort"];
                    item.ConnectionString    = dict["ConnectionString"];
                    item.IgnoreGetValueError = dict["IgnoreGetValueError"];
                    item.DatabaseType        = dict["DatabaseType"];
                }
            }
            t.Columns = list;
            var el = new XElement("tables", tables.Select(a => a.ToXml()));

            el.Save(path);
            return(DFPub.EXECUTE_SUCCESS);
        }
 public override int Delete(FormM form, DFDictionary entity, ref string message)
 {
     try
     {
         var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);
         if (data == null)
         {
             throw new ArgumentNullException("data");
         }
         using (var db = Pub.DB)
         {
             if (entity["subAction"] == "ResetPassword")
             {
                 var sql = "select * from WF_M_USER where UserId=@UserId";
                 foreach (var item in data)
                 {
                     var oldEntity = db.Query <WF_M_USER>(sql, new { UserId = item["UserId"] }).FirstOrDefault();
                     if (null != oldEntity)
                     {
                         oldEntity.Password = HashHelper.GenerateUserHash(oldEntity.UserName, "123456");
                         db.Update(oldEntity);
                     }
                 }
                 message = "重置成功,已经将密码重置为 123456".GetRes();
             }
             else
             {
                 var sql = "delete from WF_M_USER where UserId=@UserId";
                 db.Execute(sql, data.Select(a => new { UserId = a["UserId"] }));
                 message = "删除成功".GetRes();
             }
         }
         return(DFPub.EXECUTE_SUCCESS);
     }
     catch (Exception ex)
     {
         message = ex.Message;
         return(DFPub.EXECUTE_ERROR);
     }
 }
Beispiel #23
0
 public override int Delete(FormM form, DFDictionary entity, ref string message)
 {
     try
     {
         var currentUser = Util.GetCurrentUser();
         var subAction   = entity["subAction"];
         if (subAction == "MarkAllRead")
         {
             MsgCenter.MarkAllRead(currentUser.UserId, currentUser.UserName);
             MsgCenter.RefreshUserMessage(currentUser.UserId);
             message = "全部标记已读成功";
         }
         else
         {
             var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);
             if (data == null)
             {
                 throw new ArgumentNullException("data");
             }
             if (subAction == "MarkRead")
             {
                 MsgCenter.MarkRead(data.Select(a => a["MsgId"]).ToList(), currentUser.UserName);
                 MsgCenter.RefreshUserMessage(currentUser.UserId);
                 message = "标记已读成功";
             }
             else
             {
                 MsgCenter.DeleteMessage(data.Select(a => a["MsgId"]).ToList());
                 MsgCenter.RefreshUserMessage(currentUser.UserId);
                 message = "删除成功";
             }
         }
         return(DFPub.EXECUTE_SUCCESS);
     }
     catch (Exception ex)
     {
         message = ex.Message;
         return(DFPub.EXECUTE_ERROR);
     }
 }
Beispiel #24
0
        public override void SetAccess(FormM form, DFDictionary entity)
        {
            var newDict = new Dictionary <string, string>();
            var dict    = JsonSerializeHelper.DeserializeObject <Dictionary <string, string> >(form.GetControlM("TableName").Options);

            //foreach (var item in dict)
            //{
            //    if (!string.IsNullOrWhiteSpace(item.Value))
            //    {
            //        if (AuthLoader.CheckFunctionAccess(item.Value, Util.GetCurrentUser().UserId))
            //        {
            //            newDict.Add(item.Key, item.Value);
            //        }
            //    }
            //}
            base.SetSelectDataSource(form, "TableName",
                                     dict.Select(a => new DFSelectItem()
            {
                Value = a.Key, Text = a.Value
            }).ToList(), true);
            base.SetAccess(form, entity);
        }
 public override int Delete(FormM form, DFDictionary entity, ref string message)
 {
     try
     {
         var data = JsonSerializeHelper.DeserializeObject <List <Dictionary <string, string> > >(entity["data"]);
         if (data == null)
         {
             throw new ArgumentNullException("data");
         }
         using (var db = Pub.DB)
         {
             var sql = "delete from WF_T_LOG where LogId=@LogId";
             db.Execute(sql, data.Select(a => new { LogId = a["LogId"] }));
         }
         message = "删除成功".GetRes();
         return(DFPub.EXECUTE_SUCCESS);
     }
     catch (Exception ex)
     {
         message = ex.Message;
         return(DFPub.EXECUTE_ERROR);
     }
 }
Beispiel #26
0
        public override int Update(FormM form, DFDictionary entity, ref string message)
        {
            try
            {
                var currentUser = Util.GetCurrentUser();
                var listStatus1 = JsonSerializeHelper.DeserializeObject <List <WFTreeNode> >(Base64StringHelper.ConvertFromBase64String(entity["DF_TREE_VIEWSTATE1"]));
                if (listStatus1 == null)
                {
                    throw new Exception("Invalid DF_TREE_VIEWSTATE1");
                }
                var listStatus2 = JsonSerializeHelper.DeserializeObject <List <WFTreeNode> >(Base64StringHelper.ConvertFromBase64String(entity["DF_TREE_VIEWSTATE2"]));
                if (listStatus2 == null)
                {
                    throw new Exception("Invalid DF_TREE_VIEWSTATE2");
                }
                if (string.IsNullOrWhiteSpace(entity["RoleId"]))
                {
                    throw new ArgumentNullException("RoleId");
                }

                using (var db = Pub.DB)
                {
                    var sql = string.Empty;

                    sql = "DELETE FROM WF_M_AUTH_MODULE WHERE RoleId=@RoleId";
                    db.Execute(sql, new { RoleId = entity["RoleId"] });

                    sql = "DELETE FROM WF_M_AUTH_DATA WHERE RoleId=@RoleId";
                    db.Execute(sql, new { RoleId = entity["RoleId"] });

                    var checkedList = listStatus1.Where(a => a._checked).ToList();
                    db.Insert(checkedList.Select(a => new WF_M_AUTH_MODULE()
                    {
                        AuthId         = Guid.NewGuid().ToString(),
                        ModuleId       = a.id,
                        RoleId         = entity["RoleId"],
                        CreateUser     = currentUser.UserName,
                        CreateTime     = DateTime.Now,
                        LastModifyUser = currentUser.UserName,
                        LastModifyTime = DateTime.Now
                    }));

                    checkedList = listStatus2.Where(a => a._checked).ToList();
                    db.Insert(checkedList.Select(a => new WF_M_AUTH_DATA()
                    {
                        AuthId         = Guid.NewGuid().ToString(),
                        DeptId         = a.id,
                        RoleId         = entity["RoleId"],
                        CreateUser     = currentUser.UserName,
                        CreateTime     = DateTime.Now,
                        LastModifyUser = currentUser.UserName,
                        LastModifyTime = DateTime.Now
                    }));
                }
                message = "保存成功".GetRes();
                return(DFPub.EXECUTE_SUCCESS);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(DFPub.EXECUTE_ERROR);
            }
        }
Beispiel #27
0
        public void SaveToDB(string data, string currentUser)
        {
            var root     = JsonSerializeHelper.DeserializeObject <Dictionary <string, object> >(data);
            var title    = _T(root["title"]);
            var jo_lines = root["lines"] as JObject;
            // var areas = root["areas"] as JObject;
            var jo_nodes = root["nodes"] as JObject;
            var initNum  = ParseHelper.ParseInt(_T(root["initNum"])).GetValueOrDefault();

            var lines = jo_lines.Children().Cast <JProperty>().Select(a =>
            {
                var line        = new Line();
                line.id         = a.Name;
                line.name       = GetProperty <string>(a.Value, "name");
                line.type       = GetProperty <string>(a.Value, "type");
                line.M          = GetProperty <decimal?>(a.Value, "M");
                line.from       = GetProperty <string>(a.Value, "from");
                line.to         = GetProperty <string>(a.Value, "to");
                line.marked     = GetProperty <bool?>(a.Value, "marked");
                line.strategy   = GetProperty <string>(a.Value, "strategy");
                line.scripttype = GetProperty <string>(a.Value, "scripttype");
                return(line);
            }).ToList();


            var nodes = jo_nodes.Children().Cast <JProperty>().Select(a =>
            {
                var node        = new Node();
                node.id         = a.Name;
                node.name       = GetProperty <string>(a.Value, "name");
                node.type       = GetProperty <string>(a.Value, "type");
                node.left       = GetProperty <int?>(a.Value, "left");
                node.top        = GetProperty <int?>(a.Value, "top");
                node.width      = GetProperty <int?>(a.Value, "width");
                node.height     = GetProperty <int?>(a.Value, "height");
                node.alt        = GetProperty <bool?>(a.Value, "alt");
                node.strategy   = GetProperty <string>(a.Value, "strategy");
                node.scripttype = GetProperty <string>(a.Value, "scripttype");
                return(node);
            }).ToList();

            var steps = nodes.Select(a =>
            {
                var step = a.ToStep();
                return(step);
            });
            var connectors = lines.Select(a =>
            {
                var connector = a.ToConnector();
                return(connector);
            });

            var ModelName = title;

            if (string.IsNullOrWhiteSpace(ModelName))
            {
                throw new WFException("模型名称不能为空");
            }
            var model = SaveModel(currentUser, ModelName);

            SaveSteps(currentUser, steps, model);
            SaveConnectors(currentUser, connectors, model);

            // 删除没用的数据
            var list = WFDA.Instance.GetSteps(model.ModelId)
                       .Where(a => !steps.Any(b => b.StepId == a.StepId)).Select(a => a.StepId).ToList();

            WFDA.Instance.DeleteStep(list);

            list = WFDA.Instance.GetConnectors(model.ModelId)
                   .Where(a => !connectors.Any(b => b.ConnectorId == a.ConnectorId)).Select(a => a.ConnectorId).ToList();
            WFDA.Instance.DeleteConnector(list);
        }