public ItemSpec AddSpec(ItemSpec spec) { throw new InvalidOperationException("Cannot AddSpec on client."); }
public void GetItems(VersionControlServer server) { ItemSpec spec = new ItemSpec(ServerPath, RecursionType.OneLevel); m_itemSet = server.GetItems(spec, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Folder, false); }
public void AddShapeShift(ItemSpec spec, ModelId targetType, Color?targetColor = null) { itemShapeShiftDefinitions.Add(new ItemShapeShiftDefinition(spec, targetType, targetColor)); }
public void addItem(string itemname, ItemSpec spec) { Item item = new Item(itemname, spec); itemlist.Add(item); }
public static void SetLoadedAmmoType(this InventoryItem item, ItemSpec ammoType) { Debug.Assert(ammoType.IsAmmo()); item.SetProperty(new InventoryItemProperty((short)InventoryItemPropertyEnum.LoadedAmmoType, ammoType.Id)); }
public List<PendingSet> QueryPendingSets(string localWorkspaceName, string localWorkspaceOwner, string queryWorkspaceName, string ownerName, ItemSpec[] itemSpecs, bool generateDownloadUrls) { var invoker = new SoapInvoker(this); var msg = invoker.CreateEnvelope("QueryPendingSets"); msg.Add(new XElement(MessageNs + "localWorkspaceName", localWorkspaceName)); msg.Add(new XElement(MessageNs + "localWorkspaceOwner", localWorkspaceOwner)); msg.Add(new XElement(MessageNs + "queryWorkspaceName", queryWorkspaceName)); msg.Add(new XElement(MessageNs + "ownerName", ownerName)); msg.Add(new XElement(MessageNs + "itemSpecs", itemSpecs.Select(i => i.ToXml(MessageNs + "ItemSpec")))); msg.Add(new XElement(MessageNs + "generateDownloadUrls", generateDownloadUrls.ToLowString())); var result = invoker.InvokeResult(); return new List<PendingSet>(result.Elements(MessageNs + "PendingSet").Select(PendingSet.FromXml)); // var pendingChangesElements = result.Descendants(MessageNs + "PendingChange"); // var failuresElements = result.Descendants(MessageNs + "PendingChange"); // // var changes = new List<PendingChange>(pendingChangesElements.Select(el => PendingChange.FromXml(el))); // var faillist = new List<Failure>(failuresElements.Select(el => Failure.FromXml(el))); // return new Tuple<List<PendingChange>, List<Failure>>(changes, faillist); }
public void init(ItemSpec _spec) { spec = _spec; transform.Find("Text").GetComponent <Text> ().text = LanController.getString(spec.name).ToUpper(); transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + spec.name + "Icon"); GameObject buyBut = transform.Find("BuyButton").gameObject; GameObject useBut = transform.Find("UseButton").gameObject; useBut.transform.Find("Text").GetComponent <Text> ().text = LanController.getString("Use").ToUpper(); int cost = 10000; if (spec.gem > 0) { cost = spec.gem; transform.Find("BuyButton").Find("Image").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/gemIcon"); } else { cost = spec.coin; } useBut.SetActive(false); switch (spec.getItemType()) { case SpecController.TreasureType: transform.Find("StarImage").gameObject.SetActive(true); useBut.SetActive(true); buyBut.SetActive(false); TreasureData treasure = GameController.GetInstance().treasureDatas [spec.item_id]; if (treasure == null || !GameController.GetInstance().IsPaymentInitialized()) { useBut.transform.Find("Text").GetComponent <Text> ().text = LanController.getString("buy").ToUpper(); } else { useBut.transform.Find("Text").GetComponent <Text> ().text = treasure.priceString; } break; case SpecController.BulletType: List <string> bullets = PlayerData.getBullets(); if (bullets.Contains(spec.item_id)) { buyBut.SetActive(false); useBut.SetActive(true); if (PlayerData.getCurrentBullet() == spec.item_id) { useBut.transform.Find("Text").GetComponent <Text>().text = LanController.getString("using").ToUpper(); } } else { buyBut.transform.Find("Text").GetComponent <Text> ().text = cost.ToString(); } break; case SpecController.CannonType: List <string> cannons = PlayerData.getCannons(); if (cannons.Contains(spec.item_id)) { buyBut.SetActive(false); useBut.SetActive(true); if (PlayerData.getCurrentCannon() == spec.item_id) { useBut.transform.Find("Text").GetComponent <Text>().text = LanController.getString("using").ToUpper(); } } else { buyBut.transform.Find("Text").GetComponent <Text> ().text = cost.ToString(); } break; default: buyBut.transform.Find("Text").GetComponent <Text> ().text = cost.ToString(); buyBut.SetActive(true); break; } }
private void ProcessDirectory(string path) { char[] charsToTrim = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }; string itemPath = path.TrimEnd(charsToTrim); string serverPath = workspace.GetServerItemForLocalItem(itemPath); // pull item list based on WorkspaceVersion. otherwise might get // new items on server that haven't been pulled yet in the list returned WorkspaceVersionSpec version = new WorkspaceVersionSpec(workspace); // process recursion settings RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.OneLevel; bool recursionSetting = Settings.Current.GetAsBool("Online.Recursive"); if (recursionSetting) { rtype = RecursionType.Full; } SearchOption searchType = (rtype == RecursionType.Full) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; // process command options ItemSpec itemSpec = new ItemSpec(itemPath, rtype); ItemSet itemSet = VersionControlServer.GetItems(itemSpec, version, DeletedState.NonDeleted, ItemType.Any, true); // get item list from TFS server Item[] items = itemSet.Items; SortedList <string, byte[]> itemList = new SortedList <string, byte[]>(PathComparer); foreach (Item item in items) { if (item.ServerItem.Length == serverPath.Length) { continue; } string serverItem = item.ServerItem.Remove(0, serverPath.Length + 1); // server item paths are separated with '/', but on windows the file list below has '\' separated paths if (Path.DirectorySeparatorChar != '/') { serverItem = serverItem.Replace('/', Path.DirectorySeparatorChar); } string fname = Path.Combine(itemPath, serverItem); //Console.WriteLine(serverItem + " : " + fname); itemList.Add(fname, item.HashValue); } DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] localFiles = dir.GetFiles("*", searchType); SortedList <string, bool> dirList = new SortedList <string, bool>(); foreach (FileInfo file in localFiles) { // skip files we're not interested in if (IsExcludedFile(file.FullName)) { continue; } dirList.Add(file.FullName, true); ProcessFile(itemList, file.FullName); } foreach (DirectoryInfo di in dir.GetDirectories("*", SearchOption.AllDirectories)) { dirList.Add(di.FullName, true); } if (!OptionDeleted) { return; } foreach (string key in itemList.Keys) { // skip files that exist or we're not interested in if (dirList.ContainsKey(key)) { continue; } if (IsExcludedFile(key)) { continue; } Console.WriteLine("Deleted: " + key); deletedFiles.Add(key); } }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (e.Cancel) { return; } string[] queryItems = (string[])e.Argument; ItemSpec[] array = new ItemSpec[queryItems.Length]; for (int i = 0; i < queryItems.Length; i++) { array[i] = new ItemSpec(VersionControlPath.Combine(queryItems[i], "*"), RecursionType.OneLevel); } ExtendedItem[][] itemSets; itemSets = m_workspace.GetExtendedItems(array, m_deletedState, ShowFiles ? ItemType.Any : ItemType.Folder, GetItemsOptions.IncludeBranchInfo); TempItemSet[] result = new TempItemSet[itemSets.Length]; for (int i = 0; i < itemSets.Length; i++) { result[i] = new TempItemSet { QueryPath = VersionControlPath.GetFolderName(array[i].Item), Items = itemSets[i].Where((item) => (item.TargetServerItem != queryItems[i] && (item.IsInWorkspace || !m_limitToWorkspace))).ToArray() }; } if (m_limitToWorkspace) { Workspace ws = m_workspace; ws.RefreshIfNeeded(); var folders = ws.Folders; foreach (TempItemSet its in result) { int desiredCloakDepth = VersionControlPath.GetFolderDepth(its.QueryPath) + 1; string cloakedWeSaw = null; List <ItemSpec> newItems = new List <ItemSpec>(); foreach (var fldr in folders) { if (fldr.IsCloaked && fldr.Depth != RecursionType.None && VersionControlPath.IsSubItem(fldr.ServerItem, its.QueryPath) && VersionControlPath.GetFolderDepth(fldr.ServerItem) == desiredCloakDepth) { cloakedWeSaw = fldr.ServerItem; } else if (!fldr.IsCloaked && cloakedWeSaw != null && VersionControlPath.IsSubItem(fldr.ServerItem, cloakedWeSaw)) { //we need this to keep going even if it's cloaked newItems.Add(new ItemSpec(cloakedWeSaw, RecursionType.None)); cloakedWeSaw = null; } } if (newItems.Count > 0) { ExtendedItem[] newExItems = new ExtendedItem[its.Items.Length + newItems.Count]; Array.Copy(its.Items, newExItems, its.Items.Length); ExtendedItem[][] tempExItems = m_sourceControl.GetExtendedItems(newItems.ToArray(), m_deletedState, ItemType.Folder, GetItemsOptions.IncludeBranchInfo); for (int i = 0; i < tempExItems.Length; i++) { newExItems[i + its.Items.Length] = tempExItems[i][0]; } its.Items = newExItems; } } } foreach (TempItemSet its in result) { Array.Sort(its.Items, (a, b) => a.TargetServerItem.CompareTo(b.TargetServerItem)); } e.Result = result; }
private Dictionary <string, TfsFileData> GetTFSProjectInfo(string Path, RecursionType RecursionLevel) { Dictionary <string, TfsFileData> TFSFileDataDict = new Dictionary <string, TfsFileData>(); WorkspaceInfo[] wsis = Workstation.Current.GetAllLocalWorkspaceInfo(); foreach (WorkspaceInfo wsi in wsis) { //Ensure that all this processing is for the current server. if (!wsi.ServerUri.DnsSafeHost.ToLower().Equals(collectionUrl.ToLower().Replace("http://", "").Split('/')[0])) { continue; } var workspaceName = wsi.Name; var owner = wsi.OwnerName; Workspace ws = GetWorkspace(wsi); ItemSet items = ws.VersionControlServer.GetItems(Path, RecursionType.Full); //ItemSet items = version.GetItems(@"$\ProjectName\FileName.cs", RecursionType.Full); foreach (Item item in items.Items) { if (item.ItemType == ItemType.Folder) { continue; } GetRequest request = new GetRequest(new ItemSpec(item.ServerItem, RecursionType.None), VersionSpec.Latest); GetStatus status = ws.Get(request, GetOptions.Preview); TfsFileData tfd = new TfsFileData(); if (status.NumOperations == 0) { tfd.IsLatest = "Yes"; } else { tfd.IsLatest = "No"; } TFSFileDataDict.Add(item.ServerItem.Substring(item.ServerItem.LastIndexOf("/") + 1).ToLower(), tfd); } ItemSpec[] itemSpecs = new ItemSpec[1]; itemSpecs[0] = new ItemSpec(Path, (RecursionType)RecursionType.OneLevel); PendingSet[] pendingSet = ws.VersionControlServer.QueryPendingSets( itemSpecs, workspaceName, owner, false); for (int i = 0; i < pendingSet.Length; i++) { for (int n = 0; n < pendingSet[i].PendingChanges.Length; n++) { if (TFSFileDataDict.ContainsKey(pendingSet[i].PendingChanges[n].FileName.ToLower())) { TfsFileData tfd = TFSFileDataDict[pendingSet[i].PendingChanges[n].FileName.ToLower()]; tfd.FileName = pendingSet[i].PendingChanges[n].FileName; tfd.CheckoutBy = pendingSet[i].OwnerName; tfd.Encoding = pendingSet[i].PendingChanges[n].EncodingName; tfd.IsAdd = pendingSet[i].PendingChanges[n].IsAdd.ToString(); tfd.IsLock = pendingSet[i].PendingChanges[n].IsLock.ToString(); } } } break; } return(TFSFileDataDict); }
public override void Run() { string path = Environment.CurrentDirectory; if (Arguments.Length > 0) { path = Path.GetFullPath(Arguments[0]); } if (File.Exists(path)) { // would need to fixup dir.GetDirectories calls if we wanted to support filenames Console.WriteLine("Error: This command only takes paths as arguments, not file names."); Environment.Exit((int)ExitCode.Failure); } char[] charsToTrim = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }; string itemPath = path.TrimEnd(charsToTrim); if (OptionWritable) { ShowWritableFiles(itemPath); Environment.Exit((int)ExitCode.Success); } Workspace workspace = GetWorkspaceFromCache(); workspace.RefreshMappings(); string serverPath = workspace.GetServerItemForLocalItem(itemPath); // process command options ItemSpec itemSpec = new ItemSpec(itemPath, RecursionType.Full); if (OptionOld) { ShowOldFiles(workspace, itemSpec); Environment.Exit((int)ExitCode.Success); } // pull item list based on WorkspaceVersion. otherwise might get // new items on server that haven't been pulled yet in the list returned WorkspaceVersionSpec version = new WorkspaceVersionSpec(workspace); ItemSet itemSet = VersionControlServer.GetItems(itemSpec, version, DeletedState.NonDeleted, ItemType.Any, true); Item[] items = itemSet.Items; SortedList <string, string> itemList = new SortedList <string, string>(PathComparer); foreach (Item item in items) { if (item.ServerItem.Length == serverPath.Length) { continue; } string serverItem = item.ServerItem.Remove(0, serverPath.Length + 1); // server item paths are separated with '/', but on windows the file list below has '\' separated paths if (Path.DirectorySeparatorChar != '/') { serverItem = serverItem.Replace('/', Path.DirectorySeparatorChar); } string fname = Path.Combine(itemPath, serverItem); string hash = ""; if (item.ItemType == ItemType.File && item.HashValue != null) { hash = Convert.ToBase64String(item.HashValue); } itemList.Add(fname, hash); } if (OptionOthers) { ShowOtherFiles(itemPath, itemList); } else if (OptionDeleted) { ShowDeletedFiles(itemPath, itemList); } else if (OptionModified) { ShowModifiedFiles(itemPath, itemList); } else { foreach (string key in itemList.Keys) { Driver.WriteLine(key); } } }
public ItemSpec AddSpec(ItemSpec spec) { _specs.Add(spec); return(spec); }
/// <summary> /// Création d'un label lors de la publication /// </summary> /// <param name="model"></param> private void CreateLabel(CandleModel model, string modelFileName) { if (model == null || modelFileName == null) { return; } try { DTE dte = GetService <DTE>(); string solutionFolder = Path.GetDirectoryName(modelFileName); // Récupère les caractèristiques du workspace contenant le fichier contenant le modèle if (Workstation.Current == null) { throw new Exception("TFS not installed"); } WorkspaceInfo wi = Workstation.Current.GetLocalWorkspaceInfo(solutionFolder); if (wi == null) { LogError("The current solution is not in a Team System workspace"); return; } // Récupèration du server TFS à partir des infos du workspace TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(wi.ServerUri.AbsoluteUri); // Création d'un label sur la solution VersionControlServer vcs = tfs.GetService(typeof(VersionControlServer)) as VersionControlServer; vcs.NonFatalError += new ExceptionEventHandler(vcs_NonFatalError); // On prend tous les fichiers de la solution ItemSpec itemSpec = new ItemSpec(solutionFolder, RecursionType.Full); LabelItemSpec labelItemSpec = new LabelItemSpec(itemSpec, VersionSpec.Latest, false); string changeSet = "-"; // Calcul du nom du label string labelName = String.Format(labelNameFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet); // Calcul du commentaire string labelComment = String.Format(labelCommentFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet); //Checkin if (forceCheckin) { Workspace ws = wi.GetWorkspace(tfs); PendingChange[] pendingChanges = ws.GetPendingChanges(new ItemSpec[] { itemSpec }, false); if (pendingChanges.Length > 0) { changeSet = ws.CheckIn(pendingChanges, labelComment).ToString(); // Mise à jour de l'explorateur de solution (icones) Microsoft.VisualStudio.Shell.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)dte); IVersionControlProvider versionControlProvider = (IVersionControlProvider)serviceProvider.GetService(typeof(IVersionControlProvider)); if (versionControlProvider != null) { versionControlProvider.RefreshStatus(); } // On intègre le changeset dans le commentaire labelName = String.Format(labelNameFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet); labelComment = String.Format(labelCommentFormat, DateTime.Now, wi.OwnerName, wi.Computer, model.Version, model.Version.Revision, changeSet); } } string scope; string label; LabelSpec.Parse(labelName, null, false, out label, out scope); VersionControlLabel vcl = new VersionControlLabel(vcs, label, null, scope, labelComment); // Et on applique le label. LabelResult[] results = vcs.CreateLabel(vcl, new LabelItemSpec[] { labelItemSpec }, childOption); } catch (Exception ex) { LogError(ex); nbErrors++; } if (nbErrors > 0 && stopOnError) { throw new PublishingException(); } }
void configTask() { if (taskdata.taskId == "random") { transform.Find("TaskName").GetComponent <Text> ().text = LanController.getString("randomTask").ToUpper(); } else { TaskItemSpec taskspec = taskdata.getTaskSpec(); transform.Find("TaskName").GetComponent <Text> ().text = LanController.getString(taskspec.name).ToUpper(); } for (int i = 0; i < requireGrid.transform.childCount; i++) { GameObject go = requireGrid.transform.GetChild(i).gameObject; Destroy(go); } for (int i = 0; i < rewardGrid.transform.childCount; i++) { GameObject to = rewardGrid.transform.GetChild(i).gameObject; Destroy(to); } requireList = taskdata.getRequireList(); rewardList = taskdata.getRewardList(); hasFinished = true; foreach (string id in requireList.Keys) { GameObject bt = Instantiate(requireRender); bt.GetComponent <RectTransform>().SetParent(requireGrid.GetComponent <RectTransform>()); bt.GetComponent <RectTransform>().localScale = Vector3.one; //调整大小 bt.GetComponent <RectTransform>().localPosition = Vector3.zero; //调整位置 bt.SetActive(true); TaskItem taskItem = requireList [id]; GameObject completeIcon = bt.transform.Find("CompletIcon").gameObject; int completeC = Mathf.Min(taskItem.finished, taskItem.total); bt.transform.Find("CompleteText").GetComponent <Text> ().text = completeC.ToString(); bt.transform.Find("TotalText").GetComponent <Text> ().text = "/" + taskItem.total.ToString(); if (taskItem.beFinished()) { completeIcon.SetActive(true); } else { completeIcon.SetActive(false); hasFinished = false; } ItemSpec spec = SpecController.getItemById(id); bt.transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + spec.name + "Icon"); } int t = (requireList.Count % 2) == 0 ? (requireList.Count / 2) : ((requireList.Count / 2) + 1); float h = t * 120 + (t - 1) * 10 + 20; requireGrid.GetComponent <RectTransform>().sizeDelta = new Vector2(requireGrid.GetComponent <RectTransform>().sizeDelta.x, h); requireGrid.transform.Translate(new Vector3(0, -h / 2, 0)); foreach (string key in rewardList.Keys) { GameObject bt = Instantiate(rewardRender); bt.GetComponent <RectTransform>().SetParent(rewardGrid.GetComponent <RectTransform>()); bt.GetComponent <RectTransform>().localScale = Vector3.one; //调整大小 bt.GetComponent <RectTransform>().localPosition = Vector3.zero; //调整位置 bt.SetActive(true); bt.transform.Find("Text").GetComponent <Text> ().text = "×" + rewardList[key].ToString(); if (key == "gem") { bt.transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + "gemIcon"); } else if (key == "coin") { bt.transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + "CoinIcon"); } else if (key == "bullet") { bt.transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + "BulletShopIcon"); } else if (key == "exp") { bt.transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + "ExpIcon"); } else if (key == "ship") { bt.transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + "PirateBoat"); } else { ItemSpec spec = SpecController.getItemById(key); bt.transform.Find("Icon").GetComponent <Image>().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + spec.name + "Icon"); } } if (hasFinished) { confirmButText.text = LanController.getString("complete").ToUpper(); } else { confirmButText.text = LanController.getString("confirm").ToUpper(); } }
// <QueryItems xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/ClientServices/03"> // <workspaceName>string</workspaceName> // <workspaceOwner>string</workspaceOwner> // <items> // <ItemSpec item="string" recurse="None or OneLevel or Full" did="int" /> // <ItemSpec item="string" recurse="None or OneLevel or Full" did="int" /> // </items> // <version /> // <deletedState>NonDeleted or Deleted or Any</deletedState> // <itemType>Any or Folder or File</itemType> // <generateDownloadUrls>boolean</generateDownloadUrls> // <options>int</options> // </QueryItems> public List<Item> QueryItems(string workspaceName, string workspaceOwner, ItemSpec[] itemSpecs, VersionSpec versionSpec, DeletedState deletedState, ItemType itemType, bool includeDownloadInfo) { var invoker = new SoapInvoker(this); var msg = invoker.CreateEnvelope("QueryItems"); if (!string.IsNullOrEmpty(workspaceName)) msg.Add(new XElement(MessageNs + "workspaceName", workspaceName)); if (!string.IsNullOrEmpty(workspaceOwner)) msg.Add(new XElement(MessageNs + "workspaceOwner", workspaceOwner)); msg.Add(new XElement(MessageNs + "items", itemSpecs.Select(itemSpec => itemSpec.ToXml(MessageNs + "ItemSpec")))); msg.Add(versionSpec.ToXml(MessageNs + "version")); msg.Add(new XElement(MessageNs + "deletedState", deletedState)); msg.Add(new XElement(MessageNs + "itemType", itemType)); msg.Add(new XElement(MessageNs + "generateDownloadUrls", includeDownloadInfo.ToLowString())); var result = invoker.InvokeResult(); return result.Descendants(MessageNs + "Item").Select(Item.FromXml).ToList(); }
public override bool Read() { bool read; if (this.first) { this.first = false; var parameters = this.command.Parameters; var path = (string)parameters["path"].Value; RecursionType recursion; var parameter = parameters.FirstOrDefault(p => p.ParameterName == "recursion"); if (parameter != null) { string recursionString = Database.GetValueOrDefault <string>(parameter.Value); recursion = Enum <RecursionType> .Parse(recursionString); } else { recursion = RecursionType.Full; } VersionControlServer versionControlServer = this.command.Connection.VersionControlServer; Workspace[] workspaces = versionControlServer.QueryWorkspaces(null, null, Environment.MachineName); Workspace workspace = null; WorkingFolder workingFolder = null; foreach (Workspace currentWorkspace in workspaces) { workingFolder = currentWorkspace.TryGetWorkingFolderForServerItem(path); if (workingFolder != null) { workspace = currentWorkspace; ItemSpec itemSpec = new ItemSpec(path, recursion); ExtendedItem[][] extendedItems = currentWorkspace.GetExtendedItems(new ItemSpec[] { itemSpec }, DeletedState.Any, ItemType.Any); this.items = extendedItems[0]; } } if (workingFolder == null) { throw new Exception($"Workspace not found for '{path}'"); } string name; if (workspace != null) { name = workspace.Name; } else { name = "(not found)"; } var queryForm = (QueryForm)DataCommanderApplication.Instance.MainForm.ActiveMdiChild; queryForm.AddInfoMessage(new InfoMessage(LocalTime.Default.Now, InfoMessageSeverity.Information, $"\r\nworkspace.Name: {name}\r\nworkingFolder.LocalItem: {workingFolder.LocalItem}")); } if (this.items != null && this.index < this.items.Length) { ExtendedItem item = this.items[this.index]; var values = new object[] { item.SourceServerItem, item.ChangeType.ToString(), item.LockOwner, item.LockStatus.ToString(), item.IsLatest, item.HasOtherPendingChange, item.VersionLatest, item.VersionLocal }; this.Values = values; read = true; this.index++; } else { read = false; } return(read); }
public List<Item> QueryItems(Workspace workspace, ItemSpec itemSpec, VersionSpec versionSpec, DeletedState deletedState, ItemType itemType, bool includeDownloadInfo) { if (workspace == null) return QueryItems(itemSpec, versionSpec, deletedState, itemType, includeDownloadInfo); return QueryItems(workspace.Name, workspace.OwnerName, new [] { itemSpec }, versionSpec, deletedState, itemType, includeDownloadInfo); }
public void AddLines(ISession session, IList <WHTransferLine> lines) { if (this.Status != WHTransferStatus.New) { log.WarnFormat("status of transfer order {0} is not New, lines can't be added", this.OrderNumber); throw new Exception(string.Format("移库单{0}不是新建状态,无法添加明细", this.OrderNumber)); } //检查 System.Text.StringBuilder builder = new System.Text.StringBuilder(); bool msghead = false; ItemSpec sku = null;; foreach (WHTransferLine line in lines) { msghead = false; sku = null; StockDetail sto = StockDetail.Retrieve(session, line.FromStockID); if (sto == null) { log.ErrorFormat("detail stock ID {0} not exists", line.FromStockID); throw new Exception(string.Format("库存明细ID {0}不存在", line.FromStockID)); } line.OrderNumber = this.OrderNumber; line.LineNumber = this.NextLineNumber(); line.SKUID = sto.SKUID; line.FromLocation = Cast.String(this.FromLocation, "").Trim().ToUpper(); line.ToLocation = Cast.String(this.ToLocation, "").Trim().ToUpper(); line.FromArea = Cast.String(sto.AreaCode).Trim().ToUpper(); line.FromSection = Cast.String(sto.SectionCode).Trim().ToUpper(); line.UnitID = 0; bool isAreaEmpty = false; if (string.IsNullOrEmpty(line.ToArea) || line.ToArea.Trim().Length <= 0) { if (!msghead) { if (sku == null) { sku = ItemSpec.Retrieve(session, sto.SKUID); } builder.Append(sku.BarCode).Append(":"); } builder.Append("移入库位为空;"); isAreaEmpty = true; } else if (!string.IsNullOrEmpty(line.ToSection) && line.ToSection.Trim().Length > 0) { WHSection section = WHSection.Retrieve(session, line.ToArea, line.ToSection); if (section == null) { if (!msghead) { if (sku == null) { sku = ItemSpec.Retrieve(session, sto.SKUID); } builder.Append(sku.BarCode).Append(":"); } builder.Append("移入库位").Append(line.ToArea).Append("中不存在货架").Append(line.ToSection).Append(";"); } } if (!isAreaEmpty && line.FromArea == Cast.String(line.ToArea).Trim().ToUpper() && line.FromSection == Cast.String(line.ToSection, "").Trim().ToUpper()) { if (sku == null) { sku = ItemSpec.Retrieve(session, sto.SKUID); } builder.Append(sku.BarCode).Append(":"); builder.Append("来源库位-货架与移入库位-货架一样;"); } } if (builder.Length > 0) { log.Warn(builder.ToString()); throw new Exception(builder.ToString()); } foreach (WHTransferLine line in lines) { line.Create(session); } this.Update(session, "CurrentLineNumber"); }
protected override Revision[] OnGetHistory(FilePath localFile, Revision since) { var workspace = this.GetWorkspaceByLocalPath(localFile); var serverPath = workspace.GetServerPathForLocalPath(localFile); ItemSpec spec = new ItemSpec(serverPath, RecursionType.None); ChangesetVersionSpec versionFrom = null; if (since != null) versionFrom = new ChangesetVersionSpec(((TFSRevision)since).Version); return this.VersionControlService.QueryHistory(spec, VersionSpec.Latest, versionFrom, null).Select(x => new TFSRevision(this, serverPath, x)).ToArray(); }
protected void mbar_ItemCommand(object sender, Magic.Web.UI.MagicItemEventArgs args) { if (args.CommandName == "save") { using (ISession session = new Session()) { try { string itemCode = this.txtItemCode.Text.Trim(); string itemStatus = this.ddlItemStatus.SelectedValue; string itemName = this.txtItemName.Text.Trim(); string itemDesc = this.txtItemSpec.Text.Trim(); if (this.IsNew) { //新增 ItemMaster master = new ItemMaster(); master.ItemCode = itemCode; //判断输入的itemCode是否重复 if (session.CreateEntityQuery <ItemMaster>().Where(Exp.Eq("ItemCode", itemCode)).Count() > 0) { WebUtil.ShowMsg(this, string.Format("辅料编号{0}已经存在", master.ItemCode), "错误"); return; } master.ItemType = ItemType.AssistantItem; master.ItemName = itemName; master.ItemDesc = itemDesc; session.BeginTransaction(); master.Create(session); ItemSpec spec = new ItemSpec(); spec.ItemID = master.ItemID; spec.ItemCode = itemCode; spec.Status = Cast.Enum <ItemSpecStatus>(itemStatus); spec.ColorCode = " "; spec.BarCode = itemCode; spec.OperateTime = DateTime.Now; spec.Operator = 0;// Magic.Security.SecuritySession.CurrentUser.UserId; spec.PubDate = DateTime.Now; spec.AvgMoveCost = 0; spec.EnableCost = true; spec.EnableOS = false; spec.Create(session); session.Commit(); } else { session.BeginTransaction(); ItemSpec spec = ItemSpec.Retrieve(session, this.SKUID); spec.Status = Cast.Enum <ItemSpecStatus>(itemStatus); spec.Update(session, "Status"); int itemID = spec.ItemID; ItemMaster master = ItemMaster.Retrieve(session, itemID); master.ItemName = itemName; master.ItemDesc = itemDesc; master.Update(session, "ItemName", "ItemDesc"); session.Commit(); } } catch (System.Exception e) { session.Rollback(); throw e; } } this.Response.Redirect(WebUtil.Param("return")); } }
public void ForceGetFile(string path, int changeset) { var item = new ItemSpec(path, RecursionType.None); DoUntilNoFailures(() => _workspace.Get(new GetRequest(item, changeset), GetOptions.Overwrite | GetOptions.GetAll)); }
/// <summary> /// Undo changes to unchanged files in the workspace /// </summary> /// <param name="workspace">Workspace</param> public static void UndoUnchanged(Workspace workspace) { //Get pending changes PendingChange[] pendingChanges = workspace.GetPendingChanges(); if (pendingChanges.Length == 0) { return; } var spec = new ChangesetVersionSpec(workspace.VersionControlServer.GetLatestChangesetId()); var sourceArray = ItemSpec.FromPendingChanges(pendingChanges); var pendingChangesItems = new ItemSet[0]; if (sourceArray.Length > 0) { pendingChangesItems = workspace.VersionControlServer.GetItems(sourceArray, spec, DeletedState.Any, ItemType.Any); } //Build redundant change list var itemsToUndo = new List <ItemSpec>(); var itemsToGet = new List <string>(); for (int j = 0; j < pendingChanges.Length; j++) { var pendingChange = pendingChanges[j]; if (pendingChange.IsAdd || pendingChange.IsDelete || pendingChange.IsMerge || (pendingChange.ChangeType & ~ChangeType.Lock) == ChangeType.Edit) { Item item = null; foreach (Item currentItem in pendingChangesItems[j].Items) { if (pendingChange.ItemType == currentItem.ItemType && (pendingChange.IsDelete || currentItem.DeletionId == 0)) { if (pendingChange.IsDelete && currentItem.DeletionId == 0) { item = null; break; } if (!pendingChange.IsDelete || item == null || currentItem.DeletionId >= item.DeletionId) { item = currentItem; } } } if (item != null) { bool additemToUndo = false; bool addItemToGet = false; if (pendingChange.ItemType == ItemType.File) { if (pendingChange.IsDelete) { additemToUndo = true; addItemToGet = true; TrackMessage(string.Format("{0}: {1}", pendingChange.ChangeTypeName, pendingChange.LocalItem)); } else if (IsMatchesContent(pendingChange.LocalItem, item.HashValue)) { additemToUndo = true; if (pendingChange.IsAdd || pendingChange.IsDelete) { addItemToGet = true; } TrackMessage(string.Format("{0} (contents match): {1}", pendingChange.ChangeTypeName, pendingChange.LocalItem)); } } else if (pendingChange.IsAdd || pendingChange.IsDelete) { additemToUndo = true; addItemToGet = true; TrackMessage(string.Format("{0}: {1}", pendingChange.ChangeTypeName, pendingChange.LocalItem)); } if (additemToUndo) { itemsToUndo.Add(new ItemSpec(pendingChange)); } if (addItemToGet) { itemsToGet.Add(pendingChange.LocalItem); } } } } if (itemsToUndo.Count == 0) { //No redundant pending changes TrackMessage("There are no redundant pending changes."); return; } //Undo redundant pending changes TrackMessage("Undoing redundant changes..."); workspace.Undo(itemsToUndo.ToArray()); if (itemsToGet.Count > 0) { //Force get undone adds TrackMessage("Forcing a get for undone adds and deletes..."); workspace.Get(itemsToGet.ToArray(), spec, RecursionType.None, GetOptions.GetAll | GetOptions.Overwrite); } }
private ItemSpec itemspec; //アイテムのスペック public Item(string name, ItemSpec spec) { this.itemname = name; this.itemspec = spec; }
public void CreateOrUpdateLines(ISession session, IList <StockInLine> lines) { if (this.Status != StockInStatus.New) { log.WarnFormat("order status is {0}, attemping to update lines is denied", this.Status.ToString()); throw new Exception("单据不是新建状态,不可以更新"); } bool needUpdateHead = false; foreach (StockInLine line in lines) { StockDetail sto = null; if (this.OrderTypeCode == StockInHead.ORD_TYPE_PRD_IN || this.OrderTypeCode == StockInHead.ORD_TYPE_ASSIST_IN) { sto = StockDetail.Retrieve(session, line.SKUID, line.LocationCode, line.AreaCode, line.SectionCode); if (sto == null) { sto = new StockDetail(); sto.LocationCode = line.LocationCode; sto.SKUID = line.SKUID; sto.AreaCode = line.AreaCode; sto.SectionCode = string.IsNullOrEmpty(line.SectionCode) ? " " : line.SectionCode; sto.LotNumber = " "; sto.StockQty = 0M; sto.FrozenQty = 0M; sto.Create(session); } } else { sto = StockDetail.Retrieve(session, line.StockDetailID); } if (sto == null) { log.ErrorFormat("add line for {0}, stock detail id {1} not exists", this.OrderNumber, line.StockDetailID); throw new Exception("库存项不存在"); } if ((this.OrderTypeCode == StockInHead.ORD_TYPE_ASSIST_OUT || this.OrderTypeCode == StockInHead.ORD_TYPE_PRD_OUT) && (line.Quantity > sto.StockQty - sto.FrozenQty)) { throw new Exception("领用数量超过可使用库存数量"); } if (!string.IsNullOrEmpty(line.LineNumber) && line.LineNumber.Trim().Length > 0) { //更新 line.RefQuantity = sto.StockQty; line.LocationCode = sto.LocationCode; line.AreaCode = sto.AreaCode; line.SectionCode = sto.SectionCode; line.StockDetailID = sto.StockDetailID; ItemSpec sku = ItemSpec.Retrieve(session, sto.SKUID); line.Price = sku.AvgMoveCost; line.Update(session, "LocationCode", "AreaCode", "SectionCode", "StockDetailID", "RefQuantity", "Quantity", "Price"); } else { //创建 line.OrderNumber = this.OrderNumber; line.LineNumber = this.NextLineNumber(); line.LocationCode = sto.LocationCode; line.AreaCode = sto.AreaCode; line.SectionCode = sto.SectionCode; line.StockDetailID = sto.StockDetailID; line.SKUID = sto.SKUID; line.UnitID = 0; line.RefQuantity = sto.StockQty; ItemSpec sku = ItemSpec.Retrieve(session, sto.SKUID); line.Price = sku.AvgMoveCost; line.Create(session); needUpdateHead = true; } } if (needUpdateHead) { this.Update(session, "CurrentLineNumber"); } }
public override int GetHashCode() { return(unchecked (ItemSpec.ToLowerInvariant().GetHashCode())); }
protected override void PerformModifications(ItemSpec target) { }
public string GetBranchNameForItem( string localFullPath, bool waitForConnection, CancellationToken cancellationToken, out Workspace workspace, out BranchObject branchObject) { workspace = null; branchObject = null; try { if (localFullPath.IsNullOrEmpty()) { return(null); } WaitForConnection(); if (cancellationToken.IsCancellationRequested) { return(null); } var info = Workstation.Current.GetLocalWorkspaceInfo(localFullPath); if (info == null) { return(null); } var serverName = info.ServerUri; var tfsSrv = Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(serverName); VersionControlServer vcs = (VersionControlServer)tfsSrv.GetService(typeof(VersionControlServer)); if (cancellationToken.IsCancellationRequested) { return(null); } workspace = vcs.TryGetWorkspace(localFullPath); if (workspace == null) { return(null); } var serverItem = workspace.GetServerItemForLocalItem(localFullPath); if (cancellationToken.IsCancellationRequested) { return(null); } var branchObjects = vcs.QueryRootBranchObjects(RecursionType.Full) .OrderBy(bo => bo.Properties.RootItem.Item) .Reverse(); var itemSpecs = new ItemSpec[] { new ItemSpec(serverItem, RecursionType.None) }; // for each itemSpec return BranchHistoryItem[] var branchHistory = vcs.GetBranchHistory(itemSpecs, VersionSpec.Latest); if (!branchHistory[0].Any()) { return(null); } if (cancellationToken.IsCancellationRequested) { return(null); } branchObject = (from bo in branchObjects where serverItem.StartsWith(bo.Properties.RootItem.Item) select bo). FirstOrDefault(); if (branchObject == null) { return(null); } var branchName = System.IO.Path.GetFileName(branchObject.Properties.RootItem.Item); if (cancellationToken.IsCancellationRequested) { return(null); } return(branchName); } catch (Exception ex) { // TODO: logging return(null); } }
/// <summary> /// <para>开始库存交易</para> /// <returns>执行成功返回true,否则将抛出异常</returns> /// </summary> /// <remarks> /// 1. 采购退货没有使用这个方式 /// </remarks> public static bool CommitWHTrans(ISession session, IWHTransHead transHead) { if (transHead == null) { throw new Exception("the order committed for wh transaction is null"); } if (string.IsNullOrEmpty(transHead.OrderTypeCode) || transHead.OrderTypeCode.Trim().Length <= 0) { throw new Exception(string.Format("the order {0}'s OrderTypeCode is null or empty", transHead.OrderNumber)); } OrderTypeDef orderTypeDef = OrderTypeDef.Retrieve(session, transHead.OrderTypeCode); if (orderTypeDef == null) { throw new Exception(string.Format("OrderTypeDef {0} not exists", transHead.OrderTypeCode)); } if (orderTypeDef.TransStepCount <= 0) { throw new Exception("transaction steps (TransStepCount) invalidate"); } int commitDate = Cast.Int(DateTime.Now.ToString("yyyyMMdd")), commitTime = Cast.Int(DateTime.Now.ToString("HHmm")); int lineNumber = 1; //交易主档 log.DebugFormat("to build transaction head for {0}...", transHead.OrderNumber); WHTransHead head = new WHTransHead(); #region 创建主档 head.TransOrderType = transHead.OrderTypeCode; head.TransOrderNumber = transHead.OrderNumber; head.RefOrderType = transHead.RefOrderType; head.RefOrderNumber = transHead.RefOrderNumber; head.OriginalOrderType = transHead.OriginalOrderType; head.OriginalOrderNumber = transHead.OrginalOrderNumber; head.CommitUser = transHead.CreateUser; head.CommitDate = commitDate; head.CommitTime = commitTime; head.TransDesc = transHead.Note; #endregion //交易明细 IList <WHTransLine> lines = new List <WHTransLine>(); IList <IWHTransLine> transLines = transHead.GetLines(session); if (transLines == null || transLines.Count <= 0) { transHead.AfterTransaction(session); log.Warn(orderTypeDef.TypeText + transHead.OrderNumber + " has no lines, the transaction finished"); return(true); } #region 创建明细 log.DebugFormat("to build transaction lines for {0}...", transHead.OrderNumber); foreach (IWHTransLine transLine in transLines) { for (int i = 0; i < orderTypeDef.TransStepCount; i++) { log.DebugFormat("line:{0}, trans step:{1}", transLine.LineNumber, i + 1); OrderTransDef orderTransDef = OrderTransDef.Retrieve(session, orderTypeDef.OrderTypeCode, i + 1); if (orderTransDef == null) { throw new Exception(string.Format(" transaction step {0} for order type {1} not exists", i + 1, transHead.OrderTypeCode)); } IList <WHTransLine> tempTransLine = new List <WHTransLine>(); if (transHead.PreLockStock) { //销售发货、换货发货,生成发货单的时候已经为每个发货明细分配好明细库位、货架、出库数量 // (可能一个发货明细从多个库位、货架出货,具体的分配明细在CRMSNLineINV中) //并且冻结明细库存。因此发货出库时除了出库操作外,需要恢复冻结的明细库存量 IList <IWHLockItem> lockItems = transLine.GetLockItem(session); if (lockItems == null || lockItems.Count <= 0) { log.DebugFormat("{0}{1} use pre-locked detail stock items", orderTypeDef.TypeText, transHead.OrderNumber); throw new Exception("no pre-locked detail stock items found"); } foreach (IWHLockItem li in lockItems) { log.DebugFormat("pre-locked item: trans type={0}, id={1}, ownerid={2}, area={3}, section={4}, qty={5}", transLine.TransTypeCode, li.StockDetailID, li.OwnerID, li.AreaCode, li.SectionCode, li.Quantity); TransItemWrapper wrapper = new TransItemWrapper( transLine.SKUID, transLine.UnitID, transLine.CurrencyCode, transLine.LineNumber, transLine.OriginalOrderLine, transLine.TaxValue, transLine.TransTypeCode, li.Quantity, transLine.UnQualifiedQty, transLine.Price, li.LocationCode, li.AreaCode, li.SectionCode, li.StockDetailID); tempTransLine.Add(BuildTransLine(session, wrapper, transHead, commitDate, commitTime, ref lineNumber, orderTransDef)); } } else if (transLine is IWHTransTransferLine) { //移库操作,从A移库到B,对应会配置2个交易明细 TransTypeDef tranTypeDef = TransTypeDef.Retrieve(session, orderTransDef.TransTypeCode); if (tranTypeDef.TransProperty == TransProperty.Out) //移库操作,出库部分 { IWHTransTransferLine transferLine = transLine as IWHTransTransferLine; log.DebugFormat("transfer order line - Out: trans type={0}, sku={1}, price={2}, qty={3}, area={4}, section={5}, stoid={6}", transLine.TransTypeCode, transLine.SKUID, transLine.Price, transLine.QualifiedQty, transLine.AreaCode, transLine.SectionCode, transferLine.FromStockID); TransItemWrapper wrapper = new TransItemWrapper( transLine.SKUID, transLine.UnitID, transLine.CurrencyCode, transLine.LineNumber, transLine.OriginalOrderLine, transLine.TaxValue, transLine.TransTypeCode, transLine.QualifiedQty, transLine.UnQualifiedQty, transLine.Price, transLine.LocationCode, transLine.AreaCode, transLine.SectionCode, transferLine.FromStockID); tempTransLine.Add(BuildTransLine(session, wrapper, transHead, commitDate, commitTime, ref lineNumber, orderTransDef)); } else if (tranTypeDef.TransProperty == TransProperty.In) //移库操作,入库部分 { IWHTransTransferLine transferLine = transLine as IWHTransTransferLine; log.DebugFormat("transfer order line - In: trans type={0}, sku={1}, price={2}, qty={3}, area={4}, section={5}", transLine.TransTypeCode, transLine.SKUID, transLine.Price, transLine.QualifiedQty, transferLine.ToArea, transferLine.ToSection); TransItemWrapper wrapper = new TransItemWrapper( transLine.SKUID, transLine.UnitID, transLine.CurrencyCode, transLine.LineNumber, transLine.OriginalOrderLine, transLine.TaxValue, transLine.TransTypeCode, transLine.QualifiedQty, transLine.UnQualifiedQty, transLine.Price, transferLine.ToLocation, transferLine.ToArea, transferLine.ToSection, 0); tempTransLine.Add(BuildTransLine(session, wrapper, transHead, commitDate, commitTime, ref lineNumber, orderTransDef)); } else { throw new Exception("Transfer Order Type does not support TransProperty " + tranTypeDef.TransProperty.ToString()); } } else //其它出入库操作 { int stoid = 0; if (transLine is IWHExactItem) { stoid = (transLine as IWHExactItem).StockDetailID; } log.DebugFormat("trans order line: trans type={0}, sku={1}, price={2}, qty={3}, area={4}, section={5}", transLine.TransTypeCode, transLine.SKUID, transLine.Price, transLine.QualifiedQty, transLine.AreaCode, transLine.SectionCode); TransItemWrapper wrapper = new TransItemWrapper( transLine.SKUID, transLine.UnitID, transLine.CurrencyCode, transLine.LineNumber, transLine.OriginalOrderLine, transLine.TaxValue, transLine.TransTypeCode, transLine.QualifiedQty, transLine.UnQualifiedQty, transLine.Price, transLine.LocationCode, transLine.AreaCode, transLine.SectionCode, stoid); tempTransLine.Add(BuildTransLine(session, wrapper, transHead, commitDate, commitTime, ref lineNumber, orderTransDef)); } foreach (WHTransLine line in tempTransLine) { lines.Add(line); } } } #endregion #region 更新库存表, 计算移动平均成本 //update ... set STOCK_QTY=STOCK_QTY+:qty,避免并发影响 //事务一个一个串行排队,应该不会造成库存量不准 log.DebugFormat("to update stock qty for {0}...", transHead.OrderNumber); DbSession dbSession = session.DbSession as DbSession; IDbCommand commandUpdate1 = dbSession.CreateSqlStringCommand("update INV_STOCK_SUM set USE_QTY=USE_QTY+:qty,LAST_UPDATE=sysdate where SKU_ID=:skuId"); IDbCommand commandInsert1 = dbSession.CreateSqlStringCommand("insert into INV_STOCK_SUM(SKU_ID,USE_QTY,FROZEN_QTY,LAST_UPDATE) values(:skuId,:qty,0,sysdate)"); IDbCommand commondUpdate2 = dbSession.CreateSqlStringCommand("update INV_STOCK_DETAIL set STOCK_QTY=STOCK_QTY+:qty,FROZEN_QTY=FROZEN_QTY+:fzqty where STOCK_DTL_ID=:dtlId"); IDbCommand cmdCheck = dbSession.CreateSqlStringCommand("select STOCK_QTY from INV_STOCK_DETAIL where STOCK_DTL_ID=:dtlId"); foreach (WHTransLine l in lines) { //计算移动平均成本的逻辑 TransTypeDef transDef = TransTypeDef.Retrieve(session, l.TransTypeCode); if (transDef.IsCostTrans) //成本交易才计算移动平均价 { //采购成本计算说明: //小规模纳税人,采购税率(进项税)不可以抵扣,即没有退税政策,不管税率多少都必须算作采购成本,所以单位采购成本即为采购价格 //一般纳税人有退税政策,不过涉及的因素比较多,比如对方是什么性质的企业,所开的发票是否可以退税等。企业规模增长,成为一般纳税人后, //采购收货由财务手工确定是否可以抵扣,抵扣的税率为多少 //一般采购成本需要考虑的其它费用包括:运杂费、运输途中的损耗、国外贸易的进口关税。采购差旅费一般记入管理费用 //系统实现: //流程: 采购下达采购订单=>仓库收货检验=>财务确定是否可抵扣、抵扣税率=>系统执行入库、计算商品移动平均成本 //1. 系统默认是不可以抵扣的,采购收货的抵扣税率设置为0 //2. 如果可以抵扣,财务选择收货抵扣税率,这种情况下采购成本计算公式为: (采购数量*采购单价)/(1+抵扣税率) //3. 如果一张采购单分多次送货、收货,财务先与供应商沟通所开发票是否可以退税抵扣,供应商在采购订单全部送货完毕后开发票, // 所开发票必须与先前确定的发票类型、金额保持一致,否则财务将发票退回供应商重开 // 只有最后一次收货之后供应商才会开发票,所以开票校验之类的动作必须能对应多次收货 //4. 对于国内贸易运杂费等其它因素可以不用考虑到采购成本中(因为一般金额比较小,财务可以手工记入相应费用分录中);但对于国际贸易则必须考虑运费、进口关税之类 if (l.TaxValue < 0) { l.TaxValue = 0; } decimal costAmt = l.TransQty * l.TransPrice / (1 + l.TaxValue); DataSet ds = session.CreateObjectQuery(@" select a.AvgMoveCost as AvgMoveCost,b.StockQty as StockQty from ItemSpec a left join StockSummary b on a.SKUID=b.SKUID where a.SKUID=?sku") .Attach(typeof(ItemSpec)).Attach(typeof(StockSummary)) .SetValue("?sku", l.SKUID, "a.SKUID") .DataSet(); decimal prevCost = Cast.Decimal(ds.Tables[0].Rows[0]["AvgMoveCost"], 0M), currentStock = Cast.Decimal(ds.Tables[0].Rows[0]["StockQty"], 0M); decimal currentCost = (prevCost * currentStock + costAmt) / (l.TransQty + currentStock); log.DebugFormat("new avg mov cost: {0}. old cost:{1}, old stock:{2}, trans amt:{3}, trans qty:{4}", currentCost, prevCost, currentStock, costAmt, l.TransQty); ItemSpec spec = new ItemSpec(); spec.SKUID = l.SKUID; spec.AvgMoveCost = currentCost; spec.ItemCost = currentCost; spec.Update(session, "AvgMoveCost", "ItemCost"); } //质检仓的出入库事件,不更新汇总库存表的库存量 if (!l.IsScrap && !l.IsQC && !l.IsNonFormal) { if (session.CreateEntityQuery <StockSummary>().Where(Exp.Eq("SKUID", l.SKUID)).Count() > 0) { log.DebugFormat("to update summary stock, sku:{0}, qty:{1}", l.SKUID, l.TransQty); commandUpdate1.Parameters.Clear(); dbSession.AddParameter(commandUpdate1, ":qty", EntityManager.GetEntityMapping(typeof(StockSummary)).GetPropertyMapping("StockQty").DbTypeInfo, l.TransQty); dbSession.AddParameter(commandUpdate1, ":skuId", EntityManager.GetEntityMapping(typeof(StockSummary)).GetPropertyMapping("SKUID").DbTypeInfo, l.SKUID); dbSession.ExecuteNonQuery(commandUpdate1); } else { log.DebugFormat("to create summary stock, sku:{0}, qty:{1}", l.SKUID, l.TransQty); commandInsert1.Parameters.Clear(); dbSession.AddParameter(commandInsert1, ":skuId", EntityManager.GetEntityMapping(typeof(StockSummary)).GetPropertyMapping("SKUID").DbTypeInfo, l.SKUID); dbSession.AddParameter(commandInsert1, ":qty", EntityManager.GetEntityMapping(typeof(StockSummary)).GetPropertyMapping("StockQty").DbTypeInfo, l.TransQty); dbSession.ExecuteNonQuery(commandInsert1); } } bool update = false; decimal qty = l.TransQty, fzqty = 0M; if (transHead.PreLockStock) { update = true; fzqty = l.TransQty; StockDetail stockDetail = StockDetail.Retrieve(session, l.StockDetailID); if (stockDetail != null) { l.BeforeTransQty = stockDetail.StockQty; } else { log.ErrorFormat("the locked sto dtl {0} for order {1}, line {2} not exists", l.StockDetailID, transHead.RefOrderNumber, l.RefOrderLine); throw new Exception("被冻结的库存明细" + l.StockDetailID.ToString() + "不存在"); } } else if (l.StockDetailID > 0) { StockDetail stockDetail = StockDetail.Retrieve(session, l.StockDetailID); if (stockDetail != null) { update = true; l.BeforeTransQty = stockDetail.StockQty; } else { log.ErrorFormat("sto dtl {0} for order {1}, line {2} not exists", l.StockDetailID, transHead.RefOrderNumber, l.RefOrderLine); throw new Exception("库存明细" + l.StockDetailID.ToString() + "不存在"); } } else { EntityQuery query = session.CreateEntityQuery <StockDetail>() .Where(Exp.Eq("SKUID", l.SKUID) & Exp.Eq("LocationCode", l.LocationCode) & Exp.Eq("AreaCode", l.AreaCode)) .And(Exp.Eq("SectionCode", string.IsNullOrEmpty(l.SectionCode) || l.SectionCode.Trim().Length <= 0 ? " " : l.SectionCode)) .SetLastOffset(1); if (l.HasLotControl && !string.IsNullOrEmpty(l.LotNumber) && l.LotNumber.Trim().Length > 0) { query.And(Exp.Eq("LotNumber", l.LotNumber)); } IList <StockDetail> stockDetails = query.List <StockDetail>(); if (stockDetails != null && stockDetails.Count > 0) { update = true; l.StockDetailID = stockDetails[0].StockDetailID; l.BeforeTransQty = stockDetails[0].StockQty; } } if (update) { log.DebugFormat("to update detail stock, sku:{0}, old qty:{1}, trans qty:{2}", l.SKUID, l.BeforeTransQty, l.TransQty); commondUpdate2.Parameters.Clear(); dbSession.AddParameter(commondUpdate2, ":qty", EntityManager.GetEntityMapping(typeof(StockDetail)).GetPropertyMapping("StockQty").DbTypeInfo, qty); dbSession.AddParameter(commondUpdate2, ":fzqty", EntityManager.GetEntityMapping(typeof(StockDetail)).GetPropertyMapping("FrozenQty").DbTypeInfo, fzqty); dbSession.AddParameter(commondUpdate2, ":dtlId", EntityManager.GetEntityMapping(typeof(StockDetail)).GetPropertyMapping("StockDetailID").DbTypeInfo, l.StockDetailID); dbSession.ExecuteNonQuery(commondUpdate2); } else { log.DebugFormat("to create detail stock, sku{0}, trans qty:{1}", l.SKUID, l.TransQty); l.BeforeTransQty = 0M; StockDetail sto = new StockDetail(); sto.SKUID = l.SKUID; sto.LocationCode = l.LocationCode; sto.AreaCode = l.AreaCode; sto.SectionCode = string.IsNullOrEmpty(l.SectionCode) || l.SectionCode.Trim().Length <= 0 ? " " : l.SectionCode; sto.LotNumber = string.IsNullOrEmpty(l.LotNumber) || l.LotNumber.Trim().Length <= 0 ? " " : l.LotNumber; sto.StockQty = l.TransQty; sto.Create(session); l.StockDetailID = sto.StockDetailID; } cmdCheck.Parameters.Clear(); dbSession.AddParameter(cmdCheck, ":dtlId", DbTypeInfo.Int32(), l.StockDetailID); decimal newStoQty = Cast.Decimal(dbSession.ExecuteScalar(cmdCheck)); if (newStoQty < 0M) { throw new Exception(string.Format("库存明细{0}将变成负数!不允许负库存!", l.StockDetailID)); } } #endregion #region 插入交易记录 //insert记录,不会存在并发冲突 head.Create(session); log.DebugFormat("wh trans head created: {0}", head.TransNumber); foreach (WHTransLine l in lines) { l.TransNumber = head.TransNumber; l.Create(session); } log.DebugFormat("{0} wh trans lines created", lines.Count); transHead.AfterTransaction(session); #endregion return(true); }
public ItemShapeShiftDefinition(ItemSpec sourceSpec, ModelId targetType, Color?targetColor) { SourceSpec = sourceSpec; TargetType = targetType; TargetColor = targetColor; }
private static WHTransLine BuildTransLine(ISession session, TransItemWrapper wrapper, IWHTransHead transHead, int commitDate, int commitTime, ref int lineNumber, OrderTransDef orderTransDef) { WHArea area = null; WHTransLine line = new WHTransLine(); line.LineNumber = lineNumber++; line.SKUID = wrapper.SKUID; line.TransDate = commitDate; line.TransTime = commitTime; line.UnitID = wrapper.UnitID; line.CurrencyCode = wrapper.CurrencyCode; line.RefOrderType = transHead.OrderTypeCode; line.RefOrderNumber = transHead.OrderNumber; line.RefOrderLine = wrapper.LineNumber; line.OriginalOrderType = transHead.OriginalOrderType; line.OriginalOrderNumber = transHead.OrginalOrderNumber; line.OriginalOrderLine = wrapper.OriginalOrderLine; line.TaxValue = wrapper.TaxValue; line.StockDetailID = wrapper.StockDetailID; ItemSpec itemSpec = ItemSpec.Retrieve(session, line.SKUID); line.AvgMoveCost = itemSpec.AvgMoveCost; //TODO: 目前只支持的配置实现方式有限 //交易类型 if (orderTransDef.StepType == TransStepType.Single) { if (orderTransDef.TransTypeFrom == TransTypeFrom.ConfigValue) { line.TransTypeCode = orderTransDef.TransTypeCode; } else if (orderTransDef.TransTypeFrom == TransTypeFrom.InterfaceValue) { line.TransTypeCode = wrapper.TransTypeCode; } else { throw new Exception(string.Format("WHTransaction: TransTypeFrom {0} not supported", (int)orderTransDef.TransTypeFrom)); } } else if (orderTransDef.StepType == TransStepType.MultiSelect) { if (orderTransDef.TransTypeFrom == TransTypeFrom.InterfaceValue) { line.TransTypeCode = wrapper.TransTypeCode; } else { throw new Exception(string.Format("WHTransaction: TransTypeFrom {0} not supported by TransStepType.MultiSelect", (int)orderTransDef.TransTypeFrom)); } } //交易数量 if (orderTransDef.TransQtyFrom == TransQtyFrom.QualifiedQty) { line.TransQty = wrapper.QualifiedQty; } else if (orderTransDef.TransQtyFrom == TransQtyFrom.UnQualifiedQty) { line.TransQty = wrapper.UnQualifiedQty; } else { throw new Exception(string.Format("WHTransaction: TransQtyFrom {0} not supported", (int)orderTransDef.TransQtyFrom)); } //交易仓库信息。LocationCode, AreaCode必须有,SectionCode可以有可以没有 if (orderTransDef.TransLocationFrom == TransLocationFrom.ConfigValue) { //从(交易-仓库配置)中取库房区域、货架信息 //不会从(产品-默认存储位置)读取,因为出入库单据如果用到(产品-默认存储位置),需要在界面提供选择,因此仓库获取类型变为TransLocationFrom.InterfaceValue IList <WHAreaCfg> areaCfg = WHAreaCfg.Retrieve(session, line.TransTypeCode); if (areaCfg == null || areaCfg.Count <= 0) { throw new Exception(string.Format("WHTransaction: area cfg does not exists for transaction type {0}", line.TransTypeCode)); } area = WHArea.Retrieve(session, areaCfg[0].AreaCode); if (area == null) { throw new Exception(string.Format("WHTransaction: area {0} does not exist", areaCfg[0].AreaCode)); } line.LocationCode = area.LocationCode; line.AreaCode = area.AreaCode; } else if (orderTransDef.TransLocationFrom == TransLocationFrom.InterfaceValue) { if (string.IsNullOrEmpty(wrapper.LocationCode) || wrapper.LocationCode.Trim().Length <= 0 || string.IsNullOrEmpty(wrapper.AreaCode) || wrapper.AreaCode.Trim().Length <= 0) { throw new Exception(string.Format("WHTransaction: LocationCode or AreaCode is empty in transaction order line {0}", wrapper.LineNumber)); } line.LocationCode = wrapper.LocationCode; line.AreaCode = wrapper.AreaCode; line.SectionCode = wrapper.SectionCode; } else { throw new Exception(string.Format("WHTransaction: TransLocationFrom {0} not supported", (int)orderTransDef.TransLocationFrom)); } area = WHArea.Retrieve(session, line.AreaCode); if (area == null) { throw new Exception(string.Format("WHTransaction: invalidate AreaCode {0}", line.AreaCode)); } //如果库位被锁定(例如正在进行盘点作业)则不允许交易 if (area.IsLocked && orderTransDef.TransTypeCode != "301") //盘点的交易类型为301 { throw new Exception("库位" + area.AreaCode + "-" + area.Name + "正在盘点,无法执行出入库操作"); } line.IsScrap = area.IsScrap; line.IsQC = area.IsQC; line.IsNonFormal = area.IsNonFormal; TransTypeDef transTypeDef = TransTypeDef.Retrieve(session, orderTransDef.TransTypeCode); if (transTypeDef == null) { throw new Exception(string.Format("WHTransaction: invalidate transaction type code {0}", orderTransDef.TransTypeCode)); } line.TransQty = line.TransQty * ((int)transTypeDef.TransProperty); //交易描述 line.TransReason = transTypeDef.TransDefText; if (!string.IsNullOrEmpty(transTypeDef.TransDefDesc) && transTypeDef.TransDefDesc.Trim().Length > 0) { line.TransReason = line.TransReason + " - " + transTypeDef.TransDefDesc; } //交易价格 if (transTypeDef.PriceSourceType == TransTypePriceSource.FromSourceOrder) { line.TransPrice = wrapper.Price; } else if (transTypeDef.PriceSourceType == TransTypePriceSource.FromMovAvgCost) { line.TransPrice = itemSpec.AvgMoveCost; } else if (transTypeDef.PriceSourceType == TransTypePriceSource.FromAreaCfg) { if (!area.UseFixCost || area.CostFixValue < 0M) { throw new Exception(string.Format("WHTransaction: TransTypePriceSource is FromAreaCfg, but it does not exists in AreaCode {0}", area.AreaCode)); } line.TransPrice = area.CostFixValue; } line.TransPrice = line.TransPrice * area.CostTransRate - area.FixedComsumeValue; if (line.TransPrice < 0M) { line.TransPrice = 0M; } //if ((line.TransTypeCode == "101" || line.TransTypeCode == "301") && itemSpec.EnableOS) //{ // itemSpec.EnableOS = false; // itemSpec.Update(session, "EnableOS"); //} log.DebugFormat("trans line built: trans type:{0}, qty={1}, area={2}, section={3}, price={4}", line.TransTypeCode, line.TransQty, line.AreaCode, line.SectionCode, line.TransPrice); return(line); }
void OnGet(object sender, System.EventArgs e) { var requests = new List<GetRequest>(); for (int row = 0; row < listStore.RowCount; row++) { var isChecked = listStore.GetValue(row, isSelectedField); if (isChecked) { var item = listStore.GetValue(row, itemField); var spec = new ItemSpec(item.ServerPath, item.ItemType == ItemType.File ? RecursionType.None : RecursionType.Full); var version = (int)versionBox.SelectedItem == 0 ? new ChangesetVersionSpec(Convert.ToInt32(changeSetNumber.Value)) : VersionSpec.Latest; requests.Add(new GetRequest(spec, version)); if (forceGet.State == CheckBoxState.On) { workspace.ResetDownloadStatus(item.ItemId); } } } var option = GetOptions.None; if (forceGet.State == CheckBoxState.On) { option |= GetOptions.GetAll; } // if (overrideGet.State == CheckBoxState.On) // option |= GetOptions.Overwrite; using (var progress = VersionControlService.GetProgressMonitor("Get", VersionControlOperationType.Pull)) { progress.Log.WriteLine("Start downloading items. GetOption: " + option); foreach (var request in requests) { progress.Log.WriteLine(request); } workspace.Get(requests, option, progress); progress.ReportSuccess("Finish Downloading."); } Respond(Command.Ok); }
// performs the modifications to the item spec passed in according to any requirements // the net result will be registered as a new type. protected abstract void PerformModifications(ItemSpec target);
public List<Item> QueryItems(ItemSpec itemSpec, VersionSpec versionSpec, DeletedState deletedState, ItemType itemType, bool includeDownloadInfo) { return QueryItems(string.Empty, string.Empty, new [] { itemSpec }, versionSpec, deletedState, itemType, includeDownloadInfo); }
private void DoFullGet() { try { #if DEBUG Thread.Sleep(5000); #endif Configuration = new Config(); Configuration.Init(); var cts = new CancellationTokenSource(); $"Get info for all TPCs and all projects".Info(); var sw = new Stopwatch(); sw.Start(); var lpc = GetTeamProjectCollections().AsParallel(); Func <TfsTeamProjectCollection, string> workspaceName = projColl => { var str = $"{Guid.NewGuid()}_{projColl.GetProjectCollectionName()}"; $"workspaceName: {str}".Trace(); return(str); }; Func <VersionControlServer, string, Workspace> createWorkSpace = (vcs, wsName) => { try { if (vcs.DeleteWorkspace(wsName, vcs.AuthorizedUser)) { // TODO log } } catch (Exception e) { $"createWorkspace: {e.Message}".Error(); } try { var options = new CreateWorkspaceParameters(wsName) { WorkspaceOptions = WorkspaceOptions.None, OwnerName = vcs.AuthorizedUser, Location = WorkspaceLocation.Server }; var workSpace = vcs.CreateWorkspace(options); $"Workspace created: {workSpace.Name}".Trace(); return(workSpace); } catch (Exception e) { $"createWorkspace: {e.Message}".Error(); throw; } }; Action <TfsTeamProjectCollection> dropWorkspaces = collection => { try { var vcs = collection.GetService <VersionControlServer>(); var wss = vcs.QueryWorkspaces(null, vcs.AuthorizedUser, Environment.MachineName); foreach (var workspace in wss) { if (!workspace.Delete()) { $"Failed to delete {workspace.Name}".Error(); } else { $"Deleted {workspace.Name}".Info(); } } } catch (Exception e) { e.Error(); throw; } }; Action <TfsTeamProjectCollection> dropMappings = (collection) => { try { var vcs = collection.GetService <VersionControlServer>(); var wss = vcs.QueryWorkspaces(null, vcs.AuthorizedUser, null); var localPath = collection.GetProjectCollectionLocalPath(Globals.TfsRoot); var withPath = wss.Select(workspace => Tuple.Create(workspace, workspace.TryGetWorkingFolderForServerItem(collection.Uri.AbsoluteUri))); foreach (var tuple in withPath) { if (tuple.Item1 != null && tuple.Item2 != null) { $"Dropping {tuple.Item2.LocalItem} for workspace {tuple.Item1.Name}".Info(); tuple.Item1.DeleteMapping(tuple.Item2); } } } catch (Exception e) { e.Error(); } }; Func <Workspace, TfsTeamProjectCollection, Workspace> mapWorkspace = (ws, pc) => { try { var serverPath = "$/"; var localPath = pc.GetProjectCollectionLocalPath(Globals.TfsRoot); $"mapWorkspace: {nameof(serverPath)} = {serverPath}".Trace(); $"mapWorkspace: {nameof(localPath)} = {localPath}".Trace(); var vcs = pc.GetService <VersionControlServer>(); var lws = Workstation.Current.RemoveCachedWorkspaceInfo(vcs); var wss = vcs.QueryWorkspaces(null, vcs.AuthorizedUser, null); foreach (var workspace in wss) { $"Checking workspace {workspace.Name} for mapping of local path {localPath}".Info(); if (workspace.IsLocalPathMapped(localPath)) { var wf = workspace.TryGetWorkingFolderForLocalItem(localPath); workspace.DeleteMapping(wf); $"Deleted {localPath} mapping from workspace {workspace.Name}".Info(); } } ws.Map(serverPath, localPath); return(ws); } catch (Exception e) { e.Error(); } return(null); }; // get the workspaces for this user on this machine and their working folders, if any, for the project collection they belong to var pcsAndAllTheirWorkspaces = from pc in lpc.AsParallel() let vcs = pc.GetService <VersionControlServer>() let localPath = pc.GetProjectCollectionLocalPath(Globals.TfsRoot) select new { LocalPath = localPath, VersionControlServer = vcs, ProjectCollection = pc, WorkspaceAndWorkingFolderList = vcs .QueryWorkspaces(null, vcs.AuthorizedUser, null) .Where(workspace => workspace.Computer.Equals(Environment.MachineName, StringComparison.OrdinalIgnoreCase)) .Select(workspace => Tuple.Create(workspace, workspace.TryGetWorkingFolderForLocalItem(localPath))) }; $"{nameof(pcsAndAllTheirWorkspaces)}: {string.Join(",", pcsAndAllTheirWorkspaces.Select(arg => arg.LocalPath))}".Trace(); $"{nameof(pcsAndAllTheirWorkspaces)}: {string.Join(",", pcsAndAllTheirWorkspaces.Select(arg => arg.WorkspaceAndWorkingFolderList.Count()))}".Trace(); // select the relevant information from the above gross and create workspace and mapping where necessary var pcsAndMappedWorkspaces = from a in pcsAndAllTheirWorkspaces let workspaceAndFolder = a.WorkspaceAndWorkingFolderList.SingleOrDefault(tuple => tuple.Item2 != null) let name = workspaceAndFolder?.Item1.Name ?? workspaceName(a.ProjectCollection) let workspace = workspaceAndFolder?.Item1 ?? mapWorkspace(createWorkSpace(a.VersionControlServer, name), a.ProjectCollection) let workingFolder = workspaceAndFolder?.Item2 ?? workspace.TryGetWorkingFolderForLocalItem(a.LocalPath) select new { a.ProjectCollection, a.VersionControlServer, Workspace = workspace, WorkingFolder = workingFolder }; $"{nameof(pcsAndMappedWorkspaces)}: {string.Join(",", pcsAndMappedWorkspaces.Select(arg => arg.WorkingFolder.LocalItem))}".Trace(); var allProjects = from p in pcsAndMappedWorkspaces from pp in p.ProjectCollection.GetTeamProjects() let sp = pp.GetProjectServerPath(p.ProjectCollection) let wf = p.Workspace.TryGetWorkingFolderForServerItem(sp) where wf.LocalItem.ToLowerInvariant().Contains(Configuration.SourceRoot.ToLowerInvariant()) select new { ProjectCollection = p, Project = pp, LocalPath = pp.GetProjectLocalPath(p.ProjectCollection), ServerPath = sp, WorkspaceInfo = p.Workspace, WorkingFolder = wf }; $"{nameof(allProjects)}: {string.Join(",", allProjects.Select(arg => arg.LocalPath))}".Trace(); var filterStats = new Dictionary <StatTypes, int> { [StatTypes.Added] = 0, [StatTypes.Deleted] = 0, [StatTypes.Ignored] = 0, [StatTypes.Skipped] = 0 }; string[] exceptions = { @"vnext", @"-oem" }; string[] exclusions = { @"/development/", @"/release/", @"/team/" }; var maxAge = TimeSpan.FromHours(6.0); var fc = new GetFilterCallback((Workspace workspace, ILocalUpdateOperation[] operations, object userData) => { var spec = userData as ItemSpec; $"TFS filter callback: workspace name = {workspace.Name} | spec.item = {spec.Item} | number of operations {operations.Length}".Trace(); foreach (var operation in operations) { if ( operation.TargetServerItem != null && exclusions.Any(s1 => operation.TargetServerItem.ToLowerInvariant().Contains(s1)) && !exceptions.Any(s2 => operation.TargetServerItem.ToLowerInvariant().Contains(s2))) { operation.Ignore = true; filterStats[StatTypes.Skipped]++; } if ( operation.SourceLocalItem != null && File.Exists(operation.SourceLocalItem) && (DateTime.UtcNow - File.GetLastWriteTimeUtc(operation.SourceLocalItem) < maxAge) ) { filterStats[StatTypes.Skipped]++; operation.Ignore = true; } if (operation.TargetLocalItem == null) { filterStats[StatTypes.Deleted]++; } filterStats[StatTypes.Added]++; } }); $"Getting all files from {allProjects.Count()} projects".Trace(); // get all the files allProjects.AsParallel().WithDegreeOfParallelism(1).ForAll(obj => { var subs = obj.ProjectCollection.VersionControlServer.GetItems($"{obj.WorkingFolder.ServerItem}/*"); for (int i = 0; i < subs.Items.Length; i++) { foreach (var ext in Extensions) { $"get files: {nameof(ext)} = {ext}".Trace(); var pattern = $"{subs.Items[i].ServerItem}/*.{ext}"; var itemSpec = new ItemSpec(pattern, RecursionType.Full); var getRequest = new GetRequest(itemSpec, VersionSpec.Latest); $"get files: {nameof(pattern)} = {pattern}".Trace(); $"get files: {nameof(itemSpec)} = {itemSpec.Item}".Trace(); try { obj.WorkspaceInfo.Get(getRequest, GetOptions.GetAll, fc, itemSpec); } catch (Exception e) { e.Error(); } } } }); sw.Stop(); $"Finished get info for all TPCs and all projects. Time elapsed: {sw.ElapsedMilliseconds.ToString("F")}".Info(); } catch (Exception e) { e.Error(); throw; } }
public List<ExtendedItem> QueryItemsExtended(Workspace workspace, ItemSpec itemSpec, DeletedState deletedState, ItemType itemType) { if (workspace == null) return QueryItemsExtended(string.Empty, string.Empty, new List<ItemSpec> { itemSpec }, deletedState, itemType); return QueryItemsExtended(workspace.Name, workspace.OwnerName, new List<ItemSpec> { itemSpec }, deletedState, itemType); }
protected override void PerformModifications(ItemSpec target) { _materialModification.Apply(target); }
public List<Changeset> QueryHistory(ItemSpec item, VersionSpec versionItem, VersionSpec versionFrom, VersionSpec versionTo, int maxCount = short.MaxValue) { var invoker = new SoapInvoker(this); var msg = invoker.CreateEnvelope("QueryHistory"); msg.Add(item.ToXml(MessageNs + "itemSpec")); msg.Add(versionItem.ToXml(MessageNs + "versionItem")); if (versionFrom != null) msg.Add(versionFrom.ToXml(MessageNs + "versionFrom")); if (versionTo != null) msg.Add(versionTo.ToXml(MessageNs + "versionTo")); msg.Add(new XElement(MessageNs + "maxCount", maxCount)); msg.Add(new XElement(MessageNs + "includeFiles", false)); msg.Add(new XElement(MessageNs + "generateDownloadUrls", false)); msg.Add(new XElement(MessageNs + "slotMode", false)); msg.Add(new XElement(MessageNs + "sortAscending", false)); var result = invoker.InvokeResult(); return result.Elements(MessageNs + "Changeset").Select(Changeset.FromXml).ToList(); }
public Changeset[] QueryHistory(string tfsUrl, ICredentials credentials, string workspaceName, string workspaceOwner, ItemSpec itemSpec, VersionSpec versionItem, string user, VersionSpec versionFrom, VersionSpec versionTo, int maxCount, bool includeFiles, bool generateDownloadUrls, bool slotMode) { return(WrapWebException <Changeset[]>(delegate { Repository webSvc = CreateProxy(tfsUrl, credentials); return webSvc.QueryHistory(workspaceName, workspaceOwner, itemSpec, versionItem, user, versionFrom, versionTo, maxCount, includeFiles, generateDownloadUrls, slotMode); })); }
protected override void OnRevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor) { var spec = new ItemSpec(localPath, localPath.IsDirectory ? RecursionType.Full : RecursionType.None); var rev = (TFSRevision)revision; var request = new GetRequest(spec, new ChangesetVersionSpec(rev.Version)); var workspace = GetWorkspaceByLocalPath(localPath); if (workspace != null) { workspace.Get(request, GetOptions.None, monitor); cache.RefreshItem(localPath); } }
public GetRequest(ItemSpec itemSpec, VersionSpec versionSpec) { this.ItemSpec = itemSpec; this.VersionSpec = versionSpec; }