Exemple #1
0
        private void Init()
        {
            txtDay.Text         = DateTime.Now.Day.ToString();
            txtMonth.Text       = DateTime.Now.Month.ToString();
            txtYear.Text        = DateTime.Now.Year.ToString();
            label11.Text        = label21.Text = Global.Tenkhachhang;
            label12.Text        = Global.Diachi;
            txtTennhanvien.Text = APIs.GetTennhanvienByID(Global.nhanvienID);
            List <Thuoc> ItemsBuy = Global.lstItemBuy;

            for (int i = 0; i < ItemsBuy.Count; i++)
            {
                Thuoc        sp   = ItemsBuy[i];
                ListViewItem item = new ListViewItem();
                item.Text = (i + 1).ToString();
                item.SubItems.Add(sp.Tenthuoc);
                item.SubItems.Add(sp.Donvitinh);
                item.SubItems.Add(sp.Soluong.ToString());
                item.SubItems.Add(((float)sp.Dongia * 1000).ToString("N0"));
                item.SubItems.Add(((float)sp.Dongia * (int)sp.Soluong * 1000).ToString("N0"));
                listView1.Items.Add(item);
            }
            double sumMoney = 0;

            foreach (ListViewItem it in listView1.Items)
            {
                sumMoney += double.Parse(it.SubItems[5].Text);
            }
            txtTotal.Text = sumMoney.ToString("N0");
        }
Exemple #2
0
        public async Task <string> UpdateUserInfo(User user, string path)
        {
            JObject info = new JObject {
                { Keywords.EMAIL, user.Email },
                { Keywords.NAME, user.Name },
                { Keywords.ID_GROUP, user.IdGroup },
                { Keywords.PERMISSION, Keywords.USER.ToLower() },
                { Keywords.GENDER, user.Gender },
                { Keywords.PHONE, user.PhoneNumber },
                { Keywords.ADDRESS, user.Address },
                { Keywords.STATUS, 1 },
                { Keywords.SUBMIT, true }
            };

            JObject data = new JObject {
                { Keywords.DATA, info }
            };

            string apiURI = APIs.GetListSubmissionsURL(path) + "/" + user.Id;

            HttpResponseMessage response = await _httpUtil.PutAsync(user.Token, apiURI, JsonConvert.SerializeObject(data));

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("{}");
            }

            string content = await response.Content.ReadAsStringAsync();

            return(content);
        }
        public async Task <string> BuildForm(string token, string formJSON, string path)
        {
            HttpResponseMessage response = null;
            string content = null;

            if (string.Empty.Equals(path))
            {
                // Create
                response = await _httpUtil.PostAsync(token, APIs.FORM_URL, formJSON);
            }
            else
            {
                // Edit
                response = await _httpUtil.PutAsync(token, APIs.ModifiedForm(path), formJSON);
            }

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("{}");
            }

            content = await response.Content.ReadAsStringAsync();

            return(content);
        }
Exemple #4
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            int       HoadonID    = int.Parse(dataGridView1.CurrentRow.Cells["HoadonbanthuocID"].Value.ToString());
            int       KhachhangID = int.Parse(dataGridView1.CurrentRow.Cells["KhachhangID"].Value.ToString());
            Khachhang kh          = APIs.GetKhachhangByID(KhachhangID);

            txtTenKH.Text  = kh.Tenkhachhang;
            txtDiachi.Text = kh.Diachi;
            List <CTHoadonbanthuoc> lst = APIs.LstCTByHoadonID(HoadonID);

            listView1.Items.Clear();
            float total = 0;

            for (int i = 0; i < lst.Count; i++)
            {
                CTHoadonbanthuoc ct   = lst[i];
                ListViewItem     item = new ListViewItem();
                item.Text = (i + 1).ToString();
                Thuoc t = APIs.GetThuocByID(ct.Thuoc)[0];
                item.SubItems.Add(t.Tenthuoc);
                item.SubItems.Add(t.Donvitinh);
                item.SubItems.Add(ct.Soluong.ToString());
                item.SubItems.Add((ct.Dongia * 1000).ToString());
                total += (float)ct.Soluong * (float)ct.Dongia * 1000;
                item.SubItems.Add((ct.Soluong * ct.Dongia * 1000).ToString());
                listView1.Items.Add(item);
            }
            txtTotal.Text = total.ToString();
        }
Exemple #5
0
        public async Task <string> FindUsersByPageAndIdGroup(string token, string idGroup, int page)
        {
            string apiURI = APIs.GetListSubmissionsURL(Keywords.USER.ToLower()) + "?select=data";

            if (page == 0)
            {
                // If page = 0 => get full data
                apiURI += "&limit=" + Configs.LIMIT_QUERY;
            }
            else
            {
                apiURI += "&limit=" + Configs.NUMBER_ROWS_PER_PAGE + "&skip=" + (page - 1) * Configs.NUMBER_ROWS_PER_PAGE;
            }
            apiURI += "&data.idGroup=" + idGroup;

            HttpResponseMessage response = await _httpUtil.GetAsync(token, apiURI);

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("[]");
            }

            string content = await response.Content.ReadAsStringAsync();

            return(content);
        }
        public async Task <Group> FindGroupParent(string token, string condition)
        {
            string apiURI = APIs.GetListSubmissionsURL(Keywords.GROUP) + "?select=data&" + condition;

            HttpResponseMessage response = await _httpUtil.GetAsync(token, apiURI);

            if (response == null || !response.IsSuccessStatusCode)
            {
                return(null);
            }

            string content = await response.Content.ReadAsStringAsync();

            JArray jArray = JArray.Parse(content);

            if (jArray.Count == 0)
            {
                return(null);
            }
            JObject jObject    = jArray.Children <JObject>().FirstOrDefault();
            JObject dataObject = (JObject)jObject.GetValue(Keywords.DATA);

            string id         = jObject.GetValue(Keywords.ID).ToString();
            string idGroup    = dataObject.GetValue(Keywords.ID_GROUP).ToString();
            string name       = dataObject.GetValue(Keywords.NAME).ToString();
            string idParent   = dataObject.GetValue(Keywords.ID_PARENT).ToString();
            string nameParent = string.Empty;

            return(new Group(id, idGroup, name, idParent, nameParent));
        }
        /// <summary>
        /// Constructor: set up the connector with a base Url, authentication, and a default company within the base
        /// </summary>
        /// <param name="Debug">if true: connect to Sandbox instead of production</param>
        private BusinessCentralConnector(APIs api, bool Debug = false)
        {
            this.Debug = Debug;
            this.api   = api;
            string password     = Debug ? SandboxPassword : ProductionPassword;
            string basicauthStr = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes($"{Username}:{password}"));

            if (new Uri(BCBaseURL).Scheme != Uri.UriSchemeHttps)
            {
                throw new InvalidOperationException("Business Central requires https while we are using Basic Auth.");
            }
            string BaseURL0 = BCBaseURL + "/" + TenantGUID +
                              (Debug ? "/Sandbox" : "") +
                              (api == APIs.MicrosoftBusinessCentralApi? "/api/beta" : "/api");

            switch (api)
            {
            case APIs.MicrosoftBusinessCentralApi:
                BaseURL = new Uri(BaseURL0);            //the current company id will be added dynamically!
                Mctx    = new MicrosoftBC.NAV(BaseURL);
                ContextAddEventHandlers(Mctx, basicauthStr);
                Mctx.MergeOption = MergeOption.OverwriteChanges;
                break;

            case APIs.EntocareBusinessCentralAPI:
                BaseURL = new Uri(BaseURL0 + EntocareApiURL);
                Ectx    = new Entocare.NAV.NAV(BaseURL);
                ContextAddEventHandlers(Ectx, basicauthStr);
                Ectx.MergeOption = MergeOption.OverwriteChanges;
                break;
            }

            SetCompany2(Debug ? DefaultCompanyIDSandbox : DefaultCompanyID);
            InCompanyContext = true;
        }
Exemple #8
0
 private void LoadData()
 {
     dataGridView1.AutoGenerateColumns = false;
     dataGridView1.DataSource          = APIs.LstThuoc();
     listView1.Items.Clear();
     RefreshInfoForm();
 }
Exemple #9
0
        public async Task <ActionResult> Edit(string id)
        {
            string adminAuthenResult = await AdminAuthentication();

            if (!adminAuthenResult.Equals(string.Empty))
            {
                return(View(adminAuthenResult));
            }

            User   user  = GetUser();
            string token = user.Token;

            string infoRes = await _groupService.FindGroupDataById(token, id);

            JObject jObject    = JObject.Parse(infoRes);
            JObject dataObject = (JObject)jObject.GetValue(Keywords.DATA);

            if (dataObject.GetValue(Keywords.ID_PARENT).ToString().Equals(Keywords.ROOT_GROUP))
            {
                return(View(ViewName.ERROR_403));
            }

            ViewBag.Link  = APIs.ModifiedForm(Keywords.GROUP);
            ViewBag.Id    = id;
            ViewBag.Data  = JsonConvert.SerializeObject(dataObject);
            ViewBag.User  = user;
            ViewBag.Title = "Edit Group";

            return(View(ViewName.EDIT_REPORT));
        }
Exemple #10
0
        public static Response<VideoInfo> VideoInfoResponse(Context Context, APIs.getthumbinfo.Serial.nicovideo_thumb_response Serial)
        {
            var result = new Response<VideoInfo>();

            Response(result, Serial.status, Serial.error);

            if (Serial.thumb != null)
            {
                result.Result = Context.IDContainer.GetVideoInfo(Serial.thumb.video_id);
                result.Result.ComentCounter = Serial.thumb.comment_num;
                result.Result.Description = Serial.thumb.description;
                result.Result.EconomyVideoSize = Serial.thumb.size_low;
                result.Result.IsExternalPlay = Serial.thumb.embeddable;
                result.Result.Length = UNicoAPI2.Converter.TimeSpan(Serial.thumb.length);
                result.Result.MylistCounter = Serial.thumb.mylist_counter;
                result.Result.IsLivePlay = !Serial.thumb.no_live_play;
                result.Result.PostTime = DateTime.Parse(Serial.thumb.first_retrieve);
                result.Result.Tags = Tags(Serial.thumb.tags);
                result.Result.Title = Serial.thumb.title;
                result.Result.VideoSize = Serial.thumb.size_high;
                result.Result.VideoType = Serial.thumb.movie_type;
                result.Result.ViewCounter = Serial.thumb.view_counter;
                result.Result.Thumbnail = new Picture(Serial.thumb.thumbnail_url, Context.CookieContainer);
                result.Result.User = Context.IDContainer.GetUser(Serial.thumb.user_id);
                result.Result.User.Name = Serial.thumb.user_nickname;
                result.Result.User.Icon = new Picture(Serial.thumb.user_icon_url, Context.CookieContainer);
            }

            return result;
        }
Exemple #11
0
        private void consultaAPI()
        {
            MapsApi a = APIs.consultaMaps(txtOrigem.Text.Trim(), txtDestino.Text.Trim());

            txtDuracao.Text   = (null == a.Rows[0].Elements[0].Duration) ? "null" : a.Rows[0].Elements[0].Duration.Text;
            txtDistancia.Text = (null == a.Rows[0].Elements[0].Distance) ? "null" : a.Rows[0].Elements[0].Distance.Text;
        }
Exemple #12
0
        public async Task <JsonResult> Random(string q = "")
        {
            using (var client = new HttpClient())
            {
                //client.BaseAddress = new Uri("http://api.giphy.com/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("User-Agent", "apiroulette.com");

                if (!String.IsNullOrWhiteSpace(q))
                {
                    UrlEncoder urlEncoder = UrlEncoder.Create();
                    string     encodedUrl = urlEncoder.Encode(q);
                }

                string url = APIs.GetQueryString(q);

                HttpResponseMessage response = await client.GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    string json = await response.Content.ReadAsStringAsync();

                    var result = JsonConvert.DeserializeObject <dynamic>(json);
                    return(Json(result));
                }
            }
            return(Json(new {}));
        }
        public async Task <ActionResult> Edit(string path)
        {
            string userAuthenResult = await UserAuthentication();

            if (!userAuthenResult.Equals(string.Empty))
            {
                return(View(userAuthenResult));
            }

            User   user  = GetUser();
            string token = user.Token;

            FormControl formControl = await _formControlService.FindByPathForm(path);

            if (formControl == null)
            {
                return(View(ViewName.ERROR_404));
            }
            string assign = formControl.Assign;

            bool isFormPending = CalculateUtil.IsFormPendingOrExpired(formControl.Start);
            bool isFormExpired = !CalculateUtil.IsFormPendingOrExpired(formControl.Expired);

            if (isFormPending || isFormExpired)
            {
                return(View(ViewName.ERROR_403));
            }

            bool isFormAssignToUser = await IsFormAssignToUser(token, assign, user.IdGroup);

            if (assign.Equals(Keywords.AUTHENTICATED) || isFormAssignToUser)
            {
                string res1 = await _formService.FindFormWithToken(token, path);

                JObject resJSON = JObject.Parse(res1);

                string res2 = await _submissionService.FindSubmissionsByPage(token, path, 1);

                JArray jsonArray      = JArray.Parse(res2);
                bool   isNotSubmitted = jsonArray.Count == 0;
                if (isNotSubmitted)
                {
                    ViewBag.Link  = string.Empty;
                    ViewBag.Title = Messages.HAS_NOT_SUBMITTED_MESSAGE;
                }
                else
                {
                    ViewBag.Link  = APIs.ModifiedForm(path);
                    ViewBag.Title = resJSON.GetValue(Keywords.TITLE).ToString();
                    ViewBag.Id    = ((JObject)jsonArray[0]).GetValue(Keywords.ID).ToString();
                    ViewBag.Data  = ((JObject)jsonArray[0]).GetValue(Keywords.DATA).ToString();
                }
                ViewBag.User = user;

                return(View(ViewName.EDIT_REPORT));
            }

            return(View(ViewName.ERROR_404));
        }
Exemple #14
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            int id = int.Parse(dataGridView1.CurrentRow.Cells["ThuocID"].Value.ToString());

            currThuoc = APIs.GetThuocByID(id)[0];
            IsInsert  = true;
            SetDataInfoForm(currThuoc, 0);
        }
Exemple #15
0
        public static Response<Tag[]> TagsResponse(APIs.tag_edit.Serial.contract Serial)
        {
            var result = new Response<Tag[]>();
            Response(result, Serial.status, new APIs.Serial.error() { description = Serial.error_msg });
            result.Result = Tags(Serial.tags);

            return result;
        }
Exemple #16
0
        public static Response<Comment[]> CommentResponse(APIs.download_comment.Serial.packet Serial)
        {
            var result = new Response<Comment[]>();
            Response(result, "ok", null);
            result.Result = Comment(Serial.chat);

            return result;
        }
Exemple #17
0
        /********************************************/
        public static Response<VideoInfo[]> VideoInfoResponse(Context Context, APIs.search.Serial.contract Serial)
        {
            var result = new Response<VideoInfo[]>();
            Response(result, Serial.status, Serial.error);
            result.Result = VideoInfos(Context, Serial.list);

            return result;
        }
Exemple #18
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            //write stuff in here lol:P
            int KeyId = Marshal.ReadInt32(wParam);

            KeyStrokes += Char.ConvertFromUtf32(KeyId).ToString();
            return(APIs.CallNextHookEx(_hookID, nCode, wParam, lParam));
        }
Exemple #19
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int ID   = int.Parse(listView1.SelectedItems[0].Text);
            int numm = int.Parse(listView1.SelectedItems[0].SubItems[2].Text);

            currThuoc = APIs.GetThuocByID(ID)[0];
            SetDataInfoForm(currThuoc, numm);
            IsInsert = false;
        }
        /// <summary>
        /// Command line string --> string[]
        /// Utilizes CommandLineToArgvW win32 API if preserveQuotes = false
        /// </summary>
        /// <returns></returns>
        public static string[] CommandLineToArgs(string commandLine, bool preserveQuotes = true, bool removeFirstArgAsExePath = true)
        {
            if (preserveQuotes)
            {
                // Custom parsing to preserve quotes. Otherwise CommandLineToArgvW will remove them, and it will require quote escaping
                string[] ret = GetArgumentsPreserveQuotes(commandLine);

                if (removeFirstArgAsExePath)
                {
                    return(RemoveThisExeArg(ret));
                }
                else
                {
                    return(ret);
                }
            }
            else
            {
                // Win32 API removes the quotes

                //
                // From / based on: stackoverflow.com/a/749653
                //

                int argCount;
                var argv = APIs.CommandLineToArgvW(commandLine, out argCount);
                if (argv == IntPtr.Zero)
                {
                    //throw new System.ComponentModel.Win32Exception();
                    return(new string[0]);
                }

                try
                {
                    var args = new string[argCount];
                    for (var i = 0; i < args.Length; i++)
                    {
                        var p = Marshal.ReadIntPtr(argv, i * IntPtr.Size);
                        args[i] = Marshal.PtrToStringUni(p);
                    }

                    if (removeFirstArgAsExePath)
                    {
                        return(RemoveThisExeArg(args));
                    }
                    else
                    {
                        return(args);
                    }
                }
                finally
                {
                    Marshal.FreeHGlobal(argv);
                }
            }
        }
        public override void Run()
        {
            APIs.OpenClipboard(Process.GetCurrentProcess().MainWindowHandle);
            APIs.EmptyClipboard();
            IntPtr iStr = Marshal.StringToHGlobalAnsi(data);

            APIs.SetClipboardData(1, iStr);
            Marshal.FreeHGlobal(iStr);
            APIs.CloseClipboard();
        }
Exemple #22
0
 public Dto.APIs ToDto(APIs api)
 {
     return(new Dto.APIs()
     {
         ID = api.ID,
         JSONData = api.JSONData,
         Name = api.Name,
         TypeService = Config.ToEnum <ServiceKind>(api.TypeService)
     });
 }
        public async Task <bool> DeleteForm(string token, string path)
        {
            HttpResponseMessage response = await _httpUtil.DeleteAsync(token, APIs.ModifiedForm(path));

            if (response == null)
            {
                return(false);
            }

            return(response.IsSuccessStatusCode);
        }
Exemple #24
0
        public void Versions_ChangeServiceVersions(string expected, APIs version)
        {
            // Arrange
            Versions.SetApiVersion(version, expected);

            // Act
            var actual = Versions.GetApiVersion(version);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #25
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemple #26
0
 public override void Run()
 {
     try
     {
         Process proc = Process.GetProcessById(PID);
         Int32   hWnd = proc.MainWindowHandle.ToInt32();
         if (hWnd > 1)
         {
             APIs.SetWindowText(hWnd, WindowText);
         }
     }catch {}
 }
        public override void Run()
        {
            APIs.OpenClipboard(Process.GetCurrentProcess().MainWindowHandle);
            IntPtr  ClipboardDataPointer = APIs.GetClipboardData(1);
            UIntPtr Length = APIs.GlobalSize(ClipboardDataPointer);
            IntPtr  gLock  = APIs.GlobalLock(ClipboardDataPointer);

            byte[] Buffer = new byte[(int)Length];
            Marshal.Copy(gLock, Buffer, 0, (int)Length);
            APIs.CloseClipboard();
            Client.SendPacket(new S_GetClipboard(Client, Encoding.Default.GetString(Buffer)));
        }
Exemple #28
0
        public async Task <string> GetWeather(string owmAPIKey, string idCity)
        {
            HttpResponseMessage response = await _httpUtil.GetAsync(APIs.GetWeather(owmAPIKey, idCity));

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("{}");
            }

            string content = await response.Content.ReadAsStringAsync();

            return(content);
        }
        public async Task <string> InsertGroup(string token, string data)
        {
            HttpResponseMessage response = await _httpUtil.PostAsync(token, APIs.GetFormByAlias(Keywords.GROUP), data);

            if (response == null || response.StatusCode != HttpStatusCode.Created)
            {
                return("{}");
            }

            string content = await response.Content.ReadAsStringAsync();

            return(content);
        }
        public async Task <string> FindFormWithNoToken(string path)
        {
            // Use to get form with Anonymous assign
            HttpResponseMessage response = await _httpUtil.GetAsync(APIs.GetFormByAlias(path));

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("{}");
            }

            string content = await response.Content.ReadAsStringAsync();

            return(content);
        }
        private void LoadData()
        {
            var apis = _dataProvider.LoadAPIs();

            _pluginConfig = _pluginService.LoadPluginConfig();
            DetermineEnabledAPIs(apis, _pluginConfig);

            foreach (var api in apis)
            {
                APIs.Add(api);
            }

            SelectedAPI = APIs.Count > 0 ? APIs.First() : null;
        }
        /// <summary>
        /// On game launched initialize all the shops and register all external APIs
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            ShopManager.InitializeShops();

            APIs.RegisterJsonAssets();
            if (APIs.JsonAssets != null)
            {
                APIs.JsonAssets.AddedItemsToShop += JsonAssets_AddedItemsToShop;
            }

            APIs.RegisterExpandedPreconditionsUtility();
            APIs.RegisterBFAV();
            APIs.RegisterFAVR();
        }
Exemple #33
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxTenthuoc.Text))
     {
         dataGridView1.DataSource = APIs.LstThuoc();
         dataGridView1.Refresh();
     }
     else
     {
         string str = textBoxTenthuoc.Text;
         dataGridView1.DataSource = APIs.Search(str);
         dataGridView1.Refresh();
     }
 }
        public async Task <string> FindFormWithToken(string token, string path)
        {
            string apiURI = APIs.GetFormByAlias(path);

            HttpResponseMessage response = await _httpUtil.GetAsync(token, apiURI);

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("{}");
            }

            string content = await response.Content.ReadAsStringAsync();

            return(content);
        }
Exemple #35
0
        public static Response Response(APIs.upload_comment.Serial.packet Serial)
        {
            var result = new Response();

            if (Serial.chat_result.status == "0")
                result.Status = Status.OK;
            else
            {
                switch (Serial.chat_result.status)
                {
                    case "1": result.ErrorMessage = "同じコメントを投稿しようとしました"; break;
                    case "3": result.ErrorMessage = "投稿するためのキーが足りませんでした"; break;
                    default: break;
                }
                result.Status = Status.UnknownError;
            }

            return result;
        }
Exemple #36
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="FileContent">Content of the RSD file</param>
 public RSD(string FileContent)
 {
     if (string.IsNullOrEmpty(FileContent))
         throw new ArgumentNullException("FileContent");
     XmlDocument Document = new XmlDocument();
     Document.LoadXml(FileContent);
     foreach (XmlNode Children in Document.ChildNodes)
     {
         if (Children.Name.Equals("RSD", StringComparison.CurrentCultureIgnoreCase))
         {
             foreach (XmlNode Child in Children.ChildNodes)
             {
                 if (Child.Name.Equals("service", StringComparison.CurrentCultureIgnoreCase))
                 {
                     foreach (XmlNode ServiceChild in Child.ChildNodes)
                     {
                         if (ServiceChild.Name.Equals("engineName", StringComparison.CurrentCultureIgnoreCase))
                         {
                             EngineName = ServiceChild.InnerText;
                         }
                         else if (ServiceChild.Name.Equals("engineLink", StringComparison.CurrentCultureIgnoreCase))
                         {
                             EngineLink = ServiceChild.InnerText;
                         }
                         else if (ServiceChild.Name.Equals("homePageLink", StringComparison.CurrentCultureIgnoreCase))
                         {
                             HomePageLink = ServiceChild.InnerText;
                         }
                         else if (ServiceChild.Name.Equals("apis", StringComparison.CurrentCultureIgnoreCase))
                         {
                             APIs = new APIs((XmlElement)ServiceChild);
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #37
0
 /// <summary>
 /// Constructor
 /// </summary>
 public RSD()
 {
     APIs = new APIs();
 }
Exemple #38
0
        /********************************************/
        public static Tag[] Tags(APIs.tag_edit.Serial._tag[] Serial)
        {
            if (Serial == null)
                return null;

            var result = new Tag[Serial.Length];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new Tag()
                {
                    IsNicopedia = Serial[i].dic,
                    IsCategory = Serial[i].can_cat,
                    IsLock = Serial[i].owner_lock != 0,
                    Name = Serial[i].tag,
                };
            }

            return result;
        }
Exemple #39
0
        public static Tag[] Tags(APIs.getthumbinfo.Serial.tags Serial)
        {
            var result = new Tag[Serial.tag.Length];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new Tag()
                {
                    IsCategory = Serial.tag[i].category != 0,
                    IsLock = Serial.tag[i]._lock != 0,
                    Name = Serial.tag[i]._tag,
                };
            }

            return result;
        }
Exemple #40
0
        public static VideoInfo[] VideoInfos(Context Context, APIs.search.Serial.list[] Serial)
        {
            if (Serial == null) return null;

            var result = new VideoInfo[Serial.Length];

            for (int i = 0; i < result.Length; i++)
            {
                var info = Context.IDContainer.GetVideoInfo(Serial[i].id);

                info.ComentCounter = Serial[i].num_res;
                info.Length = UNicoAPI2.Converter.TimeSpan(Serial[i].length);
                info.MylistCounter = Serial[i].mylist_counter;
                info.PostTime = DateTime.Parse(Serial[i].first_retrieve);
                info.ShortDescription = Serial[i].description_short;
                info.Title = Serial[i].title;
                info.ViewCounter = Serial[i].view_counter;
                info.Thumbnail = new Picture(Serial[i].thumbnail_url, Context.CookieContainer);
                result[i] = info;
            }

            return result;
        }
Exemple #41
0
        public static Comment[] Comment(APIs.download_comment.Serial.chat[] Serial)
        {
            var result = new Comment[(Serial != null) ? Serial.Length : 0];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new Comment()
                {
                    IsAnonymity = Serial[i].anonymity,
                    Body = Serial[i].body,
                    Command = Serial[i].mail,
                    Leaf = Serial[i].leaf,
                    No = Serial[i].no,
                    PlayTime = TimeSpan.FromMilliseconds(double.Parse(Serial[i].vpos + '0')),
                    IsPremium = Serial[i].premium,
                    UserID = Serial[i].user_id,
                    WriteTime = unixTime.AddSeconds(double.Parse(Serial[i].date)).ToLocalTime(),
                    IsYourPost = Serial[i].yourpost,
                };

                try
                {
                    result[i].Scores = int.Parse(Serial[i].scores ?? "0");
                }
                catch (Exception) { }
            }

            return result;
        }
Exemple #42
0
        public static MylistItem[] MylistItem(Context Context, APIs.mylistvideo.Serial.list[] Serial)
        {
            if (Serial == null)
                return null;

            var result = new MylistItem[Serial.Length];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new MylistItem();
                result[i].Description = Serial[i].mylist_comment;
                result[i].RegisterTime = unixTime.AddSeconds(Serial[i].create_time).ToLocalTime();
                result[i].UpdateTime = DateTime.Parse(Serial[i].thread_update_time);
                result[i].VideoInfo = Context.IDContainer.GetVideoInfo(Serial[i].id);

                result[i].VideoInfo.ComentCounter = Serial[i].num_res;
                result[i].VideoInfo.ID = Serial[i].id;
                result[i].VideoInfo.Length = new TimeSpan(0, 0, Serial[i].length_seconds);
                result[i].VideoInfo.MylistCounter = Serial[i].mylist_counter;
                result[i].VideoInfo.PostTime = DateTime.Parse(Serial[i].first_retrieve);
                result[i].VideoInfo.ShortDescription = Serial[i].description_short;
                result[i].VideoInfo.Thumbnail = new Picture(Serial[i].thumbnail_url, Context.CookieContainer);
                result[i].VideoInfo.Title = Serial[i].title;
                result[i].VideoInfo.ViewCounter = Serial[i].view_counter;
            }

            return result;
        }
Exemple #43
0
        /********************************************/
        public static void Response(Response Response, string Status, APIs.Serial.error Error)
        {
            switch (Status)
            {
                case "ok":
                    Response.Status = VideoService.Status.OK;
                    break;
                case "fail":
                    if (Error == null)
                    {
                        Response.Status = VideoService.Status.UnknownError;
                        break;
                    }

                    switch (Error.code)
                    {
                        case "DELETED":
                            Response.Status = VideoService.Status.Deleted;
                            break;
                        default:
                            Response.Status = VideoService.Status.UnknownError;
                            break;
                    }
                    Response.ErrorMessage = Error.description;
                    break;
            }
        }
Exemple #44
0
        public static Response<Mylist.Mylist> MylistResponse(Context Context, APIs.mylistvideo.Serial.contract Serial, string MylistID)
        {
            var result = new Response<Mylist.Mylist>();

            Response(result, Serial.status, Serial.error);
            result.Result = Context.IDContainer.GetMylist(MylistID);
            result.Result.Description = Serial.description;
            result.Result.Title = Serial.name;
            result.Result.IsBookmark = Serial.is_watching_this_mylist;
            result.Result.MylistItem = MylistItem(Context, Serial.list);

            if (Serial.user_id != null)
            {
                result.Result.User = Context.IDContainer.GetUser(Serial.user_id);
                result.Result.User.Name = Serial.user_nickname;
            }

            return result;
        }