示例#1
0
            public void ReadProperty(object instance, int rowIndex)
            {
                var recordId  = columnView.GetString(rowIndex);
                var recordRef = new RecordRef(formId, recordId);

                property.SetValue(instance, recordRef);
            }
示例#2
0
        public InvoiceItemList addItemList( SalesOrderItemList salesOrderLines)
        {
            InvoiceItemList invItemList = new InvoiceItemList();

            int i = 0;
            InvoiceItem[] Items = new InvoiceItem[salesOrderLines.item.Count()];

            foreach (var itemLine in salesOrderLines.item)
            {
                Items[i] = new InvoiceItem();
                RecordRef item = new RecordRef();
                item.type = RecordType.inventoryItem;
                item.typeSpecified = true;
                // item.internalId = "1229";
                item.internalId = salesOrderLines.item[i].item.internalId;
                Items[i].item = item;

                RecordRef prLevel = new RecordRef();
                prLevel.type = RecordType.priceLevel;
                prLevel.internalId = "-1";
                prLevel.typeSpecified = true;

                Items[i].price = prLevel;
                Items[i].rate = Convert.ToString(salesOrderLines.item[i].rate);
                Items[i].quantity = salesOrderLines.item[i].quantity;
                Items[i].quantitySpecified = true;
                i++;
            }
            invItemList.item = Items;
            return invItemList;
        }
 private void UpdatedInvoice(List <Foodics.NetSuite.Shared.Model.Invoice> InvoiceLst, WriteResponseList responseLst)
 {
     try
     {
         //Tuple to hold local invoice ids and its corresponding Netsuite ids
         List <Tuple <int, string> > iDs = new List <Tuple <int, string> >();
         //loop to fill tuple values
         for (int counter = 0; counter < InvoiceLst.Count; counter++)
         {
             //ensure that invoice is added to netsuite
             if (responseLst.writeResponse[counter].status.isSuccess)
             {
                 try
                 {
                     RecordRef rf = (RecordRef)responseLst.writeResponse[counter].baseRef;
                     iDs.Add(new Tuple <int, string>(Convert.ToInt32(rf.internalId.ToString()), InvoiceLst[counter].Foodics_Id));
                 }
                 catch (Exception ex)
                 {
                     LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
                 }
             }
         }
         GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice> objDAO = new GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice>();
         objDAO.UpdateNetsuiteIDs(iDs, "Invoice");
     }
     catch (Exception ex)
     {
         LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
     }
 }
示例#4
0
        public void addItemList(List<SalesOrderLine> salesOrderLines)
        {
            SalesOrderItemList salesOrderItemList = new SalesOrderItemList();

            int i = 0;
            SalesOrderItem[] Items = new SalesOrderItem[salesOrderLines.Count];
            foreach (var SOLine in salesOrderLines)
            {
                Items[i] = new SalesOrderItem();
                RecordRef item = new RecordRef();
                item.type = RecordType.inventoryItem;
                item.typeSpecified = true;
                item.internalId = salesOrderLines[i].item.itemRecord.internalId;
                Items[i].item = item;

                RecordRef prLevel = new RecordRef();
                prLevel.type = RecordType.priceLevel;
                prLevel.internalId = "-1";
                prLevel.typeSpecified = true;

                Items[i].price = prLevel;
                Items[i].rate = Convert.ToString(salesOrderLines[i].UnitPrice);
                Items[i].quantity = salesOrderLines[i].QuantityRequested;
                Items[i].quantitySpecified = true;
                i++;
            }
            salesOrderItemList.item = Items;
            this.salesOrder.itemList = salesOrderItemList;
        }
        public NetSuiteReadWriteResult Get(RecordRef recordRef)
        {
            Task <ReadResponse> getAsyncResult = null;

            recordRef.type          = RecordType;
            recordRef.typeSpecified = true;

            NetSuiteHelper.TryRun(() =>
            {
                using (var proxy = NetSuiteHelper.GetProxy())
                {
                    getAsyncResult = proxy.getAsync(recordRef);
                    var result     = getAsyncResult.Result;
                    return(result.status.isSuccessSpecified && result.status.isSuccess);
                }
            },
                                  (message) =>
            {
                LogMessage?.Invoke(message);
            });

            //TODO record
            return(new NetSuiteReadWriteResult(result.status, RecordType,
                                               NetSuiteOperationType.Get, null, null));
        }
        public com.netsuite.webservices.Classification[] GenerateNetSuitelst(List <Categories.FoodicsCategories> Lst_Items)
        {
            RecordRef[] subsidiarylst = new RecordRef[1];
            com.netsuite.webservices.Classification[] ItemArr = new com.netsuite.webservices.Classification[Lst_Items.Count];
            for (int i = 0; i < Lst_Items.Count; i++)
            {
                Foodics.NetSuite.Shared.Model.Categories.FoodicsCategories Obj = Lst_Items[i];
                com.netsuite.webservices.Classification NewItemObject          = new com.netsuite.webservices.Classification();

                NewItemObject.name = Obj.name.Length > 30 ? Obj.name.Substring(0, 30) : Obj.name;
                RecordRef subsidiary = new RecordRef();
                subsidiary.internalId        = Obj.Subsidiary_Id.ToString();
                subsidiary.type              = RecordType.subsidiary;
                subsidiarylst[0]             = subsidiary;
                NewItemObject.subsidiaryList = subsidiarylst;
                if (Obj.Netsuite_Id > 0)
                {
                    NewItemObject.internalId = Obj.Netsuite_Id.ToString();
                }
                if (Obj.InActive)
                {
                    NewItemObject.isInactive          = true;
                    NewItemObject.isInactiveSpecified = true;
                }


                ItemArr[i] = NewItemObject;
            }
            return(ItemArr);
            // Send order list to netsuite
        }
        private void UpdatedLst(List <Item> Lst_Items, WriteResponseList responseLst)
        {
            //Tuple to hold local order ids and its corresponding Netsuite ids
            List <Tuple <int, string> > iDs = new List <Tuple <int, string> >();

            //loop to fill tuple values
            //for (int counter = 0; counter < Lst_Items.Count; counter++)
            try
            {
                for (int counter = 0; counter < Lst_Items.Count; counter++)
                {
                    //ensure that order is added to netsuite
                    if (responseLst.writeResponse[counter].status.isSuccess)
                    {
                        RecordRef rf = (RecordRef)responseLst.writeResponse[counter].baseRef;
                        //update netsuiteId property
                        Lst_Items[counter].Netsuite_Id = Convert.ToInt32(rf.internalId.ToString());
                        //add item to the tuple
                        iDs.Add(new Tuple <int, string>(Convert.ToInt32(rf.internalId.ToString()), Lst_Items[counter].Foodics_Id));
                    }
                }
            }
            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
            GenericeDAO <Item> objDAO = new GenericeDAO <Item>();

            //updates local db
            objDAO.UpdateNetsuiteIDs(iDs, "Item", true);
        }
示例#8
0
        private void UpdatedLst(List <Item> Lst_Items, WriteResponseList responseLst)
        {
            //Tuple to hold local order ids and its corresponding Netsuite ids
            List <Tuple <int, string> > iDs = new List <Tuple <int, string> >();

            //loop to fill tuple values
            //for (int counter = 0; counter < Lst_Items.Count; counter++)
            try
            {
                for (int counter = 0; counter < Lst_Items.Count; counter++)
                {
                    //ensure that order is added to netsuite
                    if (responseLst.writeResponse[counter].status.isSuccess)
                    {
                        RecordRef rf = (RecordRef)responseLst.writeResponse[counter].baseRef;
                        //update netsuiteId property
                        Lst_Items[counter].Netsuite_Id = Convert.ToInt32(rf.internalId.ToString());
                        //add item to the tuple
                        iDs.Add(new Tuple <int, string>(Convert.ToInt32(rf.internalId.ToString()), Lst_Items[counter].Foodics_Id));
                    }
                }
            }
            catch (Exception ex)
            {
            }
            GenericeDAO <Item> objDAO = new GenericeDAO <Item>();

            //updates local db
            objDAO.UpdateNetsuiteIDs(iDs, "Item", true);
        }
        /// <summary>
        /// create the nesuite record of file for the upload
        /// </summary>
        /// <param name="taskFile">task file</param>
        /// <returns>netsuite file record</returns>
        private static Record createRecord(TaskFile taskFile)
        {
            string path = taskFile.Path;

            if (!System.IO.File.Exists(path))
            {
                throw new Exception("Error in Task: file does not exist [" + path + "]");
            }

            string folderInternalId = taskFile.Folderid;

            NetsuiteUploader.com.netsuite.na1.webservices.File record = new NetsuiteUploader.com.netsuite.na1.webservices.File();
            record.name                  = System.IO.Path.GetFileName(path);
            record.content               = System.IO.File.ReadAllBytes(path);
            record.isOnlineSpecified     = record.isOnline = (taskFile.IsOnline != null) ? taskFile.IsOnline : false;
            record.bundleableSpecified   = record.bundleable = (taskFile.Bundleable != null) ? taskFile.Bundleable : false;
            record.hideInBundleSpecified = record.hideInBundle = (taskFile.HideInBundle != null) ? taskFile.HideInBundle : false;
            record.isInactiveSpecified   = record.isInactive = (taskFile.IsInactive != null) ? taskFile.IsInactive : false;
            record.isPrivateSpecified    = record.isPrivate = (taskFile.IsPrivate != null) ? taskFile.IsPrivate : false;

            RecordRef recRef = new RecordRef();

            recRef.internalId = folderInternalId;
            record.folder     = recRef;

            return(record);
        }
示例#10
0
        public static PricingMatrix GeneratePricingMatrix(Setting objSetting, Double price)
        {
            Price[]       pricelst         = new Price[1];
            Pricing[]     Pricinglst       = new Pricing[1];
            PricingMatrix PricingMatrixobj = new PricingMatrix();

            RecordRef Currency = new RecordRef();

            Currency.internalId = objSetting.Currency_Netsuite_Id.ToString();
            //Currency.typeSpecified = true;
            // Currency.type = RecordType.account;
            //for (int i = 0; i < 5; i++)
            //{
            RecordRef PriceLevel = new RecordRef();

            PriceLevel.internalId    = "1";//objSetting.Price_Level_Netsuite_Id.ToString();
            PriceLevel.typeSpecified = true;

            PriceLevel.type = RecordType.priceLevel;



            Price objprice = new Price();

            objprice.value    = price;
            objprice.quantity = 0;//0 for item,1 for assembly

            objprice.quantitySpecified = true;
            objprice.valueSpecified    = true;

            pricelst[0] = objprice;



            Pricing objPricing = new Pricing();

            objPricing.currency          = Currency;
            objPricing.priceLevel        = PriceLevel;
            objPricing.priceList         = pricelst;
            objPricing.discount          = double.NaN;//0;
            objPricing.discountSpecified = false;


            Pricinglst[0] = objPricing;
            //}

            //NewItemObject.taxSchedule = Tax_Schedule;


            //PricingMatrixobj.pricing = new Pricing();

            PricingMatrixobj.pricing = Pricinglst;
            //PricingMatrixobj.replaceAll = false;

            return(PricingMatrixobj);
        }
        /// <summary>
        /// Gets the object from the NetSuite by the given internal ID
        /// </summary>
        /// <param name="internalId">Object internal ID in NetSuite</param>
        /// <returns>The instance of the <see cref="NetSuiteReadWriteResult"/> object</returns>
        public NetSuiteReadWriteResult Get(string internalId)
        {
            RecordRef recordRef = new RecordRef();

            recordRef.internalId    = internalId;
            recordRef.type          = RecordType;
            recordRef.typeSpecified = true;

            return(Get(recordRef));
        }
示例#12
0
        public override void Get()
        {
            /// <summary> This method get all items (with types we need in POS) from netsuite and check item type,
            /// after that get all item info and save in DB.</summary>
            ///

            string IntrnelID = GetCustomizationId("customrecord_da_payment_method_percentag");



            CustomRecordSearch      customRecordSearch      = new CustomRecordSearch();
            CustomRecordSearchBasic customRecordSearchBasic = new CustomRecordSearchBasic();
            RecordRef recordRef = new RecordRef();

            recordRef.internalId            = IntrnelID;
            recordRef.type                  = RecordType.customTransaction;
            customRecordSearchBasic.recType = recordRef;
            customRecordSearch.basic        = customRecordSearchBasic;
            SearchResult response = Service(true).search(customRecordSearch);

            if (response.status.isSuccess)
            {
                if (response.totalRecords > 0)
                {
                    CustomRecord     item_Custom;
                    CustomFieldRef[] flds;
                    List <Foodics.NetSuite.Shared.Model.PaymentMethod> lstsetting = new List <Foodics.NetSuite.Shared.Model.PaymentMethod>();
                    for (int i = 0; i < response.recordList.Length; i++)
                    {
                        item_Custom = (CustomRecord)response.recordList[i];
                        flds        = item_Custom.customFieldList;

                        Foodics.NetSuite.Shared.Model.PaymentMethod payObj = new Foodics.NetSuite.Shared.Model.PaymentMethod();
                        //payObj.Netsuite_Id = Utility.ConvertToInt(item_Custom.internalId);

                        for (int c = 0; c < flds.Length; c++)
                        {
                            if (flds[c].scriptId == "custrecord_da_percentage")
                            {
                                payObj.Percentage = Utility.ConvertToInt(((com.netsuite.webservices.DoubleCustomFieldRef)flds[c]).value.ToString());
                            }
                            if (flds[c].scriptId == "custrecord_da_payment_method_ref")
                            {
                                payObj.Netsuite_Id = Utility.ConvertToInt(((com.netsuite.webservices.SelectCustomFieldRef)flds[c]).value.internalId.ToString());
                            }
                        }
                        lstsetting.Add(payObj);
                    }


                    new GenericeDAO <Foodics.NetSuite.Shared.Model.PaymentMethod>().UpdatePaymentMethod(lstsetting);
                }
            }
        }
        private RecordRef CreateLocation(WarehouseLocation warehouse)
        {
            RecordRef location = new RecordRef()
            {
                type          = RecordType.location,
                typeSpecified = true,
                internalId    = warehouse.ToString("d")
            };

            return(location);
        }
示例#14
0
 public Passport prepare(NetsuiteUser NSuser)
 {
     Passport passport = new Passport();
     passport.account = NSuser.AccountNumber;
     passport.email = NSuser.Email;
     RecordRef role = new RecordRef();
     role.internalId = NSuser.RoleID;
     passport.role = role;
     passport.password = NSuser.Password;
     return passport;
 }
示例#15
0
        public Passport prepare(NetsuiteUser NSuser)
        {
            Passport passport = new Passport();

            passport.account = NSuser.AccountNumber;
            passport.email   = NSuser.Email;
            RecordRef role = new RecordRef();

            role.internalId   = NSuser.RoleID;
            passport.role     = role;
            passport.password = NSuser.Password;
            return(passport);
        }
示例#16
0
        public static RecordRef CreateRecordRefWithId(string internalId)
        {
            if (internalId == null || internalId.Trim().Length == 0)
            {
                return(null);
            }

            RecordRef recordRef = new RecordRef();

            recordRef.internalId = internalId;

            return(recordRef);
        }
        public int Compare(RecordRef r1, RecordRef r2)
        {
            var owningRun = buffer.AsSpan(0, limit);

            var r1Span = owningRun.Slice(r1.offset, r1.length);
            var r2Span = owningRun.Slice(r2.offset, r2.length);

            int d;
            var tl1 = r1.length - r1.textStart;
            var tl2 = r2.length - r2.textStart;
            var len = Min(tl1, tl2);

            // compare text
            for (int i = 0; i < len; ++i)
            {
                d = r1Span[r1.textStart + i] - r2Span[r2.textStart + i];
                if (d == 0)
                {
                    continue;
                }
                return(d);
            }
            var textLengthCompareResult = tl1.CompareTo(tl2);

            if (textLengthCompareResult != 0)
            {
                return(textLengthCompareResult);
            }

            // compare number
            // assume there are no leading zeroes
            // (if there are any, this method may yield wrong result)
            d = r1.textStart - r2.textStart;
            if (d != 0)
            {
                return(d);
            }

            var numLen = r1.textStart - 2;

            for (int i = 0; i < numLen; ++i)
            {
                d = r1Span[i] - r2Span[i];
                if (d == 0)
                {
                    continue;
                }
                return(d);
            }
            return(0);
        }
        public IEnumerable <NetSuiteReadWriteResult> Get(List <string> internalIds)
        {
            List <RecordRef> recordRefs = new List <RecordRef>();

            foreach (var item in internalIds)
            {
                RecordRef recordRef = new RecordRef();
                recordRef.internalId    = item;
                recordRef.type          = RecordType;
                recordRef.typeSpecified = true;
            }

            return(Get(recordRefs.ToArray()));
        }
        public List <RecordRef> GetNSGetList(List <ItemInfo> in_magento_not_ns_items)
        {
            List <RecordRef> recordRefs = new List <RecordRef>();

            foreach (ItemInfo itemInfo in in_magento_not_ns_items)
            {
                RecordRef itemRef = new RecordRef
                {
                    name          = itemInfo.sku,
                    internalId    = itemInfo.ns_internal_id,
                    typeSpecified = true
                };

                switch (itemInfo.ns_item_type)
                {
                case "Inventory Item":
                    itemRef.type = RecordType.inventoryItem;
                    break;

                case "Lot Numbered Assembly":
                    itemRef.type = RecordType.lotNumberedAssemblyItem;
                    break;

                case "Non-inventory Item":
                    itemRef.type = RecordType.nonInventorySaleItem;
                    break;

                case "Kit/Package":
                    itemRef.type = RecordType.kitItem;
                    break;

                case "Service for Sale":
                    itemRef.type = RecordType.serviceSaleItem;
                    break;

                case "Undefined":
                    Console.WriteLine("{0, -10} Type Undefined, Skip!", itemInfo.sku);
                    continue;

                default:
                    Console.WriteLine("Error item: {0}, type: {1}", itemInfo.sku, itemInfo.ns_item_type);
                    throw new Exception("itemType match error!");
                }

                recordRefs.Add(itemRef);
            }

            return(recordRefs);
        }
示例#20
0
        private void Updatedlst(List <Foodics.NetSuite.Shared.Model.UnitsOfMeasure> InvoiceLst, WriteResponseList responseLst)
        {
            try
            {
                string strids = "";
                //Tuple to hold local invoice ids and its corresponding Netsuite ids
                List <Tuple <int, string> > iDs = new List <Tuple <int, string> >();
                //loop to fill tuple values
                for (int counter = 0; counter < InvoiceLst.Count; counter++)
                {
                    //ensure that invoice is added to netsuite
                    if (responseLst.writeResponse[counter].status.isSuccess)
                    {
                        try
                        {
                            RecordRef rf = (RecordRef)responseLst.writeResponse[counter].baseRef;
                            //update netsuiteId property
                            InvoiceLst[counter].Netsuite_Id = Convert.ToInt32(rf.internalId.ToString());
                            //add item to the tuple
                            iDs.Add(new Tuple <int, string>(Convert.ToInt32(rf.internalId.ToString()), InvoiceLst[counter].Id.ToString()));

                            strids += InvoiceLst[counter].Id.ToString();
                            if (counter + 1 < InvoiceLst.Count)
                            {
                                strids += ",";
                            }
                        }
                        catch (Exception ex)
                        {
                            LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
                        }
                    }
                }
                // NetsuiteDAO objDAO = new NetsuiteDAO();
                //updates local db
                // LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask UpdateDB", "Updating " + iDs.Count().ToString() + " from " + InvoiceLst.Count().ToString());

                //objDAO.UpdateNetsuiteIDs(iDs, "Invoice");

                GenericeDAO <Foodics.NetSuite.Shared.Model.UnitsOfMeasure> objDAO = new GenericeDAO <Foodics.NetSuite.Shared.Model.UnitsOfMeasure>();
                objDAO.MainUpdateNetsuiteIDs(iDs, "UnitsOfMeasure");
                new CustomDAO().UpdateUnitsOfMeasureIngredient(strids);
            }

            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
        }
示例#21
0
        public override Int64 Set(string parametersArr)
        {
            try
            {
                new CustomDAO().Check_PaymentCash_Exist();
                List <Foodics.NetSuite.Shared.Model.PaymentMethod> Lst_Items = new GenericeDAO <Foodics.NetSuite.Shared.Model.PaymentMethod>().GetWhere(" (Netsuite_Id IS NULL or Netsuite_Id =0)");
                if (Lst_Items.Count <= 0)
                {
                    return(0);
                }

                RecordRef[] subsidiarylst = new RecordRef[1];
                com.netsuite.webservices.PaymentMethod[] ItemArr = new com.netsuite.webservices.PaymentMethod[Lst_Items.Count];
                for (int i = 0; i < Lst_Items.Count; i++)
                {
                    Foodics.NetSuite.Shared.Model.PaymentMethod Obj           = Lst_Items[i];
                    com.netsuite.webservices.PaymentMethod      NewItemObject = new com.netsuite.webservices.PaymentMethod();
                    NewItemObject.name = Obj.Name_En.Length > 30 ? Obj.Name_En.Substring(0, 30) : Obj.Name_En;

                    NewItemObject.undepFunds          = true;
                    NewItemObject.undepFundsSpecified = true;

                    NewItemObject.isOnline          = false;
                    NewItemObject.isOnlineSpecified = true;
                    if (Obj.InActive)
                    {
                        NewItemObject.isInactive          = true;
                        NewItemObject.isInactiveSpecified = true;
                    }

                    ItemArr[i] = NewItemObject;
                }
                // Send order list to netsuite
                WriteResponseList wr = Service(true).addList(ItemArr);
                bool result          = wr.status.isSuccess;
                if (result)
                {
                    //Update database with returned Netsuite ids
                    UpdatedLst(Lst_Items, wr);
                }
            }
            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
            return(0);
        }
示例#22
0
        public override Int64 Set(string parametersArr)
        {
            List <Foodics.NetSuite.Shared.Model.Location> Lst_Items = new GenericeDAO <Foodics.NetSuite.Shared.Model.Location>().GetWhere("Netsuite_Id IS NULL or Netsuite_Id =0");

            if (Lst_Items.Count <= 0)
            {
                return(0);
            }

            try
            {
                com.netsuite.webservices.Location[] ItemArr = new com.netsuite.webservices.Location[Lst_Items.Count];
                for (int i = 0; i < Lst_Items.Count; i++)
                {
                    Foodics.NetSuite.Shared.Model.Location Obj = Lst_Items[i];
                    RecordRef[] subsidiarylst = new RecordRef[1];
                    com.netsuite.webservices.Location NewItemObject = new com.netsuite.webservices.Location();
                    NewItemObject.name      = Obj.Name_En.Length < 30? Obj.Name_En: Obj.Name_En.Substring(0, 30);
                    NewItemObject.latitude  = Utility.ConvertToDouble(Obj.Latitude);
                    NewItemObject.longitude = Utility.ConvertToDouble(Obj.Longitude);

                    RecordRef subsidiary = new RecordRef();
                    subsidiary.internalId        = Obj.Subsidiary_Id.ToString();
                    subsidiary.type              = RecordType.subsidiary;
                    subsidiarylst[0]             = subsidiary;
                    NewItemObject.subsidiaryList = subsidiarylst;

                    if (Obj.InActive)
                    {
                        NewItemObject.isInactive          = true;
                        NewItemObject.isInactiveSpecified = true;
                    }
                    ItemArr[i] = NewItemObject;
                }
                WriteResponseList wr = Service(true).addList(ItemArr);
                bool result          = wr.status.isSuccess;
                if (result)
                {
                    UpdatedLst(Lst_Items, wr);
                }
            }
            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
            return(0);
        }
示例#23
0
        public string createNewBin(InventoryBin bin)
        {
            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            LocationSearch locationSearch = new LocationSearch();
            LocationSearchBasic locationSearchBasic = new LocationSearchBasic();
            SearchStringField locationName = new SearchStringField();
            locationName.searchValue = bin.LocationName;
            locationName.@operator = SearchStringFieldOperator.@is;
            locationName.operatorSpecified = true;
            locationSearchBasic.name = locationName;
            locationSearch.basic = locationSearchBasic;

            SearchResult sr = new SearchResult();
            sr = service.search(locationSearch);
            if (sr.status.isSuccess != true) Console.WriteLine(sr.status.statusDetail[0].message);

            Bin newBin = new Bin();
            RecordRef newLocation = new RecordRef();
            newLocation.type = RecordType.location;
            newLocation.typeSpecified = true;
            newLocation.internalId = ((com.netsuite.webservices.Location)sr.recordList[0]).internalId;
            newBin.binNumber = bin.BinNumber;
            newBin.location = newLocation;

            WriteResponse writeResponse = service.add(newBin);
            if (writeResponse.status.isSuccess == true)
            {

                Console.WriteLine("Bin: "+ newBin.binNumber +" has been created.");
                return "Bin: " + newBin.binNumber + " has been created.";

            }
            if (writeResponse.status.isSuccess == false)
            {
                Console.WriteLine(writeResponse.status.statusDetail[0].message);
                return writeResponse.status.statusDetail[0].message;
            }
            return string.Empty;
        }
        private RecordRef CreateCustomer(int customer_group_id)
        {
            RecordRef customer = new RecordRef()
            {
                type          = RecordType.customer,
                typeSpecified = true
            };

            switch (customer_group_id)
            {
            case 1: customer.internalId = "3183521"; break;     // Lollicupstore2

            case 2: customer.internalId = "3196989"; break;     // Lollicupstore2 - Reseller

            case 3: customer.internalId = "3114319"; break;     // Amazon Seller Central

            default: throw new Exception("group_id match error!");
            }

            return(customer);
        }
        private RecordRef CreateSalesRep(int customer_group_id)
        {
            RecordRef salesRep = new RecordRef()
            {
                type          = RecordType.salesRole,
                typeSpecified = true
            };

            switch (customer_group_id)
            {
            case 1: salesRep.internalId = "8"; break;           // Standard : E-BIZ LLC

            case 2: salesRep.internalId = "8"; break;           // Reseller : E-BIZ LLC

            case 3: salesRep.internalId = "1670292"; break;     // Amazon   : E-BIZ AMZ

            default: throw new Exception("group_id match error!");
            }

            return(salesRep);
        }
        private void UpdatedInvoice(List <Foodics.NetSuite.Shared.Model.Invoice> InvoiceLst, WriteResponseList responseLst)
        {
            try
            {
                //Tuple to hold local invoice ids and its corresponding Netsuite ids
                List <Tuple <int, string> > iDs = new List <Tuple <int, string> >();
                //loop to fill tuple values
                for (int counter = 0; counter < InvoiceLst.Count; counter++)
                {
                    //ensure that invoice is added to netsuite
                    if (responseLst.writeResponse[counter].status.isSuccess)
                    {
                        try
                        {
                            RecordRef rf = (RecordRef)responseLst.writeResponse[counter].baseRef;
                            //update netsuiteId property
                            InvoiceLst[counter].Netsuite_Id = Convert.ToInt32(rf.internalId.ToString());
                            //add item to the tuple
                            iDs.Add(new Tuple <int, string>(Convert.ToInt32(rf.internalId.ToString()), InvoiceLst[counter].Foodics_Id));
                        }
                        catch (Exception ex)
                        {
                            //   LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask UpdateDB Counter Error", "Error " + ex.Message + " Count = " + counter.ToString());
                        }
                    }
                }
                // NetsuiteDAO objDAO = new NetsuiteDAO();
                //updates local db
                // LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask UpdateDB", "Updating " + iDs.Count().ToString() + " from " + InvoiceLst.Count().ToString());

                //objDAO.UpdateNetsuiteIDs(iDs, "Invoice");

                GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice> objDAO = new GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice>();
                objDAO.UpdateNetsuiteIDs(iDs, "Invoice");
            }
            catch (Exception ex) {
                // LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask UpdateDB Error", "Error " + ex.Message);
            }
        }
        private List <RecordRef> ExtractItems(byte[] buffer, int limit)
        {
            var span  = new ReadOnlySpan <byte>(buffer, 0, limit);
            var items = new List <RecordRef>(span.Length / _lineLengthHintInBytes + 1);

            int i             = 0;
            int lastStart     = 0;
            int recordCounter = 0;

            while (i < span.Length)
            {
                while (i < span.Length && span[i] != (byte)'\n')
                {
                    ++i;
                }
                var record = RecordRef.EnsureFormatAndCreate(ref span, lastStart, (short)(i - lastStart + 1), ++recordCounter);

                lastStart = ++i;
                items.Add(record);
            }

            return(items);
        }
        /// <summary>
        /// Gets a list of records for one or more NetSuite WEB service call
        /// </summary>
        /// <param name="recordsList">Array of <see cref="RecordRef"/> objects</param>
        /// <returns>Array of the <see cref="NetSuiteReadWriteResult"/> objects</returns>
        public virtual NetSuiteReadWriteResult[] GetList(RecordRef[] recordsList)
        {
            if (recordsList == null)
            {
                return(null);
            }

            if (recordsList.Length == 0)
            {
                return(new NetSuiteReadWriteResult[0]);
            }

            NetSuiteReadWriteResult[] resultArray = new NetSuiteReadWriteResult[recordsList.Length];

            var maxGetListRecordsCount = NetSuiteHelper.MaxGetListRecordsCount;

            for (int index = 0; index *maxGetListRecordsCount < recordsList.Length; index++)
            {
                int startIndex    = index * maxGetListRecordsCount;
                int elementsCount = (startIndex + maxGetListRecordsCount) > recordsList.Length ?
                                    (recordsList.Length - startIndex) : maxGetListRecordsCount;

                RecordRef[] getList = new RecordRef[elementsCount];
                Array.Copy(recordsList, startIndex, getList, 0, elementsCount);
                Task <ReadResponseList> responseArrayTask = NetSuiteHelper.GetProxy().getListAsync(getList);

                for (int jIndex = 0; jIndex < responseArrayTask.Result.readResponse.Length; jIndex++)
                {
                    resultArray[startIndex + jIndex] = new NetSuiteReadWriteResult(
                        responseArrayTask.Result.readResponse[jIndex].status, getList[jIndex].type, NetSuiteOperationType.Get,
                        responseArrayTask.Result.readResponse[jIndex].record, null);
                }
            }

            return(resultArray);
        }
示例#29
0
        public Invoice(SalesOrder salesOrder)
        {
            this.invoice = new com.netsuite.webservices.Invoice();

            RecordRef salesOrderID = new RecordRef();
            salesOrderID.type = RecordType.salesOrder;
            salesOrderID.typeSpecified = true;

            salesOrderID.internalId = salesOrder.salesOrder.internalId;

            this.invoice.createdFrom = salesOrderID;

            this.invoice.billAddress = salesOrder.salesOrder.billAddress;
            //this.invoice.shipAddress = salesOrder.salesOrder.shipAddress;
            this.invoice.entity = salesOrder.salesOrder.entity;
            this.invoice.subTotal = salesOrder.salesOrder.subTotal;

            InvoiceItemList invoiceItemList = new InvoiceItemList();
            this.invoice.itemList = addItemList(salesOrder.salesOrder.itemList);

            this.invoice.memo = salesOrder.salesOrder.memo;
            this.invoice.location = salesOrder.salesOrder.location;
            //this.invoice.fob = salesOrder.salesOrder.fob;
        }
        private void Updatedlst(List <Foodics.NetSuite.Shared.Model.AdjustmentBuild> InvoiceLst, WriteResponseList responseLst)
        {
            try
            {
                //Tuple to hold local invoice ids and its corresponding Netsuite ids
                List <Tuple <int, int, int> > iDs = new List <Tuple <int, int, int> >();
                //loop to fill tuple values
                for (int counter = 0; counter < InvoiceLst.Count; counter++)
                {
                    //ensure that invoice is added to netsuite
                    if (responseLst.writeResponse[counter].status.isSuccess)
                    {
                        try
                        {
                            RecordRef rf = (RecordRef)responseLst.writeResponse[counter].baseRef;
                            //update netsuiteId property
                            InvoiceLst[counter].Netsuite_Id = Convert.ToInt32(rf.internalId.ToString());
                            //add item to the tuple
                            iDs.Add(new Tuple <int, int, int>(Convert.ToInt32(rf.internalId.ToString()), InvoiceLst[counter].Location_Id, InvoiceLst[counter].Subsidiary_Id));
                        }
                        catch (Exception ex)
                        {
                            //   LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask UpdateDB Counter Error", "Error " + ex.Message + " Count = " + counter.ToString());
                        }
                    }
                }


                GenericeDAO <Foodics.NetSuite.Shared.Model.AssemblyBuild> objDAO = new GenericeDAO <Foodics.NetSuite.Shared.Model.AssemblyBuild>();
                objDAO.UpdateNetsuiteID_ADjustement(iDs, "AdjustmentBuild");
            }
            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
        }
        /*
            Attaching the contact to the customer is not only establishing the 1-to-N relationship but also
            assigning a role to the contact within the customer organization.  This form doesn't ask what the
            end user's role is within their organization, but it could and that data could be recorded here.
            Right now we're assuming that the customer is the primary point of contact.
        */
        public void attachContact()
        {
            // Create a new contact role (primary)
            RecordRef contactRole = new RecordRef();
            contactRole.internalId = "-10";  //Primary
            contactRole.type = RecordType.contactRole;
            contactRole.typeSpecified = true;

            /* We're going to create a reference to the new contact record via it's internal ID */
            RecordRef contactRef = new RecordRef();
            contactRef.internalId = _contactID;
            contactRef.type = RecordType.contact;
            contactRef.typeSpecified = true;

            /* And the same here for the newly created customer record */
            RecordRef customerRef = new RecordRef();
            customerRef.internalId = _customerID;
            customerRef.type = RecordType.customer;
            customerRef.typeSpecified = true;

            /* We attach the two by using a pre-made XML renderer from NetSuite. */
            AttachContactReference attachReference = new AttachContactReference();
            attachReference.attachTo = customerRef;
            attachReference.contact = contactRef;
            attachReference.contactRole = contactRole;

            _attachStatus = _service.attach(attachReference).status;
        }
        public com.netsuite.webservices.ServiceSaleItem[] GenerateNetSuitelst(List <Item> Lst_ItemsAll)
        {
            com.netsuite.webservices.ServiceSaleItem[] ItemArr = new com.netsuite.webservices.ServiceSaleItem[Lst_ItemsAll.Count];
            try
            {
                for (int i = 0; i < Lst_ItemsAll.Count; i++)
                {
                    RecordRef[] subsidiarylst = new RecordRef[1];
                    Item        Obj           = Lst_ItemsAll[i];
                    Setting     objSetting    = new GenericeDAO <Setting>().GetWhere("Subsidiary_Netsuite_Id=" + Obj.Subsidiary_Id).FirstOrDefault();
                    Categories.CategoriesAccounts            objCatAccount = new Categories.CategoriesAccounts();
                    com.netsuite.webservices.ServiceSaleItem NewItemObject = new com.netsuite.webservices.ServiceSaleItem();
                    if (Obj.Netsuite_Id <= 0)
                    {
                        NewItemObject.displayName = Obj.Display_Name_En;
                        //NewItemObject.itemId = Obj.UPC_Code;
                        NewItemObject.itemId           = Obj.Display_Name_En;
                        NewItemObject.salesDescription = Obj.Display_Name_En;
                    }
                    //check if new or can be updated
                    if (Obj.Netsuite_Id > 0)
                    {
                        NewItemObject.internalId = Obj.Netsuite_Id.ToString();
                    }

                    NewItemObject.pricingMatrix = Helper.GeneratePricingMatrix(objSetting, Obj.Price);


                    CustomFieldRef[] custFieldList = new CustomFieldRef[] {
                        new StringCustomFieldRef {
                            value    = Obj.Name_Ar != null? Obj.Name_Ar:"",
                            scriptId = "custitem_da_item_name_ar"
                        }
                    };
                    NewItemObject.customFieldList = custFieldList;


                    #region Items Account
                    RecordRef IncomAccountref = new RecordRef();
                    IncomAccountref.type        = RecordType.account;
                    NewItemObject.incomeAccount = IncomAccountref;

                    IncomAccountref.internalId = objSetting.IncomeAccount_Netsuite_Id.ToString();



                    #endregion
                    RecordRef Tax_Schedule = new RecordRef();
                    Tax_Schedule.internalId   = objSetting.TaxSchedule_Netsuite_Id.ToString();
                    Tax_Schedule.type         = RecordType.salesTaxItem;
                    NewItemObject.taxSchedule = Tax_Schedule;

                    RecordRef subsidiary = new RecordRef();
                    subsidiary.internalId        = objSetting.Subsidiary_Netsuite_Id.ToString();
                    subsidiary.type              = RecordType.subsidiary;
                    subsidiarylst[0]             = subsidiary;
                    NewItemObject.subsidiaryList = subsidiarylst;


                    NewItemObject.isInactive          = Obj.InActive;
                    NewItemObject.isInactiveSpecified = true;

                    ItemArr[i] = NewItemObject;
                }
            }
            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
            return(ItemArr);
        }
示例#33
0
        public com.netsuite.webservices.AssemblyItem[] GenerateNetSuitelst(List <Item> Lst_Items)
        {
            Price[]   pricelst   = new Price[1];
            Pricing[] Pricinglst = new Pricing[1];
            com.netsuite.webservices.AssemblyItem[] ItemArr = new com.netsuite.webservices.AssemblyItem[Lst_Items.Count];
            try
            {
                for (int i = 0; i < Lst_Items.Count; i++)
                {
                    Item    Obj        = Lst_Items[i];
                    Setting objSetting = new GenericeDAO <Setting>().GetWhere("Subsidiary_Netsuite_Id=" + Obj.Subsidiary_Id).FirstOrDefault();
                    com.netsuite.webservices.AssemblyItem NewItemObject = new com.netsuite.webservices.AssemblyItem();
                    Categories.CategoriesAccounts         objCatAccount = new Categories.CategoriesAccounts();

                    // if (Obj.Netsuite_Id <= 0)
                    //{
                    NewItemObject.itemId      = Obj.UPC_Code;
                    NewItemObject.displayName = Obj.Display_Name_En;
                    //}


                    NewItemObject.trackLandedCost          = true;
                    NewItemObject.trackLandedCostSpecified = true;

                    if (Obj.Category_Id > 0)
                    {
                        RecordRef classref = new RecordRef();
                        classref.internalId  = Obj.Category_Id.ToString();
                        classref.type        = RecordType.classification;
                        NewItemObject.@class = classref;

                        objCatAccount = new GenericeDAO <Categories.CategoriesAccounts>().GetWhere("Netsuite_Id=" + Obj.Category_Id).FirstOrDefault();
                    }

                    #region Custom fields

                    Obj.Storage_Unit = string.IsNullOrEmpty(Obj.Storage_Unit) ? "" : Obj.Storage_Unit;

                    CustomFieldRef[] custFieldList = new CustomFieldRef[] {
                        new StringCustomFieldRef {
                            value    = !string.IsNullOrEmpty(Obj.Name_Ar)? Obj.Name_Ar.ToString():"",
                            scriptId = "custitem_da_item_name_ar"
                        }
                        ,
                        new StringCustomFieldRef {
                            value    = Obj.UPC_Code.ToString(),
                            scriptId = "custitem1"
                        }
                    };
                    NewItemObject.customFieldList = custFieldList;
                    #endregion
                    if (Obj.Netsuite_Id > 0)
                    {
                        NewItemObject.internalId = Obj.Netsuite_Id.ToString();
                    }

                    #region pricing

                    NewItemObject.pricingMatrix = Helper.GeneratePricingMatrix(objSetting, Obj.Price);
                    #endregion
                    #region AssemblyComponent

                    List <ItemCompnent> itemCompnentslst = new GenericeDAO <ItemCompnent>().GetWhere("ItemFoodics_Id ='" + Obj.Foodics_Id + "'");
                    if (itemCompnentslst.Count > 0)
                    {
                        ItemMember[]   ItemMemberlst = new ItemMember[itemCompnentslst.Count];
                        ItemMemberList memberlst     = new ItemMemberList();
                        for (int x = 0; x < itemCompnentslst.Count; x++)
                        {
                            ItemMember   obj        = new ItemMember();
                            ItemCompnent itmcompobj = itemCompnentslst[x];
                            RecordRef    Itemref    = new RecordRef();
                            Itemref.internalId = itmcompobj.ComponentId.ToString();
                            Itemref.type       = RecordType.inventoryItem;

                            obj.item = Itemref;

                            obj.quantity          = itmcompobj.Quantity == 0 ? 1 : itmcompobj.Quantity;
                            obj.quantitySpecified = true;
                            ItemMemberlst[x]      = obj;
                        }
                        memberlst.itemMember                = ItemMemberlst;
                        NewItemObject.memberList            = memberlst;
                        NewItemObject.memberList.replaceAll = true;
                    }



                    #endregion
                    #region Items Account
                    RecordRef IncomAccountref = new RecordRef();
                    IncomAccountref.type        = RecordType.account;
                    NewItemObject.incomeAccount = IncomAccountref;
                    if (objCatAccount.income_account > 0)
                    {
                        IncomAccountref.internalId = objCatAccount.income_account.ToString();
                    }
                    else if (objSetting.IncomeAccount_Netsuite_Id > 0)
                    {
                        IncomAccountref.internalId = objSetting.IncomeAccount_Netsuite_Id.ToString();
                    }

                    RecordRef cogsAccountref = new RecordRef();
                    cogsAccountref.type       = RecordType.account;
                    NewItemObject.cogsAccount = cogsAccountref;
                    if (objCatAccount.cogs_account > 0)
                    {
                        cogsAccountref.internalId = objCatAccount.cogs_account.ToString();
                    }
                    else if (objSetting.CogsAccount_Netsuite_Id > 0)
                    {
                        cogsAccountref.internalId = objSetting.CogsAccount_Netsuite_Id.ToString();
                    }

                    RecordRef assetAccountref = new RecordRef();
                    assetAccountref.type       = RecordType.account;
                    NewItemObject.assetAccount = assetAccountref;
                    if (objCatAccount.asset_account > 0)
                    {
                        assetAccountref.internalId = objCatAccount.asset_account.ToString();
                    }
                    else if (objSetting.AssetAccount_Netsuite_Id > 0)
                    {
                        assetAccountref.internalId = objSetting.AssetAccount_Netsuite_Id.ToString();
                    }

                    RecordRef intercoIncomeref = new RecordRef();
                    intercoIncomeref.type = RecordType.account;
                    NewItemObject.intercoIncomeAccount = intercoIncomeref;
                    if (objCatAccount.income_intercompany_account > 0)
                    {
                        intercoIncomeref.internalId = objCatAccount.income_intercompany_account.ToString();
                    }
                    else if (objSetting.IntercoIncomeAccount_Netsuite_Id > 0)
                    {
                        intercoIncomeref.internalId = objSetting.IntercoIncomeAccount_Netsuite_Id.ToString();
                    }

                    RecordRef intercoCogsAccount = new RecordRef();
                    intercoCogsAccount.type          = RecordType.account;
                    NewItemObject.intercoCogsAccount = intercoCogsAccount;
                    if (objCatAccount.inter_cogs_account > 0)
                    {
                        intercoCogsAccount.internalId = objCatAccount.inter_cogs_account.ToString();
                    }
                    else if (objSetting.IntercoCogsAccount_Netsuite_Id > 0)
                    {
                        intercoCogsAccount.internalId = objSetting.IntercoCogsAccount_Netsuite_Id.ToString();
                    }

                    RecordRef gainLossAccount = new RecordRef();
                    gainLossAccount.type          = RecordType.account;
                    NewItemObject.gainLossAccount = gainLossAccount;
                    if (objCatAccount.gainloss_account > 0)
                    {
                        gainLossAccount.internalId = objCatAccount.gainloss_account.ToString();
                    }
                    else if (objSetting.GainLossAccount_Netsuite_Id > 0)
                    {
                        gainLossAccount.internalId = objSetting.GainLossAccount_Netsuite_Id.ToString();
                    }


                    if (objCatAccount.cust_qty_variance_account > 0)
                    {
                        RecordRef refgAccount = new RecordRef();
                        refgAccount.type                  = RecordType.account;
                        refgAccount.internalId            = objCatAccount.cust_qty_variance_account.ToString();
                        NewItemObject.billQtyVarianceAcct = refgAccount;
                    }

                    if (objCatAccount.cust_ex_rate_account > 0)
                    {
                        RecordRef refgAccount = new RecordRef();
                        refgAccount.type       = RecordType.account;
                        refgAccount.internalId = objCatAccount.cust_ex_rate_account.ToString();
                        NewItemObject.billExchRateVarianceAcct = refgAccount;
                    }
                    if (objCatAccount.price_variance_account > 0)
                    {
                        RecordRef refgAccount = new RecordRef();
                        refgAccount.type       = RecordType.account;
                        refgAccount.internalId = objCatAccount.price_variance_account.ToString();
                        NewItemObject.billPriceVarianceAcct = refgAccount;
                    }

                    #endregion
                    RecordRef Tax_Schedule = new RecordRef();
                    Tax_Schedule.internalId   = objSetting.TaxSchedule_Netsuite_Id.ToString();
                    Tax_Schedule.type         = RecordType.salesTaxItem;
                    NewItemObject.taxSchedule = Tax_Schedule;
                    RecordRef[] subsidiarylst = new RecordRef[1];
                    RecordRef   subsidiary    = new RecordRef();
                    subsidiary.internalId        = Obj.Subsidiary_Id.ToString();
                    subsidiary.type              = RecordType.subsidiary;
                    subsidiarylst[0]             = subsidiary;
                    NewItemObject.subsidiaryList = subsidiarylst;

                    if (Obj.InActive)
                    {
                        NewItemObject.isInactive          = true;
                        NewItemObject.isInactiveSpecified = true;
                    }

                    ItemArr[i] = NewItemObject;
                }
            }
            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
            return(ItemArr);
        }
示例#34
0
        public override Int64 Set(string parametersArr)
        {
            try
            {
                new CustomDAO().Check_PaymentCash_Exist();
                List <Foodics.NetSuite.Shared.Model.Discount> Lst_Items = new GenericeDAO <Foodics.NetSuite.Shared.Model.Discount>().GetWhere(" InActive = 0 and (Netsuite_Id IS NULL or Netsuite_Id =0)");
                if (Lst_Items.Count <= 0)
                {
                    return(0);
                }
                com.netsuite.webservices.DiscountItem[] ItemArr = new com.netsuite.webservices.DiscountItem[Lst_Items.Count];
                for (int i = 0; i < Lst_Items.Count; i++)
                {
                    RecordRef[] subsidiarylst = new RecordRef[1];
                    Foodics.NetSuite.Shared.Model.Discount Obj           = Lst_Items[i];
                    com.netsuite.webservices.DiscountItem  NewItemObject = new com.netsuite.webservices.DiscountItem();
                    Setting objSetting = new GenericeDAO <Setting>().GetWhere("Subsidiary_Netsuite_Id=" + Obj.Subsidiary_Id).FirstOrDefault();
                    if (objSetting != null && objSetting.Netsuite_Id <= 0)
                    {
                        return(0);
                    }

                    NewItemObject.displayName = Obj.Name_En + " - " + objSetting.Name;
                    NewItemObject.itemId      = Obj.Name_En + " - " + objSetting.Name;

                    NewItemObject.rate = Obj.Amount.ToString();
                    if (Obj.IsPercentage)
                    {
                        NewItemObject.rate += "%";
                    }

                    RecordRef subsidiary = new RecordRef();
                    subsidiary.internalId        = Obj.Subsidiary_Id.ToString();
                    subsidiary.type              = RecordType.subsidiary;
                    subsidiarylst[0]             = subsidiary;
                    NewItemObject.subsidiaryList = subsidiarylst;

                    RecordRef Accountref = new RecordRef();
                    Accountref.internalId = objSetting.DiscountAccount_Netsuite_Id.ToString();
                    Accountref.type       = RecordType.account;
                    NewItemObject.account = Accountref;
                    if (Obj.InActive)
                    {
                        NewItemObject.isInactive          = true;
                        NewItemObject.isInactiveSpecified = true;
                    }
                    ItemArr[i] = NewItemObject;
                }
                WriteResponseList wr = Service(true).addList(ItemArr);
                bool result          = wr.status.isSuccess;
                if (result)
                {
                    UpdatedLst(Lst_Items, wr);
                }
            }
            catch (Exception ex)
            {
                LogDAO.Integration_Exception(LogIntegrationType.Error, this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Error " + ex.Message);
            }
            return(0);
        }
        /// <summary>
        /// create the nesuite record of file for the upload
        /// </summary>
        /// <param name="taskFile">task file</param>
        /// <returns>netsuite file record</returns>
        private static Record createRecord(TaskFile taskFile)
        {
            string path = taskFile.Path;
            if (!System.IO.File.Exists(path))
                throw new Exception("Error in Task: file does not exist [" + path + "]");

            string folderInternalId = taskFile.Folderid;
            NetsuiteUploader.com.netsuite.na1.webservices.File record = new NetsuiteUploader.com.netsuite.na1.webservices.File();
            record.name = System.IO.Path.GetFileName(path);
            record.content = System.IO.File.ReadAllBytes(path);
            record.isOnlineSpecified = record.isOnline = (taskFile.IsOnline != null) ? taskFile.IsOnline : false;
            record.bundleableSpecified = record.bundleable = (taskFile.Bundleable != null) ? taskFile.Bundleable : false;
            record.hideInBundleSpecified = record.hideInBundle = (taskFile.HideInBundle != null) ? taskFile.HideInBundle : false;
            record.isInactiveSpecified = record.isInactive = (taskFile.IsInactive != null) ? taskFile.IsInactive : false;
            record.isPrivateSpecified = record.isPrivate = (taskFile.IsPrivate != null) ? taskFile.IsPrivate : false;

            RecordRef recRef = new RecordRef();
            recRef.internalId = folderInternalId;
            record.folder = recRef;

            return record;
        }
 //Uses a sparse global array to store currency lookups in memory for speed
 string getCurrencySymbol(string theCurrencyID)
 {
     string symbol = "";
     for (int id = 0; id < Settings.Default.MC_CurrencySymbolsMax; id++)
     {
         if (_CurrencySymbols[id, 0] == theCurrencyID)
         {
             return _CurrencySymbols[id, 1];
         }
         else
         {
             if (_CurrencySymbols[id, 0] == null)
             {
                 RecordRef CurrencyRef = new RecordRef();
                 CurrencyRef.typeSpecified = true;
                 CurrencyRef.type = RecordType.currency;
                 CurrencyRef.internalId = theCurrencyID;
                 ReadResponse getSymbolResponse = _NSservice.get(CurrencyRef);
                 if (getSymbolResponse.status.isSuccess)
                 {
                     Currency theCurrency = (Currency)getSymbolResponse.record;
                     _CurrencySymbols[id, 0] = theCurrencyID;
                     _CurrencySymbols[id, 1] = theCurrency.symbol;
                     return theCurrency.symbol;
                 }
                 else
                 {
                     return "";
                 }
             }
         }
     }
     return symbol;
 }
示例#37
0
 public void setupNetSuiteObjects(NetSuiteService service)
 {
     Passport passport = new Passport();
     passport.account = "3524453";
     passport.email = "*****@*****.**";
     RecordRef role = new RecordRef();
     role.internalId = "3";
     passport.role = role;
     passport.password = "******"; //remember to replace
     Status loginStatus = service.login(passport).status;
 }
        public static void DeleteItemFullfitment()
        {
            string strItem = "";
            try
            {
                TransactionSearch xactionSearch = new TransactionSearch();
                //xactionSearch.basic
                //SearchMultiSelectField entity = new SearchMultiSelectField();
                //entity.@operator = SearchMultiSelectFieldOperator.anyOf;
                //entity.operatorSpecified = true;
                //RecordRef custRecordRef = new RecordRef();
                //custRecordRef.internalId = strCustomerId;
                //custRecordRef.type = RecordType.customer;
                //custRecordRef.typeSpecified = true;
                //RecordRef[] custRecordRefArray = new RecordRef[1];
                //custRecordRefArray[0] = custRecordRef;
                //entity.searchValue = custRecordRefArray;

                SearchEnumMultiSelectField searchSalesOrderField = new SearchEnumMultiSelectField();
                searchSalesOrderField.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
                searchSalesOrderField.operatorSpecified = true;
                System.String[] soStringArray = new System.String[1];
                soStringArray[0] = "_itemFulfillment";
                searchSalesOrderField.searchValue = soStringArray;

                TransactionSearchBasic xactionBasic = new TransactionSearchBasic();
                xactionBasic.type = searchSalesOrderField;
                xactionBasic.dateCreated = new SearchDateField();
                xactionBasic.dateCreated.@operator = SearchDateFieldOperator.within;
                xactionBasic.dateCreated.operatorSpecified = true;
                xactionBasic.dateCreated.searchValue = new DateTime(2011, 12, 30);
                xactionBasic.dateCreated.searchValueSpecified = true;
                xactionBasic.dateCreated.searchValue2 = new DateTime(2011, 12, 31);
                xactionBasic.dateCreated.searchValue2Specified = true;

                xactionSearch.basic = xactionBasic;

                SearchResult objSearchResult = _service.search(xactionSearch);
                if (objSearchResult.status != null && objSearchResult.status.isSuccess)
                {
                    if (objSearchResult.recordList != null)
                    {
                        Record[] recordList;
                        for (int i = 1; i <= objSearchResult.totalPages; i++)
                        {
                            recordList = objSearchResult.recordList;

                            for (int j = 0; j < recordList.Length; j++)
                            {
                                if (recordList[j] is ItemFulfillment)
                                {
                                    try
                                    {
                                        ItemFulfillment objOrder = (ItemFulfillment)(recordList[j]);
                                        object objCustomReseller = GetValue("custbodytbfcustomerid", objOrder.customFieldList);
                                        if (objCustomReseller != null && (objCustomReseller.ToString().Equals("CST100WA") || objCustomReseller.ToString().Equals("1")))
                                        {

                                            RecordRef objRef = new RecordRef();
                                            objRef.internalId = ((ItemFulfillment)recordList[j]).internalId;
                                            objRef.type = RecordType.itemFulfillment;
                                            objRef.typeSpecified = true;
                                            WriteResponse writeRes = _service.delete(objRef);
                                            if (writeRes.status.isSuccess)
                                            {
                                                Console.WriteLine("delete: " + objRef.internalId);
                                            }
                                            else
                                            {
                                                Console.WriteLine(getStatusDetails(writeRes.status));
                                            }
                                        }

                                    }
                                    catch (Exception objExc)
                                    {
                                        Console.WriteLine(objExc.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    strItem = "error";
                }
            }
            catch (Exception objExc)
            {
                Console.WriteLine(objExc.ToString());
            }
        }
        public static string AddSalesOrderMassive(RecordRef objCustomer, string strCategory, string strPoNumber, string strOrderNumber, DateTime datOrderDate,
    DateTime datInsertDate, DateTime datEventDate, bool booConfirmed, bool booCases, string strBride, string strGroom, ArrayList arrItems, string strUserId)
        {
            string strId = "";
            SalesOrder objSalesOrder = new SalesOrder();
            objSalesOrder.entity = objCustomer;
            objSalesOrder.tranDate = new System.DateTime();
            objSalesOrder.orderStatus = SalesOrderOrderStatus._pendingFulfillment;

            //objSalesOrder.salesRep = new RecordRef();
            //objSalesOrder.salesRep.internalId = strUserId;
            //objSalesOrder.salesRep.type = RecordType.employee;
            //objSalesOrder.salesRep.typeSpecified = true;

            SelectCustomFieldRef objReseller = new SelectCustomFieldRef();
            objReseller.internalId = "custbodytbfcustomerid";
            objReseller.value = new ListOrRecordRef();
            objReseller.value.internalId = "1";

            BooleanCustomFieldRef objCategory = new BooleanCustomFieldRef();
            objCategory.internalId = "custbodycst_ordercategory";
            objCategory.value = bool.Parse(strCategory);

            BooleanCustomFieldRef objConfirmed = new BooleanCustomFieldRef();
            objConfirmed.internalId = "custbodycst_orderconfirmed";
            objConfirmed.value = booConfirmed;

            BooleanCustomFieldRef objCases = new BooleanCustomFieldRef();
            objCases.internalId = "custbodycst_cases";
            objCases.value = booCases;

            StringCustomFieldRef objOrderNumber = new StringCustomFieldRef();
            objOrderNumber.internalId = "custbodycst_ordernumber";
            objOrderNumber.value = strOrderNumber;

            StringCustomFieldRef objPONumber = new StringCustomFieldRef();
            objPONumber.internalId = "custbodycostcoponumber";
            objPONumber.value = strPoNumber;

            StringCustomFieldRef objGroom = new StringCustomFieldRef();
            objGroom.internalId = "custbody_groom";
            objGroom.value = strGroom;

            StringCustomFieldRef objBride = new StringCustomFieldRef();
            objBride.internalId = "custbody_bride";
            objBride.value = strBride;

            DateCustomFieldRef objOrderDate = new DateCustomFieldRef();
            objOrderDate.internalId = "custbodycst_orderdate";
            objOrderDate.value = datOrderDate;

            DateCustomFieldRef objInsertDate = new DateCustomFieldRef();
            objInsertDate.internalId = "custbodycst_insertdate";
            objInsertDate.value = datInsertDate;

            DateCustomFieldRef objEventDate = new DateCustomFieldRef();
            objEventDate.internalId = "custbody_wedding_date";
            objEventDate.value = datEventDate;

            object[] arrFirstItem = (object[])arrItems[0];

            DateCustomFieldRef objDeliveryDate = new DateCustomFieldRef();
            objDeliveryDate.internalId = "custbody_delivery_date";
            objDeliveryDate.value = (DateTime)arrFirstItem[2];

            DateCustomFieldRef objShippingDate = new DateCustomFieldRef();
            objShippingDate.internalId = "custbody_shipping_date";
            objShippingDate.value = (DateTime)arrFirstItem[3];

            if (datEventDate != DateTime.MaxValue)
            {
                objSalesOrder.customFieldList = new CustomFieldRef[] { objReseller, objConfirmed, objCases, objCategory, objGroom, objBride, objOrderNumber, objPONumber, objOrderDate, objInsertDate, objEventDate, objDeliveryDate, objShippingDate };
            }
            else
            {
                objSalesOrder.customFieldList = new CustomFieldRef[] { objReseller, objConfirmed, objCases, objCategory, objGroom, objBride, objOrderNumber, objPONumber, objOrderDate, objInsertDate, objDeliveryDate, objShippingDate };
            }
            objSalesOrder.otherRefNum = strPoNumber;

            SalesOrderItem[] salesOrderItemArray = new SalesOrderItem[arrItems.Count];
            for (int i = 0; i < salesOrderItemArray.Length; i++)
            {
                object[] arrColumns = (object[])arrItems[i];

                RecordRef item = new RecordRef();
                item.type = RecordType.nonInventoryResaleItem;
                item.typeSpecified = true;
                item.internalId = arrColumns[0].ToString();

                salesOrderItemArray[i] = new SalesOrderItem();
                salesOrderItemArray[i].item = item;

                StringCustomFieldRef objCustomInfo = new StringCustomFieldRef();
                objCustomInfo.internalId = "custcol_additional_info";
                objCustomInfo.value = arrColumns[8].ToString();

                StringCustomFieldRef objOriginal = new StringCustomFieldRef();
                objOriginal.internalId = "custcolcst_originalid";
                objOriginal.value = arrColumns[9].ToString();

                LongCustomFieldRef objOrderLine = new LongCustomFieldRef();
                objOrderLine.internalId = "custcolcst_orderline";
                objOrderLine.value = (int)arrColumns[6];

                SelectCustomFieldRef objShippingType = new SelectCustomFieldRef();
                objShippingType.internalId = "custcolcst_shippingtype";
                objShippingType.value = new ListOrRecordRef();
                switch (arrColumns[7].ToString())
                {
                    case "IPD":
                        objShippingType.value.internalId = "1";
                        break;
                    case "IP":
                        objShippingType.value.internalId = "2";
                        break;
                    case "Domestic":
                        objShippingType.value.internalId = "3";
                        break;
                    case "Fedex Next Day":
                        objShippingType.value.internalId = "4";
                        break;
                }

                if ((DateTime)arrColumns[4] == DateTime.MaxValue)
                {
                    DateCustomFieldRef objDelivDate = new DateCustomFieldRef();
                    objDelivDate.internalId = "custcolcst_deliverydate";
                    objDelivDate.value = (DateTime)arrColumns[2];

                    DateCustomFieldRef objShipDate = new DateCustomFieldRef();
                    objShipDate.internalId = "custcolcst_shippingdate";
                    objShipDate.value = (DateTime)arrColumns[3];

                    salesOrderItemArray[i].customFieldList = new CustomFieldRef[] { objDelivDate, objShipDate, objOrderLine, objShippingType, objCustomInfo, objOriginal };
                }
                else
                {
                    DateCustomFieldRef objDelivDate = new DateCustomFieldRef();
                    objDelivDate.internalId = "custcolcst_deliverydate";
                    objDelivDate.value = (DateTime)arrColumns[2];

                    DateCustomFieldRef objShipDate = new DateCustomFieldRef();
                    objShipDate.internalId = "custcolcst_shippingdate";
                    objShipDate.value = (DateTime)arrColumns[3];

                    DateCustomFieldRef objPrefDate = new DateCustomFieldRef();
                    objPrefDate.internalId = "custcolcst_preferredarrivaldate";
                    objPrefDate.value = (DateTime)arrColumns[4];

                    salesOrderItemArray[i].customFieldList = new CustomFieldRef[] { objDelivDate, objShipDate, objPrefDate, objOrderLine, objShippingType, objCustomInfo, objOriginal };
                }

                System.Double quantity = System.Double.Parse(arrColumns[1].ToString());
                salesOrderItemArray[i].quantity = quantity;
                salesOrderItemArray[i].quantitySpecified = true;
            }

            SalesOrderItemList salesOrderItemList = new SalesOrderItemList();
            salesOrderItemList.item = salesOrderItemArray;

            objSalesOrder.itemList = salesOrderItemList;
            WriteResponse writeRes = _service.add(objSalesOrder);
            if (writeRes.status.isSuccess)
            {
                strId = ((RecordRef)writeRes.baseRef).internalId;
                //_out.writeLn("\nSales order created successfully\nSales Order Internal ID=" + ((RecordRef)writeRes.baseRef).internalId);
            }
            else
            {
                throw new Exception("Orden no ingresada: " + getStatusDetails(writeRes.status));
                //_out.error(getStatusDetails(writeRes.status));
            }
            return strId;
        }
        public static string AddSalesOrder1800(int numReseller, Customer objCustomer, string strVendorCode, string strPoNumber, string strOrderNumber, DateTime datOrderDate,
            DateTime datInsertDate, DateTime datEventDate, ArrayList arrItems, string strUserId, out string strError)
        {
            strError = "";
            string strId = "";
            SalesOrder objSalesOrder = new SalesOrder();
            objSalesOrder.entity = new RecordRef();
            objSalesOrder.entity.type = RecordType.customer;
            objSalesOrder.entity.typeSpecified = true;
            objSalesOrder.entity.externalId = objCustomer.externalId;
            objSalesOrder.tranDate = new System.DateTime();
            objSalesOrder.orderStatus = SalesOrderOrderStatus._pendingFulfillment;
            objSalesOrder.externalId = "so1800_"+strOrderNumber;

            objSalesOrder.customForm = new RecordRef();
            objSalesOrder.customForm.internalId = GlobalSettings.Default.nsOrderForm;
            objSalesOrder.customForm.type = RecordType.account;
            objSalesOrder.customForm.typeSpecified = true;

            //objSalesOrder.salesRep = new RecordRef();
            //objSalesOrder.salesRep.internalId = strUserId;
            //objSalesOrder.salesRep.type = RecordType.employee;
            //objSalesOrder.salesRep.typeSpecified = true;

            SelectCustomFieldRef objReseller = new SelectCustomFieldRef();
            objReseller.internalId = "custbodytbfcustomerid";
            objReseller.value = new ListOrRecordRef();
            objReseller.value.internalId = numReseller.ToString();

            StringCustomFieldRef objVendorCode = new StringCustomFieldRef();
            objVendorCode.internalId = "custbody_vfvendorcode";
            objVendorCode.value = strVendorCode;

            StringCustomFieldRef objOrderNumber = new StringCustomFieldRef();
            objOrderNumber.internalId = "custbodycst_ordernumber";
            objOrderNumber.value = strOrderNumber;

            StringCustomFieldRef objPONumber = new StringCustomFieldRef();
            objPONumber.internalId = "custbodycostcoponumber";
            objPONumber.value = strPoNumber;

            DateCustomFieldRef objOrderDate = new DateCustomFieldRef();
            objOrderDate.internalId = "custbodycst_orderdate";
            objOrderDate.value = datOrderDate;

            DateCustomFieldRef objInsertDate = new DateCustomFieldRef();
            objInsertDate.internalId = "custbodycst_insertdate";
            objInsertDate.value = datInsertDate;

            //DateCustomFieldRef objEventDate = new DateCustomFieldRef();
            //objEventDate.internalId = "custbody_wedding_date";
            //objEventDate.value = datEventDate;

            object[] arrFirstItem = (object[])arrItems[0];

            DateCustomFieldRef objDeliveryDate = new DateCustomFieldRef();
            objDeliveryDate.internalId = "custbody_delivery_date";
            objDeliveryDate.value = (DateTime)arrFirstItem[3];

            DateCustomFieldRef objShippingDate = new DateCustomFieldRef();
            objShippingDate.internalId = "custbody_shipping_date";
            objShippingDate.value = (DateTime)arrFirstItem[2];

            StringCustomFieldRef objMessage = new StringCustomFieldRef();
            objMessage.internalId = "custbodycst_giftmessage";
            objMessage.value = "";

            if (objDeliveryDate.value != DateTime.MaxValue)
            {
                objSalesOrder.customFieldList = new CustomFieldRef[] { objReseller, objOrderNumber, objPONumber, objOrderDate, objInsertDate, objMessage, objVendorCode };
            }
            else
            {
                objSalesOrder.customFieldList = new CustomFieldRef[] { objReseller, objOrderNumber, objPONumber, objOrderDate, objInsertDate, objMessage, objVendorCode };
            }
            objSalesOrder.otherRefNum = strPoNumber;

            //arrItems.Add(new object[] { strProductId, numQty, strShipDate, strDeliDate, arrItems.IndexOf(strShipType) });

            SalesOrderItem[] salesOrderItemArray = new SalesOrderItem[arrItems.Count];
            for (int i = 0; i < salesOrderItemArray.Length; i++)
            {
                object[] arrColumns = (object[])arrItems[i];

                RecordRef item = new RecordRef();
                item.type = RecordType.nonInventoryResaleItem;
                item.typeSpecified = true;
                item.internalId = arrColumns[0].ToString();

                salesOrderItemArray[i] = new SalesOrderItem();
                salesOrderItemArray[i].item = item;

                SelectCustomFieldRef objShippingType = new SelectCustomFieldRef();
                objShippingType.internalId = "custcolcst_shippingtype";
                objShippingType.value = new ListOrRecordRef();
                objShippingType.value.internalId = arrColumns[4].ToString();
                if (objShippingType.value.internalId.Equals("-1"))
                {
                    objShippingType.value.internalId = "7";
                }

                SelectCustomFieldRef objShippingCourier = new SelectCustomFieldRef();
                objShippingCourier.internalId = "custcolcst_courier";
                objShippingCourier.value = new ListOrRecordRef();
                objShippingCourier.value.internalId = "1";
                if (objShippingType.value.internalId.Equals("8") || objShippingType.value.internalId.Equals("9"))
                {
                    objShippingCourier.value.internalId = "2";
                }
                if (objShippingType.value.internalId.Equals("5") || objShippingType.value.internalId.Equals("6") || objShippingType.value.internalId.Equals("7"))
                {
                    objShippingCourier.value.internalId = "3";
                }

                DateCustomFieldRef objShipDate = new DateCustomFieldRef();
                objShipDate.internalId = "custcolcst_shippingdate";
                objShipDate.value = (DateTime)arrColumns[2];

                DateCustomFieldRef objDelivDate = new DateCustomFieldRef();
                objDelivDate.internalId = "custcolcst_deliverydate";
                objDelivDate.value = (DateTime)arrColumns[3];

                StringCustomFieldRef objPo = new StringCustomFieldRef();
                objPo.internalId = "custcolos_ponumber";
                objPo.value = arrColumns[5].ToString();

                StringCustomFieldRef objColMessage = new StringCustomFieldRef();
                objColMessage.internalId = "custcolcst_message";
                objColMessage.value = "";

                if (arrColumns.Length == 7)
                {
                    objColMessage.value = arrColumns[6].ToString();
                    objMessage.value = arrColumns[6].ToString();
                }

                if (objDelivDate.value != DateTime.MaxValue)
                {
                    salesOrderItemArray[i].customFieldList = new CustomFieldRef[] { objDelivDate, objShipDate, objShippingType, objPo, objShippingCourier, objColMessage };
                }
                else
                {
                    salesOrderItemArray[i].customFieldList = new CustomFieldRef[] { objShipDate, objShippingType, objPo, objShippingCourier, objColMessage };
                }

                System.Double quantity = System.Double.Parse(arrColumns[1].ToString());
                salesOrderItemArray[i].quantity = quantity;
                salesOrderItemArray[i].quantitySpecified = true;
            }

            SalesOrderItemList salesOrderItemList = new SalesOrderItemList();
            salesOrderItemList.item = salesOrderItemArray;

            objSalesOrder.itemList = salesOrderItemList;
            //WriteResponse writeRes = _service.add(objSalesOrder);
            WriteResponse[] writeRes = _service.addList(new Record[] { objCustomer, objSalesOrder });
            if (writeRes[0].status.isSuccess)
            {
                strId = ((RecordRef)writeRes[0].baseRef).internalId;
                //_out.writeLn("\nSales order created successfully\nSales Order Internal ID=" + ((RecordRef)writeRes.baseRef).internalId);
            }
            else
            {
                strError = getStatusDetails(writeRes[0].status);
            }
            if (writeRes[1].status.isSuccess)
            {
                strId = ((RecordRef)writeRes[1].baseRef).internalId;
                //_out.writeLn("\nSales order created successfully\nSales Order Internal ID=" + ((RecordRef)writeRes.baseRef).internalId);
            }
            else
            {
                strError = getStatusDetails(writeRes[1].status);
            }
            return strId;
        }
 private static SalesOrder GetSalesOrder(string strOrderId)
 {
     SalesOrder objOrder = new SalesOrder();
     try
     {
         RecordRef objRef = new RecordRef();
         objRef.internalId = strOrderId;
         objRef.type = RecordType.salesOrder;
         objRef.typeSpecified = true;
         ReadResponse objReadResponse = _service.get(objRef);
         objOrder = (SalesOrder)(objReadResponse.record);
     }
     catch (Exception)
     {
     }
     return objOrder;
 }
        public static RecordRef UpdateCustomer(string strInternalId, string strSalesRep, string strParent, string strFirstName, string strLastName, string strEmail,
            string strBillTo, string strBillPhone, string strBillAddress1, string strBillAddress2, string strBillAddress3, string strBillCity, string strBillState, string strBillZip,
            string strShipTo, string strShipPhone, string strShipAddress1, string strShipAddress2, string strShipAddress3, string strShipCity, string strShipState, string strShipZip,
            out string strError)
        {
            strError = "";
            RecordRef objRecordRef = null;
            RecordRef objTemp = new RecordRef();
            objTemp.internalId = strInternalId;
            objTemp.type = RecordType.customer;
            objTemp.typeSpecified = true;

            ReadResponse objReadResponse = _service.get(objTemp);

            string strInternalId1 = "";
            string strInternalId2 = "";

            if (objReadResponse.status.isSuccess)
            {
                Customer objCustomerTemp = (Customer)objReadResponse.record;
                CustomerAddressbookList temp = objCustomerTemp.addressbookList;

                if (objCustomerTemp.addressbookList.addressbook != null && objCustomerTemp.addressbookList.addressbook.Length > 1)
                {
                    foreach (CustomerAddressbook objAddress in objCustomerTemp.addressbookList.addressbook)
                    {
                        strInternalId1 = objCustomerTemp.addressbookList.addressbook[0].internalId;
                        strInternalId2 = objCustomerTemp.addressbookList.addressbook[1].internalId;
                    }
                }
            }
            Customer objCustomer = new Customer();
            objCustomer.internalId = strInternalId;
            objCustomer.parent = new RecordRef();
            //objCustomer.parent.internalId = strParent;
            //objCustomer.parent.type = RecordType.customer;
            //objCustomer.parent.typeSpecified = true;
            objCustomer.taxable = false;
            objCustomer.taxableSpecified = true;

            objCustomer.salesRep = new RecordRef();
            objCustomer.salesRep.internalId = strSalesRep;
            objCustomer.salesRep.type = RecordType.employee;
            objCustomer.salesRep.typeSpecified = true;

            //objCustomer.customForm = new RecordRef();
            //objCustomer.customForm.internalId = "12";
            //objCustomer.customForm.type = RecordType.account;
            //objCustomer.customForm.typeSpecified = true;

            //objCustomer.terms = new RecordRef();
            //objCustomer.terms.internalId = "2";
            //objCustomer.terms.type = RecordType.account;
            //objCustomer.terms.typeSpecified = true;

            objCustomer.taxable = false;
            objCustomer.taxableSpecified = true;

            objCustomer.salesRep = new RecordRef();
            objCustomer.salesRep.internalId = strSalesRep;
            objCustomer.salesRep.type = RecordType.employee;
            objCustomer.salesRep.typeSpecified = true;

            objCustomer.defaultAddress = "";
            objCustomer.addressbookList = new CustomerAddressbookList();
            objCustomer.addressbookList.replaceAll = true;
            objCustomer.addressbookList.addressbook = new CustomerAddressbook[2];
            objCustomer.addressbookList.addressbook[0] = new CustomerAddressbook();
            objCustomer.addressbookList.addressbook[0].internalId = strInternalId1;
            objCustomer.addressbookList.addressbook[0].@override = true;
            objCustomer.addressbookList.addressbook[0].overrideSpecified = true;
            objCustomer.addressbookList.addressbook[0].defaultBilling = true;
            objCustomer.addressbookList.addressbook[0].defaultBillingSpecified = true;
            objCustomer.addressbookList.addressbook[0].defaultShipping = false;
            objCustomer.addressbookList.addressbook[0].defaultShippingSpecified = true;
            objCustomer.addressbookList.addressbook[0].isResidential = false;
            objCustomer.addressbookList.addressbook[0].isResidentialSpecified = true;
            objCustomer.addressbookList.addressbook[0].addr1 = strBillAddress1;
            objCustomer.addressbookList.addressbook[0].addr2 = strBillAddress2;
            objCustomer.addressbookList.addressbook[0].addr3 = strBillAddress3;
            objCustomer.addressbookList.addressbook[0].city = strBillCity;
            objCustomer.addressbookList.addressbook[0].zip = strBillZip;
            objCustomer.addressbookList.addressbook[0].state = strBillState;
            objCustomer.addressbookList.addressbook[0].phone = strBillPhone;
            objCustomer.addressbookList.addressbook[0].attention = strBillTo;
            objCustomer.addressbookList.addressbook[0].label = strBillTo;
            objCustomer.addressbookList.addressbook[0].country = Country._unitedStates;
            objCustomer.addressbookList.addressbook[0].addressee = strBillTo + "\n" + strBillAddress1 + "\n" + strBillAddress2 + "\n" + strBillAddress3 + "\n" + strBillCity + " " + strBillState + " " + strBillZip + "\nUS\n" + strBillPhone;
            objCustomer.addressbookList.addressbook[0].addrText = strBillTo + "\n" + strBillAddress1 + "\n" + strBillAddress2 + "\n" + strBillAddress3 + "\n" + strBillCity + " " + strBillState + " " + strBillZip + "\nUS\n" + strBillPhone;

            if (objCustomer.addressbookList.addressbook[0].addressee.Length > 100)
            {
                objCustomer.addressbookList.addressbook[0].addressee = strBillTo + "\n" + strBillAddress1 + "\n" + strBillAddress2 + "\n" + strBillCity + " " + strBillState + " " + strBillZip + "\nUS";
                while (objCustomer.addressbookList.addressbook[0].addressee.Length > 100)
                {
                    objCustomer.addressbookList.addressbook[0].addressee = objCustomer.addressbookList.addressbook[0].addressee.Substring(1);
                }
            }

            if (objCustomer.addressbookList.addressbook[0].addrText.Length > 100)
            {
                objCustomer.addressbookList.addressbook[0].addrText = strBillTo + "\n" + strBillAddress1 + "\n" + strBillAddress2 + "\n" + strBillCity + " " + strBillState + " " + strBillZip + "\nUS";
                while (objCustomer.addressbookList.addressbook[0].addrText.Length > 100)
                {
                    objCustomer.addressbookList.addressbook[0].addrText = objCustomer.addressbookList.addressbook[0].addrText.Substring(1);
                }
            }

            objCustomer.addressbookList.addressbook[1] = new CustomerAddressbook();
            objCustomer.addressbookList.addressbook[1].internalId = strInternalId2;
            objCustomer.addressbookList.addressbook[1].@override = true;
            objCustomer.addressbookList.addressbook[1].overrideSpecified = true;
            objCustomer.addressbookList.addressbook[1].defaultBilling = false;
            objCustomer.addressbookList.addressbook[1].defaultBillingSpecified = true;
            objCustomer.addressbookList.addressbook[1].defaultShipping = true;
            objCustomer.addressbookList.addressbook[1].defaultShippingSpecified = true;
            objCustomer.addressbookList.addressbook[1].isResidential = false;
            objCustomer.addressbookList.addressbook[1].isResidentialSpecified = true;
            objCustomer.addressbookList.addressbook[1].addr1 = strShipAddress1;
            objCustomer.addressbookList.addressbook[1].addr2 = strShipAddress2;
            objCustomer.addressbookList.addressbook[1].addr3 = strShipAddress3;
            objCustomer.addressbookList.addressbook[1].city = strShipCity;
            objCustomer.addressbookList.addressbook[1].state = strShipState;
            objCustomer.addressbookList.addressbook[1].zip = strShipZip;
            objCustomer.addressbookList.addressbook[1].attention = strShipTo;
            objCustomer.addressbookList.addressbook[1].label = strShipTo;
            objCustomer.addressbookList.addressbook[1].phone = strShipPhone;
            objCustomer.addressbookList.addressbook[1].country = Country._unitedStates;
            objCustomer.addressbookList.addressbook[1].addressee = strShipTo + "\n" + strShipAddress1 + "\n" + strShipAddress2 + "\n" + strShipAddress3 + "\n" + strShipCity + " " + strShipState + " " + strShipZip + "\nUS \n" + strShipPhone;
            objCustomer.addressbookList.addressbook[1].addrText = strShipTo + "\n" + strShipAddress1 + "\n" + strShipAddress2 + "\n" + strShipAddress3 + "\n" + strShipCity + " " + strShipState + " " + strShipZip + "\nUS \n" + strShipPhone;

            if (objCustomer.addressbookList.addressbook[1].addressee.Length > 100)
            {
                objCustomer.addressbookList.addressbook[1].addressee = strShipTo + "\n" + strShipAddress1 + "\n" + strShipAddress2 + "\n" + strShipCity + " " + strShipState + " " + strShipZip + "\nUS";
                while (objCustomer.addressbookList.addressbook[1].addressee.Length > 100)
                {
                    objCustomer.addressbookList.addressbook[1].addressee = objCustomer.addressbookList.addressbook[1].addressee.Substring(1);
                }
            }

            if (objCustomer.addressbookList.addressbook[1].addrText.Length > 100)
            {
                objCustomer.addressbookList.addressbook[1].addrText = strShipTo + "\n" + strShipAddress1 + "\n" + strShipAddress2 + "\n" + strShipCity + " " + strShipState + " " + strShipZip + "\nUS";
                while (objCustomer.addressbookList.addressbook[1].addrText.Length > 100)
                {
                    objCustomer.addressbookList.addressbook[1].addrText = objCustomer.addressbookList.addressbook[1].addrText.Substring(1);
                }
            }

            WriteResponse objResponse = _service.update(objCustomer);
            if (objResponse.status.isSuccess)
            {
                objRecordRef = (RecordRef)objResponse.baseRef;
            }
            else
            {
                strError = objResponse.status.statusDetail[0].message;
            }
            return objRecordRef;
        }
        public static string Login(string strUser, string strPassword, string strAccount, string strRole)
        {
            string strResult = null;
            try
            {
                Passport passport = new Passport();
                RecordRef role = new RecordRef();
                passport.email = strUser;
                passport.password = strPassword;
                role.internalId = strRole;
                passport.role = role;
                passport.account = strAccount;

                _service = new NetSuiteService();
                _service.Timeout = 1000 * 60 * 60 * 2;
                _service.passport = passport;
                SessionResponse objResponse = _service.login(passport);
                if (!objResponse.status.isSuccess)
                {
                    strResult = objResponse.status.statusDetail[0].message;
                }
                Console.WriteLine(_service.Url);
            }
            catch (Exception objExc)
            {
                strResult = objExc.Message;
            }
            return strResult;
        }
        public static void DeleteSalesOrder()
        {
            string strItem = "";
            try
            {
                TransactionSearch xactionSearch = new TransactionSearch();
                //xactionSearch.basic
                //SearchMultiSelectField entity = new SearchMultiSelectField();
                //entity.@operator = SearchMultiSelectFieldOperator.anyOf;
                //entity.operatorSpecified = true;
                //RecordRef custRecordRef = new RecordRef();
                //custRecordRef.internalId = strCustomerId;
                //custRecordRef.type = RecordType.customer;
                //custRecordRef.typeSpecified = true;
                //RecordRef[] custRecordRefArray = new RecordRef[1];
                //custRecordRefArray[0] = custRecordRef;
                //entity.searchValue = custRecordRefArray;

                SearchEnumMultiSelectField searchSalesOrderField = new SearchEnumMultiSelectField();
                searchSalesOrderField.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
                searchSalesOrderField.operatorSpecified = true;
                System.String[] soStringArray = new System.String[1];
                soStringArray[0] = "_salesOrder";
                searchSalesOrderField.searchValue = soStringArray;

                TransactionSearchBasic xactionBasic = new TransactionSearchBasic();
                xactionBasic.type = searchSalesOrderField;
                xactionBasic.customFieldList = new SearchCustomField[1];

                SearchStringCustomField objNumber = new SearchStringCustomField();
                objNumber.internalId = "custbodycst_ordernumber";
                objNumber.@operator = SearchStringFieldOperator.notEmpty;
                objNumber.operatorSpecified = true;
                xactionBasic.customFieldList[0] = objNumber;
                xactionSearch.basic = xactionBasic;

                SearchResult objSearchResult = _service.search(xactionSearch);
                if (objSearchResult.status != null && objSearchResult.status.isSuccess)
                {
                    if (objSearchResult.recordList != null)
                    {
                        Record[] recordList;
                        for (int i = 1; i <= objSearchResult.totalPages; i++)
                        {
                            recordList = objSearchResult.recordList;

                            for (int j = 0; j < recordList.Length; j++)
                            {
                                if (recordList[j] is SalesOrder)
                                {
                                    try
                                    {
                                        SalesOrder objOrder = GetSalesOrder(((SalesOrder)(recordList[j])).internalId);
                                        object objCustomReseller = GetValue("custbodytbfcustomerid", objOrder.customFieldList);
                                        if (objCustomReseller.ToString().Equals("CST100WA"))
                                        {
                                            RecordRef objRef = new RecordRef();
                                            objRef.internalId = objOrder.internalId;
                                            objRef.type = RecordType.salesOrder;
                                            objRef.typeSpecified = true;
                                            WriteResponse writeRes = _service.delete(objRef);
                                            if (writeRes.status.isSuccess)
                                            {
                                                Console.WriteLine("delete: " + objOrder.tranId);
                                            }
                                            else
                                            {
                                                Console.WriteLine(getStatusDetails(writeRes.status));
                                            }

                                        }
                                    }
                                    catch (Exception objExc)
                                    {
                                        Console.WriteLine(objExc.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    strItem = "error";
                }
            }
            catch (Exception)
            {
            }
        }
示例#45
0
        public void savedSearch(NetSuiteService service, string searchID)
        {
            CustomRecordSearchAdvanced csa = new CustomRecordSearchAdvanced();
            csa.savedSearchId = searchID;

            SearchResult SR = service.search(csa);

            if (SR.status.isSuccess)
            {
                SearchRow[] searchRows = SR.searchRowList;

                for (int i = 0; i < searchRows.Length; i++)
                {
                    CustomRecordSearchRow crsr = (CustomRecordSearchRow)searchRows[i];
                    ArrayList customFieldList = new ArrayList(crsr.basic.customFieldList);
                    String strRecNumberPrefix = "Record " + i.ToString() + ": ";

                    for (int j = 0; j < customFieldList.Count; j++)
                    {
                        MessageBox.Show("Field Type for element " + j + ": " + customFieldList[j].GetType().Name);
                        switch (customFieldList[j].GetType().Name)
                        {
                            case "SearchColumnSelectCustomField":
                                SearchColumnSelectCustomField scselectcf = (SearchColumnSelectCustomField)customFieldList[j];
                                if (scselectcf.internalId == "custrecord_currency")
                                {
                                    ListOrRecordRef lorrCurrency = (ListOrRecordRef)scselectcf.searchValue;
                                    RecordRef rrCurrency = new RecordRef();
                                    rrCurrency.internalId = lorrCurrency.internalId;
                                    rrCurrency.type = RecordType.currency;
                                    txtSearchResults.Text = txtSearchResults.Text + strRecNumberPrefix + rrCurrency.name + Environment.NewLine;
                                }
                                else if (scselectcf.internalId == "custrecord_subsidiary")
                                {
                                    ListOrRecordRef lorrSubsidiary = (ListOrRecordRef)scselectcf.searchValue;
                                    RecordRef rrSubsidiary = new RecordRef();
                                    rrSubsidiary.internalId = lorrSubsidiary.internalId;
                                    rrSubsidiary.type = RecordType.subsidiary;
                                    txtSearchResults.Text = txtSearchResults.Text + strRecNumberPrefix + rrSubsidiary.name + Environment.NewLine;
                                }
                                break;
                            case "SearchColumnStringCustomField":
                                SearchColumnStringCustomField scstringcf = (SearchColumnStringCustomField)customFieldList[j];
                                if (scstringcf.internalId == "custrecord_jdecountry")
                                {
                                    txtSearchResults.Text = txtSearchResults.Text + strRecNumberPrefix + scstringcf.searchValue + Environment.NewLine;
                                }
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            else
            {
                txtSearchResults.Text = "Failure";
            }
        }
 public void setupNetSuiteObjects(NetSuiteService service)
 {
     try //Using a session test - if it fails then login ...
     {
         GetServerTimeResult testResult = service.getServerTime();
     }
     catch
     {
         AppendTextBoxLine(txtSearchResults, "Logging in ...", true);
         Passport passport = new Passport();
         passport.account = Settings.Default.NS_AccountID;
         passport.email = Settings.Default.NS_UserEmail;
         RecordRef role = new RecordRef();
         role.internalId = Settings.Default.NS_Role;
         passport.role = role;
         passport.password = Settings.Default.NS_Password;
         Status loginStatus = service.login(passport).status;
         if (loginStatus.isSuccess)
         {
             AppendTextBoxLine(txtSearchResults, "Logged in OK : " + passport.account + " : " + passport.email, true);
         }
         else
         {
             AppendTextBoxLine(txtSearchResults, "Login Error : " + loginStatus.statusDetail[0].message, true);
         }
     }
 }
 public static Record GetEntity(string strEntityId, RecordType objType)
 {
     Record objRecord = null;
     try
     {
         RecordRef objRef = new RecordRef();
         objRef.internalId = strEntityId;
         objRef.type = objType;
         objRef.typeSpecified = true;
         ReadResponse objReadResponse = _service.get(objRef);
         objRecord = objReadResponse.record;
     }
     catch (Exception objExc)
     {
     }
     return objRecord;
 }
        public override void Get()
        {
            /// <summary> This method get all items (with types we need in POS) from netsuite and check item type,
            /// after that get all item info and save in DB.</summary>
            ///

            string IntrnelID = GetCustomizationId("customrecord_da_foodics_settings");



            CustomRecordSearch      customRecordSearch      = new CustomRecordSearch();
            CustomRecordSearchBasic customRecordSearchBasic = new CustomRecordSearchBasic();
            RecordRef recordRef = new RecordRef();

            recordRef.internalId            = IntrnelID;
            recordRef.type                  = RecordType.customTransaction;
            customRecordSearchBasic.recType = recordRef;
            customRecordSearch.basic        = customRecordSearchBasic;
            SearchResult response = Service(true).search(customRecordSearch);

            if (response.status.isSuccess)
            {
                if (response.totalRecords > 0)
                {
                    CustomRecord              item_Custom;
                    CustomFieldRef[]          flds;
                    List <Setting.integerate> lstsetting = new List <Setting.integerate>();
                    for (int i = 0; i < response.recordList.Length; i++)
                    {
                        item_Custom = (CustomRecord)response.recordList[i];
                        flds        = item_Custom.customFieldList;

                        Setting.integerate settingObj = new Setting.integerate();
                        settingObj.Netsuite_Id = Utility.ConvertToInt(item_Custom.internalId);

                        for (int c = 0; c < flds.Length; c++)
                        {
                            if (flds[c].scriptId == "custrecord_da_foodics_tax_rate")
                            {
                                settingObj.TaxRate = Utility.ConvertToInt(((com.netsuite.webservices.DoubleCustomFieldRef)flds[c]).value.ToString());
                            }
                            if (flds[c].scriptId == "custrecord_da_foodics_currency")
                            {
                                settingObj.Currency_Netsuite_Id = Utility.ConvertToInt(((com.netsuite.webservices.SelectCustomFieldRef)flds[c]).value.internalId.ToString());
                            }
                            if (flds[c].scriptId == "custrecord_da_foodics_subsidiary")
                            {
                                settingObj.Subsidiary_Netsuite_Id = Utility.ConvertToInt(((com.netsuite.webservices.SelectCustomFieldRef)flds[c]).value.internalId.ToString());
                            }
                            if (flds[c].scriptId == "custrecord_da_tax_code")
                            {
                                settingObj.TaxCode_Netsuite_Id = Utility.ConvertToInt(((com.netsuite.webservices.SelectCustomFieldRef)flds[c]).value.internalId.ToString());
                            }
                            if (flds[c].scriptId == "custrecord_da_foodics_default_customer")
                            {
                                settingObj.Customer_Netsuite_Id = Utility.ConvertToInt(((com.netsuite.webservices.SelectCustomFieldRef)flds[c]).value.internalId.ToString());
                            }
                        }
                        lstsetting.Add(settingObj);
                    }


                    new GenericeDAO <Setting.integerate>().BaseNetSuiteIntegration(lstsetting, "Setting");
                }
            }
        }
        public static RecordRef GetCustomer(string strParent, string strPhone)
        {
            RecordRef objCustomer = null;
            CustomerSearch custSearch = new CustomerSearch();
            SearchStringField customerPhone = new SearchStringField();
            customerPhone.@operator = SearchStringFieldOperator.@is;
            customerPhone.operatorSpecified = true;
            customerPhone.searchValue = strPhone;

            CustomerSearchBasic custBasic = new CustomerSearchBasic();
            custBasic.phone = customerPhone;
            custBasic.parent = new SearchMultiSelectField();
            custBasic.parent.@operator = SearchMultiSelectFieldOperator.anyOf;
            custBasic.parent.operatorSpecified = true;
            custBasic.parent.searchValue = new RecordRef[1];
            custBasic.parent.searchValue[0] = new RecordRef();
            custBasic.parent.searchValue[0].internalId = strParent;
            custBasic.parent.searchValue[0].type = RecordType.customer;
            custBasic.parent.searchValue[0].typeSpecified = true;

            custSearch.basic = custBasic;

            SearchResult res = _service.search(custSearch);
            if (res.status.isSuccess)
            {
                if (res.recordList != null && res.recordList.Length == 1)
                {
                    objCustomer = new RecordRef();
                    objCustomer.type = RecordType.customer;
                    objCustomer.typeSpecified = true;
                    System.String entID = ((Customer)(res.recordList[0])).entityId;
                    objCustomer.name = entID;
                    objCustomer.internalId = ((Customer)(res.recordList[0])).internalId;
                }
            }

            return objCustomer;
        }
        private static void LoadTable()
        {
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            Hashtable htCustomers = new Hashtable();
            Hashtable htProducts = new Hashtable();
            Hashtable htOrders = new Hashtable();
            Util.Login(GlobalSettings.Default.nsUser, GlobalSettings.Default.nsPassword, GlobalSettings.Default.nsAccount, GlobalSettings.Default.nsRole);

            int numUserIndex = 0;
            ArrayList arrUsers = Util.GetUsers(GlobalSettings.Default.nsSalesRoleId);
            if (arrUsers.Count == 0)
            {
                string[] arrTemp = GlobalSettings.Default.nsSalesRep.Split(new string[] { "," }, StringSplitOptions.None);
                foreach (string strTemp in arrTemp)
                {
                    Employee objEmp = new Employee();
                    objEmp.internalId = strTemp;
                    arrUsers.Add(objEmp);
                }
                //ShowError("SalesReps haven't been found. Role ID: " + GlobalSettings.Default.nsSalesRoleId);
                //return;
            }

            int numIndex = 0;
            ArrayList arrItems = new ArrayList();
            string strRef = "PO";
            bool booIsByPO = true;
            string strDateFormat = "yyyy-MM-dd";
            if (arrAcum.Contains(dsTable.TableName))
            {
                strDateFormat = "GLyyyy-MM-dd";
                strRef = "Ship Date";
                booIsByPO = false;
            }

            Customer objReseller = new Customer();
            int numLineId = 1;
            int numTotal = 0;
            SalesOrder objSalesOrder = new SalesOrder();
            foreach (DataRow objRow in dsTable.Rows)
            {
                string strEmployeeId = ((Employee)arrUsers[numUserIndex]).internalId;
                string strPoNumber = "";
                string strPoAux = "";
                bool booAdd = false;
                try
                {
                    objForm.IncrementProcess();
                    strPoNumber = objRow[strRef].ToString();
                    strPoAux = objRow["PO"].ToString();
                    if (objRow[strRef] is DateTime)
                    {
                        strPoNumber = ((DateTime)objRow[strRef]).ToString(strDateFormat);
                    }
                    if (!htOrders.ContainsKey(strPoNumber))
                    {
                        string strCustomer = objRow["Customer"].ToString();
                        string strId = Util.GetOrderId(strPoNumber, (arrReseller.IndexOf(strCustomer) + 1).ToString());
                        if (string.IsNullOrEmpty(strId))
                        {
                            if (!htCustomers.ContainsKey(strCustomer))
                            {
                                objReseller = Util.GetCustomer(strCustomer);
                                if (objReseller == null || objReseller.internalId == null)
                                {
                                    throw new Exception("Customer hasn't been found. Reseller ID: " + strCustomer);
                                }
                                else
                                {
                                    htCustomers.Add(strCustomer, objReseller.internalId);
                                }
                            }

                            string strBillTo = "";
                            string strBillPhone = "";
                            string strBillAddress1 = "";
                            string strBillAddress2 = "";
                            string strBillAddress3 = "";
                            string strBillCity = "";
                            string strBillState = "";
                            string strBillZip = "";
                            foreach (CustomerAddressbook objAddress in objReseller.addressbookList.addressbook)
                            {
                                if (objAddress.defaultBilling)
                                {
                                    strBillTo = "ttt";// objAddress.attention;
                                    strBillPhone = objAddress.phone;
                                    strBillAddress1 = objAddress.addr1;
                                    strBillAddress2 = objAddress.addr2;
                                    strBillAddress3 = objAddress.addr3;
                                    strBillCity = objAddress.city;
                                    strBillState = objAddress.state;
                                    strBillZip = objAddress.zip;
                                }
                            }

                            string strCustomerId = htCustomers[strCustomer].ToString();

                            string strProduct = objRow["SKU"].ToString();
                            if (string.IsNullOrEmpty(strProduct))
                            {
                                throw new Exception("Product is empty.");
                            }
                            string strProductId = "";
                            if (!htProducts.ContainsKey(strProduct))
                            {
                                ArrayList arrProducts = Util.GetItemId(strProduct);
                                if (arrProducts.Count == 0)
                                {

                                    throw new Exception("Product hasn't been found. Product: " + strProduct);
                                }
                                else if (arrProducts.Count == 1)
                                {
                                    strProductId = ((string[])arrProducts[0])[0];
                                    htProducts.Add(strProduct, strProductId);
                                }
                                else
                                {
                                    Form2 objForm2 = new Form2(arrProducts);
                                    System.Windows.Forms.DialogResult objResult = objForm2.ShowDialog(objForm);
                                    while (objResult != System.Windows.Forms.DialogResult.OK)
                                    {
                                        objForm2.ShowDialog(objForm);
                                    }
                                    if (objResult == System.Windows.Forms.DialogResult.OK)
                                    {
                                        strProductId = objForm2.ItemId;
                                    }
                                }
                            }
                            else
                            {
                                strProductId = htProducts[strProduct].ToString();
                            }

                            string strShipToName = objRow["ShipToName"].ToString();
                            string strShipPhone = objRow["ShipToPhone"].ToString();

                            string strShipAddress1 = objRow["ShipToAddress1"].ToString();
                            string strShipAddress2 = objRow["ShipToAddress2"].ToString();
                            string strShipCity = objRow["ShipToCity"].ToString();
                            string strShipZipCode = objRow["ShipToZipCode"].ToString();
                            string strShipState = objRow["ShipToState"].ToString();
                            string strShipEmail = objRow["ShipToEmail"].ToString();
                            string strShipType = objRow["Transport1"].ToString().Trim();
                            string strCourierType = objRow["Transport2"].ToString().Trim();

                            RecordRef objSubCustomer = new RecordRef();
                            objSubCustomer.internalId = objReseller.internalId;
                            objSubCustomer.type = RecordType.customer;
                            objSubCustomer.typeSpecified = true;

                            if (!string.IsNullOrEmpty(strShipToName))
                            {
                                string strFirstName = "";
                                string strLastName = "";

                                string[] arrNames = strShipToName.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                                if (arrNames.Length == 1 || arrNames.Length != 0)
                                {
                                    arrNames = arrNames[0].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                                    if (arrNames.Length > 1)
                                    {
                                        strFirstName = arrNames[0];
                                        strLastName = arrNames[1];
                                    }
                                    else
                                    {
                                        strFirstName = strShipToName;
                                    }
                                }
                                else
                                {
                                    strFirstName = strShipToName;
                                }
                                try
                                {
                                    string strError = "";
                                    //objSubCustomer = Util.GetCustomer(strCustomerId, strShipPhone);
                                    objSubCustomer = null;

                                    if (string.IsNullOrEmpty(strBillTo))
                                    {
                                        throw new Exception("Billing information missed!");
                                    }

                                    if (objSubCustomer == null || objSubCustomer.internalId == null)
                                    {
                                        objSubCustomer = Util.AddCustomer(strCustomerId, strEmployeeId, strFirstName, strLastName, strShipEmail,
                                            strBillTo, strBillPhone, strBillAddress1, strBillAddress2, strBillAddress3, strBillCity, strBillState, strBillZip,
                                            strShipToName, strShipPhone, strShipAddress1, strShipAddress2, "", strShipCity, strShipState, strShipZipCode,
                                            out strError);
                                    }
                                    else
                                    {
                                        objSubCustomer = Util.UpdateCustomer(objSubCustomer.internalId, strEmployeeId, strCustomerId, strFirstName, strLastName, strShipEmail,
                                            strBillTo, strBillPhone, strBillAddress1, strBillAddress2, strBillAddress3, strBillCity, strBillState, strBillZip,
                                            strShipToName, strShipPhone, strShipAddress1, strShipAddress2, "", strShipCity, strShipState, strShipZipCode,
                                            out strError);
                                    }

                                    if (!string.IsNullOrEmpty(strError))
                                    {
                                        throw new Exception(strError);
                                    }
                                    strCustomerId = objSubCustomer.internalId;
                                }
                                catch (Exception objExc)
                                {
                                    throw new Exception("Subcustomer hasn't created or updated (" + strShipToName + "): " + objExc.Message);
                                }
                            }

                            DateTime strShipDate = DateTime.Parse(objRow["Ship Date"].ToString());
                            DateTime strDeliDate = strShipDate;
                            try
                            {
                                strDeliDate = DateTime.Parse(objRow["DeliveryDate"].ToString());
                            }
                            catch (Exception)
                            {
                            }
                            DateTime strInvoiceDate = strDeliDate;
                            try
                            {
                                strInvoiceDate = DateTime.Parse(objRow["InvoiceDate"].ToString());
                            }
                            catch (Exception)
                            {
                            }
                            DateTime objOrderDate = DateTime.Now;
                            try
                            {
                                objOrderDate = DateTime.Parse(objRow["F1"].ToString());
                            }
                            catch (Exception)
                            {
                            }

                            double numQty = double.Parse(objRow["Q"].ToString());

                            if (!string.IsNullOrEmpty(strCustomer) && !string.IsNullOrEmpty(strProduct) && !string.IsNullOrEmpty(strPoNumber))
                            {
                                if (booIsByPO)
                                {
                                    for (int i = 0; i < numQty; i++)
                                    {
                                        arrItems.Add(new object[] { strProductId, 1, strShipDate, strDeliDate, arrShipType.IndexOf(strShipType) + 1, objRow["PO"].ToString(), objRow["ORDERMESSAGETEXT"].ToString(), arrCourierType.IndexOf(strCourierType) + 1 });
                                    }
                                }
                                else
                                {
                                    arrItems.Add(new object[] { strProductId, numQty, strShipDate, strDeliDate, arrShipType.IndexOf(strShipType) + 1, objRow["PO"].ToString(), objRow["ORDERMESSAGETEXT"].ToString(), arrCourierType.IndexOf(strCourierType) + 1 });
                                }
                                string strNextRef = "";
                                if (numIndex + 1 < dsTable.Rows.Count)
                                {
                                    strNextRef = dsTable.Rows[numIndex + 1][strRef].ToString();
                                    if (dsTable.Rows[numIndex + 1][strRef] is DateTime)
                                    {
                                        strNextRef = ((DateTime)dsTable.Rows[numIndex + 1][strRef]).ToString(strDateFormat);
                                    }
                                }
                                if (numIndex + 1 >= dsTable.Rows.Count || !strNextRef.Equals(strPoNumber))
                                {
                                    // Insert order
                                    string strError = "";
                                    string strClase = "";
                                    strId = Util.AddSalesOrder(arrReseller.IndexOf(strCustomer) + 1, objSubCustomer, strPoNumber, strPoNumber, objOrderDate, DateTime.Now, objOrderDate, arrItems, strEmployeeId, strInvoiceDate, strClase, out strError);
                                    if (!string.IsNullOrEmpty(strId))
                                    {
                                        LastProcessResult = ProcessResult.Ok2;
                                        strMessage = strId;
                                        numUserIndex++;
                                        numUserIndex = (numUserIndex) % arrUsers.Count;
                                        if (!htOrders.ContainsKey(strPoNumber))
                                        {
                                            htOrders.Add(strPoNumber, strId);
                                        }
                                    }
                                    else
                                    {
                                        LastProcessResult = ProcessResult.Error;
                                        strMessage = strError;
                                    }
                                    arrItems.Clear();
                                }
                                else
                                {
                                    LastProcessResult = ProcessResult.Ok1;
                                    strMessage = "Linea agregada: " + strProduct;
                                }
                            }
                            else
                            {
                                LastProcessResult = ProcessResult.Error;
                                strMessage = "Información incompleta en SKU";
                            }
                        }
                        else
                        {
                            //objSalesOrder = (SalesOrder)Util.GetEntity(strId, RecordType.salesOrder);
                            //if (!htOrders.ContainsKey(strPoNumber))
                            //{
                            //    htOrders.Add(strPoNumber, strId);
                            //}
                            //strMessage = "Registro ya procesado: " + strId;
                            //LastProcessResult = ProcessResult.Processed;
                            objSalesOrder = (SalesOrder)Util.GetEntity(strId, RecordType.salesOrder);
                            numTotal = objSalesOrder.itemList.item.Length;
                            if (GlobalSettings.Default.AddLines.Equals("Yes"))
                            {
                                numTotal = 0;
                            }
                            if (!htOrders.ContainsKey(strPoNumber))
                            {
                                htOrders.Add(strPoNumber, strId);
                            }
                            booAdd = true;
                        }
                    }
                    else
                    {
                        booAdd = true;
                    }

                    if(booAdd)
                    {
                        if (htOrders[strPoNumber].Equals("error"))
                        {
                            LastProcessResult = ProcessResult.Error;
                            strMessage = "Linea omitida por error en linea anteriores a la orden";
                        }
                        else
                        {
                            // Depende del archivo de configuración si es True AddLines numTotal es 0
                            if (numTotal < 1)
                            {
                                //Adicional
                                string strProduct = objRow["SKU"].ToString();
                                if (string.IsNullOrEmpty(strProduct))
                                {
                                    throw new Exception("Product is empty.");
                                }
                                string strProductId = "";
                                if (!htProducts.ContainsKey(strProduct))
                                {
                                    ArrayList arrProducts = Util.GetItemId(strProduct);
                                    if (arrProducts.Count == 0)
                                    {
                                        throw new Exception("Product hasn't been found. Product: " + strProduct);
                                    }
                                    else if (arrProducts.Count == 1)
                                    {
                                        strProductId = ((string[])arrProducts[0])[0];
                                        htProducts.Add(strProduct, strProductId);
                                    }
                                    else
                                    {
                                        Form2 objForm2 = new Form2(arrProducts);
                                        System.Windows.Forms.DialogResult objResult = objForm2.ShowDialog(objForm);
                                        while (objResult != System.Windows.Forms.DialogResult.OK)
                                        {
                                            objForm2.ShowDialog(objForm);
                                        }
                                        if (objResult == System.Windows.Forms.DialogResult.OK)
                                        {
                                            strProductId = objForm2.ItemId;
                                        }
                                    }
                                }
                                else
                                {
                                    strProductId = htProducts[strProduct].ToString();
                                }

                                DateTime strShipDate = DateTime.Parse(objRow["Ship Date"].ToString());
                                DateTime strDeliDate = strShipDate;
                                try
                                {
                                    strDeliDate = DateTime.Parse(objRow["DeliveryDate"].ToString());
                                }
                                catch (Exception)
                                {
                                }
                                DateTime objOrderDate = DateTime.Now;
                                try
                                {
                                    objOrderDate = DateTime.Parse(objRow["F1"].ToString());
                                }
                                catch (Exception)
                                {
                                }
                                double numQty = double.Parse(objRow["Q"].ToString());
                                string strShipType = objRow["Transport1"].ToString().Trim();
                                string strCourierType = objRow["Transport2"].ToString().Trim();

                                if (booIsByPO)
                                {
                                    for (int i = 0; i < numQty; i++)
                                    {
                                        arrItems.Add(new object[] { strProductId, 1, strShipDate, strDeliDate, arrShipType.IndexOf(strShipType) + 1, objRow["PO"].ToString(), arrCourierType.IndexOf(strCourierType) + 1  });
                                    }
                                }
                                else
                                {
                                    arrItems.Add(new object[] { strProductId, numQty, strShipDate, strDeliDate, arrShipType.IndexOf(strShipType) + 1, objRow["PO"].ToString(), arrCourierType.IndexOf(strCourierType) + 1 });
                                }

                                string strNextRef = "";
                                if (numIndex + 1 < dsTable.Rows.Count)
                                {
                                    strNextRef = dsTable.Rows[numIndex + 1][strRef].ToString();
                                    if (dsTable.Rows[numIndex + 1][strRef] is DateTime)
                                    {
                                        strNextRef = ((DateTime)dsTable.Rows[numIndex + 1][strRef]).ToString(strDateFormat);
                                    }
                                }
                                if (numIndex + 1 >= dsTable.Rows.Count || !strNextRef.Equals(strPoNumber))
                                {
                                    // Insert order
                                    string strError = "";
                                    string strId = objSalesOrder.internalId;
                                    Util.UpdateSalesOrder(objSalesOrder, arrItems, out strError);
                                    if (!string.IsNullOrEmpty(strId))
                                    {
                                        LastProcessResult = ProcessResult.Added;
                                        strMessage = "Linea adicionada para la orden: " + strPoNumber;
                                        numUserIndex++;
                                        numUserIndex = (numUserIndex) % arrUsers.Count;
                                        if (!htOrders.ContainsKey(strPoNumber))
                                        {
                                            htOrders.Add(strPoNumber, strId);
                                        }
                                    }
                                    else
                                    {
                                        LastProcessResult = ProcessResult.Error;
                                        strMessage = strError;
                                    }
                                    arrItems.Clear();
                                }
                                else
                                {
                                    LastProcessResult = ProcessResult.Ok1;
                                    strMessage = "Linea agregada en la orden: " + strPoNumber;
                                }
                            }
                            else
                            {
                                strMessage = "Registro ya procesado: " + htOrders[strPoNumber];
                                LastProcessResult = ProcessResult.Processed;
                            }
                        }
                    }
                }
                catch (Exception objExc)
                {
                    arrItems.Clear();
                    if (!htOrders.ContainsKey(strPoNumber))
                    {
                        htOrders.Add(strPoNumber, "error");
                    }
                    else
                    {
                        htOrders[strPoNumber] = "error";
                    }
                    LastProcessResult = ProcessResult.Error;
                    strMessage = objExc.Message;
                    //ShowError(objExc.Message);
                }

                string strRefAux = "";
                if (numIndex + 1 < dsTable.Rows.Count)
                {
                    strRefAux = dsTable.Rows[numIndex + 1][strRef].ToString();
                    if (dsTable.Rows[numIndex + 1][strRef] is DateTime)
                    {
                        strRefAux = ((DateTime)dsTable.Rows[numIndex + 1][strRef]).ToString(strDateFormat);
                    }
                }
                if (numIndex + 1 >= dsTable.Rows.Count || !strRefAux.Equals(strPoNumber))
                {
                    numLineId = 0;
                }
                numIndex++;
                numLineId++;
            }

            objForm.IncrementProcess();
            RUN = false;
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
        }
        public override Int64 Set(string parametersArr)
        {
            try
            {
                //Set Values of Netsuite Customer ID
                //  LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask", "Start");

                //new GenericeDAO<Foodics.NetSuite.Shared.Model.Invoice.Integrate>().GetAndUpdateCustomerIDandCreditMemo();
                //get recentrly added invoices after creating the return
                List <Foodics.NetSuite.Shared.Model.Invoice> invoiceLst = new GenericeDAO <Foodics.NetSuite.Shared.Model.Invoice>().GetWhere(" Netsuite_Id IS NULL or Netsuite_Id =0");
                Setting objSetting = new GenericeDAO <Setting>().GetAll().FirstOrDefault();
                // = new NetsuiteDAO().SelectInvoicesForIntegration();
                //  LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask", "Count: " + invoiceLst.Count.ToString());
                bool result = true;
                if (invoiceLst.Count > 0)
                {
                    #region variables
                    Invoice[] InvoiceArr = new Invoice[invoiceLst.Count];

                    List <Foodics.NetSuite.Shared.Model.InvoiceItem> itemLst;
                    List <Foodics.NetSuite.Shared.Model.GiftCertificate.Integrate> giftCertificateLst;
                    //List<Foodics.NetSuite.Shared.Model.ItemLotSerial.Sales> lotSerialLst;

                    Foodics.NetSuite.Shared.Model.Invoice     invoice_info;
                    Foodics.NetSuite.Shared.Model.InvoiceItem itemDetails;

                    GiftCertRedemption[] giftRedeem;
                    InvoiceItem[]        invoiceItems;

                    DateTime                invoice_date;
                    Invoice                 invoiceObject;
                    InvoiceItem             invoiceItemObject;
                    InvoiceItemList         items;
                    InventoryAssignmentList InventoryAssignmentlst;
                    InventoryAssignment[]   assignList;
                    InventoryAssignment     assign;
                    InventoryDetail         invDetails;

                    GiftCertRedemptionList redemptionLst;

                    DateCustomFieldRef   trans_time;
                    ListOrRecordRef      emirate_region, custSelectValue, custSelectCashier;
                    SelectCustomFieldRef emirate_ref = null, terminal, cashier;
                    RecordRef            authCodeRef, taxCode, item, unit, price, itmSerial, discItem,
                                         subsid, currency, entity, location, classification, department;
                    DoubleCustomFieldRef line_total, line_discount_amount, balance, paid, lineDiscount;
                    StringCustomFieldRef trans_no, pos_id, orderDiscount;

                    CustomFieldRef[] customFieldRefArr, customFieldRefArray;

                    int item_custom_cols = 2;
                    #endregion

                    for (int i = 0; i < invoiceLst.Count; i++)
                    {
                        try
                        {
                            invoice_info = invoiceLst[i];
                            //Netsuite invoice type
                            invoiceObject = new Invoice();

                            //get invoice items
                            itemLst = new GenericeDAO <Foodics.NetSuite.Shared.Model.InvoiceItem>().GetWhere("Invoice_Id =" + invoice_info.Id);//new NetsuiteDAO().SelectInvoicItems(invoice_info.Id);

                            //get invoice gift certificates
                            #region gift certificate redemption
                            //try
                            //{
                            //    giftCertificateLst = new NetsuiteDAO().SelectEntityGiftCertificates(invoice_info.Id, 1);
                            //    if (giftCertificateLst.Count > 0)
                            //    {
                            //        redemptionLst = new GiftCertRedemptionList();
                            //        giftRedeem = new GiftCertRedemption[giftCertificateLst.Count];
                            //        for (int r = 0; r < giftCertificateLst.Count; r++)
                            //        {
                            //            GiftCertRedemption gift = new GiftCertRedemption();
                            //            authCodeRef = new RecordRef();
                            //            authCodeRef.internalId = giftCertificateLst[r].Netsuite_Id.ToString();
                            //            authCodeRef.type = RecordType.giftCertificate;
                            //            gift.authCode = authCodeRef;
                            //            gift.authCodeAppliedSpecified = true;
                            //            gift.authCodeApplied = Convert.ToDouble(giftCertificateLst[r].Amount);
                            //            giftRedeem[r] = gift;
                            //        }

                            //        redemptionLst.giftCertRedemption = giftRedeem;
                            //        invoiceObject.giftCertRedemptionList = redemptionLst;
                            //    }
                            //}
                            //catch (Exception ex)
                            //{
                            //    //LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding GiftCertificates: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString());
                            //}
                            #endregion

                            #region invoice items

                            //Define Invoice Items List
                            invoiceItems = new InvoiceItem[itemLst.Count];
                            try
                            {
                                item_custom_cols = 2;
                                for (int k = 0; k < itemLst.Count; k++)
                                {
                                    itemDetails       = itemLst[k];
                                    invoiceItemObject = new InvoiceItem();

                                    // TAX
                                    //invoiceItemObject.taxRate1Specified = true;
                                    //invoiceItemObject.taxRate1 = itemDetails.Tax_Rate;
                                    //invoiceItemObject.taxAmount = itemDetails.Tax_Amt;

                                    // tax code
                                    taxCode                   = new RecordRef();
                                    taxCode.internalId        = objSetting.TaxCode_Netsuite_Id.ToString(); //"15";//itemDetails.Tax_Code.ToString();
                                    taxCode.type              = RecordType.taxAcct;
                                    invoiceItemObject.taxCode = taxCode;

                                    // item
                                    item            = new RecordRef();
                                    item.internalId = itemDetails.Item_Id.ToString();
                                    item.type       = (RecordType)Enum.Parse(typeof(RecordType), itemDetails.Item_Type, true);
                                    //item.type = (RecordType)Enum.Parse(typeof(RecordType), "InventoryItem", true);
                                    invoiceItemObject.item = item;

                                    if (Utility.ConvertToInt(itemDetails.Units) > 0)
                                    {
                                        unit                    = new RecordRef();
                                        unit.internalId         = itemDetails.Units.ToString();
                                        unit.type               = RecordType.unitsType;
                                        invoiceItemObject.units = unit;
                                    }

                                    // price level
                                    #region price level
                                    price      = new RecordRef();
                                    price.type = RecordType.priceLevel;

                                    if (itemDetails.Amount > 0)
                                    {
                                        //if (itemDetails.Customer_Price_Level > 0)
                                        //{
                                        //    // customer price level
                                        //    price.internalId = itemDetails.Customer_Price_Level.ToString();
                                        //    invoiceItemObject.price = price;
                                        //}
                                        //else if (itemDetails.Price_Level_Id > 0)
                                        //{
                                        //    // default price level
                                        //    price.internalId = itemDetails.Price_Level_Id.ToString();
                                        //    invoiceItemObject.price = price;
                                        //}
                                        //else
                                        //{
                                        // amount
                                        invoiceItemObject.amountSpecified = true;
                                        invoiceItemObject.amount          = itemDetails.Amount;
                                        //}
                                    }

                                    #endregion

                                    // invoiceItemObject.costEstimateType = (ItemCostEstimateType)itemDetails.Cost_Estimate_Type;


                                    //if (itemDetails.Item_Type == "GiftCertificateItem")
                                    //{
                                    //    #region sell gift certificate
                                    //    try
                                    //    {
                                    //        invoiceItemObject.giftCertNumber = itemDetails.Gift_Code;
                                    //        invoiceItemObject.giftCertFrom = itemDetails.Sender;
                                    //        invoiceItemObject.giftCertMessage = itemDetails.Gift_Message;
                                    //        invoiceItemObject.giftCertRecipientName = itemDetails.Recipient_Name;
                                    //        invoiceItemObject.giftCertRecipientEmail = itemDetails.Recipient_Email;
                                    //    }
                                    //    catch { }
                                    //    #endregion
                                    //}
                                    //else
                                    //{
                                    // quantity
                                    invoiceItemObject.quantitySpecified = true;
                                    invoiceItemObject.quantity          = itemDetails.Quantity;

                                    #region serials/Lot
                                    //if (Utility.ItemTypeSerialized.Contains(itemDetails.Item_Type))
                                    //{
                                    //    lotSerialLst = new NetsuiteDAO().SelectInvoiceLotSerials(itemDetails.Id);
                                    //    InventoryAssignmentlst = new InventoryAssignmentList();
                                    //    assignList = new InventoryAssignment[lotSerialLst.Count];

                                    //    for (int z = 0; z < lotSerialLst.Count; z++)
                                    //    {
                                    //        assign = new InventoryAssignment();

                                    //        itmSerial = new RecordRef();
                                    //        itmSerial.internalId = lotSerialLst[z].Netsuite_Id.ToString();
                                    //        itmSerial.type = RecordType.lotNumberedInventoryItem;
                                    //        itmSerial.typeSpecified = true;

                                    //        if (Utility.ItemTypeLot.Contains(itemDetails.Item_Type))
                                    //        {
                                    //            assign.quantitySpecified = true;
                                    //            assign.quantity = lotSerialLst[z].Quantity;
                                    //        }
                                    //        assign.issueInventoryNumber = itmSerial;

                                    //        assignList[z] = assign;
                                    //    }

                                    //    InventoryAssignmentlst.inventoryAssignment = assignList;
                                    //    invDetails = new InventoryDetail();
                                    //    invDetails.inventoryAssignmentList = InventoryAssignmentlst;

                                    //    invoiceItemObject.inventoryDetail = invDetails;
                                    //}

                                    #endregion
                                    //  }

                                    #region custom fields

                                    try
                                    {
                                        #region line-item discount

                                        //line_total = new DoubleCustomFieldRef();
                                        //line_total.scriptId = "custcol_da_pos_line_item_total";
                                        //line_total.value = Math.Round(itemDetails.Total_Line_Amount, 3);

                                        //line_discount_amount = new DoubleCustomFieldRef();
                                        //line_discount_amount.scriptId = "custcol_da_pos_line_item_discount";
                                        //line_discount_amount.value = Math.Round(itemDetails.Line_Discount_Amount, 3);

                                        // line-item amount
                                        invoiceItemObject.amount = (itemDetails.Quantity * itemDetails.Amount);

                                        #endregion

                                        #region Transaction Region (Emirate)
                                        //item_custom_cols = 2;
                                        //if (invoice_info.Transaction_Region > 0)
                                        //{
                                        //    item_custom_cols = 3;
                                        //    emirate_region = new ListOrRecordRef();
                                        //    emirate_region.internalId = invoice_info.Transaction_Region.ToString();

                                        //    emirate_ref = new SelectCustomFieldRef();
                                        //    emirate_ref.scriptId = "custcol_emirate";
                                        //    emirate_ref.value = emirate_region;
                                        //}
                                        #endregion

                                        //customFieldRefArr = new CustomFieldRef[item_custom_cols];
                                        //customFieldRefArr[0] = line_total;
                                        //customFieldRefArr[1] = line_discount_amount;

                                        //if (item_custom_cols == 3)
                                        //    customFieldRefArr[2] = emirate_ref;

                                        //invoiceItemObject.customFieldList = customFieldRefArr;
                                    }
                                    catch (Exception ex)
                                    {
                                        //  LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding customField: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString());
                                    }
                                    #endregion

                                    invoiceItems[k] = invoiceItemObject;
                                }
                            }
                            catch (Exception ex)
                            {
                                //  LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding invoice: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString());
                            }
                            //Assign invoive items
                            items                  = new InvoiceItemList();
                            items.item             = invoiceItems;
                            invoiceObject.itemList = items;

                            //GiftCertRedemption
                            #endregion

                            #region Invoice Values

                            #region Standard Attributes
                            invoice_date = TimeZoneInfo.ConvertTimeToUtc(invoice_info.Date, TimeZoneInfo.Local);

                            invoiceObject.tranDateSpecified = true;
                            invoiceObject.dueDateSpecified  = true;
                            invoiceObject.tranDate          = invoice_date;
                            invoiceObject.dueDate           = invoice_date;
                            invoiceObject.exchangeRate      = invoice_info.Exchange_Rate;

                            invoiceObject.memo = invoice_info.Notes;

                            if (invoice_info.Subsidiary_Id > 0)
                            {
                                subsid                   = new RecordRef();
                                subsid.internalId        = objSetting.Subsidiary_Netsuite_Id.ToString();
                                subsid.type              = RecordType.subsidiary;
                                invoiceObject.subsidiary = subsid;
                            }

                            //RecordRef customForm = new RecordRef();
                            //customForm.internalId = "92";
                            //invoiceObject.customForm = customForm;

                            currency               = new RecordRef();
                            currency.internalId    = objSetting.Currency_Netsuite_Id.ToString();
                            currency.type          = RecordType.currency;
                            invoiceObject.currency = currency;

                            entity = new RecordRef();

                            entity.internalId    = invoice_info.Customer_Netsuite_Id > 0? invoice_info.Customer_Netsuite_Id.ToString(): objSetting.Customer_Netsuite_Id.ToString();
                            entity.type          = RecordType.customer;
                            invoiceObject.entity = entity;

                            location               = new RecordRef();
                            location.internalId    = invoice_info.Location_Id.ToString(); //objSetting.Location_Netsuite_Id.ToString();
                            location.type          = RecordType.location;
                            invoiceObject.location = location;

                            // department
                            //if (invoice_info.Department_Id > 0)
                            //{
                            //    department = new RecordRef();
                            //    department.internalId = invoice_info.Department_Id.ToString();
                            //    department.type = RecordType.department;
                            //    invoiceObject.department = department;
                            //}

                            //// class
                            //if (invoice_info.Class_Id > 0)
                            //{
                            //    classification = new RecordRef();
                            //    classification.internalId = invoice_info.Class_Id.ToString();
                            //    classification.type = RecordType.classification;
                            //    invoiceObject.@class = classification;
                            //}
                            // sales rep
                            if (invoice_info.Sales_Rep_Id > 0)
                            {
                                RecordRef sales_rep = new RecordRef();
                                sales_rep.internalId   = invoice_info.Sales_Rep_Id.ToString();
                                sales_rep.type         = RecordType.employee;
                                invoiceObject.salesRep = sales_rep;
                            }
                            #endregion

                            #region Invoice Custom Attributes

                            trans_no          = new StringCustomFieldRef();
                            trans_no.scriptId = "custbody_da_pos_trans_no";
                            trans_no.value    = invoice_info.BarCode.ToString();

                            pos_id          = new StringCustomFieldRef();
                            pos_id.scriptId = "custbody_da_pos_id";
                            pos_id.value    = invoice_info.Id.ToString();

                            custSelectValue = new ListOrRecordRef();

                            terminal = new SelectCustomFieldRef();
                            custSelectValue.internalId = invoice_info.Terminal_Id.ToString();
                            terminal.scriptId          = "custbody_da_terminal";
                            terminal.value             = custSelectValue;

                            custSelectCashier = new ListOrRecordRef();

                            cashier = new SelectCustomFieldRef();
                            custSelectCashier.internalId = invoice_info.Cashier.ToString();
                            cashier.scriptId             = "custbody_da_cashier";
                            cashier.value = custSelectCashier;

                            balance          = new DoubleCustomFieldRef();
                            balance.scriptId = "custbody_da_balance";
                            balance.value    = Math.Round(invoice_info.Balance, 3);


                            paid          = new DoubleCustomFieldRef();
                            paid.scriptId = "custbody_da_paid";
                            paid.value    = Math.Round(invoice_info.Paid, 3);

                            trans_time          = new DateCustomFieldRef();
                            trans_time.scriptId = "custbody_da_pos_trans_time";
                            trans_time.value    = invoice_date;

                            #region Discount

                            invoiceObject.discountRate = (Math.Round(invoice_info.Total_Discount, 3) * -1).ToString();

                            lineDiscount          = new DoubleCustomFieldRef();
                            lineDiscount.scriptId = "custbody_da_pos_line_item_discount";
                            lineDiscount.value    = Math.Round(invoice_info.Line_Discount_Amount, 3) * -1;


                            orderDiscount          = new StringCustomFieldRef();
                            orderDiscount.scriptId = "custbody_da_pos_order_discount";
                            orderDiscount.value    = (Math.Round(invoice_info.Invoice_Discount_Rate, 3) * -1).ToString();
                            if (invoice_info.Invoice_Discount_Type == 1)
                            {
                                orderDiscount.value = (Math.Round(invoice_info.Invoice_Discount_Rate, 3) * -1).ToString() + "%";
                            }

                            if (invoice_info.Accounting_Discount_Item != 0)
                            {
                                discItem                   = new RecordRef();
                                discItem.internalId        = invoice_info.Accounting_Discount_Item.ToString();
                                discItem.type              = RecordType.discountItem;
                                invoiceObject.discountItem = discItem;
                            }
                            #endregion

                            int length = 7;
                            if (invoice_info.Terminal_Id > 0)
                            {
                                length = 8;
                            }

                            customFieldRefArray    = new CustomFieldRef[length];
                            customFieldRefArray[0] = cashier;
                            customFieldRefArray[1] = balance;
                            customFieldRefArray[2] = paid;
                            customFieldRefArray[3] = trans_time;
                            customFieldRefArray[4] = trans_no;
                            customFieldRefArray[5] = lineDiscount;
                            customFieldRefArray[6] = orderDiscount;

                            if (invoice_info.Terminal_Id > 0)
                            {
                                customFieldRefArray[7] = terminal;
                            }

                            invoiceObject.customFieldList = customFieldRefArray;
                            #endregion

                            InvoiceArr[i] = invoiceObject;
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            invoiceLst.RemoveAt(i);
                            //  LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask", "Error adding invoice: " + ex.Message + " Invoice id = " + invoiceLst[i].Id.ToString());
                        }
                    }
                    // Send invoice list to netsuite
                    WriteResponseList wr = Service(true).addList(InvoiceArr);
                    result = wr.status.isSuccess;

                    // LogDAO.Integration_Exception(LogIntegrationType.Info, TaskRunType.POST, "InvoiceTask", "Status: " + result);
                    if (result)
                    {
                        //Update database with returned Netsuite ids
                        UpdatedInvoice(invoiceLst, wr);
                    }
                }

                // post customerPayment to netsuite
                //  bool postPayments = PostCustomerPayment();
            }
            catch (Exception ex)
            {
                //  LogDAO.Integration_Exception(LogIntegrationType.Error, TaskRunType.POST, "InvoiceTask Error", "Error " + ex.Message);
            }

            // release the the object
            //new ScheduleTaskDAO().Processing(taskType, TaskRunType.POST, false);

            return(0);
        }
示例#52
0
        public void DeleteBin(InventoryBin bin)
        {
            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            BinSearch binSearch = new BinSearch();
            BinSearchBasic bSBasic = new BinSearchBasic();
            SearchStringField binName = new SearchStringField();
            binName.searchValue = bin.BinNumber;
            binName.@operator = SearchStringFieldOperator.@is;
            binName.operatorSpecified = true;
            bSBasic.binNumber = binName;
            binSearch.basic = bSBasic;

            SearchResult sr = new SearchResult();
            sr = service.search(binSearch);
            if (sr.status.isSuccess != true) Console.WriteLine(sr.status.statusDetail[0].message);

            RecordRef binToDelete = new RecordRef();
            binToDelete.type = RecordType.bin;
            binToDelete.typeSpecified = true;
            binToDelete.name = bin.BinNumber;
            binToDelete.internalId = ((Bin)sr.recordList[0]).internalId;

            WriteResponse writeResponse = service.delete(binToDelete);
            if (writeResponse.status.isSuccess == true)
            {
                Console.WriteLine("Bin: " + binToDelete.name + " has been deleted.");
            }
            if (writeResponse.status.isSuccess == false)
            {
                Console.WriteLine(writeResponse.status.statusDetail[0].message);

            }
        }
        public static Customer GetCustomer(string strCustomerName)
        {
            RecordRef reseller = new RecordRef();
            Customer objCustomer = new Customer();
            try
            {
                CustomerSearch custSearch = new CustomerSearch();
                custSearch.basic = new CustomerSearchBasic();
                custSearch.basic.entityId = new SearchStringField();
                custSearch.basic.entityId.@operator = SearchStringFieldOperator.@is;
                custSearch.basic.entityId.operatorSpecified = true;
                custSearch.basic.entityId.searchValue = strCustomerName;

                SearchResult res = _service.search(custSearch);
                if (res.status.isSuccess)
                {
                    if (res.recordList != null && res.recordList.Length == 1)
                    {
                        reseller.type = RecordType.customer;
                        reseller.typeSpecified = true;
                        System.String entID = ((Customer)(res.recordList[0])).entityId;
                        reseller.name = entID;
                        reseller.internalId = ((Customer)(res.recordList[0])).internalId;

                        ReadResponse objReadResponse = _service.get(reseller);
                        if (objReadResponse.status.isSuccess)
                        {
                            objCustomer = (Customer)objReadResponse.record;
                        }
                    }
                }
            }
            catch (Exception objExc)
            {
            }

            return objCustomer;
        }
示例#54
0
 public List<Record> GetRecords(Objects.Version version, out List<Record> baseList, out List<Alteration> alterations)
 {
     System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
     sw.Start();
     Printer.PrintDiagnostics("Getting records for version {0}.", version.ID);
     long? snapshotID = null;
     List<Objects.Version> parents = new List<Objects.Version>();
     Objects.Version snapshotVersion = version;
     while (!snapshotID.HasValue)
     {
         parents.Add(snapshotVersion);
         if (snapshotVersion.Snapshot.HasValue)
             snapshotID = snapshotVersion.Snapshot;
         else
         {
             if (!snapshotVersion.Parent.HasValue)
                 break;
             snapshotVersion = Get<Objects.Version>(snapshotVersion.Parent);
         }
     }
     if (!snapshotID.HasValue)
     {
         Printer.PrintDiagnostics(" - No snapshot.");
         baseList = new List<Record>();
     }
     else
     {
         Printer.PrintDiagnostics(" - Last snapshot version: {0}", snapshotVersion.ID);
         var sslist = Query<RecordRef>("SELECT * FROM RecordRef WHERE RecordRef.SnapshotID = ?", snapshotID.Value).Select(x => x.RecordID).ToList();
         CacheRecords(sslist);
         baseList = sslist.Select(x => GetCachedRecord(x)).ToList();
         Printer.PrintDiagnostics(" - Snapshot {0} has {1} records.", snapshotID, baseList.Count);
     }
     alterations = GetAlterationsInternal(parents);
     Printer.PrintDiagnostics(" - Target has {0} alterations.", alterations.Count);
     List<Record> finalList = null;
     try
     {
         finalList = Consolidate(baseList, alterations, null);
     }
     catch
     {
         Printer.PrintError("Error during database operation. Deleting cached snapshots.");
         BeginExclusive(true);
         RunConsistencyCheck();
         Commit();
         Printer.PrintError("Please retry this operation.");
         throw;
     }
     Printer.PrintDiagnostics("Record list resolved in {0} ticks.", sw.ElapsedTicks);
     if (baseList.Count < alterations.Count || (alterations.Count > 4096 && parents.Count > 128))
     {
         Printer.PrintDiagnostics(" - Attempting to build new snapshot ({0} records in base list, {1} alterations over {2} revisions)", baseList.Count, alterations.Count, parents.Count);
         try
         {
             BeginTransaction();
             Objects.Snapshot snapshot = new Snapshot();
             this.InsertSafe(snapshot);
             foreach (var z in finalList)
             {
                 Objects.RecordRef rref = new RecordRef();
                 rref.RecordID = z.Id;
                 rref.SnapshotID = snapshot.Id;
                 this.InsertSafe(rref);
             }
             version.Snapshot = snapshot.Id;
             this.UpdateSafe(version);
             Commit();
         }
         catch
         {
             Rollback();
         }
     }
     return finalList;
 }
        /*
            Creates the new Lead/Customer record in NetSuite.  Must be called first because we'll need the resulting Customer ID
            to place in the new Contact record, and both ids to run the 'attach' operation.  These are NetSuite's rules, sadly.
        */
        public void createCustomer()
        {
            Customer customer = new Customer();

            // Populate information provided by the user
            customer.companyName = _companyName;
            customer.email = _email;
            customer.phone = _phone;

            // Set as Lead - New
            RecordRef status = new RecordRef();
            status.internalId = "6"; // LEAD - New
            customer.entityStatus = status;

            /*
                Custom Fields require creating a reference record based on the type of field, and then we
                add each reference object to an array that gets passed into the XML renderer that NetSuite
                provides for us.

                Industry, IP address and Source are custom fields we've created.  Industry is a drop down list, which
                means our reference object must contain a reference to which drop down entry the new lead selected.
                This seems a bit overboard but lists can be multi-selects as well.  IP Address and source are just simple
                text fields, so nothing fancy is required, they're just a simple name/value pair.
            */

            System.Collections.ArrayList customFields = new System.Collections.ArrayList();

            if (_industry != "") {
                SelectCustomFieldRef custIndustry = new SelectCustomFieldRef();
                custIndustry.internalId = "custentity_customerindustry";
                ListOrRecordRef custIndustryList = new ListOrRecordRef();
                custIndustryList.internalId = _industry;
                custIndustry.value = custIndustryList;
                customFields.Add(custIndustry);
            }

            if (_ip != "") {
                StringCustomFieldRef ip = new StringCustomFieldRef();
                ip.internalId = "custentity_fnaipaddress";
                ip.value = _ip;
                customFields.Add(ip);
            }

            if (_source != "") {
                StringCustomFieldRef source = new StringCustomFieldRef();
                source.internalId = "custentity_custfnasource";
                source.value = _source;
                customFields.Add(source);
            }

            CustomFieldRef[] customFieldRefs = new CustomFieldRef[customFields.Count];
            IEnumerator ienum = customFields.GetEnumerator();
            for (int i = 0; ienum.MoveNext(); i++) {
                customFieldRefs[i] = (CustomFieldRef)ienum.Current;
            }
            customer.customFieldList = customFieldRefs;

            /*
                Now with our customer record created, we're going to add it to our XML renderer and pass it on NetSuite.
                NetSuite will be returning a response in XML so we're going to grab that so we can get the id of the newly
                created record in NetSuite.
            */
            WriteResponse response = _service.add(customer);
            _customerStatus = response.status;
            if (this.getCustomerStatus() == "") {
                _customerID = ((RecordRef)response.baseRef).internalId;
                _entityName = ((RecordRef)response.baseRef).name;
            }
        }
        public static string UpdateSalesOrder(SalesOrder objOrder, ArrayList arrItems, out string strError)
        {
            strError = "";
            string strId = "";
            SalesOrder objSalesOrder = new SalesOrder();
            objSalesOrder.internalId = objOrder.internalId;
            objSalesOrder.customForm = new RecordRef();
            objSalesOrder.customForm.internalId = GlobalSettings.Default.nsOrderForm;
            objSalesOrder.customForm.type = RecordType.account;
            objSalesOrder.customForm.typeSpecified = true;

            SalesOrderItem[] salesOrderItemArray = new SalesOrderItem[arrItems.Count + objOrder.itemList.item.Length];
            for (int i = 0; i < salesOrderItemArray.Length; i++)
            {
                if (i < objOrder.itemList.item.Length)
                {
                    salesOrderItemArray[i] = new SalesOrderItem();
                    salesOrderItemArray[i].item = objOrder.itemList.item[i].item;
                    salesOrderItemArray[i].line = objOrder.itemList.item[i].line;
                    salesOrderItemArray[i].lineSpecified = true;

                    SelectCustomFieldRef objShippingType = new SelectCustomFieldRef();
                    objShippingType.internalId = "custcolcst_shippingtype";
                    objShippingType.value = new ListOrRecordRef();
                    objShippingType.value.internalId = "7";

                    //salesOrderItemArray[i].customFieldList = new CustomFieldRef[] { objShippingType };
                }
                else
                {
                    object[] arrColumns = (object[])arrItems[i - objOrder.itemList.item.Length];

                    RecordRef item = new RecordRef();
                    item.type = RecordType.nonInventoryResaleItem;
                    item.typeSpecified = true;
                    item.internalId = arrColumns[0].ToString();
                    salesOrderItemArray[i] = new SalesOrderItem();
                    salesOrderItemArray[i].item = item;

                    SelectCustomFieldRef objShippingType = new SelectCustomFieldRef();
                    objShippingType.internalId = "custcolcst_shippingtype";
                    objShippingType.value = new ListOrRecordRef();
                    objShippingType.value.internalId = arrColumns[4].ToString();
                    if (objShippingType.value.internalId.Equals("-1"))
                    {
                        objShippingType.value.internalId = "7";
                    }

                    DateCustomFieldRef objShipDate = new DateCustomFieldRef();
                    objShipDate.internalId = "custcolcst_shippingdate";
                    objShipDate.value = (DateTime)arrColumns[2];

                    DateCustomFieldRef objDelivDate = new DateCustomFieldRef();
                    objDelivDate.internalId = "custcolcst_deliverydate";
                    objDelivDate.value = (DateTime)arrColumns[3];

                    StringCustomFieldRef objPo = new StringCustomFieldRef();
                    objPo.internalId = "custcolos_ponumber";
                    objPo.value = arrColumns[5].ToString();

                    if (objDelivDate.value != DateTime.MaxValue)
                    {
                        salesOrderItemArray[i].customFieldList = new CustomFieldRef[] { objDelivDate, objShipDate, objShippingType, objPo };
                    }
                    else
                    {
                        salesOrderItemArray[i].customFieldList = new CustomFieldRef[] { objShipDate, objShippingType, objPo };
                    }

                    System.Double quantity = System.Double.Parse(arrColumns[1].ToString());
                    salesOrderItemArray[i].quantity = quantity;
                    salesOrderItemArray[i].quantitySpecified = true;
                }
            }

            SalesOrderItemList salesOrderItemList = new SalesOrderItemList();
            salesOrderItemList.item = salesOrderItemArray;

            objSalesOrder.itemList = salesOrderItemList;
            WriteResponse writeRes = _service.update(objSalesOrder);
            if (writeRes.status.isSuccess)
            {
                strId = ((RecordRef)writeRes.baseRef).internalId;
                //_out.writeLn("\nSales order created successfully\nSales Order Internal ID=" + ((RecordRef)writeRes.baseRef).internalId);
            }
            else
            {
                strError = getStatusDetails(writeRes.status);
            }
            return strId;
        }
        public static string GetOrderId(string strCustomerId, double numAmount)
        {
            string strItem = "";
            try
            {
                TransactionSearch xactionSearch = new TransactionSearch();
                SearchMultiSelectField entity = new SearchMultiSelectField();
                entity.@operator = SearchMultiSelectFieldOperator.anyOf;
                entity.operatorSpecified = true;
                RecordRef custRecordRef = new RecordRef();
                custRecordRef.internalId = strCustomerId;
                custRecordRef.type = RecordType.customer;
                custRecordRef.typeSpecified = true;
                RecordRef[] custRecordRefArray = new RecordRef[1];
                custRecordRefArray[0] = custRecordRef;
                entity.searchValue = custRecordRefArray;

                SearchEnumMultiSelectField searchSalesOrderField = new SearchEnumMultiSelectField();
                searchSalesOrderField.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
                searchSalesOrderField.operatorSpecified = true;
                System.String[] soStringArray = new System.String[1];
                soStringArray[0] = "_salesOrder";
                searchSalesOrderField.searchValue = soStringArray;

                TransactionSearchBasic xactionBasic = new TransactionSearchBasic();
                xactionBasic.type = searchSalesOrderField;
                xactionBasic.entity = entity;
                xactionBasic.status = new SearchEnumMultiSelectField();
                xactionBasic.status.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
                xactionBasic.status.operatorSpecified = true;
                xactionBasic.status.searchValue = new string[] { "_salesOrderPendingApproval" };
                xactionBasic.amount = new SearchDoubleField();
                xactionBasic.amount.@operator = SearchDoubleFieldOperator.equalTo;
                xactionBasic.amount.operatorSpecified = true;
                xactionBasic.amount.searchValue = numAmount;
                xactionBasic.amount.searchValueSpecified = true;

                xactionSearch.basic = xactionBasic;

                SearchResult objSearchResult = _service.search(xactionSearch);
                if (objSearchResult.recordList != null)
                {
                    Record[] recordList;
                    for (int i = 1; i <= objSearchResult.totalPages; i++)
                    {
                        recordList = objSearchResult.recordList;

                        for (int j = 0; j < recordList.Length; j++)
                        {
                            if (recordList[j] is SalesOrder)
                            {
                                SalesOrder so = (SalesOrder)(recordList[j]);
                                strItem = so.internalId;
                                return strItem;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            return strItem;
        }
示例#58
0
        public string deleteFulfillment()
        {
            NetSuiteService service = new NetSuiteService();
            service.CookieContainer = new CookieContainer();
            NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168");
            Passport passport = user.prepare(user);
            Status status = service.login(passport).status;

            RecordRef orderToBeDeleted = new RecordRef();
            orderToBeDeleted.type = RecordType.itemFulfillment;
            orderToBeDeleted.typeSpecified = true;
            orderToBeDeleted.internalId = this.itemFulfillment.internalId;

            WriteResponse writeResponse = service.delete(orderToBeDeleted);
            if (writeResponse.status.isSuccess == true)
            {
                Console.WriteLine("Delete Item Fulfillment " + this.itemFulfillment.tranId + " success");
                return "Delete Item Fulfillment " + this.itemFulfillment.tranId + " success";
            }
            if (writeResponse.status.isSuccess == false)
            {
                Console.WriteLine(writeResponse.status.statusDetail[0].message);
                return writeResponse.status.statusDetail[0].message;
            }
            return string.Empty;
        }
示例#59
0
        public ItemFulfillmentItemList addToExistingItemList(ItemFulfillmentItemList oldList, ItemFulfillmentLine fulfillmentLine)
        {
            int oldCount = oldList.item.Length;
            int newCount = oldCount + 1;
            ItemFulfillmentItemList newFulfillmentList = new ItemFulfillmentItemList();
            ItemFulfillmentItem[] newItem = new ItemFulfillmentItem[1];
            ItemFulfillmentItem[] newList = new ItemFulfillmentItem[newCount];
            oldList.item.CopyTo(newList, 0);

            newItem[0] = new ItemFulfillmentItem();
            RecordRef item = new RecordRef();
            item.type = RecordType.inventoryItem;
            item.typeSpecified = true;
            item.name = fulfillmentLine.item.ItemName;
            item.internalId = fulfillmentLine.item.itemRecord.internalId;
            newItem[0].item = item;

            newItem[0].quantity = fulfillmentLine.QuantityRequested;
            newItem[0].quantitySpecified = true;

            newItem.CopyTo(newList, oldCount);
            newFulfillmentList.item = newList;

            return newFulfillmentList;
        }
示例#60
-1
        public Dictionary<string, double> getBins(string SKU)
        {
            NetSuiteService objService = new NetSuiteService();
            objService.CookieContainer = new CookieContainer();
            Passport passport = new Passport();
            passport.account = "3451682";
            passport.email = "*****@*****.**";
            RecordRef role = new RecordRef();
            role.internalId = "1026";
            passport.role = role;
            passport.password = "******";
            Passport objPassport = passport;
            Status objStatus = objService.login(objPassport).status;

            ItemSearchAdvanced isa = new ItemSearchAdvanced();
            isa.savedSearchId = "141";  //substitute your own saved search internal ID
            ItemSearch iS = new ItemSearch();
            ItemSearchBasic isb = new ItemSearchBasic();

            SearchStringField itemSKU = new SearchStringField();
            itemSKU.searchValue = SKU;
            itemSKU.@operator = SearchStringFieldOperator.contains;
            itemSKU.operatorSpecified = true;
            isb.itemId = itemSKU;
            iS.basic = isb;
            isa.criteria = iS;

            SearchResult sr = new SearchResult();
            sr = objService.search(isa);

            if (sr.status.isSuccess != true) throw new Exception("Cannot find item.");

            Dictionary<string, double> binNumberList = new Dictionary<string, double>();

            foreach (ItemSearchRow irow in sr.searchRowList)
            {
                if (irow.basic.itemId[0].searchValue == SKU)
                {
                    binNumberList.Add(irow.basic.binNumber[0].searchValue, irow.basic.binOnHandAvail[0].searchValue);
                }
            }

            return binNumberList;
        }