/// <summary> /// 保存每天排班计划记录。 /// </summary> /// <param name="dataTable">数据表对象。</param> public void SaveShiftOfSchedule(DataTable dataTable) { DataSet dsReturn = new DataSet(); dsReturn.Tables.Add(dataTable); //每天排班计划集合不为空。 if (ScheduleDayList.Count > 0) { DataTable shiftDayTable = CAL_SCHEDULE_DAY.CreateDataTable(); //遍历每天排班计划集合中的记录。 foreach (ScheduleDay scheduleDay in ScheduleDayList) { Dictionary <string, string> rowData = new Dictionary <string, string>() { { CAL_SCHEDULE_DAY.FIELD_DKEY, scheduleDay.DKey }, { CAL_SCHEDULE_DAY.FIELD_STARTTIME, scheduleDay.StartTime }, { CAL_SCHEDULE_DAY.FIELD_ENDTIME, scheduleDay.EndTime }, { CAL_SCHEDULE_DAY.FIELD_SHIFT_VALUE, scheduleDay.ShiftValue }, { CAL_SCHEDULE_DAY.FIELD_SEQNO, scheduleDay.SeqNo }, { CAL_SCHEDULE_DAY.FIELD_SHIFT_KEY, scheduleDay.ShiftKey }, { CAL_SCHEDULE_DAY.FIELD_DAY, scheduleDay.Day } }; FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref shiftDayTable, rowData); } dsReturn.Tables.Add(shiftDayTable); } try { //远程调用的工厂对象。 IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); //工厂对象创建成功。 if (null != serverFactory) { //调用远程函数 dsReturn = serverFactory.CreateISchedule().SaveShiftOfSchedule(dsReturn); //远程函数执行结果消息。 _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (_errorMsg == "")//保存每天排班计划数据成功。 { this.ResetDirtyList(); //遍历日排班计划集合。 foreach (ScheduleDay scheduleDay in ScheduleDayList) { scheduleDay.OperationAction = OperationAction.Update; scheduleDay.IsInitializeFinished = true; } } } } catch (Exception ex) { _errorMsg = ex.Message; } finally { //关闭远程调用信道。 CallRemotingService.UnregisterChannel(); } }
/// <summary> /// 更新每天排班计划数据。 /// </summary> /// <returns>true:更新成功。false:更新失败。</returns> public bool UpdateShiftOfSchedule() { DataSet dsReturn = new DataSet(); if (IsDirty) //数据有不一致。 { //每天排班计划的数据集合不为空。 if (ScheduleDayList.Count > 0) { DataTable scheduleDayTable = CAL_SCHEDULE_DAY.CreateDataTable(); DataColumn mKeyDataRow = new DataColumn(CAL_SCHEDULE_DAY.FIELD_MKEY); DataColumn actionDataRow = new DataColumn(COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION); scheduleDayTable.Columns.Add(mKeyDataRow); //每月排班计划主键列。 scheduleDayTable.Columns.Add(actionDataRow); //操作动作列。 foreach (ScheduleDay scheduleDay in ScheduleDayList) { //记录操作动作为None或或者Update,则不需要进行更新。 if (scheduleDay.OperationAction == OperationAction.None || scheduleDay.OperationAction == OperationAction.Update) { continue; } else { //待更新的数据。添加到数据表中。 Dictionary <string, string> rowData = new Dictionary <string, string>() { { CAL_SCHEDULE_DAY.FIELD_DKEY, scheduleDay.DKey }, { CAL_SCHEDULE_DAY.FIELD_STARTTIME, scheduleDay.StartTime }, { CAL_SCHEDULE_DAY.FIELD_ENDTIME, scheduleDay.EndTime }, { CAL_SCHEDULE_DAY.FIELD_SHIFT_VALUE, scheduleDay.ShiftValue }, { CAL_SCHEDULE_DAY.FIELD_SEQNO, scheduleDay.SeqNo }, { CAL_SCHEDULE_DAY.FIELD_SHIFT_KEY, scheduleDay.ShiftKey }, { CAL_SCHEDULE_DAY.FIELD_DAY, scheduleDay.Day }, { CAL_SCHEDULE_DAY.FIELD_MKEY, MKey }, { COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION, Convert.ToString((int)scheduleDay.OperationAction) } }; FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref scheduleDayTable, rowData); } } //数据表中有待更新的记录。 if (scheduleDayTable.Rows.Count > 0) { dsReturn.Tables.Add(scheduleDayTable); } } try { //远程调用的工厂对象。 IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); //工厂对象创建成功。 if (null != serverFactory) { if (dsReturn.Tables.Count > 0) { //更新每天排班计划数据。 dsReturn = serverFactory.CreateISchedule().UpdateShiftOfSchedule(dsReturn); //远程函数执行结果消息。 _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); } else { _errorMsg = "${res:Global.UpdateItemDataMessage}"; } if (_errorMsg == "")//成功 { this.ResetDirtyList(); //遍历日排班计划集合。 foreach (ScheduleDay scheduleDay in ScheduleDayList) { scheduleDay.OperationAction = OperationAction.Update; scheduleDay.IsInitializeFinished = true; } } else { return(false); } } } catch (Exception ex) { _errorMsg = ex.Message; } finally { //关闭远程调用信道。 CallRemotingService.UnregisterChannel(); } } return(true); }