private FolderMetaData GetFolderInfo(TFSSourceControlProvider sourceControlProvider,
                                      string depth,
                                      string path,
                                      int?version,
                                      bool loadPropertiesFromFile)
 {
     if (depth == "0")
     {
         FolderMetaData folderInfo = new FolderMetaData();
         ItemMetaData   item       =
             GetItems(sourceControlProvider, version.HasValue ? version.Value : -1, path, Recursion.None, loadPropertiesFromFile);
         folderInfo.Items.Add(item);
         return(folderInfo);
     }
     else if (depth == "1")
     {
         FolderMetaData data =
             (FolderMetaData)GetItems(sourceControlProvider, version.HasValue ? version.Value : -1, path, Recursion.OneLevel, loadPropertiesFromFile);
         return(data);
     }
     else
     {
         throw new InvalidOperationException(String.Format("Depth not supported: {0}", depth));
     }
 }
Example #2
0
 public Trousers(ItemMetaData meta = null) : base(new ItemTag[] { ItemTag.ARMOR, ItemTag.ITEM }, meta)
 {
     if (MetaData == null)
     {
         MetaData = new ItemMetaData().SetColor(Color.red);
     }
 }
        private void WriteWrkResponse(TFSSourceControlProvider sourceControlProvider,
                                      string requestPath,
                                      string depth,
                                      PropData data,
                                      Stream outputStream)
        {
            string activityId = requestPath.Split('/')[3];

            if (depth != "0")
            {
                throw new InvalidOperationException(String.Format("Depth not supported: {0}", depth));
            }
            string       path = requestPath.Substring(11 + activityId.Length);
            ItemMetaData item = sourceControlProvider.GetItemInActivity(activityId, Helper.Decode(path));

            if (item == null)
            {
                throw new FileNotFoundException("Unable to find file '" + path + "'in the specified activity", path);
            }

            using (StreamWriter writer = new StreamWriter(outputStream))
            {
                writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
                WriteMultiStatusStart(writer, data.Properties);
                INode node = new FileNode(item, sourceControlProvider);
                WriteProperties(node, data.Properties, writer, item.ItemType == ItemType.Folder);
                writer.Write("</D:multistatus>\n");
            }
        }
Example #4
0
        private string StripBasePath(ItemMetaData item, string basePath)
        {
            string name = item.Name;

            if (name.StartsWith("/"))
            {
                name = name.Substring(1);
            }

            if (basePath.StartsWith("/"))
            {
                basePath = basePath.Substring(1);
            }

            basePath = basePath + "/";

            if (name.StartsWith(basePath))
            {
                name = name.Substring(basePath.Length);
                if (name.StartsWith(@"/"))
                {
                    name = name.Substring(1);
                }
            }
            return(name);
        }
Example #5
0
        private bool Put(TFSSourceControlProvider sourceControlProvider, string path, Stream inputStream, string baseHash, string resultHash)
        {
            if (!path.StartsWith("//"))
            {
                path = "/" + path;
            }

            string activityId = path.Substring(11, path.IndexOf('/', 11) - 11);
            string serverPath = Helper.Decode(path.Substring(11 + activityId.Length));

            byte[] sourceData = new byte[0];
            if (baseHash != null)
            {
                ItemMetaData item = sourceControlProvider.GetItemInActivity(activityId, serverPath);
                sourceData = sourceControlProvider.ReadFile(item);
                if (ChecksumMismatch(baseHash, sourceData))
                {
                    throw new Exception("Checksum mismatch with base file");
                }
            }
            byte[] fileData = SvnDiffParser.ApplySvnDiffsFromStream(inputStream, sourceData);
            if (fileData.Length > 0)
            {
                if (ChecksumMismatch(resultHash, fileData))
                {
                    throw new Exception("Checksum mismatch with new file");
                }
            }
            return(sourceControlProvider.WriteFile(activityId, serverPath, fileData));
        }
Example #6
0
 public Shirt(ItemMetaData meta = null) : base(new ItemTag[] { ItemTag.ARMOR, ItemTag.ITEM }, meta)
 {
     if (MetaData == null)
     {
         MetaData = new ItemMetaData().SetColor(Color.yellow);
     }
 }
 public virtual void ReadFileAsync(ItemMetaData item, Guid repositoryUuid)
 {
     byte[] data = GetFile(item, repositoryUuid);
     item.Base64DiffData = SvnDiffParser.GetBase64SvnDiffData(data);
     item.Md5Hash        = Helper.GetMd5Checksum(data);
     item.DataLoaded     = true;
 }
 public BcFileNode(int requestVersion,
                   ItemMetaData item,
                   TFSSourceControlProvider sourceControlProvider)
 {
     this.requestVersion = requestVersion;
     this.item           = item;
     node = new FileNode(item, sourceControlProvider);
 }
        protected ItemMetaData QueryItems(string path, int version, Recursion recursion)
        {
            version = version == -1 ? GetSDKObject().GetLastestVersionNum(path) : version;
            int max = GetSDKObject().GetLastestVersionNum(path);

            if (version > max)
            {
                version = max;
            }

            FolderMetaData folder = new FolderMetaData();

            folder.Name             = path;
            folder.ItemRevision     = version;
            folder.LastModifiedDate = System.DateTime.Now;

            var result = GetSDKObject().EnumItems(path, version);

            if (result == null) // may be a file?
            {
                ItemMetaData item = new ItemMetaData();
                item.Name             = path;
                item.ItemRevision     = version;
                item.LastModifiedDate = System.DateTime.Now;
                return(item);
            }
            else
            {
                for (int i = 0; i < result.Count; i++)
                {
                    string name = result[i].name.Remove(0, 1);
                    //if (name != null && name[0] == '$') name = name.Substring(1, name.Length - 1);
                    //name = "/" + GetSDKObject().GetCurRepository() + name;
                    ItemMetaData item;
                    if (result[i].isdir && (recursion != Recursion.None))
                    {
                        if (recursion == Recursion.OneLevel)
                        {
                            item = QueryItems(name, result[i].version, Recursion.None);
                        }
                        else
                        {
                            item = QueryItems(name, result[i].version, recursion);
                        }
                    }
                    else
                    {
                        item = new ItemMetaData();
                    }
                    item.Name             = name;
                    item.ItemRevision     = result[i].version;
                    item.LastModifiedDate = result[i].date;
                    folder.Items.Add(item);
                }
            }

            return(folder);
        }
        private void HandleAllProp(TFSSourceControlProvider sourceControlProvider, string requestPath, Stream outputStream)
        {
            int    revision;
            string path;
            bool   bcPath = false;

            if (requestPath.StartsWith("/!svn/bc"))
            {
                bcPath   = true;
                revision = int.Parse(requestPath.Split('/')[3]);
                path     = requestPath.Substring("/!svn/bc/".Length + revision.ToString().Length);
            }
            else
            {
                const string latestVersion = "Repository.Latest.Version";
                if (RequestCache.Items[latestVersion] != null)
                {
                    revision = (int)RequestCache.Items[latestVersion];
                }
                else
                {
                    revision = GetSDKObject().GetLastestVersionNum(requestPath);
                }
                //    revision = sourceControlProvider.GetItems(-1, requestPath, Recursion.None).Revision;
                path = requestPath;
            }

            ItemMetaData item = GetItems(sourceControlProvider, revision, path, Recursion.None, true);

            if (item == null)
            {
                if (IsSvnRequestForProjectCreation(path, revision, sourceControlProvider))
                {
                    item      = GetItems(sourceControlProvider, revision, "", Recursion.None, true);
                    item.Name = "trunk";
                }

                if (item == null)
                {
                    throw new FileNotFoundException("There is no item " + requestPath + " in revision " + revision);
                }
            }

            using (StreamWriter writer = new StreamWriter(outputStream))
            {
                if (item.ItemType == ItemType.Folder)
                {
                    WriteAllPropForFolder(writer, requestPath, item, bcPath, sourceControlProvider);
                }
                else
                {
                    //   WriteAllPropForItem(writer, requestPath, item, sourceControlProvider.ReadFile(item), sourceControlProvider);
                    WriteAllPropForItem(writer, requestPath, item, new byte[1], sourceControlProvider);
                }
            }
        }
Example #11
0
 public MaterialDataItem(ItemMetaData itemMetaData)
 {
     base.uid       = 0;
     this._metaData = itemMetaData;
     base.ID        = this._metaData.ID;
     base.rarity    = this._metaData.rarity;
     base.level     = 1;
     base.exp       = 0;
     base.number    = 1;
 }
        private void WriteAllPropForFolder(TextWriter writer, string requestPath, ItemMetaData item, bool bcPath, TFSSourceControlProvider sourceControlProvider)
        {
            writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
            if (bcPath)
            {
                writer.Write("<D:multistatus xmlns:D=\"DAV:\" xmlns:ns0=\"DAV:\">\n");
            }
            else
            {
                writer.Write("<D:multistatus xmlns:D=\"DAV:\" xmlns:ns2=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ns1=\"http://www.w3.org/2001/XMLSchema\" xmlns:ns0=\"DAV:\">\n");
            }
            writer.Write("<D:response xmlns:S=\"http://subversion.tigris.org/xmlns/svn/\" xmlns:C=\"http://subversion.tigris.org/xmlns/custom/\" xmlns:V=\"http://subversion.tigris.org/xmlns/dav/\" xmlns:lp1=\"DAV:\" xmlns:lp2=\"http://subversion.tigris.org/xmlns/dav/\">\n");
            writer.Write("<D:href>" + Helper.Encode(requestPath) + "/</D:href>\n");
            writer.Write("<D:propstat>\n");
            writer.Write("<D:prop>\n");
            foreach (var prop in item.Properties)
            {
                if (prop.Key.StartsWith("svn:"))
                {
                    writer.Write("<S:" + prop.Key.Substring(4) + ">" + prop.Value + "</S:" + prop.Key.Substring(4) + ">\n");
                }
                else
                {
                    writer.Write("<C:" + prop.Key + ">" + prop.Value + "</C:" + prop.Key + ">\n");
                }
            }
            writer.Write("<lp1:getcontenttype>text/html; charset=UTF-8</lp1:getcontenttype>\n");
            writer.Write("<lp1:getetag>W/\"" + item.Revision + "//" + Helper.EncodeB(item.Name) + "\"</lp1:getetag>\n");
            writer.Write("<lp1:creationdate>" + Helper.FormatDate(item.LastModifiedDate) + "</lp1:creationdate>\n");
            writer.Write("<lp1:getlastmodified>" + Helper.FormatDateB(item.LastModifiedDate) + "</lp1:getlastmodified>\n");
            string svrVerLocalPath = GetLocalPath("/!svn/ver/" + item.Revision + "/" + Helper.Encode(item.Name, true));

            writer.Write("<lp1:checked-in><D:href>" + svrVerLocalPath + "</D:href></lp1:checked-in>\n");
            writer.Write("<lp1:version-controlled-configuration><D:href>" + VccPath + "</D:href></lp1:version-controlled-configuration>\n");
            writer.Write("<lp1:version-name>" + item.Revision + "</lp1:version-name>\n");
            writer.Write("<lp1:creator-displayname>" + item.Author + "</lp1:creator-displayname>\n");
            if (item.Name != "")
            {
                writer.Write("<lp2:baseline-relative-path>" + Helper.EncodeB(item.Name) + "</lp2:baseline-relative-path>\n");
            }
            else
            {
                writer.Write("<lp2:baseline-relative-path/>\n");
            }
            writer.Write("<lp2:repository-uuid>" + Guid.NewGuid() + "</lp2:repository-uuid>\n");
            writer.Write("<lp2:deadprop-count>" + item.Properties.Count + "</lp2:deadprop-count>\n");
            writer.Write("<lp1:resourcetype><D:collection/></lp1:resourcetype>\n");
            writer.Write("<D:lockdiscovery/>\n");
            writer.Write("</D:prop>\n");
            writer.Write("<D:status>HTTP/1.1 200 OK</D:status>\n");
            writer.Write("</D:propstat>\n");
            writer.Write("</D:response>\n");
            writer.Write("</D:multistatus>\n");
        }
Example #13
0
        public bool AddItems(ItemMetaData[] items)
        {
            int count = items.Length;

            if (_items == null)
            {
                _items = new ITag[count];
            }
            for (int i = 0; i < count; i++)
            {
                ITag          dataItem = null;
                ItemMetaData  meta     = items[i];
                DeviceAddress addr     = new DeviceAddress(0, 0, meta.ID, meta.Size, 0, meta.DataType);
                switch (meta.DataType)
                {
                case DataType.BOOL:
                    dataItem = new BoolTag(meta.ID, addr, this);
                    break;

                case DataType.BYTE:
                    dataItem = new ByteTag(meta.ID, addr, this);
                    break;

                case DataType.WORD:
                case DataType.SHORT:
                    dataItem = new ShortTag(meta.ID, addr, this);
                    break;

                case DataType.TIME:
                case DataType.INT:
                    dataItem = new IntTag(meta.ID, addr, this);
                    break;

                case DataType.FLOAT:
                    dataItem = new FloatTag(meta.ID, addr, this);
                    break;

                case DataType.STR:
                    dataItem = new StringTag(meta.ID, addr, this);
                    break;

                default:
                    dataItem = new BoolTag(meta.ID, addr, this);
                    break;
                }
                _items[i] = dataItem;
                _server.AddItemIndex(meta.Name, dataItem);
            }
            Array.Sort <ITag>(_items);
            Init();
            return(true);
        }
Example #14
0
        public ItemViewModel(Item item)
            : base(item, DomainObjectRepositories.ItemRepository)
        {
            _transient = true;
            _metaData  = ItemMetaDataProvider.GetMetaData(item);
            //_metaData.Refreshed += (sender, args) => UpdateMetaDataProperties();

            item.ObjectSaved += (sender, args) =>
            {
                UpdateMetaDataProperties();
            };

            UpdateMetaDataProperties();

            MadeFrom = new RecipeCollectionViewModel(item.MadeFrom, item);
            foreach (var i in MadeFrom.Collection)
            {
                i.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName == nameof(UnitCost))
                    {
                        _metaData.Recalculate();
                        UpdateMetaDataProperties();
                    }
                };
            }

            UsedIn = new RecipeCollectionViewModel(item.UsedIn);

            var primaryRecipe = item.MadeFrom.FirstOrDefault();

            if (primaryRecipe != null)
            {
                PrimarySourceRecipe = new RecipeViewModel(primaryRecipe);
            }


            MarketObservationCollection = new MarketObservationCollectionViewModel(item.AllMarketData, item);
            MarketObservationCollection.Collection.CollectionChanged += MarketObservationCollection_CollectionChanged;

            if (item.CurrentMarketData != null)
            {
                MostRecentMarketObservation = new MarketObservationViewModel(item.CurrentMarketData);
            }
            else
            {
                MessageLog.GetLog().LogMessage($"Couldn't find any market data for {item.Name}");
            }

            MarketCategories = CollectionHelper.MarketCategories;
            _transient       = item.Id == Guid.Empty;
        }
        public static ItemMetaData GetMetaData(Item item)
        {
            ItemMetaData meta;

            if (!_itemMetaData.TryGetValue(item, out meta))
            {
                item.ObjectSaved += ItemOnObjectSaved;
                meta              = new ItemMetaData(item, StaticSettings.Character);
                _itemMetaData.Add(item, meta);
            }

            return(meta);
        }
Example #16
0
        private void SendBlameResponse(IHttpRequest request, IHttpResponse response, TFSSourceControlProvider sourceControlProvider, string serverPath, FileRevsReportData data)
        {
            LogItem log = sourceControlProvider.GetLog(
                serverPath,
                data.StartRevision,
                data.EndRevision,
                Recursion.Full,
                data.EndRevision - data.StartRevision);

            if (log.History.Length == 0)
            {
                WriteFileNotFoundResponse(request, response);
            }

            foreach (SourceItemHistory history in log.History)
            {
                foreach (SourceItemChange change in history.Changes)
                {
                    if (change.Item.ItemType == ItemType.Folder)
                    {
                        SendErrorResponseCannotRunBlameOnFolder(response, serverPath);
                        return;
                    }
                }
            }
            using (var output = new StreamWriter(response.OutputStream))
            {
                response.StatusCode = (int)HttpStatusCode.OK;
                output.Write(
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
<S:file-revs-report xmlns:S=""svn:"" xmlns:D=""DAV:"">");

                foreach (SourceItemHistory history in Helper.SortHistories(true, log.History))
                {
                    foreach (SourceItemChange change in history.Changes)
                    {
                        ItemMetaData items    = sourceControlProvider.GetItems(change.Item.RemoteChangesetId, change.Item.RemoteName, Recursion.None);
                        byte[]       itemData = sourceControlProvider.ReadFile(items);
                        string       txdelta  = SvnDiffParser.GetBase64SvnDiffData(itemData);

                        output.Write(@"<S:file-rev path=""" + change.Item.RemoteName + @""" rev=""" +
                                     change.Item.RemoteChangesetId + @""">
                            <S:rev-prop name=""svn:log"">" + history.Comment + @"</S:rev-prop>
                            <S:rev-prop name=""svn:author"">" + history.Username + @"</S:rev-prop>
                            <S:rev-prop name=""svn:date"">" + Helper.FormatDate(change.Item.RemoteDate) + @"</S:rev-prop>
                            <S:txdelta>" + txdelta + @"</S:txdelta></S:file-rev>");
                    }
                }
                output.Write("</S:file-revs-report>");
            }
        }
Example #17
0
 private bool ItemExistsAtTheClient(ItemMetaData item, UpdateReportData updateReportRequest, string srcPath, int clientRevisionForItem)
 {
     if (sourceControlProvider != null)
     {
         return(updateReportRequest.IsCheckOut == false &&
                IsMissing(updateReportRequest, srcPath, item.Name) == false &&
                // we need to check both name and id to ensure that the item was not renamed
                sourceControlProvider.ItemExists(item.Name, clientRevisionForItem) &&
                sourceControlProvider.ItemExists(item.Id, clientRevisionForItem));
     }
     else
     {
         return(false);
     }
 }
Example #18
0
        public static ItemMetaData GetGroupRowMetadata(object item)
        {
            ItemMetaData metaData = new ItemMetaData();

            metaData.Selectable = false;
            metaData.Focusable  = true;
            metaData.CssClasses = "slick-group";
            metaData.Columns    = new Dictionary <object, Column>();
            Column col = new Column();

            metaData.Columns[0] = col;
            col.ColSpan         = "*";
            col.Formatter       = GroupCellFormatter;
            col.Editor          = null;
            return(metaData);
        }
Example #19
0
        private List <ItemMetaData> GetAllItemData()
        {
            List <ItemMetaData> itemList = ItemMetaDataReader.GetItemList();
            List <ItemMetaData> list2    = new List <ItemMetaData>();
            int num   = 0;
            int count = itemList.Count;

            while (num < count)
            {
                ItemMetaData item = itemList[num];
                if (!ItempediaData.IsInBlacklist(item.ID))
                {
                    list2.Add(item);
                }
                num++;
            }
            return(list2);
        }
        /// <summary>
        /// Adds an Item of type T to the queue
        /// </summary>
        /// <param name="item">the item of type T</param>
        /// <param name="itemCausesStop">if true the spooler stops after this item and must be restarted</param>
        public void AddItem(T item, bool itemCausesStop = false)
        {
            try
            {
                ItemMetaData storedItem = new ItemMetaData()
                {
                    HoldOnItem = itemCausesStop,
                    Item       = item
                };

                _inputs.Enqueue(storedItem);
                StartProcess();
            }
            catch (Exception ex)
            {
                RaiseException(this, ex);
            }
        }
Example #21
0
 private bool ShouldDeleteItemBeforeSendingToClient(ItemMetaData folder,
                                                    UpdateReportData updateReportRequest,
                                                    string srcPath,
                                                    int clientRevisionForItem,
                                                    bool existingFolder)
 {
     if (sourceControlProvider != null)
     {
         return(existingFolder == false && updateReportRequest.IsCheckOut == false &&
                IsMissing(updateReportRequest, srcPath, folder.Name) == false &&
                sourceControlProvider.ItemExists(folder.Name, clientRevisionForItem));
     }
     else
     {
         return(existingFolder == false && updateReportRequest.IsCheckOut == false &&
                IsMissing(updateReportRequest, srcPath, folder.Name) == false);
     }
 }
Example #22
0
        private string CheckOut(TFSSourceControlProvider sourceControlProvider, CheckoutData request, string path)
        {
            string activityId = PathParser.GetActivityId(request.ActivitySet.href);

            if (path.Contains("/bln"))
            {
                return(GetLocalPath("//!svn/wbl/" + activityId + path.Substring(9)));
            }

            if (path == "/!svn/vcc/default")
            {
                int latestVersion = sourceControlProvider.GetLatestVersion();
                return(GetLocalPath("//!svn/wbl/" + activityId + "/" + latestVersion.ToString()));
            }

            int    revisionStart = path.IndexOf("/ver/") + 5;
            int    version;
            string itemPath;

            if (path.IndexOf('/', revisionStart + 1) != -1)
            {
                int revisionEnd = path.IndexOf('/', revisionStart + 1);
                version  = int.Parse(path.Substring(revisionStart, revisionEnd - revisionStart));
                itemPath = path.Substring(revisionEnd);
            }
            else
            {
                version  = int.Parse(path.Substring(revisionStart));
                itemPath = "/";
            }

            itemPath = itemPath.Replace("//", "/");
            string location = GetLocalPath("//!svn/wrk/" + activityId + itemPath);

            ItemMetaData item = sourceControlProvider.GetItemsWithoutProperties(-1, Helper.Decode(itemPath), Recursion.None);

            if (item.ItemRevision > version || item.PropertyRevision > version)
            {
                throw new ConflictException();
            }

            return(location);
        }
        private static ItemMetaData GetItems(TFSSourceControlProvider sourceControlProvider,
                                             int version,
                                             string path,
                                             Recursion recursion,
                                             bool loadPropertiesFromFile)
        {
            // Make sure path is decoded
            ItemMetaData item = null;

            if (loadPropertiesFromFile)
            {
                item = sourceControlProvider.GetItems(version, Helper.Decode(path), recursion);
            }
            else
            {
                item = sourceControlProvider.GetItemsWithoutProperties(version, Helper.Decode(path), recursion);
            }
            return(item);
        }
        private void WriteAllPropForItem(TextWriter writer, string requestPath, ItemMetaData item, byte[] itemData, TFSSourceControlProvider sourceControlProvider)
        {
            writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
            writer.Write("<D:multistatus xmlns:D=\"DAV:\" xmlns:ns0=\"DAV:\">\n");
            writer.Write("<D:response xmlns:S=\"http://subversion.tigris.org/xmlns/svn/\" xmlns:C=\"http://subversion.tigris.org/xmlns/custom/\" xmlns:V=\"http://subversion.tigris.org/xmlns/dav/\" xmlns:lp1=\"DAV:\" xmlns:lp2=\"http://subversion.tigris.org/xmlns/dav/\">\n");
            writer.Write("<D:href>" + Helper.Encode(requestPath) + "</D:href>\n");
            writer.Write("<D:propstat>\n");
            writer.Write("<D:prop>\n");
            writer.Write("<lp1:getcontentlength>" + itemData.Length + "</lp1:getcontentlength>\n");
            writer.Write("<lp1:getcontenttype>text/plain</lp1:getcontenttype>\n");
            writer.Write("<lp1:getetag>\"" + item.Revision + "//" + Helper.EncodeB(item.Name) + "\"</lp1:getetag>\n");
            writer.Write("<lp1:creationdate>" + Helper.FormatDate(item.LastModifiedDate) + "</lp1:creationdate>\n");
            writer.Write("<lp1:getlastmodified>" + Helper.FormatDateB(item.LastModifiedDate) + "</lp1:getlastmodified>\n");
            string svnVerLocalPath = GetLocalPath("/!svn/ver/" + item.Revision + "/" + Helper.Encode(item.Name, true));

            writer.Write("<lp1:checked-in><D:href>" + svnVerLocalPath + "</D:href></lp1:checked-in>\n");
            writer.Write("<lp1:version-controlled-configuration><D:href>" + VccPath + "</D:href></lp1:version-controlled-configuration>\n");
            writer.Write("<lp1:version-name>" + item.Revision + "</lp1:version-name>\n");
            writer.Write("<lp1:creator-displayname>" + item.Author + "</lp1:creator-displayname>\n");
            writer.Write("<lp2:baseline-relative-path>" + Helper.EncodeB(item.Name) + "</lp2:baseline-relative-path>\n");
            writer.Write("<lp2:md5-checksum>" + Helper.GetMd5Checksum(itemData) + "</lp2:md5-checksum>\n");
            writer.Write("<lp2:repository-uuid>" + Guid.NewGuid() + "</lp2:repository-uuid>\n");
            writer.Write("<lp2:deadprop-count>0</lp2:deadprop-count>\n");
            writer.Write("<lp1:resourcetype/>\n");
            writer.Write("<D:supportedlock>\n");
            writer.Write("<D:lockentry>\n");
            writer.Write("<D:lockscope><D:exclusive/></D:lockscope>\n");
            writer.Write("<D:locktype><D:write/></D:locktype>\n");
            writer.Write("</D:lockentry>\n");
            writer.Write("</D:supportedlock>\n");
            writer.Write("<D:lockdiscovery/>\n");
            writer.Write("</D:prop>\n");
            writer.Write("<D:status>HTTP/1.1 200 OK</D:status>\n");
            writer.Write("</D:propstat>\n");
            writer.Write("</D:response>\n");
            writer.Write("</D:multistatus>\n");
        }
 protected bool GetData(ItemMetaData metadata)
 {
     if (metadata is FolderMetaData)
     {
         bool bRet = true;
         foreach (var x in ((FolderMetaData)metadata).Items)
         {
             bRet = bRet && GetData(x);
         }
         return(bRet);
     }
     else
     {
         byte[] buffer = ReadFile(metadata.Name, metadata.ItemRevision);
         if (buffer == null)
         {
             return(false);
         }
         metadata.Base64DiffData = SvnDiffParser.GetBase64SvnDiffData(buffer);
         metadata.Md5Hash        = Helper.GetMd5Checksum(buffer);
         metadata.DataLoaded     = true;
         return(true);
     }
 }
Example #26
0
        private void GetLocationsReport(TFSSourceControlProvider sourceControlProvider, GetLocationsReportData getLocationsReport, string path, StreamWriter output)
        {
            if (path.IndexOf('/', 9) > -1)
            {
                path = path.Substring(path.IndexOf('/', 9));
            }
            else
            {
                path = "/";
            }

            output.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
            output.Write("<S:get-locations-report xmlns:S=\"svn:\" xmlns:D=\"DAV:\">\n");
            foreach (string locationRevision in getLocationsReport.LocationRevision)
            {
                ItemMetaData item = sourceControlProvider.GetItemsWithoutProperties(int.Parse(locationRevision), path, Recursion.None);
                if (item != null)
                {
                    output.Write("<S:location rev=\"" + locationRevision + "\" path=\"" + path + "\"/>\n");
                }
            }

            output.Write("</S:get-locations-report>\n");
        }
 public virtual byte[] GetFile(ItemMetaData item, Guid repositoryUuid)
 {
     return(webTransferService.DownloadBytes(GetDownloadUrl(item.DownloadUrl, repositoryUuid), credentials));
 }
Example #28
0
 public RangeWeapon(ItemMetaData meta = null) : base(meta)
 {
 }
Example #29
0
        public void ProcessUpdateReportForFile(UpdateReportData updateReportRequest, ItemMetaData item, StreamWriter output, bool parentFolderWasDeleted)
        {
            if (item is DeleteMetaData)
            {
                if (!parentFolderWasDeleted)
                {
                    output.Write("<S:delete-entry name=\"" + Helper.EncodeB(GetFileName(item.Name)) + "\"/>\n");
                }
            }
            else
            {
                bool   existingFile          = false;
                string srcPath               = GetSrcPath(updateReportRequest);
                int    clientRevisionForItem = GetClientRevisionFor(updateReportRequest.Entries, StripBasePath(item, srcPath));
                if (ItemExistsAtTheClient(item, updateReportRequest, srcPath, clientRevisionForItem))
                {
                    existingFile = true;
                }

                //another item with the same name already exists, need to remove it.
                if (!parentFolderWasDeleted && ShouldDeleteItemBeforeSendingToClient(item, updateReportRequest, srcPath, clientRevisionForItem, existingFile))
                {
                    output.Write("<S:delete-entry name=\"" + Helper.EncodeB(GetFileName(item.Name)) + "\"/>\n");
                }

                if (existingFile)
                {
                    output.Write("<S:open-file name=\"" + Helper.EncodeB(GetFileName(item.Name)) + "\" rev=\"" +
                                 clientRevisionForItem + "\">\n");
                }
                else
                {
                    output.Write("<S:add-file name=\"" + Helper.EncodeB(GetFileName(item.Name)) + "\">\n");
                }

                string localPath = handler.GetLocalPath("/!svn/ver/" + item.Revision + "/" + Helper.Encode(item.Name, true));
                output.Write("<D:checked-in><D:href>" + localPath + "</D:href></D:checked-in>\n");
                output.Write("<S:set-prop name=\"svn:entry:committed-rev\">" + item.Revision + "</S:set-prop>\n");
                output.Write("<S:set-prop name=\"svn:entry:committed-date\">" + Helper.FormatDate(item.LastModifiedDate) + "</S:set-prop>\n");
                output.Write("<S:set-prop name=\"svn:entry:last-author\">" + item.Author + "</S:set-prop>\n");
                if (sourceControlProvider == null)
                {
                    output.Write("<S:set-prop name=\"svn:entry:uuid\">" + new Guid() + "</S:set-prop>\n");
                }
                else
                {
                    output.Write("<S:set-prop name=\"svn:entry:uuid\">" + sourceControlProvider.GetRepositoryUuid() + "</S:set-prop>\n");
                }
                foreach (KeyValuePair <string, string> property in item.Properties)
                {
                    output.Write("<S:set-prop name=\"" + property.Key + "\">" + property.Value + "</S:set-prop>\n");
                }

                while (item.DataLoaded == false)                 // <== Uha
                {
                    Thread.Sleep(100);
                }

                output.Write("<S:txdelta>");
                output.Write(item.Base64DiffData);
                output.Write("\n</S:txdelta>");
                output.Write("<S:prop><V:md5-checksum>" + item.Md5Hash + "</V:md5-checksum></S:prop>\n");

                // Release data memory
                item.DataLoaded     = false;
                item.Base64DiffData = null;

                if (existingFile)
                {
                    output.Write("</S:open-file>\n");
                }
                else
                {
                    output.Write("</S:add-file>\n");
                }
            }
        }
Example #30
0
        public void ProcessUpdateReportForDirectory(UpdateReportData updateReportRequest, FolderMetaData folder, StreamWriter output, bool rootFolder, bool parentFolderWasDeleted)
        {
            if (folder is DeleteFolderMetaData)
            {
                if (!parentFolderWasDeleted)
                {
                    output.Write("<S:delete-entry name=\"" + Helper.EncodeB(GetFileName(folder.Name)) + "\"/>\n");
                }
            }
            else
            {
                bool existingFolder   = false;
                bool folderWasDeleted = parentFolderWasDeleted;
                if (rootFolder)
                {
                    output.Write("<S:open-directory rev=\"" + updateReportRequest.Entries[0].Rev + "\">\n");
                }
                else
                {
                    string srcPath = GetSrcPath(updateReportRequest);
                    int    clientRevisionForItem = GetClientRevisionFor(updateReportRequest.Entries, StripBasePath(folder, srcPath));
                    if (ItemExistsAtTheClient(folder, updateReportRequest, srcPath, clientRevisionForItem))
                    {
                        existingFolder = true;
                    }

                    //another item with the same name already exists, need to remove it.
                    if (!parentFolderWasDeleted && ShouldDeleteItemBeforeSendingToClient(folder, updateReportRequest, srcPath, clientRevisionForItem, existingFolder))
                    {
                        output.Write("<S:delete-entry name=\"" + Helper.EncodeB(GetFileName(folder.Name)) + "\"/>\n");
                        folderWasDeleted = true;
                    }

                    if (existingFolder)
                    {
                        output.Write("<S:open-directory name=\"" + Helper.EncodeB(GetFileName(folder.Name)) +
                                     "\" rev=\"" + updateReportRequest.Entries[0].Rev + "\">\n");
                    }
                    else
                    {
                        output.Write("<S:add-directory name=\"" + Helper.EncodeB(GetFileName(folder.Name)) +
                                     "\" bc-url=\"" + handler.GetLocalPath("/!svn/bc/" + folder.Revision + "/" + Helper.Encode(folder.Name, true)) +
                                     "\">\n");
                    }
                }
                if (!rootFolder || updateReportRequest.UpdateTarget == null)
                {
                    string svnVer = handler.GetLocalPath("/!svn/ver/" + folder.Revision + "/" + Helper.Encode(folder.Name, true));
                    output.Write("<D:checked-in><D:href>" + svnVer + "</D:href></D:checked-in>\n");
                    output.Write("<S:set-prop name=\"svn:entry:committed-rev\">" + folder.Revision +
                                 "</S:set-prop>\n");
                    output.Write("<S:set-prop name=\"svn:entry:committed-date\">" +
                                 Helper.FormatDate(folder.LastModifiedDate) + "</S:set-prop>\n");
                    output.Write("<S:set-prop name=\"svn:entry:last-author\">" + folder.Author + "</S:set-prop>\n");
                    if (sourceControlProvider == null)
                    {
                        output.Write("<S:set-prop name=\"svn:entry:uuid\">" + new Guid() + "</S:set-prop>\n");
                    }
                    else
                    {
                        output.Write("<S:set-prop name=\"svn:entry:uuid\">" + sourceControlProvider.GetRepositoryUuid() + "</S:set-prop>\n");
                    }
                    foreach (KeyValuePair <string, string> property in folder.Properties)
                    {
                        output.Write("<S:set-prop name=\"" + property.Key + "\">" + property.Value + "</S:set-prop>\n");
                    }
                }

                for (int i = 0; i < folder.Items.Count; i++)
                {
                    ItemMetaData item = folder.Items[i];
                    if (item.ItemType == ItemType.Folder)
                    {
                        ProcessUpdateReportForDirectory(updateReportRequest, (FolderMetaData)item, output, false, folderWasDeleted);
                    }
                    else
                    {
                        ProcessUpdateReportForFile(updateReportRequest, item, output, folderWasDeleted);
                    }
                }
                output.Write("<S:prop></S:prop>\n");
                if (rootFolder || existingFolder)
                {
                    output.Write("</S:open-directory>\n");
                }
                else
                {
                    output.Write("</S:add-directory>\n");
                }
            }
        }