Ejemplo n.º 1
0
        public long UpdateIssue(IssueObject issue)
        {
            try
            {
                if (issue == null)
                {
                    return(-2);
                }

                var issueEntity = ModelMapper.Map <IssueObject, Issue>(issue);
                if (issueEntity == null || issueEntity.Id < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    db.Issues.Attach(issueEntity);
                    db.Entry(issueEntity).State = EntityState.Modified;
                    db.SaveChanges();
                    return(issue.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Ejemplo n.º 2
0
        private GenericValidator ValidateIssue(IssueObject issue)
        {
            var gVal = new GenericValidator();

            try
            {
                if (issue.IssueLogObject.IssueCategoryId < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please select Issue Category.";
                    return(gVal);
                }

                if (string.IsNullOrEmpty(issue.IssueLogObject.Issue))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please provide you complaint.";
                    return(gVal);
                }

                gVal.Code = 5;
                return(gVal);
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Issue Validation failed. Please provide all required fields and try again.";
                return(gVal);
            }
        }
Ejemplo n.º 3
0
        private async Task LoadIssueDetails(IssueLoadScenario loadScenario)
        {
            // if we can't parse the number, don't show it.
            if (!txtIssueNumber.CausesValidation || !int.TryParse(txtIssueNumber.Text, out int issueNumber))
            {
                return;
            }

            // try to load the issue from the github and show the title.
            try
            {
                // get the repository
                (string owner, string repo) = UIHelpers.GetRepoOwner(cboAvailableRepos.SelectedItem);

                RepositoryInfo repoFromGH = await _issueManager.GetRepositoryAsync(owner, repo);

                IssueObject issue = loadScenario switch {
                    IssueLoadScenario.BrowseEpic => await _issueManager.GetBrowseableIssueAsync(repoFromGH.Id, issueNumber),
                    IssueLoadScenario.LoadAllIssues => await _issueManager.GetAllIssueAsync(repoFromGH.Id, issueNumber),
                    IssueLoadScenario.LoadIssueAsTemplate => await _issueManager.GetTemplateIssueAsync(repoFromGH.Id, issueNumber),
                    _ => throw new InvalidOperationException("Invalid IssueLoadScenario")
                };

                lblIssueTitle.Text = issue.Title;
            }
            catch
            {
                lblIssueTitle.Text = "!!! Could not find issue !!!";
            }
        }
Ejemplo n.º 4
0
        public ActionResult ResolveIssue(IssueObject issue)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var validationResult = ValidateIssue(issue);

                if (validationResult.Code == 1)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                if (Session["_issue"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldissue = Session["_issue"] as IssueObject;

                if (oldissue == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                oldissue.ResolvedById = importerInfo.UserProfileObject.Id;
                oldissue.Status       = issue.Status;

                var docStatus = new IssueServices().UpdateIssue(oldissue);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Issue could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = docStatus;
                gVal.Error = "You have successsfully marked this Issue as resolved.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }

            catch (Exception)
            {
                gVal.Error = "Issue processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 5
0
    public GameObject Get_Object()
    {
        GameObject spawned_object;

        //check if an inactive object exists
        if (inactive_objects.Count > 0)
        {
            spawned_object = inactive_objects.Pop();
        }
        // otherwise create a new object
        else
        {
            spawned_object = (GameObject)GameObject.Instantiate(prefab);

            // add to the prefab
            IssueObject directory_object = spawned_object.AddComponent <IssueObject>();
            directory_object.files = this;
        }

        spawned_object.transform.SetParent(null);
        spawned_object.SetActive(true);

        // return the object
        return(spawned_object);
    }
Ejemplo n.º 6
0
        private async void txtIssueNumber_Leave(object sender, EventArgs e)
        {
            using IDisposable scope = _logger.CreateScope("Focus lost on issue number box. Attempting to retrieve the issue title.");

            // if we can't parse the number, don't show it.
            if (!int.TryParse(txtIssueNumber.Text, out int issueNumber))
            {
                return;
            }

            // try to load the issue from the github and show the title.
            try
            {
                // get the repository
                (string owner, string repo) = UIHelpers.GetRepoOwner(cboAvailableRepos.SelectedItem);

                RepositoryInfo repoFromGH = await _issueManager.GetRepositoryAsync(owner, repo);

                IssueObject issue = await _issueManager.GetIssueAsync(repoFromGH.Id, issueNumber);

                lblIssueTitle.Text = issue.Title;
            }
            catch {
                lblIssueTitle.Text = "!!! Could not find issue !!!";
            }
        }
Ejemplo n.º 7
0
 public long UpdateIssue(IssueObject issue)
 {
     try
     {
         return(_issueManager.UpdateIssue(issue));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Ejemplo n.º 8
0
        public ActionResult EditIssue(IssueObject issue)
        {
            var gVal = new GenericValidator();

            try
            {
                var stat = ValidateIssue(issue);

                if (stat.Code < 1)
                {
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_issue"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldissue = Session["_issue"] as IssueObject;

                if (oldissue == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                oldissue.AffectedUserId = issue.AffectedUserId;
                oldissue.IssueLogId     = issue.IssueLogId;
                oldissue.ResolvedById   = issue.ResolvedById;
                oldissue.Status         = issue.Status;

                var docStatus = new IssueServices().UpdateIssue(oldissue);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = docStatus == -3 ? "Issue already exists." : "Issue could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldissue.Id;
                gVal.Error = "Issue was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Issue could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <ActionResult> IssueShares([FromRoute] long id, [FromBody] IssueObject issueObject)
        {
            var stock = await _context.Stocks.Where(x => x.Id == id)
                        .Include(s => s.ShareHolders)
                        .Where(s => s.ShareHolders.Any(q => q.ShareholderId == issueObject.Owner)).FirstOrDefaultAsync();

            stock = await AddShareholder(id, issueObject, stock);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Ejemplo n.º 10
0
        protected virtual void OnIssueLoaded(IssueObject issue, IssueLoadScenario loadScenario)
        {
            switch (loadScenario)
            {
            case IssueLoadScenario.BrowseEpic:
                BrowseableIssueLoaded?.Invoke(this, issue);
                break;

            case IssueLoadScenario.LoadAllIssues:
                IssueLoaded?.Invoke(this, issue);
                break;

            case IssueLoadScenario.LoadIssueAsTemplate:
                TemplateIssueLoaded?.Invoke(this, issue);
                break;

            default:
                break;
            }
        }
        private async Task <Stock> AddShareholder(long id, IssueObject issueObject, Stock stock)
        {
            if (stock == null)
            {
                stock = await _context.Stocks.Include(x => x.ShareHolders).Where(x => x.Id == id).FirstOrDefaultAsync();

                stock.ShareHolders.Add(new Shareholder {
                    ShareholderId = issueObject.Owner, Amount = issueObject.Amount
                });
            }
            else
            {
                var shareHolder = stock.ShareHolders.FirstOrDefault(sh => sh.ShareholderId == issueObject.Owner);
                if (shareHolder != null)
                {
                    shareHolder.Amount += issueObject.Amount;
                }
            }

            return(stock);
        }
Ejemplo n.º 12
0
        public ActionResult AddIssue(IssueObject issue)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var validationResult = ValidateIssue(issue);

                if (validationResult.Code == 1)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                var appStatus = new IssueServices().AddIssue(issue);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = appStatus == -2 ? "Issue could not be added. Please try again." : "The Issue Information already exists";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = appStatus;
                gVal.Error = "Issue was successfully added.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Error = "Issue processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 13
0
        public long AddIssue(IssueObject issue)
        {
            try
            {
                if (issue == null || issue.IssueLogObject.IssueCategoryId < 1)
                {
                    return(-2);
                }

                var issueEntity = ModelMapper.Map <IssueObject, Issue>(issue);
                if (issueEntity == null || issueEntity.AffectedUserId < 1)
                {
                    return(-2);
                }

                var issueLog       = issue.IssueLogObject;
                var issueLogEntity = ModelMapper.Map <IssueLogObject, IssueLog>(issueLog);
                if (issueLogEntity == null || issueLogEntity.IssueCategoryId < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    var processedLog = db.IssueLogs.Add(issueLogEntity);
                    db.SaveChanges();

                    issueEntity.IssueLogId = processedLog.Id;
                    var processedIssue = db.Issues.Add(issueEntity);
                    db.SaveChanges();
                    return(processedIssue.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Ejemplo n.º 14
0
    public void ReturnObject(GameObject return_object)
    {
        IssueObject directory_object = return_object.GetComponent <IssueObject>();

        // check if the instance is from this directory
        if (directory_object != null && directory_object.files == this)
        {
            // disable this instance
            return_object.transform.SetParent(transform);
            return_object.SetActive(false);

            // add as an inactive instance
            inactive_objects.Push(return_object);
        }

        // otherwise delete the object
        else
        {
            Debug.LogWarning(return_object.name + " was returned to the directory it isn't from.");
            Destroy(return_object);
        }
    }
Ejemplo n.º 15
0
        public ActionResult SendSupportRequest(IssueObject issue)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Your session has timed out. Please refresh the page.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var validationResult = ValidateIssue(issue);

                if (validationResult.Code == 1)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }
                issue.IssueLogObject.DateCreated = DateTime.Now;
                issue.AffectedUserId             = importerInfo.UserProfileObject.Id;
                issue.Status = IssueStatusEnum.Pending.ToString();

                var appStatus = new IssueServices().AddIssue(issue);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = "Your request/complaint could not be processed. Please try again.";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                if (Request.Url != null)
                {
                    #region Using SendGrid

                    var config   = WebConfigurationManager.OpenWebConfiguration(HttpContext.Request.ApplicationPath);
                    var settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");

                    if (settings == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = "Internal server error. Your request could not be processed. Please try again.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var str = "<b>Issue Category : </b> " + "<b>" + issue.IssueCategoryName + "</b>";
                    str += "<b>Affected Company : </b> " + "<b>" + importerInfo.Name + "</b>";
                    str += "<b>Request/Issue : </b> " + "<b>" + issue.IssueLogObject.Issue + "</b>";

                    var mail = new MailMessage(new MailAddress(settings.Smtp.From), new MailAddress("*****@*****.**"))
                    {
                        Subject    = issue.IssueCategoryName,
                        Body       = str,
                        IsBodyHtml = true
                    };

                    var smtp = new SmtpClient(settings.Smtp.Network.Host)
                    {
                        Credentials = new NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password),
                        EnableSsl   = true,
                        Port        = settings.Smtp.Network.Port
                    };

                    smtp.Send(mail);
                    gVal.Code  = 5;
                    gVal.Error = "Your message has been sent. Be rest assured it will be handled as soon as possible.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));

                    #endregion
                }

                gVal.Code  = -1;
                gVal.Error = "Internal server error. Your request could not be processed. Please try again.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                ErrorLogger.LoggError(e.StackTrace, e.Source, e.Message);
                gVal.Code  = -1;
                gVal.Error = "Internal server error. Your request could not be processed. Please try again.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }