예제 #1
0
		// 从服务器获得元数据
		public void GetMetaDataParam(DigitalPlatform.Xml.ElementItem element)
		{
			string strID = element.GetAttrValue("id");

			if (strID == null || strID == "")
			{
				Debug.Assert(false);
			}


			// 如果没有挂回调函数,警告
			if (this.procDownloadOneMetaData == null) 
			{
				element.SetAttrValue("__mime", "?mime");
				element.SetAttrValue("__localpath", "?localpath");
				element.SetAttrValue("__size", "?size");
				element.SetAttrValue("__timestamp", "?timestamp");
				m_bChanged = true;
			}
			else 
			{

				string strExistTimeStamp = element.GetAttrValue("__timestamp");



				if (strExistTimeStamp != null && strExistTimeStamp != "")
				{
					ChangeLine(strID, 
						null,	// newid
						null,	// state
						element.GetAttrValue("__localpath"),
						element.GetAttrValue("__mime"),
						element.GetAttrValue("__size"),
						element.GetAttrValue("__timestamp") );
					return;
				}

				m_bChanged = true;

				string strMetaData = "";
				string strError = "";
				byte [] timestamp = null;
				int nRet = this.procDownloadOneMetaData(
					strID, 
					out strMetaData,
					out timestamp,
					out strError);
				if (nRet == -1) 
				{
					element.SetAttrValue("__localpath",
						strError);
					return;
				}

				if (strMetaData == "")
				{
					return;
				}

				// 取metadata
				Hashtable values = StringUtil.ParseMedaDataXml(strMetaData,
					out strError);
				if (values == null)
				{
					element.SetAttrValue("__localpath",
						strError);
					return;
				}

				string strTimeStamp = ByteArray.GetHexTimeStampString(timestamp);

				element.SetAttrValue("__mime",
					(string)values["mimetype"]);
				element.SetAttrValue("__localpath",
					(string)values["localpath"]);
				element.SetAttrValue("__size",
					(string)values["size"]);
				element.SetAttrValue("__timestamp",
					(string)strTimeStamp);
			}
		}
예제 #2
0
		// ?
		// 在listview加一行,如果此行已存在,则修改其内容
		public void NewLine(DigitalPlatform.Xml.ElementItem fileitem,
			bool bIsNewFile)
		{
			string strID = fileitem.GetAttrValue("id");

			if (strID == null || strID == "")
			{
				Debug.Assert(bIsNewFile == true, "必须是客户端文件才能无id属性");
			}

			string strState;
			if (bIsNewFile == false)
				strState = this.ServerFileState;
			else
				strState = this.NewFileState;


			// 维护id表
			if (strID != null && strID != "") 
			{
				if (m_tableFileId.Contains((object)strID) == false)
					m_tableFileId.Add(strID, (object)true);
			}



			ListViewItem item = SearchLine(strID);
            if (item == null)
            {
                item = new ListViewItem(strID, 0);
                this.Items.Add(item);

                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                m_bChanged = true;

            }
            else
            {
                // 2006/6/22
                // 重复插入.
                // 插入在已经发现的事项前面
                int index = this.Items.IndexOf(item);

                item = new ListViewItem(strID, 0);
                this.Items.Insert(index, item);

                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                item.SubItems.Add("");
                m_bChanged = true;
            }

			string strOldState = fileitem.GetAttrValue("__state");
			if (strOldState != strState)
				fileitem.SetAttrValue("__state", strState);
		}