Esempio n. 1
0
        /// <summary>
        /// 添加日志
        /// </summary>
        public static void AddLog(string logType, string LogName, MesRequestParamModel LogMessMode)
        {
            var message = string.Format("调用MES接口未获取数据-参数信息-->SqlServer:{0},Database:{1},UserID_ID:{2},StartDate:{3},EndDate:{4},CustomerIDString:{5}", LogMessMode.SqlServer, LogMessMode.Database, LogMessMode.UserID_ID, LogMessMode.StartDate, LogMessMode.EndDate, LogMessMode.CustomerIDString);

            _LogService.AddLog(new LogMessageRecord()
            {
                LogType    = logType,
                LogName    = LogName,
                LogMessage = message,
                LogTime    = DateTime.Now,
                LogRemark  = "同步数据失败"
            });
        }
Esempio n. 2
0
 //获取MES接口
 public Recordset GetMesAPIData(MesRequestParamModel mesRequest)
 {
     //3 转换MES接口的数据
     try
     {
         WP_WIPRouteSteps wp = new WP_WIPRouteSteps();
         Recordset        re = wp.ListWIPHistory(mesRequest.SqlServer, mesRequest.Database, mesRequest.UserID_ID, mesRequest.StartDate, mesRequest.EndDate, mesRequest.CustomerIDString);
         //Recordset re = wp.ListWIPHistory("azapsectusql42", "jems", 794, "2018/03/29 12:00", "2018/03/29 14:00", "17");
         return(re);
     }
     catch (Exception ex)
     {
         return(new Recordset());
     }
 }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var requestParam            = textBox1.Text.ToString();
            MES_PIS_HandSyncBus Syncbus = new MES_PIS_HandSyncBus();
            var uid = 0;

            int.TryParse(requestParam, out uid);

            if (uid == 0)
            {
                if (MessageBox.Show(this, "请输入正确的同步ID?",
                                    "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                }
            }
            else
            {
                var syncModel = Syncbus.GetSyncFailedRecordByUID(uid);
                if (syncModel == null)
                {
                    if (MessageBox.Show(this, "未获取到需要同步的数据?",
                                        "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                    }
                }
                else
                {
                    try
                    {
                        var requestStr = syncModel.SyncRequest.Substring(syncModel.SyncRequest.IndexOf(':') + 1);
                        var reArray    = requestStr.Split(',');
                        MesRequestParamModel mesRequest = new MesRequestParamModel();
                        mesRequest.SqlServer        = reArray[0].ToString().Split('_')[1];
                        mesRequest.Database         = reArray[1].ToString().Split('_')[1];
                        mesRequest.UserID_ID        = int.Parse(reArray[2].ToString().Split('_')[1]);
                        mesRequest.StartDate        = reArray[3].ToString().Split('_')[1];
                        mesRequest.EndDate          = reArray[4].ToString().Split('_')[1];
                        mesRequest.CustomerIDString = reArray[5].ToString().Split('_')[1];
                        mesRequest.AssemblyIDString = reArray[5].ToString().Split('_')[1];

                        Recordset resultMesData = new Recordset();
                        resultMesData = Syncbus.GetMesAPIData(mesRequest);
                        var currenDate           = System.Convert.ToDateTime(mesRequest.StartDate);
                        var currentDateInfoModel = Syncbus.GetCurrentTime(currenDate);
                        var MesPeocessInfoList   = Syncbus.ConvertMesDateToPis(resultMesData);
                        var result = Syncbus.AddMES_PIS(uid, MesPeocessInfoList, currentDateInfoModel, mesRequest);
                        if (result)
                        {
                            if (MessageBox.Show(this, "同步成功?",
                                                "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                            {
                            }
                        }
                        else
                        {
                            if (MessageBox.Show(this, "同步失败?",
                                                "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                            {
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("同步失败:" + ex.Message.ToString());
                    }
                }
            }
        }
Esempio n. 4
0
        //添加数据
        public bool AddMES_PIS(int uid, List <MES_StationDataRecordDTO> mesDataList, CurentTimeModel CurrentDate, MesRequestParamModel mesRequest)
        {
            //是否发邮件
            var isSendEMail     = false;
            var isAddFailRecord = false;

            try
            {
                var pisConfigList   = _process_Service.GetSyscProcessConfig();
                var resultModelList = new List <MES_StationDataRecordDTO>();
                var convertModel    = mesDataList.GroupBy(p => p.MES_ProcessName).ToDictionary(p => p.Key, m => m);
                //筛选领料--待商议
                var AllPickIngModel = convertModel.Where(p => pisConfigList.Select(m => m.MES_PickingID).Contains(p.Key));
                var AllNgModel      = convertModel.Where(p => pisConfigList.Select(m => m.MES_NgID).Contains(p.Key));
                var AllReworkModel  = convertModel.Where(p => pisConfigList.Select(m => m.MES_ReworkID).Contains(p.Key));
                foreach (var item in AllNgModel)
                {
                    isAddFailRecord = true;
                    MES_StationDataRecord AddPisModel = new MES_StationDataRecord();
                    AddPisModel.Date              = CurrentDate.CurrentDay;
                    AddPisModel.TimeInterVal      = CurrentDate.CurrentInterval;
                    AddPisModel.StartTimeInterval = CurrentDate.CurrentStartMinute;
                    AddPisModel.EndTimeInterval   = CurrentDate.CurrentEndMinute;
                    AddPisModel.PIS_ProcessID     = pisConfigList.Where(p => p.MES_NgID == item.Key).FirstOrDefault().PIS_ProcessID;
                    AddPisModel.PIS_ProcessName   = pisConfigList.Where(p => p.MES_NgID == item.Key).FirstOrDefault().PIS_ProcessName;
                    AddPisModel.MES_ProcessID     = item.Value.FirstOrDefault().MES_ProcessID;
                    AddPisModel.MES_ProcessName   = item.Key;
                    AddPisModel.ProductQuantity   = item.Value.Count();
                    AddPisModel.ProjectName       = mesRequest.CustomerIDString;
                    AddPisModel.ProcessType       = "PIS-NG";
                    //resultModelList.Add(AddPisModel);
                    var result = _mes_Service.AddMesData(AddPisModel);
                    if (!result)
                    {
                        isSendEMail = true;
                        //AddMESSyncFailedLog("Failed", "AddPIS", mesRequest);
                    }
                }

                foreach (var item in AllReworkModel)
                {
                    isAddFailRecord = true;
                    MES_StationDataRecord AddPisModel = new MES_StationDataRecord();
                    AddPisModel.Date              = CurrentDate.CurrentDay;
                    AddPisModel.TimeInterVal      = CurrentDate.CurrentInterval;
                    AddPisModel.StartTimeInterval = CurrentDate.CurrentStartMinute;
                    AddPisModel.EndTimeInterval   = CurrentDate.CurrentEndMinute;
                    AddPisModel.PIS_ProcessID     = pisConfigList.Where(p => p.MES_ReworkID == item.Key).FirstOrDefault().PIS_ProcessID;
                    AddPisModel.PIS_ProcessName   = pisConfigList.Where(p => p.MES_ReworkID == item.Key).FirstOrDefault().PIS_ProcessName;
                    AddPisModel.MES_ProcessID     = item.Value.FirstOrDefault().MES_ProcessID;
                    AddPisModel.MES_ProcessName   = item.Key;
                    AddPisModel.ProductQuantity   = item.Value.Count();
                    AddPisModel.ProjectName       = mesRequest.CustomerIDString;
                    AddPisModel.ProcessType       = "PIS-ReWork";
                    var result = _mes_Service.AddMesData(AddPisModel);
                    if (!result)
                    {
                        isSendEMail = true;
                        //AddLog("Failed", "AddPIS", mesRequest);
                        //AddMESSyncFailedLog("Failed", "AddPIS", mesRequest);
                    }
                }

                foreach (var item in AllPickIngModel)
                {
                    isAddFailRecord = true;
                    MES_StationDataRecord AddPisModel = new MES_StationDataRecord();
                    AddPisModel.Date              = CurrentDate.CurrentDay;
                    AddPisModel.TimeInterVal      = CurrentDate.CurrentInterval;
                    AddPisModel.StartTimeInterval = CurrentDate.CurrentStartMinute;
                    AddPisModel.EndTimeInterval   = CurrentDate.CurrentEndMinute;
                    AddPisModel.PIS_ProcessID     = pisConfigList.Where(p => p.MES_PickingID == item.Key).FirstOrDefault().PIS_ProcessID;
                    AddPisModel.PIS_ProcessName   = pisConfigList.Where(p => p.MES_PickingID == item.Key).FirstOrDefault().PIS_ProcessName;
                    AddPisModel.MES_ProcessID     = item.Value.FirstOrDefault().MES_ProcessID;
                    AddPisModel.MES_ProcessName   = item.Key;
                    AddPisModel.ProductQuantity   = item.Value.Count();
                    AddPisModel.ProjectName       = mesRequest.CustomerIDString;
                    AddPisModel.ProcessType       = "PIS-PICK";
                    //resultModelList.Add(AddPisModel);
                    var result = _mes_Service.AddMesData(AddPisModel);
                    if (!result)
                    {
                        isSendEMail = true;
                        //AddLog("Failed", "AddPIS", mesRequest);
                        //AddMESSyncFailedLog("Failed", "AddPIS", mesRequest);
                    }
                }

                //手动同步失败更新状态和失败次数
                if (isAddFailRecord)
                {
                    if (isSendEMail)
                    {
                        UpdateSyncFailedLog("MES_PIS", "MES数据手动同步", false, uid, mesRequest);
                    }
                    else
                    {
                        UpdateSyncFailedLog("MES_PIS", "MES数据手动同步", true, uid, mesRequest);
                    }
                }

                //有数据同步成功
                if (isAddFailRecord && !isSendEMail)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _LogService.AddLog(new LogMessageRecord()
                {
                    LogType    = "手动同步-异常",
                    LogName    = "手动同步异常",
                    LogMessage = ex.Message.ToString(),
                    LogTime    = DateTime.Now,
                    LogRemark  = "添加_MES_StationDataRecord"
                });
                return(false);
            }
        }
Esempio n. 5
0
        public static void UpdateSyncFailedLog(string logType, string LogName, bool isSuccess, int uid, MesRequestParamModel LogMessMode)
        {
            var message = string.Format("调用MES接口未获取数据-参数信息-->SqlServer:{0},Database:{1},UserID_ID:{2},StartDate:{3},EndDate:{4},CustomerIDString:{5}", LogMessMode.SqlServer, LogMessMode.Database, LogMessMode.UserID_ID, LogMessMode.StartDate, LogMessMode.EndDate, LogMessMode.CustomerIDString);

            _SyncFailedLogServer.updateSyncFailedLog(new MES_PIS_SyncFailedRecordDTO()
            {
                MES_PIS_SyncFailedRecord_UID = uid,
                SyncType           = logType,
                SyncName           = LogName,
                SyncTime           = DateTime.Now,
                SyncRequest        = message,
                Is_ManuallySuccess = isSuccess,
                SyncResult         = "同步数据失败",
                OperateTime        = DateTime.Now,
            });
        }