예제 #1
0
        static void Main(string[] args)
        {
            Client      client     = CodeExample.createKalturaClient();
            bool        done       = false;
            string      secret     = "********************";
            string      userId     = "*****@*****.**";
            SessionType type       = SessionType.USER;
            int         partnerId  = 123456;
            int         expiry     = 86400;
            string      privileges = "";

            OnCompletedHandler <string> handler = new OnCompletedHandler <string>(
                (string result, Exception e) =>
            {
                CodeExample.PrintObject(result);
                done = true;
            });

            SessionService.Start(secret, userId, type, partnerId, expiry, privileges)
            .SetCompletion(handler)
            .Execute(client);

            while (!done)
            {
                Thread.Sleep(100);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Configuration config = new Configuration();

            config.ServiceUrl = "https://www.kaltura.com/";
            Client      client     = new Client(config);
            int         partnerId  = YOUR_PARTNER_ID;
            string      secret     = "";
            string      userId     = "";
            SessionType type       = SessionType.ADMIN;
            int         expiry     = 86400;
            string      privileges = "";

            client.KS = client.GenerateSession(partnerId, secret, userId, type, expiry, privileges);

            MediaEntryFilter filter = new MediaEntryFilter();
            FilterPager      pager  = new FilterPager();

            OnCompletedHandler <ListResponse <MediaEntry> > handler = new OnCompletedHandler <ListResponse <MediaEntry> >(
                (ListResponse <MediaEntry> result, Exception e) => Console.WriteLine(result));

            MediaService.List(filter, pager)
            .SetCompletion(handler)
            .Execute(client);
        }
예제 #3
0
        static void Main(string[] args)
        {
            Client  client        = CodeExample.createKalturaClient();
            bool    done          = false;
            string  uploadTokenId = "abcde";
            file    fileData      = new FileStream("/path/to/file", FileMode.Open, FileAccess.Read);
            boolean resume        = false;
            boolean finalChunk    = true;
            number  resumeAt      = -1;

            OnCompletedHandler <UploadToken> handler = new OnCompletedHandler <UploadToken>(
                (UploadToken result, Exception e) =>
            {
                CodeExample.PrintObject(result);
                done = true;
            });

            UploadTokenService.Upload(uploadTokenId, fileData, resume, finalChunk, resumeAt)
            .SetCompletion(handler)
            .Execute(client);

            while (!done)
            {
                Thread.Sleep(100);
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            Client client     = CodeExample.createKalturaClient();
            bool   done       = false;
            string loginId    = "foobar";
            string password   = "******";
            int    partnerId  = 0;
            int    expiry     = 86400;
            string privileges = "*";
            string otp        = "";

            OnCompletedHandler <string> handler = new OnCompletedHandler <string>(
                (string result, Exception e) =>
            {
                CodeExample.PrintObject(result);
                done = true;
            });

            UserService.LoginByLoginId(loginId, password, partnerId, expiry, privileges, otp)
            .SetCompletion(handler)
            .Execute(client);

            while (!done)
            {
                Thread.Sleep(100);
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            Client      client            = CodeExample.createKalturaClient();
            bool        done              = false;
            string      id                = "";
            string      tokenHash         = "";
            string      userId            = "YOUR_USER_ID";
            SessionType type              = SessionType.USER;
            int         expiry            = 0;
            string      sessionPrivileges = "";

            OnCompletedHandler <SessionInfo> handler = new OnCompletedHandler <SessionInfo>(
                (SessionInfo result, Exception e) =>
            {
                CodeExample.PrintObject(result);
                done = true;
            });

            AppTokenService.StartSession(id, tokenHash, userId, type, expiry, sessionPrivileges)
            .SetCompletion(handler)
            .Execute(client);

            while (!done)
            {
                Thread.Sleep(100);
            }
        }
예제 #6
0
        /// <summary>
        /// 全部导出
        /// </summary>
        /// <param name="onCompleted">完成回调</param>
        /// <param name="onStatus">状态</param>
        public void ExportAll(OnCompletedHandler onCompleted, OnStatusHandler onStatus)
        {
            // 文件的状态,0 未处理,1 处理中,2 处理完
            Dictionary <string, int> status = _paths.ToDictionary(path => path, _ => 0);

            for (int i = 0; i < Math.Min(Config.ExportThreadCount, status.Count); ++i)
            {
                int  threadCount = 0;
                bool isBreak     = false;
                var  thread      = new Thread(() =>
                {
                    ++threadCount;

                    foreach (var path in status.Keys.ToArray())
                    {
                        if (isBreak)
                        {
                            break;
                        }
                        if (status[path] == 0)
                        {
                            status[path] = 1;
                            onStatus?.Invoke(null, "正在处理...", status.Values.ToArray().Count(e => e == 2) * 1.0 / status.Count + "");
                            if (Export(path, onStatus))
                            {
                                status[path] = 2;
                                onStatus?.Invoke(null, "正在处理...", status.Values.ToArray().Count(e => e == 2) * 1.0 / status.Count + "");
                            }
                            else
                            {
                                isBreak = true;
                            }
                        }
                    }

                    --threadCount;
                    if (threadCount == 0)
                    {
                        onStatus?.Invoke(null, isBreak ? "中断" : "完成", null, isBreak);
                        onCompleted?.Invoke(!isBreak);
                    }
                });
                thread.IsBackground = true;
                thread.Start();
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            Client client = CodeExample.createKalturaClient();
            bool   done   = false;
            AccessControlProfile accessControlProfile = new AccessControlProfile();

            accessControlProfile.Name  = "foo";
            accessControlProfile.Rules = new List <Rule>();
            accessControlProfile.Rules.Add(new Rule());
            accessControlProfile.Rules[0].Code     = "thiscode";
            accessControlProfile.Rules[0].Contexts = new List <ContextTypeHolder>();
            accessControlProfile.Rules[0].Contexts.Add(new ContextTypeHolder());
            accessControlProfile.Rules[0].Contexts[0].Type = 1;
            accessControlProfile.Rules[0].Contexts.Add(new ContextTypeHolder());
            accessControlProfile.Rules[0].Conditions = new List <Condition>();
            accessControlProfile.Rules[0].Conditions.Add(new Condition());
            accessControlProfile.Rules[0].Conditions[0].Description = "cond 1";
            accessControlProfile.Rules[0].Conditions.Add(new Condition());
            accessControlProfile.Rules[0].Conditions[1].Description = "cond 2";
            accessControlProfile.Rules.Add(new Rule());
            accessControlProfile.Rules[1].Code = "second code";

            OnCompletedHandler <AccessControlProfile> handler = new OnCompletedHandler <AccessControlProfile>(
                (AccessControlProfile result, Exception e) =>
            {
                CodeExample.PrintObject(result);
                done = true;
            });

            AccessControlProfileService.Add(accessControlProfile)
            .SetCompletion(handler)
            .Execute(client);

            while (!done)
            {
                Thread.Sleep(100);
            }
        }
예제 #8
0
        static void Main(string[] args)
        {
            Client           client = CodeExample.createKalturaClient();
            bool             done   = false;
            MediaEntryFilter filter = new MediaEntryFilter();
            FilterPager      pager  = new FilterPager();

            OnCompletedHandler <ListResponse <MediaEntry> > handler = new OnCompletedHandler <ListResponse <MediaEntry> >(
                (ListResponse <MediaEntry> result, Exception e) =>
            {
                CodeExample.PrintObject(result);
                done = true;
            });

            MediaService.List(filter, pager)
            .SetCompletion(handler)
            .Execute(client);

            while (!done)
            {
                Thread.Sleep(100);
            }
        }
 public BaseRequestBuilder <T> SetCompletion(OnCompletedHandler <T> completion)
 {
     onCompletion = completion;
     return(this);
 }