Exemplo n.º 1
0
        public static ContentComment LeaveComment(string contentId, string commentText, string destinationUserId, string replyToCommentId, string fileName, string commentType)
        {
            try
            {
                var guidDestinationUserId = !string.IsNullOrEmpty(destinationUserId)
                                                ? (Guid?)Guid.Parse(destinationUserId)
                                                : null;

                var guidReplyToCommentId = !string.IsNullOrEmpty(replyToCommentId)
                                                ? (Guid?)Guid.Parse(replyToCommentId)
                                                : null;
                commentText = commentText.Replace("\n", "#@#");
                commentText = Sanitizer.GetSafeHtmlFragment(commentText);
                commentText = commentText.Replace("\r\n", "")
                              .Replace("<p><br></p>", "")
                              .Replace("#@#", "\n");

                var publicationCommentMap = ContentCommentRepository.Add(CurrentUser.Instance.SiteID, CurrentUser.Instance.ID, Guid.Parse(contentId),
                                                                         commentText, guidDestinationUserId, guidReplyToCommentId, fileName,
                                                                         commentType.ToEnum <CommentTables>());

                return(publicationCommentMap);
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("ContentComment LeaveComment({0}, {1})", contentId, commentText), ex);
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the OnClick event of the lbtnUpdateNotFulfilledLiabilities control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void lbtnUpdateNotFulfilledLiabilities_OnClick(object sender, EventArgs e)
        {
            var invoice = DataManager.Invoice.SelectById(CurrentUser.Instance.SiteID, ObjectId);

            if (invoice != null)
            {
                var commentText =
                    string.Format("Не выполнены обязательства Исполнителя для оплаты счета. Причины: {0}", txtNotFulfilledLiabilities.Text);

                ContentCommentRepository.Add(CurrentUser.Instance.SiteID, CurrentUser.Instance.ID, invoice.ID, commentText, null,
                                             null, string.Empty, CommentTables.tbl_InvoiceComment);

                invoice.IsExistBuyerComplaint = true;

                DataManager.Invoice.Update(invoice);
            }

            txtNotFulfilledLiabilities.Text = string.Empty;

            ucNotificationMessage.Text = "Комментарий успешно добавлен.";

            if (!Page.ClientScript.IsStartupScriptRegistered("CloseNotFulfilledLiabilitiesRadWindow"))
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "CloseNotFulfilledLiabilitiesRadWindow",
                                                    "CloseNotFulfilledLiabilitiesRadWindow();", true);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the OnClick event of the lbtnUpdatePostponePaymentDate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void lbtnUpdatePostponePaymentDate_OnClick(object sender, EventArgs e)
        {
            var invoice = DataManager.Invoice.SelectById(CurrentUser.Instance.SiteID, ObjectId);

            if (invoice != null)
            {
                var commentText =
                    string.Format("Перенесена дата оплаты с {0} на {1}. Причины: {2}", invoice.PaymentDatePlanned.HasValue ? invoice.PaymentDatePlanned.Value.ToString("dd.MM.yyyy") : "[Дата не установлена]",
                                  rdpInvoicePlannedPaymentDate.SelectedDate.Value.ToString("dd.MM.yyyy"),
                                  txtCommentForManager.Text);

                ContentCommentRepository.Add(CurrentUser.Instance.SiteID, CurrentUser.Instance.ID, invoice.ID, commentText, null,
                                             null, string.Empty, CommentTables.tbl_InvoiceComment);

                invoice.PaymentDatePlanned = rdpInvoicePlannedPaymentDate.SelectedDate;

                lrlPaymentDatePlanned.Text = rdpInvoicePlannedPaymentDate.SelectedDate.Value.ToString("dd.MM.yyyy");

                DataManager.Invoice.Update(invoice);
            }

            rdpInvoicePlannedPaymentDate.SelectedDate = null;
            txtCommentForManager.Text = string.Empty;

            ucNotificationMessage.Text = "Дата оплаты успешно перенесена.";

            if (!Page.ClientScript.IsStartupScriptRegistered("ClosePostponePaymentDateRadWindow"))
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "ClosePostponePaymentDateRadWindow",
                                                    "ClosePostponePaymentDateRadWindow();", true);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Saves the comment.
        /// </summary>
        /// <param name="request">The request.</param>
        public void SaveComment(tbl_Request request)
        {
            if (SelectedRequirementId.HasValue && !string.IsNullOrEmpty(Comment) && request.ContactID.HasValue)
            {
                var user = DataManager.User.SelectByContactIdExtended(CurrentUser.Instance.SiteID, (Guid)request.ContactID) ??
                           DataManager.User.AddPortalUser(CurrentUser.Instance.SiteID, (Guid)request.ContactID);
                if (user != null)
                {
                    var requirement = DataManager.Requirement.SelectById(CurrentUser.Instance.SiteID, (Guid)SelectedRequirementId);
                    if (!request.tbl_Requirement.Any(o => o.ID == requirement.ID))
                    {
                        request.tbl_Requirement.Add(requirement);
                        DataManager.Request.Update(request);
                    }

                    ContentCommentRepository.Add(CurrentUser.Instance.SiteID, user.ID, (Guid)SelectedRequirementId,
                                                 Comment, null, null, string.Empty,
                                                 CommentTables.tbl_RequirementComment);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the OnClick event of the lbtnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void lbtnSave_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            if (!access.Write)
            {
                return;
            }

            var requirement = DataManager.Requirement.SelectById(SiteId, _requirementId) ?? new tbl_Requirement();

            requirement.ShortDescription = (txtShortDescription.Text.Length > 2048
                                                ? txtShortDescription.Text.Substring(0, 2048)
                                                : txtShortDescription.Text);

            //requirement.LongDescription = ucLongDescription.Content;

            requirement.RequestSourceTypeID = dcbRequestSourceType.SelectedIdNullable;

            requirement.RequirementStatusID = ucRequirementStatus.RequirementStatusId;

            requirement.RequestID           = dcbRequests.SelectedIdNullable;
            requirement.ProductID           = dcbProducts.SelectedIdNullable;
            requirement.CompanyID           = dcbCompany.SelectedIdNullable;
            requirement.ContactID           = ucContact.SelectedValue;
            requirement.ProductSeriesNumber = txtProductSeriesNumber.Text;
            requirement.RequirementTypeID   = dcbRequirementType.SelectedId;

            requirement.RequirementSeverityOfExposureID = dcbRequirementSeverityOfExposure.SelectedIdNullable;

            requirement.ServiceLevelID = dcbServiceLevel.SelectedId;

            requirement.ParentID = ucParentRequirment.ParentRequirementId;

            requirement.RequirementPriorityID   = dcbRequirementPriority.SelectedIdNullable;
            requirement.RequirementComplexityID = dcbRequirementComplexity.SelectedIdNullable;

            if (ucPublicationCategory.SelectedCategoryId != Guid.Empty)
            {
                requirement.PublicationCategoryID = ucPublicationCategory.SelectedCategoryId;
            }
            else
            {
                requirement.PublicationCategoryID = null;
            }

            requirement.ResponsibleID          = ucResponsible.SelectedValue;
            requirement.RealizationDatePlanned = rdpRealizationDatePlanned.SelectedDate;
            requirement.RealizationDateActual  = rdpRealizationDateActual.SelectedDate;
            requirement.ContractID             = dcbContract.SelectedIdNullable;
            requirement.OrderID   = dcbOrder.SelectedIdNullable;
            requirement.InvoiceID = dcbInvoice.SelectedIdNullable;
            requirement.EvaluationRequirementsProductID = dcbEvaluationRequirementsProducts.SelectedIdNullable;
            requirement.AnyProductName = txtAnyProductName.Text;
            requirement.Quantity       = (decimal)rntxtQuantity.Value;
            requirement.CurrencyID     = dcbCurrency.SelectedIdNullable;
            requirement.CurrencyPrice  = (decimal)rntxtCurrencyPrice.Value;
            requirement.CurrencyAmount = (decimal)rntxtCurrencyAmount.Value;
            requirement.UnitID         = dcbUnit.SelectedIdNullable;
            requirement.Rate           = (decimal)rntxtRate.Value;
            requirement.Price          = (decimal)rntxtPrice.Value;
            requirement.Amount         = (decimal)rntxtAmount.Value;
            requirement.RequirementImplementationCompleteID = dcbRequirementImplementationComplete.SelectedIdNullable;
            requirement.RequirementSpeedTimeID    = dcbRequirementSpeedTime.SelectedIdNullable;
            requirement.RequirementSatisfactionID = dcbRequirementSatisfaction.SelectedIdNullable;
            requirement.EstimationComment         = txtEstimationComment.Text;

            requirement.InternalUnitID           = dcbInternalUnit.SelectedIdNullable;
            requirement.InternalQuantity         = (decimal)rntxtInternalQuantity.Value;
            requirement.EstimateCommentInternal  = txtEstimateCommentInternal.Text;
            requirement.EstimateCommentForClient = txtEstimateCommentForClient.Text;

            if (requirement.ID == Guid.Empty)
            {
                requirement.SiteID    = SiteId;
                requirement.OwnerID   = CurrentUser.Instance.ContactID;
                requirement.CreatedAt = DateTime.Now;

                var requestSourceType = DataManager.RequirementType.SelectById(SiteId, requirement.RequirementTypeID);
                if (requestSourceType != null)
                {
                    var documentNumerator = DocumentNumerator.GetNumber((Guid)requestSourceType.NumeratorID, requirement.CreatedAt, requestSourceType.tbl_Numerator.Mask, "tbl_Requirement");
                    requirement.Number       = documentNumerator.Number;
                    requirement.SerialNumber = documentNumerator.SerialNumber;
                }

                DataManager.Requirement.Add(requirement);

                if (!string.IsNullOrEmpty(ucComment.Content))
                {
                    var contactId = requirement.ContactID ?? CurrentUser.Instance.ContactID;

                    var user = DataManager.User.SelectByContactIdExtended(SiteId, (Guid)contactId) ??
                               DataManager.User.AddPortalUser(SiteId, (Guid)contactId);

                    if (user != null)
                    {
                        ContentCommentRepository.Add(CurrentUser.Instance.SiteID, user.ID, requirement.ID, ucComment.Content, null, null, string.Empty,
                                                     CommentTables.tbl_RequirementComment, false, false);
                    }
                }

                if (!string.IsNullOrEmpty(txtComment.Text))
                {
                    var fileName = string.Empty;
                    if (rauFileUpload.UploadedFiles.Count > 0)
                    {
                        var fsp = new FileSystemProvider();
                        fileName = fsp.Upload(CurrentUser.Instance.SiteID,
                                              EnumHelper.GetEnumDescription(CommentTables.tbl_RequirementComment),
                                              rauFileUpload.UploadedFiles[0].FileName, rauFileUpload.UploadedFiles[0].InputStream, FileType.Attachment);
                    }

                    ContentCommentRepository.Add(CurrentUser.Instance.SiteID, CurrentUser.Instance.ID, requirement.ID, txtComment.Text, null, null, fileName,
                                                 CommentTables.tbl_RequirementComment, chxIsOfficialAnswer.Checked, false);
                }
            }
            else
            {
                DataManager.Requirement.Update(requirement);
            }

            if (!CheckRequestsToClose(requirement))
            {
                Response.Redirect(UrlsData.AP_Requirements());
            }
        }