Ejemplo n.º 1
0
        public TaskCollection loadTaskCollection()
        {
            var f = new FileInfo(tasksFileName);

            if (f.Exists)
            {
                using (StreamReader r = File.OpenText(tasksFileName))
                {
                    try
                    {
                        string s = r.ReadToEnd();
                        return(taskCollection = JSONHelper.Deserialize <TaskCollection>(s));
                    }
                    finally
                    {
                        r.Close();
                    }
                }
            }
            else
            {
                return
                    (new TaskCollection());
            }
        }
Ejemplo n.º 2
0
        private void WindowBase_Loaded(object sender, RoutedEventArgs e)
        {
            RoleAddDialogModel.pageModel.TreeData.Clear();
            this.DataContext = RoleAddDialogModel.pageModel;
            List <PermissionsEntity> perInfo   = RoleAddDialogModel.pageModel.PermissionsDB.GetAll <PermissionsEntity>().ToList();
            List <PermissionsEntity> mainNodes = perInfo.Where((p) => p.ParentId == null).OrderBy((o) => o.DisplayOrder).ToList();

            foreach (var permissionNode in mainNodes)
            {
                MRoleTreeData            mainInfo   = JSONHelper.Deserialize <MRoleTreeData>(JSONHelper.Serialize(permissionNode));
                List <PermissionsEntity> childNodes = perInfo.Where((p) => p.ParentId == permissionNode.PermissionId).OrderBy((o) => o.DisplayOrder).ToList();
                RoleAddDialogModel.pageModel.TreeData.Add(mainInfo);
                if (childNodes.Count > 0)
                {
                    foreach (var child in childNodes)
                    {
                        MRoleTreeData childInfo = JSONHelper.Deserialize <MRoleTreeData>(JSONHelper.Serialize(child));
                        mainInfo.Children.Add(childInfo);
                        childInfo.Parent = mainInfo;
                        if (!string.IsNullOrEmpty(RoleAddDialogModel.pageModel.RoleData.PermissionCodes))
                        {
                            if (RoleAddDialogModel.pageModel.RoleData.PermissionCodes.Split(',').Any((p) => p.Equals(child.PermissionCode.ToString())))
                            {
                                childInfo.IsChecked = true;
                            }
                            else
                            {
                                childInfo.IsChecked = false;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public bool AcknowledgePurchase(GxUserType gxStoreConfig, string productId, GxUserType gxPurchaseResult)
        {
            IStoreManager          storeMgr = null;
            int                    errCode  = GetManager(gxStoreConfig, 2, out storeMgr);
            GooglePlayStoreManager mgr      = (GooglePlayStoreManager)storeMgr;
            PurchaseResult         purchase = JSONHelper.Deserialize <PurchaseResult>(gxPurchaseResult.ToJSonString());

            try
            {
                return(mgr.AcknowledgePurchase(productId, purchase));
            }
            catch (StoreConfigurationException e)
            {
                errCode        = 3;
                ErrDescription = e.Message;
            }
            catch (StoreInvalidPurchaseException e)
            {
                errCode        = 2;
                ErrDescription = e.Message;
            }
            catch (StoreServerException e)
            {
                errCode        = 4;
                ErrDescription = e.Message;
            }
            catch (StoreException e)
            {
                errCode        = 10;
                ErrDescription = e.Message;
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static List <Azure_CrossRef_AniDB_Trakt> Admin_Get_CrossRefAniDBTrakt(int animeID)
        {
            try
            {
                string username = ServerSettings.Instance.AniDb.Username;
                if (ServerSettings.Instance.WebCache.Anonymous)
                {
                    username = Constants.AnonWebCacheUsername;
                }


                string uri =
                    $@"http://{azureHostBaseAddress}/api/Admin_CrossRef_AniDB_Trakt/{animeID}?p={username}&p2={
                            ServerSettings.Instance.WebCache.AuthKey
                        }";

                string json = GetDataJson(uri);

                List <Azure_CrossRef_AniDB_Trakt> xrefs = JSONHelper.Deserialize <List <Azure_CrossRef_AniDB_Trakt> >(json);

                return(xrefs ?? new List <Azure_CrossRef_AniDB_Trakt>());
            }
            catch
            {
                return(new List <Azure_CrossRef_AniDB_Trakt>());
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var payData   = Request.QueryString["payData"];
            var ticket    = Request.QueryString["ticket"];
            var payStatus = Request.QueryString["payStatus"];

            if (!string.IsNullOrEmpty(payData) && !string.IsNullOrEmpty(ticket))
            {
                payData = EncryptionManager.AESDecrypt(payData, ticket);

                var payDataModel = JSONHelper.Deserialize <UnifiedOrderEntity>(payData);

                if (payDataModel != null)
                {
                    dingdanidnum = payDataModel.Extra["dingdanidnum"];
                    openid       = payDataModel.Extra["openid"];
                    hotelid      = payDataModel.Extra["hotelid"];
                    roomid       = payDataModel.Extra["roomid"];
                    JumpUrl(payStatus);
                }
                else
                {
                    dingdanidnum = Request.QueryString["dingdanidnum"];
                    openid       = Request.QueryString["openid"];
                    hotelid      = Request.QueryString["hotelid"];
                    roomid       = Request.QueryString["roomid"];
                    JumpUrl(payStatus);
                }
            }
            else
            {
                Response.Clear();
                Response.Write("不完整的参数");
            }
        }
Ejemplo n.º 6
0
        public static Azure_CrossRef_AniDB_Other Get_CrossRefAniDBOther(int animeID, CrossRefType xrefType)
        {
            if (!ServerSettings.WebCache_TvDB_Get)
            {
                return(null);
            }

            string username = ServerSettings.AniDB_Username;

            if (ServerSettings.WebCache_Anonymous)
            {
                username = Constants.AnonWebCacheUsername;
            }

            string uri = string.Format(@"http://{0}/api/CrossRef_AniDB_Other/{1}?p={2}&p2={3}", azureHostBaseAddress,
                                       animeID,
                                       username, (int)xrefType);
            string msg = string.Format("Getting AniDB/Other Cross Ref From Cache: {0}", animeID);

            DateTime start = DateTime.Now;

            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            string json = GetDataJson(uri);

            TimeSpan ts = DateTime.Now - start;

            msg = string.Format("Got AniDB/MAL Cross Ref From Cache: {0} - {1}", animeID, ts.TotalMilliseconds);
            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            Azure_CrossRef_AniDB_Other xref = JSONHelper.Deserialize <Azure_CrossRef_AniDB_Other>(json);

            return(xref);
        }
Ejemplo n.º 7
0
        public static List <Azure_AnimeIDTitle> Get_AnimeTitle(string query)
        {
            try
            {
                //if (!ServerSettings.Instance.WebCache.XRefFileEpisode_Send) return;
                string uri = $@"http://{azureHostBaseAddress}/api/animeidtitle/{query}";
                string msg = $"Getting Anime Title Data From Cache: {query}";

                DateTime start = DateTime.Now;
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                string json = GetDataJson(uri);

                TimeSpan ts = DateTime.Now - start;
                msg = $"Got Anime Title Data From Cache: {query} - {ts.TotalMilliseconds}";
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                List <Azure_AnimeIDTitle> titles = JSONHelper.Deserialize <List <Azure_AnimeIDTitle> >(json);

                return(titles ?? new List <Azure_AnimeIDTitle>());
            }
            catch
            {
                return(new List <Azure_AnimeIDTitle>());
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            payStatus = Request.QueryString["PayStatus"];
            var payData = Request.QueryString["payData"];
            var ticket  = Request.QueryString["ticket"];

            payData = EncryptionManager.AESDecrypt(payData, ticket);
            var payDataModel = JSONHelper.Deserialize <UnifiedOrderEntity>(payData);

            shopid = Convert.ToInt32(payDataModel.Extra["shopid"]);
            switch (payStatus.ToLower())
            {
            case "success":
                //支付成功,清空购物车,跳转到当前店铺订单列表
                clearCache = "cart.clear();";
                newUrl     =
                    string.Format(
                        "../restaurant/diancai_orderDetail.aspx?wid={0}&shopid={1}&dingdan={2}&openid={3}",
                        payDataModel.wid,
                        payDataModel.Extra["shopid"],
                        payDataModel.OrderId,
                        payDataModel.openid);
                break;

            case "fail":
            case "cancel":
                //支付失败,跳转到购物车
                newUrl =
                    string.Format(
                        "../restaurant/diancai_shoppingCart.aspx?shopid={0}&openid={1}&wid={2}",
                        payDataModel.Extra["shopid"], payDataModel.openid, payDataModel.Extra["wid"]);
                break;
            }
        }
Ejemplo n.º 9
0
        public static Azure_CrossRef_AniDB_MAL Get_CrossRefAniDBMAL(int animeID)
        {
            if (!ServerSettings.WebCache_MAL_Get)
            {
                return(null);
            }

            string username = ServerSettings.AniDB_Username;

            if (ServerSettings.WebCache_Anonymous)
            {
                username = Constants.AnonWebCacheUsername;
            }

            string uri = string.Format(@"http://{0}/api/CrossRef_AniDB_MAL/{1}?p={2}", azureHostBaseAddress, animeID,
                                       username);
            string msg = string.Format("Getting AniDB/MAL Cross Ref From Cache: {0}", animeID);

            DateTime start = DateTime.Now;

            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            string json = GetDataJson(uri);

            TimeSpan ts = DateTime.Now - start;

            msg = string.Format("Got AniDB/MAL Cross Ref From Cache: {0} - {1}", animeID, ts.TotalMilliseconds);
            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            Azure_CrossRef_AniDB_MAL xref = JSONHelper.Deserialize <Azure_CrossRef_AniDB_MAL>(json);

            xref.Self = string.Format(CultureInfo.CurrentCulture, "api/crossRef_anidb_mal/{0}",
                                      xref.CrossRef_AniDB_MALID);
            return(xref);
        }
Ejemplo n.º 10
0
        public static Azure_CrossRef_AniDB_Other Get_CrossRefAniDBOther(int animeID, CrossRefType xrefType)
        {
            try
            {
                if (!ServerSettings.Instance.WebCache.TvDB_Get)
                {
                    return(null);
                }

                string username = Constants.AnonWebCacheUsername;

                string uri =
                    $@"http://{azureHostBaseAddress}/api/CrossRef_AniDB_Other/{animeID}?p={username}&p2={
                            (int) xrefType
                        }";
                string msg = $"Getting AniDB/Other Cross Ref From Cache: {animeID}";

                DateTime start = DateTime.Now;
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                string json = GetDataJson(uri);

                TimeSpan ts = DateTime.Now - start;
                msg = $"Got AniDB/MAL Cross Ref From Cache: {animeID} - {ts.TotalMilliseconds}";
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                Azure_CrossRef_AniDB_Other xref = JSONHelper.Deserialize <Azure_CrossRef_AniDB_Other>(json);

                return(xref);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 11
0
        public static List <Azure_CrossRef_File_Episode> Get_CrossRefFileEpisode(SVR_VideoLocal vid)
        {
            try
            {
                if (!ServerSettings.Instance.WebCache.XRefFileEpisode_Get)
                {
                    return(new List <Azure_CrossRef_File_Episode>());
                }

                string username = Constants.AnonWebCacheUsername;

                string uri = $@"http://{azureHostBaseAddress}/api/CrossRef_File_Episode/{vid.Hash}?p={username}";
                string msg = $"Getting File/Episode Cross Ref From Cache: {vid.Hash}";

                DateTime start = DateTime.Now;
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                string json = GetDataJson(uri);

                TimeSpan ts = DateTime.Now - start;
                msg = $"Got File/Episode Cross Ref From Cache: {vid.Hash} - {ts.TotalMilliseconds}";
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                List <Azure_CrossRef_File_Episode> xrefs =
                    JSONHelper.Deserialize <List <Azure_CrossRef_File_Episode> >(json);

                return(xrefs ?? new List <Azure_CrossRef_File_Episode>());
            }
            catch
            {
                return(new List <Azure_CrossRef_File_Episode>());
            }
        }
Ejemplo n.º 12
0
        // TODO wrap the rest of these in timeout tasks
        public static async Task <List <Azure_FileHash> > Get_FileHashWithTaskAsync(FileHashType hashType, string hashDetails)
        {
            Task <List <Azure_FileHash> > task = new Task <List <Azure_FileHash> >(() =>
            {
                try
                {
                    string uri = $@"http://{azureHostBaseAddress}/api/FileHash/{(int) hashType}?p={hashDetails}";
                    string msg = $"Getting File Hash From Cache: {hashType} - {hashDetails}";

                    DateTime start = DateTime.Now;
                    ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                    string json = GetDataJson(uri);

                    TimeSpan ts = DateTime.Now - start;
                    msg         = $"Got File Hash From Cache: {hashDetails} - {ts.TotalMilliseconds}";
                    ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                    return(JSONHelper.Deserialize <List <Azure_FileHash> >(json));
                }
                catch
                {
                    return(new List <Azure_FileHash>());
                }
            });

            if (await Task.WhenAny(task, Task.Delay(30000)) == task)
            {
                return(await task);
            }
            return(await Task.FromResult(new List <Azure_FileHash>()));
        }
Ejemplo n.º 13
0
        public static List <Azure_Media> Get_Media(string ed2k)
        {
            if (string.IsNullOrEmpty(ed2k))
            {
                return(new List <Azure_Media>());
            }
            try
            {
                string uri = $@"http://{azureHostBaseAddress}/api/Media/{ed2k}/{SVR_VideoLocal.MEDIA_VERSION}";
                string msg = $"Getting Media Info From Cache for ED2K: {ed2k} Version : {SVR_VideoLocal.MEDIA_VERSION}";

                DateTime start = DateTime.Now;
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                string json = GetDataJson(uri);

                TimeSpan ts = DateTime.Now - start;
                msg = $"Getting Media Info From Cache for ED2K: {ed2k} - {ts.TotalMilliseconds}";
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                List <Azure_Media> medias = JSONHelper.Deserialize <List <Azure_Media> >(json) ??
                                            new List <Azure_Media>();

                return(medias);
            }catch
            {
                return(new List <Azure_Media>());
            }
        }
Ejemplo n.º 14
0
        public static List <Azure_CrossRef_AniDB_TvDB> Get_CrossRefAniDBTvDB(int animeID)
        {
            string username = ServerSettings.AniDB_Username;

            if (ServerSettings.WebCache_Anonymous)
            {
                username = Constants.AnonWebCacheUsername;
            }


            string uri = string.Format(@"http://{0}/api/CrossRef_AniDB_TvDB/{1}?p={2}", azureHostBaseAddress, animeID,
                                       username);
            string msg = string.Format("Getting AniDB/TvDB Cross Ref From Cache: {0}", animeID);

            DateTime start = DateTime.Now;

            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            string json = GetDataJson(uri);

            TimeSpan ts = DateTime.Now - start;

            msg = string.Format("Got AniDB/TvDB Cross Ref From Cache: {0} - {1}", animeID, ts.TotalMilliseconds);
            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            List <Azure_CrossRef_AniDB_TvDB> xrefs = JSONHelper.Deserialize <List <Azure_CrossRef_AniDB_TvDB> >(json);

            return(xrefs);
        }
Ejemplo n.º 15
0
        /*public static List<CrossRef_File_Episode> Get_CrossRefFileEpisode()
         * {
         *  //if (!ServerSettings.WebCache_XRefFileEpisode_Get) return null;
         *
         *  //string username = ServerSettings.AniDB_Username;
         *  //if (ServerSettings.WebCache_Anonymous)
         *  //    username = Constants.AnonWebCacheUsername;
         *
         *  string uri = string.Format(@"http://{0}/api/CrossRef_File_Episode/{1}?p={2}", azureHostBaseAddress, "88D29145F18DCEA4D4C41EF94B950378", "Ilast");
         *  string msg = string.Format("Getting File/Episode Cross Ref From Cache: {0}", "88D29145F18DCEA4D4C41EF94B950378");
         *
         *  DateTime start = DateTime.Now;
         *  JMMService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);
         *
         *  string json = GetDataJson(uri);
         *
         *  TimeSpan ts = DateTime.Now - start;
         *  msg = string.Format("Got File/Episode Cross Ref From Cache: {0} - {1}", "88D29145F18DCEA4D4C41EF94B950378", ts.TotalMilliseconds);
         *  JMMService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);
         *
         *  List<CrossRef_File_Episode> xrefs = JSONHelper.Deserialize<List<CrossRef_File_Episode>>(json);
         *
         *  return xrefs;
         * }*/

        public static List <Azure_CrossRef_File_Episode> Get_CrossRefFileEpisode(SVR_VideoLocal vid)
        {
            if (!ServerSettings.WebCache_XRefFileEpisode_Get)
            {
                return(null);
            }

            string username = ServerSettings.AniDB_Username;

            if (ServerSettings.WebCache_Anonymous)
            {
                username = Constants.AnonWebCacheUsername;
            }

            string uri = string.Format(@"http://{0}/api/CrossRef_File_Episode/{1}?p={2}", azureHostBaseAddress,
                                       vid.Hash,
                                       username);
            string msg = string.Format("Getting File/Episode Cross Ref From Cache: {0}", vid.Hash);

            DateTime start = DateTime.Now;

            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            string json = GetDataJson(uri);

            TimeSpan ts = DateTime.Now - start;

            msg = string.Format("Got File/Episode Cross Ref From Cache: {0} - {1}", vid.Hash, ts.TotalMilliseconds);
            ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

            List <Azure_CrossRef_File_Episode> xrefs = JSONHelper.Deserialize <List <Azure_CrossRef_File_Episode> >(json);

            return(xrefs);
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var payData = Request.QueryString["payData"];
            var ticket  = Request.QueryString["ticket"];

            if (!string.IsNullOrEmpty(payData) && !string.IsNullOrEmpty(ticket))
            {
                payData = EncryptionManager.AESDecrypt(payData, ticket);

                var payDataModel = JSONHelper.Deserialize <UnifiedOrderEntity>(payData);

                if (payDataModel != null)
                {
                    //赋值支付参数
                    wid          = payDataModel.wid;
                    body         = payDataModel.body;
                    payModuleID  = payDataModel.PayModuleID.ToString();
                    out_trade_no = payDataModel.out_trade_no;
                    total_fee    = payDataModel.total_fee;
                    openid       = payDataModel.openid;
                    OrderID      = payDataModel.OrderId;

                    PayComplete = string.Format("{0}{1}{2}&payStatus=",
                                                payDataModel.PayComplete,
                                                payDataModel.PayComplete.IndexOf("?", System.StringComparison.Ordinal) > 0 ? "&" : "?",
                                                Request.Url.Query.Substring(1));
                }
            }
            else
            {
                Response.Clear();
                Response.Write("不完整的参数");
            }
        }
Ejemplo n.º 17
0
        public static List <Azure_CrossRef_AniDB_TvDB> Get_CrossRefAniDBTvDB(int animeID)
        {
            try
            {
                string username = ServerSettings.Instance.AniDb.Username;
                if (ServerSettings.Instance.WebCache.Anonymous)
                {
                    username = Constants.AnonWebCacheUsername;
                }


                string uri = $@"http://{azureHostBaseAddress}/api/CrossRef_AniDB_TvDB/{animeID}?p={username}";
                string msg = $"Getting AniDB/TvDB Cross Ref From Cache: {animeID}";

                DateTime start = DateTime.Now;
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                string json = GetDataJson(uri);

                TimeSpan ts = DateTime.Now - start;
                msg = $"Got AniDB/TvDB Cross Ref From Cache: {animeID} - {ts.TotalMilliseconds}";
                ShokoService.LogToSystem(Constants.DBLogType.APIAzureHTTP, msg);

                List <Azure_CrossRef_AniDB_TvDB> xrefs = JSONHelper.Deserialize <List <Azure_CrossRef_AniDB_TvDB> >(json);

                return(xrefs ?? new List <Azure_CrossRef_AniDB_TvDB>());
            }
            catch
            {
                return(new List <Azure_CrossRef_AniDB_TvDB>());
            }
        }
 new public object GetCustomResult()
 {
     if (!string.IsNullOrWhiteSpace(this.GetRes()))
     {
         Dictionary <string, object> result = (Dictionary <string, object>)JSONHelper.Deserialize(this.GetRes());
         return(result);
     }
     return(0);
 }
Ejemplo n.º 19
0
        //public class Instruction: Dictionary<CompilerProperty, string> {}

        #endregion

        public MainWindow()
        {
            InitializeComponent();
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("es-AR");

            // Asocio tipo de archivo
            if (!FileAssociation.IsAssociated(".h5c"))
            {
                FileAssociation.Associate(".h5c", "ghApps.HTML5Compiler", "HTML5 Compiler Proyect", "H5Clogo-256.ico", AppDomain.CurrentDomain.DomainManager.EntryAssembly.Location);
            }
            // Chequeo si abrio un proyecto desde un archivo
            // Environment.GetCommandLineArgs()
            //if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null)
            //{
            string[] arguments = Environment.GetCommandLineArgs();

            if (arguments.Length > 1)
            {
                // Cargar poryecto
                try
                {
                    string filePath = arguments[1];     // string.Empty;
                    //filePath = @"C:\Proyectos\Mobile\gecommerce\trunk\src\MobileViews\mobileView.h5c";
                    string JSONProject = File.ReadAllText(filePath, Encoding.Default);

                    var oProject = JSONHelper.Deserialize <Project>(JSONProject);
                    // Chequear si los paths de oProject son relativos y modificarlos el path pasaría a estar en "filePath"

                    if (oProject != null && oProject.Configs != null && oProject.Configs.Count > 0)
                    {
                        LoadProject(oProject);
                        if (arguments.Length > 2)
                        {
                            // TODO: leer el comando y ejecutar (probablemente el unico comando sea "compilar" asi que ewjecutar compilar)
                        }
                    }
                    else
                    {
                        SetDevice(DeviceConfig.Devices.html5);
                        SaveDevice(SelectedDevice);
                    }
                }
                catch (Exception ex)
                {
                    SetDevice(DeviceConfig.Devices.html5);
                    SaveDevice(SelectedDevice);
                    txtResult.Text = "Se produjo un error al cargar el proyecto, recuerde escapar caracteres como \"\\\", etc. El log indica: " + ex.Message + Environment.NewLine;
                }
            }
            else
            {
                SetDevice(DeviceConfig.Devices.html5);
                SaveDevice(SelectedDevice);
            }
            //}
        }
Ejemplo n.º 20
0
        public bool GetFileList(string hash, ref List <TorrentFile> torFiles)
        {
            torFiles = new List <TorrentFile>();

            if (!ValidCredentials())
            {
                BaseConfig.MyAnimeLog.Write("Credentials are not valid for uTorrent");
                return(false);
            }

            try
            {
                string url    = string.Format(urlTorrentFileList, address, port, token, hash);
                string output = GetWebResponse(url);
                if (output.Length == 0)
                {
                    return(false);
                }

                TorrentFileList fileList = JSONHelper.Deserialize <TorrentFileList>(output);

                if (fileList != null && fileList.files != null && fileList.files.Length > 1)
                {
                    object[] actualFiles = fileList.files[1] as object[];
                    if (actualFiles == null)
                    {
                        return(false);
                    }

                    foreach (object obj in actualFiles)
                    {
                        object[] actualFile = obj as object[];
                        if (actualFile == null)
                        {
                            continue;
                        }

                        TorrentFile tf = new TorrentFile();
                        tf.FileName   = actualFile[0].ToString();
                        tf.FileSize   = long.Parse(actualFile[1].ToString());
                        tf.Downloaded = long.Parse(actualFile[2].ToString());
                        tf.Priority   = long.Parse(actualFile[3].ToString());

                        torFiles.Add(tf);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("Error in GetTorrentList: {0}", ex.ToString());
                return(false);
            }
        }
Ejemplo n.º 21
0
        public int GetPurchase(GxUserType gxStoreConfig, string productId, GxUserType gxPurchaseResult, GxUserType gxStorePurchase)
        {
            PurchaseResult purchase = JSONHelper.Deserialize <PurchaseResult>(gxPurchaseResult.ToJSonString());
            StorePurchase  sp       = null;
            int            errCode  = GetPurchaseImpl(gxStoreConfig, productId, purchase, out sp);

            if (errCode == 0)
            {
                gxStorePurchase.FromJSonString(sp.ToJson());
            }
            return(errCode);
        }
Ejemplo n.º 22
0
        public static Azure_AnimeLink Admin_GetRandomLinkForApproval(AzureLinkType linkType)
        {
            string username = ServerSettings.AniDB_Username;

            if (ServerSettings.WebCache_Anonymous)
            {
                username = Constants.AnonWebCacheUsername;
            }

            string uri  = string.Format(@"http://{0}/api/Admin_CrossRef_AniDB_TvDB/{1}?p={2}&p2={3}&p3=dummy", azureHostBaseAddress, (int)linkType, username, ServerSettings.WebCacheAuthKey);
            string json = GetDataJson(uri);

            return(JSONHelper.Deserialize <Azure_AnimeLink>(json));
        }
Ejemplo n.º 23
0
        public override AuthenticationTicket AuthenticateCore(AuthenticationTicket ticket)
        {
            string tokenEndpoint = string.Concat(_options.AuthorizeUrl, "/oauth2.0/me?access_token={0}");
            var    url           = string.Format(
                tokenEndpoint, ticket.AccessToken);
            string tokenResponse = _httpClient.GetStringAsync(url).Result.ToString();

            Logger.Info("请求url:{0},返回值:{1}", url, tokenResponse);
            string strJson = tokenResponse.Replace("callback(", "").Replace(");", "");
            var    payload = JSONHelper.Deserialize(strJson, typeof(Callback)) as Callback;

            ticket.OpenId = payload.openid;
            return(ticket);
        }
Ejemplo n.º 24
0
        public override AuthenticationTicket PreAuthorization(AuthenticationTicket ticket)
        {
            string tokenEndpoint = string.Concat(_options.AuthorizeUrl, "/sns/gettoken?appid={0}&appsecret={1}");
            var    url           = string.Format(
                tokenEndpoint,
                Uri.EscapeDataString(_options.AppId),
                Uri.EscapeDataString(_options.AppSecret));
            string tokenResponse = _httpClient.GetStringAsync(url).Result.ToString();

            Logger.Info("请求url:{0},返回值:{1}", url, tokenResponse);
            var payload = JSONHelper.Deserialize(tokenResponse, typeof(Callback)) as Callback;

            ticket.AccessToken = payload.access_token;
            return(ticket);
        }
Ejemplo n.º 25
0
 public override bool FromJSonString(string s)
 {
     try {
         WebSecureToken wt = JSONHelper.Deserialize <WebSecureToken>(s, Encoding.UTF8);
         this.Expiration  = wt.Expiration;
         this.Value       = wt.Value;
         this.ProgramName = wt.ProgramName;
         this.Issuer      = wt.Issuer;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 26
0
        static void ExtractJson()
        {
            var ds3raw = JSONHelper.Deserialize <DarkSouls3Text>(File.ReadAllText("ds3raw.json", new UTF8Encoding(false)));

            foreach (var langIt in ds3raw.Languages)
            {
                var lang = langIt.Value;
                lang.Accessory     = ParseGenericItems(lang, "Accessories ");
                lang.Armor         = ParseGenericItems(lang, "Armor ");
                lang.Item          = ParseGenericItems(lang, "Item ");
                lang.Magic         = ParseGenericItems(lang, "Magic ");
                lang.Weapon        = ParseGenericItems(lang, "Weapon ");
                lang.Conversations = ParseConversations(lang);
            }
            File.WriteAllText("ds3.json", JSONHelper.Serialize(ds3raw), new UTF8Encoding(false));
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            Button         btn  = sender as Button;
            UsersEntity    user = btn.Tag as UsersEntity;
            UserEditDialog view = new UserEditDialog();

            view.Model = JSONHelper.Deserialize <UsersEntity>(JSONHelper.Serialize(user));
            bool?nullable = view.ShowDialog();
            bool flag     = true;

            if ((nullable.GetValueOrDefault() == flag ? (nullable.HasValue ? 1 : 0) : 0) == 0)
            {
                return;
            }
            RefreshData();
        }
        /// <summary>
        /// 修改主表信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ReviseMain_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            FixtureFurnaceMainEntity main = (FixtureFurnaceMainEntity)btn.Tag;// as FixtureFurnaceMain;
            ChuckingDialog           view = new ChuckingDialog(main);

            view.Model = JSONHelper.Deserialize <FixtureFurnaceMainEntity>(JSONHelper.Serialize(main));
            bool?nullable = view.ShowDialog();
            bool flag     = true;

            if ((nullable.GetValueOrDefault() == flag ? (nullable.HasValue ? 1 : 0) : 0) == 0)
            {
                return;
            }
            RefreshData();
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Gets a list of all surveys available to the user.
        /// </summary>
        /// <returns>Returns IEnumerable of Survey objects.</returns>
        public IEnumerable <Survey> ListSurveys()
        {
            var content = HttpHelper.Get("/API/v3/surveys", _connection);

            if (!string.IsNullOrEmpty(content))
            {
                var surveysResult = JSONHelper <SurveyResult> .Deserialize(content);

                if (surveysResult?.Result?.Elements.Count > 0)
                {
                    foreach (var survey in surveysResult.Result.Elements)
                    {
                        yield return((Survey)survey);
                    }
                }
            }
        }
Ejemplo n.º 30
0
        public override AuthenticationTicket AuthenticateCore(AuthenticationTicket ticket)
        {
            string tokenEndpoint = string.Concat(_options.AuthorizeUrl, "/sns/get_persistent_code?access_token={0}");
            var    url           = string.Format(
                tokenEndpoint, ticket.AccessToken);
            HttpContent content = new StringContent("{{\"tmp_auth_code\": \"{0}\"}}".FormatTo(ticket.Code))
            {
                Headers = { ContentType = new MediaTypeHeaderValue("application/json") }
            };
            string tokenResponse = _httpClient.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;

            Logger.Info("请求url:{0},返回值:{1}", url, tokenResponse);
            var payload = JSONHelper.Deserialize(tokenResponse, typeof(Callback)) as Callback;

            ticket.OpenId  = payload.openid;
            ticket.UnionId = payload.unionid;
            return(ticket);
        }