コード例 #1
0
ファイル: Device.cs プロジェクト: radtek/EMIP
        public virtual PageResult GetDevicesList(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    uid     = request.GetString("uid", null);

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    if (String.IsNullOrEmpty(uid))
                    {
                        return(DeviceManager.GetDevices(provider, cn, null, request.GetSortString("LastLogin DESC"), request.Start, request.Limit));
                    }
                    else
                    {
                        return(DeviceManager.GetUserDevices(provider, cn, uid, null, request.GetSortString("LastLogin DESC"), request.Start, request.Limit));
                    }
                }
            }
        }
コード例 #2
0
        public virtual JObject GetTestingTemplates(HttpContext context)
        {
            string    loginAccount = YZAuthHelper.LoginUserAccount;
            YZRequest request      = new YZRequest(context);
            string    processName  = request.GetString("ProcessName", null);

            IYZDbProvider provider = YZDbProviderManager.DefaultProvider;

            //System.Threading.Thread.Sleep(2000);
            //获得数据
            BPMDraftCollection drafts = new BPMDraftCollection();
            int     rowcount          = 0;
            JObject rv = new JObject();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                if (!String.IsNullOrEmpty(processName))
                {
                    drafts = cn.GetTestingTemplates(processName, null, null, request.GetSortString("CreateDate DESC"), 0, Int32.MaxValue, out rowcount);
                }

                //将数据转化为Json集合
                rv[YZJsonProperty.total] = rowcount;

                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                foreach (BPMDraft draft in drafts)
                {
                    JObject item = new JObject();
                    children.Add(item);

                    item["DraftID"]      = draft.DraftGuid.ToString();
                    item["ProcessName"]  = draft.ProcessName;
                    item["CreateDate"]   = draft.CreateDate;
                    item["ModifyDate"]   = draft.ModifyDate;
                    item["Account"]      = draft.Account;
                    item["OwnerAccount"] = draft.OwnerAccount;
                    item["Comments"]     = draft.Comments;
                    item["Description"]  = draft.Description;
                    if (!NameCompare.EquName(draft.OwnerAccount, loginAccount))
                    {
                        item["Owner"] = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID);
                    }
                }
            }

            return(rv);
        }
コード例 #3
0
        public virtual JObject GetDrafts(HttpContext context)
        {
            YZRequest    request      = new YZRequest(context);
            string       loginAccount = YZAuthHelper.LoginUserAccount;
            GridPageInfo gridPageInfo = new GridPageInfo(context);

            //System.Threading.Thread.Sleep(2000);
            //获得数据
            BPMDraftCollection drafts = new BPMDraftCollection();
            int     rowcount;
            JObject rv = new JObject();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                drafts = cn.GetMyDrafts(DraftType.Draft, null, request.GetSortString("CreateDate DESC"), gridPageInfo.Start, gridPageInfo.Limit, out rowcount);

                //将数据转化为Json集合
                rv[YZJsonProperty.total] = rowcount;

                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                foreach (BPMDraft draft in drafts)
                {
                    JObject item = new JObject();
                    children.Add(item);

                    item["DraftID"]      = draft.DraftGuid.ToString();
                    item["ProcessName"]  = draft.ProcessName;
                    item["CreateDate"]   = draft.CreateDate;
                    item["ModifyDate"]   = draft.ModifyDate;
                    item["Account"]      = draft.Account;
                    item["OwnerAccount"] = draft.OwnerAccount;
                    item["Comments"]     = draft.Comments;
                    item["Description"]  = draft.Description;
                    if (!NameCompare.EquName(draft.OwnerAccount, loginAccount))
                    {
                        item["Owner"] = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID);
                    }
                }
            }

            //输出数据
            return(rv);
        }
コード例 #4
0
        public virtual object GetOnlineUsers(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            //获得数据
            ActiveUserCollection activeUsers = new ActiveUserCollection();
            int rowcount;
            int allOnlineUserCount = 0;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                activeUsers        = LoginManager.GetActiveUsers(cn, 1200, null, request.GetSortString("LastActiveDate DESC"), request.Start, request.Limit, out rowcount);
                allOnlineUserCount = LoginManager.GetActiveUserCount(cn, 1200);
            }

            List <object> data = new List <object>();

            foreach (ActiveUser user in activeUsers)
            {
                data.Add(
                    new
                {
                    Account        = user.Account,
                    DisplayName    = user.DisplayName,
                    OfficePhone    = user.OfficePhone,
                    EMail          = user.EMail,
                    LastActiveDate = user.LastActiveDate
                }
                    );
            }

            return(new
            {
                success = true,
                total = rowcount,
                allOnlineUserCount = allOnlineUserCount,
                children = data
            });
        }
コード例 #5
0
        public virtual object GetAppLog(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            BPMObjectNameCollection sids;

            using (BPMConnection bpmcn = new BPMConnection())
            {
                bpmcn.WebOpen();
                sids = bpmcn.Token.SIDs;
            }

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    return(LogManager.GetLog(provider, cn, sids, request.GetDateTime("Date"), this.GetFilterString(request, provider), request.GetSortString("LogDate DESC"), request.Start, request.Limit));
                }
            }
        }
コード例 #6
0
        public virtual object GetSystemUsers(HttpContext context)
        {
            YZRequest     request  = new YZRequest(context);
            IYZDbProvider provider = YZDbProviderManager.DefaultProvider;

            //获得数据
            ActiveUserCollection activeUsers = new ActiveUserCollection();
            int rowcount;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                activeUsers = LoginManager.GetSystemUsers(cn, 30, this.GetFilterStringSystemUsers(request, provider), request.GetSortString("LastActiveDate DESC"), request.Start, request.Limit, out rowcount);
            }

            List <object> data = new List <object>();

            foreach (ActiveUser user in activeUsers)
            {
                data.Add(
                    new
                {
                    Account        = user.Account,
                    DisplayName    = user.DisplayName,
                    OfficePhone    = user.OfficePhone,
                    EMail          = user.EMail,
                    LastActiveDate = user.LastActiveDate
                }
                    );
            }

            return(new
            {
                success = true,
                total = rowcount,
                children = data
            });
        }
コード例 #7
0
        protected virtual JObject InternalGetShareTasks(string uid, HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    path    = request.GetString("path", null);

            IYZDbProvider provider = YZDbProviderManager.DefaultProvider;

            //获得数据
            BPMTaskListCollection tasks = new BPMTaskListCollection();
            int rowcount;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                tasks = cn.GetShareTaskList(path, uid, this.GetFilterStringWorklist(request, provider), request.GetSortString("StepID DESC", null, "StepID DESC"), request.Start, request.Limit, out rowcount);
            }

            //将数据转化为Json集合
            JObject rv = new JObject();

            rv[YZJsonProperty.total] = rowcount;

            JArray children = new JArray();

            rv[YZJsonProperty.children] = children;

            foreach (BPMTaskListItem task in tasks)
            {
                JObject item = new JObject();
                children.Add(item);

                item["StepID"]                 = task.StepID;
                item["TaskID"]                 = task.TaskID;
                item["SerialNum"]              = task.SerialNum;
                item["ProcessName"]            = task.ProcessName;
                item["ProcessVersion"]         = task.ProcessVersion.ToString(2);
                item["OwnerAccount"]           = task.OwnerAccount;
                item["OwnerDisplayName"]       = task.OwnerFullName;
                item["AgentAccount"]           = task.AgentAccount;
                item["AgentDisplayName"]       = task.AgentFullName;
                item["CreateAt"]               = task.CreateAt;
                item["NodeName"]               = task.StepName;
                item["ReceiveAt"]              = task.ReceiveAt;
                item["Share"]                  = task.Share;
                item["State"]                  = task.TaskState.ToString();
                item["TimeoutFirstNotifyDate"] = task.TimeoutFirstNotifyDate;
                item["TimeoutDeadline"]        = task.TimeoutDeadline;
                item["TimeoutNotifyCount"]     = task.TimeoutNotifyCount;
                item["Description"]            = String.IsNullOrEmpty(task.Description) ? Resources.YZStrings.All_None : task.Description;
            }

            return(rv);
        }
コード例 #8
0
        protected virtual JObject InternalGetWorkList(string uid, HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    path    = request.GetString("path", null);

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                //获得数据
                BPMTaskListCollection tasks = new BPMTaskListCollection();
                int rowcount;

                JObject rv = new JObject();
                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();

                    tasks = cn.GetTaskList(path, uid, this.GetFilterStringWorklist(request, provider), request.GetSortString("StepID DESC", null, "StepID DESC"), request.Start, request.Limit, out rowcount);
                    rv    = this.Serialize(cn, tasks, rowcount);
                }

                return(rv);
            }
        }
コード例 #9
0
        public virtual object GetTimeoutMonitorWorklist(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    path    = request.GetString("path", null);

            //获得数据
            BPMTaskListCollection tasks = new BPMTaskListCollection();
            int     rowcount;
            JObject rv = new JObject();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                {
                    tasks = cn.GetTaskList(path, null, this.GetTimeoutMonitorWorklistFilterString(request, provider), request.GetSortString("Progress DESC"), request.Start, request.Limit, out rowcount);
                }

                rv = this.Serialize(cn, tasks, rowcount);
            }

            return(rv);
        }
コード例 #10
0
        public virtual object GetHandoverRequests(HttpContext context)
        {
            YZRequest  request = new YZRequest(context);
            string     uid     = request.GetString("uid");
            PageResult result;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    result = TaskListManager.GetHandoverMyRequests(provider, cn, uid, this.GetFilterStringHandoverRequests(request, provider), request.GetSortString("TaskID ASC"), request.Start, request.Limit);
                }
            }

            JArray children = new JArray();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                foreach (DataRow task in result.Table.Rows)
                {
                    JObject item = new JObject();
                    children.Add(item);

                    int    taskid       = YZConvert.ToInt32(task["TaskID"]);
                    string desc         = YZConvert.ToString(task["Description"]);
                    string ownerAccount = YZConvert.ToString(task["OwnerAccount"]);
                    string agentAccount = YZConvert.ToString(task["AgentAccount"]);

                    User owner = User.TryGetUser(cn, ownerAccount);
                    User agent = null;

                    if (!String.IsNullOrEmpty(agentAccount))
                    {
                        agent = User.TryGetUser(cn, agentAccount);
                    }

                    item["TaskID"]           = taskid;
                    item["SerialNum"]        = YZConvert.ToString(task["SerialNum"]);
                    item["ProcessName"]      = YZConvert.ToString(task["ProcessName"]);
                    item["ProcessVersion"]   = YZConvert.ToString(task["ProcessVersion"]);
                    item["OwnerAccount"]     = ownerAccount;
                    item["OwnerDisplayName"] = owner == null ? ownerAccount : owner.ShortName;
                    item["AgentAccount"]     = agentAccount;
                    item["AgentDisplayName"] = agent == null ? agentAccount : agent.ShortName;
                    item["CreateAt"]         = YZConvert.ToDateTime(task["CreateAt"]);
                    item["State"]            = YZJsonHelper.GetTaskStateJObject(cn, YZConvert.ToEnum <TaskState>(task["State"]), taskid);
                    item["Description"]      = String.IsNullOrEmpty(desc) ? Resources.YZStrings.All_None : desc;
                }
            }

            return(new
            {
                success = true,
                total = result.TotalRows,
                children = children
            });
        }
コード例 #11
0
        public virtual JObject GetHistoryTasks(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            GridPageInfo    gridPageInfo = new GridPageInfo(context);
            HistoryTaskType taskType     = request.GetEnum <HistoryTaskType>("HistoryTaskType", HistoryTaskType.AllAccessable);
            string          strTaskType  = request.GetString("HistoryTaskType");
            int             year         = request.GetString("byYear", "1") == "0" ? -1 : request.GetInt32("Year");

            //获得数据
            JObject rv = new JObject();

            string taskTableFilter;
            string stepTableFilter;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                taskTableFilter = this.GetFilterStringHistoryTaskTaskTable(request, provider);
                stepTableFilter = this.GetFilterStringHistoryTaskStep(request, provider);
            }

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                int rowcount;
                BPMTaskCollection tasks = cn.GetHistoryTasks(year, taskType, taskTableFilter, stepTableFilter, request.GetSortString("TaskID DESC", null, "TaskID DESC"), gridPageInfo.Start, gridPageInfo.Limit, out rowcount);

                rv[YZJsonProperty.total] = rowcount;
                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                foreach (BPMTask task in tasks)
                {
                    JObject item = new JObject();
                    children.Add(item);

                    item["TaskID"]           = task.TaskID;
                    item["SerialNum"]        = task.SerialNum;
                    item["ProcessName"]      = task.ProcessName;
                    item["ProcessVersion"]   = task.ProcessVersion.ToString(2);
                    item["OwnerAccount"]     = task.OwnerAccount;
                    item["OwnerDisplayName"] = task.OwnerFullName;
                    item["AgentAccount"]     = task.AgentAccount;
                    item["AgentDisplayName"] = task.AgentFullName;
                    item["CreateAt"]         = task.CreateAt;
                    item["State"]            = YZJsonHelper.GetTaskStateJObject(cn, task.TaskState, task.TaskID);
                    item["Description"]      = String.IsNullOrEmpty(task.Description) ? Resources.YZStrings.All_None : task.Description;
                }
            }

            return(rv);
        }
コード例 #12
0
        public virtual JObject GetReportData(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            string    path       = request.GetString("path");
            string    viewName   = request.GetString("viewName", null);
            string    outputType = request.GetString("outputType", "");
            YZClientParamCollection runtimeParams = JArray.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(request.GetString("params", YZJsonHelper.Base64EmptyJArray)))).ToObject <YZClientParamCollection>();

            //获得数据
            Report     report;
            ReportView view;
            DataTable  dataTable;
            int        rowcount;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                //获得报表定义
                report = Report.Open(cn, path);
                if (String.IsNullOrEmpty(viewName))
                {
                    view = report.DefaultView;
                }
                else
                {
                    view = report.Views.TryGetItem(viewName);
                }

                string srcdata = request.GetString("srcdata", null);
                if (String.IsNullOrEmpty(srcdata))
                {
                    BPMDBParameterCollection selectParameters = report.QueryParameters.CreateNullDBParameters();

                    //应用查询条件
                    foreach (BPMDBParameter selectParam in selectParameters)
                    {
                        YZClientParam clientParam = runtimeParams.TryGetItem(selectParam.Name);
                        if (clientParam != null && clientParam.value != null)
                        {
                            selectParam.Value = clientParam.value;
                        }
                    }

                    cn.RequestParams["sortstring"] = request.GetSortString("");
                    cn.UpdateRequestParams();

                    //获得数据
                    FlowDataTable ftable = new FlowDataTable();
                    ftable.Load(cn, BPMCommandType.Report, path, selectParameters, report.ClientCursor, request.Start, request.Limit, out rowcount);
                    dataTable = ftable.ToDataTable();
                }
                else
                {
                    dataTable = JArray.Parse(Encoding.UTF8.GetString(Convert.FromBase64String(srcdata))).ToObject <DataTable>();
                    rowcount  = request.GetInt32("total");
                }
            }

            //将数据转化为Json集合
            JObject rv = new JObject();

            rv[YZJsonProperty.total] = rowcount;
            rv["srcdata"]            = Convert.ToBase64String(Encoding.UTF8.GetBytes(JArray.FromObject(dataTable).ToString(Formatting.None, YZJsonHelper.Converters)));

            JArray children = new JArray();

            rv.Add("children", children);

            //不管是什么view都要给数据
            foreach (DataRow row in dataTable.Rows)
            {
                JObject item = new JObject();
                children.Add(item);

                foreach (DataColumn column in dataTable.Columns)
                {
                    object value = row[column.ColumnName];
                    item[column.ColumnName] = JToken.FromObject(value);

                    if (NameCompare.EquName(column.ColumnName, "TaskID") && (value is int))
                    {
                        item["Token"] = YZSecurityHelper.GenTaskAccessToken((int)value);
                    }

                    //为任务链接生成Token
                    ReportColumnInfo colInfo = report.ReportColumnInfos.TryGetItem(column.ColumnName);
                    if (colInfo != null && colInfo.LinkType == ReportLinkType.Task)
                    {
                        ParameterFill paramFill = colInfo.ParametersFill.TryGetItem("@TaskID");
                        if (paramFill != null)
                        {
                            int linktoTaskID;
                            if (Int32.TryParse(Convert.ToString(row[paramFill.FillWith]), out linktoTaskID))
                            {
                                item[column.ColumnName + "Token"] = YZSecurityHelper.GenTaskAccessToken((int)linktoTaskID);
                            }
                        }
                    }
                }
            }

            if (String.Compare(outputType, "Export", true) != 0)
            {
                if (view is ReportMSChartView)
                {
                    this.ApplyMSChartData(request, rv, view as ReportMSChartView, dataTable);
                }

                if (view is ReportExcelView)
                {
                    this.ApplyExcelData(request, rv, view as ReportExcelView, dataTable, runtimeParams);
                }
            }

            return(rv);
        }