Example #1
0
        public async Task <ActionResult> AddContract(ContractAddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddContractView", model));
            }

            var contract = new ApplicationContract()
            {
                EmployeeUID       = model.EmployeeUID,
                ContractStartDate = (DateTime)model.ContractStartDate,
                ContractEndDate   = model.ContractEndDate,
                ContractType      = (ContractTypes)model.ContractType,
                ContractNumber    = (int)model.ContractNumber
            };

            MemoryStream memoryStream = new MemoryStream();
            await model.ContractFile.InputStream.CopyToAsync(memoryStream);

            contract.ContractFile     = memoryStream.ToArray();
            contract.ContractFileName = model.ContractFile.FileName;

            await ApplicationService.ContractService.ContractAddContract(contract);


            return(PartialView());
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appContract"></param>
        private void ProcessQueue(ApplicationContract appContract)
        {
            if (appContract != null)
            {
                // Retrieve the connection string for this Application Contract.
                var connString = appContract.GenerateConnectionStr();

                // Retrieve the company data for the specified ID.
                CompanySettingsForId = new CompanySettings(connString, Config.CompanyId);

                // Create a new SQL Cache.
                MakoCache = new SqlCacheRepo(appContract.GenerateConnectionStr(), MakoLogger);

                // Create a new Queue management object.
                var queueManager = new QueueManagement(Config.CompanyId, appContract.GenerateConnectionStr());

                // Clear the queue for this Company ID.
                queueManager.ClearQueue();

                //
                IsRunning = true;

                //
                while (IsRunning)
                {
                    //
                    ProcessQueueItem(appContract, MakoLogger, MakoCache, queueManager);
                }
            }
        }
Example #3
0
        public async Task <ApplicationContract> ContractGetContactFile(Guid contractUID)
        {
            var contract = await ContractWorkflow.ContractGetContractFile(contractUID);

            var contractToReturn = new ApplicationContract()
            {
                ContractFile     = contract.ContractFile,
                ContractFileName = contract.ContractFileName
            };

            return(contractToReturn);
        }
Example #4
0
        public async Task <IActionResult> ExportData(string ids)//
        {
            var result = new ResultContract <ResultContract <string> >()
            {
                Code = 0, Msg = "导出成功"
            };

            try
            {
                DataTable  tblDatas = new DataTable("Datas");
                DataColumn dc       = null;
                dc = tblDatas.Columns.Add("序号", Type.GetType("System.Int32"));
                dc.AutoIncrement     = true;  //自动增加
                dc.AutoIncrementSeed = 1;     //起始为1
                dc.AutoIncrementStep = 1;     //步长为1
                dc.AllowDBNull       = false; //

                dc = tblDatas.Columns.Add("来源", Type.GetType("System.String"));
                dc = tblDatas.Columns.Add("所属系统", Type.GetType("System.String"));
                dc = tblDatas.Columns.Add("时间", Type.GetType("System.String"));
                dc = tblDatas.Columns.Add("图片", Type.GetType("System.String"));
                List <string> idList = ids.Split(",").ToList();
                foreach (var id in idList)
                {
                    var        returnResult = logic.GetTagsInfo(id);
                    EsContract contract     = SerializeHelper.deserializeToObject <EsContract>(returnResult.Data.ToString());
                    DataRow    newRow;
                    newRow       = tblDatas.NewRow();
                    newRow["来源"] = contract.orgName;
                    ApplicationContract appContract = new ApplicationContract();
                    appContract.Id = Guid.Parse(contract.appId);
                    var applist = applicationService.GetApplication(appContract);
                    newRow["所属系统"] = applist.Count > 0 ? applist[0].AppName : "";
                    DateTime time = (DateTime)contract.uploadTime;
                    newRow["时间"] = time.ToString("yyyy-MM-dd hh:mm:ss");
                    newRow["图片"] = contract.url;
                    tblDatas.Rows.Add(newRow);
                }

                MemoryStream ms = ExportHelper.RenderDataTableToExcel(tblDatas) as MemoryStream;

                return(File(ms.ToArray(), "application/vnd.ms-excel", "ExportImage.xls"));
            }
            catch (Exception e)
            {
                LogHelper.logError("查询ES失败:" + e.StackTrace);
                result.Code = -1;
                result.Msg  = e.StackTrace;
            }
            return(null);
        }
Example #5
0
 public async Task ContractAddContract(ApplicationContract applicationContract)
 {
     var contractEntitty = new ContractEntity()
     {
         EmployeeUID       = applicationContract.EmployeeUID,
         ContractType      = (int)applicationContract.ContractType,
         ContractFile      = applicationContract.ContractFile,
         ContractNumber    = applicationContract.ContractNumber,
         ContractFileName  = applicationContract.ContractFileName,
         ContractCreatedOn = DateTime.UtcNow,
         ContractStartDate = applicationContract.ContractStartDate,
         ContractEndDate   = applicationContract.ContractEndDate
     };
     await ContractWorkflow.ContractAddContract(contractEntitty);
 }
Example #6
0
        public async Task <ApplicationContract> ContractGetContract(Guid contractUID)
        {
            var contract = await ContractWorkflow.ContractGetContract(contractUID);

            var toReturn = new ApplicationContract()
            {
                ContractUID       = contract.ContractUID,
                EmployeeUID       = contract.EmployeeUID,
                ContractNumber    = contract.ContractNumber,
                ContractType      = (ContractTypes)contract.ContractType,
                ContractStartDate = contract.ContractStartDate,
                ContractEndDate   = contract.ContractEndDate
            };

            return(toReturn);
        }
Example #7
0
        /// <summary>
        /// 根据查询参数获取应用列表
        /// </summary>
        /// <param name="contract"></param>
        /// <returns></returns>
        public List <ApplicationContract> GetApplication(ApplicationContract contract)
        {
            var query = (from a in this._dbContext.Application
                         select new ApplicationContract
            {
                AppName = a.AppName,
                AppSecret = a.AppSecret,
                Id = a.Id,
                CreateTime = a.CreateTime,
                isDelete = a.isDelete,
                OrganizationId = a.OrganizationId
            });

            if (contract.Id != null)
            {
                query = query.Where(t => t.Id == contract.Id);
            }
            if (contract.AppName != null)
            {
                query = query.Where(t => t.AppName == contract.AppName);
            }
            return(query.ToList());
        }
Example #8
0
        public async Task <ResultContract <List <ApplicationContract> > > GetApplication([FromBody] ApplicationContract contract)
        {
            var result = new ResultContract <List <ApplicationContract> >()
            {
                Code = 0, Msg = "查询成功"
            };

            try
            {
                if (contract == null)
                {
                    contract = new ApplicationContract();
                }
                result.Data = applicationService.GetApplication(contract);
            }
            catch (Exception e)
            {
                LogHelper.logError("查询系统失败:" + e.StackTrace);
                result.Code = -1;
                result.Msg  = e.StackTrace;
            }

            return(result);
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appContract"></param>
        /// <param name="makoLogger"></param>
        /// <param name="makoCache"></param>
        /// <param name="queueManager"></param>
        private void ProcessQueueItem(ApplicationContract appContract, DelegateLogProvider makoLogger, SqlCacheRepo makoCache, QueueManagement queueManager)
        {
            // TODO: Find a smart way to check to see if there are changes to the connection strings and so forth

            //
            while (queueManager.FindNextQueueItem(out RunQueueItem item))             // TODO: Write authentication for app
            {
                //
                var startTime = DateTimeOffset.Now;
                _logRunTy      = item.RunTy;
                ConnectString  = appContract.GenerateConnectionStr();
                _logCompanyId  = Config.CompanyId;
                _logQueueId    = item.QueueId;
                _logPeriodType = item.PeriodTy;
                _logPeriodId   = item.PeriodId;

                try
                {
                    //
                    UpdateMakoAdmin(item, makoCache, makoLogger);

                    //
                    _listLog = new List <string>();
                    _listLog.Add("");
                    _listLog.Add($"{DateTime.UtcNow.ToString("G")} ------------------------------------------");
                    _listLog.Add(
                        $"{DateTime.UtcNow.ToString("G")} Now Processing Real Time -  QueueId {item.QueueId}");
                    _listLog.Add(
                        $"{DateTime.UtcNow.ToString("G")} RunTy({item.RunTy}), PlanId({item.PlanId}), RevisionId({item.RevisionId})");
                    _listLog.Add($"{DateTime.UtcNow.ToString("G")} ------------------------------------------");
                    _listLog.Add("");

                    // Assembly assm, string typesXML, string bonusXML, string glossaryXML,
                    // string overrideXML, string rankXML, string volumeXML
                    var myschema = new MakoXMLSchemas(
                        Assembly,
                        PlanName + ".MakoTypes.xml",
                        PlanName + ".MakoBonuses.xml",
                        "",
                        PlanName + ".MakoOverrides.xml",
                        PlanName + ".MakoRanks.xml",
                        PlanName + ".MakoVolumes.xml"
                        );
                    //
                    MakoConfig comConfig = new MakoConfig()
                    {
                        PeriodID  = item.PeriodId,
                        PeriodTy  = item.PeriodTy,
                        QueueID   = item.QueueId,
                        RunDescr  = item.RunDescr,
                        RunID     = item.RunId,
                        RunTy     = item.RunTy,
                        XMLSchema = myschema,
                        PlanID    = item.PlanId,
                        RevisonID = item.RevisionId
                    };
                    //
                    Admin.ProcessCommissions(comConfig);

                    //
                    var endTime = DateTimeOffset.Now;

                    //
                    if (comConfig.RunID != 0 && comConfig.RunTy != 4)
                    {
                        LoggingHelpers.UpdateRunLog(appContract.GenerateConnectionStr(), Config.CompanyId, item.QueueId,
                                                    comConfig.RunID);
                        queueManager.UpdateRunStartAndEndDate(appContract.GenerateConnectionStr(), Config.CompanyId, item.RunId,
                                                              startTime, endTime);
                    }

                    queueManager.DeleteQueueItem(item.QueueId);

                    var log = new FileLogger(Config.CompanyKey, item.QueueId, item.RunTy);
                    log.GenerateLog(_listLog);
                    _listLog.Clear();

                    //
                    if (!IsRunning)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    var log = new FileLogger(Config.CompanyKey, item.QueueId, item.RunTy);
                    _listLog.Add($"{DateTime.UtcNow.ToString("G")} [Error] " + ex.Message);
                    _listLog.Add($"{DateTime.UtcNow.ToString("G")} [Error] " + ex.StackTrace);
                    log.GenerateLog(_listLog);
                    _listLog.Clear();

                    //
                    queueManager.LogQueueError(appContract.GenerateConnectionStr(), Config.CompanyId, item.QueueId, ex);
                }
            }
            //
            Thread.Sleep(TimeSpan.FromSeconds(1));
        }