Exemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try {
                #region 建设单位信息
                T_Company_MDL companyMDL = new T_Company_MDL();

                companyMDL              = Comm.GetValueToObject(companyMDL, table_Company) as T_Company_MDL;
                companyMDL.CreateDate   = DateTime.Now;
                companyMDL.IsCompany    = true;
                companyMDL.CreateIP     = Common.DNTRequest.GetIP();
                companyMDL.CreateUserID = 0;//公司创建人

                int companyID = companyBLL.Add(companyMDL);
                #endregion

                if (companyID > 0)
                {
                    #region 项目信息
                    T_Construction_Project_MDL cpModel = new T_Construction_Project_MDL();
                    T_Construction_Project_BLL cpBll   = new T_Construction_Project_BLL();

                    cpModel.CompanyID = companyID;                     //所属单位
                    cpModel.xmmc      = xmmc.Text;                     //项目名称
                    cpModel.xmh       = string.Empty;                  //项目号
                    if (jgsj.Text.Length > 0)
                    {
                        cpModel.jgrq = Common.ConvertEx.ToDate(jgsj.Text);  //开工时间
                    }
                    cpModel.jgsj        = jgsj.Text;
                    cpModel.ProjectType = ProjectType.SelectValue;
                    int constructionProjectID = cpBll.Add(cpModel);
                    #endregion

                    #region 工程信息
                    T_SingleProject_MDL singleProjectMDL = new T_SingleProject_MDL();

                    singleProjectMDL                       = Comm.GetValueToObject(singleProjectMDL, tablemain) as T_SingleProject_MDL;
                    singleProjectMDL.AREA_CODE             = AREA_CODE.SelectValue;
                    singleProjectMDL.ConstructionProjectID = constructionProjectID;
                    singleProjectMDL.CreateDate            = DateTime.Now;
                    singleProjectMDL.Status                = 0;                      //初始为0,未分配
                    singleProjectMDL.jsdw                  = companyMDL.CompanyName; //建设单位,是当前单位
                    singleProjectMDL.gcdd                  = gcdd.Text.Trim();
                    singleProjectMDL.WorkFlow_DoStatus     = 0;

                    int singleProjectID = singleProjectBLL.Add(singleProjectMDL); //工程ID
                    UploadFile(singleProjectID);                                  //上传证书

                    #endregion

                    #region 用户信息 ,角色默认给先前定义好的建设单位角色
                    T_UsersInfo_MDL userMDL = new T_UsersInfo_MDL();
                    userMDL               = (T_UsersInfo_MDL)Comm.GetValueToObject(userMDL, tLoginInfo);
                    userMDL.RoleID        = roleBLL.GetRoleIdByRoleCode(SystemSet._ROLECODE_JSCOMPANY, singleProjectMDL.AREA_CODE);
                    userMDL.Passwd        = DESEncrypt.Encrypt(Passwd.Text);
                    userMDL.UserType      = SystemSet.EumUserType.CompanyUser.ToString();
                    userMDL.UserName      = userMDL.LoginName;
                    userMDL.CompanyID     = companyID;
                    userMDL.Createdate    = DateTime.Now;
                    userMDL.LastLoginTime = DateTime.Now;
                    userMDL.IsLeader      = true;
                    userMDL.IsValid       = false;
                    userMDL.Createdby     = "工程报建产生";
                    int userID = userBLL.Add(userMDL);
                    #endregion

                    #region 添加工程用户关联信息
                    PublicModel.AddSingleProjectUser(singleProjectID, userMDL.RoleID, userID);
                    #endregion

                    #region 添加工程公司关联信息
                    PublicModel.AddSingleProjectCompany(singleProjectID, companyID);
                    #endregion

                    #region 添加工程流程环节
                    new T_WorkFlowDefine_BLL().AddWorkFlowDefine(singleProjectID, singleProjectMDL.AREA_CODE);
                    #endregion

                    #region 更新工程表的 CompanyUserID为当前建设单位用户ID
                    singleProjectMDL = singleProjectBLL.GetModel(singleProjectID);
                    singleProjectMDL.CompanyUserID = userID;
                    singleProjectBLL.Update(singleProjectMDL);
                    #endregion

                    #region 报建完成提示信息
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "IsSuccess",
                                                                 "<script>"
                                                                 + " layer.alert('您已经成功注册,但您注册的信息,必需确认后才可以登录使用。请耐心等待,或致电:" + SystemSet._QUICKREGTEL + "', { btnAlign: 'c' }, function (i) {"
                                                                 + "     var index = parent.layer.getFrameIndex(window.name);"
                                                                 + "     parent.layer.close(index);"
                                                                 + "}); "
                                                                 + "</script>");
                    #endregion
                }
            } catch (Exception ex) {
                Common.LogUtil.Debug(this, "建设单位工程报建", ex);
                Common.MessageBox.FnLayerAlert(this.Page, "工程报建保存失败:" + ex.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string getUserInfo(HttpContext context)
        {
            try {
                if (context.Request.Form["username"] == null || context.Request.Form["password"] == null)
                {
                    return("账号或密码为空!");
                }

                T_UsersInfo_BLL userinfobll = new T_UsersInfo_BLL();

                string strPrivateKey = string.Empty;
                using (StreamReader reader = new StreamReader(context.Server.MapPath("/RsaKey/PrivateKey.xml"))) {
                    strPrivateKey = reader.ReadToEnd();
                }

                RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
                rsa.FromXmlString(strPrivateKey);

                byte[] result = rsa.Decrypt(UserLoginGather.HexStringToBytes(context.Request.Form["password"]), false);
                System.Text.ASCIIEncoding enc = new ASCIIEncoding();
                string rsaPwd = enc.GetString(result);

                string loginString = "UPPER(loginname)='" + Common.Common.SqlSafe(context.Request.Form["username"]).ToUpper()
                                     + "' and passwd='" + DESEncrypt.Encrypt(rsaPwd) + "' ";

                List <T_UsersInfo_MDL> userinfomdl = userinfobll.GetModelList(loginString);
                if (userinfomdl.Count > 0)
                {
                    if (userinfomdl[0].IsValid == true)
                    {
                        T_Company_BLL compBLL = new T_Company_BLL();
                        T_Company_MDL compMDL = compBLL.GetModel(userinfomdl[0].CompanyID);
                        if (compMDL != null)
                        {
                            context.Session["IsCompany"]     = compMDL.IsCompany.ToString().ToLower();
                            context.Session["CompanyName"]   = compMDL.CompanyName;
                            context.Session["OLD_AREA_CODE"] = compMDL.AREA_CODE;
                            context.Session["AREA_CODE"]     = "";
                            if (compMDL.IsCompany.ToString().ToLower() == "false")     //只有档案馆,需要区域信息,建设单位等都不要过虑
                            {
                                string myArea_Code    = compMDL.AREA_CODE;
                                string myArea_CodeNew = compMDL.AREA_CODE;
                                for (int i1 = myArea_Code.Length - 1; i1 > 0; i1--)
                                {
                                    if (myArea_Code[i1].ToString() == "0")
                                    {
                                        myArea_CodeNew = myArea_Code.Substring(0, i1);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                context.Session["AREA_CODE"] = myArea_CodeNew;
                            }
                            context.Session["CompanyType"] = compMDL.CompanyType;
                        }
                        else
                        {
                            return(SystemSet._RETURN_FAILURE_VALUE + ":单位信息不存在!");
                        }

                        BLL.T_SystemInfo_BLL   systemInfoBLL = new T_SystemInfo_BLL();
                        Model.T_SystemInfo_MDL systemInfoMDL = systemInfoBLL.GetModel(compMDL.CompanyType);
                        if (systemInfoMDL == null)
                        {
                            return(SystemSet._RETURN_FAILURE_VALUE + ":单位类型字典不存在!");
                        }

                        context.Session["CompanyTypeName"] = systemInfoMDL.SystemInfoName;
                        context.Session["CompanyTypeCode"] = systemInfoMDL.SystemInfoCode;
                        context.Session["SystemInfoID"]    = systemInfoMDL.SystemInfoID;
                        context.Session["MyParentID"]      = systemInfoMDL.ParentID;

                        context.Session["UserID"]       = userinfomdl[0].UserID;
                        context.Session["LoginName"]    = userinfomdl[0].LoginName;
                        context.Session["UserName"]     = userinfomdl[0].UserName;
                        context.Session["RoleID"]       = userinfomdl[0].RoleID;
                        context.Session["CompanyID"]    = userinfomdl[0].CompanyID;
                        context.Session["IsLeader"]     = userinfomdl[0].IsLeader;
                        context.Session["SuperAdmin"]   = userinfomdl[0].IsSuperAdmin;
                        context.Session["OwnerFileTmp"] = userinfomdl[0].OwnerFileTmp;         //外协单位用户

                        T_Role_MDL roleMDL = new T_Role_BLL().GetModel(userinfomdl[0].RoleID); //签章用
                        if (roleMDL != null)
                        {
                            context.Session["RoleName"] = roleMDL.RoleName;
                            context.Session["RoleCode"] = roleMDL.RoleCode;
                        }

                        TimeSpan ts      = new TimeSpan(8760, 0, 0);
                        DateTime expired = DateTime.Today.Add(ts);
                        HttpContext.Current.Response.Cookies["LoginName"].Value   = context.Server.UrlEncode(userinfomdl[0].LoginName);
                        HttpContext.Current.Response.Cookies["LoginName"].Expires = expired;

                        //修改最后登录时间
                        userinfomdl[0].LastLoginTime = DateTime.Now;
                        userinfobll.Update(userinfomdl[0]);

                        PublicModel.writeLog(SystemSet.EumLogType.LogIn.ToString(), ";用户登录系统");
                        return(SystemSet._RETURN_SUCCESS_VALUE);
                    }
                    else
                    {
                        return("如果您已经成功注册,请等待确认后再登录!");
                    }
                }
                else
                {
                    return("用户账号或密码错误!");
                }
            } catch (Exception ex) {
                Common.LogUtil.Debug(this, "用户登录BUG", ex);
                return("系统异常,请稍后再试");
            }
        }