示例#1
0
        public jsonFile(string file)
        {
            try
            {
                fileType   = FILETYPE.unknown;
                fileBuffer = file;
                root       = JObject.Parse(fileBuffer);

                //TODO: finish this schema resolver - currently the code will partial process files as validation not in place.
                JsonSchema schema = JsonSchema.Parse(fileBuffer);
                if (root.IsValid(schema))
                {
                    if (root["orders"] != null)
                    {
                        fileType = FILETYPE.orders;
                        rows     = root["orders"];
                    }
                    else if (root["order items"] != null)
                    {
                        fileType = FILETYPE.orderitems;
                        rows     = root["order items"];
                    }
                    else if (root["shipments"] != null)
                    {
                        fileType = FILETYPE.shipments;
                        rows     = root["shipments"];
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Exception caught: " + ex.Source + " : " + ex.Message);
            }
        }
示例#2
0
        /// <summary>
        ///  Return a ContentValues to be inserted or updated to DB
        /// </summary>
        protected internal override ContentValues __saveData()
        {
            List <object> colsAndValues = new List <object>(2);
            FILETYPE      fType         = FILETYPE.fBin;

            if (this.rawBinData != null)
            {
                colsAndValues.Add(FILEDATABLOCK.dRawBinData.ToString());
                colsAndValues.Add(this.rawBinData);
                colsAndValues.Add(FILEDATABLOCK.dTextData.ToString());            // clear text column
                colsAndValues.Add("");
            }
            else if (this.textData != null)
            {
                colsAndValues.Add(FILEDATABLOCK.dTextData.ToString());
                colsAndValues.Add(this.textData);
                colsAndValues.Add(FILEDATABLOCK.dRawBinData.ToString());            // clear rawbin column
                colsAndValues.Add(null);
                fType = FILETYPE.fText;
            }

            // file type
            colsAndValues.Add(FILEDATABLOCK.dFileType.ToString());
            colsAndValues.Add(fType.ordinal());

            return(SqlStr.genContentValues(colsAndValues));
        }
示例#3
0
 public BinaryIO(string FileName = "", FILETYPE type = FILETYPE.BINARY)
     : base(FileName, type)
 {
     if (FileName != "")
     {
         fileStream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
     }
 }
示例#4
0
        /// <summary>
        /// Returns list of certain files in the directory.
        /// </summary>
        /// <param name="directory">Full path to folder with files.</param>
        /// <param name="ft">Type of file to search.</param>
        /// <returns></returns>
        public string[] GetFileListByType(string directory, FILETYPE ft)
        {
            string[] fileList = null;

            try
            {
                fileList = Directory.GetFiles(directory);
            }
            catch (ArgumentNullException ex)
            {
                throw new Exception("One or few directories names are incorrect!");
            }
            catch (DirectoryNotFoundException ex)
            {
                throw new Exception("One or few directories names are incorrect!");
            }

            List <string> tempList   = new List <string>(fileList);
            List <string> bufferList = new List <string>();

            foreach (string elem in tempList)
            {
                bufferList.Add(elem);
            }

            switch (ft)
            {
            case FILETYPE.SOUND:
            {
                foreach (string elem in tempList)
                {
                    if (!elem.Contains(".mp3"))
                    {
                        bufferList.Remove(elem);
                    }
                }
                break;
            }

            case FILETYPE.IMAGE:
            {
                foreach (string elem in tempList)
                {
                    if (!elem.Contains(".jpg") && !elem.Contains(".png") && !elem.Contains(".jpeg"))
                    {
                        bufferList.Remove(elem);
                    }
                }
                break;
            }

            default: break;
            }

            return(bufferList.ToArray());
        }
        private async void OpenFileSavePicker(FILETYPE fileType)
        {
            FileSavePicker savePicker = new FileSavePicker();

            savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

            // Dropdown of file types the user can save the file as
            switch (fileType)
            {
            case FILETYPE.TEXTFILE: savePicker.FileTypeChoices.Add("Plain Text", new List <string>()
                {
                    ".txt"
                });
                break;

            case FILETYPE.WORDDOCUMENT: savePicker.FileTypeChoices.Add("Word Document", new List <string>()
                {
                    ".doc"
                });
                break;
            }

            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "New Document";
            StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
                CachedFileManager.DeferUpdates(file);
                // write to file
                await FileIO.WriteTextAsync(file, OcrString);

                // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);

                MessageDialog msgDialog;
                if (status == FileUpdateStatus.Complete)
                {
                    msgDialog = new MessageDialog("File " + file.Name + " was saved.", "File Saved.");
                }
                else
                {
                    msgDialog = new MessageDialog("File " + file.Name + " couldn't be saved.", "File Saved.");
                }
                await msgDialog.ShowAsync();
            }
            else
            {
                //"Operation cancelled.";
            }
        }
示例#6
0
        private int CommFileInit(FILETYPE ftype)
        {
            switch (ftype)
            {
            case FILETYPE.fileBMP:
                m_filename = m_filename + ".bmp";     //"imgsnap.bmp"
                break;

            case FILETYPE.fileJPEG:
                m_filename = m_filename + ".jpg";     //"imgsnap.jpg"
                break;
            }

            return(0);
        }
示例#7
0
        /// <summary>
        /// Fetch the file tumbnail
        /// </summary>
        /// <param name="Filetype">Set it to use ID or file HASH</param>
        /// <param name="ab"></param>
        /// <returns>A thumbnail file</returns>
        public static ResponseFile Get_Files_Thumbnails(FILETYPE Filetype, string HashOrID)
        {
            try
            {
                var url = _Server_Addr + "/get_files/thumbnail?";
                switch (Filetype)
                {
                case FILETYPE.File_ID:
                    url += "file_id=" + HashOrID;
                    break;

                case FILETYPE.File_Hash:
                    url += "hash=" + HashOrID;
                    break;

                default:
                    break;
                }

                //fire off that thumbnail request
                var request = (HttpWebRequest)WebRequest.Create(url + "&Hydrus-Client-API-Access-Key=" + _API_KEY);
                request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                var f = request.GetResponse();

                //get filetype from stream data
                string filetype = DetectImageType(f.GetResponseStream());


                var reg = new Regex("\"[^\"]*\"");

                var match = reg.Matches(f.Headers["Content-Disposition"])[0].Value.Replace("thumbnail", filetype).Trim('"');

                ResponseFile response = new ResponseFile
                {
                    FileByteStream = f.GetResponseStream(),
                    FileName       = match
                };


                return(response);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace);
                return(null);
            }
        }
示例#8
0
        /// <summary>
        /// Adds using block to the closed file's buffer
        /// </summary>
        /// <param name="filename">File path</param>
        /// <param name="nmspc">Imported namespace</param>
        private void AddUsingBlockTo(string filename, string nmspc)
        {
            FILETYPE type = filename.GetFileType();

            switch (type)
            {
            case FILETYPE.CSHARP:
                filesCache[filename].Insert(0, string.Format(StringConstants.CSharpUsingBlockFormat, nmspc));
                break;

            case FILETYPE.ASPX:
                filesCache[filename].Insert(0, string.Format(StringConstants.AspImportDirectiveFormat, nmspc));
                break;

            case FILETYPE.VB:
                filesCache[filename].Insert(0, string.Format(StringConstants.VBUsingBlockFormat, nmspc));
                break;
            }
        }
示例#9
0
        protected static string fileDialog( FILETYPE type, bool bWrite )
        {
            FileDialog dlg = bWrite ? ((FileDialog)(new SaveFileDialog())) : ((FileDialog)(new OpenFileDialog()));

            int idx = (int)(type);

            dlg.DefaultExt = FileExt[idx];
            dlg.Filter = FileDesc[idx];
            dlg.CheckFileExists = false;

            // Display OpenFileDialog by calling ShowDialog method 
            Nullable<bool> result = dlg.ShowDialog();

            // Get the selected file name
            if (result == true)
                return dlg.FileName;

            return "";
        }
示例#10
0
        public void Clear()
        {
            td_fieldsset=new uint[libtiff.FIELD_SETLONGS];
            td_imagewidth=td_imagelength=td_imagedepth=0;
            td_tilewidth=td_tilelength=td_tiledepth=0;
            td_subfiletype=0;
            td_bitspersample=0;
            td_sampleformat=0;
            td_compression=0;
            td_photometric=0;
            td_threshholding=0;
            td_fillorder=0;
            td_orientation=0;
            td_samplesperpixel=0;
            td_rowsperstrip=0;
            td_minsamplevalue=td_maxsamplevalue=0;
            td_sminsamplevalue=td_smaxsamplevalue=0;
            td_xresolution=td_yresolution=0;
            td_resolutionunit=0;
            td_planarconfig=0;
            td_xposition=td_yposition=0;
            td_pagenumber=new ushort[2];
            td_colormap=new ushort[3][];
            td_halftonehints=new ushort[2];
            td_extrasamples=0;
            td_sampleinfo=null;

            td_stripsperimage=0;
            td_nstrips=0;				// size of offset & bytecount arrays
            td_stripoffset=null;
            td_stripbytecount=null;
            td_stripbytecountsorted=0;	// is the bytecount array sorted ascending?
            td_nsubifd=0;
            td_subifd=null;

            // YCbCr parameters
            td_ycbcrsubsampling=new ushort[2];
            td_ycbcrpositioning=0;

            // Colorimetry parameters
            td_refblackwhite=null;
            td_transferfunction=new ushort[3][];

            // CMYK parameters
            td_inknameslen=0;
            td_inknames=null;

            td_customValueCount=0;
            td_customValues.Clear();
        }
示例#11
0
 public int SaveImage(string  lpSaveName, FILETYPE FileType)
 {
     return ArtCam.SaveImage(m_hACam, lpSaveName, FileType);
 }
示例#12
0
 public static extern int SaveImage(int hACam, string  lpSaveName, FILETYPE FileType);
示例#13
0
 public FileIO(string FileName, FILETYPE type = FILETYPE.UNKNOWN)
 {
     this.FileName = FileName;
     FileType = type;
 }
示例#14
0
 public KMLIO(string FileName = "", FILETYPE type = FILETYPE.KML)
     : base(FileName, type)
 {
 }
示例#15
0
 public EXCELIO(string FileName = "", FILETYPE type = FILETYPE.XML)
     : base(FileName, type)
 {
     excelApp = new Excel.Application();
 }
示例#16
0
 public CSVIO( string FileName = "", FILETYPE type = FILETYPE.CSV ) : base(FileName, type)
 {
 }
示例#17
0
        public XMLIO(string FileName = "", FILETYPE type = FILETYPE.XML)
            : base(FileName, type)
        {
            FileStream fs = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

            XmlWriterSettings xws = new XmlWriterSettings();
            xws.Encoding = new UTF8Encoding(false);
            xws.ConformanceLevel = ConformanceLevel.Document;
            xws.Indent = true;
            Writer = XmlWriter.Create(fs, xws);
        }
示例#18
0
 public TextIO( string FileName = "", FILETYPE type = FILETYPE.PLAINTEXT ) : base(FileName, type)
 {
     if (FileName != "")
     {
         writer = new StreamWriter(new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite));
         reader = new StreamReader(new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite));
     }
 }
示例#19
0
 public CacheIdentifier(string p, string n, FILETYPE t)
 {
     PID      = p;
     FileName = n;
     Type     = t;
 }
示例#20
0
        private async void OpenFileSavePicker(FILETYPE fileType)
        {
            FileSavePicker savePicker = new FileSavePicker();
            savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

            // Dropdown of file types the user can save the file as
            switch (fileType)
            {
                case FILETYPE.TEXTFILE: savePicker.FileTypeChoices.Add("Plain Text", new List<string>() { ".txt" });
                    break;
                case FILETYPE.WORDDOCUMENT: savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".doc" });
                    break;
            }

            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "New Document";
            StorageFile file = await savePicker.PickSaveFileAsync();
            if (file != null)
            {
                // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
                CachedFileManager.DeferUpdates(file);
                // write to file
                await FileIO.WriteTextAsync(file, OcrString);
                // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
                MessageDialog msgDialog;
                if (status == FileUpdateStatus.Complete)
                {
                    msgDialog = new MessageDialog("File " + file.Name + " was saved.", "File Saved.");
                }
                else
                {
                    msgDialog = new MessageDialog("File " + file.Name + " couldn't be saved.", "File Saved.");
                }
                await msgDialog.ShowAsync();
            }
            else
            {
                //"Operation cancelled.";
            }
        }
        /// <summary>
        /// Called after page directive &lt;%@ %&gt;
        /// </summary>
        public void OnPageDirective(DirectiveContext context)
        {
            // add new imported namespace
            if (context.DirectiveName == "Import" && context.Attributes.Exists((info) => { return(info.Name == "Namespace"); }))
            {
                declaredNamespaces.Add(new UsedNamespaceItem(context.Attributes.Find((info) => { return(info.Name == "Namespace"); }).Value, null, true));
            }
            if (context.DirectiveName == "Page" || context.DirectiveName == "Control")
            {
                string lang = null; // value of Language attribute
                string ext  = null; // extension of the code-behind file
                foreach (var info in context.Attributes)
                {
                    if (info.Name == "Language")
                    {
                        lang = info.Value;         // get file language
                    }
                    if (info.Name == "CodeFile")   // get code-behind file
                    {
                        int index = info.Value.LastIndexOf('.');
                        if (index != -1 && index + 1 < info.Value.Length)
                        {
                            ext = info.Value.Substring(index + 1);
                        }
                    }
                }
                if (string.IsNullOrEmpty(lang))
                {
                    if (!string.IsNullOrEmpty(ext))   // infer file language from the extension
                    {
                        fileLanguage = StringConstants.CsExtensions.Contains(ext.ToLower()) ? FILETYPE.CSHARP : FILETYPE.VB;
                    }
                }
                else
                {
                    fileLanguage = lang == "C#" ? FILETYPE.CSHARP : FILETYPE.VB;
                }
            }
            if (context.DirectiveName == "Register")
            {
                string assembly = null, nmspc = null, src = null, tagName = null, tagPrefix = null;
                foreach (AttributeInfo info in context.Attributes)
                {
                    if (info.Name == "Assembly")
                    {
                        assembly = info.Value;
                    }
                    if (info.Name == "Namespace")
                    {
                        nmspc = info.Value;
                    }
                    if (info.Name == "Src")
                    {
                        src = info.Value;
                    }
                    if (info.Name == "TagName")
                    {
                        tagName = info.Value;
                    }
                    if (info.Name == "TagPrefix")
                    {
                        tagPrefix = info.Value;
                    }
                }
                // add definitions of elements for future type resolution
                if (!string.IsNullOrEmpty(tagPrefix))
                {
                    if (!string.IsNullOrEmpty(assembly) && !string.IsNullOrEmpty(nmspc))
                    {
                        if (webConfig != null)
                        {
                            webConfig.AddTagPrefixDefinition(new TagPrefixAssemblyDefinition(assembly, nmspc, tagPrefix));
                        }
                    }
                    else if (!string.IsNullOrEmpty(tagName) && !string.IsNullOrEmpty(src))
                    {
                        if (webConfig != null)
                        {
                            webConfig.AddTagPrefixDefinition(new TagPrefixSourceDefinition(projectItem,
                                                                                           VisualLocalizerPackage.Instance.DTE.Solution, tagName, src, tagPrefix));
                        }
                    }
                }
            }

            if (parentCommand is BatchMoveCommand)   // no resource references can be directly in the attributes, safe to look only for string literals
            {
                foreach (AttributeInfo info in context.Attributes)
                {
                    if (info.ContainsAspTags)
                    {
                        continue;                       // attribute's value contains &lt;%= - like tags - localization is not desirable
                    }
                    if (info.Name.ToLower() == "language")
                    {
                        continue;
                    }

                    AspNetStringResultItem item = AddResult(info, null, context.DirectiveName, context.WithinClientSideComment, false, false, true);
                    if (item != null)
                    {
                        item.ComesFromDirective = true;
                        item.AttributeName      = info.Name;
                    }
                }
            }
        }
示例#22
0
    private void OnGUI()
    {
        if (!m_WINDOW)
        {
            Init();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        m_Place           = EditorGUILayout.TextField("Place", m_Place);
        m_Version         = EditorGUILayout.FloatField("Asset Version", m_Version, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.8f));
        m_AssetbundleFile = EditorGUILayout.ObjectField("Upload File", m_AssetbundleFile, typeof(object), false, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.8f));
        m_FileType        = (FILETYPE)EditorGUILayout.EnumPopup("File Type", m_FileType, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.8f));

        m_Descript = EditorGUILayout.TextField("Descript", m_Descript, EditorStyles.textArea, GUILayout.Height(30));

        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Thumbnail", GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.25f));
        m_ThumbnailFile = EditorGUILayout.ObjectField("", m_ThumbnailFile, typeof(Texture), false, GUILayout.Width(EditorGUIUtility.currentViewWidth * 0.15f)) as Texture;
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Upload"))
        {
            if (m_ThumbnailFile == null || m_AssetbundleFile == null || m_Place == null)
            {
                Debug.LogError("File is empty");
                return;
            }
            string m_Filetypename = "";
            switch (m_FileType)
            {
            case FILETYPE.ASSETBUNDLE:
                m_Filetypename = ".assetbundle";
                break;

            case FILETYPE.IMAGE360:
                m_Filetypename = ".png";
                break;

            case FILETYPE.VIDEO360:
                m_Filetypename = ".mp4";
                break;
            }
            UploadObject.UploadFile(AssetDatabase.GetAssetPath(m_AssetbundleFile), m_Buckname, m_AssetbundleFile.name + m_Filetypename);
            UploadObject.UploadFile(AssetDatabase.GetAssetPath(m_ThumbnailFile), m_Buckname, m_ThumbnailFile.name + ".png");
            string tmp_Myurl = string.Format(m_Gateway + "?place={0}&type={1}&descript={2}&version={3}&assetName={4}&thumbnailName={5}",
                                             m_Place, m_FileType.ToString(), m_Descript, m_Version, m_AssetbundleFile.name + m_Filetypename, m_ThumbnailFile.name + ".png");
            Debug.Log(tmp_Myurl);
            MyThread tmp_Mythrea = new MyThread(tmp_Myurl);
            Thread   tmp_thread  = new Thread(new ThreadStart(tmp_Mythrea.CreateGetHttpResponse));
            tmp_thread.Start();
        }

        if (GUILayout.Button("Clean"))
        {
            m_Descript        = null;
            m_ThumbnailFile   = null;
            m_AssetbundleFile = null;
            m_Version         = 1;
            m_Place           = null;
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginVertical("WindowBackground");
        m_ShowInfo = EditorGUILayout.Foldout(m_ShowInfo, "Upload info");
        if (m_ShowInfo)
        {
            GUILayout.Label(string.Format("AB Name:{0}", m_AssetbundleFile == null ? "Empty" : m_AssetbundleFile.name));
            GUILayout.Label(string.Format("Thumbnail Name:{0}", m_ThumbnailFile == null ? "Empty" : m_ThumbnailFile.name));
        }
        EditorGUILayout.EndVertical();
        m_WINDOW.Repaint();
    }