Ejemplo n.º 1
0
        //protected override string GetDefaultEmailSubject()
        //{
        //    return "EPL Proposal";
        //}

        protected override string GetEmailSubject(View view, DataRow row)
        {
            ColumnField subjectField = (ColumnField)view.Fields[Proposal.Subject.ToString()];
            string      subject      = subjectField.GetValue(row);

            return(subject);
        }
Ejemplo n.º 2
0
        public Json.ProductInfo GetProductInfo(string pk)
        {
            View productView = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.Product.ToString()];

            Json.ProductInfo productInfo = new Durados.Web.Mvc.Specifics.Shade.CRM.BusinessLogic.Json.ProductInfo();

            DataRow productRow = productView.GetDataRow(pk);

            ColumnField descriptionField = (ColumnField)productView.Fields[Durados.Web.Mvc.Specifics.Shade.CRM.Product.Description.ToString()];
            string      description      = descriptionField.GetValue(productRow);

            productInfo.Description = description;

            ParentField productPriceCategoryField = (ParentField)productView.Fields[Durados.Web.Mvc.Specifics.Shade.CRM.Product.FK_Product_ProductPriceCategory_Parent.ToString()];

            string productPriceCategoryId = productPriceCategoryField.GetValue(productRow);

            View productPriceView = (Durados.Web.Mvc.View)Map.Database.Views[ShadeViews.ProductPrice.ToString()];

            Dictionary <string, object> values = new Dictionary <string, object>();

            values.Add(ProductPrice.FK_ProductPrice_ProductCategory_Parent.ToString(), productPriceCategoryId);

            Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>();
            string sortColumn = ProductPrice.Width.ToString();

            if (!string.IsNullOrEmpty(sortColumn))
            {
                sortColumns.Add(sortColumn, SortDirection.Asc);
            }

            int      rowCount = 0;
            DataView dataView = productPriceView.FillPage(1, 10000, values, false, sortColumns, out rowCount, null, null);

            List <Json.Price> prices = new List <Durados.Web.Mvc.Specifics.Shade.CRM.BusinessLogic.Json.Price>();

            foreach (DataRow productPriceRow in dataView.Table.Rows)
            {
                double cost   = Convert.ToDouble(productPriceRow[ProductPrice.Cost.ToString()]);
                double pprice = (productPriceRow[ProductPrice.Price.ToString()] == DBNull.Value) ? 0 : Convert.ToDouble(productPriceRow[ProductPrice.Price.ToString()]);
                double width  = Convert.ToDouble(productPriceRow[ProductPrice.Width.ToString()]);
                double height = Convert.ToDouble(productPriceRow[ProductPrice.Height.ToString()]);
                bool   seamed = Convert.ToBoolean(productPriceRow[ProductPrice.Seamed.ToString()]);
                prices.Add(new Json.Price()
                {
                    Cost = cost, PPrice = pprice, Height = height, Width = width, Seamed = seamed
                });
            }

            productInfo.Prices = prices.OrderBy(p => p.Width).OrderBy(p => p.Height).ToArray();

            return(productInfo);
        }
Ejemplo n.º 3
0
        public virtual ActionResult Send(string viewName, string pk, string body, string subject, string to, string cc, string bcc)
        {
            try
            {
                if (IsMultiRows(viewName, pk))
                {
                    return(RedirectToAction("SendMultiRows", new { viewName = viewName, pks = pk, body = body, subject = subject, to = to, cc = cc, bcc = bcc }));
                }
                //DataRow proposalRow = ProposalView.GetDataRow(pk);
                //Durados.Web.Mvc.ColumnField wordDocumentField = (Durados.Web.Mvc.ColumnField)ProposalView.Fields[Proposal.WordDocument.ToString()];

                View        view            = GetView(viewName);
                DataRow     dataRow         = view.GetDataRow(pk);
                ColumnField attachmentField = GetAttachmentField(view, pk);
                string      file            = "";
                if (attachmentField != null)
                {
                    string fileVirtualPath = attachmentField.Upload.UploadVirtualPath;
                    string path            = HttpContext.Server.MapPath(fileVirtualPath);
                    string fileName        = attachmentField.GetValue(dataRow);
                    file = path + fileName;
                    PrepareAttachedFile(file, viewName, pk);
                }
                string userPk = GetUserPK(view, pk, dataRow);

                PrepareAttachedFile(file, viewName, pk);

                string from;
                string fromNick;
                GetEmailInfo(userPk, out from, out fromNick);
                if (bcc == null)
                {
                    bcc = string.Empty;
                }

                SendProposalEmail(from, fromNick, to, cc, bcc, body, subject, file);
                //run after email send command to log messages if needed
                AfterEmailSent(subject, to, body, file, viewName, pk);

                return(PartialView("~/Views/Shared/Controls/TextArea.ascx", string.Empty));
            }
            catch (Exception exception)
            {
                HandleSendException(viewName, pk, exception);
                return(PartialView("~/Views/Shared/Controls/ErrorMessage.ascx", FormatExceptionMessage(viewName, "Send", exception)));
            }
        }
Ejemplo n.º 4
0
        public Json.VendorInfo GetVendorInfo(string pk)
        {
            View vendorView = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.V_Vendor.ToString()];

            Json.VendorInfo vendorInfo = new Durados.Web.Mvc.Specifics.Projects.CRMShade.BusinessLogic.Json.VendorInfo();

            DataRow vendorRow = vendorView.GetDataRow(pk);

            //ColumnField multiplyField = (ColumnField)vendorView.Fields[Durados.Web.Mvc.Specifics.Projects.CRMShade.Organization.Multiply.ToString()];
            ColumnField multiplyField = (ColumnField)vendorView.Fields[V_Vendor.Multiply.ToString()];
            string      s             = multiplyField.GetValue(vendorRow);
            double      multiply      = 1;

            if (!string.IsNullOrEmpty(s))
            {
                multiply = Convert.ToDouble(s);
            }

            vendorInfo.Multiply = multiply;


            return(vendorInfo);
        }
Ejemplo n.º 5
0
        public Json.ContactInfo GetContactInfo(string pk)
        {
            View contactView = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.V_Contact.ToString()];

            Json.ContactInfo contactInfo = new Durados.Web.Mvc.Specifics.Projects.CRMShade.BusinessLogic.Json.ContactInfo();

            DataRow contactRow = contactView.GetDataRow(pk);

            ColumnField field = (ColumnField)contactView.Fields[V_Contact.Cellular.ToString()];
            string      val   = field.GetValue(contactRow);

            contactInfo.ClientCellular = val ?? string.Empty;

            field = (ColumnField)contactView.Fields[V_Contact.Email.ToString()];
            val   = field.GetValue(contactRow);
            contactInfo.ClientEmail = val ?? string.Empty;

            field = (ColumnField)contactView.Fields[V_Contact.FullName.ToString()];
            val   = field.GetValue(contactRow);
            contactInfo.ClientName = val ?? string.Empty;

            field = (ColumnField)contactView.Fields[V_Contact.Phone.ToString()];
            val   = field.GetValue(contactRow);
            contactInfo.ClientPhone = val ?? string.Empty;

            View        addressView  = (View)Durados.Web.Mvc.Map.Database.Views[ShadeViews.Address.ToString()];
            ParentField addressField = (ParentField)contactView.Fields[V_Contact.FK_AddressOther_V_Contact_Parent.ToString()];

            val = addressField.GetValue(contactRow);
            if (string.IsNullOrEmpty(val))
            {
                addressField          = (ParentField)contactView.Fields[V_Contact.FK_Address_V_Contact_Parent.ToString()];
                val                   = addressField.GetValue(contactRow);
                contactInfo.AddressID = val ?? string.Empty;

                DataRow addressRow = contactRow.GetParentRow(addressField.DataRelation.RelationName);
                if (addressRow != null)
                {
                    field = (ColumnField)addressView.Fields[Address.FullAddress.ToString()];
                    val   = field.GetValue(addressRow);
                    contactInfo.AddressText = val ?? string.Empty;
                }
                else
                {
                    contactInfo.AddressText = string.Empty;
                }
            }
            else
            {
                contactInfo.AddressID = val ?? string.Empty;

                DataRow addressRow = contactRow.GetParentRow(addressField.DataRelation.RelationName);
                if (addressRow != null)
                {
                    field = (ColumnField)addressView.Fields[Address.FullAddress.ToString()];
                    val   = field.GetValue(addressRow);
                    contactInfo.AddressText = val ?? string.Empty;
                }
                else
                {
                    contactInfo.AddressText = string.Empty;
                }
            }

            //field = (ColumnField)contactView.Fields[V_Contact.MailingCountry.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobCountry = val ?? string.Empty;

            //field = (ColumnField)contactView.Fields[V_Contact.MailingState.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobState = val ?? string.Empty;


            //field = (ColumnField)contactView.Fields[V_Contact.MailingStreet.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobStreet = val ?? string.Empty;

            //field = (ColumnField)contactView.Fields[V_Contact.MailingZip.ToString()];
            //val = field.GetValue(contactRow);
            //contactInfo.JobZip = val ?? string.Empty;

            return(contactInfo);
        }
Ejemplo n.º 6
0
        public virtual string GetMilestones(DataRow row)
        {
            //GetMilestoneWidth
            string msRow = string.Empty;

            string commDelem = field.GetValue(row);

            if (commDelem == null)
            {
                throw new DuradosException("Gantt is undefined");
            }

            string[] s = commDelem.Split(',');

            int count = (s.Length / 2);

            string ganttTpl = "<div class='{2}' style='width:{0}px;{1}' title='{3}'></div>";

            try
            {
                //List<DateTime?> dates = GetDates(field, fields, dataRow); //Get From Row

                List <string> fields = GetFields(field, s);

                List <DateTime?> allDates = GetDates(s);// Get From Cell Data

                List <DateTime> dates = GetValidDates(s);

                List <Color> colors = GetColors(field, s.Length / 2);

                msRow = "<div class='milestoneContainer'>";

                int position = -11;

                int width = 0;

                //bool hasPad = false;

                if (dates.Count > 0)
                {
                    width = GetMilestoneWidth(LowerBoundDate, dates[0]);
                    if (width > 0)
                    {
                        //width -= 2; // for begining of the day!
                        msRow    += string.Format(ganttTpl, width, "", "milestonePad", "");
                        position += width;
                        //hasPad = true;
                    }
                }


                int allIndex = -1;

                string msImages = string.Empty;

                for (int i = 0; i < dates.Count; i++)
                {
                    allIndex++;

                    string bg = string.Empty;
                    if (!field.Milestone.Custom)
                    {
                        bg = GetMilestoneBgColor(GetMilestoneColor(colors, i));
                    }

                    if (i + 1 < dates.Count)
                    {
                        string title = string.Empty;

                        if (allDates[allIndex] == null)
                        {
                            title += " - First milestone is missing ";
                            bg     = "background: rgb(0,0,0)";
                        }

                        if (allDates[allIndex + 1] == null)
                        {
                            bg = "background: rgb(0,0,0)";
                            while (allIndex + 1 < allDates.Count && allDates[allIndex + 1] == null)
                            {
                                title += " - Missing milestone";
                                allIndex++;
                            }
                        }

                        width = GetMilestoneWidth(dates[i], dates[i + 1]);

                        if (width <= 0)
                        {
                            continue;
                        }

                        if (i == 0)
                        {
                            //if (!hasPad) width -= 2; // for begining of the day!

                            if (dates[i] >= LowerBoundDate)
                            {
                                msImages += string.Format("<img src='/Content/Images/milestone.png' alt='' title='{0}' class='milestoneImg' style='left: " + position.ToString() + "px' />", field.View.Fields[fields[allIndex]].DisplayName + " - " + dates[i].ToString(field.Format));
                            }
                        }

                        position += width;

                        if (dates[i + 1] <= UpperBoundDate)
                        {
                            msImages += string.Format("<img src='/Content/Images/milestone.png' alt='' title='{0}' class='milestoneImg' style='left: " + position.ToString() + "px' />", field.View.Fields[fields[allIndex + 1]].DisplayName + " - " + dates[i + 1].ToString(field.Format));
                        }

                        title = "From " + dates[i].ToString(field.Format) + " To " + dates[i + 1].ToString(field.Format) + title;


                        msRow += string.Format(ganttTpl, width, bg, "milestone" + i.ToString(), title);
                    }
                }

                msRow += "</div>" + msImages;
            }
            catch (Exception ex)
            {
                throw new DuradosException("Gantt error: " + ex.Message);
            }
            return(msRow);
        }
Ejemplo n.º 7
0
        protected virtual string GetEmail(string parameter, Durados.View view, Dictionary <string, object> values, DataRow prevRow, string pk, string connectionString)
        {
            parameter = parameter.Trim();

            if (parameter.StartsWith(Database.DictionaryPrefix) && values.ContainsKey(parameter))
            {
                return(values[parameter].ToString());
            }

            if (parameter.StartsWith("$"))
            {
                string fieldName = parameter.TrimStart('$');
                if (view.Fields.ContainsKey(fieldName))
                {
                    Field field = view.Fields[fieldName];
                    if (field.FieldType == FieldType.Column)
                    {
                        ColumnField columnField = (ColumnField)field;
                        if (columnField.TextHtmlControlType == TextHtmlControlType.Autocomplete)
                        {
                            return(GetEmailFromAutocomplete(parameter, view, values, prevRow, pk, connectionString));
                        }
                        else
                        {
                            if (values.ContainsKey(fieldName))
                            {
                                return(values[fieldName].ToString());
                            }
                            else
                            {
                                return(columnField.GetValue(prevRow));
                            }
                        }
                    }
                    else if (field.FieldType == FieldType.Parent)
                    {
                        ParentField parentField = (ParentField)field;
                        if (parentField.ParentView.Base.Name.ToLower() == ((Database)view.Database).UserViewName.ToLower())
                        {
                            string key;
                            if (values.ContainsKey(fieldName))
                            {
                                key = values[fieldName].ToString();
                            }
                            else
                            {
                                key = parentField.GetValue(prevRow);
                            }
                            return(((Database)view.Database).Map.GetUserEmail(key));
                        }
                        else
                        {
                            return(GetEmailFromParent(parameter, view, values, prevRow, pk, connectionString));
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(parameter);
            }
        }