private string GetContactOrganizationKey(string contactKey)
        {
            Durados.Web.Mvc.View contactView = GetView(CRMViews.V_Contact.ToString());
            DataRow     dataRow           = contactView.GetDataRow(contactKey);
            ParentField organizationField = (Durados.Web.Mvc.ParentField)contactView.Fields[V_Contact.FK_Contact_Organization_Parent.ToString()];

            return(organizationField.GetValue(dataRow));
        }
Exemple #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);
        }
Exemple #3
0
        protected virtual string GetUserPK(View view, string pk, DataRow dataRow)
        {
            ParentField ownerField = GetOwnerField(view, pk);

            if (ownerField == null)
            {
                return(Map.Database.GetUserID());
            }
            string userPk = ownerField.GetValue(dataRow);

            return(userPk);
        }
Exemple #4
0
        protected override string GetUserPK(View view, string pk, DataRow dataRow)
        {
            ParentField ownerField = GetOwnerField(view, pk);

            ParentField jobField = (Durados.Web.Mvc.ParentField)view.Fields[v_JobVendor.FK_JobVendor_Job_Parent.ToString()];
            string      jobFk    = jobField.GetValue(dataRow);

            Durados.Web.Mvc.View jobView = GetView(ShadeViews.Job.ToString());

            DataRow jobRow = jobView.GetDataRow(jobFk);

            string userPk = ownerField.GetValue(jobRow);

            return(userPk);
        }
Exemple #5
0
        protected virtual string GetTemplateForNew(View view, string pk)
        {
            DataRow dataRow = view.GetDataRow(pk);

            string templateFieldName;

            //if (view.Name == CRMViews.Proposal.ToString())
            //    templateFieldName = Proposal.FK_Proposal_Template_Parent.ToString();
            //else
            //    templateFieldName = v_ProposalLast2Months.FK_Proposal_Template1_Parent.ToString();
            templateFieldName = v_Proposal.FK_Proposal_Template_Parent.ToString();

            ParentField templateField = (ParentField)view.Fields[templateFieldName];

            string templatePK = templateField.GetValue(dataRow);

            Durados.Web.Mvc.View templateView     = GetView(ShadeViews.Template.ToString());
            string      documentLocationFiledName = Template.DocumentLocation.ToString();
            ColumnField documentLocationField     = (ColumnField)templateView.Fields[documentLocationFiledName];
            string      virtualPath = documentLocationField.Upload.UploadVirtualPath;

            return(GetTemplate(templatePK, templateView, documentLocationFiledName, virtualPath));
        }
Exemple #6
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);
        }
Exemple #7
0
        public static IEnumerable <SelectListItem> GetSelectList(this ChildrenField childrenField, string fk, string pk)
        {
            List <SelectListItem> selectList = new List <SelectListItem>();


            View childrenView = (Durados.Web.Mvc.View)childrenField.ChildrenView;


            View view = (Durados.Web.Mvc.View)childrenField.View;

            ParentField fkField = null;

            ParentField parentField = null;

            View parentView = null;


            foreach (ParentField field in childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent))
            {
                if (!field.ParentView.Base.Equals(view.Base))
                {
                    parentField = field;
                    parentView  = (Durados.Web.Mvc.View)field.ParentView;
                }
                else
                {
                    fkField = field;
                }
            }

            if (parentField == null)
            {
                return(selectList);
            }

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

            if (!string.IsNullOrEmpty(fk) && !string.IsNullOrEmpty(childrenField.DependencyFieldName))
            {
                filterParent.Add(childrenField.DependencyFieldName, fk);
            }

            int      rowCount       = 0;
            DataView parentDataView = parentView.FillPage(1, 1000000, filterParent, false, null, out rowCount, null, null);

            if (childrenField.View.Database.DiagnosticsReportInProgress)
            {
                if (parentDataView.Count > childrenField.View.Database.DiagnosticsReport.OverLoadLimit)
                {
                    Map.Logger.Log(parentView.Name, childrenField.Name, childrenField.View.Database.DiagnosticsReport.Name, string.Empty, childrenField.View.Database.DiagnosticsReport.GetStackTrace(), -parentDataView.Count, string.Empty, childrenField.View.Database.DiagnosticsReport.DateTime);
                }
            }
            //Selected values = rows in many-to-many view
            Dictionary <object, object> keys = new Dictionary <object, object>();

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

            if (!string.IsNullOrEmpty(pk) && fkField != null)
            {
                filter.Add(fkField.Name, pk);

                DataView childrenDataView = childrenView.FillPage(1, 1000000, filter, false, null, out rowCount, null, null);

                if (childrenField.View.Database.DiagnosticsReportInProgress)
                {
                    if (parentDataView.Count > childrenField.View.Database.DiagnosticsReport.OverLoadLimit)
                    {
                        Map.Logger.Log(childrenView.Name, childrenField.Name, childrenField.View.Database.DiagnosticsReport.Name, string.Empty, childrenField.View.Database.DiagnosticsReport.GetStackTrace(), -parentDataView.Count, string.Empty, childrenField.View.Database.DiagnosticsReport.DateTime);
                    }
                }

                foreach (System.Data.DataRowView row in childrenDataView)
                {
                    string key = parentField.GetValue(row.Row);
                    if (!keys.ContainsKey(key))
                    {
                        keys.Add(key, key);
                    }
                }
            }

            //Create Options
            foreach (System.Data.DataRowView row in parentDataView)
            {
                string text     = parentView.GetDisplayValue(row.Row);
                string value    = parentView.GetPkValue(row.Row);
                bool   selected = keys.ContainsKey(value);

                SelectListItem item = new SelectListItem();
                item.Text     = text;
                item.Value    = value;
                item.Selected = selected;

                selectList.Add(item);
            }


            return(selectList);
        }
Exemple #8
0
        public virtual Result Complete(object controller, Dictionary <string, Parameter> parameters, View view, Dictionary <string, object> values, DataRow prevRow, string pk, string connectionString, int currentUsetId, string currentUserRole, IDbCommand command, Engine engine)
        {
            Result result = new Result();
            Dictionary <string, EnabledStep> enabledSteps = new Dictionary <string, EnabledStep>();

            ParentField parentField = (ParentField)view.WorkFlowStepsField;
            View        parentView  = parentField.ParentView;
            DataTable   dataTable   = ((ILoader)controller).GetDataTable(parentView);

            result.PK = pk;
            Field ordinalField = null;

            result.Description = ((ILoader)controller).GetTooltip(view.DisplayName + " Steps", parentField.Description);

            if (!string.IsNullOrEmpty(parentView.OrdinalColumnName))
            {
                if (parentView.Fields.ContainsKey(parentView.OrdinalColumnName))
                {
                    ordinalField = parentView.Fields[parentView.OrdinalColumnName];
                }
            }

            string workflowCompletedMessage = string.Empty;
            string workflowNoResultMessage  = string.Empty;

            bool messageOnly = false;

            result.Message = view.Database.DefaultStepMessage;
            result.WorkflowCompletedMessage = view.Database.DefaultWorkFlowCompletedMessage;
            if (values.ContainsKey(parentField.Name))
            {
                result.CurrentStepId = values[parentField.Name].ToString();
            }
            else
            {
                result.CurrentStepId = parentField.GetValue(prevRow);
            }

            foreach (string key in parameters.Keys)
            {
                if (key.ToLower() == "message")
                {
                    result.Message = parameters[key].Value;
                }
                else if (key.ToLower() == "workflowcompletedmessage")
                {
                    workflowCompletedMessage = parameters[key].Value;
                }
                else if (key.ToLower() == "workflownoresultmessage")
                {
                    workflowNoResultMessage = parameters[key].Value;
                }
                else if (key.ToLower() == "messageonly")
                {
                    messageOnly = parameters[key].Value.ToLower() != "false" && parameters[key].Value.ToLower() != "0";
                }
                else
                {
                    Rule stepRule = new Rule();
                    stepRule.WhereCondition = key;
                    string[] ids     = parameters[key].Value.Split('~');
                    bool     enabled = engine.Check(view, stepRule, TriggerDataAction.BeforeCompleteStep, values, pk, prevRow, parameters[key].UseSqlParser, connectionString, currentUsetId, currentUserRole);

                    if (enabled)
                    {
                        foreach (string id2 in ids)
                        {
                            string id = id2;
                            if (id.Equals(Step.PreviousStep))
                            {
                                id = GetPrevStep((ILoader)controller, view, pk, result.CurrentStepId);
                            }
                            if (id != null)
                            {
                                DataRow dataRow = dataTable.Rows.Find(parentView.GetPkValue(id));
                                if (dataRow != null)
                                {
                                    string name    = parentView.GetDisplayValue(dataRow);
                                    int    ordinal = 0;
                                    if (ordinalField != null)
                                    {
                                        string s = ordinalField.GetValue(dataRow);
                                        if (!string.IsNullOrEmpty(s))
                                        {
                                            ordinal = Convert.ToInt32(s);
                                        }
                                    }
                                    string description = string.Empty;
                                    if (dataTable.Columns.Contains("Description"))
                                    {
                                        description = ((ILoader)controller).GetTooltip(name, dataRow["Description"].ToString());
                                    }
                                    if (!enabledSteps.ContainsKey(id))
                                    {
                                        enabledSteps.Add(id, new EnabledStep()
                                        {
                                            Enable = enabled, Id = id, Name = name, Ordinal = ordinal, Description = description
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }

            foreach (DataRow row in dataTable.Rows)
            {
                string id = parentView.GetPkValue(row);
                if (!enabledSteps.ContainsKey(id))
                {
                    string name    = parentView.GetDisplayValue(row);
                    int    ordinal = 0;
                    if (ordinalField != null)
                    {
                        string s = ordinalField.GetValue(row);
                        if (!string.IsNullOrEmpty(s))
                        {
                            ordinal = Convert.ToInt32(s);
                        }
                    }
                    string description = string.Empty;
                    if (dataTable.Columns.Contains("Description"))
                    {
                        description = row["Description"].ToString();
                    }

                    enabledSteps.Add(id, new EnabledStep()
                    {
                        Enable = false, Id = id, Name = name, Ordinal = ordinal, Description = description
                    });
                }
            }

            result.EnabledSteps = enabledSteps.Values.OrderBy(es => es.Ordinal).ToArray();

            int enabledStepsCount = result.EnabledSteps.Where(es => es.Enable).Count();

            result.MessageOnly = enabledStepsCount == 0 || (enabledStepsCount == 1 && messageOnly);

            if (enabledStepsCount == 0)
            {
                result.WorkflowCompletedMessage = workflowNoResultMessage;
            }
            else
            {
                result.WorkflowCompletedMessage = workflowCompletedMessage;
            }

            return(result);
        }
Exemple #9
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);
            }
        }