Moss: Iterating gegnum sérsniðnum lista og aftur sía gögn til InfoPath

Viðskipti Atburðarás:

Koma fram með aðferð sem gerir notendum að slá inn nákvæmar requisitions kaupa fljótt.

Viðskipti vandamál:

Viðskiptavinurinn tekur fyrirtæki með nokkur hundruð smásali.

Vendors are "type" sérstakur. Þetta þýðir að seljandi selur tölvubúnað (e.g. Dell) eða skrifstofuvörur (e.g. Staples).

Hvernig kveiki við notendur sem búa kaupa requisitions velja gilt seljanda?

Business Solution:

Differentiate vendors in the system via "type".

Enable users to select the "type" vöru og þá veita síað setja viðeigandi smásali.

Tæknilegar Lausn:

An InfoPath mynd hefur verið hannað sem gerir notendum kleift að slá á netinu requisitions kaupa.

Tveir InfoPath val listar stjórna seljanda val. Fyrsta, the user selects a "purchase type". This limits a second selection list to contain only vendors that sell for that purchase type. This is a classic cascading drop-down.

Seljendur eru geymdar í mosa sérsniðnum lista með sérsniðnum dálka fyrir eiginleika seljanda svo sem nafn, address and especially "type".

Innleiða a vefur þjónusta fyrir Infopath viðskiptavinur að neyta sem iterates gegnum sérsniðnum seljanda lista, returning only vendors matching a supplied "type".

Ákalla vefnum þjónustu í gegnum Infopath formi.

Reynslu sem fengist:

  • Fyrsta, það virðist nauðsynlegt að fara þessa leið. Ég hefði kosið að gera sía alfarið innan InfoPath og ekki skapist þjónustu vefur virkni hér. Hins, eyðublöð miðlara veitir ekki nauðsynlegar sía getu. We can put a rule onto a the "type" val lista í formi til að raða í opna aftur seljandi fyrirspurn, en við getum ekki fengið það til að vinna almennilega. Því, það var nauðsynlegt til að framkvæma vefur þjónusta.
  • This is a classic "cascading selection list" vandamál í InfoPath eyðublöð miðlara heim og það eru mörg góð dæmi þarna úti sem skýra hvernig á að leysa þetta.
  • Autt gildi fyrir dálk í söluaðili listi ekki verið tómt band þegar vísað svona: initItem["Vendor Name"]. Staðinn, það skilar null.

Sumir annar Skýringar:

  • Ég skila fylki[] smásali vegna þess að ég hafði nokkrum erfiðleikum koma aftur til ArrayList. InfoPath var að kvarta um það og ég hafði ekki tíma eða halla til að berjast yfir það. Þetta, auðvitað, setur tilbúna takmörk á heildarfjölda birgja. Það knúinn mér líka að innleiða snyrta() method on the array because I hate the idea of returning back 100’s of null vendors. InfoPath er ekki sama, en það nagged á mig. (Aftur, þetta var auðveldara en að berjast Infopath yfir ArrayLists).
  • Ég innleitt GetSpecificVendorByName() virka eins vel, sem kann að vera lærdómsríkt.

The númer:

með System;
með System.Web;
með System.Web.Services;
með System.Web.Services.Protocols;
með Microsoft.SharePoint;
með System.Configuration;

/// <Yfirlit>
///
Vendor Service: Provides vendor related services which today are consumed by an infopath client form.
///
/// History:
/// ——–
/// 07/24/07: Initial coding, Paul J. Gavin of Conchango.
///
/// </Yfirlit>
[VefÃ(Namespace = "http://www.conchango.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
almennings flokki VendorService : System.Web.Services.VefÃ
{

/// <Yfirlit>
/// Represents a vendor from a custom sharepoint list maintained by MSUSA.
/// </Yfirlit>
almennings flokki Vendor
{
almennings Vendor() { }

almennings Vendor(Spýta initItem)
{
ef (! (initItem["Vendor Name"] == núll)) VendorName = initItem["Vendor Name"].ToString();
ef (! (initItem["Address 1"] == núll)) VendorAddress1 = initItem["Address 1"].ToString();
ef (! (initItem["Address 2"] == núll)) VendorAddress2 = initItem["Address 2"].ToString();
ef (! (initItem["City"] == núll)) VendorCity = initItem["City"].ToString();
ef (! (initItem["VendorPhone"] == núll)) VendorPhone = initItem["VendorPhone"].ToString();
ef (! (initItem["PurchaseType"] == núll)) VendorType = initItem["PurchaseType"].ToString();
ef (! (initItem["State"] == núll)) VendorState = initItem["State"].ToString();
ef (! (initItem["Zip"] == núll)) VendorZip = initItem["Zip"].ToString();
ef (!(initItem["Fax"] == núll)) VendorFax = initItem["Fax"].ToString();
ef (!(initItem["SalesRepName"] == núll)) VendorSalesRepName = initItem["SalesRepName"].ToString();

VendorItemId = initItem.ID; // Unique ID maintained via MOSS.
}

almennings INT VendorItemId;
almennings band VendorName;
almennings band VendorAddress1;
almennings band VendorAddress2;
almennings band VendorCity;
almennings band VendorState;
almennings band VendorZip;
almennings band VendorPhone;
almennings band VendorType;
almennings band VendorSalesRepName;
almennings band VendorFax;
}

almennings VendorService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

einkaaðila Vendor[] GenerateTestVendors()
{
Vendor[] resultList;
resultList = Vendor[100];

Vendor v;
v = Vendor();
v.VendorAddress1 = "v1_address1";
v.VendorAddress2 = "v1_address2";
v.VendorCity = "v1_city";
v.VendorName = "v1_vendorname";
v.VendorPhone = "v1_vendorphone";
v.VendorState = "v1_st";
v.VendorType = "v1_type";
v.VendorZip = "v1_zip";

resultList[0] = v;

v = Vendor();

v.VendorAddress1 = "v2_address1";
v.VendorAddress2 = "v2_address2";
v.VendorCity = "v2_city";
v.VendorName = "v2_vendorname";
v.VendorPhone = "v2_vendorphone";
v.VendorState = "v2_st";
v.VendorType = "v2_type";
v.VendorZip = "v2_zip";

resultList[1] = v;

v = Vendor();
v.VendorAddress1 = "v3_address1";
v.VendorAddress2 = "v3_address2";
v.VendorCity = "v3_city";
v.VendorName = "v3_vendorname";
v.VendorPhone = "v3_vendorphone";
v.VendorState = "v3_st";
v.VendorType = "v3_type";
v.VendorZip = "v3_zip";

resultList[2] = v;

aftur resultList;

}

[WebMethod]
almennings Vendor GetSpecificVendorById(INT vendorId)
{
band SpVendorSiteName; // Name of the actual MOSS site that hosts the vendor custom list.
band SpVendorListName; // Name of the actual MOSS list containing vendors.

SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();

með (SPSite site = SPSite(SpVendorSiteName))
{

með (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpVendorListName];

Spýta specificItem = currentList.Items[vendorId];

aftur Vendor(specificItem);

} // using spweb web = site.openweb()
} // using spsite site = new spsite("http://localhost/mizuho")

}

[WebMethod]
// Assumes that the vendor name is unique, from a business perspective
almennings Vendor GetSpecificVendorByVendorName(band vendorName)
{
band SpVendorSiteName; // Name of the actual MOSS site that hosts the vendor custom list.
band SpVendorListName; // Name of the actual MOSS list containing vendors.

SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();

með (SPSite site = SPSite(SpVendorSiteName))
{
með (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpVendorListName];

framhandleggur (Spýta vendorItem í currentList.Items)
{
ef (vendorItem["Vendor Name"] == núll) áfram;

ef (vendorItem["Vendor Name"].ToString().Jafngildir(vendorName))
aftur Vendor(vendorItem);
}

Vendor v = Vendor();
v.VendorPhone = "not found: " + vendorName;

aftur v;

aftur núll;

} // using spweb web = site.openweb()
} // using spsite site = new spsite("http://localhost/mizuho")

} // aðferð

[WebMethod]
almennings Vendor[] GetVendorsOfType (band síu)
{

band SpVendorSiteName; // Name of the actual MOSS site that hosts t
he vendor custom list.
band SpVendorListName; // Name of the actual MOSS list containing vendors.

SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();

Vendor[] resultList;
INT vendorIndex = 0;
resultList = Vendor[1000];

// Initialize the list with a default friendly message.
Vendor v = Vendor();
v.VendorName = "Select a vendor type to populate this list.";
resultList[0] = v;

// Convert the filter to lower case for easier string comparison later.
filterType = filterType.ToLower();

// If the filter type passed is "test", generate some simple data.
#region Filter type = "test"
ef (filterType.Equals("test"))
aftur GenerateTestVendors();
#endregion

ef (satt)
{
með (SPSite site = SPSite(SpVendorSiteName))
{
með (SPWeb web = site.OpenWeb())
{

v = núll;

SPList currentList = web.Lists[SpVendorListName];

// Iterate through all the items in the vendor list.
framhandleggur (Spýta vendorItem í currentList.Items)
{

band lowerVendorType;

lowerVendorType = vendorItem["PurchaseType"].ToString().ToLower();
lowerVendorType = lowerVendorType.Substring(3);

ef (lowerVendorType.Equals(síu))
{
resultList[vendorIndex ] = Vendor(vendorItem);
}
} // iterating thru all the vendors in the list


aftur TrimVendorArray(vendorIndex, resultList);
// return resultList;

} // using spweb web = site.openweb()
} // using spsite site = new spsite("http://localhost/mizuho")

} // if true

aftur núll;
}

einkaaðila Vendor[] TrimVendorArray(INT newsize, Vendor[] originalVendorArray)
{
Vendor[] trimmedArray;

ef (newsize == 0) newsize = 1;
trimmedArray = Vendor[newsize];

INT currentCounter = 0;

fyrir (currentCounter = 0; currentCounter < newsize; currentCounter )
{
trimmedArray[currentCounter] = originalVendorArray[currentCounter];
}

aftur trimmedArray;

}
}

Eftir svar

Netfangið þitt verður ekki birt. Nauðsynlegir reitir eru merktir *