Ejemplo n.º 1
0
        /*
         * The actual implementation of PostRequest.
         */
        private bool PostRequest(WorkRequest request)
        {
            Monitor.Enter(_syncLock);
            try
            {
                /*
                 * A requestQueueLimit of -1 means the queue is "unbounded"
                 * (subject to available resources).  IOW, no artificial limit
                 * has been placed on the maximum # of requests that can be
                 * placed into the queue.
                 */
                if (_requestQueueLimit == -1 || _requestQueue.Count < _requestQueueLimit)
                {
                    try
                    {
                        _requestQueue.Enqueue(request);
                        Monitor.Pulse(_syncLock);
                        return(true);
                    }
                    catch
                    {
                    }
                }
            }
            finally
            {
                Monitor.Exit(_syncLock);
            }

            return(false);
        }
 internal WorkRequest[] GetWorkRequests([Optional] WorkRequest matchOnValues)
 {
     try
     {
         if (matchOnValues != null)
         {
             return(dao.GetWorkRequest(matchOnValues));
         }
         else
         {
             return(dao.GetWorkRequest());
         }
     }
     catch (Exception ex)
     {
         if (matchOnValues != null)
         {
             Error.Log(ex, "Data sent to method was : " + Utility.objectToSql(matchOnValues));
         }
         else
         {
             Error.Log(ex);
         }
         throw;
     }
 }
Ejemplo n.º 3
0
        public void Update(WorkRequest obj)
        {
            UpdateRoot(obj);

            if (obj.WorkType == "NOND")
            {
                CreateOrUpdateNonDesigned(obj);
            }
            //if (obj.ExtraDetails != null)
            //{
            //    new ExtraDetailsBl().Create(obj.ExtraDetails);
            //}
            //if (obj.Premises != null && obj.Premises.Count > 0)
            //{
            //    new PremiseBl().Update(obj.Premises);
            //}
            //if (obj.GasLoadDetails != null && obj.GasLoadDetails.Count > 0)
            //{
            //    //Use Create here because of "pivot" table
            //    new GasLoadDetailBl().Create(obj.GasLoadDetails);
            //}
            //if (obj.MilestoneRequirements != null && obj.MilestoneRequirements.Count > 0)
            //{
            //    new MilestoneRequirementBl().Update(obj.MilestoneRequirements);
            //}
            //if (obj.Specifications != null && obj.Specifications.Count > 0)
            //{
            //    foreach (var item in obj.Specifications)
            //    {
            //        new DesignBl().CreateExternalDesign(item);
            //    }
            //}
        }
Ejemplo n.º 4
0
        private void CreateOrUpdateNonDesigned(WorkRequest workRequest)
        {
            WorkRequestNonDesigned wrnd = new WorkRequestNonDesignedBl().GetNonDesigned(workRequest.WorkRequestId, workRequest.District);

            if (wrnd == null)
            {
                JobCode jc = new JobCodeBl().GetById(workRequest.JobCode);

                wrnd = new WorkRequestNonDesigned();

                wrnd.CD_WR          = workRequest.WorkRequestId;
                wrnd.CD_DIST        = workRequest.District;
                wrnd.DS_JOB         = jc.DS_JOB;
                wrnd.CD_JOB         = jc.CD_JOB;
                wrnd.FG_REINITIATED = "N";

                new WM.STORMS.BusinessLayer.BusinessLogic.WorkRequestNonDesignedBl().Create(wrnd);
            }
            else
            {
                wrnd.DS_JOB         = workRequest.JobDescription;
                wrnd.CD_JOB         = workRequest.JobCode;
                wrnd.FG_REINITIATED = "N";

                new WM.STORMS.BusinessLayer.BusinessLogic.WorkRequestNonDesignedBl().Update(wrnd);
            }
        }
        public async Task <ActionResult <WorkRequest> > PostWorkRequest(WorkRequest workRequest)
        {
            _context.WorkRequest.Add(workRequest);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWorkRequest", new { id = workRequest.id }, workRequest));
        }
        async void SaveWorkRequest()
        {
            progressBar.Visibility = Visibility.Visible;
            cancelButton.IsEnabled = false;
            saveButton.IsEnabled   = false;

            WorkRequest = new WorkRequest {
                WorkRequestId = Guid.NewGuid(), CreatedByUser = AppGlobals.UserThatIsLoggedin, RequestDate = RequestDate.Value, Description = RequestDescription, WorkStatus = WorkStatus, WorkType = WorkType, SoftwareType = SoftwareType, UsersAssigned = AssignedToUsers, Customer = Customer
            };

            var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();


            try
            {
                // Add workRequest
                WorkRequest = await client.AddWorkRequestAsync(WorkRequest);

                WorkRequestWasAdded = true;
                Close();
                MessageBox.Show("Work request was added.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 7
0
        private void SetupSentimentServices(IServiceCollection builder, SentimentConfig sentiment)
        {
            if (string.IsNullOrEmpty(sentiment.Url))
            {
                logger.LogInformation("Sentiment service is not configured.");
                return;
            }

            logger.LogInformation("Setting up sentiment services...");
            builder.AddSingleton <IStreamApiClientFactory>(context => new StreamApiClientFactory(context.GetRequiredService <ILoggerFactory>(),
                                                                                                 new HttpClient
            {
                Timeout = TimeSpan.FromMinutes(10)
            },
                                                                                                 new Uri(sentiment.Url)));
            var request = new WorkRequest
            {
                CleanText = true,
                Domain    = sentiment.Domain
            };

            builder.AddSingleton(request);
            builder.AddTransient <ISentimentAnalysis, SentimentAnalysis>();
            logger.LogInformation("Register sentiment: {0} {1}", sentiment.Url, sentiment.Domain);
        }
        public async Task <IActionResult> PutWorkRequest(int id, WorkRequest workRequest)
        {
            if (id != workRequest.id)
            {
                return(BadRequest());
            }

            _context.Entry(workRequest).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkRequestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 9
0
        // The actual implementation of PostRequest.
        //
        bool PostRequest(WorkRequest request)
        {
            lock (this)
            {
                // A requestQueueLimit of -1 means the queue is "unbounded"
                // (subject to available resources).  IOW, no artificial limit
                // has been placed on the maximum # of requests that can be
                // placed into the queue.
                //
                if ((requestQueueLimit == -1) || (requestQueue.Count < requestQueueLimit))
                {
                    try
                    {
                        //LibSys.StatusBar.Trace("======== thread enqueue request=" + request.procArg + " count=" + requestQueue.Count + " limit=" + requestQueueLimit);
                        //requestQueue.Enqueue(request);
                        requestQueue.Push(request);
                        Monitor.Pulse(this);
                        return(true);
                    }
                    catch
                    {
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 10
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtajEmpName.TextLength != 0 && txtajEmpSurname.TextLength != 0)
            {
                WorkRequest submitRequest = new WorkRequest();

                submitRequest.Name            = txtajEmpName.Text;
                submitRequest.Surname         = txtajEmpSurname.Text;
                submitRequest.WorkDuration    = workDuration;
                submitRequest.WorkRequirement = workRequest;
                if (submitRequest.SubmitRequest() == true)
                {
                    Message += new Display.myDelegate(Display.Success);
                    Message.Invoke();
                }
                else
                {
                    Message += new Display.myDelegate(Display.Failure);
                    Message.Invoke();
                }
            }
            else
            {
                Message += new Display.myDelegate(Display.Error);
                Message.Invoke();
            }
        }
Ejemplo n.º 11
0
        public ResponseMessageGetWorkRequest GetWorkRequest(RequestMessageGetWorkRequest request)
        {
            List <WorkRequest> workRequestList = new List <WorkRequest>();

            IEnumerable <WOrequest> woRequestList = dbPrisma.WOrequest.Where(x => x.createdby.Equals(request.Username));

            //TODO: Entitytranslator
            foreach (var req in woRequestList)
            {
                WorkRequest workRequest = new WorkRequest();
                workRequest.BuildingCode      = req.blbuilding_code;
                workRequest.CreatedBy         = req.createdby;
                workRequest.CreatedDate       = req.createddate;
                workRequest.Description       = req.descr;
                workRequest.FloorCode         = req.blfloor_code;
                workRequest.RoomCode          = req.blroom_code;
                workRequest.WOActionCode      = req.woaction_code;
                workRequest.WORequestCode     = req.worequest_code;
                workRequest.WorkorderCode     = req.wo_code;
                workRequest.WorkorderPartCode = req.partwo_code;
                workRequestList.Add(workRequest);
            }

            ResponseMessageGetWorkRequest response = new ResponseMessageGetWorkRequest();

            response.WorkRequestList = workRequestList;

            return(response);
        }
Ejemplo n.º 12
0
        internal int AddWorkRequest(WorkRequest workRequest)
        {
            string        connString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
            SqlConnection conn       = null;
            int           requestId;

            try
            {
                conn = new SqlConnection(connString);
                conn.Open();

                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection   = conn;
                    cmd.CommandType  = CommandType.Text;
                    cmd.CommandText  = "INSERT INTO [data].[Requests] ";
                    cmd.CommandText += "(Requestor, Manager, Title, Goal, BusinessValueUnit, BusinessValueAmount, NonImplementImpact, RealizationOfImpact, RequestedCompletionDate, Status, StatusDate, LastModified, Created, ";
                    cmd.CommandText += " CorporateGoals, GoalSupport, SupportsDept, DeptGoalSupport, ConditionsOfSatisfaction)";
                    cmd.CommandText += "output INSERTED.RequestID ";
                    cmd.CommandText += "Values ('" + escape(workRequest.Requestor) + "', '" +
                                       escape(workRequest.Manager) + "', '" +
                                       escape(workRequest.Title) + "', '" +
                                       escape(workRequest.Goal) + "', '" +
                                       // Problem field deprecated, Iteration 9, January 2018
                                       // escape(workRequest.Problem) + "', '" +
                                       workRequest.BusinessValueUnit + "', '" +
                                       workRequest.BusinessValueAmount + "', '" +
                                       escape(workRequest.NonImplementImpact) + "', '" +
                                       escape(workRequest.RealizationOfImpact) + "', '" +
                                       workRequest.RequestedCompletionDate + "', '" +
                                       // Quantification field deprecated, Iteration 6, December 2017, replaced by BusinessValueUnit/BusinessValueAmount
                                       // escape(workRequest.Quantification) + "', '" +
                                       // Benefit field deprecated, Iteration 9, January 2018
                                       // escape(workRequest.Benefit) + "', '" +
                                       workRequest.Status + "', '" +
                                       DateTime.Now + "', '" +
                                       DateTime.Now + "', '" +
                                       DateTime.Now + "', '" +
                                       Utility.objectToSql(workRequest.CorporateGoals) + "', '" +
                                       escape(workRequest.GoalSupport) + "', '" +
                                       workRequest.SupportsDept + "', '" +
                                       escape(workRequest.DeptGoalSupport) + "', '" +
                                       escape(workRequest.ConditionsOfSatisfaction) + "')";
                    requestId = (int)cmd.ExecuteScalar();
                }
            }
            catch (Exception ex)
            {
                Error.Log(ex);
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(requestId);
        }
Ejemplo n.º 13
0
        /// <exclude />
        protected void btnReactivate_Click(object sender, EventArgs e)
        {
            WorkRequestService  workRequestService  = new WorkRequestService();
            NotificationService notificationService = new NotificationService();

            Status.Visible = true;
            int         id          = Int32.Parse(((Button)sender).CommandArgument);
            WorkRequest workRequest = workRequestService.GetWorkRequests(new Models.WorkRequest {
                RequestID = id
            }).First();

            if (workRequest.RequestID == id)
            {
                workRequest.Status = WorkRequestStatus.SubmittedToPortfolioManager.Description();
            }
            workRequestService.UpdateWorkRequest(workRequest, false);
            Notification notify = new Notification
            {
                WorkRequestId = id,
                Template      = Template.Restored
            };

            notify.NotifyUser = workRequest.Requestor; // email requestor
            notificationService.Send(notify);
            notify.NotifyUser = workRequest.Manager;   // email manager
            notificationService.Send(notify);

            // refresh the page to show the result
            Response.Redirect("/Admin");
        }
Ejemplo n.º 14
0
    public static string DeleteAttachment(int workRequestID, int id)
    {
        Dictionary <string, string> result = new Dictionary <string, string>()
        {
            { "deleted", "" }, { "id", "" }, { "error", "" }
        };

        bool   deleted = false;
        string errorMsg = string.Empty, ids = string.Empty;

        try
        {
            deleted = WorkRequest.Attachment_Delete(workRequestID: workRequestID, attachmentID: id, errorMsg: out errorMsg);
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);
            errorMsg += ": " + ex.Message;
            deleted   = false;
        }

        result["deleted"] = deleted.ToString();
        result["id"]      = id.ToString();
        result["error"]   = errorMsg;

        return(JsonConvert.SerializeObject(result, Formatting.None));
    }
Ejemplo n.º 15
0
 public ResponseBase StartMine([FromBody] WorkRequest request)
 {
     if (request == null)
     {
         return(ResponseBase.InvalidInput("参数错误"));
     }
     try {
         VirtualRoot.ThisLocalInfo(nameof(MinerClientController), $"通过群控开始挖矿", toConsole: true);
         WorkType workType = WorkType.None;
         if (request.WorkId != Guid.Empty)
         {
             workType = WorkType.MineWork;
             if (request.WorkId.IsSelfMineWorkId())
             {
                 workType = WorkType.SelfWork;
             }
         }
         NTMinerContext.Instance.RestartMine(workType, request.WorkerName);
         return(ResponseBase.Ok());
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(ResponseBase.ServerError(e.Message));
     }
 }
        public WorkRequestMetadataDTO SaveWorkRequest(WorkRequestMetadataDTO wr, string auth0Id)
        {
            WorkRequest newWorkRequest = null;

            wr.Person.EmployeeId = EmpRepository.GetEmployeeByAuthId(auth0Id).EmployeeId;

            if (wr.WorkRequestId != Guid.Empty)
            {
                newWorkRequest = DbContext.WorkRequests.Find(wr.WorkRequestId);
            }
            if (newWorkRequest != null) // Edit existing
            {
                newWorkRequest.ApproverId  = wr.Approver.EmployeeId;
                newWorkRequest.EndTime     = wr.EndTime != null ? wr.EndTime.Value : newWorkRequest.EndTime;
                newWorkRequest.OfficeId    = wr.Office.OfficeId;
                newWorkRequest.PersonId    = wr.Person.EmployeeId;
                newWorkRequest.RequestorId = wr.Requestor.EmployeeId;
                newWorkRequest.SectionId   = wr.Section.SectionId;
                newWorkRequest.StartTime   = wr.StartTime != null ? wr.StartTime.Value : newWorkRequest.StartTime;
            }
            else // Create new request
            {
                newWorkRequest = WorkRequestMetadataDTO.MapToBaseFunc(wr);
                newWorkRequest.WorkRequestId = Guid.NewGuid();
                DbContext.Add(newWorkRequest);
            }

            DbContext.SaveChanges();

            return(WorkRequestMetadataDTO.MapToDTOFunc(newWorkRequest));
        }
Ejemplo n.º 17
0
    private void loadWorkRequest()
    {
        DataTable dt = WorkRequest.WorkRequest_Get(workRequestID: this.WorkRequestID);

        if (dt != null && dt.Rows.Count > 0)
        {
            DataRow  row  = dt.Rows[0];
            ListItem item = null;

            this.spanWorkRequestNumber.InnerText = row["WORKREQUESTID"].ToString();
            this.txtTitle.Text = row["TITLE"].ToString();

            WTSUtility.SelectDdlItem(ddlContract, row["CONTRACTID"].ToString(), row["CONTRACT"].ToString());
            WTSUtility.SelectDdlItem(ddlOrganization, row["ORGANIZATIONID"].ToString(), row["ORGANIZATION"].ToString());

            textAreaDescription.InnerHtml = row["DESCRIPTION"].ToString();

            WTSUtility.SelectDdlItem(ddlRequestType, row["REQUESTTYPEID"].ToString(), row["REQUESTTYPE"].ToString());
            WTSUtility.SelectDdlItem(ddlRequestGroup, row["RequestGroupID"].ToString(), row["RequestGroup"].ToString());
            WTSUtility.SelectDdlItem(ddlScope, row["WTS_SCOPEID"].ToString(), row["SCOPE"].ToString());
            WTSUtility.SelectDdlItem(ddlEffort, row["EFFORTID"].ToString(), row["EFFORT"].ToString());
            WTSUtility.SelectDdlItem(ddlSubmittedBy, row["SUBMITTEDBY"].ToString(), row["Submitted_Name"].ToString());
            WTSUtility.SelectDdlItem(ddlSME, row["SMEID"].ToString(), row["SME"].ToString());
            WTSUtility.SelectDdlItem(ddlLead_IA_TW, row["LEAD_IA_TWID"].ToString(), row["Lead_IA_TW"].ToString());
            WTSUtility.SelectDdlItem(ddlLeadResource, row["LEAD_RESOURCEID"].ToString(), row["Lead_Resource"].ToString());
            WTSUtility.SelectDdlItem(ddlPriority, row["OP_PRIORITYID"].ToString(), row["PRIORITY"].ToString());

            textAreaJustification.InnerHtml = row["JUSTIFICATION"].ToString();

            this.labelCreated.Text = row["CREATEDBY"].ToString() + " - " + row["CREATEDDATE"].ToString();
            this.labelUpdated.Text = row["UPDATEDBY"].ToString() + " - " + row["UPDATEDDATE"].ToString();
        }
    }
Ejemplo n.º 18
0
        // The actual implementation of PostRequest.
        //
        bool PostRequest(WorkRequest request)
        {
            lock (this)
            {
                // A requestQueueLimit of -1 means the queue is "unbounded"
                // (subject to available resources).  IOW, no artificial limit
                // has been placed on the maximum # of requests that can be
                // placed into the queue.
                //
                if ((requestQueueLimit == -1) || (requestQueue.Count < requestQueueLimit))
                {
                    try
                    {
                        requestQueue.Enqueue(request);
                        Monitor.Pulse(this);
                        return(true);
                    }
                    catch
                    {
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 19
0
 public ResponseBase RestartNTMiner([FromBody] WorkRequest request)
 {
     if (request == null)
     {
         return(ResponseBase.InvalidInput("参数错误"));
     }
     if (request.WorkId != Guid.Empty)
     {
         File.WriteAllText(SpecialPath.NTMinerLocalJsonFileFullName, request.LocalJson);
         File.WriteAllText(SpecialPath.NTMinerServerJsonFileFullName, request.ServerJson);
     }
     Task.Factory.StartNew(() => {
         try {
             if (IsNTMinerOpened())
             {
                 CloseNTMiner();
                 System.Threading.Thread.Sleep(1000);
             }
             string arguments = string.Empty;
             if (request.WorkId != Guid.Empty)
             {
                 arguments = "--work";
             }
             string location = NTMinerRegistry.GetLocation();
             if (!string.IsNullOrEmpty(location) && File.Exists(location))
             {
                 Windows.Cmd.RunClose(location, arguments);
             }
         }
         catch (Exception e) {
             Logger.ErrorDebugLine(e);
         }
     });
     return(ResponseBase.Ok());
 }
Ejemplo n.º 20
0
        public bool SaveSelfWorkLocalJson(WorkRequest request)
        {
            bool   isSuccess   = false;
            string description = "保存单机作业";

            if (request == null)
            {
                isSuccess   = false;
                description = "参数错误";
            }
            else
            {
                try {
                    SpecialPath.WriteSelfWorkLocalJsonFile(request.LocalJson);
                    SpecialPath.WriteSelfWorkServerJsonFile(request.ServerJson);
                    isSuccess = true;
                }
                catch (Exception e) {
                    Logger.ErrorDebugLine(e);
                }
            }
            VirtualRoot.OperationResultSet.Add(new OperationResultData {
                Timestamp    = Timestamp.GetTimestamp(),
                StateCode    = isSuccess ? 200 : 500,
                ReasonPhrase = isSuccess ? "Ok" : "Fail",
                Description  = description
            });
            return(isSuccess);
        }
Ejemplo n.º 21
0
        public void SaveSelfWorkLocalJsonAsync(IMinerData client, string localJson, string serverJson)
        {
            if (!MinerStudioRoot.WsClient.IsOpen)
            {
                ShowWarn();
                return;
            }
            if (string.IsNullOrEmpty(localJson) || string.IsNullOrEmpty(serverJson))
            {
                return;
            }
            WorkRequest request = new WorkRequest {
                WorkId     = MineWorkData.SelfMineWorkId,
                WorkerName = client.WorkerName,
                LocalJson  = localJson.Replace(NTKeyword.MinerNameParameterName, client.WorkerName),
                ServerJson = serverJson
            };

            MinerStudioRoot.WsClient.SendAsync(new WsMessage(Guid.NewGuid(), WsMessage.SaveSelfWorkLocalJson)
            {
                Data = new WrapperClientIdData {
                    ClientId = client.ClientId,
                    Data     = request
                }
            });
        }
Ejemplo n.º 22
0
    private void loadRequests()
    {
        DataTable dt = null;

        if (_refreshData || Session["dtWorkItemRequest"] == null)
        {
            dt = WorkRequest.WorkRequestList_Get(typeID: 0, showArchived: _showArchived, requestGroupID: 0, myData: _myData);
            HttpContext.Current.Session["dtWorkItemRequest"] = dt;
        }
        else
        {
            dt = (DataTable)HttpContext.Current.Session["dtWorkItemRequest"];
        }

        if (dt != null)
        {
            this.DCC = dt.Columns;
            spanRowCount.InnerText = dt.Rows.Count.ToString();

            InitializeColumnData(ref dt);
            dt.AcceptChanges();
        }

        if (_export)
        {
            ExportExcel(dt);
        }
        else
        {
            grdRequest.DataSource = dt;
            grdRequest.DataBind();
        }
    }
Ejemplo n.º 23
0
        public bool PutWorkRequest(WorkRequest workRequest)
        {
            var maxWOCode = dbPrisma.WOrequest.Max(x => x.worequest_code);

            //TODO: Entitytranslator
            var woRequest = new WOrequest
            {
                worequest_code  = maxWOCode + 1,
                blbuilding_code = workRequest.BuildingCode,
                blfloor_code    = workRequest.FloorCode,
                blroom_code     = workRequest.RoomCode,
                createdby       = workRequest.CreatedBy,
                createddate     = DateTime.Now,
                descr           = workRequest.Description,
                partwo_code     = 1,
                status          = "1",
                woaction_code   = workRequest.WOActionCode,
                reqphone        = workRequest.Telephone
            };

            dbPrisma.WOrequest.Add(woRequest);
            dbPrisma.SaveChanges();

            return(true);
        }
Ejemplo n.º 24
0
        public bool PostRequest(Delegate cb, object[] args, out IWorkRequest reqStatus)
        {
            WorkRequest request = new WorkRequest(cb, args, _propogateThreadPrincipal, _propogateCallContext);

            reqStatus = request;
            return(PostRequest(request));
        }
Ejemplo n.º 25
0
    private IEnumerator SendRequestStopWork()
    {
        WorkRequest work = Requests.Instance.workRequest;

        if (!constructions.ContainsKey(dropdownConstructions.captionText.text))
        {
            ShowAttention("! объект не найден !");
            yield break;
        }
        int constructionId = constructions[dropdownConstructions.captionText.text];

        yield return(StartCoroutine(work.SendRequest(WorkRequest.StatusWork.STOP_WORK, constructionId)));

        switch (work.ResponseCode)
        {
        case Requests.RESPONSE_CODE_SUCCESS:
            StopWork(constructionId);
            ShowAttention("! смена закончилась !", true);
            break;

        case Requests.RESPONSE_CODE_BAD_REQUEST:
            StopWork(constructionId);
            ShowAttention("! вы уже закончили работать !");
            break;

        case Requests.RESPONSE_CODE_BAD_GATEAWAY:
            ShowAttention("! сервер неактивен !");
            break;
        }
    }
Ejemplo n.º 26
0
        public void IPxWorkRequest_Location_Updates_Valid()
        {
            DataTable table = base.PxApplication.ExecuteQuery("SELECT ID FROM " + base.PxApplication.GetQualifiedTableName(ArcFM.Process.WorkflowManager.Tables.WorkRequest));

            if (table.Rows.Count > 0)
            {
                int nodeID = table.Rows[0].Field <int>(0);
                using (WorkRequest request = new WorkRequest(base.PxApplication, nodeID))
                {
                    Assert.AreEqual(true, request.Valid);

                    if (request.Location != null && request.Location.Valid)
                    {
                        request.Location.FacilityDisplayField = "FacilityID";
                        Assert.AreEqual("FacilityID", request.Location.FacilityDisplayField);

                        if (request.Location.Address != null && request.Location.Address.Valid)
                        {
                            request.Location.Address.Address1 = " 380 New York Street, Redlands, CA 92373-8100";
                            Assert.AreEqual(" 380 New York Street, Redlands, CA 92373-8100", request.Location.Address.Address1);
                        }
                    }
                }
            }
        }
Ejemplo n.º 27
0
        public ResponseBase StartMine(WorkRequest request)
        {
            ResponseBase response;

            if (request == null)
            {
                response = ResponseBase.InvalidInput("参数错误");
            }
            else
            {
                try {
                    // 单机作业的localJson和serverJson是在编辑单机作业时提前传递到挖矿端的所以不需要在开始挖矿时再传递
                    if (request.WorkId != Guid.Empty && !request.WorkId.IsSelfMineWorkId())
                    {
                        SpecialPath.WriteMineWorkLocalJsonFile(request.LocalJson);
                        SpecialPath.WriteMineWorkServerJsonFile(request.ServerJson);
                    }
                    if (IsNTMinerOpened())
                    {
                        WorkRequest innerRequest = new WorkRequest {
                            WorkId     = request.WorkId,
                            WorkerName = request.WorkerName
                        };
                        JsonRpcRoot.PostAsync <ResponseBase>(NTKeyword.Localhost, NTKeyword.MinerClientPort, _minerClientControllerName, nameof(IMinerClientController.StartMine), innerRequest, callback: null, timeountMilliseconds: 3000);
                        response = ResponseBase.Ok("开始挖矿");
                    }
                    else
                    {
                        string location = NTMinerRegistry.GetLocation(NTMinerAppType.MinerClient);
                        if (!string.IsNullOrEmpty(location) && File.Exists(location))
                        {
                            string arguments = NTKeyword.AutoStartCmdParameterName;
                            if (request.WorkId != Guid.Empty)
                            {
                                if (request.WorkId.IsSelfMineWorkId())
                                {
                                    arguments = "--selfWork " + arguments;
                                }
                                else
                                {
                                    arguments = "--work " + arguments;
                                }
                            }
                            Windows.Cmd.RunClose(location, arguments);
                            response = ResponseBase.Ok("开始挖矿");
                        }
                        else
                        {
                            response = ResponseBase.ServerError("开始挖矿,未找到挖矿端程序");
                        }
                    }
                }
                catch (Exception e) {
                    Logger.ErrorDebugLine(e);
                    response = ResponseBase.ServerError(e.Message);
                }
            }
            VirtualRoot.OperationResultSet.Add(response.ToOperationResult());
            return(response);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// FOR VISUAL STUDIO USE ONLY, DO NOT USE!!!
 /// </summary>
 public RequestForm()
 {
     DB          = new Database();
     equipment   = new Equipment();
     part        = new Part();
     workRequest = new WorkRequest();
     Setup();
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Opens the window with intent of creating a new request
 /// </summary>
 /// <param name="DB">The Database containing the equipment and parts lists</param>
 public RequestForm(Database DB)
 {
     this.DB     = DB;
     workRequest = new WorkRequest();
     equipment   = new Equipment();
     launchType  = RequestFormLaunchType.New;
     Setup();
 }
 public ResponseBase StartMine(string clientIp, WorkRequest request)
 {
     using (HttpClient client = new HttpClient()) {
         Task <HttpResponseMessage> message = client.PostAsJsonAsync($"http://{clientIp}:{WebApiConst.MinerClientPort}/api/{s_controllerName}/{nameof(IMinerClientController.StartMine)}", request);
         ResponseBase response = message.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
Ejemplo n.º 31
0
        public JobSection(WorkRequest workRequest, WorkerCard workerCard)
        {
            WorkRequest = workRequest;
            WorkerCard = workerCard;

            WorkerIDs = new List<string>();

            HiringPipe = new Pipe(workRequest.HiringPipeName);
            HiringPipe.Open();
        }
Ejemplo n.º 32
0
        public WorkAssignment(WorkRequest workRequest, RoleSlotToken roleSlotToken, 
            int jobId, int scheduleRunDuration, string scheduleCreatedBy, long notificationId, string frequency)
        {
            WorkRequest = workRequest;
            RoleSlotToken = roleSlotToken;

            WorkerBadge = new WorkerBadge(this);

            // Information required to start classic jobs
            JobId = jobId;
            ScheduleRunDuration = scheduleRunDuration;
            ScheduleCreatedBy = scheduleCreatedBy;
            NotificationId = notificationId;
            Frequency = frequency;
        }
Ejemplo n.º 33
0
        public ActionResult IndexSave(AnmalanModel incomingAnmalan)
        {
            AnmalanModel anmalan = TempData["anmalan"] as AnmalanModel;

            PrismaServiceClient client = new PrismaServiceClient();
            WorkRequest workRequest = new WorkRequest
            {
                BuildingCode = anmalan.SelectedBuildingCode,
                CreatedBy = Environment.UserName,
                Description = anmalan.WRDescription,
                FloorCode = anmalan.SelectedFloorCode,
                RoomCode = anmalan.SelectedRoomCode,
                WOActionCode = anmalan.SelectedActionCode,
                Telephone = anmalan.TelephoneNumber
            };

            client.PutWorkRequest(workRequest);
            client.Close();

            return RedirectToAction("WorkRequestView");
        }
		// The actual implementation of PostRequest.
		//
		bool PostRequest(WorkRequest request)
		{
			lock (this)
			{
				// A requestQueueLimit of -1 means the queue is "unbounded"
				// (subject to available resources).  IOW, no artificial limit
				// has been placed on the maximum # of requests that can be
				// placed into the queue.
				//
				if ((requestQueueLimit == -1) || (requestQueue.Count < requestQueueLimit))
				{
					try
					{
						requestQueue.Enqueue(request);
						Monitor.Pulse(this);
						return (true);
					}
					catch
					{
					}

				}
			}

			return (false);
		}
		public bool PostRequest(Delegate cb, object[] args, out ISharedCacheWorkRequest reqStatus)
		{
			WorkRequest request =
					new WorkRequest(cb, args,
													 propogateThreadPrincipal, propogateCallContext,
													 propogateHttpContext, propogateCASMarkers);
			reqStatus = request;
			return PostRequest(request);
		}
Ejemplo n.º 36
0
 public bool PostRequest(Delegate cb, object[] args, out IWorkRequest reqStatus)
 {
     WorkRequest request = new WorkRequest(cb, args, _propogateThreadPrincipal, _propogateCallContext);
     reqStatus = request;
     return PostRequest(request);
 }
Ejemplo n.º 37
0
        /*
         * The actual implementation of PostRequest.
         */
        private bool PostRequest(WorkRequest request)
        {
            Monitor.Enter(_syncLock);
            try
            {
                /*
                 * A requestQueueLimit of -1 means the queue is "unbounded"
                 * (subject to available resources).  IOW, no artificial limit
                 * has been placed on the maximum # of requests that can be
                 * placed into the queue.
                 */
                if (_requestQueueLimit == -1 || _requestQueue.Count < _requestQueueLimit)
                {
                    try
                    {
                        _requestQueue.Enqueue(request);
                        Monitor.Pulse(_syncLock);
                        return (true);
                    }
                    catch
                    {
                    }

                }
            }
            finally
            {
                Monitor.Exit(_syncLock);
            }

            return (false);
        }
Ejemplo n.º 38
0
 public bool PostRequest( WorkRequestDelegate cb, object state, out IWorkRequest reqStatus )
 {
     WorkRequest request =
         new WorkRequest( cb, state,
                          propogateThreadPrincipal, propogateCallContext,
                          propogateHttpContext, propogateCASMarkers );
     reqStatus = request;
     return PostRequest(request);
 }