Exemple #1
0
        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);
            }
        }
        private bool ExecuteOrder(PushMsgModel pushMsgModel)
        {
            ADC_Status adcStatus  = new ADC_Status();
            ADCManager adcManager = new ADCManager();

            adcStatus.ADC_Index         = adcManager.CreateNewProcess(pushMsgModel);
            adcStatus.ADC_ProcessStatus = DefineManager.STATUS_CODE_RECEIVE_PUSH_MSG;

            ExecuteManager executeManager = new ExecuteManager();

            executeManager.pushMsgModel = pushMsgModel;
            executeManager.adcManager   = adcManager;
            executeManager.adcStatus    = adcStatus;

            adcManager.UpdateCurrentProcessStatus(adcStatus);

            return(executeManager.Execute());
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public void UpdateCurrentProcessStatus(ADC_Status adcStatus)
        {
            using (AutoDeployClientEntities context = new AutoDeployClientEntities())
                using (var tran = context.Database.BeginTransaction())
                {
                    try
                    {
                        ADC_Status selectedADCStatus = context.ADC_Status.Where(selectedADCStatusItem => selectedADCStatusItem.ADC_Index == adcStatus.ADC_Index).FirstOrDefault();
                        selectedADCStatus.ADC_ProcessMsg     = adcStatus.ADC_ProcessMsg;
                        selectedADCStatus.ADC_ProcessStatus  = adcStatus.ADC_ProcessStatus;
                        selectedADCStatus.ADC_UpdateDateTime = DateTime.Now;

                        context.SaveChanges();
                        tran.Commit();

                        LogManager.PrintLogMessage("ADCManager", "UpdateCurrentProcessStatus", "process status updated, status: " + adcStatus.ADC_StatusCode, DefineManager.LOG_LEVEL_DEBUG);
                    }
                    catch (Exception err)
                    {
                        tran.Rollback();
                        LogManager.PrintLogMessage("ADCManager", "UpdateCurrentProcessStatus", "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);
        }
Exemple #6
0
        public void UpdateCurrentProcessStatus(ADC_Status adcStatus)
        {
            using (AutoSecurityInspectClientEntities context = new AutoSecurityInspectClientEntities())
                using (var tran = context.Database.BeginTransaction())
                {
                    try
                    {
                        ADC_Status selectedADCStatus = context.ADC_Status.Where(selectedADCStatusItem => selectedADCStatusItem.ADC_Index == adcStatus.ADC_Index).FirstOrDefault();
                        selectedADCStatus.ADC_ProcessMsg     = adcStatus.ADC_ProcessMsg;
                        selectedADCStatus.ADC_ProcessStatus  = adcStatus.ADC_ProcessStatus;
                        selectedADCStatus.ADC_UpdateDateTime = DateTime.Now;

                        context.SaveChanges();
                        tran.Commit();

                        logManager.PrintLogMessage("ADCManager", "UpdateCurrentProcessStatus", "process status updated, status: " + adcStatus.ADC_StatusCode, System.Diagnostics.EventLogEntryType.Information);
                    }
                    catch (Exception err)
                    {
                        tran.Rollback();
                        logManager.PrintLogMessage("ADCManager", "UpdateCurrentProcessStatus", "cannot update process status: " + err.Message, System.Diagnostics.EventLogEntryType.Error);
                    }
                }
        }