using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using BP.DA;
using BP.Difference;
using BP.Sys;
using BP.Web;
using BP.Port;
using BP.En;
using BP.WF;
using BP.WF.Template;
namespace BP.Cloud.HttpHandler
{
///
/// 页面功能实体
///
public class Portal_SaaS : BP.WF.HttpHandler.DirectoryPageBase
{
///
/// 构造函数
///
public Portal_SaaS()
{
}
public string EmpDepts_Init()
{
String empNo = this.FK_Emp;
if (DataType.IsNullOrEmpty(empNo) == true)
return "err@参数FK_Emp不能为空";
Emp emp = new Emp();
emp.No = empNo;
emp.Retrieve();
DataSet ds = new DataSet();
string dbstr = SystemConfig.AppCenterDBVarStr;
//获取当前人员所在的部门及兼职部门
string sql = "SELECT B.No AS FK_Dept,B.Name AS FK_DeptText,A.MyPK From Port_DeptEmp A,Port_Dept B WHERE A.FK_Dept=B.No AND A.FK_Emp='" + empNo + "'";
if (SystemConfig.AppCenterDBType == DBType.PostgreSQL || SystemConfig.AppCenterDBType == DBType.Oracle)
sql = "SELECT B.No AS FK_Dept,B.Name AS FK_DeptText,A.MyPK AS MyPK From Port_DeptEmp A,Port_Dept B WHERE A.FK_Dept=B.No AND A.FK_Emp='" + empNo + "'";
if (SystemConfig.CCBPMRunModel == CCBPMRunModel.SAAS)
sql += " B.OrgNo='" + WebUser.OrgNo + "'";
DataTable dt = DBAccess.RunSQLReturnTable(sql);
if (SystemConfig.AppCenterDBFieldCaseModel != FieldCaseModel.None)
{
dt.Columns[0].ColumnName = "FK_Dept";
dt.Columns[1].ColumnName = "FK_DeptText";
dt.Columns[2].ColumnName = "MyPK";
}
if (dt.Rows.Count == 0)
{
DeptEmp deptEmp = new DeptEmp();
deptEmp.FK_Dept = emp.FK_Dept;
deptEmp.FK_Emp = emp.No;
deptEmp.MyPK = emp.FK_Dept + "_" + emp.No;
deptEmp.Insert();
DataRow dr = dt.NewRow();
dr[0] = emp.FK_Dept;
dr[1] = emp.FK_DeptText;
dr[2] = deptEmp.MyPK;
dt.Rows.Add(dr);
}
dt.TableName = "Port_DeptEmp";
ds.Tables.Add(dt);
//获取岗位
sql = "SELECT B.No AS FK_Station,B.Name AS FK_StationText ,A.FK_Dept AS FK_Dept From Port_DeptEmpStation A,Port_Station B WHERE A.FK_Station=B.No AND A.FK_Emp='" + empNo + "'";
if (SystemConfig.AppCenterDBType == DBType.PostgreSQL || SystemConfig.AppCenterDBType == DBType.Oracle)
sql = "SELECT B.No AS FK_Station,B.Name AS FK_StationText,A.FK_Dept AS FK_Dept From Port_DeptEmpStation A,Port_Station B WHERE A.FK_Station=B.No AND A.FK_Emp='" + empNo + "'";
if (SystemConfig.CCBPMRunModel == CCBPMRunModel.SAAS)
sql += " B.OrgNo='" + WebUser.OrgNo + "'";
dt = DBAccess.RunSQLReturnTable(sql);
if (SystemConfig.AppCenterDBFieldCaseModel != FieldCaseModel.None)
{
dt.Columns[0].ColumnName = "FK_Station";
dt.Columns[1].ColumnName = "FK_StationText";
dt.Columns[2].ColumnName = "FK_Dept";
}
dt.TableName = "Port_DeptEmpStation";
ds.Tables.Add(dt);
return BP.Tools.Json.ToJson(ds);
}
public string Login_Submit()
{
try
{
string orgNo = this.OrgNo;
string userNo = this.GetRequestVal("TB_No");
string pass = this.GetRequestVal("TB_PW");
if (pass == null)
pass = this.GetRequestVal("TB_Pass");
pass = pass.Trim();
BP.Port.Emp emp = new BP.Port.Emp();
emp.No = this.OrgNo + "_" + userNo;
if (emp.RetrieveFromDBSources() == 0)
return "err@用户名不存在.";
if (emp.CheckPass(pass) == false)
return "err@密码错误.";
BP.Cloud.Emp emp2 = new BP.Cloud.Emp(emp.No);
string token = BP.Cloud.Dev2Interface.Port_Login(emp2);
return "url@/Portal/Standard/Default.htm?Token=" + token + "&UserNo=" + emp.UserID + "&OrgNo=" + emp.OrgNo;
}
catch (Exception ex)
{
return "err@" + ex.Message;
}
}
#region 执行父类的重写方法.
///
/// 默认执行的方法
///
///
protected override string DoDefaultMethod()
{
switch (this.DoType)
{
case "DtlFieldUp": //字段上移
return "执行成功.";
default:
break;
}
//找不不到标记就抛出异常.
throw new Exception("@标记[" + this.DoType + "],没有找到. @RowURL:" + HttpContextHelper.RequestRawUrl);
}
#endregion 执行父类的重写方法.
#region xxx 界面 .
#endregion xxx 界面方法.
}
}