Exemple #1
0
 static string /*?*/ GetSortAttributeString(Type t)
 {
     object /*?*/[] /*?*/ attrs = t.GetCustomAttributes(typeof(SortAttribute), true);
     if (attrs != null && attrs.Length > 0)
     {
         SortAttribute attr = (SortAttribute)attrs[0];
         return(attr.Name);
     }
     return(null);
 }
        public bool Equals(SortAttribute other)
        {
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            if (ReferenceEquals(this, null))
            {
                return(true);
            }

            return(AttributeName == other.AttributeName && Direction == other.Direction);
        }
Exemple #3
0
        private List <SortAttribute> ExtractSortAttributes(DataSourceRequest request)
        {
            List <SortAttribute> list = new List <SortAttribute>();

            foreach (var sort in request.Sorts)
            {
                SortAttribute attribute = new SortAttribute()
                {
                    Member        = sort.Member,
                    SortDirection = sort.SortDirection
                };
                list.Add(attribute);
            }
            return(list);
        }
            //identity how the header should be sorted
            public static SortAttribute processSorting(SortAttribute oldAttribute, SortAttribute newAttribute)
            {
                if (oldAttribute.Header.Equals(newAttribute.Header) && oldAttribute.Control.Equals(newAttribute.Control))
                {
                    if (oldAttribute.Flow.Equals(FLOW_ASC))
                    {
                        newAttribute.Flow = FLOW_DESC;
                    }
                    else
                    {
                        newAttribute.Flow = FLOW_ASC;
                    }
                }

                return(newAttribute);
            }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bindData();
            }

            string parameter = Request["__EVENTARGUMENT"];

            if (parameter != null)
            {
                if (parameter.Equals("ReloadTable"))
                {
                    bindData();
                }
                else if ("SortTable".Equals(parameter.Split(';')[0]))
                {
                    string[]      parameters = parameter.Split(';');
                    SortAttribute newSort    = new SortAttribute(parameters[1], SortAttribute.FLOW_ASC, parameters[2]);

                    if (sortAttribute != null)
                    {
                        sortAttribute = SortAttribute.processSorting(sortAttribute, newSort);
                    }
                    else
                    {
                        sortAttribute = newSort;
                    }

                    if (sortAttribute.Control.Equals("0"))
                    {
                        List <ExpressPrintingSystem.Model.Entities.Request> requestList = getRequestList(Requestlist.STATUS_PENDING, Requestlist.STATUS_PRINTED, Request.Cookies["CompanyID"].Value, sortAttribute.Header);
                        lvRequestConfirmation.DataSource = requestList;
                        lvRequestConfirmation.DataBind();
                    }
                    else if (sortAttribute.Control.Equals("1"))
                    {
                        List <ExpressPrintingSystem.Model.Entities.Request> requestList2 = getRequestList(Requestlist.STATUS_COLLECTED, Requestlist.STATUS_COMPLETED, Request.Cookies["CompanyID"].Value, sortAttribute.Header);
                        lvPickUpRequest.DataSource = requestList2;
                        lvPickUpRequest.DataBind();
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Find open opportunities based on contact or org.
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public List <OpportunityModel> FindOpenOpportunities(string attribute, string value)
        {
            try
            {
                ViewCriteriaItem item = new ViewCriteriaItem();
                item.upperCaseCompare = false;
                item.attribute        = attribute;
                item.@operator        = "=";
                item.Items            = new[] { value };

                ViewCriteriaItem item2 = new ViewCriteriaItem();
                item2.upperCaseCompare = true;
                item2.attribute        = "StatusCode";
                item2.@operator        = "=";
                item2.Items            = new[] { "Open" };

                ViewCriteriaRow condition1 = new ViewCriteriaRow();
                condition1.upperCaseCompare = false;
                condition1.item             = new[] { item, item2 };

                ViewCriteria viewCriteria = new ViewCriteria();
                viewCriteria.conjunction = Conjunction.And;
                viewCriteria.group       = new[] { condition1 };

                //Sorting by Creation date.
                SortAttribute sortAttr = new SortAttribute();
                sortAttr.name       = "CreationDate";
                sortAttr.descending = true;

                FindCriteria findCriteria = new FindCriteria();
                findCriteria.fetchStart = 0;
                findCriteria.fetchSize  = 500;
                findCriteria.filter     = viewCriteria;
                findCriteria.sortOrder  = new[] { sortAttr };

                findCriteria.findAttribute = new string[]
                {
                    "KeyContactId",
                    "PrimaryContactPartyName",
                    "SalesAccountId",
                    "TargetPartyName",
                    "OptyId",
                    "OptyNumber",
                    "PartyName1",
                    "EmailAddress",
                    "Name",
                    "Description",
                    "StatusCode",
                    "SalesMethod",
                    "SalesStage",
                    "SalesChannelCd",
                    "CurrencyCode",
                    "Revenue",
                    "WinProb",
                    "CreatedBy",
                    "CreationDate",
                    "EffectiveDate"
                };

                FindControl findControl = new FindControl();

                Opportunity[] opp = _opportunityClient.findOpportunity(findCriteria, findControl);

                return(getOpportunityModels(opp));
            }
            catch (EndpointNotFoundException wex)
            {
                //Handling incorrect opportunity endpoint
                _logger.Error(wex.Message, wex.StackTrace);
                MessageBox.Show(OSCExceptionMessages.EndpointNotFound,
                                OSCOpportunitiesCommon.EndpointNotFound, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (MessageSecurityException mse)
            {
                //Handling incorrect credentials
                _logger.Error(mse.Message, mse.StackTrace);
                MessageBox.Show(OSCExceptionMessages.OpportunityAuthError,
                                OSCOpportunitiesCommon.OpportunityAuthError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (CommunicationException ce)
            {
                //Handling maximum reponse size exceeded
                _logger.Error(ce.Message, ce.StackTrace);
                MessageBox.Show(OSCExceptionMessages.MaxReceivedMessageSizeExceeded,
                                OSCOpportunitiesCommon.MaxReceivedMessageSizeExceededTitle, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex.StackTrace);
                MessageBox.Show(OSCExceptionMessages.UnexpectedError,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(null);
        }
        /// <summary>
        /// Find open opportunities based on contact or org.
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public List<OpportunityModel> FindOpenOpportunities(string attribute, string value)
        {
            try
            {
                ViewCriteriaItem item = new ViewCriteriaItem();
                item.upperCaseCompare = false;
                item.attribute = attribute;
                item.@operator = "=";
                item.Items = new[] {value};

                ViewCriteriaItem item2 = new ViewCriteriaItem();
                item2.upperCaseCompare = true;
                item2.attribute = "StatusCode";
                item2.@operator = "=";
                item2.Items = new[] {"Open"};

                ViewCriteriaRow condition1 = new ViewCriteriaRow();
                condition1.upperCaseCompare = false;
                condition1.item = new[] {item, item2};

                ViewCriteria viewCriteria = new ViewCriteria();
                viewCriteria.conjunction = Conjunction.And;
                viewCriteria.group = new[] {condition1};

                //Sorting by Creation date.
                SortAttribute sortAttr = new SortAttribute();
                sortAttr.name = "CreationDate";
                sortAttr.descending = true;

                FindCriteria findCriteria = new FindCriteria();
                findCriteria.fetchStart = 0;
                findCriteria.fetchSize = 500;
                findCriteria.filter = viewCriteria;
                findCriteria.sortOrder = new[] {sortAttr};

                findCriteria.findAttribute = new string[]
                {
                    "KeyContactId",
                    "PrimaryContactPartyName",
                    "SalesAccountId",
                    "TargetPartyName",
                    "OptyId",
                    "OptyNumber",
                    "PartyName1",
                    "EmailAddress",
                    "Name",
                    "Description",
                    "StatusCode",
                    "SalesMethod",
                    "SalesStage",
                    "SalesChannelCd",
                    "CurrencyCode",
                    "Revenue",
                    "WinProb",
                    "CreatedBy",
                    "CreationDate",
                    "EffectiveDate"
                };

                FindControl findControl = new FindControl();

                Opportunity[] opp = _opportunityClient.findOpportunity(findCriteria, findControl);

                return getOpportunityModels(opp);
            }
            catch (EndpointNotFoundException wex)
            {
                //Handling incorrect opportunity endpoint
                _logger.Error(wex.Message, wex.StackTrace);
                MessageBox.Show(OSCExceptionMessages.EndpointNotFound,
                    OSCOpportunitiesCommon.EndpointNotFound, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (MessageSecurityException mse)
            {
                //Handling incorrect credentials
                _logger.Error(mse.Message, mse.StackTrace);
                MessageBox.Show(OSCExceptionMessages.OpportunityAuthError,
                    OSCOpportunitiesCommon.OpportunityAuthError, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (CommunicationException ce)
            {
                //Handling maximum reponse size exceeded
                _logger.Error(ce.Message, ce.StackTrace);
                MessageBox.Show(OSCExceptionMessages.MaxReceivedMessageSizeExceeded,
                        OSCOpportunitiesCommon.MaxReceivedMessageSizeExceededTitle, MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex.StackTrace);
                MessageBox.Show(OSCExceptionMessages.UnexpectedError,
                       "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return null;
        }
Exemple #8
0
 private List<SortAttribute> ExtractSortAttributes(DataSourceRequest request)
 {
     List<SortAttribute> list = new List<SortAttribute>();
     if (request.Sorts == null)
         return list;
     foreach (var sort in request.Sorts)
     {
         SortAttribute attribute = new SortAttribute()
         {
             Member = sort.Member,
             SortDirection = sort.SortDirection
         };
         list.Add(attribute);
     }
     return list;
 }