Exemplo n.º 1
0
        //start stop work
        //存盘时时间的数据
        private static String Struct2TimeString(TimeInfo timeInfo)
        {         
            String timeString="2003-01-01 "+timeInfo.Hour+":"+timeInfo.Minute+":"+"00";
            DateTime time = DateTime.Parse(timeString);
            String timeResult = time.ToString();
            return timeResult;

        }
Exemplo n.º 2
0
        private static DateTime calcuWorkTimeMinute(String startWorkTime, String stopWorkTime, DateTime NowTime, out int startworkMinute, out int stopworkMinute, out int nowMinute)
        {
            TimeInfo startWorkInfos = new TimeInfo();
            startWorkInfos = DashboardManager.TimeString2Struct(startWorkTime);
            startworkMinute = Int32.Parse(startWorkInfos.Hour) * 60 + Int32.Parse(startWorkInfos.Minute);

            TimeInfo stopWorkInfos = new TimeInfo();
            stopWorkInfos = DashboardManager.TimeString2Struct(stopWorkTime);
            stopworkMinute = Int32.Parse(stopWorkInfos.Hour) * 60 + Int32.Parse(stopWorkInfos.Minute);

            if (stopworkMinute <= startworkMinute)
            {
                stopworkMinute = stopworkMinute + 24 * 60;
            }

            nowMinute = NowTime.Hour * 60 + NowTime.Minute;
            return NowTime;
        }
Exemplo n.º 3
0
 private static int Struct2TimeInt(TimeInfo time)
 {
     int result=0;            
     result+=Int32.Parse(time.Hour)*3600;
     result+=Int32.Parse(time.Minute)*60;
     result+=Int32.Parse(time.Second);
     return result;
 }
Exemplo n.º 4
0
        //start stop work
        public static TimeInfo TimeString2Struct(String timeString)
        {
            TimeInfo timeResult = new TimeInfo();
            try
            {
                DateTime time = DateTime.Parse(timeString);
                int hour = time.Hour;
                int minute = time.Minute;
                int second = 0;

                String formatHour = hour.ToString("00");
                String formatMinute = minute.ToString("00");
                String formatSecond = second.ToString("00");


                timeResult.Hour = formatHour;
                timeResult.Minute = formatMinute;
                timeResult.Second = formatSecond;
            }
            catch
            {
                //不需要处理
            }
            return timeResult;
        }
Exemplo n.º 5
0
        //刷新时间
        private static TimeInfo TimeInt2Struct(int time)
        {
            int countTime = time;
            int hour = (int)(countTime / 3600);
            countTime = countTime - hour * 3600;
            int minute = (int)(countTime / 60);
            countTime = countTime - minute * 60;
            int second = countTime;

            String formatHour=hour.ToString("00");
            String formatMinute=minute.ToString("00");
            String formatSecond=second.ToString("00");

            TimeInfo timeResult = new TimeInfo();
            timeResult.Hour = formatHour;
            timeResult.Minute = formatMinute;
            timeResult.Second = formatSecond;
            return timeResult;
        }
Exemplo n.º 6
0
        public static DashboardWindowInfo GetDashboardWindowSetting(String WindowId)
        {
            WindowId=GeneralUtil.Null2String(WindowId);

            DashboardWindowInfo result = new DashboardWindowInfo();

            if (WindowId == "")
            {
                return result;
            }
            else
            {
                DataTable DashboardMainInfo = GetEditDashboardMainByWinId(WindowId);
                if (DashboardMainInfo.Rows.Count == 0)
                {
                    ExceptionManager.Throw("The specified item has been removed.");
                }

                //还需要进一步转换添加等,注意每一位都要根据新的内容赋值
                result.WindowId=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["ID"]);
                result.WindowName=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["WindowName"]);

                result.DisplayName=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["DisplayName"]);
                result.AlertMessage=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["AlertMessage"]);
                result.RefreshTime=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["RefreshTime"]);

                TimeInfo timeInfos=new TimeInfo();
                if(result.RefreshTime!="")
                {
                    int freshTime=Int32.Parse(result.RefreshTime);
                    timeInfos= TimeInt2Struct(freshTime);
                   
                }
                result.Hour=timeInfos.Hour;
                result.Second=timeInfos.Second;
                result.Minute=timeInfos.Minute;

                result.DataSourceType=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["DataSourceType"]);
                result.StageTargetId=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StageTargetId"]);
                result.StageId=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StageId"]);
                result.StageName=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StageName"]);
                result.IsStageDisplay=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["IsStageDsp"]);
                result.StartWorkTime=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StartWorkTime"]);

                TimeInfo startWorkInfos=new TimeInfo();
                if(result.StartWorkTime!="")
                {
                    startWorkInfos= TimeString2Struct(result.StartWorkTime);
                   
                }

                result.StartWorkTimeHour=startWorkInfos.Hour;
                result.StartWorkTimeMinute=startWorkInfos.Minute;
                                
                result.StopWorkTime=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StopWorkTime"]);

                TimeInfo stopWorkInfos=new TimeInfo();
                if(result.StopWorkTime!="")
                {
                    stopWorkInfos= TimeString2Struct(result.StopWorkTime);
                   
                }

                result.StopWorkTimeHour=stopWorkInfos.Hour;
                result.StopWorkTimeMinute=stopWorkInfos.Minute;
                
                result.DisplayFields=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["DisplayFields"]);

                StageDisplayFieldInfo displayFieldInfos = new StageDisplayFieldInfo();

                if(result.DisplayFields!="")
                {
                    displayFieldInfos = StageDisplayFieldsString2Struct(result.DisplayFields);
                   
                }

                result.IsDnDisplay=displayFieldInfos.IsDnDisplay;
                result.IsFaInputDisplay =displayFieldInfos.IsFaInputDisplay ;
                result.IsFaOutputDisplay = displayFieldInfos.IsFaOutputDisplay;
                result.IsPaInputDisplay = displayFieldInfos.IsPaInputDisplay;
                result.IsPaOutputDisplay  = displayFieldInfos.IsPaOutputDisplay;
                result.IsGoalDisplay = displayFieldInfos.IsGoalDisplay;
                result.IsSaInputDisplay = displayFieldInfos.IsSaInputDisplay;
                result.IsSaOutputDisplay = displayFieldInfos.IsSaOutputDisplay;
                result.IsRateDisplay=displayFieldInfos.IsRateDisplay;


                result.Cdt=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["Cdt"]);
                result.Udt=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["Udt"]);
                result.Editor=GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["Editor"]);

                DataTable LineResult = GetEditLineListByWinId(WindowId);

                for (int i = 0; i < LineResult.Rows.Count; i++)
                {
                    WindowLineInfo lineInfo = new WindowLineInfo();
                    lineInfo.LineTargetId= GeneralUtil.Null2String(LineResult.Rows[i]["LineTargetId"]);
                    lineInfo.LineID= GeneralUtil.Null2String(LineResult.Rows[i]["LineId"]);
                    lineInfo.Stage= GeneralUtil.Null2String(LineResult.Rows[i]["SatgeName"]);
                    lineInfo.Line= GeneralUtil.Null2String(LineResult.Rows[i]["LineName"]);
                    lineInfo.FPYTarget= GeneralUtil.Null2String(LineResult.Rows[i]["FPYTarget"]);
                    lineInfo.FPYAlert = GeneralUtil.Null2String(LineResult.Rows[i]["FPYAlert"]);
                    lineInfo.OutputTarget = GeneralUtil.Null2String(LineResult.Rows[i]["OutputTarget"]);
                    lineInfo.StartWork= GeneralUtil.Null2String(LineResult.Rows[i]["StartWorkTime"]);

                    
                    TimeInfo lineStartWorkInfos=new TimeInfo();
                    if(lineInfo.StartWork!="")
                    {
                        lineStartWorkInfos= TimeString2Struct(lineInfo.StartWork);
                       
                    }
                    lineInfo.StartWorkHour=lineStartWorkInfos.Hour;
                    lineInfo.StartWorkMinute=lineStartWorkInfos.Minute;

                    lineInfo.StopWork= GeneralUtil.Null2String(LineResult.Rows[i]["StopWorkTime"]);

                    TimeInfo lineStopWorkInfos = new TimeInfo();
                    if (lineInfo.StopWork != "")
                    {
                        lineStopWorkInfos = TimeString2Struct(lineInfo.StopWork);

                    }
                    lineInfo.StopWorkHour = lineStopWorkInfos.Hour;
                    lineInfo.StopWorkMinute = lineStopWorkInfos.Minute;

                    lineInfo.StationDisplay= GeneralUtil.Null2String(LineResult.Rows[i]["IsStationDsp"]);
                    lineInfo.Order= GeneralUtil.Null2String(LineResult.Rows[i]["SortOrder"]);
                    List<WindowLineStationInfo> StationResult = GetEditStationListByLineAndWinId(WindowId, lineInfo.LineID);
                    lineInfo.WindowLineStationInfos = StationResult;
                    result.WindowLineInfos.Add(lineInfo);
                }
            }
            return result;
        }
Exemplo n.º 7
0
        public static WindowLineInfo GetLineBaseSettingInfo(String lineId)
        {
            WindowLineInfo result = new WindowLineInfo();
            String connectString = DatabaseUtil.GetConnectionString();

            String sqlString = "SELECT top 1  Dashboard_Line_Target.FPYTarget AS FPYTarget,Dashboard_Line_Target.FPYAlert AS FPYAlert, Dashboard_Line_Target.OutputTarget AS OutputTarget,[StartWorkTime],[StopWorkTime] FROM [Dashboard_Line_Target] WHERE [Line]=@param1";
            List<ConditionValueSet> paramList = new List<ConditionValueSet>();
            ConditionValueSet param1 = new ConditionValueSet();
            param1.ParamName = "@param1";
            param1.DataType = "char(10)";
            param1.ParamValue = lineId;
            paramList.Add(param1);

            DataTable sqlResult = DatabaseUtil.GetResultBySQL(sqlString, connectString, paramList);
            if (sqlResult.Rows.Count > 0)
            {

                result.OutputTarget = GeneralUtil.Null2String(sqlResult.Rows[0]["OutputTarget"]);
                result.FPYAlert = GeneralUtil.Null2String(sqlResult.Rows[0]["FPYAlert"]);
                result.FPYTarget = GeneralUtil.Null2String(sqlResult.Rows[0]["FPYTarget"]);

                String StartWorkTime = GeneralUtil.Null2String(sqlResult.Rows[0]["StartWorkTime"]);
                String StopWorkTime = GeneralUtil.Null2String(sqlResult.Rows[0]["StopWorkTime"]);

                TimeInfo startWorkInfos = new TimeInfo();
                if (StartWorkTime != "")
                {
                    startWorkInfos = TimeString2Struct(StartWorkTime);
                }
                TimeInfo stopWorkInfos = new TimeInfo();
                if (StopWorkTime != "")
                {
                    stopWorkInfos = TimeString2Struct(StopWorkTime);
                }

                result.StartWorkHour = startWorkInfos.Hour;
                result.StartWorkMinute = startWorkInfos.Minute;
                result.StopWorkHour = stopWorkInfos.Hour;
                result.StopWorkMinute = stopWorkInfos.Minute;

            }
            return result;

        }
Exemplo n.º 8
0
        public static List<TimeInfo> GetStageWorkTimeInfo(String stageId)
        {
            List<TimeInfo> result = new List<TimeInfo>();
            String connectString = DatabaseUtil.GetConnectionString();

            String sqlString = "SELECT top 1 [StartWorkTime],[StopWorkTime] FROM [Dashboard_Stage_Target] WHERE [Stage] = @param1";
            List<ConditionValueSet> paramList = new List<ConditionValueSet>();
            ConditionValueSet param1 = new ConditionValueSet();
            param1.ParamName = "@param1";
            param1.DataType = "char(10)";
            param1.ParamValue = stageId;
            paramList.Add(param1);

            DataTable sqlResult = DatabaseUtil.GetResultBySQL(sqlString, connectString, paramList);
            if (sqlResult.Rows.Count > 0)
            {
                String StartWorkTime = GeneralUtil.Null2String(sqlResult.Rows[0]["StartWorkTime"]);
                String StopWorkTime = GeneralUtil.Null2String(sqlResult.Rows[0]["StopWorkTime"]);

                TimeInfo startWorkInfos = new TimeInfo();
                if (StartWorkTime != "")
                {
                    startWorkInfos = TimeString2Struct(StartWorkTime);
                }
                TimeInfo stopWorkInfos = new TimeInfo();
                if (StopWorkTime != "")
                {
                    stopWorkInfos = TimeString2Struct(StopWorkTime);
                }

                result.Add(startWorkInfos);
                result.Add(stopWorkInfos);

            }
            return result;

        }
Exemplo n.º 9
0
        public static String SaveDashboardWindowSetting(DashboardWindowInfo windowInfo)
        {
            String connectString = DatabaseUtil.GetConnectionString();

            String windowId = GeneralUtil.Null2String( windowInfo.WindowId);
            String windowName=GeneralUtil.Null2String( windowInfo.WindowName);

            String sqlString = "";
            StringBuilder sqlStringBuilder = new StringBuilder();

            //同时更新全部相同的stage的start work和stop work的所有SQL
            StringBuilder sqlStageUpdateAllStringBuilder = new StringBuilder();
            //同时更新全部相同的line的start work和stop work的所有SQL
            StringBuilder sqlLineUpdateAllStringBuilder = new StringBuilder();

            List<ConditionValueSet> paramList = new List<ConditionValueSet>();
            int paramIndex=0;

            //如果原先有数据,先删除
            if (windowId != "")
            {
                CheckWindowSettingExist(windowId);

                ConditionValueSet paramItem = new ConditionValueSet();
                String paramName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramItem.ParamName = paramName;
                paramItem.DataType = "char(32)";
                paramItem.ParamValue = windowId;

                paramList.Add(paramItem);

                sqlStringBuilder.Append("DELETE FROM [Dashboard_Station_Target] WHERE WindowsID=").Append(paramName).Append(" ");
                sqlStringBuilder.Append("DELETE FROM [Dashboard_Line_Target] WHERE WindowsID=").Append(paramName).Append(" ");
                sqlStringBuilder.Append("DELETE FROM [Dashboard_Stage_Target] WHERE WindowID=").Append(paramName).Append(" ");
                sqlStringBuilder.Append("DELETE FROM [Dashboard_Window] WHERE ID=").Append(paramName).Append(" ");
            }
            else
            {
                //检查名称是否重复
                windowId = DatabaseUtil.GetUUID();
            }

            CheckWindowNameSame(windowName,windowId);

            ConditionValueSet paramItemWindowId = new ConditionValueSet(); 
            paramItemWindowId.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramItemWindowId.DataType = "char(32)";
            paramItemWindowId.ParamValue = windowId;
            paramList.Add(paramItemWindowId);

           ConditionValueSet paramWindowName = new ConditionValueSet(); 
            paramWindowName.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramWindowName.DataType = "nvarchar(128)";
            paramWindowName.ParamValue = windowName;
            paramList.Add(paramWindowName);

            ConditionValueSet paramDisplayName = new ConditionValueSet(); 
            paramDisplayName.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramDisplayName.DataType = "nvarchar(128)";
            paramDisplayName.ParamValue = GeneralUtil.Null2String( windowInfo.DisplayName);
            paramList.Add(paramDisplayName);


            ConditionValueSet paramAlertMessage = new ConditionValueSet(); 
            paramAlertMessage.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramAlertMessage.DataType = "nvarchar(512)";
            paramAlertMessage.ParamValue = GeneralUtil.Null2String( windowInfo.AlertMessage);
            paramList.Add(paramAlertMessage);

            TimeInfo timeInfos=new TimeInfo();
            timeInfos.Hour=windowInfo.Hour;
            timeInfos.Minute=windowInfo.Minute;
            timeInfos.Second=windowInfo.Second;
            int refreshTime=Struct2TimeInt(timeInfos);

            ConditionValueSet paramRefreshTime = new ConditionValueSet(); 
            paramRefreshTime.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramRefreshTime.DataType = "bigint";
            paramRefreshTime.ParamValue = refreshTime.ToString();
            paramList.Add(paramRefreshTime);

            ConditionValueSet paramDataSourceType = new ConditionValueSet(); 
            paramDataSourceType.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramDataSourceType.DataType = "int";
            paramDataSourceType.ParamValue = GeneralUtil.Null2String( windowInfo.DataSourceType);
            paramList.Add(paramDataSourceType);

            ConditionValueSet paramIsStageDsp = new ConditionValueSet(); 
            paramIsStageDsp.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramIsStageDsp.DataType = "bit";
            paramIsStageDsp.ParamValue = GeneralUtil.Null2String( windowInfo.IsStageDisplay);
            paramList.Add(paramIsStageDsp);

            ConditionValueSet paramCdt = new ConditionValueSet();
            //新建时
            if (windowInfo.Cdt != "")
            {                
                paramCdt.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramCdt.DataType = "datetime";
                paramCdt.ParamValue = GeneralUtil.Null2String(windowInfo.Cdt);
                paramList.Add(paramCdt);
            }

            ConditionValueSet paramEditor = new ConditionValueSet(); 
            paramEditor.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramEditor.DataType = "nvarchar(100)";
            paramEditor.ParamValue = GeneralUtil.Null2String( windowInfo.Editor);
            paramList.Add(paramEditor);


            //create time由于没有地方修改,而保留了原来的create time
            sqlStringBuilder.Append("INSERT INTO [Dashboard_Window] ([ID],[WindowName],[DisplayName],[AlertMessage],[RefreshTime]")
                .Append(",[DataSourceType],[IsStageDsp],[Cdt],[Udt],[Editor]) VALUES(")
                .Append(paramItemWindowId.ParamName).Append(",")
                .Append(paramWindowName.ParamName).Append(",")
                .Append(paramDisplayName.ParamName).Append(",")
                .Append(paramAlertMessage.ParamName).Append(",")
                .Append(paramRefreshTime.ParamName).Append(",")
                .Append(paramDataSourceType.ParamName).Append(",")
                .Append(paramIsStageDsp.ParamName).Append(",");
            if (windowInfo.Cdt != "")
            {
                sqlStringBuilder.Append(paramCdt.ParamName).Append(",");
            }
            else
            {
                sqlStringBuilder.Append("getdate()").Append(",");
            }
            sqlStringBuilder.Append("getdate()").Append(",")
                .Append(paramEditor.ParamName)
                .Append(") ");



            ConditionValueSet paramStageTargetId = new ConditionValueSet(); 
            paramStageTargetId.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStageTargetId.DataType = "char(32)";
            paramStageTargetId.ParamValue =  DatabaseUtil.GetUUID();
            paramList.Add(paramStageTargetId);

            ConditionValueSet paramStageId = new ConditionValueSet(); 
            paramStageId.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStageId.DataType = "char(10)";
            paramStageId.ParamValue = GeneralUtil.Null2String( windowInfo.StageId);
            paramList.Add(paramStageId);

            //window id见上面

            TimeInfo stageStartWorkTimeInfo=new TimeInfo ();
            stageStartWorkTimeInfo.Hour= windowInfo.StartWorkTimeHour;
            stageStartWorkTimeInfo.Minute=windowInfo.StartWorkTimeMinute;
            String stageStartWorkTime=Struct2TimeString(stageStartWorkTimeInfo);

            ConditionValueSet paramStartWorkTime = new ConditionValueSet(); 
            paramStartWorkTime.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStartWorkTime.DataType = "datetime";
            paramStartWorkTime.ParamValue =stageStartWorkTime;
            paramList.Add(paramStartWorkTime);

            TimeInfo stageStopWorkTimeInfo=new TimeInfo ();
            stageStopWorkTimeInfo.Hour= windowInfo.StopWorkTimeHour;
            stageStopWorkTimeInfo.Minute=windowInfo.StopWorkTimeMinute;
            String stageStopWorkTime=Struct2TimeString(stageStopWorkTimeInfo);

            ConditionValueSet paramStopWorkTime = new ConditionValueSet(); 
            paramStopWorkTime.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStopWorkTime.DataType = "datetime";
            paramStopWorkTime.ParamValue =stageStopWorkTime;
            paramList.Add(paramStopWorkTime);

            StageDisplayFieldInfo stageDisplayFieldInfo=new StageDisplayFieldInfo ();
            stageDisplayFieldInfo.IsDnDisplay = windowInfo.IsDnDisplay;
            stageDisplayFieldInfo.IsFaInputDisplay = windowInfo.IsFaInputDisplay;
            stageDisplayFieldInfo.IsFaOutputDisplay = windowInfo.IsFaOutputDisplay;
            stageDisplayFieldInfo.IsPaInputDisplay = windowInfo.IsPaInputDisplay;
            stageDisplayFieldInfo.IsPaOutputDisplay = windowInfo.IsPaOutputDisplay;
            stageDisplayFieldInfo.IsGoalDisplay = windowInfo.IsGoalDisplay;
            stageDisplayFieldInfo.IsSaInputDisplay = windowInfo.IsSaInputDisplay;
            stageDisplayFieldInfo.IsSaOutputDisplay = windowInfo.IsSaOutputDisplay;
            stageDisplayFieldInfo.IsRateDisplay = windowInfo.IsRateDisplay;


            String stageDisplayFieldValue =Struct2StageDisplayFieldsString(stageDisplayFieldInfo);

            ConditionValueSet paramDisplayFields = new ConditionValueSet(); 
            paramDisplayFields.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramDisplayFields.DataType = "varchar(100)";
            paramDisplayFields.ParamValue =stageDisplayFieldValue;
            paramList.Add(paramDisplayFields);

            StringBuilder sqlStageStringBuilder = new StringBuilder();
            sqlStageStringBuilder.Append("INSERT INTO [Dashboard_Stage_Target] ([ID],[Stage],[WindowID],[StartWorkTime],[StopWorkTime],[DisplayFields])")
                .Append("VALUES(")
                .Append(paramStageTargetId.ParamName).Append(",")
                .Append(paramStageId.ParamName).Append(",")
                .Append(paramItemWindowId.ParamName).Append(",")
                .Append(paramStartWorkTime.ParamName).Append(",")
                .Append(paramStopWorkTime.ParamName).Append(",")
                .Append(paramDisplayFields.ParamName)
                .Append(") ");

            sqlStageUpdateAllStringBuilder.Append("UPDATE [Dashboard_Stage_Target] SET [StartWorkTime] = ")
                .Append(paramStartWorkTime.ParamName).Append(",")
                .Append("[StopWorkTime] =")
                .Append(paramStopWorkTime.ParamName)
                .Append(" WHERE [Stage]=")
                .Append(paramStageId.ParamName).Append(" ");

            StringBuilder sqlLineStringBuilder = new StringBuilder();
            StringBuilder sqlStationStringBuilder = new StringBuilder();

            //判断windowId,如果不为空,先删除对应的station,line, stage window,再加入
            for (int i = 0; i < windowInfo.WindowLineInfos.Count; i++)
            {
                WindowLineInfo lineItem= windowInfo.WindowLineInfos[i];  
           
                ConditionValueSet paramLineTargetId = new ConditionValueSet(); 
                paramLineTargetId.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineTargetId.DataType = "char(32)";
                paramLineTargetId.ParamValue =  DatabaseUtil.GetUUID();
                paramList.Add(paramLineTargetId);

                ConditionValueSet paramLineId = new ConditionValueSet(); 
                paramLineId.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineId.DataType = "char(10)";
                paramLineId.ParamValue =  GeneralUtil.Null2String(lineItem.LineID);
                paramList.Add(paramLineId);

                ConditionValueSet paramOutputTarget = new ConditionValueSet(); 
                paramOutputTarget.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramOutputTarget.DataType = "int";
                paramOutputTarget.ParamValue = GeneralUtil.Null2String(lineItem.OutputTarget);
                paramList.Add(paramOutputTarget);

                ConditionValueSet paramFPYTarget = new ConditionValueSet(); 
                paramFPYTarget.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramFPYTarget.DataType = "float";
                paramFPYTarget.ParamValue = GeneralUtil.Null2String(lineItem.FPYTarget);
                paramList.Add(paramFPYTarget);

                ConditionValueSet paramFPYAlert = new ConditionValueSet();
                paramFPYAlert.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramFPYAlert.DataType = "float";
                paramFPYAlert.ParamValue = GeneralUtil.Null2String(lineItem.FPYAlert);
                paramList.Add(paramFPYAlert);

                TimeInfo lineStartWorkTimeInfo=new TimeInfo ();
                lineStartWorkTimeInfo.Hour= lineItem.StartWorkHour;
                lineStartWorkTimeInfo.Minute=lineItem.StartWorkMinute;
                String lineStartWorkTime=Struct2TimeString(lineStartWorkTimeInfo);

                ConditionValueSet paramLineStartWorkTime = new ConditionValueSet(); 
                paramLineStartWorkTime.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineStartWorkTime.DataType = "datetime";
                paramLineStartWorkTime.ParamValue = lineStartWorkTime;
                paramList.Add(paramLineStartWorkTime);

                TimeInfo lineStopWorkTimeInfo=new TimeInfo ();
                lineStopWorkTimeInfo.Hour= lineItem.StopWorkHour;
                lineStopWorkTimeInfo.Minute=lineItem.StopWorkMinute;
                String lineStopWorkTime=Struct2TimeString(lineStopWorkTimeInfo);

                ConditionValueSet paramLineStopWorkTime = new ConditionValueSet(); 
                paramLineStopWorkTime.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineStopWorkTime.DataType = "datetime";
                paramLineStopWorkTime.ParamValue = lineStopWorkTime;
                paramList.Add(paramLineStopWorkTime);

                ConditionValueSet paramIsStationDsp = new ConditionValueSet(); 
                paramIsStationDsp.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramIsStationDsp.DataType = "bit";
                paramIsStationDsp.ParamValue = lineItem.StationDisplay;
                paramList.Add(paramIsStationDsp);

                ConditionValueSet paramLineOrder = new ConditionValueSet(); 
                paramLineOrder.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineOrder.DataType = "int";
                paramLineOrder.ParamValue = i.ToString();
                paramList.Add(paramLineOrder);

                sqlLineStringBuilder.Append("INSERT INTO [Dashboard_Line_Target] ([ID],[WindowsID],[Line],[OutputTarget],[FPYTarget],[FPYAlert],[StartWorkTime],[StopWorkTime],[IsStationDsp],[Order])")
                 .Append("VALUES (")
                 .Append(paramLineTargetId.ParamName).Append(",")   
                 .Append(paramItemWindowId.ParamName).Append(",")
                 .Append(paramLineId.ParamName).Append(",")
                 .Append(paramOutputTarget.ParamName).Append(",")
                 .Append(paramFPYTarget.ParamName).Append(",")
                 .Append(paramFPYAlert.ParamName).Append(",")
                 .Append(paramLineStartWorkTime.ParamName).Append(",")
                 .Append(paramLineStopWorkTime.ParamName).Append(",")
                 .Append(paramIsStationDsp.ParamName).Append(",")
                 .Append(paramLineOrder.ParamName )
                 .Append(") ");

                //存盘时,相同的line的基本数据同时变
                sqlLineUpdateAllStringBuilder.Append("UPDATE [Dashboard_Line_Target] SET [StartWorkTime] = ")
                .Append(paramLineStartWorkTime.ParamName)
                .Append(",[StopWorkTime] =")
                .Append(paramLineStopWorkTime.ParamName)
                .Append(",[OutputTarget] =")
                .Append(paramOutputTarget.ParamName)
                .Append(",[FPYTarget] =")
                .Append(paramFPYTarget.ParamName)
                .Append(",[FPYAlert] =")
                .Append(paramFPYAlert.ParamName)
                .Append(" WHERE [Line]=")
                .Append(paramLineId.ParamName).Append(" ");

                //存SA的目标量
               // String SA = ConfigurationManager.AppSettings["SA"].ToString();
               // ConditionValueSet paramSaStage = new ConditionValueSet(); 
               // paramSaStage.ParamName = "@param" + paramIndex;
               // paramIndex = paramIndex + 1;
               // paramSaStage.DataType = "char";
               // paramSaStage.ParamValue = SA;
               // paramList.Add(paramSaStage);

               // sqlLineUpdateAllStringBuilder.Append("DELETE FROM [Dashboard_StageGoal] WHERE Stage=")
               //.Append(paramSaStage.ParamName).Append(" ")
               //.Append("INSERT INTO [Dashboard_StageGoal] ([Stage],[Goal]) ")
               //.Append("SELECT a.Stage, SUM(a.OutputTarget) as GoalNum ")
               //.Append("FROM (SELECT DISTINCT [Dashboard_Line_Target].[Line] ")
               //.Append(",[Dashboard_Line_Target].[OutputTarget],[Line].Stage ")
               //.Append("FROM [Dashboard_Line_Target] INNER JOIN [Line] ")
               //.Append("ON [Dashboard_Line_Target].[Line]=[Line].[Line] ")
               //.Append("WHERE [Line].Stage=")
               //.Append(paramSaStage.ParamName).Append(" ) AS a GROUP BY a.Stage ");


                for (int j = 0; j < lineItem.WindowLineStationInfos.Count; j++)
                {

                    WindowLineStationInfo stationItem= lineItem.WindowLineStationInfos[j];  

                    ConditionValueSet paramStationTargetId = new ConditionValueSet(); 
                    paramStationTargetId.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramStationTargetId.DataType = "char(32)";
                    paramStationTargetId.ParamValue =  DatabaseUtil.GetUUID();
                    paramList.Add(paramStationTargetId);

                    ConditionValueSet paramStationId = new ConditionValueSet(); 
                    paramStationId.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramStationId.DataType = "char(10)";
                    paramStationId.ParamValue = GeneralUtil.Null2String(stationItem.StationId);
                    paramList.Add(paramStationId);
                    
                    ConditionValueSet paramYieldTarget = new ConditionValueSet(); 
                    paramYieldTarget.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramYieldTarget.DataType = "float";
                    paramYieldTarget.ParamValue = GeneralUtil.Null2String(stationItem.YieldTarget);
                    paramList.Add(paramYieldTarget);

                    //true 1 True都可
                    ConditionValueSet paramFactorOfFPY = new ConditionValueSet();
                    paramFactorOfFPY.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramFactorOfFPY.DataType = "bit";
                    paramFactorOfFPY.ParamValue = GeneralUtil.Null2String(stationItem.FactorOfFPY);
                    paramList.Add(paramFactorOfFPY);

                    StationDisplayFieldInfo stationDisplayFieldsInfo=new StationDisplayFieldInfo ();
                    stationDisplayFieldsInfo.DefectDsp=stationItem.Defect;
                    stationDisplayFieldsInfo.QuantityDsp=stationItem.Quantity;
                    stationDisplayFieldsInfo.WIPDsp=stationItem.WIP;
                    stationDisplayFieldsInfo.YieldRateDsp=stationItem.YieldRate;

                    String stationDisplayFieldsInfoValue=Struct2StationDisplayFieldsString(stationDisplayFieldsInfo);

                    ConditionValueSet paramStationDisplayFields = new ConditionValueSet(); 
                    paramStationDisplayFields.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramStationDisplayFields.DataType = "varchar(100)";
                    paramStationDisplayFields.ParamValue = stationDisplayFieldsInfoValue;
                    paramList.Add(paramStationDisplayFields);

                    ConditionValueSet paramStationOrder = new ConditionValueSet(); 
                    paramStationOrder.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramStationOrder.DataType = "int";
                    paramStationOrder.ParamValue = j.ToString();
                    paramList.Add(paramStationOrder);

                    sqlStationStringBuilder.Append("INSERT INTO [Dashboard_Station_Target] ([ID],[WindowsID],[Line],[Station],[YieldTarget],[FactorOfFPY],[DisplayFields],[Order])")
                        .Append("VALUES (")
                        .Append(paramStationTargetId.ParamName).Append(",")   
                        .Append(paramItemWindowId.ParamName).Append(",")
                        .Append(paramLineId.ParamName).Append(",")
                        .Append(paramStationId.ParamName).Append(",")
                        .Append(paramYieldTarget.ParamName).Append(",")
                        .Append(paramFactorOfFPY.ParamName).Append(",")
                        .Append(paramStationDisplayFields.ParamName).Append(",")
                        .Append(paramStationOrder.ParamName)
                        .Append(") ");

                }
            }

            sqlString = sqlStringBuilder.ToString() + sqlStageStringBuilder.ToString() + sqlLineStringBuilder.ToString() + sqlStationStringBuilder.ToString() + sqlStageUpdateAllStringBuilder.ToString() + sqlLineUpdateAllStringBuilder.ToString();
            DatabaseUtil.ExecSqlNonQueryWithParam(sqlString, connectString, paramList);

            return windowId;
        }