Пример #1
0
        /// <summary>
        /// Gets the web dav URL by WebDavTicket.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <returns></returns>
        public static string GetWebDavUrl(string ticket)
        {
            string       retVal       = string.Empty;
            WebDavTicket webDavTicket = WebDavTicket.Parse(ticket);

            //Попытаемся определить имя файла
            if (String.IsNullOrEmpty(webDavTicket.AbsolutePath.FileName))
            {
                if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_FileStorage)
                {
                    FileStorageAbsolutePath fsAbsPath = webDavTicket.AbsolutePath as FileStorageAbsolutePath;
                    if (fsAbsPath != null)
                    {
                        FileStorage fs = new FileStorage();
                        Mediachase.IBN.Business.ControlSystem.FileInfo fileInfo = fs.GetFile(fsAbsPath.UniqueId);
                        if (fileInfo != null)
                        {
                            webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                        }
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaData)
                {
                    MetaDataAbsolutePath mdAbsPath = webDavTicket.AbsolutePath as MetaDataAbsolutePath;
                    if (mdAbsPath != null)
                    {
                        Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(mdAbsPath.FileUID);
                        webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaDataPlus)
                {
                    MetaDataPlusAbsolutePath mdpAbsPath = webDavTicket.AbsolutePath as MetaDataPlusAbsolutePath;
                    if (mdpAbsPath != null)
                    {
                        Mediachase.MetaDataPlus.MetaObject obj = MetaDataWrapper.LoadMetaObject(mdpAbsPath.MetaObjectId, mdpAbsPath.MetaObjectType);
                        MetaFile mf = obj[mdpAbsPath.MetaFieldName] as MetaFile;
                        if (mf != null)
                        {
                            webDavTicket.AbsolutePath.FileName = mf.Name;
                        }
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_Incident)
                {
                    EmailStorageAbsolutePath emlAbsPath = webDavTicket.AbsolutePath as EmailStorageAbsolutePath;
                    if (emlAbsPath != null)
                    {
                        EMailMessageInfo emlInfo    = EMailMessageInfo.Load(emlAbsPath.EmailMsgId);
                        AttachmentInfo   attachInfo = emlInfo.Attachments[emlAbsPath.EmailAttachmentIndex];
                        webDavTicket.AbsolutePath.FileName = attachInfo.FileName;
                    }
                }
            }

            retVal = GetWebDavUrl(webDavTicket.AbsolutePath, true);


            return(retVal);
        }
Пример #2
0
 public MetaFileStream(MetaObject mo, MetaFile mf, string metaFieldName, long contentLength)
 {
     _metaObject = mo;
     _metaFile = mf;
     _metaFieldName = metaFieldName;
     _stream = new MemoryStream();
     _contentLength = contentLength;
 }
Пример #3
0
        /// <summary>
        /// Gets the web dav URL.
        /// </summary>
        /// <param name="storageType">Type of the storage.</param>
        /// <param name="objectId">The object id.</param>
        /// <param name="objectName">Name of the object.</param>
        /// <returns></returns>
        public static string GetMetaDataPlusWebDavUrl(int objectId, string objectType, string fieldName, bool withAuthToken)
        {
            string retVal = string.Empty;

            Mediachase.MetaDataPlus.MetaObject obj = MetaDataWrapper.LoadMetaObject(objectId, objectType);
            retVal = GetMetaDataPlusWebDavUrl(obj, fieldName, withAuthToken);

            return(retVal);
        }
        public void Save(int objectId)
        {
            obj = MetaDataWrapper.LoadMetaObject(objectId, MetaClassName);
            if (obj == null)
                obj = MetaDataWrapper.NewMetaObject(objectId, MetaClassName);

            if (mainTable.Controls.Count > 0)
                ProcessCollection(mainTable.Controls, obj);

            MetaDataWrapper.AcceptChanges(obj);
        }
Пример #5
0
        public static int AcceptChanges(MetaObject obj)
        {
            obj.AcceptChanges();

            if (obj.MetaClass.Namespace == "Mediachase.IBN40.List") // ƒобавление/изменение записи в списке
            {
                string[] splitter = obj.MetaClass.Name.Split('_');
                try
                {
                    int ListId = int.Parse(splitter[1]);
                    SystemEvents.AddSystemEvents(SystemEventTypes.List_Updated_Data, ListId);
                }
                catch{}
            }

            return obj.Id;
        }
Пример #6
0
        /// <summary>
        /// Gets the web dav URL.
        /// </summary>
        /// <param name="metaObjectId">The meta object id.</param>
        /// <param name="metaClassName">Name of the meta class.</param>
        /// <param name="metaFieldName">Name of the meta field.</param>
        /// <param name="withAuthToken">if set to <c>true</c> [with auth token].</param>
        /// <returns></returns>
        public static string GetMetaDataPlusWebDavUrl(Mediachase.MetaDataPlus.MetaObject mo, string metaField, bool withAuthToken)
        {
            MetaFile mf = mo[metaField] as MetaFile;

            if (mf == null)
            {
                throw new ArgumentException(metaField + " is not a MetaFile");
            }

            MetaDataPlusAbsolutePath absPath = (MetaDataPlusAbsolutePath)WebDavAbsolutePath.CreateInstance(ObjectTypes.File_MetaDataPlus);

            absPath.MetaFieldName  = metaField;
            absPath.MetaObjectId   = mo.Id;
            absPath.MetaObjectType = mo.MetaClass.Name;
            absPath.UniqueId       = mo.Id;
            absPath.FileName       = mf.Name;

            return(GetWebDavUrl(absPath, withAuthToken));
        }
        private void BindData(bool needToBind)
        {
            pageView = new PageView(false, PageViewType.Static, string.Empty, this.Page, MetaClassName);

            mc = MetaClass.Load(MetaClassName);

            if (ObjectId > 0)
                obj = MetaDataWrapper.LoadMetaObject(ObjectId, MetaClassName);
            if (obj == null)
                obj = MetaDataWrapper.NewMetaObject(ObjectId, MetaClassName);

            GenerateMainTable();

            LoadControls(needToBind);

            wasBound = true;
        }
        private void ProcessCollection(ControlCollection coll, MetaObject obj)
        {
            foreach (Control ctrl in coll)
            {
                if (ctrl is ICustomField)
                {
                    ICustomField field = (ICustomField)ctrl;
                    object FieldValue = field.Value;
                    string FieldName = field.FieldName;

                    obj[FieldName] = FieldValue;
                }
                else if (ctrl.HasControls())
                {
                    ProcessCollection(ctrl.Controls, obj);
                }
            }
        }
Пример #9
0
        private void GetFieldValue(MD45.MetaObject object45, MD47.Meta.Management.MetaField field47, ref bool fieldPresent, ref object value)
        {
            string field47Name = field47.Name;

            if (_fieldMap.ContainsKey(field47Name))
            {
                fieldPresent = true;
                string field45Name = _fieldMap[field47Name];

                if (field47.IsEnum || field47.IsMultivalueEnum)
                {
                    if (object45[field45Name] != null)
                    {
                        Dictionary <int, string> enumValues;
                        //Try find mapping id for this FieldType
                        if (!_enumValuesByType.TryGetValue(field47.GetMetaType(), out enumValues))
                        {
                            throw new ArgumentException("Not mapped enum item");
                        }

                        if (field47.IsMultivalueEnum)
                        {
                            List <string> valueList = new List <string>();
                            foreach (MD45.Configurator.MetaDictionaryItem enumItem in (MD45.Configurator.MetaDictionaryItem[])object45[field45Name])
                            {
                                valueList.Add(enumItem.Value);
                            }

                            if (valueList.Count > 0)
                            {
                                value = valueList.ToArray();
                            }
                        }
                        else
                        {
                            value = ((MD45.Configurator.MetaDictionaryItem)object45[field45Name]).Value;
                        }
                    }
                }
                else if (field47.GetMetaType().McDataType == MD47.Meta.Management.McDataType.File)
                {
                    MD45.MetaFile metaFile45 = object45[field45Name] as MD45.MetaFile;

                    if (metaFile45 != null)
                    {
                        //Begin copy file to 47
                        if (metaFile45.Buffer != null)
                        {
                            using (MemoryStream stream = new MemoryStream(metaFile45.Buffer))
                            {
                                value = new MD47.Meta.FileInfo(metaFile45.Name, stream);
                            }
                        }
                        else
                        {
                            value = new MD47.Meta.FileInfo(metaFile45.Name);
                        }
                    }
                }
                else
                {
                    switch (field47Name)
                    {
                    case "Created":
                        value = object45.Created;
                        break;

                    case "CreatorId":
                        value = object45.CreatorId;
                        break;

                    case "Modified":
                        value = object45.Modified;
                        break;

                    case "ModifierId":
                        value = object45.ModifierId;
                        break;

                    default:
                        value = object45[field45Name];
                        break;
                    }
                }
            }
            else
            {
                fieldPresent = false;
            }
        }
Пример #10
0
        public static MetaObject NewObject(int objectId, MetaClass type, int creatorId, DateTime created)
        {
            MetaObject retVal = new MetaObject();

            retVal._objectId = objectId;
            retVal._metaClass = type;

            retVal._creatorId = creatorId;
            retVal._created = created;

            retVal._modifierId = creatorId;
            retVal._modified = created;

            retVal.LoadMetaFields();

            return retVal;
        }
Пример #11
0
        static MetaObject Load(MetaClass type, SqlDataReader reader)
        {
            MetaObject retVal = new MetaObject();

            retVal._objectId = (int)reader["ObjectId"];
            retVal._metaClass = type;

            retVal.LoadMetaFields(reader);

            return retVal;
        }