Lag luam Scenario:
Muab txoj kev enables rau cov neeg siv yuav sau purchase yog requisitions ceev ceev.
Cov teeb meem ua lag ua luam:
Tus neeg twg ua lag ua luam nrog rau ntau pua neeg muag khoom.
Neeg muag khoom yog "hom" meej. Qhov no txhais tau hais tias ib tug vendor sells lub computer khoom (e.g. Dell) los sis khoom siv hauv chaw ua hauj lwm (e.g. Staples).
Peb yuav pab cov neeg siv tag leej twg rhawv purchase requisitions xaiv ib vendor uas koj siv tau li cas?
Kev hais haum ua lag ua luam:
Qha cov neeg muag khoom nyob rau hauv lub cev ntawm "hom".
Pab kom cov neeg siv kom xaiv "hom" ntawm cov khoom thiab muab ib txheej uas tsim nyog cov neeg muag khoom.
Kev tov:
Ib cov ntawv InfoPath twb tau tsim cov neeg enables sau hauv internet muas requisitions.
Ob tug InfoPath xaiv npe tswj vendor xaiv. Ua ntej, tus neeg siv ntawv twg xaiv ib tus "purchase yam". Qhov no txwv thib ob uas sau kom muaj xwb neeg muag khoom muag rau ntawd purchase hom. Qhov no nws yog ib tug classic cascading nco-down.
Neeg muag khoom muab cia rau hauv NTXHUAB kev cai sau kev cai txhua rau vendor pas xws li lub npe nrog rau, qhov chaw nyob thiab tshwj xeeb tshaj yog "yam".
Qhov Web site rau ib tug neeg InfoPath yuav haus cov dej uas siv los ntawm daim ntawv kev cai vendor iterates, rov qab xwb neeg muag khoom txuam ib supplied "yam".
Ua tau rau tus cov qhov Web site ntawm daim InfoPath.
Cov tshooj lus kawm:
- Ua ntej, nkawd yuav mus no lawv. Kuv yuav muaj tau najnpawb mus ua tus filtering nkaus li cov InfoPath thiab tsis tsim tej Web site rau functionality no. Txawm li cas los, cov neeg rau zaub mov yuav tsis muaj qhov yuav tsum tau filtering muaj rab peev xwm. Peb yuav muab txoj cai rau ib "hom" daim ntawv xaiv nyob rau hauv daim ntawv tsawm tsawv thiab rov qhib rau cov lus nug vendor, tab sis peb tsis tau mus ua hauj lwm kom zoo. Yog li no, yog yuav siv tau cov Web site qhov.
- Classic "cascading xaiv yuav sau li no" qhov teeb meem nyob rau hauv cov InfoPath tas li neeg rau zaub mov qab ntuj thiab muaj ntau yam zoo qauv muaj sia uas piav seb yuav kom daws tau qhov no li cas.
- Ib tug nqi rau ib sab nyob rau hauv daim ntawv vendor dawb paug tsis xa ib khoob hlua thaum hais los zoo li no: initItem["Vendor npe"]. Xwb, nws rov ib null.
Ib co sau ntawv:
- Kuv xa ib array[] cov neeg muag khoom vim kuv tau tej teeb meem uas rov qab ua ArrayList. InfoPath tau complaining txog nws thiab kuv tsis muaj sij hawm los yog tus inclination mus tua dua nws. Qhov no, tau mas, txo nws hwj ib co txwv rau tag nrho cov neeg muag khoom. Nws kuj compelled kuv siv ib trim() qauv rau cov array vim kuv ntxub cov tswv yim uas rov qaum 100 tus uas thov tus neeg muag khoom. InfoPath tsis tu, tab sis nws nagged rau kuv. (Dua, qhov no yooj yim dua ntaus InfoPath nyob ArrayLists).
- Kuv DVR ib GetSpecificVendorByName() ua kom zoo li, uas tej zaum yuav instructive.
Qhov chaws:
siv Tsim;
siv System.Web;
siv System.Web.Services;
siv System.Web.Services.Protocols;
siv Microsoft.SharePoint;
siv System.Configuration;
/// <txoj kev>
/// Qhov kev pab cuam vendor: Muab vendor ntsig txog cov kev pab uas hnub no yog ntim ntawm ib daim ntawv infopath nyob hauv kev pab.
///
/// Keeb kwm:
/// ——–
/// 07/24/07: Thawj zaug coding, Paul J. Cov Conchango Gavin.
///
/// </txoj kev>
[WebService(Namespace = "http://www.conchango.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
pej xeem hoob VendorService : System.Web.Services.WebService
{
/// <txoj kev>
/// Nruab nrab yog ib vendor ntawm ib daim ntawv kev cai sharepoint ntawm MSUSA.
/// </txoj kev>
pej xeem hoob Vendor
{
pej xeem Vendor() { }
pej xeem Vendor(SPItem initItem)
{
Yog hais tias (! (initItem["Vendor npe"] == null)) VendorName = initItem["Vendor npe"].ToString();
Yog hais tias (! (initItem["Nyob 1"] == null)) VendorAddress1 = initItem["Nyob 1"].ToString();
Yog hais tias (! (initItem["Nyob 2"] == null)) VendorAddress2 = initItem["Nyob 2"].ToString();
Yog hais tias (! (initItem["City"] == null)) VendorCity = initItem["City"].ToString();
Yog hais tias (! (initItem["VendorPhone"] == null)) VendorPhone = initItem["VendorPhone"].ToString();
Yog hais tias (! (initItem["PurchaseType"] == null)) VendorType = initItem["PurchaseType"].ToString();
Yog hais tias (! (initItem["Lub xeev"] == null)) VendorState = initItem["Lub xeev"].ToString();
Yog hais tias (! (initItem["Zip"] == null)) VendorZip = initItem["Zip"].ToString();
Yog hais tias (!(initItem["Fax"] == null)) VendorFax = initItem["Fax"].ToString();
Yog hais tias (!(initItem["SalesRepName"] == null)) VendorSalesRepName = initItem["SalesRepName"].ToString();
VendorItemId = initItem.ID; // Nws tswj tseg ntawm NTXHUAB ID.
}
pej xeem rau cov menyuam VendorItemId;
pej xeem hlua VendorName;
pej xeem hlua VendorAddress1;
pej xeem hlua VendorAddress2;
pej xeem hlua VendorCity;
pej xeem hlua VendorState;
pej xeem hlua VendorZip;
pej xeem hlua VendorPhone;
pej xeem hlua VendorType;
pej xeem hlua VendorSalesRepName;
pej xeem hlua VendorFax;
}
pej xeem VendorService () {
//Cov lus hauv qab no kab yog siv tsim Cheebtsam uncomment
//InitializeComponent();
}
lwm yam Vendor[] GenerateTestVendors()
{
Vendor[] resultList;
resultList = tshiab Vendor[100];
Vendor v;
v = tshiab Vendor();
v.VendorAddress1 = "v1_address1";
v.VendorAddress2 = "v1_address2";
v.VendorCity = "v1_city";
v.VendorName = "v1_vendorname";
v.VendorPhone = "v1_vendorphone";
v.VendorState =
v.VendorType = "v1_type";
v.VendorZip = "v1_zip";
resultList[0] = v;
v = tshiab 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 = tshiab 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;
rov qab los resultList;
}
[WebMethod]
pej xeem Vendor GetSpecificVendorById(rau cov menyuam vendorId)
{
hlua SpVendorSiteName; // Lub npe ntawm lub txoos NTXHUAB kawm uas hosts vendor kev cai daim ntawv.
hlua SpVendorListName; // Lub npe ntawm lub txoos NTXHUAB daim ntawv uas muaj cov neeg muag khoom.
SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();
siv (SPSite kawm ntawv = tshiab SPSite(SpVendorSiteName))
{
siv (SPWeb Web = kawm ntawv. OpenWeb())
{
Splist.Update() currentList = web. Teev[SpVendorListName];
SPItem specificItem = currentList.Items[vendorId];
rov qab los tshiab Vendor(specificItem);
} // siv lub web spweb = site.openweb()
} // siv qhov chaw spsite = spsite tshiab("http://localhost/mizuho")
}
[WebMethod]
// Assumes tias cov vendor npe hu ua nws, ntawm lub lag luam foundations
pej xeem Vendor GetSpecificVendorByVendorName(hlua yuav)
{
hlua SpVendorSiteName; // Lub npe ntawm lub txoos NTXHUAB kawm uas hosts vendor kev cai daim ntawv.
hlua SpVendorListName; // Lub npe ntawm lub txoos NTXHUAB daim ntawv uas muaj cov neeg muag khoom.
SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();
siv (SPSite kawm ntawv = tshiab SPSite(SpVendorSiteName))
{
siv (SPWeb Web = kawm ntawv. OpenWeb())
{
Splist.Update() currentList = web. Teev[SpVendorListName];
foreach (SPItem vendorItem nyob rau hauv currentList.Items)
{
Yog hais tias (vendorItem["Vendor npe"] == null) ntxiv mus;
Yog hais tias (vendorItem["Vendor npe"].ToString().Qhov sib npaug(yuav))
rov qab los tshiab Vendor(vendorItem);
}
Vendor v = tshiab Vendor();
v.VendorPhone = "nrhiav tsis tau: " + yuav;
rov qab los v;
rov qab los null;
} // siv lub web spweb = site.openweb()
} // siv qhov chaw spsite = spsite tshiab("http://localhost/mizuho")
} // txujci
[WebMethod]
pej xeem Vendor[] GetVendorsOfType (hlua filterType)
{
hlua SpVendorSiteName; // Lub npe ntawm lub txoos NTXHUAB kawm uas ib hom tsiaj t
nws vendor kev cai sau.
hlua SpVendorListName; // Lub npe ntawm lub txoos NTXHUAB daim ntawv uas muaj cov neeg muag khoom.
SpVendorSiteName = ConfigurationSettings.AppSettings["VendorListHostingSite"].ToString();
SpVendorListName = ConfigurationSettings.AppSettings["VendorList"].ToString();
Vendor[] resultList;
rau cov menyuam vendorIndex = 0;
resultList = tshiab Vendor[1000];
// Initialize daim ntawv nrog vim tus phooj ywg lus.
Vendor v = tshiab Vendor();
v.VendorName = "Xaiv ib yam vendor rau populate daim ntawv.";
resultList[0] = v;
// Hloov lub lim los txo cov ntaub ntawv kom yooj yim txoj hlua sib piv ib tsam.
filterType = filterType.ToLower();
// Yog hom lim kis yog "sim", ua kom muaj tej ntaub ntawv yooj yim.
#thaj av Lim yam = "sim"
Yog hais tias (filterType. qhov sib npaug("sim"))
rov qab los GenerateTestVendors();
#endregion
Yog hais tias (tseeb)
{
siv (SPSite kawm ntawv = tshiab SPSite(SpVendorSiteName))
{
siv (SPWeb Web = kawm ntawv. OpenWeb())
{
v = null;
Splist.Update() currentList = web. Teev[SpVendorListName];
// Iterate txog txhua yam nyob rau hauv daim ntawv vendor.
foreach (SPItem vendorItem nyob rau hauv currentList.Items)
{
hlua lowerVendorType;
lowerVendorType = vendorItem["PurchaseType"].ToString().ToLower();
lowerVendorType = lowerVendorType.Substring(3);
Yog hais tias (lowerVendorType. qhov sib npaug(filterType))
{
resultList[vendorIndex ] = tshiab Vendor(vendorItem);
}
} // ntsuas qhib rau txhua tus neeg muag khoom nyob hauv daim ntawv
rov qab los TrimVendorArray(vendorIndex, resultList);
// rov qab mus resultList;
} // siv lub web spweb = site.openweb()
} // siv qhov chaw spsite = spsite tshiab("http://localhost/mizuho")
} // Yog hais tias muaj tseeb tiag
rov qab los null;
}
lwm yam Vendor[] TrimVendorArray(rau cov menyuam newsize, Vendor[] originalVendorArray)
{
Vendor[] trimmedArray;
Yog hais tias (newsize == 0) newsize = 1;
trimmedArray = tshiab Vendor[newsize];
rau cov menyuam currentCounter = 0;
rau (currentCounter = 0; currentCounter < newsize; currentCounter )
{
trimmedArray[currentCounter] = originalVendorArray[currentCounter];
}
rov qab los trimmedArray;
}
}