示例#1
0
        private static string GetJson(MDataTable configTable)
        {
            JsonHelper      json         = new JsonHelper(false, false);
            string          configKey    = string.Empty;
            bool            isKeyChanged = false;
            List <MDataRow> groupList    = new List <MDataRow>();
            int             count        = configTable.Rows.Count;

            for (int i = 0; i < count; i++)
            {
                MDataRow row = configTable.Rows[i];
                if (configKey != string.Empty && configKey != row.Get <string>("ConfigKey", string.Empty).Trim())
                {
                    isKeyChanged = true;
                }
                if (isKeyChanged)
                {
                    if (groupList.Count > 0)
                    {
                        json.Add(configKey, GetInnerJson(groupList), true);
                        groupList.Clear();
                    }
                    isKeyChanged = false;
                }
                groupList.Add(row);
                configKey = row.Get <string>("configKey", string.Empty).Trim();
                if (i == count - 1 && groupList.Count > 0)//最的一条(最后一组处理)
                {
                    json.Add(configKey, GetInnerJson(groupList), true);
                }
            }
            json.AddBr();
            return(json.ToString());
        }
示例#2
0
        /// <summary>
        /// 显示 单选/多选 下一步
        /// </summary>
        /// <param name="nextActivitySetid"></param>
        private void GetNextListRadioActivityHtml(JsonHelper js)
        {
            if (WFContext.FormAction == FormAction.View || WFContext.TaskID.ToString() == Guid.Empty.ToString())
            {
                return;
            }
            if (WFContext.FormAction == FormAction.Todo && WFContext.Instance.InstanceState != InstanceState.Complete)
            {
                var nextTransitionList = WFContext.Activity.TransitionList;

                StringBuilder activityHtml = new StringBuilder();
                StringBuilder actorHtml    = new StringBuilder();

                bool isEndActivityOnNext = false;

                if (nextTransitionList.Count() > 0)
                {
                    foreach (Transition item in nextTransitionList)
                    {
                        Activity a = item.ToActivity;

                        //自动步骤不在手动提交供选当中,由于当前步骤是手动发出,那么如果下一步都是由手动进入的步骤来承接
                        //如果当前发出为自动,那么下一步都是自动进入的步骤来承接
                        if (a == null)
                        {
                            continue;
                        }
                        if (nextTransitionList.Count == 1)
                        {
                            //是否仅是一个结束步骤,如果是则默认选中

                            switch (a.ActivityType)
                            {
                            case ActivityType.Join:
                            case ActivityType.Split:
                            case ActivityType.End:
                                isEndActivityOnNext = a.ActivityType == ActivityType.End;
                                isEndActivityOnNext = isEndActivityOnNext || (a.TransitionList.Count == 1 && a.TransitionList[0].ToActivity.ActivityType == ActivityType.End);
                                break;
                            }
                        }
                        activityHtml.Append(WF.Actor.GetActivityHtml(a, WFContext.Activity));
                        if (!isEndActivityOnNext)
                        {
                            actorHtml.Append(WF.Actor.GetActorHtml(a, WFContext));
                        }
                    }
                }
                else
                {
                    activityHtml.Append("<ul>");
                    activityHtml.Append("<li  style='color;red;'>无步骤可选择,请尝试刷新缓存!</li>");
                    activityHtml.Append("</ul>");
                }

                js.Add("isEndActivityOnNext", isEndActivityOnNext);
                js.Add("activityHtml", activityHtml.ToString());
                js.Add("actorHtml", actorHtml.ToString());
            }
        }
示例#3
0
        static string GetJson()
        {
            JsonHelper js = new JsonHelper();

            js.Add("v1", "v1...");
            js.Add("v2", "222", true);
            return(js.ToString());
        }
示例#4
0
        private string GetJson(MDataColumn mdc)
        {
            JsonHelper js = new JsonHelper();

            foreach (var cell in mdc)
            {
                js.Add("Key", cell.ColumnName);
                js.Add("Value", cell.ColumnName);
                js.AddBr();
            }
            return(js.ToString(true));
        }
示例#5
0
        private static string GetInnerJson(List <MDataRow> groupList)
        {
            JsonHelper json = new JsonHelper(false, false);

            foreach (MDataRow row in groupList)
            {
                json.Add("text", row.Get <string>("ConfigName"));
                json.Add("value", row.Get <string>("ConfigValue"));
                json.AddBr();
            }
            return(json.ToString(true));
        }
示例#6
0
        /// <summary>
        /// 获取流程设计器初始化信息
        /// </summary>
        public void GetDesignerConfig()
        {
            //WF.Run.
            Guid wid          = Query <Guid>("wid");
            Guid wiid         = Query <Guid>("wiid");
            bool isDesignMode = Query <string>("dm") != "0";

            if (wid == Guid.Empty && wiid != Guid.Empty)
            {
                var info = WF.Context.GetOnView(wiid);
                if (info != null)
                {
                    wid = info.WorkflowID;
                }
            }
            JsonHelper js = new JsonHelper();

            if (isDesignMode && wiid == Guid.Empty)
            {
                js.Add("template", WF.Desiger.GetTemplate());
            }
            //XmlToJson 流程图查看
            if (wid != Guid.Empty)
            {
                js.Add("workflow", WF.Desiger.Get(wid));
            }

            //DesignerJson 已经走过的节点数据
            string mapData = string.Empty;

            if (!isDesignMode)//View状态
            {
                if (wiid != Guid.Empty)
                {
                    mapData = WF.Desiger.GetHistory(wiid);
                    if (String.IsNullOrEmpty(mapData))
                    {
                        mapData = WF.Desiger.GetHistory(wid);
                    }
                }
            }
            else if (wid != Guid.Empty)
            {
                mapData = WF.Desiger.GetHistory(wid);
            }
            if (!string.IsNullOrEmpty(mapData))
            {
                js.Add("mapData", mapData);
            }

            jsonResult = js.ToString();
        }
示例#7
0
        //JsonHelper的实例方法
        static void JsonHelperInstance()
        {
            JsonHelper js = new JsonHelper(true, true);

            js.Add("key", "value...");
            js.Add("boolKey", "true", true);
            js.AddBr();//需要构造多个Json时,要换一下行

            js.Add("key", "value2...");
            js.Add("child", GetJson());//可以构造复杂Json。
            js.AddBr();
            string value = js.ToString();

            OutMsg("JsonHelper:--------------------------------------------");
            OutMsg(value);
        }
示例#8
0
        public override IList <MenuItem> GetViewMenu(Dictionary <string, string> dataForMenu)
        {
            var results  = new List <MenuItem>();
            var menuId   = String.Empty;
            var parentId = String.Empty;

            if (dataForMenu.ContainsKey("MenuId"))
            {
                menuId = dataForMenu["MenuId"];
            }
            if (dataForMenu.ContainsKey("ParentId"))
            {
                parentId = dataForMenu["ParentId"];
            }

            if (!String.IsNullOrWhiteSpace(menuId))
            {
                results.Add(new MenuItem("Back", EventNumber.ViewMenus, parentId));
            }

            var jsonObject = new JsonHelper();

            jsonObject.Add("ParentId", menuId);
            var json = jsonObject.ToString();

            results.Add(new MenuItem("Add", EventNumber.AddMenu, json));

            return(results);
        }
示例#9
0
        private static string GetInnerJson(List <MDataRow> groupList)
        {
            MDataTable group = groupList;

            if (AppConfig.DB.DefaultDalType == DalType.Txt)
            {
                group.Rows.Sort("OrderNo ASC");//文本需要再次排序(因为不支持查询的时候多重排序)
            }
            JsonHelper json = new JsonHelper(false, false);

            foreach (MDataRow row in group.Rows)
            {
                json.Add("text", row.Get <string>("ConfigName"));
                json.Add("value", row.Get <string>("ConfigValue"));
                json.AddBr();
            }
            return(json.ToString(true));
        }
示例#10
0
        public override async Task <IList <IEvent> > ProcessAction(int actionNumber)
        {
            var fromDate = GetValue <DateTime>("FromDate");
            var toDate   = GetValue <DateTime>("ToDate");
            var userIds  = GetValue <List <string> >("Users");

            var json = new JsonHelper();

            json.Add("FromDate", fromDate);
            json.Add("ToDate", toDate);
            json.Add("UserIds", JsonHelper.SerializeObject(userIds));

            return(new List <IEvent>()
            {
                new ExecuteAction(EventNumber.CreateAuditReport, json.ToString()),
                new CancelInputDialog(),
            });
        }
示例#11
0
        public override void ConfigureColumns(ColumnConfiguration columnConfig)
        {
            columnConfig.AddStringColumn("Date", "Date");
            columnConfig.AddStringColumn("Task", "Task");
            columnConfig.AddStringColumn("Status", "Status", 3);
            columnConfig.AddHiddenColumn("Id");
            var json = new JsonHelper();

            json.Add("type", "status");
            columnConfig.AddLinkColumn("", "Id", "Detail", EventNumber.ViewBackgroundDetail, parametersToPass: json.ToString()); //parameters not passing
        }
示例#12
0
        /// <summary>
        /// 获取UI、MID、ActionKey的配置值。
        /// </summary>
        public void GetInitConfig()
        {
            string ui = string.Empty, actionKeys = string.Empty, menuID = string.Empty;

            if (context.Request.Url.LocalPath.ToLower().StartsWith("/ui/"))
            {
                ui = AppConfig.GetApp("UI");
            }
            actionKeys = p.GetFuncKeys();
            if (!string.IsNullOrEmpty(actionKeys))
            {
                actionKeys = "," + actionKeys.ToLower().Trim();
            }

            menuID = p.UrlMenuID;
            JsonHelper js = new JsonHelper(false, false);

            js.Add("ui", ui);
            js.Add("actionKeys", actionKeys);
            js.Add("mid", menuID);
            jsonResult = js.ToString();
        }
示例#13
0
        public string GetExcelMapping()
        {
            MDataRow row     = ExcelConfig.GetExcelRow(Query <string>("ID"));
            string   objName = row.Get <string>(Config_Excel.ExcelName);

            string[] TableNames             = row.Get <string>(Config_Excel.TableNames).Split(',');
            Dictionary <string, string> dic = new Dictionary <string, string>();
            JsonHelper js = new JsonHelper();

            foreach (string name in TableNames)
            {
                MDataColumn mdc = DBTool.GetColumns(name);
                js.Add(name, GetJson(mdc), true);
                dic.Add(name, name);
            }
            JsonHelper jh = new JsonHelper();

            jh.Add("objName", objName);
            jh.Add("arrColumns", js.ToString(false));
            jh.Add("arrTables", MDataTable.CreateFrom(dic).ToJson(false, false));
            return(jh.ToString());
        }
示例#14
0
        /// <summary>
        /// 获取UI、MID、ActionKey的配置值。
        /// </summary>
        public void GetInitConfig()
        {
            string ui = string.Empty, actionKeys = string.Empty, menuID = string.Empty;

            if (IsUseUISite)
            {
                ui = "/" + AppConfig.GetApp("UI").Trim('/');
            }
            actionKeys = p.GetFuncKeys();
            if (!string.IsNullOrEmpty(actionKeys))
            {
                actionKeys = "," + actionKeys.ToLower() + ",";
            }

            menuID = p.UrlMenuID;
            JsonHelper js = new JsonHelper(false, false);

            js.Add("ui", ui);
            js.Add("actionKeys", actionKeys);
            js.Add("mid", menuID);
            jsonResult = js.ToString();
        }
示例#15
0
        public override IList <MenuItem> GetViewMenu(Dictionary <string, string> dataForMenu)
        {
            var results = new List <MenuItem>();

            var jsonObject = new JsonHelper();

            jsonObject.Add("IsNew", true);
            var json = jsonObject.ToString();

            results.Add(new MenuItem("Add", Id + 1, json));

            return(results);
        }
示例#16
0
        public string AddBeerRating(List <BeerRatings> beerRatings, string path)
        {
            bool   flag = false;
            string json = Serialize.ToJson(beerRatings);

            flag = JsonHelper.Add(json, path);
            if (flag)
            {
                return("success");
            }
            else
            {
                return("Failure");
            }
        }
示例#17
0
        public override async Task <IList <IEvent> > ProcessAction()
        {
            var url  = "https://localhost/websitetemplate/api/v1/performBackup";
            var json = new JsonHelper();

            json.Add("abc", "xyz");
            var bytes = QBicUtils.GetBytes(json.ToString());

            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
            //using (var client = new WebClient())
            using (var client = new HttpClient())
            {
                //var responseData = client.UploadData(url, bytes);
                //var tmpString = XXXUtils.GetString(responseData);

                client.BaseAddress = new Uri(url);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var resp = await client.PostAsJsonAsync(url, bytes);

                var backupTypeString = resp.Headers.GetValues(BackupService.BACKUP_HEADER_KEY).FirstOrDefault();
                //var byteContent = await resp.Content.ReadAsByteArrayAsync();
                //var byteString = XXXUtils.GetString(byteContent);

                var stringContent = await resp.Content.ReadAsStringAsync();

                //stringContent = stringContent.Substring(1, stringContent.Length - 2);
                stringContent = stringContent.Replace("\0", "");

                var data         = Convert.FromBase64String(stringContent);
                var responseData = CompressionHelper.InflateByte(data);

                var itemsString = QBicUtils.GetString(responseData);

                itemsString = "[" + itemsString + "]";
                itemsString = itemsString.Replace("}{", "},{");
                var itemsList = JsonHelper.DeserializeObject <List <BaseClass>[]>(itemsString, true);
                var items     = itemsList.SelectMany(i => i).ToList();
                Console.WriteLine(items.Count);
            }

            return(new List <IEvent>()
            {
                new ShowMessage("Test done")
            });
        }
示例#18
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            JsonHelper helper = new JsonHelper();

            helper.Add(new Facade.Model.ConnectionString()
            {
                conn = conn,
                name = instance,
                type = type
            });


            DialogResult result = MessageBox.Show("添加成功,是否关闭窗口!", "提示", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                myRefresh();
                this.Close();
            }
        }
示例#19
0
        internal static void SetCache(AopEnum action, AopInfo aopInfo)//End
        {
            if (!IsCanOperateCache(aopInfo))
            {
                return;
            }
            string baseKey = GetBaseKey(aopInfo);

            switch (action)
            {
            case AopEnum.ExeNonQuery:
            case AopEnum.Insert:
            case AopEnum.Update:
            case AopEnum.Delete:
                if (aopInfo.IsSuccess || aopInfo.RowCount > 0)
                {
                    if (action == AopEnum.Update || action == AopEnum.ExeNonQuery)
                    {
                        //检测是否指定忽略的列名(多数据库的指定?{XXX.XXX})
                        if (!IsCanRemoveCache(action, aopInfo))
                        {
                            return;
                        }
                    }
                    ReadyForRemove(baseKey);
                }
                return;
            }


            if (_MemCache.CacheType == CacheType.LocalCache && _MemCache.Count > 5000000)//数量超过500万
            {
                return;
            }
            string key = GetKey(action, aopInfo, baseKey);
            int    flag;                         //0 正常;1:未识别;2:不允许缓存

            SetBaseKeys(aopInfo, key, out flag); //存档Key,后续缓存失效 批量删除
            if (flag == 2)
            {
                return;                                          //
            }
            double cacheTime = AppConfig.Cache.DefaultCacheTime; // Math.Abs(12 - DateTime.Now.Hour) * 60 + DateTime.Now.Second;//缓存中午或到夜里1点

            if (flag == 1 || aopInfo.PageIndex > 2)              // 后面的页数,缓存时间可以短一些
            {
                cacheTime = 2;                                   //未知道操作何表时,只缓存2分钟(比如存储过程等语句)
            }
            switch (action)
            {
            case AopEnum.ExeMDataTableList:
                if (IsCanCache(aopInfo.TableList))
                {
                    JsonHelper js = new JsonHelper(false, false);
                    foreach (MDataTable table in aopInfo.TableList)
                    {
                        js.Add(Guid.NewGuid().ToString(), table.ToJson(true, true, RowOp.IgnoreNull, false, EscapeOp.No));
                    }
                    js.AddBr();
                    _MemCache.Set(key, js.ToString(), cacheTime);
                }
                break;

            case AopEnum.Select:
            case AopEnum.ExeMDataTable:
                if (IsCanCache(aopInfo.Table))
                {
                    _MemCache.Set(key, aopInfo.Table.ToJson(true, true, RowOp.IgnoreNull, false, EscapeOp.No), cacheTime);
                }
                break;

            case AopEnum.ExeScalar:
                _MemCache.Set(key, aopInfo.ExeResult, cacheTime);
                break;

            case AopEnum.Fill:
                _MemCache.Set(key, aopInfo.Row.Clone(), cacheTime);
                break;

            case AopEnum.GetCount:
                _MemCache.Set(key, aopInfo.RowCount, cacheTime);
                break;

            case AopEnum.Exists:
                _MemCache.Set(key, aopInfo.ExeResult, cacheTime);
                break;
            }
        }
示例#20
0
        /// <summary>
        /// 获得当前工作流程的上下文0
        /// </summary>
        public void GetWorkflowContext()
        {
            WorkflowContext context = WFContext;

            if (context != null)
            {
                if (context.FormAction == FormAction.Todo)
                {
                    if (context.TaskInstance.TaskState == TaskState.Complete || !context.TaskInstance.IsValid)
                    {
                        jsonResult = JsonHelper.OutResult(false, "任务已结束!");
                        return;
                    }
                    if (context.Instance.InstanceState == InstanceState.Complete || context.Instance.InstanceState == InstanceState.Invalid)
                    {
                        jsonResult = JsonHelper.OutResult(false, "流程已结束!");
                        return;
                    }
                }

                JsonHelper js = new JsonHelper(false, false);

                js.Add("name", context.DefinitionInfo.WorkflowName);
                js.Add("title", context.Instance.InstanceTitle);
                js.Add("instanceID", context.InstanceID.ToString());
                js.Add("formID", context.Instance.FormID);
                js.Add("startTime", context.Instance.StartTime.ToString("yyyy-MM-dd HH:mm:ss"));
                if (context.Instance.FinishTime.HasValue)
                {
                    js.Add("finishTime", context.Instance.FinishTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(context.DefinitionInfo.App.FormPath))
                {
                    js.Add("formPath", context.DefinitionInfo.App.FormPath);
                }
                js.Add("sheetID", context.Instance.SheetID);
                js.Add("workflowID", context.WorkflowID);
                js.Add("taskID", context.TaskID);
                if (WFContext.TaskInstance != null)
                {
                    js.Add("taskState", context.TaskInstance.TaskState);
                }
                js.Add("instanceState", context.Instance.InstanceState);
                js.Add("formAction", (int)context.FormAction);
                js.Add("urgency", context.Instance.Urgency);
                js.Add("importance", context.Instance.Importance);
                js.Add("appID", context.AppID);
                if (context.Activity != null)
                {
                    js.Add("activityID", context.Activity.ActivityID);
                    js.Add("activityName", context.Activity.ActivityName);
                    js.Add("activityType", context.Activity.ActivityType.ToString());
                    js.Add("splitType", context.Activity.SplitType.ToString());
                    js.Add("joinType", context.Activity.JoinType.ToString());
                    js.Add("respondType", context.Activity.RespondType.ToString());
                    js.Add("isEditForm", context.Activity.IsEditForm);
                    js.Add("isShowOpinion", context.DefinitionInfo.IsShowOpinion && context.Activity.IsShowOpinion);
                    js.Add("isOpinionRequire", context.Activity.IsOpinionRequire);

                    //按钮权限

                    js.Add("enableCirculate", context.DefinitionInfo.IsEnableCirculate && (context.Activity.CirculateType == CirculateType.Manual || context.Activity.CirculateType == CirculateType.Both));
                    js.Add("enableTransmit", context.DefinitionInfo.IsEnableTransmit && context.Activity.IsEnableTransmit);
                    js.Add("enableReject", context.DefinitionInfo.IsEnableReject && context.Activity.RejectType != RejectType.None);
                    if (context.FormAction == FormAction.View && context.Instance.InstanceState == InstanceState.Running && context.Instance.CreatorID == context.User.UserID)
                    {
                        js.Add("enableWithdraw", context.DefinitionInfo.IsEnableWithdraw && WF.Run.IsCanWithdraw(context.ActivityInstance));
                    }
                    js.Add("enableInvalid", context.DefinitionInfo.IsEnableInvalid && context.Instance.CreatorID == context.User.UserID && context.Instance.InstanceState == InstanceState.Running);
                }
                js.Add("orgID", context.User.OrgID);
                js.Add("orgName", context.User.OrgName);
                js.Add("orgFullName", context.User.OrgFullName);
                js.Add("userID", context.User.UserID);
                js.Add("userName", context.User.UserName);
                js.Add("fullName", context.User.FullName);
                jsonResult = JsonHelper.OutResult(true, js.ToString());
            }
        }
示例#21
0
        //[ActionKey("View")]
        /// <summary>
        /// 获取下拉框Json结果集(统一处理)
        /// </summary>
        /// <returns></returns>
        public void GetCombobox()
        {
            string itemJson = Query <string>("sys_json");

            if (!string.IsNullOrEmpty(itemJson))
            {
                List <ComboboxItem> boxes = JsonHelper.ToList <ComboboxItem>(itemJson);
                JsonHelper          json  = new JsonHelper();
                if (boxes.Count > 0)
                {
                    List <MDataTable> dtList = new List <MDataTable>();
                    StringBuilder     sb     = new StringBuilder();
                    string            value  = null;
                    for (int i = 0; i < boxes.Count; i++)
                    {
                        ComboboxItem item = boxes[i];
                        string       code = SqlCode.GetCode(item.ObjName);
                        if (code != item.ObjName)
                        {
                            #region 核心处理
                            var sql = SqlCode.GetCode(item.ObjName).ToLower();
                            //格式化请求参数
                            string key   = "@text";
                            int    index = sql.IndexOf(key);
                            if (index > -1)
                            {
                                value = Query <string>("q");                                            //easyui远程传递参数
                                if (string.IsNullOrEmpty(value) && sql.IndexOf('=', index - 5, 5) > -1) //处理成1=1,同时有=号
                                {
                                    int    end   = index + key.Length;
                                    string temp  = sql.Substring(0, index - 5);
                                    int    start = temp.LastIndexOf(' ');
                                    sql = sql.Replace(sql.Substring(start + 1, end - start - 1), "1=1");
                                }
                                else
                                {
                                    sql = sql.Replace(key, value);
                                }
                            }
                            sb.Append(sql + ";");
                            #endregion
                        }
                        else
                        {
                            #region 找不到,则移除。
                            boxes.RemoveAt(i);
                            //从程序里找。
                            MDataTable dt = Combobox.Get(item.ObjName, Query <string>("q"));
                            if (dt != null)
                            {
                                dtList.Insert(0, dt);
                                boxes.Insert(0, item);
                            }
                            else
                            {
                                i--;
                            }
                            #endregion
                        }
                    }
                    if (sb.Length > 0)
                    {
                        string sql = sb.ToString().TrimEnd(';');
                        using (MProc proc = new MProc(null, CrossDb.GetConn(sql)))
                        {
                            if (proc.DalType == DalType.MsSql)
                            {
                                proc.ResetProc(sql);
                                dtList.AddRange(proc.ExeMDataTableList());
                            }
                            else
                            {
                                string[] items = sql.Split(';');
                                foreach (string item in items)
                                {
                                    proc.ResetProc(item);
                                    dtList.Add(proc.ExeMDataTable());
                                }
                            }
                        }
                    }
                    if (dtList.Count == 1 && Query <string>("q", null) != null)
                    {
                        jsonResult = dtList[0].ToJson(false, false, true);
                        return;
                    }
                    for (int i = 0; i < dtList.Count; i++)
                    {
                        json.Add(boxes[i].ObjName, dtList[i].Rows.Count > 0 ? dtList[i].ToJson(false, false, true) : "[]", true);
                        if (!string.IsNullOrEmpty(boxes[i].Parent))
                        {
                            json.Add("Target", boxes[i].Parent);
                        }
                        json.AddBr();
                    }
                }
                jsonResult = string.IsNullOrEmpty(json.ToString()) ? "[]" : json.ToString(true);
            }
        }
示例#22
0
        //[ActionKey("View")]
        /// <summary>
        /// 获取下拉框Json结果集(统一处理)
        /// </summary>
        /// <returns></returns>
        public void GetCombobox()
        {
            string itemJson = Query <string>("sys_json");

            if (!string.IsNullOrEmpty(itemJson))
            {
                List <ComboItem> boxes = JsonHelper.ToList <ComboItem>(itemJson);
                JsonHelper       json  = new JsonHelper();
                if (boxes.Count > 0)
                {
                    List <MDataTable> dtList = new List <MDataTable>();
                    StringBuilder     sb     = new StringBuilder();
                    for (int i = 0; i < boxes.Count; i++)
                    {
                        ComboItem item = boxes[i];
                        string    code = SqlCode.GetCode(item.ObjName);
                        if (code != item.ObjName)
                        {
                            #region 核心处理
                            var sql = SqlCode.GetCode(item.ObjName);//已经处理过系统参数和Post参数
                            sql = ReplacePara(sql, "@para", item.Para);
                            sql = ReplacePara(sql, "@parent", item.Parent);

                            sb.Append(sql + " ; ");
                            #endregion
                        }
                        else
                        {
                            #region 找不到,则移除。
                            boxes.RemoveAt(i);
                            //从程序里找。
                            MDataTable dt = Combobox.Get(item.ObjName, Query <string>("q", item.Para));
                            if (dt != null)
                            {
                                dtList.Insert(0, dt);
                                boxes.Insert(0, item);
                            }
                            else
                            {
                                i--;
                            }
                            #endregion
                        }
                    }
                    if (sb.Length > 0)
                    {
                        string sql = sb.ToString().TrimEnd(';', ' ');
                        using (MProc proc = new MProc(null))
                        {
                            if (proc.DataBaseType == DataBaseType.MsSql)
                            {
                                proc.ResetProc(sql);
                                dtList.AddRange(proc.ExeMDataTableList());
                            }
                            else
                            {
                                string[] items = sql.Split(';');
                                foreach (string item in items)
                                {
                                    proc.ResetProc(item);
                                    dtList.Add(proc.ExeMDataTable());
                                }
                            }
                        }
                    }
                    if (dtList.Count == 1 && Query <string>("q", null) != null)
                    {
                        jsonResult = dtList[0].ToJson(false, false, RowOp.None, true);
                        return;
                    }
                    for (int i = 0; i < dtList.Count; i++)
                    {
                        json.Add(boxes[i].ObjName, dtList[i].Rows.Count > 0 ? dtList[i].ToJson(false, false, RowOp.None, true) : "[]", true);
                    }
                    json.AddBr();
                }
                jsonResult = json.ToString();
            }
        }
示例#23
0
        internal static void SetCache(AopEnum action, AopInfo aopInfo)//End
        {
            string baseKey = GetBaseKey(aopInfo);

            switch (action)
            {
            case AopEnum.ExeNonQuery:
            case AopEnum.Insert:
            case AopEnum.Update:
            case AopEnum.Delete:
                if (aopInfo.IsSuccess || aopInfo.RowCount > 0)
                {
                    ReadyForRemove(baseKey);
                }
                return;
            }

            //if (!IsCanOperateCache(baseKey))
            //{
            //    return;
            //}
            if (_MemCache.CacheType == CacheType.LocalCache && _MemCache.RemainMemoryPercentage < 15)//可用内存低于15%
            {
                return;
            }
            string key = GetKey(action, aopInfo, baseKey);
            int    flag;                         //0 正常;1:未识别;2:不允许缓存

            SetBaseKeys(aopInfo, key, out flag); //存档Key,后续缓存失效 批量删除
            if (flag == 2)
            {
                return;                                                                     //
            }
            double cacheTime = Math.Abs(12 - DateTime.Now.Hour) * 60 + DateTime.Now.Second; //缓存中午或到夜里1点

            if (flag == 1 || aopInfo.PageIndex > 2)                                         // 后面的页数,缓存时间可以短一些
            {
                cacheTime = 2;                                                              //未知道操作何表时,只缓存2分钟(比如存储过程等语句)
            }
            switch (action)
            {
            case AopEnum.ExeMDataTableList:
                if (IsCanCache(aopInfo.TableList))
                {
                    JsonHelper js = new JsonHelper(false, false);
                    foreach (MDataTable table in aopInfo.TableList)
                    {
                        js.Add(Guid.NewGuid().ToString(), table.ToJson(true, true, RowOp.IgnoreNull));
                    }
                    js.AddBr();
                    _MemCache.Set(key, js.ToString(), cacheTime);
                }
                break;

            case AopEnum.Select:
            case AopEnum.ExeMDataTable:
                if (IsCanCache(aopInfo.Table))
                {
                    _MemCache.Set(key, aopInfo.Table.ToJson(true, true, RowOp.IgnoreNull), cacheTime);
                }
                break;

            case AopEnum.ExeScalar:
                _MemCache.Set(key, aopInfo.ExeResult, cacheTime);
                break;

            case AopEnum.Fill:
                _MemCache.Set(key, aopInfo.Row, cacheTime);
                break;

            case AopEnum.GetCount:
                _MemCache.Set(key, aopInfo.RowCount, cacheTime);
                break;
            }
        }
示例#24
0
        /// <summary>
        /// 显示历史性退回步骤列表
        /// </summary>
        /// <param name="nextActivitySetid"></param>
        private void GetRejectListRadioActivity(JsonHelper js)
        {
            Activity ai = WFContext.Activity;

            if (ai.RejectType == RejectType.None || WFContext.FormAction == FormAction.View || WFContext.TaskID == Guid.Empty || WFContext.TaskInstance.TaskSeq.Length <= 2)
            {
                return;
            }

            //查找可回退的步骤名和步骤ID 根据TaskSeq序列规则找出包含在当前TaskSeq的历史轨迹 可能会存在多个同一活动定义存在相同的用户
            IList <TaskInstance> listHistoryTask = WF.Table.TaskInstance.GetHistoryListByTaskID(WFContext.TaskInstance.TaskID, WFContext.InstanceID);
            //筛选出历史轨迹中的活动定义
            IList <Guid> rejectActivityIDs = listHistoryTask.Select(t => t.ActivityID).Distinct().ToList <Guid>();
            //必须在活动定义之前的历史
            IList <Guid> listPreActivityID = WF.History.GetBeforeActivtiyIDs(ai);

            rejectActivityIDs = rejectActivityIDs.Where(a => listPreActivityID.Contains(a)).ToList <Guid>();
            //排掉自己
            rejectActivityIDs = rejectActivityIDs.Where(a => a != ai.ActivityID).ToList <Guid>();

            //开始步骤的id
            Guid startActivityID = WFContext.DefinitionInfo.StartActivity.ActivityID;


            //进一步缩小筛选
            if (ai.RejectType == RejectType.OnlyPreActivity || ai.RejectType == RejectType.OnlyStartOrPreActivity)
            {
                //仅上一步、仅上一步或提单
                IList <Guid> preActivityIDlist = ai.PreTransitionList.Select(a => a.FromActivityID).ToList <Guid>();
                if (ai.RejectType == RejectType.OnlyPreActivity)
                {
                    rejectActivityIDs = rejectActivityIDs.Where(a => preActivityIDlist.Contains(a)).ToList <Guid>();
                }
                else if (ai.RejectType == RejectType.OnlyStartOrPreActivity)
                {
                    rejectActivityIDs = rejectActivityIDs.Where(a => preActivityIDlist.Contains(a) || a == startActivityID).ToList <Guid>();
                }
            }
            else if (ai.RejectType == RejectType.OnlyStart)
            {
                //仅提单
                rejectActivityIDs = rejectActivityIDs.Where(a => a == startActivityID).ToList <Guid>();
            }

            StringBuilder activityHtml = new StringBuilder();
            StringBuilder actorHtml    = new StringBuilder();

            if (rejectActivityIDs.Count() > 0)
            {
                //指定退回的步骤名
                IList <string> activityNames = new List <string>();
                if (!string.IsNullOrEmpty(WFContext.Activity.RejectActivity))
                {
                    activityNames = WFContext.Activity.RejectActivity.Split(',').ToList <string>();
                }
                foreach (Guid id in rejectActivityIDs)
                {
                    Activity a = WFContext.DefinitionInfo.ActivityList.FirstOrDefault(t => t.ActivityID == id);
                    if (activityNames.Count > 0 && !activityNames.Contains(a.ActivityName))
                    {
                        continue;
                    }
                    switch (a.ActivityType)
                    {
                    case ActivityType.Start:
                    case ActivityType.Normal:
                    case ActivityType.LoopSelf:    //只能退回常规节点。
                        break;

                    default:
                        continue;
                    }
                    activityHtml.Append(WF.Actor.GetActivityHtml(a, WFContext.Activity));
                    actorHtml.Append(WF.Actor.GetActorHtml(a, WFContext));

                    //activityHtml.Append(string.Format(" <li  activityid=\"{0}\" activitycode=\"{4}\"  activityname=\"{1}\"><input activityid=\"{0}\" activitycode=\"{4}\"  activityname=\"{1}\" activitytype=\"{2}\" flag=\"activity\" name=\"activityradio\" type=\"radio\"  IsUserRadio=\"{3}\"   />{1}</li>",
                    //    activity.ActivityID, activity.ActivityName, activity.ActivityType.ToString(), activity.RespondType== RespondType.One?"true":"false", string.IsNullOrWhiteSpace(activity.ActivityCode) ? activity.ActivityName : activity.ActivityCode));
                    //listUserTask = listHistoryTask.Where(ts => ts.ActivityID == theActivityID).ToList<TaskInstance>();


                    //actorHtml.AppendFormat("<div class='rejectActivityUserAreaTitle'  activityid=\"{1}\" activityname=\"{0}\">【{0}】处理人,已选(<span  activityid=\"{1}\" class='selectedCount'>0</span>)</div>", activity.ActivityName, activity.ActivityID);
                    //actorHtml.Append(string.Format("<ul activityid=\"{0}\" style=\"display:none\" flag=\"activityactor\" activityname=\"{1}\">", activity.ActivityID, activity.ActivityName));
                    //if (listUserTask.Count > 0)
                    //{

                    //    IList<string> users = listUserTask.Select(a => a.UserID).Distinct().ToList<string>();
                    //    IList<UserInfo> listUser = WF.User.GetByUserIDs(string.Join<string>(",", users));

                    //    actorHtml.Append(WF.Actor.GetActorHtml(listUser, activity));

                    //}
                    //else
                    //{
                    //    actorHtml.Append("<li style='color;red;'>无处理人,请与管理员联系!</li>");
                    //}
                }
            }
            else
            {
                activityHtml.Append("<ul>");
                activityHtml.Append("<li  style='color;red;'>无步骤可选择,请尝试刷新缓存!</li>");
                activityHtml.Append("</ul>");
            }
            activityHtml.Append(" </ul>");
            js.Add("rejectActivityHtml", activityHtml.ToString());
            js.Add("rejectActorHtml", actorHtml.ToString());
        }
示例#25
0
        public async Task <string> SendPasswordResetLink(string userNameOrEmail)
        {
            Models.SystemSettings settings;
            using (var session = DataService.OpenSession())
            {
                settings = session.QueryOver <Models.SystemSettings>().SingleOrDefault <Models.SystemSettings>();
            }

            if (settings == null)
            {
                throw new Exception("No system settings have been setup.");
            }

            var user = await UserManager.FindByNameAsync(userNameOrEmail) as User;

            if (user == null)
            {
                user = await UserManager.FindByEmailAsync(userNameOrEmail) as User;
            }

            var emailStatus = String.Empty;

            if (user != null)
            {
                var passwordResetLink = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                var myuri = new Uri(System.Web.HttpContext.Current.Request.Url.AbsoluteUri);

                var body = "Hi " + user.UserName;

                body += "\nA request has been made to reset your password on " + ApplicationSettings.GetApplicationName();

                body += "\n\nClick on the following link to reset your password:\n";

                var json = new JsonHelper();
                json.Add("userId", user.Id);
                json.Add("token", passwordResetLink);
                var parameters = Encryption.Encrypt(json.ToString(), ApplicationSettings.ApplicationPassPhrase);
                body += GetCurrentUrl() + "?anonAction=" + ((int)EventNumber.ResetPassword) + "&params=" + HttpUtility.UrlEncode(parameters);

                var mailMessage = new MailMessage(settings.EmailFromAddress, user.Email, "Password Reset", body);
                //mailMessage.From = new MailAddress("*****@*****.**", "Admin");

                var sendEmailTask = Task.Run(() =>
                {
                    try
                    {
                        var smtpClient = new SmtpClient(settings.EmailHost, settings.EmailPort);

                        var password              = Encryption.Decrypt(settings.EmailPassword, ApplicationSettings.ApplicationPassPhrase);
                        smtpClient.Credentials    = new System.Net.NetworkCredential(settings.EmailUserName, password);
                        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                        smtpClient.EnableSsl      = settings.EmailEnableSsl;

                        smtpClient.Send(mailMessage);

                        emailStatus = "If a user with username or email address exists then a password reset link will be sent to the user's registered email address.";
                    }
                    catch (Exception e)
                    {
                        var message = e.Message + "\n" + e.ToString();
                        emailStatus = message;
                    }
                });
                sendEmailTask.Wait();
            }
            else
            {
                return("No user found");
            }

            await Task.Delay(1000); // To prevent it being too obvious that a username/email address exists or does not.

            return(emailStatus);
        }