Nyaraka za kila mwezi: Julai 2007

Moss: Iterating kupitia orodha ya desturi na kurudi data kuchujwa kwenye InfoPath

Biashara Igizo:

Kutoa njia ambayo itawezesha watumiaji kuingia Maombi ya ununuzi sahihi haraka.

Biashara tatizo:

mteja anafanya biashara na wachuuzi mia kadhaa.

Vendors are "type" maalum. Hii ina maana kwamba muuzaji anauza vifaa vya kompyuta (e.g. Dell) au vifaa vya ofisi (e.g. Mazao ya chakula).

How do we enable end users who create purchase requisitions select a valid vendor?

Business Solution:

Differentiate vendors in the system via "type".

Enable users to select the "type" of product and then provide a filtered set of appropriate vendors.

Kiufundi Solution:

An InfoPath form has been designed that enables users to enter online purchase requisitions.

Two InfoPath selection lists control vendor selection. Kwanza, 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.

Vendors are stored in a MOSS custom list with custom columns for vendor attributes such as name, address and especially "type".

Implement a web service for an InfoPath client to consume that iterates through the custom vendor list, returning only vendors matching a supplied "type".

Invoke the web service via the InfoPath form.

Yaliyojitokeza:

  • Kwanza, it seems necessary to go this route. I would have preferred to do the filtering entirely within InfoPath and not create any web service functionality here. Hata hivyo, forms server does not provide the required filtering capability. We can put a rule onto a the "type" selection list in the form to sort of re-open the vendor query, but we can’t get it to work properly. Kwa hiyo, it was necessary to implement the web service.
  • This is a classic "cascading selection list" problem in the InfoPath forms server world and there are many good examples out there that explain how to solve this.
  • A blank value for a column in the vendor list does not return an empty string when referenced like this: initItem["Vendor Name"]. Badala yake, it returns a null.

Some other Notes:

  • I return an array[] of vendors because I had some difficulty returning an ArrayList. InfoPath was complaining about it and I didn’t have the time or the inclination to fight over it. Hii, bila shaka, puts an artificial limit on the total number of vendors. It also compelled me to implement a trim() method on the array because I hate the idea of returning back 100’s of null vendors. InfoPath doesn’t care, but it nagged at me. (Tena, this was easier than fighting InfoPath over ArrayLists).
  • I implemented a GetSpecificVendorByName() function as well, which may be instructive.

kanuni:

kutumia Mfumo;
kutumia System.Web;
kutumia System.Web.Services;
kutumia System.Web.Services.Protocols;
kutumia Microsoft.SharePoint;
kutumia System.Configuration;

/// <muhtasari>
///
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.
///
/// </muhtasari>
[Webservice(Namespace = "http://www.conchango.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
umma darasani VendorService : System.Web.Services.Webservice
{

/// <muhtasari>
/// Represents a vendor from a custom sharepoint list maintained by MSUSA.
/// </muhtasari>
umma darasani Vendor
{
umma Vendor() { }

umma Vendor(SPItem initItem)
{
kama (! (initItem["Vendor Name"] == null)) VendorName = initItem["Vendor Name"].ToString();
kama (! (initItem["Address 1"] == null)) VendorAddress1 = initItem["Address 1"].ToString();
kama (! (initItem["Address 2"] == null)) VendorAddress2 = initItem["Address 2"].ToString();
kama (! (initItem["City"] == null)) VendorCity = initItem["City"].ToString();
kama (! (initItem["VendorPhone"] == null)) VendorPhone = initItem["VendorPhone"].ToString();
kama (! (initItem["PurchaseType"] == null)) VendorType = initItem["PurchaseType"].ToString();
kama (! (initItem["State"] == null)) VendorState = initItem["State"].ToString();
kama (! (initItem["Zip"] == null)) VendorZip = initItem["Zip"].ToString();
kama (!(initItem["Fax"] == null)) VendorFax = initItem["Fax"].ToString();
kama (!(initItem["SalesRepName"] == null)) VendorSalesRepName = initItem["SalesRepName"].ToString();

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

umma int VendorItemId;
umma string VendorName;
umma string VendorAddress1;
umma string VendorAddress2;
umma string VendorCity;
umma string VendorState;
umma string VendorZip;
umma string VendorPhone;
umma string VendorType;
umma string VendorSalesRepName;
umma string VendorFax;
}

umma VendorService () {

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

binafsi Vendor[] GenerateTestVendors()
{
Vendor[] resultList;
resultList = mpya Vendor[100];

Vendor v;
v = mpya 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 = mpya 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 = mpya 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;

kurudi resultList;

}

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

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

kutumia (SPSite site = mpya SPSite(SpVendorSiteName))
{

kutumia (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpVendorListName];

SPItem specificItem = currentList.Items[vendorId];

kurudi mpya 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
umma Vendor GetSpecificVendorByVendorName(string vendorName)
{
string SpVendorSiteName; // Name of the actual MOSS site that hosts the vendor custom list.
string SpVendorListName; // Name of the actual MOSS list containing vendors.

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

kutumia (SPSite site = mpya SPSite(SpVendorSiteName))
{
kutumia (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpVendorListName];

foreach (SPItem vendorItem katika currentList.Items)
{
kama (vendorItem["Vendor Name"] == null) kuendelea;

kama (vendorItem["Vendor Name"].ToString().Sawa na(vendorName))
kurudi mpya Vendor(vendorItem);
}

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

kurudi v;

kurudi null;

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

} // njia

[WebMethod]
umma Vendor[] GetVendorsOfType (string filterType)
{

string SpVendorSiteName; // Name of the actual MOSS site that hosts t
he vendor custom list.
string 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 = mpya Vendor[1000];

// Initialize the list with a default friendly message.
Vendor v = mpya 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.
#kanda Filter type = "test"
kama (filterType.Equals("test"))
kurudi GenerateTestVendors();
#endregion

kama (kweli)
{
kutumia (SPSite site = mpya SPSite(SpVendorSiteName))
{
kutumia (SPWeb web = site.OpenWeb())
{

v = null;

SPList currentList = web.Lists[SpVendorListName];

// Iterate through all the items in the vendor list.
foreach (SPItem vendorItem katika currentList.Items)
{

string lowerVendorType;

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

kama (lowerVendorType.Equals(filterType))
{
resultList[vendorIndex ] = mpya Vendor(vendorItem);
}
} // iterating thru all the vendors in the list


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

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

} // if true

kurudi null;
}

binafsi Vendor[] TrimVendorArray(int newsize, Vendor[] originalVendorArray)
{
Vendor[] trimmedArray;

kama (newsize == 0) newsize = 1;
trimmedArray = mpya Vendor[newsize];

int currentCounter = 0;

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

kurudi trimmedArray;

}
}

Moss: Uchunguzi juu ya debugging InfoPath

InfoPath fomu server kosa ujumbe ni kupotosha.

Wakati wa maendeleo ya fomu InfoPath, Ningependa baada ya kuwa na server MOSS na kupata fomu. fomu bila kuanza na shehena na kisha kutoa kupotosha ujumbe wa kosa akizungumzia mimi logi madirisha tukio kwa maelezo. Kwa kweli, hakuna ujumbe iliandikwa kwa logi tukio madirisha. Badala, ujumbe alitumwa kwa logi MOSS ascii uchunguzi. Unaweza kufuatilia kwamba chini kupitia huduma ya kati ya utawala.

Unahitaji kuwa ya haraka juu ya miguu yako. MOSS anapenda kuandika faili logi, mara kwa mara na verbosely. This can be trimmed but the default log writing behavior is "everything as quickly as possible".

Moss: Uppdatering orodha desturi

Kuna mifano mingi nzuri ya uppdatering orodha ya desturi kupitia SDK. Hapa ni jingine.

Biashara tatizo: Fomu InfoPath umebuniwa kwamba inawezesha watumiaji kuingia Maombi ya kununua online. PO shurutisho idadi lazima jadi mlolongo makao integer maadili na mahesabu moja kwa moja.

Business Solution: Kujenga desturi MOSS orodha zenye safu mbili: "ControlField" and "ControlValue". safu ya thamani ina ijayo kununua Shurutisho ya simu. Note that the generic "control" kumtaja mkataba hutoa kwa ajili ya mashamba ya baadaye ya kudhibiti kwamba inaweza kutumika kama inahitajika.

Kiufundi Solution: Kujenga huduma ya mtandao kupatikana kwa mteja InfoPath. huduma ya mtandao anarudi nyuma ijayo kununua Shurutisho simu updates na thamani ya orodha.

Yaliyojitokeza:

  • Wakati kuongeza huduma hii ya mtandao kama chanzo data kwa ajili ya InfoPath, Nimeona ni muhimu kubadilisha kwa UDC na kuhifadhi katika maktaba uhusiano data.
  • Mimi pia kupatikana ni muhimu ili kuwawezesha msalaba uwanja scripting kupitia huduma ya kati ya utawala // maombi ya usimamizi // fomu server Configuration.
  • mara ya kwanza fomu alijaribu kupata huduma ya mtandao, inachukua muda na juu ya tukio, itakuwa muda nje. Mimi fiddled na mazingira katika fomu muundo wa kompyuta kupanua mazingira ya umeisha na kwamba walionekana kusaidia.

kanuni:

kutumia Mfumo;
kutumia System.Web;
kutumia System.Web.Services;
kutumia System.Web.Services.Protocols;
kutumia Microsoft.SharePoint;
kutumia System.Configuration;

[Webservice(Namespace = "http://www.conchango.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
umma darasani PoService : System.Web.Services.Webservice
{
umma PoService () {

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

/// <muhtasari>
/// Obtain the next PO number from the sharepoint po number control list.
/// Increment the PO number in that list.
/// </muhtasari>
/// <anarudi></anarudi>
[WebMethod]
umma string GetNextPoNumber()
{
string SpPoControlSiteName; // Name of the actual MOSS site that hosts the PO Control list.
string SpPoControlListName; // Name of the actual MOSS list containing the Po control.

SpPoControlSiteName = ConfigurationSettings.AppSettings["PoControlListHostingSite"].ToString();
SpPoControlListName = ConfigurationSettings.AppSettings["PoControlList"].ToString();

string nextPoReqNumber = "xyzzy";

kutumia (SPSite site = mpya SPSite(SpPoControlSiteName))
{
kutumia (SPWeb web = site.OpenWeb())
{

SPList currentList = web.Lists[SpPoControlListName];

foreach (SPItem controlItem katika currentList.Items)
{

kama (((string)controlItem["ControlField"]).Sawa na("NextPoNumber"))
{
nextPoReqNumber = (string)controlItem["ControlValue"];

int int_nextPoReqNumber;
int_nextPoReqNumber = Kubadilisha.ToInt32(nextPoReqNumber);

int_nextPoReqNumber ;

controlItem["ControlValue"] = int_nextPoReqNumber;
controlItem.Update();
}

} // Locating, reading and updating the PO number in the list.


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

kurudi nextPoReqNumber;

}
}