public static Dictionary <string, List <object> > GetPropertyValuesPairs(PXCache valuesCache, IEnumerable items, IEnumerable <string> fields)
        {
            Dictionary <string, List <object> > dinamicValuesDic =
                new Dictionary <string, List <object> >();
            List <string> mergeableFields = new List <string>();

            foreach (string field in fields)
            {
                CRMergeableAttribute att = CRHelper.GetCustomAttribute <CRMergeableAttribute>(valuesCache, field);
                if (att == null || att.Enabled)
                {
                    mergeableFields.Add(field);
                }
            }
            foreach (object row in items)
            {
                foreach (string field in mergeableFields)
                {
                    if (!dinamicValuesDic.ContainsKey(field))
                    {
                        dinamicValuesDic.Add(field, new List <object>());
                    }

                    List <object> currentValuesList = dinamicValuesDic[field];
                    object        currentValue      = valuesCache.GetValueExt(row, field);
                    if (!currentValuesList.Contains(currentValue))
                    {
                        currentValuesList.Add(currentValue);
                    }
                }
            }
            return(dinamicValuesDic);
        }
Esempio n. 2
0
        protected override void PrePersistHandler(CRBAccountBatch newInstance, ICollection <CRBAccountBatch> deletingInstances)
        {
            if (deletingInstances.Count > 0)
            {
                // Location
                RefItemsCorrectorBase <CRBAccountBatch, Location> locationHelper =
                    new RefItemsCorrector <CRBAccountBatch, Location, Location.bAccountID>(this, GetBAccountID);
                locationHelper.Correct(newInstance, deletingInstances);
                // Address
                RefItemsCorrectorBase <CRBAccountBatch, Address> addressHelper =
                    new RefItemsCorrector <CRBAccountBatch, Address, Address.bAccountID>(this, GetBAccountID);
                addressHelper.Correct(newInstance, deletingInstances);
                // Contact
                RefItemsCorrectorBase <CRBAccountBatch, Contact> contactHelper =
                    new RefItemsCorrector <CRBAccountBatch, Contact, Contact.bAccountID>(this, GetBAccountID);
                contactHelper.Correct(newInstance, deletingInstances);
                // Opportunity
                RefItemsCorrectorBase <CRBAccountBatch, CROpportunity> opportunityHelper =
                    new RefItemsCorrector <CRBAccountBatch, CROpportunity, CROpportunity.bAccountID>(this, GetBAccountID);
                opportunityHelper.Correct(newInstance, deletingInstances);

                // Commit changes
                CRHelper.SafetyPersist(locations.Cache, locationHelper.SaveOperations);
                locations.Cache.IsDirty = false;
                CRHelper.SafetyPersist(addresses.Cache, addressHelper.SaveOperations);
                addresses.Cache.IsDirty = false;
                CRHelper.SafetyPersist(contact.Cache, contactHelper.SaveOperations);
                addresses.Cache.IsDirty = false;
                CRHelper.SafetyPersist(opportunity.Cache, opportunityHelper.SaveOperations);
                addresses.Cache.IsDirty = false;
            }
            base.PrePersistHandler(newInstance, deletingInstances);
        }
        private static async Task <PlayerResult> GetCRPlayerData(string tag, string endpoint, string apikey)
        {
            tag = CRHelper.URLEncodeCRTag(tag);
            try
            {
                HttpWebRequest request = HttpWebRequest.CreateHttp(endpoint);
                request.Method = "GET";
                request.Accept = "application/json";
                request.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + apikey);

                var response = (HttpWebResponse)await request.GetResponseAsync();

                var code = response.StatusCode;

                if (HttpStatusCode.OK == code)
                {
                    System.IO.Stream stream = response.GetResponseStream();
                    StreamReader     reader = new StreamReader(stream);

                    string resultString = await reader.ReadToEndAsync();

                    return(JsonConvert.DeserializeObject <PlayerResult>(resultString));
                }
            }
            catch (Exception e) { throw new Exception(e.Message, e.InnerException); }

            return(new PlayerResult());
        }
Esempio n. 4
0
        private EPActivity InsertActivity(PXCache cache)
        {
            CRHelper.AssertNull(cache, "cache");
            CRHelper.AssertInheritance(typeof(EPActivity), cache.GetItemType(), "cache.GetItemType()");

            EPActivity activity = (EPActivity)cache.Insert();

            activity.RefNoteID = NoteID;
            return(activity);
        }
        public Type[] GetTables(string viewName)
        {
            if (CRHelper.StrEquals(viewName, "Items"))
            {
                return new Type[] { typeof(CRLeadBatch), typeof(BAccount), typeof(Address) }
            }
            ;

            return(null);
        }

        #endregion
    }
        protected override void PrePersistHandler(CRContactBatch newInstance, ICollection <CRContactBatch> deletingInstances)
        {
            if (deletingInstances.Count > 0)
            {
                // CROpportunityContacts
                RefItemsCorrector <CRContactBatch, CROpportunityContacts, CROpportunityContacts.contactID> opportunityContactsHelper =
                    new RefItemsCorrector <CRContactBatch, CROpportunityContacts, CROpportunityContacts.contactID>(this, GetContactID);
                opportunityContactsHelper.Correct(newInstance, deletingInstances);

                // Commit changes
                CRHelper.SafetyPersist(opprotunityContacts.Cache, opportunityContactsHelper.SaveOperations);
            }
            base.PrePersistHandler(newInstance, deletingInstances);
        }
 public override int ExecuteUpdate(string viewName, IDictionary keys, IDictionary values, params object[] parameters)
 {
     if (CRHelper.StrEquals(viewName, "Items"))
     {
         OrderedDictionary correctValues = new OrderedDictionary();
         if (values.Contains("Selected"))
         {
             correctValues.Add("Selected", values["Selected"]);
         }
         base.ExecuteUpdate("LeadItems", keys, correctValues, parameters);
         return(base.ExecuteUpdate(viewName, keys, correctValues, parameters));
     }
     return(base.ExecuteUpdate(viewName, keys, values, parameters));
 }
 private PXCache GetCacheByField(PXGraph graph, string field)
 {
     foreach (Type cacheType in _valuesType)
     {
         PXCache cache = graph.Caches[cacheType];
         foreach (string cacheField in cache.Fields)
         {
             if (CRHelper.StrEquals(field, cacheField))
             {
                 return(cache);
             }
         }
     }
     return(null);
 }
        public IEnumerable AssignLeads(PXAdapter adapter)
        {
            PXCache cache        = this.Caches[typeof(CRLeadBatch)];
            bool    onlySelected = CRMassProcessingAttribute.GetOnlySelectedParameter(adapter.Parameters);

            if ((!onlySelected || CRMassProcessingAttribute.ExistSelectedItems(cache)) &&
                AssignmentMap.View.Ask(null, MessageButtons.Panel) == WebDialogResult.OK)
            {
                CRAssignmentProcessHelper <Lead> helper = new CRAssignmentProcessHelper <Lead>();
                int assignmentMapID = AssignmentMap.Current.CRAssignmentMapID.Value;
                foreach (CRLeadBatch item in onlySelected ?
                         CRMassProcessingAttribute.GetSelectedItems(cache) :
                         CRMassProcessingAttribute.GetAllItems(cache))
                {
                    helper.Assign(item, assignmentMapID);
                }
                CRHelper.SafetyPersist(cache, PXDBOperation.Update);
                this.SelectTimeStamp();
            }

            return(adapter.Get());
        }
Esempio n. 10
0
 private static void CheckCache(PXCache cache, string name)
 {
     CRHelper.AssertInheritance(typeof(EPActivity), cache.GetItemType(), "cache.GetItemType()");
 }
Esempio n. 11
0
        public async Task <string> GetInfo(string tag, string endpoint, string key)
        {
            var result = await GetCRPlayerData(tag, endpoint, key);

            return(CRHelper.ConstructInfoString(result));
        }