}//end of create_xml

    private void create_xml(string s, bool incontrol, string inxml_file_name, string inUser_ID)
    {
        DataSet   ds_insertDB = new DataSet();
        string    sysid = "ARY_HOLD_LOT", xml_file_name = "";
        ArrayList element      = new ArrayList();
        ArrayList element_text = new ArrayList();

        DirectoryInfo di = new DirectoryInfo(Server.MapPath(".") + "/" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString());

        if (!di.Exists)
        {
            di.Create();
        }
        file xmlw = new file();

        element.Add("EVENTID");
        element_text.Add("AlarmReport");
        element.Add("SYSTEMID");
        element_text.Add(sysid);
        element.Add("EQPID");
        element_text.Add(inxml_file_name);
        element.Add("ALARMID");
        element_text.Add("MSG");
        element.Add("ALARMTEXT");
        element_text.Add(s);

        xml_file_name = sysid + "_" + DateTime.Now.ToString("yyyyMMdd") + "_" + inxml_file_name + ".xml";

        xmlw.Create_ALCS_xml(Server.MapPath(".") + "/" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString(), xml_file_name, element, element_text);
        if (incontrol == true)
        {
            FTPFactory ff = new FTPFactory();
            ff.setDebug(true);
            ff.setRemoteHost("172.16.12.78");
            ff.setRemoteUser("CIMFTP");
            ff.setRemotePass("ALCS_cim13579");

            ff.login();
            try
            {
                ff.upload(Server.MapPath(".") + "/" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString() + "/" + xml_file_name);
                //sp.Send_mail("File Upload Success","CIM CENTRAL MAIL SYSTEM<*****@*****.**>","*****@*****.**","[Array Hold Lot] XML  File Upload ALCS Success",1,Server.MapPath(".")+"/"+ DateTime.Now.ToString("yyyyMMdd")+"_ALCS_" + DateTime.Now.Hour.ToString() + "/" + xml_file_name);

                string insertDB_phone = " begin insert into std_alarm_event_history@ods2stdman ( SYSTEM,TYPE,USER_ID,USER_LEVEL,PHONE_DTTM ) " +
                                        " values('Array_Hold_Lot','PHONE','" + inUser_ID + "','" + inxml_file_name + "',sysdate); commit; end;";
                ds_insertDB = db.GetDataset(insertDB_phone, 1);
            }
            catch (Exception ex)
            {
                //sp.Send_mail("File Upload Fail"+ex.Message,"CIM CENTRAL MAIL SYSTEM<*****@*****.**>","*****@*****.**","[CIM REPORT MSG] :WeekendReport MSG:XML  File Upload ALCS Fail",0,null);
                sp.Send_mail("File Upload Fail" + ex.Message, "CIM CENTRAL MAIL SYSTEM<*****@*****.**>", "*****@*****.**", "[Array Hold Lot] XML  File Upload ALCS Fail", 0, null);
            }
        }
    }
Exemple #2
0
        public void updateFtime()
        {
            _sample2 = new NHibernateSample.Data.NHibernateSample(typeof(file));
            DateTime dt = DateTime.Now;
            file     fl = _sample2.GetFileById(16);

            fl.changetime();
            DateTime time = _sample2.GetFileById(16).time;

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(dt, time);
        }
Exemple #3
0
        public Entity.ActionStatus UploadFiles(List <Microsoft.AspNetCore.Http.IFormFile> files, string generatorId)
        {
            Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
            try
            {
                if (files.Count > 0)
                {
                    List <file> lstFileUploaded = new List <file>();
                    System.Text.StringBuilder strFileNotUploaded = new System.Text.StringBuilder();
                    foreach (var formFile in files)
                    {
                        file obj = new file();

                        string filePath = SaveGenaratorFiles(Guid.NewGuid(), formFile);
                        if (!string.IsNullOrEmpty(filePath))
                        {
                            obj.path = filePath.ToString();
                            obj.desc = Path.GetFileNameWithoutExtension(formFile.FileName);
                            lstFileUploaded.Add(obj);
                        }
                        else
                        {
                            strFileNotUploaded.Append(formFile.FileName + " is invalid! ");
                        }
                    }
                    if (lstFileUploaded.Count > 0)
                    {
                        var xmlfiles = ObjectToXMLGeneric <List <file> >(lstFileUploaded);
                        xmlfiles     = xmlfiles.Replace("ArrayOfFile", "files");
                        actionStatus = _generatorRepository.UploadFiles(xmlfiles, generatorId);
                    }
                    else
                    {
                        actionStatus.Success = false;
                        actionStatus.Message = strFileNotUploaded.ToString();
                    }
                }
                else
                {
                    actionStatus.Success = false;
                    actionStatus.Message = "Something Went Wrong!";
                }
            }
            catch (Exception ex)
            {
                _logger.InfoLog(Constants.ACTION_EXCEPTION, "GeneratorService.UploadFiles " + ex);
                return(new Entity.ActionStatus
                {
                    Success = false,
                    Message = ex.Message
                });
            }
            return(actionStatus);
        }
Exemple #4
0
        private void lbReports_DoubleClick(object sender, EventArgs e)
        {
            if (this.lbReports.SelectedItems.Count == 0)
            {
                return;
            }

            file file = (file)this.lbReports.SelectedItem;

            this.txtReportContent.Text = File.ReadAllText(file.FullName);
        }
Exemple #5
0
        //
        // GET: /File/Details/5

        public ActionResult Details(bool?isFile, int id = 0)
        {
            ViewBag.isFile = isFile.HasValue && isFile.Value;
            file file = db.files.Find(id);

            if (file == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(file));
        }
Exemple #6
0
 private void openFile(file a)
 {
     mainForm.setAndReadCurrentFileProject(a);
     this.Hide();
     using (frmWaitForm frm = new frmWaitForm(mainForm.readContentFile))
     {
         //mainForm.readContentFile();
         frm.ShowDialog(this);
     }
     closeForm();
     mainForm.openEditorForm();
 }
Exemple #7
0
 public ActionResult fileEdit([Bind(Include = "Id,name,filepath,filetypeId,personId")] file file)
 {
     if (ModelState.IsValid)
     {
         db.Entry(file).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("fileList"));
     }
     ViewBag.filetypeId = new SelectList(db.filetypes, "Id", "name", file.filetypeId);
     ViewBag.personId   = new SelectList(db.people, "Id", "fullname", file.personId);
     return(View(file));
 }
Exemple #8
0
 public ActionResult DownloadFile(int?id)
 {
     if (id.HasValue)
     {
         file file = db.files.FirstOrDefault(p => p.id == id.Value);
         if (file != null)
         {
             return(File(file.file_detail.data, System.Net.Mime.MediaTypeNames.Application.Octet, file.name));
         }
     }
     return(HttpNotFound());
 }
Exemple #9
0
    private List <file> getFilesList(string sourcePath)
    {
        List <file>  fileList      = new List <file>();
        UploadDetail upDetail      = Session["UploadDetail"] as UploadDetail;
        DataTable    OrdreTypeList = Session["OrdreTypeList"] as DataTable;

        if ((Directory.Exists(sourcePath)))
        {
            DirectoryInfo dir = new DirectoryInfo(sourcePath);
            foreach (FileInfo files in dir.GetFiles("*.*"))
            {
                string str        = files.Name;
                string orderUmber = str.Substring(0, str.IndexOf(" "));

                if (orderUmber == upDetail.OrderUmber.ToString())     //根据订单号找对应文件
                {
                    file theFile = new file();
                    theFile.orderID        = upDetail.OrderUmber;
                    theFile.fileName       = files.Name;
                    theFile.filepath       = sourcePath;
                    theFile.printTypeTable = OrdreTypeList;
                    theFile.onePagePrice   = float.Parse(OrdreTypeList.Rows[0]["SinglePagePrice"].ToString()); //默认黑白打印的价格
                    theFile.count          = 1;                                                                //默认打印一份
                    //(str.Substring(0, str.LastIndexOf("."))
                    //  string db = str.Trim();
                    string suffixName = str.Substring(str.LastIndexOf(".") + 1);
                    if (suffixName == "doc" || suffixName == "docx")

                    {
                        string path = sourcePath + @"\" + files.Name;

                        theFile.numberOfPages = GetPageCount(path);     // 加这个方法时报错
                        theFile.price         = (theFile.numberOfPages) * (theFile.onePagePrice) * (theFile.count);
                        fileList.Add(theFile);
                    }
                    else if (suffixName == "pdf")
                    {
                        string path = sourcePath + @"\" + files.Name;
                        theFile.numberOfPages = GetPDFPageCountByDll(path);
                        theFile.price         = (theFile.numberOfPages) * (theFile.onePagePrice) * (theFile.count);
                        fileList.Add(theFile);
                    }
                }
            }

            return(fileList);
        }
        else
        {
            return(null);
        }
    }
Exemple #10
0
        public ActionResult AddOrEdit(int id = 0)
        {
            //got to figure out how to make this page unbrowseable
            var  user   = Request.Cookies["EDMSuser"].Value.Trim().ToLower();
            var  person = db.people.Where(dbl => dbl.email.Trim().ToLower() == user).FirstOrDefault <person>();
            file emp    = new file();

            if (id != 0)
            {
                emp = db.files.Where(dbl => dbl.person.Id == person.Id && dbl.Id == id).FirstOrDefault();
            }
            return(View(emp));
        }
Exemple #11
0
        public void GetfileByIdTest()
        {
            _sample2 = new NHibernateSample.Data.NHibernateSample(typeof(file));
            var tempfile = new file {
                id = 16, title = "Javahomework"
            };

            _sample2.CreatFile(tempfile);
            file fl     = _sample2.GetFileById(16);
            int  fileId = fl.id;

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(16, fileId);
        }
Exemple #12
0
        public ActionResult fileCreate([Bind(Include = "Id,name,filepath,filetypeId,personId")] file file)
        {
            if (ModelState.IsValid)
            {
                db.files.Add(file);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.filetypeId = new SelectList(db.filetypes, "Id", "name", file.filetypeId);
            ViewBag.personId   = new SelectList(db.people, "Id", "fullname", file.personId);
            return(View(file));
        }
Exemple #13
0
        public void openEditor()
        {
            txt txt = new txt();

            rtbTutorial.Visible = false;
            editorGrid.Visible  = true;
            lblEditor.Text      = txt.CAT_EDITOR_LABEL;
            if (mainForm != null)
            {
                file a = mainForm.project.getCurrentFile();
            }
            setSentencesToGridview();
        }
 public ActionResult SaveAs(file myFile)
 {
     try
     {
         //students=myFile.students;
         saveToFile(myFile.fileName);
         return(View("Details", students));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult OpenFromFile(file myFile)
 {
     try
     {
         readFromFile(myFile.fileName);
         readStudentsFromFile();
         return(View("Details", students));
     }
     catch
     {
         return(View());
     }
 }
        public HttpResponseMessage downloadByCode(string code)
        {
            file targetFile = getFileUrl(code);

            if (targetFile == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, "No such file"));
            }
            //TODO: get the download path
            Download download = new Download();
            string   path     = "";

            if (targetFile.size > 20 * 1024)
            {
                path = download.multiThreadDownload(targetFile.url, targetFile.name);
            }
            else
            {
                path = download.singleThreadDownload(targetFile.url, targetFile.name);
            }
            if (path == "")
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Fail to download"));
            }
            string              fileName   = Path.GetFileName(path);
            FileStream          fileStream = new FileStream(path, FileMode.Open);
            HttpResponseMessage response   = null;

            try
            {
                response         = Request.CreateResponse(HttpStatusCode.OK);
                response.Content = new StreamContent(fileStream);
                response.Content.Headers.ContentType        = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
                response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
                {
                    FileName = HttpUtility.UrlEncode(fileName)
                };
                response.Headers.Add("Access-Control-Expose-Header", "FileName");
                response.Headers.Add("FileName", HttpUtility.UrlEncode(fileName));
                addUpDownloadTimes(targetFile.id);
            }
            catch (Exception e)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Fail to download");
            }
            //finally
            //{
            //    fileStream.Close();
            //}
            return(response);
        }
Exemple #17
0
        public void openEditor()
        {
            txt txt = new txt();

            rtbTutorial.Visible = false;
            editorGrid.Visible  = true;
            //UpdateFont();
            if (mainForm != null)
            {
                file a = mainForm.project.getCurrentFile();
                groupBox1.Text = mainForm.project.getCurrentFile().getFileName();
            }
            setSentencesToGridview();
        }
Exemple #18
0
        // GET: files/Delete/5
        public ActionResult fileDelete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            file file = db.files.Find(id);

            if (file == null)
            {
                return(HttpNotFound());
            }
            return(View(file));
        }
        // store the file into the database
        public async Task StoreFileToDB(file file)
        {
            // using transaction scope
            using (var scope = new TransactionScope())
            {
                using (FileEntitiesFinal entity = new FileEntitiesFinal())
                {
                    entity.file.Add(file);
                    await entity.SaveChangesAsync();

                    scope.Complete();
                }
            }
        }
        public async Task <IActionResult> Upload(IFormFile filesData, int idPost, string fname)

        {
            if (filesData == null)
            {
                return(BadRequest("Null File"));
            }
            if (filesData.Length == 0)
            {
                return(BadRequest("Empty File"));
            }
            if (filesData.Length > 10 * 1024 * 1024)
            {
                return(BadRequest("Max file size exceeded."));
            }

            if (!ACCEPTED_FILE_TYPES.Any(s => s == Path.GetExtension(filesData.FileName).ToLower()))
            {
                return(BadRequest("Invalid file type."));
            }

            var uploadFilesPath = Path.Combine(host.WebRootPath, "uploads");

            if (!Directory.Exists(uploadFilesPath))
            {
                Directory.CreateDirectory(uploadFilesPath);
            }

            //  var fileName = Guid.NewGuid().ToString() + Path.GetExtension(filesData.FileName);

            var fileName = fname + Path.GetExtension(filesData.FileName);
            var filePath = Path.Combine(uploadFilesPath, fileName);

            using (var stream = new FileStream(filePath, FileMode.Create))

            {
                await filesData.CopyToAsync(stream);
            }

            var photo = new file {
                FileName = fileName, idPostu = idPost
            };

            context.files.Add(photo);

            await context.SaveChangesAsync();

            return(Ok());
        }
 public ActionResult FileDeletes(int[] id)
 {
     if (id == null)
     {
         return(RedirectToAction("Index", "Site"));
     }
     //file file = data.files.Find(id);
     foreach (var item in id)
     {
         file file = db.files.Find(item);
         file.Status = "no";
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 private bool isFileNameExisted(String name)
 {
     using (FileEntitiesFinal entity = new FileEntitiesFinal())
     {
         file tempFile = entity.file.Where(f => f.name.Equals(name)).FirstOrDefault();
         if (tempFile == null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
Exemple #23
0
        private void PushData(System.IO.FileStream input, System.IO.Stream output, file mfi)
        {
            byte[] buffer = new byte[32768];
            int    bytesRead;
            int    iRead = 0;

            while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
            {
                iRead        = iRead + buffer.Length;
                mfi.Progress = iRead;//Math.Round((double.Parse(input.Length.ToString()) / double.Parse(iRead.ToString())) * 100, 0);
                output.Write(buffer, 0, bytesRead);
            }
            mfi.Do = false;
            ListFiles();
        }
Exemple #24
0
        // GET: User/Details/5
        public ActionResult Details(int?id)
        {
            var usr = Session["usr"].ToString();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            file file = db.files.Find(id);

            if (file == null)
            {
                return(HttpNotFound());
            }
            return(View(file));
        }
Exemple #25
0
        // GET: files/Edit/5
        public ActionResult fileEdit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            file file = db.files.Find(id);

            if (file == null)
            {
                return(HttpNotFound());
            }
            ViewBag.filetypeId = new SelectList(db.filetypes, "Id", "name", file.filetypeId);
            ViewBag.personId   = new SelectList(db.people, "Id", "fullname", file.personId);
            return(View(file));
        }
Exemple #26
0
        public ActionResult Malicious(int id, bool?isFile, bool isChecked)
        {
            ViewBag.isFile = isFile.HasValue && isFile.Value;
            file file = null;

            if (isFile.HasValue && isFile.Value)
            {
                file = db.files.Find(id);
            }
            else
            {
                file = db.file_detail.Find(id).files.FirstOrDefault();
            }
            ViewBag.isChecked = isChecked;
            return(PartialView(file));
        }
 public String downloadFile(int fileId)
 {
     using (FileEntitiesFinal entity = new FileEntitiesFinal())
     {
         file tempFile = entity.file.Where(f => f.id == fileId).FirstOrDefault();
         if (tempFile == null)
         {
             return("FileNotExist");
         }
         else
         {
             addUpDownloadTimes(tempFile.id);
             return(tempFile.url.ToString() + "?attname=");
         }
     }
 }
 public data_controller(int u_c, int f_c)
 {
     Get_filecount = f_c;
     Get_usercount = u_c;
     users         = new user[u_c];
     users[0]      = new user("Адміністратор", new marker(3), 0);
     for (int i = 1; i < u_c; i++)
     {
         users[i] = new user("Користувач " + i.ToString(), new marker(r.Next(0, 4)), i);
     }
     files = new file[f_c];
     for (int i = 0; i < f_c; i++)
     {
         files[i] = new file("файл " + (i + 1).ToString(), new marker(r.Next(0, 4)));
     }
 }
        /// <summary>
        /// Insertion des information d'un fichier dans la base de données
        /// </summary>
        /// <returns></returns>
        private Boolean InsertInDataBase(file File)
        {
            Boolean InsertCompleted = false;

            try
            {
                fileService.InsertFileInformations(File);
                InsertCompleted = true;
            }
            catch (Exception error)
            {
                Debug.WriteLine(error.Message);
                throw new ControllerException(error.Message);
            }
            return(InsertCompleted);
        }
 /// <summary>
 /// Method to add both physically on the server and in the database a file associated to a group.
 /// The file must be passed as a Byte array parameter.
 /// </summary>
 /// <param name="fileByteArray">The Byte array of the file itself.</param>
 /// <param name="groupID">The group ID (Int32) of the group the file is associated to.</param>
 /// <param name="originalFileName">The original file name (String) saved by the database for later user readability</param>
 public void AddAssociatedFileToGroup(Byte[] fileByteArray, int groupID, string originalFileName)
 {
     try
     {
         file Fichier = new file();
         Fichier.FileURL  = SaveByteFile(fileByteArray, originalFileName);
         Fichier.Group_ID = groupID;
         Fichier.FileName = originalFileName;
         fileService.InsertFileInformations(Fichier);
     }
     catch (Exception error)
     {
         Debug.WriteLine(error.Message);
         throw new ControllerException(error.Message);
     }
 }
        void fileCreated(object sender, FileSystemEventArgs e)
        {
            indexEntities db = new indexEntities();

            FileInfo info = new FileInfo(e.FullPath);
            file newFile = new file()
            {
                lastModified = info.LastWriteTime,
                origFileName = info.Name
            };

            foreach (RootFolder folder in FileStructure.Index.IndexRoots)
            {
                if (e.FullPath.Contains(folder.RootFolderName))
                {
                    newFile.rootFolder = folder.RootFolderName;
                    newFile.relativeFilePath = info.FullName.Replace(folder.RootFolderName, "");
                    newFile.service = Enum.GetName(typeof(StorageServices), FileStructure.Index.algo.SortingHat(info));
                    break;
                }
            }

            Exception error;
            do
            {
                error = null;
                newFile.guid = Guid.NewGuid().ToString();
                try
                {
                    newFile = db.files.Add(newFile);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    error = ex;
                }
            } while (error != null);

            newFile.serviceFileId = Unity.UploadFile(newFile);
            db.SaveChanges();

            System.Windows.Forms.MessageBox.Show("A file has been uploaded");
        }
Exemple #32
0
        public ViewWindow(file filename)
        {
            InitializeComponent();
            if (filename.Name.EndsWith("xlsx"))
            {
                SheetList.Visibility = Visibility.Visible;
                dataGrid.Visibility = Visibility.Visible;

                fsc.GetExcelDocumentCompleted += (a, b) =>
                {
                    Exceldocument = b.Result;
                    SheetList.SetBinding(ListBox.ItemsSourceProperty, new Binding("WorkSheets") { Source = Exceldocument, BindsDirectlyToSource = true, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Default });
                };

                fsc.GetExcelDocumentAsync(filename.Name);
            }
            else if (filename.Name.EndsWith("pdf"))
            {
                UriBuilder ub = new UriBuilder(fsc.Endpoint.Address.Uri.AbsoluteUri.Replace("FileService.svc", "sender.ashx"));
                ub.Query = string.Format("filename={0}", filename.Name);

                webbrowser.Visibility = Visibility.Visible;
                webbrowser.NavigateToString("<html><body><iframe src='"+ ub.Uri.AbsoluteUri +"&mime=true' id='ifrm' style='width:100%;height:100%;border:solid 10px green;margin:0;padding:0;'></iframe></body></html>");
                
            }
            else if (filename.Name.ToLower().EndsWith("jpg"))
            {
                UriBuilder ub = new UriBuilder(fsc.Endpoint.Address.Uri.AbsoluteUri.Replace("FileService.svc", "sender.ashx"));
                ub.Query = string.Format("filename={0}", filename.Name);

                ImageSourceConverter isc = new ImageSourceConverter();
                image.Source= isc.ConvertFromString(ub.Uri.OriginalString) as ImageSource;

                image.Visibility = Visibility.Visible;

            }
            
        }
Exemple #33
0
 public static string MoveService(file f, StorageServices newService)
 {
     f.service = Enum.GetName(typeof(StorageServices), newService);
     return UploadFile(f);
 }
Exemple #34
0
        private void addButton_Click(object sender, EventArgs e)
        {
            using (var trans = new TransactionScope())
            {
                DateTime teraz = DateTime.Now;
                file add_new = new file
                {
                    u_id = userid,
                    path = fileNameBox.Text,
                    add_time = teraz
                };
                database.files.InsertOnSubmit(add_new);

                database.SubmitChanges();

                var get_files = from f in database.files
                                where f.u_id == userid
                                select new { f.f_id, f.path, f.add_time };
                FilesGridView1.DataSource = get_files;
                FilesGridView1.Refresh();
                var fid = 0;
                foreach (var f in get_files)
                {
                    fid = f.f_id;
                }
                action fileadd_act = new action
                {
                    u_id = userid,
                    act_type = "AFI",
                    action_time = teraz,
                    fi_id = fid
                };
                database.actions.InsertOnSubmit(fileadd_act);
                database.SubmitChanges();

                trans.Complete();
            }
            UpdateHistory();

            label1.Visible = false;
            fileNameBox.Visible = false;
            addButton.Visible = false;
            button1.Text = "Add new";
            act_f++;
            var toFilesCounter = mf - act_f;
            FilesCounterLabel.Text = "Files left: " + toFilesCounter.ToString();
            if (toFilesCounter == 0)
                button1.Enabled = false;
        }
Exemple #35
0
 private static void UpdateRemoteIndex(file file, FileOperation op)
 {
 }
Exemple #36
0
 private void UploadFile(file mfi, System.IO.FileStream data)
 {
     UriBuilder ub = new UriBuilder(fsc.Endpoint.Address.Uri.AbsoluteUri.Replace("FileService.svc", "receiver.ashx"));
     ub.Query = string.Format("filename={0}", mfi.Name);
     
     WebClient wc = new WebClient();
     wc.OpenWriteCompleted += (sender, e) =>
     {
         try
         {
             PushData(data, e.Result, mfi);
             e.Result.Close();
             data.Close();
         }
         catch (Exception ex)
         {
             lbl.Content += ex.Message + "\n" + ex.StackTrace + "\n";
         }
     };
     wc.OpenWriteAsync(ub.Uri);
 }
Exemple #37
0
 private void PushData(System.IO.FileStream input, System.IO.Stream output, file mfi)
 {
     byte[] buffer = new byte[32768];
     int bytesRead;
     int iRead = 0;
     while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
     {
         iRead = iRead + buffer.Length;
         mfi.Progress = iRead;//Math.Round((double.Parse(input.Length.ToString()) / double.Parse(iRead.ToString())) * 100, 0);
         output.Write(buffer, 0, bytesRead);
     }
     mfi.Do = false;
     ListFiles();
 }
Exemple #38
0
        public static string UploadFile(file newFile)
        {
            StorageServices service = (StorageServices)Enum.Parse(typeof(StorageServices), newFile.service);
            try
            {
                switch (service)
                {
                    case StorageServices.Dropbox:
                        Dropbox.Api.FileSystemInfo file = DropboxApi.Api.UploadFile("sandbox", newFile.guid, newFile.fullpath);
                        return file.Path;
                    case StorageServices.GoogleDrive:
                        var gfile = GoogleDrive.Api.UploadFile(newFile.guid, newFile.fullpath);
                        break;
                    case StorageServices.SkyDrive:
                        SkyDrive.Api.UploadFile(newFile.guid, newFile.fullpath);
                        break;
                    case StorageServices.UbuntuOne:
                        throw new NotImplementedException();
                    case StorageServices.Box:
                        throw new NotImplementedException();
                    default:
                        throw new Exception("how'd you manage that one?");

                }
                return "Test";
            }
            catch (Exception)
            {
                return "Failure";
            }
        }
Exemple #39
0
 public void Add(file fi)
 {
     _files.Add(fi);
     InvokePropertyChanged("Files");
 }
Exemple #40
0
        public static bool UpdateFile(file uploadFile)
        {
            bool result = true;
            try
            {
                switch (uploadFile.service)
                {
                    case "Dropbox":
                        var file = DropboxApi.Api.UploadFile("sandbox", uploadFile.guid, uploadFile.fullpath);
                        break;
                    case "GoogleDrive":
                        throw new NotImplementedException();
                    case "SkyDrive":
                        SkyDrive.Api.UploadFile(uploadFile.guid, uploadFile.fullpath);
                        break;
                    case "UbuntuOne":
                        throw new NotImplementedException();
                    case "Box":
                        throw new NotImplementedException();
                    default:
                        throw new Exception("how'd you manage that one?");
                }
            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }