Exemple #1
0
 private void init()
 {
     try
     {
         string  retData = Functions.HttpGet(Functions.URL + "/api/getSortList");
         JObject jo      = (JObject)JsonConvert.DeserializeObject(retData);
         Action  act     = () =>
         {
             label4.Text = "获取分区列表....";
             listBox1.Items.Clear();
             string msg  = jo["msg"].ToString();
             string code = jo["code"].ToString();
             foreach (var item in jo["rows"])
             {
                 sortItem sort = new sortItem(item["sid"].ToString(), item["name"].ToString());
                 listBox1.Items.Add(sort);
             }
             label4.Text = "分区列表获取完成";
         };
         listBox1.Invoke(act);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Exemple #2
0
        /// <summary>
        /// Convert finalized Sort Item to Movie
        /// </summary>
        /// <param name="sortModel">Model to convert to Movie</param>
        /// <returns>Movie converted from SortMediaItem</returns>
        public static Movie ToMovie(this sortItem sortModel)
        {
            Movie newMovie = new Movie {
                pk_MovieID = sortModel.pk_MediaID, FileName = sortModel.fileName, FilePath = sortModel.filePath
            };

            return(newMovie);
        }
Exemple #3
0
        /// <summary>
        /// Convert finalized Sort Item to Television Episode
        /// </summary>
        /// <param name="sortModel">Model to convert to Television Episode</param>
        /// <returns>TelevisionEpisode converted from SortMediaItem</returns>
        public static TelevisionEpisode ToEpisode(this sortItem sortModel)
        {
            TelevisionEpisode newEpisode = new TelevisionEpisode {
                pk_EpisodeID = sortModel.pk_MediaID, EpisodePath = sortModel.filePath
            };

            return(newEpisode);
        }
        /// <summary>
        /// Determine if the episode file name is sanitized according to SDN Media library format
        /// </summary>
        /// <returns>True if file passes sanitization check</returns>
        public static bool IsTitleSanitized(sortItem model)
        {
            bool finalSaniStatus = false;



            return(finalSaniStatus);
        }
        /// <summary>
        /// Action to add sort item to the database
        /// </summary>
        /// <param name="newItem">MediaManagerDBModel representing the new item to add to the database</param>
        /// <returns>
        /// redirect to view displaying kendoui grid with all sort items
        /// </returns>
        public ActionResult AddSortItem(sortItem newItem)
        {
            MediaManagerDB items = new MediaManagerDB();

            items.sortItems.Add(newItem);
            items.SaveChanges();

            return(RedirectToAction("GetContent"));
        }
        /// <summary>
        /// Get File size
        /// </summary>
        /// <param name="uSort">model representing sort item to query for file size</param>
        /// <returns>size of file in bytes</returns>
        public static long GetFileSize(this sortItem uSort)
        {
            long finalSize;

            FileInfo info = new FileInfo(uSort.filePath);

            finalSize = info.Length;

            return(finalSize);
        }
Exemple #7
0
        public ActionResult sortItems_Destroy([DataSourceRequest] DataSourceRequest request, sortItem MediaManagerDBModel)
        {
            if (ModelState.IsValid)
            {
                var entity = new sortItem
                {
                    pk_MediaID         = MediaManagerDBModel.pk_MediaID,
                    filePath           = MediaManagerDBModel.filePath,
                    fileName           = MediaManagerDBModel.fileName,
                    fileNameSanitized  = MediaManagerDBModel.fileNameSanitized,
                    fk_fileMediaTypeID = MediaManagerDBModel.fk_fileMediaTypeID,
                    fileAdded          = MediaManagerDBModel.fileAdded,
                    fileModified       = MediaManagerDBModel.fileModified,
                    hasBeenProcessed   = MediaManagerDBModel.hasBeenProcessed,
                    hasBeenSanitized   = MediaManagerDBModel.hasBeenSanitized
                };

                db.sortItems.Attach(entity);
                db.sortItems.Remove(entity);
                db.SaveChanges();
            }

            return(Json(new[] { MediaManagerDBModel }.ToDataSourceResult(request, ModelState)));
        }
Exemple #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (isupload)
            {
                MessageBox.Show("正在上传,请等待");
                return;
            }
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "所有文件|*.*";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fName = openFileDialog.FileName;
                //先获取id
                if (listBox1.SelectedIndex < 0)
                {
                    MessageBox.Show("未选择上传分区");
                    return;
                }
                sortItem tmpItem = (sortItem)listBox1.Items[listBox1.SelectedIndex];
                string   retData = Functions.HttpPost(Functions.URL + "/index/api/isUpload", "name=" + Functions.URLEncode(textBox1.Text) + "&filename=" + Functions.URLEncode(Path.GetFileName(fName))
                                                      + "&exp=" + Functions.URLEncode(textBox2.Text) + "&sort_id=" + tmpItem.ID + "&price=" + textBox3.Text + "&logo=" + Functions.URLEncode(m_image));
                JObject jo   = (JObject)JsonConvert.DeserializeObject(retData);
                string  msg  = jo["msg"].ToString();
                string  code = jo["code"].ToString();
                if (code == "0")
                {
                    retData = Functions.HttpPost(Functions.URL + "/index/api/applyUpload", "name=" + Functions.URLEncode(textBox1.Text) + "&filename=" + Functions.URLEncode(Path.GetFileName(fName))
                                                 + "&exp=" + Functions.URLEncode(textBox2.Text) + "&sort_id=" + tmpItem.ID + "&price=" + textBox3.Text + "&logo=" + Functions.URLEncode(m_image));
                    jo = (JObject)JsonConvert.DeserializeObject(retData);
                    uploadFile(fName, jo["id"].ToString());
                }
                else if (code == "-2")
                {
                    DialogResult dr = MessageBox.Show("你有一个未完成的任务,是否先将未完成的任务上传?\n点击是将先上传之前的文件,否将上一个任务删除,直接进行新任务的上传", "提示", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.Yes)
                    {
                        string filePath = Functions.ReadIni("sid_" + jo["sid"].ToString(), "filename");
                        if (!File.Exists(filePath))
                        {
                            if (MessageBox.Show("在这台电脑上没有找到相应的上传记录,是否删除记录?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                Functions.HttpPost(Functions.URL + "/index/user/remove_upload?sid=" + jo["sid"].ToString());
                            }
                            return;
                        }
                        isupload    = true;
                        label4.Text = "准备上传...";
                        IPHostEntry host = Dns.GetHostByName("d.icodef.com");
                        IPAddress   ip   = host.AddressList[0];
                        m_ftc = new ftc(ip.ToString(), FtcCallBack);//10.127.134.51
                        m_ftc.SetFileId(long.Parse(jo["sid"].ToString()));
                        m_ftc.SendToSid();
                    }
                    else
                    {
                        Functions.HttpPost(Functions.URL + "/index/user/remove_upload?sid=" + jo["sid"].ToString());
                        retData = Functions.HttpPost(Functions.URL + "/index/api/applyUpload", "name=" + Functions.URLEncode(textBox1.Text) + "&filename=" + Functions.URLEncode(Path.GetFileName(fName))
                                                     + "&exp=" + Functions.URLEncode(textBox2.Text) + "&sort_id=" + tmpItem.ID + "&price=" + textBox3.Text + "&logo=" + Functions.URLEncode(m_image));
                        jo = (JObject)JsonConvert.DeserializeObject(retData);
                        uploadFile(fName, jo["id"].ToString());
                    }
                }
                else
                {
                    MessageBox.Show(msg);
                }
            }
        }