예제 #1
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label("ファイル名", GUILayout.Width(100));
        fileName = GUILayout.TextField(fileName, GUILayout.Width(200));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("保存名称", GUILayout.Width(100));
        saveName = GUILayout.TextField(saveName, GUILayout.Width(200));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("OK", GUILayout.Height(20f), GUILayout.Width(100)))
        {
            FileInfoData fileInfoData = new FileInfoData
            {
                fileName = fileName,
                name     = saveName,
                target   = Target
            };
            callback(fileInfoData);
            Close();
        }
        EditorGUI.EndDisabledGroup();
        if (GUILayout.Button("キャンセル", GUILayout.Height(20f), GUILayout.Width(100)))
        {
            Close();
        }
        GUILayout.EndHorizontal();
    }
예제 #2
0
        public override global::System.Data.DataSet Clone()
        {
            FileInfoData cln = ((FileInfoData)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
예제 #3
0
        public object SavePreviewFile(FileInfoData fileInfo)
        {
            HttpPostedFile file = fileInfo.Filedata;

            return(SaveFileToLocal(file, new List <string>()
            {
                ".jpg", ".png", ".ico", ".bmp"
            }, "当前只支持*.jpg,*.png,*.ico,*.bmp格式文件"));
        }
예제 #4
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            FileInfoData ds = new FileInfoData();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
예제 #5
0
        /// <summary>
        /// This example demonstrates the use of the Get-SDSTeamFile API
        /// </summary>
        /// <example>GetTeamFileInfo "C:\My Secured Folder\Document.docx"</example>
        static int Main(string[] args)
        {
            int returnCode = 0;

            try
            {
                if (args.Length == 0)
                {
                    throw new ArgumentException("Missing parameters");
                }

                string filePath = args[0];

                using (API api = new API())
                {
                    object[] objects = api.Execute("Get-SDSUser");
                    if (objects == null)
                    {
                        throw new InvalidOperationException("No user connected");
                    }

                    objects = api.Execute(string.Format("Get-SDSTeamFile '{0}'", filePath));
                    if (objects == null || objects.Length != 1)
                    {
                        throw new InvalidOperationException("Get-SDSTeamFile");
                    }

                    FileInfoData fileInfoData = objects[0] as FileInfoData;
                    Console.WriteLine(string.Format("Return:\n{0}", fileInfoData.FullName));
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
                returnCode = 2;
            }

            return(returnCode);
        }
예제 #6
0
        /// <summary>
        /// Синхронизация с сервером
        /// </summary>
        /// <param name="exec">Обязательная синхронизация</param>
        public static async Task <int> Synchronization(bool exec = false)
        {
            if (!User.IsConnectToServer)
            {
                return(1);
            }
            if (!IsServer)
            {
                return(2);
            }
            //Проверка существования на сервере связки логина и пароля
            using (var client = new HttpClient())
            {
                HttpResponseMessage message = client.PostAsJsonAsync(ProgramSettings.AdressServer + "Server/RegistrationUser",
                                                                     new RegistrationData {
                    Login = _login, Md5 = _md5
                }).Result;
                string resultString = message.Content.ReadAsStringAsync().Result;
                bool   result       = Convert.ToBoolean(resultString);
                if (!result)
                {
                    return(3);
                }
            }

            //Формирование локального списка файлов для синхронизации
            List <FileInfoData> fileInfos = new List <FileInfoData>();

            if (User.IsSynchronizeSettingsWithServer)
            {
                //Файл настроек
                FileInfoData fileSettings = new FileInfoData("Settings.bin", "", true, User.DateLastEditSettings, FileToUpload.Settings, false, false);
                fileInfos.Add(fileSettings);
            }

            if (User.IsSynchronizeDatabaseWithServer)
            {
                //Файлы БД
                if (User.DBMSName == "SQLite")
                {
                    FileInfoData fileDatabase = new FileInfoData("database.db", "", true, User.DateLastEditDatabase, FileToUpload.Database, false, false);
                    if (File.Exists(Environment.CurrentDirectory + "\\data\\" + _login + "\\database.db"))
                    {
                        fileInfos.Add(fileDatabase);
                    }
                }
                //Отсутствует поддержка синхронизации файлов SQL Server

                /*else
                 * {
                 *  FileInfoData fileDatabase = new FileInfoData("database.mdf", "", true, User.DateLastEditDatabase, FileToUpload.Database, false, false);
                 *  fileInfos.Add(fileDatabase);
                 *  FileInfoData fileDatabaseLog = new FileInfoData("database_log.ldf", "", true, User.DateLastEditDatabase, FileToUpload.Database,
                 *      false, false);
                 *  fileInfos.Add(fileDatabaseLog);
                 * }*/
            }

            //Файлы резервных копий
            string[] backupFileNames = Directory.GetFiles(Environment.CurrentDirectory + "\\data\\" + _login + "\\Backups");
            foreach (string elem in backupFileNames)
            {
                FileInfo     infFile = new FileInfo(elem);
                FileInfoData file    = new FileInfoData(infFile.Name, "", false, DateTime.Now, FileToUpload.Backup, false, false);
                fileInfos.Add(file);
            }

            //Файлы фото
            string[] photoFileNames = Directory.GetFiles(Environment.CurrentDirectory + "\\data\\" + _login + "\\Photos");
            foreach (string elem in photoFileNames)
            {
                FileInfo     infFile = new FileInfo(elem);
                FileInfoData file    = new FileInfoData(infFile.Name, "", false, DateTime.Now, FileToUpload.Photo, false, false);
                fileInfos.Add(file);
            }

            //Файлы документов
            string[] documentFileNames = Directory.GetFiles(Environment.CurrentDirectory + "\\data\\" + _login + "\\Documents");
            foreach (string elem in documentFileNames)
            {
                FileInfo     infFile = new FileInfo(elem);
                FileInfoData file    = new FileInfoData(infFile.Name, "", false, DateTime.Now, FileToUpload.Document, false, false);
                fileInfos.Add(file);
            }

            //Отправка списка файлов и получение списка сервера
            ListFileInfoData list = new ListFileInfoData(fileInfos.ToArray());

            list.Login = _login;
            using (var client = new HttpClient())
            {
                HttpResponseMessage message = client.PostAsJsonAsync(ProgramSettings.AdressServer + "Server/GetListFilesInfo", list).Result;
                string resp = message.Content.ReadAsStringAsync().Result;
                list = JsonConvert.DeserializeObject <ListFileInfoData>(resp);
            }

            //Начало отправки/загрузки файлов
            foreach (var elem in list.FilesInfo)
            {
                if (elem.IsUpload && exec)
                {
                    string prevPath = "";
                    switch (elem.FileType)
                    {
                    case FileToUpload.Backup:
                        prevPath = "Backups\\";
                        break;

                    case FileToUpload.Document:
                        prevPath = "Documents\\";
                        break;

                    case FileToUpload.Photo:
                        prevPath = "Photos\\";
                        break;
                    }
                    PostFileFromServerAsync(prevPath + elem.NameFile);
                }
                if (elem.IsDownload && !exec)
                {
                    await GetFileFromServerAsync(elem.FileType, elem.NameFile);
                }
            }

            //Проверка дополнительных условий и удаление лишних файлов
            if (User.IsSynchronizeBackupWithServer)
            {
                foreach (var elem in backupFileNames)
                {
                    File.Delete(elem);
                }
            }
            if (User.IsSynchronizeDocumentsWithServer)
            {
                foreach (var elem in documentFileNames)
                {
                    File.Delete(elem);
                }
            }

            return(0);
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     FileInfoData ds = new FileInfoData();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "FileInfoDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     FileInfoData ds = new FileInfoData();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
예제 #9
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                FileInfoData ds = new FileInfoData();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "FileInfoDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
예제 #10
0
        public ActionResult Index(HttpPostedFileBase file, string search)
        {
            string filePath = string.Empty;

            if (file != null)
            {
                string path = Server.MapPath("~/Uploads/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                filePath = path + Path.GetFileName(file.FileName);
                string extension = Path.GetExtension(file.FileName);
                file.SaveAs(filePath);

                //Read the contents of file.
                string text      = System.IO.File.ReadAllText(filePath);
                var    sentences = text.Split('.');

                foreach (var sentence in sentences)
                {
                    string wordDb    = "";
                    string wordDbRev = "";
                    bool   isAddToDb = false;
                    int    counter   = 0;
                    var    words     = sentence.Split(' ');
                    foreach (var item in words)
                    {
                        var word = item.Replace("\r\n", string.Empty);
                        if (word == search)
                        {
                            isAddToDb = true;
                            counter++;
                        }
                        wordDb    += word + ' ';
                        word       = word.Reverse();
                        wordDbRev += word + ' ';
                    }
                    if (!string.IsNullOrEmpty(wordDbRev.Trim()))
                    {
                        if (isAddToDb)
                        {
                            FileInfoData fileInfoData = new FileInfoData
                            {
                                OriginText      = wordDb.Trim() + '.',
                                ReverseWordText = wordDbRev.Trim() + '.',
                                Word            = search,
                                CountWords      = counter
                            };
                            _context.FileInfoDatas.Add(fileInfoData);
                            _context.SaveChanges();
                            //Console.WriteLine(wordDb.Trim() + '.');
                        }
                    }
                }
            }
            var model = _context.FileInfoDatas.ToList();

            return(View(model));
        }