Exemplo n.º 1
0
 /// <summary>
 /// 更新包含子项的项模式
 /// </summary>
 /// <param name="name">项名称</param>
 /// <param name="displayName">显示名称</param>
 /// <param name="bizDataType">类型</param>
 /// <param name="childSchema">如果类型是BizStructure或者BizStructureArray,那么该属性有效,表示子结构</param>
 public void Update(
     string name,
     string displayName,
     BizDataType bizDataType,
     BizStructureSchema childSchema)
 {
     base.Update(name, displayName, bizDataType, UnlimitedMaxLength, null);
     this._ChildSchema = childSchema;
 }
Exemplo n.º 2
0
        private void _BizStructure(BizStructureSchema schema)
        {
            this._Schema = schema;

            string[] names = schema.GetNames();
            if (names != null)
            {
                foreach (string name in names)
                {
                    this.AddValue(name, schema.GetItem(name).DefaultValue);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 创建包含子结构的项的时候使用
 /// </summary>
 /// <param name="name">项名称</param>
 /// <param name="displayName">显示名称</param>
 /// <param name="bizDataType">类型</param>
 /// <param name="childSchema">如果类型是BizStructure或者BizStructureArray,那么该属性有效,表示子结构</param>
 public ItemSchema(
     string name,
     string displayName,
     BizDataType bizDataType,
     BizStructureSchema childSchema)
     : base(
         name,
         displayName,
         bizDataType,
         UnlimitedMaxLength,
         null)
 {
     this._ChildSchema = childSchema;
 }
Exemplo n.º 4
0
        public string GetSchema(string schemaCode)
        {
            string             strSchemaJson = string.Empty;
            BizStructureSchema stockschema   = new BizStructureSchema();

            switch (schemaCode)
            {
            case "HR_Leave_ValidationInfo":

                stockschema.Code = schemaCode;
                stockschema.Add(new H3.BizBus.ItemSchema("ValidationInfo", "验证信息", BizDataType.String));
                strSchemaJson = BizStructureUtility.SchemaToJson(stockschema);
                break;

            case "HR_Leave_Edit":
                stockschema.Code = schemaCode;

                stockschema.Add(new H3.BizBus.ItemSchema("Parent_ObjectId", "父对象编号", BizDataType.String, 200, null));
                stockschema.Add(new H3.BizBus.ItemSchema("SeqNo", "请假单号", BizDataType.String, 200, null));
                stockschema.Add(new H3.BizBus.ItemSchema("ProxyBy", "代理人", BizDataType.String, 200, null));
                stockschema.Add(new H3.BizBus.ItemSchema("UrgentTelephone", "紧急联系电话", BizDataType.String, 200, null));
                stockschema.Add(new H3.BizBus.ItemSchema("LeaveHour", "请假总小时数", BizDataType.Double, 200, null));
                stockschema.Add(new H3.BizBus.ItemSchema("Remark", "请假调休原因", BizDataType.String, 1000, null));
                stockschema.Add(new H3.BizBus.ItemSchema("IsConstrain", "受7天内填写限制", BizDataType.Bool, 200, null));

                H3.BizBus.BizStructureSchema detailsSchema = new H3.BizBus.BizStructureSchema();
                detailsSchema.Add(new H3.BizBus.ItemSchema("ObjectId", "子对象编号", BizDataType.String, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("EmpNo", "员工编号", BizDataType.String, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("LeaveTypeAutokey", "请假类型", BizDataType.Int, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("BeginDateTime", "开始日期", BizDataType.DateTime, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("EndDateTime", "结束日期", BizDataType.DateTime, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("LeaveHour", "请假小时", BizDataType.Double, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("BecomeDueDateTime", "超期邮件提醒日期", BizDataType.DateTime, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("BeginDateTimeHour", "开始日期所在年占小时", BizDataType.Double, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("EndDateTimeHour", "结束日期所在年占小时", BizDataType.Double, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyPassDate", "保安放行日期", BizDataType.DateTime, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyBy", "保安工号", BizDataType.String, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyBackFactorDate", "保安回厂日期", BizDataType.DateTime, 200, null));
                detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyBackFactorBy", "保安回厂工号", BizDataType.String, 200, null));
                stockschema.Add(new H3.BizBus.ItemSchema("details", "明细", BizDataType.BizStructureArray, detailsSchema));    //子表添加到主表
                strSchemaJson = BizStructureUtility.SchemaToJson(stockschema);
                break;

            default:
                strSchemaJson = string.Empty;
                break;
            }
            return(strSchemaJson);
        }
Exemplo n.º 5
0
        public static string SchemaToJson(BizStructureSchema schema)
        {
            if (schema == null)
            {
                return(null);
            }

            if (schema.Code.IndexOf(".") > -1)
            {
                return("编码[" + schema.Code + "]含有特殊字符!");
            }

            Dictionary <string, object> jsonObject = new Dictionary <string, object>();

            jsonObject.Add("Code", schema.Code);
            List <Dictionary <string, object> > itemsObject = new List <Dictionary <string, object> >();

            ItemSchema[] items = schema.Items;
            if (items != null && items.Length != 0)
            {
                foreach (ItemSchema item in items)
                {
                    Dictionary <string, object> itemObject = new Dictionary <string, object>();
                    itemObject.Add("Name", item.Name);
                    itemObject.Add("DisplayName", item.DisplayName);
                    itemObject.Add("DataType", item.DataType.ToString());

                    if (item.DataType == BizDataType.BizStructure || item.DataType == BizDataType.BizStructureArray)
                    {
                        string subSchema = SchemaToJson(item.ChildSchema);
                        if (subSchema != null)
                        {
                            itemObject.Add("ChildSchema", Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(subSchema));
                        }
                    }

                    itemsObject.Add(itemObject);
                }
            }

            jsonObject.Add("Items", itemsObject);
            return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonObject));
        }
Exemplo n.º 6
0
 public static bool JsonToSchema(string jsonString, out BizStructureSchema schema, out string errorMessage)
 {
     schema       = null;
     errorMessage = null;
     try
     {
         JObject jobject = Newtonsoft.Json.Linq.JObject.Parse(jsonString);
         if (jobject == null)
         {
             errorMessage = "传入的数据位空";
             return(false);
         }
         return(JObjectToSchema(jobject, out schema, out errorMessage));
     }
     catch (Exception ex)
     {
         errorMessage = ex.ToString();
         return(false);
     }
 }
Exemplo n.º 7
0
        public string Invoke(string userCode, string schemaCode, string methodName, string param)
        {
            string returnResult = null;

            if (schemaCode == "HR_ChangeClass_Edit")
            {
                switch (methodName)
                {
                case "DeleteData":
                {
                    string        errorMessage = string.Empty;
                    SqlConnection cn           = new SqlConnection(DataBase.PatData);
                    cn.Open();
                    SqlTransaction tran      = cn.BeginTransaction();
                    string         isSuccess = "True";
                    string         msg       = "处理成功";

                    try
                    {
                        H3.BizBus.BizStructureSchema stockschema = new H3.BizBus.BizStructureSchema();
                        stockschema.Add(new H3.BizBus.ItemSchema("Parent_ObjectId", "父对象编号", BizDataType.String, 200, null));
                        BizStructure billBizStructure = new BizStructure(stockschema);
                        BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                        SqlCommand Parent_CM = cn.CreateCommand();
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.Transaction    = tran;
                        Parent_CM.CommandType    = CommandType.StoredProcedure;
                        Parent_CM.CommandText    = string.Format(@"Proc_Attendance_ChangeClass_Del_Web_FromH3OA");
                        Parent_CM.Parameters.AddWithValue("@RefDocumentsHeaderKey", billBizStructure["Parent_ObjectId"].ToString());
                        Parent_CM.ExecuteNonQuery();
                        tran.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        isSuccess = "False";
                        msg       = "处理失败:" + MyErrorMesage.GetError(ex.Message, false);
                        tran.Rollback();

                        SqlConnection cn11 = new SqlConnection(DataBase.PatData);
                        cn11.Open();
                        SqlCommand cm11 = cn11.CreateCommand();
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandType    = CommandType.Text;
                        cm11.CommandText    = string.Format(@"INSERT INTO [Jj_CY_CYDebug]
           ([CYDebugName]
           ,[CYDebugDateTime])
     VALUES
           (@CYDebugName
           ,GETDATE()) 
      ");
                        cm11.Parameters.AddWithValue("@CYDebugName", MyErrorMesage.GetError(ex.Message, false));
                        cm11.ExecuteNonQuery();
                        cn11.Close();
                        //throw ex;
                    }
                    finally
                    {
                        cn.Close();
                    }

                    string returnData = "{\"isSuccess\":\"" + isSuccess + "\",\"msg\":\"" + JsonMgr.StringToJson(msg) + "\"}";        //, isSuccess, "黎中一");

                    BizStructureSchema returnSchema = new H3.BizBus.BizStructureSchema();
                    returnSchema.Code = DateTime.Now.ToShortDateString();
                    returnSchema.Add(new H3.BizBus.ItemSchema("isSuccess", "是否成功", BizDataType.ShortString, 200, "True1"));
                    returnSchema.Add(new H3.BizBus.ItemSchema("msg", "返回信息", BizDataType.ShortString, 200, "True1"));

                    BizStructure returnBizStructure = new BizStructure(returnSchema);
                    BizStructureUtility.JsonToStructure(returnData, returnBizStructure, out errorMessage);
                    InvokeResult result = new H3.BizBus.InvokeResult(0, "服务器返回成功", returnBizStructure);
                    returnResult = BizStructureUtility.InvokeResultToJson(result);
                }
                break;

                case "InsertData":
                {
                    //int ddd = int.Parse("dfd");
                    string errorMessage = string.Empty;

                    //BizStructureSchema billSchema = new BizStructureSchema();
                    //BizStructureUtility.JsonToSchema(GetSchema(schemaCode), out billSchema, out errorMessage);
                    //BizStructure billBizStructure = new BizStructure(billSchema);
                    //BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                    SqlConnection cn = new SqlConnection(DataBase.PatData);
                    cn.Open();
                    SqlTransaction tran      = cn.BeginTransaction();
                    string         isSuccess = "True";
                    string         msg       = "处理成功";

                    try
                    {
                        H3.BizBus.BizStructureSchema stockschema = new H3.BizBus.BizStructureSchema();
                        stockschema.Add(new H3.BizBus.ItemSchema("Parent_ObjectId", "父对象编号", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("SeqNo", "转班单号", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("Remark", "备注", BizDataType.String, 1000, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("IsConstrain", "受7天内填写限制", BizDataType.Bool, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("CreatedBy", "新增人", BizDataType.String, 1000, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("CreatedTime", "新增时间", BizDataType.DateTime, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("ModifiedTime", "修改时间", BizDataType.DateTime, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("ConfirmedFlag", "确认状态", BizDataType.String, 200, null));


                        H3.BizBus.BizStructureSchema detailsSchema = new H3.BizBus.BizStructureSchema();
                        detailsSchema.Add(new H3.BizBus.ItemSchema("ObjectId", "子对象编号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EmpNo", "员工编号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("BeginDate", "开始日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EndDate", "结束日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DutyClassID", "目标班次编号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DetailRemark", "明细备注", BizDataType.String, 1000, null));



                        stockschema.Add(new H3.BizBus.ItemSchema("details", "明细", BizDataType.BizStructureArray, detailsSchema));        //子表添加到主表

                        BizStructure billBizStructure = new BizStructure(stockschema);
                        BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                        // string billsCustomer = billBizStructure["BillsCustomer"] + string.Empty;


                        SqlCommand Parent_CM = cn.CreateCommand();
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.Transaction    = tran;
                        Parent_CM.CommandType    = CommandType.StoredProcedure;
                        Parent_CM.CommandText    = string.Format(@"Proc_Attendance_ChangeClass_Del_Web_FromH3OA");
                        Parent_CM.Parameters.AddWithValue("@RefDocumentsHeaderKey", billBizStructure["Parent_ObjectId"].ToString());
                        Parent_CM.ExecuteNonQuery();


                        BizStructure[] detailsDatas      = (BizStructure[])billBizStructure["details"];
                        int            detailsDatasCount = detailsDatas.Length;
                        for (int i = 0; i < detailsDatasCount; i++)
                        {
                            SqlCommand cm = cn.CreateCommand();
                            cm.CommandTimeout = 9999999;
                            cm.CommandTimeout = 9999999;
                            cm.Transaction    = tran;
                            cm.CommandType    = CommandType.StoredProcedure;
                            cm.CommandText    = string.Format(@"Proc_Attendance_ChangeClass_New_Web_FromH3OA");
                            cm.Parameters.AddWithValue("@id", detailsDatas[i]["ObjectId"].ToString());
                            cm.Parameters.AddWithValue("@mainid", billBizStructure["Parent_ObjectId"].ToString());
                            cm.Parameters.AddWithValue("@ChangeClassID", Guid.NewGuid().ToString());
                            cm.Parameters.AddWithValue("@ChangeClassHeaderKey", DBNull.Value);
                            cm.Parameters.AddWithValue("@EmpNo", detailsDatas[i]["EmpNo"]);
                            cm.Parameters.AddWithValue("@BeinDateTime", detailsDatas[i]["BeginDate"]);
                            cm.Parameters.AddWithValue("@EndDateTime", detailsDatas[i]["EndDate"]);
                            cm.Parameters.AddWithValue("@AimDutyAutoID", detailsDatas[i]["DutyClassID"]);
                            cm.Parameters.AddWithValue("@JobClassInstallDetailJobAutoID", 0);
                            cm.Parameters.AddWithValue("@ProjectManageResponsibleBy", DBNull.Value);
                            cm.Parameters.AddWithValue("@Remark", detailsDatas[i]["DetailRemark"].ToString() + "来自新H3转班单");
                            cm.Parameters.AddWithValue("@InsertedBy", billBizStructure["CreatedBy"]);
                            cm.Parameters.AddWithValue("@InsertedDate", billBizStructure["CreatedTime"]);
                            cm.Parameters.AddWithValue("@UpdatedBy", billBizStructure["CreatedBy"]);
                            cm.Parameters.AddWithValue("@UpdatedDate", billBizStructure["CreatedTime"]);
                            cm.Parameters.AddWithValue("@ConfirmedFlag", billBizStructure["ConfirmedFlag"]);
                            cm.ExecuteNonQuery();
                        }
                        tran.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        isSuccess = "False";
                        msg       = "处理失败:" + MyErrorMesage.GetError(ex.Message, false);
                        tran.Rollback();

                        SqlConnection cn11 = new SqlConnection(DataBase.PatData);
                        cn11.Open();
                        SqlCommand cm11 = cn11.CreateCommand();
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandType    = CommandType.Text;
                        cm11.CommandText    = string.Format(@"INSERT INTO [Jj_CY_CYDebug]
           ([CYDebugName]
           ,[CYDebugDateTime])
     VALUES
           (@CYDebugName
           ,GETDATE()) 
      ");
                        cm11.Parameters.AddWithValue("@CYDebugName", MyErrorMesage.GetError(ex.Message, false));
                        cm11.ExecuteNonQuery();
                        cn11.Close();
                        //throw ex;
                    }
                    finally
                    {
                        cn.Close();
                    }

                    string returnData = "{\"isSuccess\":\"" + isSuccess + "\",\"msg\":\"" + JsonMgr.StringToJson(msg) + "\"}";        //, isSuccess, "黎中一");

                    BizStructureSchema returnSchema = new H3.BizBus.BizStructureSchema();
                    returnSchema.Code = DateTime.Now.ToShortDateString();
                    returnSchema.Add(new H3.BizBus.ItemSchema("isSuccess", "是否成功", BizDataType.ShortString, 200, "True1"));
                    returnSchema.Add(new H3.BizBus.ItemSchema("msg", "返回信息", BizDataType.ShortString, 200, "True1"));

                    BizStructure returnBizStructure = new BizStructure(returnSchema);
                    BizStructureUtility.JsonToStructure(returnData, returnBizStructure, out errorMessage);
                    InvokeResult result = new H3.BizBus.InvokeResult(0, "服务器返回成功", returnBizStructure);
                    returnResult = BizStructureUtility.InvokeResultToJson(result);
                }
                break;

                default:
                    break;
                }
            }


            return(returnResult);
        }
Exemplo n.º 8
0
        private static bool JObjectToSchema(JObject jobject, out BizStructureSchema schema, out string errorMessage)
        {
            errorMessage = null;
            schema       = new BizStructureSchema();
            foreach (KeyValuePair <string, JToken> keyValuePair in jobject)
            {
                if (keyValuePair.Value == null)
                {
                    continue;
                }
                if (string.Compare(keyValuePair.Key, "code", true) == 0)
                {
                    schema.Code = keyValuePair.Value.ToString();
                    continue;
                }

                if (!(keyValuePair.Value is JArray))
                {
                    errorMessage = keyValuePair.Value.ToString() + "不合法";
                    return(false);
                }
                JArray             itemObject  = (JArray)keyValuePair.Value;
                string             name        = keyValuePair.Key;
                string             displayName = null;
                string             strDataType = null;
                BizDataType        dataType    = BizDataType.ShortString;
                BizStructureSchema childSchema = null;
                foreach (JObject childObject in itemObject)
                {
                    foreach (KeyValuePair <string, JToken> itemKeyValuePair in childObject)
                    {
                        if (string.Compare(itemKeyValuePair.Key, "name", true) == 0)
                        {
                            name = itemKeyValuePair.Value.ToString();
                        }
                        else if (string.Compare(itemKeyValuePair.Key, "displayname", true) == 0)
                        {
                            displayName = itemKeyValuePair.Value.ToString();
                        }
                        else if (string.Compare(itemKeyValuePair.Key, "datatype", true) == 0)
                        {
                            strDataType = itemKeyValuePair.Value.ToString();
                            try
                            {
                                dataType = (BizDataType)Enum.Parse(typeof(BizDataType), strDataType, true);
                            }
                            catch
                            {
                                errorMessage = string.Format("字段类型{0}不合法", strDataType);
                                return(false);
                            }
                        }
                        else if (string.Compare(itemKeyValuePair.Key, "childschema", true) == 0)
                        {
                            if (itemKeyValuePair.Value != null && !string.IsNullOrEmpty(itemKeyValuePair.Value.ToString()))
                            {
                                if (!(itemKeyValuePair.Value is JObject))
                                {
                                    errorMessage = string.Format("字段{0}不合法", itemKeyValuePair.Value.ToString());
                                    return(false);
                                }
                                JObject childJObject = (JObject)itemKeyValuePair.Value;
                                if (!JObjectToSchema(childJObject, out childSchema, out errorMessage))
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(displayName))
                    {
                        displayName = name;
                    }
                    ItemSchema itemSchema = new ItemSchema(name, displayName, dataType, childSchema);

                    schema.Add(itemSchema);
                }
            }
            return(true);
        }
Exemplo n.º 9
0
        public static string StructureToJson(BizStructure structure)
        {
            if (structure == null)
            {
                return(null);
            }
            System.Text.StringBuilder jsonString = new System.Text.StringBuilder();
            BizStructureSchema        schema     = structure.Schema;

            ItemSchema[] properties = schema.Items;
            jsonString.Append("{");
            foreach (ItemSchema p in properties)
            {
                object v = structure[p.Name];
                if (v == null)
                {
                    continue;
                }

                jsonString.Append("\"" + p.Name + "\":");
                if (p.DataType == BizDataType.UnitArray)
                {
                    string[] ids = (string[])v;
                    jsonString.Append("[");
                    if (ids.Length > 0)
                    {
                        foreach (string code in ids)
                        {
                            jsonString.Append("\"" + code + "\",");
                        }
                        jsonString.Remove(jsonString.Length - 1, 1);
                    }
                    jsonString.Append("],");
                }
                else if (p.DataType == BizDataType.BizStructure)
                {
                    jsonString.Append(StructureToJson((BizStructure)v) + ",");
                }
                else if (p.DataType == BizDataType.BizStructureArray)
                {
                    BizStructure[] children = (BizStructure[])v;
                    jsonString.Append("[");
                    foreach (BizStructure child in children)
                    {
                        jsonString.Append(StructureToJson(child) + ",");
                    }
                    if (jsonString[jsonString.Length - 1] == ',')
                    {
                        jsonString.Remove(jsonString.Length - 1, 1);
                    }
                    jsonString.Append("],");
                }
                else
                {
                    jsonString.Append("\"" + v.ToString() + "\",");
                }
            }
            if (jsonString[jsonString.Length - 1] == ',')
            {
                jsonString.Remove(jsonString.Length - 1, 1);
            }
            jsonString.Append("}");
            return(jsonString.ToString());
        }
Exemplo n.º 10
0
        private static bool JObjectToStructure(JObject jobject, BizStructure obj, out string errorMessage)
        {
            errorMessage = null;

            // 赋值进去
            foreach (KeyValuePair <string, JToken> keyValuePair in jobject)
            {
                ItemSchema property = obj.Schema.GetItem(keyValuePair.Key);
                if (keyValuePair.Value == null)
                {
                    continue;
                }
                else if (property == null)
                {
                    continue;
                }
                else if (property.DataType == BizDataType.BizStructure)
                {
                    BizStructure childObject = null;
                    if (keyValuePair.Value.ToString() != "")
                    {
                        if (!(keyValuePair.Value is JObject))
                        {
                            errorMessage = string.Format("属性{0}是一个结构,但是传过来的Json字符串与该类型不一致", property.Name);
                            return(false);
                        }
                        JObject            childJObject = (JObject)keyValuePair.Value;
                        BizStructureSchema childSchema  = property.ChildSchema;
                        childObject = new BizStructure(childSchema);
                        if (!JObjectToStructure(childJObject, childObject, out errorMessage))
                        {
                            return(false);
                        }
                    }
                    obj[property.Name] = childObject;
                }
                else if (property.DataType == BizDataType.BizStructureArray)
                {
                    List <BizStructure> boList = new List <BizStructure>();
                    if (keyValuePair.Value.ToString() != "")
                    {
                        if (!(keyValuePair.Value is JArray))
                        {
                            errorMessage = string.Format("属性{0}是一个业务对象数组,但是传过来的Json字符串与该类型不一致", property.Name);
                            return(false);
                        }
                        BizStructureSchema childSchema = property.ChildSchema;
                        if (childSchema == null)
                        {
                            continue;
                        }

                        int count = keyValuePair.Value.Count();
                        if (count == 0)
                        {
                            continue;
                        }
                        for (int i = 0; i < count; i++)
                        {
                            object p_v = keyValuePair.Value[i];
                            if (!(p_v is JObject))
                            {
                                errorMessage = string.Format("属性{0}是一个业务对象数组,但是传过来的Json字符串与该类型不一致", property.Name);
                                return(false);
                            }
                            JObject      childJObject = (JObject)p_v;
                            BizStructure childBo      = new BizStructure(childSchema);
                            if (!JObjectToStructure(childJObject, childBo, out errorMessage))
                            {
                                return(false);
                            }
                            boList.Add(childBo);
                        }
                    }
                    obj[keyValuePair.Key] = boList.ToArray();
                }
                else if (property.DataType == BizDataType.UnitArray)
                {
                    List <string> vs = new List <string>();
                    if (keyValuePair.Value.ToString() != "")
                    {
                        if (!(keyValuePair.Value is JArray))
                        {
                            errorMessage = string.Format("属性{0}是一个多人字段,但是传过来的Json字符串与该类型不一致", property.Name);
                            return(false);
                        }
                        int count = keyValuePair.Value.Count();
                        for (int i = 0; i < count; i++)
                        {
                            string unit = keyValuePair.Value[i].ToString();
                            vs.Add(unit);
                        }
                    }
                    obj[keyValuePair.Key] = vs.ToArray();
                }
                else if (property.DataType == BizDataType.Unit)
                {
                    obj[keyValuePair.Key] = keyValuePair.Value.ToString();
                }
                else
                {
                    object v = Utility.Convert(keyValuePair.Value.ToString(), property.RealType, true, null);
                    obj[property.Name] = v;
                }
            }

            return(true);
        }
Exemplo n.º 11
0
        public string Invoke(string userCode, string schemaCode, string methodName, string param)
        {
            string returnResult = null;

            if (schemaCode == "HR_BusinessReport_Edit")
            {
                switch (methodName)
                {
                case "DeleteData":
                {
                    string        errorMessage = string.Empty;
                    SqlConnection cn           = new SqlConnection(DataBase.PatData);
                    cn.Open();
                    SqlTransaction tran      = cn.BeginTransaction();
                    string         isSuccess = "True";
                    string         msg       = "处理成功";

                    try
                    {
                        H3.BizBus.BizStructureSchema stockschema = new H3.BizBus.BizStructureSchema();
                        stockschema.Add(new H3.BizBus.ItemSchema("Parent_ObjectId", "父对象编号", BizDataType.String, 200, null));
                        BizStructure billBizStructure = new BizStructure(stockschema);
                        BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                        SqlCommand Parent_CM = cn.CreateCommand();
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.Transaction    = tran;
                        Parent_CM.CommandType    = CommandType.StoredProcedure;
                        Parent_CM.CommandText    = string.Format(@"Proc_OA_WorkDailyAndTravelAttendanceDetail_Del_FromH3OA");
                        Parent_CM.Parameters.AddWithValue("@WorkDailyAndTravelAttendanceHeaderKey", billBizStructure["Parent_ObjectId"].ToString());
                        Parent_CM.ExecuteNonQuery();
                        tran.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        isSuccess = "False";
                        msg       = "处理失败:" + MyErrorMesage.GetError(ex.Message, false);
                        tran.Rollback();

                        SqlConnection cn11 = new SqlConnection(DataBase.PatData);
                        cn11.Open();
                        SqlCommand cm11 = cn11.CreateCommand();
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandType    = CommandType.Text;
                        cm11.CommandText    = string.Format(@"INSERT INTO [Jj_CY_CYDebug]
           ([CYDebugName]
           ,[CYDebugDateTime])
     VALUES
           (@CYDebugName
           ,GETDATE()) 
      ");
                        cm11.Parameters.AddWithValue("@CYDebugName", MyErrorMesage.GetError(ex.Message, false));
                        cm11.ExecuteNonQuery();
                        cn11.Close();
                        //throw ex;
                    }
                    finally
                    {
                        cn.Close();
                    }

                    string returnData = "{\"isSuccess\":\"" + isSuccess + "\",\"msg\":\"" + JsonMgr.StringToJson(msg) + "\"}";        //, isSuccess, "黎中一");

                    BizStructureSchema returnSchema = new H3.BizBus.BizStructureSchema();
                    returnSchema.Code = DateTime.Now.ToShortDateString();
                    returnSchema.Add(new H3.BizBus.ItemSchema("isSuccess", "是否成功", BizDataType.ShortString, 200, "True1"));
                    returnSchema.Add(new H3.BizBus.ItemSchema("msg", "返回信息", BizDataType.ShortString, 200, "True1"));

                    BizStructure returnBizStructure = new BizStructure(returnSchema);
                    BizStructureUtility.JsonToStructure(returnData, returnBizStructure, out errorMessage);
                    InvokeResult result = new H3.BizBus.InvokeResult(0, "服务器返回成功", returnBizStructure);
                    returnResult = BizStructureUtility.InvokeResultToJson(result);
                }
                break;

                case "InsertData":
                {
                    //int ddd = int.Parse("dfd");
                    string errorMessage = string.Empty;

                    //BizStructureSchema billSchema = new BizStructureSchema();
                    //BizStructureUtility.JsonToSchema(GetSchema(schemaCode), out billSchema, out errorMessage);
                    //BizStructure billBizStructure = new BizStructure(billSchema);
                    //BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                    SqlConnection cn = new SqlConnection(DataBase.PatData);
                    cn.Open();
                    SqlTransaction tran      = cn.BeginTransaction();
                    string         isSuccess = "True";
                    string         msg       = "处理成功";

                    try
                    {
                        DateTime dt1 = DateTime.Now;
                        DateTime dt2 = DateTime.Now;

                        H3.BizBus.BizStructureSchema stockschema = new H3.BizBus.BizStructureSchema();
                        stockschema.Add(new H3.BizBus.ItemSchema("Parent_ObjectId", "父对象编号", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("SeqNo", "加班单号", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("Remark", "备注", BizDataType.String, 1000, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("IsConstrain", "受7天内填写限制", BizDataType.Bool, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("CreatedBy", "新增人", BizDataType.String, 1000, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("CreatedTime", "新增时间", BizDataType.DateTime, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("ModifiedTime", "修改时间", BizDataType.DateTime, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("ConfirmedFlag", "确认状态", BizDataType.String, 200, null));

                        H3.BizBus.BizStructureSchema detailsSchema = new H3.BizBus.BizStructureSchema();
                        detailsSchema.Add(new H3.BizBus.ItemSchema("ObjectId", "子对象编号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EmpNo", "员工编号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("WorkDailyDate", "日报日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DateType", "日期类型", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DateTime1", "上班1日期", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DateTime2", "下班1日期", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("AddtionalHoursTime23", "中午连班加班小时", BizDataType.Double, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DateTime3", "上班2日期", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DateTime4", "下班2日期", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DateTime5", "上加班1日期", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("DateTime6", "下加班1日期", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("WorkHours", "上班小时", BizDataType.Double, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("AddtionalHours", "加班小時", BizDataType.Double, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("AddtionalHoursFact", "加班小时调整后", BizDataType.Double, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("ProcessRecord", "加班小时调整后", BizDataType.String, 2000, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("IsAttendanceData", "生成打卡", BizDataType.Bool, 2000, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("IsRegOvertime", "生成加班", BizDataType.Bool, 2000, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("IsWorkDaily", "生成日报", BizDataType.Bool, 2000, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("RealitySetOutDateTime", "出厂时间", BizDataType.String, 2000, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("RealityBackFactoryDateTime", "回厂时间", BizDataType.String, 2000, null));

                        stockschema.Add(new H3.BizBus.ItemSchema("details", "明细", BizDataType.BizStructureArray, detailsSchema));        //子表添加到主表

                        BizStructure billBizStructure = new BizStructure(stockschema);
                        BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                        // string billsCustomer = billBizStructure["BillsCustomer"] + string.Empty;


                        SqlCommand Parent_CM = cn.CreateCommand();
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.Transaction    = tran;
                        Parent_CM.CommandType    = CommandType.StoredProcedure;
                        Parent_CM.CommandText    = string.Format(@"Proc_OA_WorkDailyAndTravelAttendanceDetail_Del_FromH3OA");
                        Parent_CM.Parameters.AddWithValue("@WorkDailyAndTravelAttendanceHeaderKey", billBizStructure["Parent_ObjectId"].ToString());
                        Parent_CM.ExecuteNonQuery();


                        BizStructure[] detailsDatas      = (BizStructure[])billBizStructure["details"];
                        int            detailsDatasCount = detailsDatas.Length;
                        for (int i = 0; i < detailsDatasCount; i++)
                        {
                            SqlCommand cm = cn.CreateCommand();
                            cm.CommandTimeout = 9999999;
                            cm.CommandTimeout = 9999999;
                            cm.Transaction    = tran;
                            cm.CommandType    = CommandType.StoredProcedure;
                            cm.CommandText    = string.Format(@"Proc_OA_WorkDailyAndTravelAttendanceDetail_Upd_FromH3OA");
                            cm.Parameters.AddWithValue("@WorkDailyAndTravelAttendanceDetailKey", detailsDatas[i]["ObjectId"].ToString());
                            cm.Parameters.AddWithValue("@WorkDailyAndTravelAttendanceHeaderKey", billBizStructure["Parent_ObjectId"].ToString());
                            cm.Parameters.AddWithValue("@EmpNo", detailsDatas[i]["EmpNo"]);
                            cm.Parameters.AddWithValue("@WorkDailyDate", detailsDatas[i]["WorkDailyDate"]);
                            cm.Parameters.AddWithValue("@DateType", detailsDatas[i]["DateType"]);

                            if (detailsDatas[i]["DateTime1"] != null && detailsDatas[i]["DateTime1"].ToString().Trim() != "")
                            {
                                cm.Parameters.AddWithValue("@Time1", detailsDatas[i]["DateTime1"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@Time1", DBNull.Value);        //
                            }

                            if (detailsDatas[i]["DateTime2"] != null && detailsDatas[i]["DateTime2"].ToString().Trim() != "")
                            {
                                cm.Parameters.AddWithValue("@Time2", detailsDatas[i]["DateTime2"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@Time2", DBNull.Value);        //
                            }

                            cm.Parameters.AddWithValue("@AddtionalHoursTime23", detailsDatas[i]["AddtionalHoursTime23"]);


                            if (detailsDatas[i]["DateTime3"] != null && detailsDatas[i]["DateTime3"].ToString().Trim() != "")
                            {
                                cm.Parameters.AddWithValue("@Time3", detailsDatas[i]["DateTime3"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@Time3", DBNull.Value);        //
                            }

                            if (detailsDatas[i]["DateTime4"] != null && detailsDatas[i]["DateTime4"].ToString().Trim() != "")
                            {
                                cm.Parameters.AddWithValue("@Time4", detailsDatas[i]["DateTime4"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@Time4", DBNull.Value);        //
                            }

                            if (detailsDatas[i]["DateTime5"] != null && detailsDatas[i]["DateTime5"].ToString().Trim() != "")
                            {
                                cm.Parameters.AddWithValue("@Time5", detailsDatas[i]["DateTime5"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@Time5", DBNull.Value);        //
                            }

                            if (detailsDatas[i]["DateTime6"] != null && detailsDatas[i]["DateTime6"].ToString().Trim() != "")
                            {
                                cm.Parameters.AddWithValue("@Time6", detailsDatas[i]["DateTime6"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@Time6", DBNull.Value);        //
                            }



                            cm.Parameters.AddWithValue("@WorkHours", detailsDatas[i]["WorkHours"]);
                            cm.Parameters.AddWithValue("@AddtionalHours", detailsDatas[i]["AddtionalHours"]);
                            cm.Parameters.AddWithValue("@AddtionalHoursFact", detailsDatas[i]["AddtionalHoursFact"]);
                            cm.Parameters.AddWithValue("@ProcessRecord", detailsDatas[i]["ProcessRecord"]);


                            cm.Parameters.AddWithValue("@IsAttendanceData", detailsDatas[i]["IsAttendanceData"]);
                            cm.Parameters.AddWithValue("@IsRegOvertime", detailsDatas[i]["IsRegOvertime"]);
                            cm.Parameters.AddWithValue("@IsWorkDaily", detailsDatas[i]["IsWorkDaily"]);


                            cm.Parameters.AddWithValue("@RealitySetOutDateTime", DBNull.Value);
                            cm.Parameters.AddWithValue("@RealityBackFactoryDateTime", DBNull.Value);
                            cm.Parameters.AddWithValue("@Remark", detailsDatas[i]["ProcessRecord"].ToString() + "来自新H3出差报告单");


                            cm.Parameters.AddWithValue("@InsertedBy", billBizStructure["CreatedBy"]);
                            cm.Parameters.AddWithValue("@InsertedDate", billBizStructure["CreatedTime"]);
                            cm.Parameters.AddWithValue("@UpdatedBy", billBizStructure["CreatedBy"]);
                            cm.Parameters.AddWithValue("@UpdatedDate", billBizStructure["CreatedTime"]);
                            cm.Parameters.AddWithValue("@ConfirmedFlag", billBizStructure["ConfirmedFlag"]);
                            cm.ExecuteNonQuery();
                        }
                        tran.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        isSuccess = "False";
                        msg       = "处理失败:" + MyErrorMesage.GetError(ex.Message, false);
                        tran.Rollback();

                        SqlConnection cn11 = new SqlConnection(DataBase.PatData);
                        cn11.Open();
                        SqlCommand cm11 = cn11.CreateCommand();
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandType    = CommandType.Text;
                        cm11.CommandText    = string.Format(@"INSERT INTO [Jj_CY_CYDebug]
           ([CYDebugName]
           ,[CYDebugDateTime])
     VALUES
           (@CYDebugName
           ,GETDATE()) 
      ");
                        cm11.Parameters.AddWithValue("@CYDebugName", MyErrorMesage.GetError(ex.Message, false));
                        cm11.ExecuteNonQuery();
                        cn11.Close();
                        //throw ex;
                    }
                    finally
                    {
                        cn.Close();
                    }

                    string returnData = "{\"isSuccess\":\"" + isSuccess + "\",\"msg\":\"" + JsonMgr.StringToJson(msg) + "\"}";        //, isSuccess, "黎中一");

                    BizStructureSchema returnSchema = new H3.BizBus.BizStructureSchema();
                    returnSchema.Code = DateTime.Now.ToShortDateString();
                    returnSchema.Add(new H3.BizBus.ItemSchema("isSuccess", "是否成功", BizDataType.ShortString, 200, "True1"));
                    returnSchema.Add(new H3.BizBus.ItemSchema("msg", "返回信息", BizDataType.ShortString, 200, "True1"));

                    BizStructure returnBizStructure = new BizStructure(returnSchema);
                    BizStructureUtility.JsonToStructure(returnData, returnBizStructure, out errorMessage);
                    InvokeResult result = new H3.BizBus.InvokeResult(0, "服务器返回成功", returnBizStructure);
                    returnResult = BizStructureUtility.InvokeResultToJson(result);
                }
                break;

                default:
                    break;
                }
            }


            return(returnResult);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 新建业务结构对象的构造函数
 /// </summary>
 /// <param name="schema">业务结构模式</param>
 public BizStructure(BizStructureSchema schema)
 {
     this._BizStructure(schema);
 }
Exemplo n.º 13
0
        public string GetList(string userCode, string schemaCode, string filter)
        {
            H3.BizBus.BizStructureSchema schema = null;
            string errorMessage = string.Empty;

            BizStructureUtility.JsonToSchema(GetSchema(schemaCode), out schema, out errorMessage);
            ListResult          listResult       = null;
            string              sql              = string.Empty;
            string              sqlCount         = string.Empty;
            string              strWhere         = " where 1=1 ";
            DataTable           dt               = new DataTable();
            List <BizStructure> listBizStructure = new List <BizStructure>();

            int number    = 1;  //页码
            int size      = 10; //每页条数
            int lowNumber = size * (number - 1);

            Filter filterValue  = BizStructureUtility.JsonToFilter(filter);
            int    FromRowNum   = filterValue.FromRowNum; //起始条数
            int    ToRowNum     = filterValue.ToRowNum;   //结束条数
            bool   RequireCount = filterValue.RequireCount;

            size      = ToRowNum - FromRowNum;
            number    = (FromRowNum / size) + 1;
            lowNumber = size * (number - 1);

            Matcher matcher = filterValue.Matcher;                    //过滤条件

            SortBy[] sortByCollection = filterValue.SortByCollection; //排序

            //提取所有的条件,也可以自己根据filter的格式,自己构造
            Dictionary <string, string> matcherKeyValues = CustomExpand.MatcherToDictionary(matcher);

            switch (schemaCode)
            {
            case "HR_Leave_ValidationInfo":

                string ObjectId       = matcherKeyValues["ObjectId"].ToString().Trim();
                string EmpNo          = matcherKeyValues["EmpNo"].ToString().Trim();
                string BeginDateTime  = matcherKeyValues["BeginDateTime"].ToString().Trim();
                string EndDateTime    = matcherKeyValues["EndDateTime"].ToString().Trim();
                string ValidationInfo = "";

                SqlConnection cn = new SqlConnection(DataBase.PatData);
                cn.Open();
                try
                {
                    SqlCommand cm = cn.CreateCommand(); cm.CommandTimeout = 9999999;
                    cm.CommandTimeout = 9999999;
                    cm.CommandType    = CommandType.Text;
                    string sql1 = string.Format(@"execute Proc_Attendance_Leave_Get_ValidationInfo 
'{0}'
,'{1}'
,'{2}'
,'{3}'", ObjectId, EmpNo, BeginDateTime, EndDateTime);
                    cm.CommandText = sql1;

                    ValidationInfo = cm.ExecuteScalar().ToString();



                    SqlCommand cm2 = cn.CreateCommand();
                    cm2.CommandTimeout = 9999999;
                    cm2.CommandTimeout = 9999999;
                    cm2.CommandType    = CommandType.Text;
                    cm2.CommandText    = string.Format(@"INSERT INTO [Jj_CY_CYDebug]
           ([CYDebugName]
           ,[CYDebugDateTime])
     VALUES
           ('{0'
           ,'{1}')
GO", "a", sql1);
                    cm2.ExecuteNonQuery();
                }
                catch (System.Exception ex)
                {
                    //throw ex;
                }
                finally
                {
                    cn.Close();
                }

                BizStructure LeavebizStructure1 = new H3.BizBus.BizStructure(schema);
                LeavebizStructure1["ValidationInfo"] = JsonMgr.StringToJson(ValidationInfo);      //机构名称
                listBizStructure.Add(LeavebizStructure1);
                break;

            default:
                break;
            }
            int dataCount = 0;

            dataCount = listBizStructure.Count;

            if (listBizStructure.Count > 0)
            {
                listResult = new H3.BizBus.ListResult(0, "获取数据成功", listBizStructure.ToArray(), dataCount);
            }
            return(BizStructureUtility.ListResultToJson(listResult));
        }
Exemplo n.º 14
0
        public string Invoke(string userCode, string schemaCode, string methodName, string param)
        {
            string returnResult = null;

            if (schemaCode == "HR_Leave_Edit")
            {
                switch (methodName)
                {
                case "DeleteData":
                {
                    string        errorMessage = string.Empty;
                    SqlConnection cn           = new SqlConnection(DataBase.PatData);
                    cn.Open();
                    SqlTransaction tran      = cn.BeginTransaction();
                    string         isSuccess = "True";
                    string         msg       = "处理成功";

                    try
                    {
                        H3.BizBus.BizStructureSchema stockschema = new H3.BizBus.BizStructureSchema();
                        stockschema.Add(new H3.BizBus.ItemSchema("Parent_ObjectId", "父对象编号", BizDataType.String, 200, null));
                        BizStructure billBizStructure = new BizStructure(stockschema);
                        BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                        SqlCommand Parent_CM = cn.CreateCommand();
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.Transaction    = tran;
                        Parent_CM.CommandType    = CommandType.StoredProcedure;
                        Parent_CM.CommandText    = string.Format(@"Proc_Attendance_Leave_Del_Web_FromH3OA");
                        Parent_CM.Parameters.AddWithValue("@mainid", billBizStructure["Parent_ObjectId"].ToString());
                        Parent_CM.ExecuteNonQuery();
                        tran.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        isSuccess = "False";
                        msg       = "处理失败:" + MyErrorMesage.GetError(ex.Message, false);
                        tran.Rollback();

                        SqlConnection cn11 = new SqlConnection(DataBase.PatData);
                        cn11.Open();
                        SqlCommand cm11 = cn11.CreateCommand();
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandType    = CommandType.Text;
                        cm11.CommandText    = string.Format(@"INSERT INTO [Jj_CY_CYDebug]
           ([CYDebugName]
           ,[CYDebugDateTime])
     VALUES
           (@CYDebugName
           ,GETDATE()) 
      ");
                        cm11.Parameters.AddWithValue("@CYDebugName", MyErrorMesage.GetError(ex.Message, false));
                        cm11.ExecuteNonQuery();
                        cn11.Close();
                        //throw ex;
                    }
                    finally
                    {
                        cn.Close();
                    }

                    string returnData = "{\"isSuccess\":\"" + isSuccess + "\",\"msg\":\"" + JsonMgr.StringToJson(msg) + "\"}";        //, isSuccess, "黎中一");

                    BizStructureSchema returnSchema = new H3.BizBus.BizStructureSchema();
                    returnSchema.Code = DateTime.Now.ToShortDateString();
                    returnSchema.Add(new H3.BizBus.ItemSchema("isSuccess", "是否成功", BizDataType.ShortString, 200, "True1"));
                    returnSchema.Add(new H3.BizBus.ItemSchema("msg", "返回信息", BizDataType.ShortString, 200, "True1"));

                    BizStructure returnBizStructure = new BizStructure(returnSchema);
                    BizStructureUtility.JsonToStructure(returnData, returnBizStructure, out errorMessage);
                    InvokeResult result = new H3.BizBus.InvokeResult(0, "服务器返回成功", returnBizStructure);
                    returnResult = BizStructureUtility.InvokeResultToJson(result);
                }
                break;

                case "InsertData":
                {
                    //int ddd = int.Parse("dfd");
                    string errorMessage = string.Empty;

                    //BizStructureSchema billSchema = new BizStructureSchema();
                    //BizStructureUtility.JsonToSchema(GetSchema(schemaCode), out billSchema, out errorMessage);
                    //BizStructure billBizStructure = new BizStructure(billSchema);
                    //BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                    SqlConnection cn = new SqlConnection(DataBase.PatData);
                    cn.Open();
                    SqlTransaction tran      = cn.BeginTransaction();
                    string         isSuccess = "True";
                    string         msg       = "处理成功";

                    try
                    {
                        H3.BizBus.BizStructureSchema stockschema = new H3.BizBus.BizStructureSchema();
                        stockschema.Add(new H3.BizBus.ItemSchema("Parent_ObjectId", "父对象编号", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("SeqNo", "请假单号", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("ProxyBy", "代理人", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("UrgentTelephone", "紧急联系电话", BizDataType.String, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("LeaveHour", "请假总小时数", BizDataType.Double, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("Remark", "请假调休原因", BizDataType.String, 1000, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("IsConstrain", "受7天内填写限制", BizDataType.Bool, 200, null));

                        stockschema.Add(new H3.BizBus.ItemSchema("CreatedBy", "新增人", BizDataType.String, 1000, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("CreatedTime", "新增时间", BizDataType.DateTime, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("ModifiedTime", "修改时间", BizDataType.DateTime, 200, null));
                        stockschema.Add(new H3.BizBus.ItemSchema("ConfirmedFlag", "确认状态", BizDataType.String, 200, null));


                        H3.BizBus.BizStructureSchema detailsSchema = new H3.BizBus.BizStructureSchema();
                        detailsSchema.Add(new H3.BizBus.ItemSchema("ObjectId", "子对象编号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EmpNo", "员工编号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("LeaveTypeAutokey", "请假类型", BizDataType.Int, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("BeginDateTime", "开始日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EndDateTime", "结束日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("LeaveHour", "请假小时", BizDataType.Double, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("BecomeDueDateTime", "超期邮件提醒日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("BeginDateTimeHour", "开始日期所在年占小时", BizDataType.Double, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EndDateTimeHour", "结束日期所在年占小时", BizDataType.Double, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyPassDate", "保安放行日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyPassTime", "保安放行时间", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyBy", "保安工号", BizDataType.String, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyBackFactorDate", "保安回厂日期", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyBackFactorTime", "保安回厂时间", BizDataType.DateTime, 200, null));
                        detailsSchema.Add(new H3.BizBus.ItemSchema("EnsureSafetyBackFactorBy", "保安回厂工号", BizDataType.String, 200, null));

                        stockschema.Add(new H3.BizBus.ItemSchema("details", "明细", BizDataType.BizStructureArray, detailsSchema));        //子表添加到主表

                        BizStructure billBizStructure = new BizStructure(stockschema);
                        BizStructureUtility.JsonToStructure(param, billBizStructure, out errorMessage);

                        // string billsCustomer = billBizStructure["BillsCustomer"] + string.Empty;


                        SqlCommand Parent_CM = cn.CreateCommand();
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.CommandTimeout = 9999999;
                        Parent_CM.Transaction    = tran;
                        Parent_CM.CommandType    = CommandType.StoredProcedure;
                        Parent_CM.CommandText    = string.Format(@"Proc_Attendance_Leave_Del_Web_FromH3OA");
                        Parent_CM.Parameters.AddWithValue("@mainid", billBizStructure["Parent_ObjectId"].ToString());
                        Parent_CM.ExecuteNonQuery();


                        BizStructure[] detailsDatas      = (BizStructure[])billBizStructure["details"];
                        int            detailsDatasCount = detailsDatas.Length;
                        for (int i = 0; i < detailsDatasCount; i++)
                        {
                            SqlCommand cm = cn.CreateCommand();
                            cm.CommandTimeout = 9999999;
                            cm.CommandTimeout = 9999999;
                            cm.Transaction    = tran;
                            cm.CommandType    = CommandType.StoredProcedure;
                            cm.CommandText    = string.Format(@"Proc_Attendance_Leave_New_Web_FromH3OA");
                            cm.Parameters.AddWithValue("@id", detailsDatas[i]["ObjectId"].ToString());
                            cm.Parameters.AddWithValue("@mainid", billBizStructure["Parent_ObjectId"].ToString());
                            string LeaveID = Guid.NewGuid().ToString();
                            cm.Parameters.AddWithValue("@LeaveID", LeaveID);
                            cm.Parameters.AddWithValue("@LeaveKey", DBNull.Value);
                            cm.Parameters.AddWithValue("@LeaveNo", DBNull.Value);
                            cm.Parameters.AddWithValue("@LeaveDepartmentCode", DBNull.Value);
                            cm.Parameters.AddWithValue("@EmpNo", detailsDatas[i]["EmpNo"]);

                            cm.Parameters.AddWithValue("@BeginDateTime", detailsDatas[i]["BeginDateTime"]);
                            cm.Parameters.AddWithValue("@EndDateTime", detailsDatas[i]["EndDateTime"]);
                            cm.Parameters.AddWithValue("@LeaveTypeAutokey", detailsDatas[i]["LeaveTypeAutokey"]);
                            cm.Parameters.AddWithValue("@LeaveHour", detailsDatas[i]["LeaveHour"]);


                            if (detailsDatas[i]["BecomeDueDateTime"] != null)
                            {
                                cm.Parameters.AddWithValue("@BecomeDueDateTime", detailsDatas[i]["BecomeDueDateTime"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@BecomeDueDateTime", DBNull.Value);        //
                            }



                            if (detailsDatas[i]["BeginDateTimeHour"] != null)
                            {
                                cm.Parameters.AddWithValue("@BeginDateTimeHour", detailsDatas[i]["BeginDateTimeHour"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@BeginDateTimeHour", 0);        //
                            }

                            if (detailsDatas[i]["EndDateTimeHour"] != null)
                            {
                                cm.Parameters.AddWithValue("@EndDateTimeHour", detailsDatas[i]["EndDateTimeHour"]);        //
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@EndDateTimeHour", 0);        //
                            }



                            if (detailsDatas[i]["EnsureSafetyPassDate"] != null)
                            {
                                string EnsureSafetyPassDate = "";
                                EnsureSafetyPassDate = detailsDatas[i]["EnsureSafetyPassDate"].ToString().Trim().Split(' ')[0];
                                if (detailsDatas[i]["EnsureSafetyPassTime"] != null)
                                {
                                    DateTime EnsureSafetyPassTime = DateTime.Parse(detailsDatas[i]["EnsureSafetyPassTime"].ToString().Trim());
                                    EnsureSafetyPassDate = EnsureSafetyPassDate + " " + EnsureSafetyPassTime.Hour.ToString() + ":" + EnsureSafetyPassTime.Minute.ToString();
                                }
                                cm.Parameters.AddWithValue("@EnsureSafetyPassDate", EnsureSafetyPassDate);
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@EnsureSafetyPassDate", DBNull.Value);        //
                            }

                            cm.Parameters.AddWithValue("@EnsureSafetyBy", detailsDatas[i]["EnsureSafetyBy"]);

                            if (detailsDatas[i]["EnsureSafetyBackFactorDate"] != null)
                            {
                                string EnsureSafetyBackFactorDate = "";
                                EnsureSafetyBackFactorDate = detailsDatas[i]["EnsureSafetyBackFactorDate"].ToString().Trim().Split(' ')[0];

                                if (detailsDatas[i]["EnsureSafetyBackFactorTime"] != null)
                                {
                                    DateTime EnsureSafetyBackFactorTime = DateTime.Parse(detailsDatas[i]["EnsureSafetyBackFactorTime"].ToString().Trim());
                                    EnsureSafetyBackFactorDate = EnsureSafetyBackFactorDate + " " + EnsureSafetyBackFactorTime.Hour.ToString() + ":" + EnsureSafetyBackFactorTime.Minute.ToString();
                                }

                                cm.Parameters.AddWithValue("@EnsureSafetyBackFactorDate", EnsureSafetyBackFactorDate);
                            }
                            else
                            {
                                cm.Parameters.AddWithValue("@EnsureSafetyBackFactorDate", DBNull.Value);        //
                            }

                            cm.Parameters.AddWithValue("@EnsureSafetyBackFactorBy", detailsDatas[i]["EnsureSafetyBackFactorBy"]);
                            cm.Parameters.AddWithValue("@ProxyBy", billBizStructure["ProxyBy"]);
                            cm.Parameters.AddWithValue("@UrgentTelephone", billBizStructure["UrgentTelephone"]);
                            cm.Parameters.AddWithValue("@RequestBy", billBizStructure["CreatedBy"]);
                            cm.Parameters.AddWithValue("@RequestDate", billBizStructure["CreatedTime"]);
                            cm.Parameters.AddWithValue("@Remark", billBizStructure["Remark"]);
                            cm.Parameters.AddWithValue("@InsertedBy", billBizStructure["CreatedBy"]);
                            cm.Parameters.AddWithValue("@InsertedDate", billBizStructure["CreatedTime"]);
                            cm.Parameters.AddWithValue("@UpdatedBy", billBizStructure["CreatedBy"]);
                            cm.Parameters.AddWithValue("@UpdatedDate", billBizStructure["CreatedTime"]);
                            cm.Parameters.AddWithValue("@ConfirmedFlag", billBizStructure["ConfirmedFlag"]);
                            cm.ExecuteNonQuery();
                        }
                        tran.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        isSuccess = "False";
                        msg       = "处理失败:" + MyErrorMesage.GetError(ex.Message, false);
                        tran.Rollback();

                        SqlConnection cn11 = new SqlConnection(DataBase.PatData);
                        cn11.Open();
                        SqlCommand cm11 = cn11.CreateCommand();
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandTimeout = 9999999;
                        cm11.CommandType    = CommandType.Text;
                        cm11.CommandText    = string.Format(@"INSERT INTO [Jj_CY_CYDebug]
           ([CYDebugName]
           ,[CYDebugDateTime])
     VALUES
           (@CYDebugName
           ,GETDATE()) 
      ");
                        cm11.Parameters.AddWithValue("@CYDebugName", MyErrorMesage.GetError(ex.Message, false));
                        cm11.ExecuteNonQuery();
                        cn11.Close();
                        //throw ex;
                    }
                    finally
                    {
                        cn.Close();
                    }

                    string returnData = "{\"isSuccess\":\"" + isSuccess + "\",\"msg\":\"" + JsonMgr.StringToJson(msg) + "\"}";        //, isSuccess, "黎中一");

                    BizStructureSchema returnSchema = new H3.BizBus.BizStructureSchema();
                    returnSchema.Code = DateTime.Now.ToShortDateString();
                    returnSchema.Add(new H3.BizBus.ItemSchema("isSuccess", "是否成功", BizDataType.ShortString, 200, "True1"));
                    returnSchema.Add(new H3.BizBus.ItemSchema("msg", "返回信息", BizDataType.ShortString, 200, "True1"));

                    BizStructure returnBizStructure = new BizStructure(returnSchema);
                    BizStructureUtility.JsonToStructure(returnData, returnBizStructure, out errorMessage);
                    InvokeResult result = new H3.BizBus.InvokeResult(0, "服务器返回成功", returnBizStructure);
                    returnResult = BizStructureUtility.InvokeResultToJson(result);
                }
                break;

                default:
                    break;
                }
            }


            return(returnResult);
        }