private void RunDeployProcess(ADC_PushData adcPushData) { ADC_Status adcStatus = adcManager.FindCurrentStatus(adcPushData); try { if (adcStatus == null) { logManager.PrintLogMessage("AutoDeployRoutineManager", "RunDeployProcess", "cannot find adc status, process #" + adcPushData.ADC_Index, System.Diagnostics.EventLogEntryType.Warning); return; } adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_PUBLISHING; adcManager.UpdateCurrentProcessStatus(adcStatus); FileManager.DirectoryCopy(adcPushData.ADC_ExtractedPath, adcPushData.ADC_UpdateTargetPath, true); adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_PUBLISH_DONE; adcManager.UpdateCurrentProcessStatus(adcStatus); logManager.PrintLogMessage("AutoDeployRoutineManager", "RunDeployProcess", "deploy successfully #" + adcPushData.ADC_Index, System.Diagnostics.EventLogEntryType.SuccessAudit); } catch (Exception err) { if (adcStatus != null) { adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_PUBLISH_ERROR; adcStatus.ADC_ProcessMsg = err.Message; adcManager.UpdateCurrentProcessStatus(adcStatus); } logManager.PrintLogMessage("AutoDeployRoutineManager", "RunDeployProcess", "cannot deploy current process #" + adcPushData.ADC_Index, System.Diagnostics.EventLogEntryType.Error); } }
public int CreateNewProcess(PushMsgModel pushMsgModel) { int newProcessId = DefineManager.NOT_AVAILABLE; using (AutoDeployClientEntities context = new AutoDeployClientEntities()) using (var tran = context.Database.BeginTransaction()) { try { ADC_PushData adcPushData = new ADC_PushData(); adcPushData.ADC_OrderType = pushMsgModel.orderType; adcPushData.ADC_DownloadUrl = pushMsgModel.downloadUrl; adcPushData.ADC_UpdateTargetPath = pushMsgModel.updateTargetPath; adcPushData.ADC_PushMsg = pushMsgModel.msg; adcPushData.ADC_Version = pushMsgModel.version; adcPushData.ADC_CallbackUrl = pushMsgModel.callbackUrl; adcPushData.ADC_FileType = pushMsgModel.fileType; context.ADC_PushData.Add(adcPushData); context.SaveChanges(); newProcessId = adcPushData.ADC_Index; ADC_Status adcStatus = new ADC_Status(); adcStatus.ADC_Index = newProcessId; adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_DEFAULT; adcStatus.ADC_UpdateDateTime = DateTime.Now; context.ADC_Status.Add(adcStatus); context.SaveChanges(); tran.Commit(); LogManager.PrintLogMessage("ADCManager", "CreateNewProcess", "process created, id: " + newProcessId, DefineManager.LOG_LEVEL_DEBUG); } catch (Exception err) { tran.Rollback(); LogManager.PrintLogMessage("ADCManager", "CreateNewProcess", "cannot create new process: " + err.Message, DefineManager.LOG_LEVEL_ERROR); } } return(newProcessId); }
private void RutineAutoUpdate() { adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_DOWNLOADING_DEPLOY_FILE; adcManager.UpdateCurrentProcessStatus(adcStatus); String downloadedFilePath = FileManager.DownloadWebFile(pushMsgModel.downloadUrl, DefineManager.DIR_UPDATE_PATH, pushMsgModel.fileType); String extractedFilePath = null; if (downloadedFilePath != null) { adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_EXTRACTING_DEPLOY_FILE; adcManager.UpdateCurrentProcessStatus(adcStatus); extractedFilePath = FileManager.ExtractZipFile(downloadedFilePath); if (extractedFilePath != null) { ADC_PushData adcPushData = new ADC_PushData(); adcPushData.ADC_Index = adcStatus.ADC_Index; adcPushData.ADC_DownloadedPath = HttpContext.Current.Server.MapPath(downloadedFilePath); adcPushData.ADC_ExtractedPath = extractedFilePath; adcManager.UpdateCurrentProcessInfo(adcPushData); adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_DEPLOY_FILE_IS_READY; adcManager.UpdateCurrentProcessStatus(adcStatus); } else { adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_ERROR_WHILE_EXTRACTING_DEPLOY_FILE; LogManager.PrintLogMessage("ExecuteManager", "RutineAutoUpdate", "extract file failed", DefineManager.LOG_LEVEL_WARN); throw new Exception(); } } else { adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_ERROR_WHILE_DOWNLOADING_DEPLOY_FILE; LogManager.PrintLogMessage("ExecuteManager", "RutineAutoUpdate", "download file failed", DefineManager.LOG_LEVEL_WARN); throw new Exception(); } }
public void UpdateCurrentProcessInfo(ADC_PushData adcPushData) { using (AutoDeployClientEntities context = new AutoDeployClientEntities()) using (var tran = context.Database.BeginTransaction()) { try { ADC_PushData selectedADCPushData = context.ADC_PushData.Where(selectedADCPushDataItem => selectedADCPushDataItem.ADC_Index == adcPushData.ADC_Index).FirstOrDefault(); selectedADCPushData.ADC_DownloadedPath = adcPushData.ADC_DownloadedPath; selectedADCPushData.ADC_ExtractedPath = adcPushData.ADC_ExtractedPath; context.SaveChanges(); tran.Commit(); LogManager.PrintLogMessage("ADCManager", "UpdateCurrentProcessInfo", "process info updated, downloaded path: " + selectedADCPushData.ADC_DownloadedPath + " extracted path: " + selectedADCPushData.ADC_ExtractedPath, DefineManager.LOG_LEVEL_DEBUG); } catch (Exception err) { tran.Rollback(); LogManager.PrintLogMessage("ADCManager", "UpdateCurrentProcessInfo", "cannot update process status: " + err.Message, DefineManager.LOG_LEVEL_ERROR); } } }
public ADC_Status FindCurrentStatus(ADC_PushData adcPushData) { ADC_Status selectedADCStatus = null; using (AutoDeployClientEntities context = new AutoDeployClientEntities()) using (var tran = context.Database.BeginTransaction()) { try { selectedADCStatus = context.ADC_Status.Where(selectedADCStatusItem => selectedADCStatusItem.ADC_Index == adcPushData.ADC_Index).FirstOrDefault(); context.SaveChanges(); tran.Commit(); logManager.PrintLogMessage("ADCManager", "FindCurrentStatus", "process status updated, status: " + selectedADCStatus.ADC_StatusCode, System.Diagnostics.EventLogEntryType.Information); } catch (Exception err) { tran.Rollback(); logManager.PrintLogMessage("ADCManager", "FindCurrentStatus", "cannot update process status: " + err.Message, System.Diagnostics.EventLogEntryType.Error); } } return(selectedADCStatus); }