示例#1
0
        protected override string GetTo(string viewName, string pk)
        {
            View    view    = GetView(viewName);
            DataRow dataRow = view.GetDataRow(pk);

            Durados.Web.Mvc.ParentField jobField;
            Durados.Web.Mvc.ParentField contactField;
            //if (viewName == CRMViews.Proposal.ToString())
            //{
            //    contactField = (Durados.Web.Mvc.ParentField)view.Fields[Proposal.FK_Proposal_Contact_Parent.ToString()];
            //}
            //else
            //{
            //    contactField = (Durados.Web.Mvc.ParentField)view.Fields[v_ProposalLast2Months.V_Contact_v_ProposalLast2Months_Parent.ToString()];
            //}
            jobField = (Durados.Web.Mvc.ParentField)view.Fields[v_Proposal.FK_Proposal_Job_Parent.ToString()];
            string jobFk = jobField.GetValue(dataRow);

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

            DataRow jobRow = jobView.GetDataRow(jobFk);


            contactField = (Durados.Web.Mvc.ParentField)jobView.Fields[Job.FK_V_Contact_Job_Parent.ToString()];

            string contactFk = contactField.GetValue(jobRow);

            Durados.Web.Mvc.View contactView = GetView(ShadeViews.V_Contact.ToString());
            DataRow contactRow = contactView.GetDataRow(contactFk);
            Field   emailField = (Durados.Web.Mvc.ColumnField)contactView.Fields[V_Contact.Email.ToString()];
            string  email      = emailField.GetValue(contactRow);

            return(email);
        }
示例#2
0
        public override JsonResult GetScalar(string viewName, string pk, string fieldName)
        {
            Durados.Web.Mvc.View view = GetView(viewName, "GetScalar");
            if (view == null)
            {
                return(Json(string.Empty));
            }

            Field field = null;

            if (view.Fields.ContainsKey(fieldName))
            {
                field = view.Fields[fieldName];
            }
            else
            {
                field = view.GetFieldByColumnNames(fieldName);
            }

            if (field == null)
            {
                return(Json(string.Empty));
            }

            DataRow row = view.GetDataRow(pk);

            string scalar = field.GetValue(row);

            return(Json(scalar));
        }
示例#3
0
        protected override string GetTo(string viewName, string pk)
        {
            View    view    = GetView(viewName);
            DataRow dataRow = view.GetDataRow(pk);

            Durados.Web.Mvc.ParentField contactField;
            //if (viewName == CRMViews.Proposal.ToString())
            if (viewName == ProposalViewName)
            {
                contactField = (Durados.Web.Mvc.ParentField)view.Fields[Proposal_Contact_Parent];
                //contactField = (Durados.Web.Mvc.ParentField)view.Fields[Proposal.FK_Proposal_Contact_Parent.ToString()];
            }
            else
            {
                contactField = (Durados.Web.Mvc.ParentField)view.Fields[Proposal_Last_Contact_Parent];
                //contactField = (Durados.Web.Mvc.ParentField)view.Fields[v_ProposalLast2Months.V_Contact_v_ProposalLast2Months_Parent.ToString()];
            }

            string contactFk = contactField.GetValue(dataRow);

            //Durados.Web.Mvc.View contactView = GetView(CRMViews.V_Contact.ToString());
            Durados.Web.Mvc.View contactView = GetView(ContactViewName);
            dataRow = contactView.GetDataRow(contactFk);
            Field emailField = (Durados.Web.Mvc.ColumnField)contactView.Fields[ContactEmailFieldName];
            //Field emailField = (Durados.Web.Mvc.ColumnField)contactView.Fields[V_Contact.Email.ToString()];
            string email = emailField.GetValue(dataRow);

            return(email);
        }
示例#4
0
        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));
        }
示例#5
0
        protected virtual string GetEmailSubject(View view, DataRow row)
        {
            string viewName = GetTemplateViewName();
            string pk       = GetDefaultEmailSubject(view, row);

            Durados.Web.Mvc.View templateView = GetView(viewName);
            DataRow templateRow = templateView.GetDataRow(pk);

            string subject = templateView.GetDisplayValue(GetEmailTemplateFieldName(), templateRow);

            return(subject);
        }
示例#6
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);
        }
示例#7
0
        protected virtual string GetTemplate(string templatePK, Durados.Web.Mvc.View templateView, string documentLocationFiledName, string virtualPath)
        {
            DataRow dataRow = templateView.GetDataRow(templatePK);

            if (dataRow == null)
            {
                throw new DuradosException("Missing document template!");
            }

            virtualPath += templateView.GetDisplayValue(documentLocationFiledName, dataRow);

            string template = HttpContext.Server.MapPath(virtualPath);

            return(template);
        }
示例#8
0
        private Dictionary <string, string> GetConnectionFromConnectionId(List <int> connIds)
        {
            Dictionary <string, string> connStrs = new Dictionary <string, string>();

            foreach (int connId in connIds)
            {
                Durados.Web.Mvc.View view          = GetView(ConnectionViewName);
                System.Data.DataRow  connectionRow = view.GetDataRow(connId.ToString());

                if (connectionRow != null)
                {
                    string password, username, server, catalog;
                    int    port, SqlProductId;
                    try
                    {
                        password     = Convert.ToString(connectionRow["Password"]);
                        username     = Convert.ToString(connectionRow["Username"]);
                        server       = Convert.ToString(connectionRow["ServerName"]);
                        catalog      = Convert.ToString(connectionRow["Catalog"]);
                        SqlProductId = Convert.ToInt32(connectionRow["SqlProductId"]);
                        port         = Convert.ToInt32(connectionRow["ProductPort"]);
                    }
                    catch (Exception ex)
                    {
                        Maps.Instance.DuradosMap.Logger.Log("AppFactory", null, "GetExternalAvailableInstanceConnection", ex, 1, "Missing external instance parameters or converion errors");
                        throw new Exception("Missing external instance parameters or converion errors");
                    }
                    string connectionString = GetConnectionString(server, catalog, false, username, password, null, (Durados.SqlProduct)SqlProductId, port, false, false);
                    connStrs.Add(server, connectionString);
                }
                else
                {
                    Maps.Instance.DuradosMap.Logger.Log("AppFactory", null, "GetConnectionFromConnectionId", null, 1, "No sqlConnection row for connectionId" + connId.ToString());
                }
            }
            return(connStrs);
        }
示例#9
0
        public string GetExternalAvailableInstanceConnectionString(SqlProduct product, out string server, out int port)
        {
            string catalog  = null;
            string username = null;
            string password = null;

            server = null;
            port   = 0;
            string spName       = "durados_GetExternalAvailableInstance";
            int?   connectionId = null;

            using (System.Data.IDbConnection cnn = Durados.DataAccess.DataAccessObject.GetNewConnection(SqlProduct.SqlServer, Maps.Instance.ConnectionString))
            {
                using (DuradosCommand command = new DuradosCommand(GetSystemProduct()))
                {
                    command.Connection  = cnn;
                    command.CommandText = spName;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    if (command.Connection.State == System.Data.ConnectionState.Closed)
                    {
                        try
                        {
                            command.Connection.Open();
                        }
                        catch (Exception ex)
                        {
                            Maps.Instance.DuradosMap.Logger.Log("AppFactory", null, "GetExternalAvailableInstanceConnection", null, 1, "No connection to main database");
                            throw new Exception("No connection to main database", ex);
                        }
                    }
                    System.Data.IDataReader reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        connectionId = reader.GetInt32(reader.GetOrdinal("SqlConnectionId"));
                    }
                }
            }

            if (!connectionId.HasValue)
            {
                Maps.Instance.DuradosMap.Logger.Log("AppFactory", null, "GetExternalAvailableInstanceConnection", null, 1, "Failed to retrive available external instance = connection id has no value");
                throw new Exception("Failed to retrive available external instance = connection id has no value");
            }

            Durados.Web.Mvc.View view          = GetView(ConnectionViewName);
            System.Data.DataRow  connectionRow = view.GetDataRow(connectionId.Value.ToString());
            //Dictionary<string, object> values = new Dictionary<string, object>();
            //values.Add("Id", "&&%&=&&%& " + connectionId.Value.ToString());
            //int rowCount = 0;
            //System.Data.DataView dataView = view.FillPage(1, 2, values, false, null, out rowCount, null, null);
            //if (dataView == null || rowCount != 1)
            if (connectionRow == null)
            {
                Maps.Instance.DuradosMap.Logger.Log("AppFactory", null, "GetExternalAvailableInstanceConnection", null, 1, "Failed to retrive available external instance = no data");
                throw new Exception("Failed to retrive available external instance = no data");
            }

            try
            {
                password = Convert.ToString(connectionRow["Password"]);
                username = Convert.ToString(connectionRow["Username"]);
                server   = Convert.ToString(connectionRow["ServerName"]);
                catalog  = Convert.ToString(connectionRow["Catalog"]);
                port     = Convert.ToInt32(connectionRow["ProductPort"]);
            }
            catch (Exception ex)
            {
                Maps.Instance.DuradosMap.Logger.Log("AppFactory", null, "GetExternalAvailableInstanceConnection", ex, 1, "Missing external instance parameters or converion errors");
                throw new Exception("Missing external instance parameters or converion errors");
            }
            string connectionString = GetConnectionString(server, catalog, false, username, password, null, product, port, false, false);

            return(connectionString);
        }