private void listViewProfile_SelectedIndexChanged(object sender, System.EventArgs e) { try { // get client PLMPackServiceClient client = WCFClientSingleton.Instance.Client; if (listViewProfile.SelectedIndices.Count > 0) { int iSel = listViewProfile.SelectedIndices[0]; ListViewItem item = listViewProfile.Items[iSel]; // check if cardboard profile has some dependancies DCCardboardProfile profile = client.GetCardboardProfileByID((int)item.Tag); this.btDelete.Enabled = !profile.HasMajorationSets; } } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void btDelete_Click(object sender, EventArgs e) { try { // get client PLMPackServiceClient client = WCFClientSingleton.Instance.Client; // retrieve selected carboard profile DCCardboardProfile profile = client.GetCardboardProfileByID(GetSelectedProfileId()); client.RemoveCardboardProfile(profile); // fill list view again FillListView(); // select first item if (listViewProfile.Items.Count > 0) { listViewProfile.Items[0].Selected = true; } } catch (Exception ex) { _log.Debug(ex.ToString()); } }
private void bnModify_Click(object sender, System.EventArgs e) { try { // get client PLMPackServiceClient client = WCFClientSingleton.Instance.Client; if (listViewProfile.SelectedIndices.Count > 0) { // get selected item int iSel = this.listViewProfile.SelectedIndices[0]; ListViewItem item = listViewProfile.Items[iSel]; DCCardboardProfile currentCardboardProfile = client.GetCardboardProfileByID((int)item.Tag); FormCreateCardboardProfile dlg = new FormCreateCardboardProfile(); dlg.ProfileName = currentCardboardProfile.Name; dlg.Code = currentCardboardProfile.Code; dlg.Thickness = currentCardboardProfile.Thickness; if (DialogResult.OK == dlg.ShowDialog()) { // set new values currentCardboardProfile.Name = dlg.ProfileName; currentCardboardProfile.Code = dlg.Code; currentCardboardProfile.Thickness = dlg.Thickness; // update database client.UpdateCardboardProfile(currentCardboardProfile); // refill list view FillListView(); // select current item listViewProfile.Items[iSel].Selected = true; } } } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void RecursiveInsert(PPDataContext db, TreeNode tn, PLMPackSR.DCTreeNode wsNode, string offset, IProcessingCallback callback) { PLMPackSR.PLMPackServiceClient client = new PLMPackSR.PLMPackServiceClient(); client.ClientCredentials.UserName.UserName = UserName; client.ClientCredentials.UserName.Password = Password; PLMPackSR.DCTreeNode wsNodeChild = null; string docType = string.Empty; try { // create node thumbnail string thumbPath = tn.Thumbnail.File.PathWRepo(RepositoryPath); DCFile thFile = Upload(thumbPath, callback, client); PLMPackSR.DCThumbnail wsThumbnail = client.CreateNewThumbnailFromFile(thFile); if (tn.IsDocument) { // get document Document doc = tn.Documents(db)[0]; string docPath = doc.File.PathWRepo(RepositoryPath); // upload document PLMPackSR.DCFile wsDocFile = Upload(docPath, callback, client); if (tn.IsComponent) { docType = "COMPONENT"; Component comp = doc.Components[0]; // get majorations List <PLMPackSR.DCMajorationSet> majorationSets = new List <PLMPackSR.DCMajorationSet>(); foreach (MajorationSet majoSet in comp.MajorationSets) { DCCardboardProfile cbProfile = client.GetCardboardProfileByName(majoSet.CardboardProfile.Name); string sMajo = string.Empty; List <DCMajoration> dcMajorationList = new List <DCMajoration>(); foreach (Majoration majo in majoSet.Majorations) { sMajo += string.Format("({0}={1})", majo.Name, majo.Value); dcMajorationList.Add(new DCMajoration() { Name = majo.Name, Value = majo.Value }); } majorationSets.Add( new DCMajorationSet() { Profile = cbProfile, Majorations = dcMajorationList.ToArray() } ); if (null != callback) { callback.Info(string.Format("{0} - {1}", majoSet.CardboardProfile.Name, sMajo)); } } // get default parameter values List <PLMPackSR.DCParamDefaultValue> paramDefaultValues = new List <PLMPackSR.DCParamDefaultValue>(); foreach (ParamDefaultValue pdv in comp.ParamDefaultValues) { paramDefaultValues.Add(new DCParamDefaultValue() { Name = pdv.Name, Value = pdv.Value }); } PLMPackSR.DCTreeNode wsNodeComp = client.CreateNewNodeComponent( wsNode, tn.Name, tn.Description , wsThumbnail, wsDocFile, doc.Components[0].Guid , majorationSets.ToArray(), paramDefaultValues.ToArray()); client.ShareEveryone(wsNodeComp); } else { docType = "DOCUMENT"; PLMPackSR.DCTreeNode wsNodeDocument = client.CreateNewNodeDocument(wsNode, tn.Name, tn.Description , wsThumbnail, wsDocFile); client.ShareEveryone(wsNodeDocument); } } else { docType = "BRANCH"; wsNodeChild = client.CreateNewNodeBranch(wsNode, tn.Name, tn.Description, wsThumbnail); client.ShareEveryone(wsNodeChild); } client.Close(); } catch (Exception ex) { client.Abort(); if (null != callback) { callback.Error(ex.ToString()); } } if (null == wsNodeChild) { return; } if (null != callback) { callback.Info(string.Format("{0}-> {1} ({2})", offset, tn.Name, docType)); } offset += " "; foreach (TreeNode tnChild in tn.Childrens(db)) { RecursiveInsert(db, tnChild, wsNodeChild, offset, callback); } }