示例#1
0
        /// <summary>
        /// 登录方法
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="userPwd"></param>
        /// <returns></returns>
        public COUserIdentity Login(string loginName, string userPwd, CPEnum.DeviceTypeEnum device, ref string errorMsg)
        {
            COUser user = this.GetUserByLoginName(loginName, false, false);

            if (user == null)
            {
                errorMsg = "不存在登录名为[" + loginName + "]的用户,请重新输入!";
                return(null);
            }
            if (user.UserPwd.Equals(this.UserPwdEncrypt(userPwd), StringComparison.CurrentCultureIgnoreCase) == false)
            {
                errorMsg = "登录名或密码不对,请重新输入!";
                return(null);
            }
            Guid gId = Guid.NewGuid();
            bool b   = this.AddUserIdentity(user.Id, gId, device);

            if (b)
            {
                //记录登录日志
                CPLogHelper.Instance().AddLog(user.Id, user.UserName, device, user.UserName + "登录成功!", "用户登录");
                COUserIdentity userIden = this.GetUserIdentity(gId);
                this.AddUserSession(userIden, user);
                return(userIden);
            }
            else
            {
                errorMsg = "写入登录标识时出错!";
                return(null);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="userName">用户姓名</param>
        /// <param name="device">设备类型</param>
        /// <param name="operRemark">日志内容</param>
        /// <param name="operType">日志类型</param>
        /// <returns></returns>
        public bool AddLog(int userId, string userName, CPEnum.DeviceTypeEnum device, string operRemark, string operType)
        {
            CPLog log = new CPLog();

            log.UserId     = userId;
            log.UserName   = userName;
            log.OperTime   = DateTime.Now;
            log.OperDevice = device;
            log.OperRemark = operRemark;
            log.OperType   = operType;
            log.OperIP     = "";
            try
            {
                //获取操作IP
                log.OperIP = CPAppContext.GetClientIP();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            log.OperUrl = "";
            try
            {
                //获取办理页面地址
                log.OperUrl = CPAppContext.GetHttpContext().Request.Path;
            }
            catch (Exception ex)
            {
            }
            return(this._CPLogRep.Add(log) > 0 ? true : false);
        }
示例#3
0
文件: CPEnum.cs 项目: vebin/qMISPlat
 public static CPEnum.DeviceTypeEnum ConvertDeviceTypeEnum(int n)
 {
     CPEnum.DeviceTypeEnum type = CPEnum.DeviceTypeEnum.PCBrowser;
     foreach (int nIndex in Enum.GetValues(typeof(CPEnum.DeviceTypeEnum)))
     {
         if (nIndex.Equals(n))
         {
             type = (CPEnum.DeviceTypeEnum)Enum.Parse(typeof(CPEnum.DeviceTypeEnum), n.ToString());
             break;
         }
     }
     return(type);
 }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="userName">用户姓名</param>
        /// <param name="device">设备类型</param>
        /// <param name="operRemark">日志内容</param>
        /// <param name="operType">日志类型</param>
        /// <param name="operIP">用户操作IP</param>
        /// <param name="operUrl">用户操作页面URL</param>
        /// <returns></returns>
        public bool AddLog(int userId, string userName, CPEnum.DeviceTypeEnum device, string operRemark, string operType, string operUrl, string operIP)
        {
            CPLog log = new CPLog();

            log.UserId     = userId;
            log.UserName   = userName;
            log.OperTime   = DateTime.Now;
            log.OperDevice = device;
            log.OperRemark = operRemark;
            log.OperType   = operType;
            log.OperIP     = operIP;
            log.OperUrl    = operUrl;
            return(this._CPLogRep.Add(log) > 0 ? true : false);
        }
示例#5
0
        public bool AddUserIdentity(int userId, Guid userKey, CPEnum.DeviceTypeEnum deviceType)
        {
            //删除过期的数据
            this._COUserIdentityRep.DeleteOverdueKey();
            COUserIdentity iden = new Domain.COUserIdentity()
            {
                UserId      = userId,
                UserKey     = userKey,
                LoginTime   = DateTime.Now,
                LoginDevice = deviceType
            };

            return(this._COUserIdentityRep.Add(iden) > 0 ? true : false);
        }
示例#6
0
        private string GetControlHtml(string tableField, CPForm form, List <CPFormField> fieldCol, CPFormView view,
                                      List <CPFormFieldRight> fieldRightCol, CPEnum.DeviceTypeEnum curDeviceType
                                      , bool isView)
        {
            tableField = tableField.Replace("{@", "").Replace("@}", "");
            string[]    fArray   = tableField.Split('.');
            CPFormField curField = null;

            fieldCol.ForEach(t => {
                if (t.TableName.Equals(fArray[0], StringComparison.CurrentCultureIgnoreCase) &&
                    t.FieldName.Equals(fArray[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    curField = t;
                    return;
                }
            });
            if (curField == null)
            {
                return("未找到字段【" + tableField + "】");
            }
            CPFormFieldRight         fieldRight = null;
            IList <CPFormFieldRight> rCol       = fieldRightCol.Where(c => c.FieldId.Equals(curField.Id)).ToList();

            if (rCol.Count > 0)
            {
                fieldRight = rCol[0];
            }
            bool isMainTable = true;

            if (fArray[0].Equals(form.MainTableName, StringComparison.CurrentCultureIgnoreCase) == false)
            {
                isMainTable = false;
            }
            if (isView)
            {
                if (curField.FieldStatus == CPFormEnum.FieldStatusEnum.Edit)
                {
                    curField.FieldStatus = CPFormEnum.FieldStatusEnum.Read;
                }
            }
            return(ICPFormControlManager.GetControlInstance(curField).FormatHtml(curField, fieldRight, isMainTable ? false : true));
        }
示例#7
0
        public string FormatFormViewHtml(CPForm form, List <CPFormField> fieldCol, CPFormView view,
                                         List <CPFormFieldRight> fieldRightCol, CPEnum.DeviceTypeEnum curDeviceType, bool isRealCreateControlHtml
                                         , bool isView)
        {
            StringBuilder sbHTML = new StringBuilder();

            if (fieldRightCol == null)
            {
                fieldRightCol = new List <CPFormFieldRight>();
            }
            if (view.ViewType == CPFormEnum.ViewTypeEnum.TwoColumn ||
                view.ViewType == CPFormEnum.ViewTypeEnum.OneColumn)
            {
                #region 内置布局,一行四列式或一行两列式
                if (view.ViewType == CPFormEnum.ViewTypeEnum.OneColumn)
                {
                    //改成通栏展现,即变成 一行两列式
                    view.ViewFieldCol.ForEach(t => {
                        t.IsSpanAll = true;
                    });
                }
                //先取出主表的和包括子拓展表的字段
                List <CPFormField> mainTableField = fieldCol.Where(t => t.TableName.Equals(form.MainTableName) || t.IsChildTable.Value).ToList();
                List <int>         fieidCol       = new List <int>();
                mainTableField.ForEach(t => { fieidCol.Add(t.Id); });
                //转化成视图中的字段
                List <CPFormViewField> mainTableFormViewField = view.ViewFieldCol.Where(c => fieidCol.Contains(c.FieldId)).ToList();
                string mainHTML = this.FormatOneTableHTML(form, fieldCol, view, mainTableFormViewField,
                                                          fieldRightCol, curDeviceType, 4, true, isRealCreateControlHtml, isView);
                //再看看子表的
                if (form.ChildTableCol != null && form.ChildTableCol.Count > 0)
                {
                    form.ChildTableCol.ForEach(cTable => {
                        List <CPFormField> cTableField = fieldCol.Where(t => t.TableName.Equals(cTable.TableName) && t.IsChildTable.Value == false).ToList();
                        fieidCol.Clear();
                        cTableField.ForEach(t => { fieidCol.Add(t.Id); });
                        //转化成视图中的字段
                        List <CPFormViewField> cTableFormViewField = view.ViewFieldCol.Where(c => fieidCol.Contains(c.FieldId)).ToList();
                        string cHTML = this.FormatOneTableHTML(form, fieldCol, view, cTableFormViewField,
                                                               fieldRightCol, curDeviceType, 4, false, isRealCreateControlHtml, isView);
                        mainHTML = mainHTML.Replace("{@" + cTable.TableName + "@}", cHTML);
                    });
                }
                sbHTML.Append(mainHTML);
                #endregion
            }

            else if (view.ViewType == CPFormEnum.ViewTypeEnum.TextEditor)
            {
                #region 编辑器布局
                string          sHtml      = view.FormViewHTML;
                string          regexConst = @"{\@[\s\S]*?\@}";
                Regex           re         = new Regex(regexConst, RegexOptions.IgnoreCase);
                MatchCollection matches    = re.Matches(sHtml);
                foreach (Match match in matches)
                {
                    sHtml = sHtml.Replace(match.Value, this.GetControlHtml(match.Value, form, fieldCol, view, fieldRightCol,
                                                                           curDeviceType, isView));
                }
                sbHTML.Append(sHtml);
                if (form.ChildTableCol.Count <= 0)
                {
                    string sHtml2 = @"<select   id='CPForm_TmpHideSelect'     style='width:0px;display:none;' ";
                    sHtml2 += @"<option value='{{selectItem.valueEx}}' ng-repeat='selectItem in FormObj.Data.CPFormTmpHideSelectTable track by $index'  on-Repeat-Finished-Render >{{selectItem.textEx}}</option>";
                    sHtml2 += " />";

                    sbHTML.Append("<div>" + sHtml2 + "</div>");
                }
                #endregion
            }
            return(sbHTML.ToString());
        }
示例#8
0
        private string FormatOneTableHTML(CPForm form, List <CPFormField> fieldCol, CPFormView view, List <CPFormViewField> viewFieldCol,
                                          List <CPFormFieldRight> fieldRightCol,
                                          CPEnum.DeviceTypeEnum curDeviceType, int oneRowColumn, bool isMainTable, bool isRealCreateControlHtml, bool isView)
        {
            StringBuilder          sbHTML      = new StringBuilder();
            List <CPFormViewField> tmpFieldCol = viewFieldCol.OrderBy(t => t.ShowOrder).ToList();

            #region 内置布局,按table方式
            if (curDeviceType == CPEnum.DeviceTypeEnum.PCBrowser)
            {
                StringBuilder sbHidden = new StringBuilder();
                sbHTML.Append("<table  border=\"0\" style='width:99%;' align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tbody>");
                if (isMainTable)
                {
                    //如果没有拓展表,则自动构建一个隐藏的下拉列表,用来解决没有ng-repeat,不能执行ngRepeatFinished事件的问题
                    if (form.ChildTableCol.Count <= 0)
                    {
                        if (isRealCreateControlHtml)
                        {
                            string sHtml = @"<select   id='CPForm_TmpHideSelect'     style='width:0px;display:none;' ";
                            sHtml += @"<option value='{{selectItem.valueEx}}' ng-repeat='selectItem in FormObj.Data.CPFormTmpHideSelectTable track by $index'  on-Repeat-Finished-Render >{{selectItem.textEx}}</option>";
                            sHtml += " />";

                            sbHTML.Append("<tr><td colspan='" + oneRowColumn + "' class='trHeader'>" + form.FormTitle + sHtml + "</td></tr>");
                        }
                    }
                    else
                    {
                        sbHTML.Append("<tr><td colspan='" + oneRowColumn + "' class='trHeader'>" + form.FormTitle + "</td></tr>");
                    }
                }
                int  curRowIndex = 0;
                bool lastIsTrEnd = false;
                tmpFieldCol.ForEach(t => {
                    IList <CPFormField> tmpCol = fieldCol.Where(c => c.Id.Equals(t.FieldId)).ToList();
                    if (tmpCol.Count <= 0)
                    {
                        return;
                    }
                    CPFormFieldRight fieldRight   = null;
                    IList <CPFormFieldRight> rCol = fieldRightCol.Where(c => c.FieldId.Equals(t.FieldId)).ToList();
                    if (rCol.Count > 0)
                    {
                        fieldRight = rCol[0];
                    }
                    if (tmpCol[0].FieldStatus == CPFormEnum.FieldStatusEnum.Hidden)
                    {
                        string controlHtml = "";
                        if (isRealCreateControlHtml)
                        {
                            if (isView)
                            {
                                if (tmpCol[0].FieldStatus == CPFormEnum.FieldStatusEnum.Edit)
                                {
                                    tmpCol[0].FieldStatus = CPFormEnum.FieldStatusEnum.Read;
                                }
                            }
                            controlHtml = ICPFormControlManager.GetControlInstance(tmpCol[0]).FormatHtml(tmpCol[0], fieldRight, isMainTable ? false : true);
                        }
                        else
                        {
                            controlHtml = "{@" + tmpCol[0].TableName + "." + tmpCol[0].FieldName + "@}";
                        }
                        sbHidden.Append(controlHtml);
                        return;
                    }
                    if (tmpCol[0].ControlType == CPFormEnum.ControlTypeEnum.ChildTableExtend)
                    {
                        #region 子表
                        if (lastIsTrEnd == false)
                        {
                            sbHTML.Append("<td class='tdLeft'></td><td class='tdRight'></td></tr>");
                        }
                        sbHTML.Append("<tr><td colspan='" + oneRowColumn + "' class='trHeader'><div class='ChildTableHeaderLeft'>" + tmpCol[0].FieldTitle + "</div><div  class='ChildTableHeaderRight'><input type='button' id='btnCPFormAddChildRow_" + tmpCol[0].TableName + "'  class='btnExtendTableAdd'  ng-click=\"CPFormAddChildRow('btnCPFormAddChildRow_" + tmpCol[0].TableName + "',true)\"  data-TableName='" + tmpCol[0].TableName + "'  value='添加'/></div></td></tr>");
                        sbHTML.Append("<tr   ng-repeat='item in FormObj.Data." + tmpCol[0].TableName + "' on-Repeat-Finished-Render  id=\"trCPFormExtendTable_" + tmpCol[0].TableName + "\"  ><td colspan='" + oneRowColumn + "' class='CPFormExtendTableTdCss' >");
                        sbHTML.Append("{@" + tmpCol[0].FieldName + "@}");//最后统一替换
                        sbHTML.Append("</td></tr>");
                        curRowIndex = 0;
                        lastIsTrEnd = true;
                        #endregion
                    }
                    else
                    {
                        #region 非子表
                        string notNull = "";
                        if (tmpCol[0].IsAllowNull.Value == false)
                        {
                            notNull = "<span  class='NotAllowNullCss'>*</span>";
                        }
                        if (t.IsSpanAll.Value)
                        {
                            #region 通栏展现
                            if (lastIsTrEnd == false && curRowIndex != 0)
                            {
                                sbHTML.Append("<td class='tdLeft' style='width:" + tmpCol[0].FieldTitleShowWidth + "%'></td>");
                                sbHTML.Append("<td class='tdRight' style='width:" + (50 - tmpCol[0].FieldTitleShowWidth) + "%;' ></td>");
                                sbHTML.Append("</tr>");
                            }
                            sbHTML.Append("<tr>");
                            sbHTML.Append("<td class='tdLeft' style='width:" + tmpCol[0].FieldTitleShowWidth + "%'>" + tmpCol[0].FieldTitle + ":" + notNull + "</td>");
                            string controlHtml = "";
                            if (isRealCreateControlHtml)
                            {
                                if (isView)
                                {
                                    if (tmpCol[0].FieldStatus == CPFormEnum.FieldStatusEnum.Edit)
                                    {
                                        tmpCol[0].FieldStatus = CPFormEnum.FieldStatusEnum.Read;
                                    }
                                }
                                controlHtml = ICPFormControlManager.GetControlInstance(tmpCol[0]).FormatHtml(tmpCol[0], fieldRight, isMainTable ? false : true);
                            }
                            else
                            {
                                controlHtml = "{@" + tmpCol[0].TableName + "." + tmpCol[0].FieldName + "@}";
                            }
                            sbHTML.Append("<td class='tdRight' style='width:" + (100 - tmpCol[0].FieldTitleShowWidth) + "%;'  colspan='" + (oneRowColumn - 1) + "'>" + controlHtml + "</td>");
                            sbHTML.Append("</tr>");
                            curRowIndex = 0;
                            lastIsTrEnd = true;
                            #endregion
                        }
                        else
                        {
                            #region 非通栏展现
                            if (curRowIndex == 0)
                            {
                                sbHTML.Append("<tr>");
                                lastIsTrEnd = false;
                            }

                            sbHTML.Append("<td class='tdLeft' style='width:" + tmpCol[0].FieldTitleShowWidth + "%'>" + tmpCol[0].FieldTitle + ":" + notNull + "</td>");
                            string controlHtml = "";
                            if (isRealCreateControlHtml)
                            {
                                if (isView)
                                {
                                    if (tmpCol[0].FieldStatus == CPFormEnum.FieldStatusEnum.Edit)
                                    {
                                        tmpCol[0].FieldStatus = CPFormEnum.FieldStatusEnum.Read;
                                    }
                                }
                                controlHtml = ICPFormControlManager.GetControlInstance(tmpCol[0]).FormatHtml(tmpCol[0], fieldRight, isMainTable ? false : true);
                            }
                            else
                            {
                                controlHtml = "{@" + tmpCol[0].TableName + "." + tmpCol[0].FieldName + "@}";
                            }
                            sbHTML.Append("<td class='tdRight' style='width:" + (50 - tmpCol[0].FieldTitleShowWidth) + "%;' >" + controlHtml + "</td>");
                            curRowIndex++;
                            if (curRowIndex >= 2)
                            {
                                sbHTML.Append("</tr>");
                                curRowIndex = 0;
                                lastIsTrEnd = true;
                            }
                            #endregion
                        }
                        #endregion
                    }
                });
                if (lastIsTrEnd == false)
                {
                    sbHTML.Append("<td class='tdLeft'></td><td class='tdRight'></td></tr>");
                }
                if (sbHidden.Length > 0)
                {
                    sbHTML.Append("<tr ><td colspan='" + oneRowColumn + "' >");
                    sbHTML.Append(sbHidden);
                    sbHTML.Append("</td></tr>");
                }
                if (isMainTable == false)
                {//拓展表,最后加一行空白作为分隔
                    sbHTML.Append("<tr ><td colspan='" + oneRowColumn + "' class='trExtendTableLastRow' >");
                    sbHTML.Append("</td></tr>");
                }

                sbHTML.Append("</tbody></table>");
            }

            #endregion
            return(sbHTML.ToString());
        }