public PushResponseforMultipleEntries <T> BuildResponse(string sessionId, T[] arrayofData, string moduleName)
        {
            PushResponseforMultipleEntries <T> pushResponse = new PushResponseforMultipleEntries <T>();
            int SucceedCount = 0;
            int FailedCount  = 0;

            foreach (var data in arrayofData)
            {
                try
                {
                    var req = new AddUpdateSingleEntryRequest();
                    req.SessionId  = sessionId;
                    req.ModuleName = moduleName;
                    req.Entity     = data;
                    var response = SuiteWrapper.AddUpdateSingleEntry(req).GetAwaiter().GetResult();
                    if (!string.IsNullOrEmpty(response.Id))
                    {
                        SucceedCount++;
                    }
                    else
                    {
                        FailedCount++;
                    }
                }
                catch (Exception)
                {
                    FailedCount++;
                }
            }
            pushResponse.SucceedCount = SucceedCount;
            pushResponse.FailedCount  = FailedCount;

            return(pushResponse);
        }
示例#2
0
        public static async Task <AddUpdateSingleEntryResponse> AddUpdateSingleEntry(AddUpdateSingleEntryRequest req)
        {
            string method = "set_entry";

            if (req.SelectFields == null || req.SelectFields.Count == 0)
            {
                req.SelectFields = GetAllJsonPropertyNames(req.Entity);
            }
            var dObj = new
            {
                session         = req.SessionId,
                module_name     = req.ModuleName,
                name_value_list = EntityToNameValueList(Serialize(req.Entity, req.Entity.GetType()),
                                                        req.SelectFields),
            };
            var jstr = await CallApi(method, dObj).ConfigureAwait(false);

            return(JsonConvert.DeserializeObject <AddUpdateSingleEntryResponse>(jstr));
        }